当前位置: 首页 > news >正文

淘宝客搜索网站怎么做网上销售

淘宝客搜索网站怎么做,网上销售,三门峡做网站,荆州做网站1. SUMIF函数 SUMIF 函数可用于计算子表单中满足某一条件的数字相加并返回和。 2. 函数用法 SUMIF(range, criteria, [sum_range]) 其中各参数的含义及使用方法如下: range:必需;根据 criteria 的条件规则进行检测的判断字段。支持的字段…

1. SUMIF函数

SUMIF 函数可用于计算子表单中满足某一条件的数字相加并返回和。

2. 函数用法

SUMIF(range, criteria, [sum_range])

其中各参数的含义及使用方法如下:

  • range:必需;根据 criteria 的条件规则进行检测的判断字段。支持的字段包括:子表单中的数字、单行文本、下拉框、单选按钮组;

  • criteria:必需;用于判断的条件规则。支持的形式和使用规则如下表:

支持形式是否需要加引号示例注意事项
数字不需要20、32
表达式需要“>32”、"!=苹果"支持的运算符号包括:>、<、==、!=、>=、<=
文本需要“苹果”、"水果"
字段不需要字段1)在主表字段中使用 SUMIF 函数时,只能选择主表字段2)在子表字段中使用 SUMIF 函数时,只能选择择主表字段和当前子表字段

3. 函数示例

如,计算入库明细中产品类型为「水果」的全部入库数量,则可以在「水果类数量总计」字段设置公式为:

4. 代码实战

首先我们在function包下创建math包,在math包下创建SumIfFunction类,代码如下:

package com.ql.util.express.self.combat.function.math;import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.ql.util.express.Operator;
import com.ql.util.express.self.combat.exception.FormulaException;import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Collectors;/*** 类描述: SUMIF函数** @author admin* @version 1.0.0* @date 2023/11/24 10:33*/
public class SumIfFunction extends Operator {public SumIfFunction(String name) {this.name = name;}@Overridepublic Object executeInner(Object[] lists) throws Exception {//边界判断if (lists.length == 0 || lists.length<3 || lists.length >4) {throw new FormulaException("操作数异常");}BigDecimal res = BigDecimal.ZERO;Object range = null;Object criteria = null;List<Map<String,Object>> subFormVal =null;String rangeS ="";String key = "";if (lists.length == 3) { // 两个参数// 获取参数key = lists[0].toString();range = lists[1];criteria = lists[2];rangeS = range.toString();subFormVal = JSON.parseObject(key,List.class);res = cal(subFormVal,rangeS,criteria.toString(),rangeS);} else {// 三个参数处理Object sumRange = lists[3];key = lists[0].toString();range = lists[1];criteria = lists[2];rangeS = range.toString();subFormVal = JSON.parseObject(key,List.class);// 循环subFormVal集合res = cal(subFormVal,rangeS,criteria.toString(),sumRange.toString());}return res;}// 计算结果private BigDecimal cal(List<Map<String, Object>> list, String range, String criteria, String sumRange) {// criteria判断类型boolean isNum = CriteriaUtil.isNum(criteria);boolean isExpress = CriteriaUtil.isExpress(criteria);// 根据criteria类型 生成PredicateList<Map<String, Object>> collect =null;if (isExpress) {// 如果是表达式// 提取符号String symbol = CriteriaUtil.extractSymbol(criteria);String symbol_value = criteria.replaceAll(symbol,"");boolean sybolValueIsNum = CriteriaUtil.isNum(symbol_value);if (sybolValueIsNum) {// 如果是数字collect = list.stream().filter(paramMap -> {boolean res = false;if ("==".equals(symbol)) {res = Double.parseDouble(paramMap.get(range).toString()) == Double.parseDouble(symbol_value)?true:false;} else if (">".equals(symbol)) {res = Double.parseDouble(paramMap.get(range).toString()) > Double.parseDouble(symbol_value)?true:false;} else if (">=".equals(symbol)) {res = Double.parseDouble(paramMap.get(range).toString()) >= Double.parseDouble(symbol_value)?true:false;} else if ("<".equals(symbol)) {res = Double.parseDouble(paramMap.get(range).toString()) < Double.parseDouble(symbol_value)?true:false;} else if ("<=".equals(symbol)) {res = Double.parseDouble(paramMap.get(range).toString()) <= Double.parseDouble(symbol_value)?true:false;} else if ("!=".equals(symbol)) {res = Double.parseDouble(paramMap.get(range).toString()) != Double.parseDouble(symbol_value)?true:false;}return res;}).collect(Collectors.toList());} else {collect = list.stream().filter(paramMap -> {boolean res = false;if ("==".equals(symbol)) {res = String.valueOf(paramMap.get(range)).equals(symbol_value);} else if ("!=".equals(symbol)) {res = !(String.valueOf(paramMap.get(range)).equals(symbol_value));} else {throw new RuntimeException("字符暂不支持的操作符号为:"+symbol);}return res;}).collect(Collectors.toList());}} else {// 没有表达式 直接默认为==if (isNum) {// 如果是数字collect = list.stream().filter(paramMap -> Double.parseDouble(paramMap.get(range).toString()) == Double.parseDouble(criteria)?true:false).collect(Collectors.toList());} else {collect = list.stream().filter(paramMap -> String.valueOf(paramMap.get(range)).equals(criteria)).collect(Collectors.toList());}}// 满足条件的集合统计出来后,按照sumRange字段统计求和BigDecimal sum = BigDecimal.ZERO;for (Map<String,Object> map:collect) {BigDecimal tmp = new BigDecimal(map.get(sumRange).toString());sum = sum.add(tmp);}return sum;}static class CriteriaUtil {public static boolean isNum (String criteria) {return StrUtil.isNumeric(criteria);}public static boolean isExpress(String criteria) {List<String> symbols = Arrays.asList(">",">=","<","<=","==","!=");boolean res = symbols.stream().anyMatch(s -> criteria.contains(s));return res;}/**** 提取表达式中的符号* @param criteria* @return*/public static String extractSymbol(String criteria) {List<String> symbols = Arrays.asList(">",">=","<","<=","==","!=");final Optional<String> first = symbols.stream().filter(new Predicate<String>() {@Overridepublic boolean test(String s) {return criteria.contains(s);}}).findFirst();return first.get();}}}

把SumIfFunction类注册到公式函数入口类中,代码如下:

package com.ql.util.express.self.combat.ext;import com.ql.util.express.ExpressRunner;
import com.ql.util.express.IExpressResourceLoader;
import com.ql.util.express.parse.NodeTypeManager;
import com.ql.util.express.self.combat.function.logic.*;
import com.ql.util.express.self.combat.function.math.*;/*** 类描述: 仿简道云公式函数实战入口类** @author admin* @version 1.0.0* @date 2023/11/21 15:29*/
public class FormulaRunner extends ExpressRunner {public FormulaRunner() {super();}public FormulaRunner(boolean isPrecise, boolean isTrace) {super(isPrecise,isTrace);}public FormulaRunner(boolean isPrecise, boolean isStrace, NodeTypeManager nodeTypeManager) {super(isPrecise,isStrace,nodeTypeManager);}public FormulaRunner(boolean isPrecise, boolean isTrace, IExpressResourceLoader iExpressResourceLoader, NodeTypeManager nodeTypeManager) {super(isPrecise,isTrace,iExpressResourceLoader,nodeTypeManager);}@Overridepublic void addSystemFunctions() {// ExpressRunner 的内部系统函数super.addSystemFunctions();// 扩展公式函数this.customFunction();}/**** 自定义公式函数*/public void customFunction() {// 逻辑公式函数this.addLogicFunction();// 数学公式函数this.addMathFunction();}public void addLogicFunction() {// AND函数this.addFunction("AND",new AndFunction("AND"));// IF函数this.addFunction("IF",new IfFunction("IF"));// IFS函数this.addFunction("IFS",new IfsFunction("IFS"));// XOR函数this.addFunction("XOR",new XorFunction("XOR"));// TRUE函数this.addFunction("TRUE",new TrueFunction("TRUE"));// FALSE函数this.addFunction("FALSE",new FalseFunction("FALSE"));// NOT函数this.addFunction("NOT",new NotFunction("NOT"));// OR函数this.addFunction("OR",new OrFunction("OR"));}public void addMathFunction() {// ABS函数this.addFunction("ABS",new AbsFunction("ABS"));// AVERAGE函数this.addFunction("AVERAGE",new AvgFunction("AVERAGE"));// CEILING函数this.addFunction("CEILING",new CeilingFunction("CEILING"));// RADIANS函数this.addFunction("RADIANS",new RadiansFunction("RADIANS"));// COS函数this.addFunction("COS",new CosFunction("COS"));// COT函数this.addFunction("COT",new CotFunction("COT"));// COUNT函数this.addFunction("COUNT",new CountFunction("COUNT"));// COUNTIF函数this.addFunction("COUNTIF",new CountIfFunction("COUNTIF"));// FIXED函数this.addFunction("FIXED",new FixedFunction("FIXED"));// FLOOR函数this.addFunction("FLOOR",new FloorFunction("FLOOR"));// INT函数this.addFunction("INT",new IntFunction("INT"));// LARGE函数this.addFunction("LARGE",new LargeFunction("LARGE"));// LOG函数this.addFunction("LOG",new LogFunction("LOG"));// MAX函数this.addFunction("MAX",new MaxFunction("MAX"));// MIN函数this.addFunction("MIN",new MinFunction("MIN"));// MOD函数this.addFunction("MOD",new ModFunction("MOD"));// POWER函数this.addFunction("POWER",new PowerFunction("POWER"));// PRODUCT函数this.addFunction("PRODUCT",new ProductFunction("PRODUCT"));// RAND函数this.addFunction("RAND",new RandFunction("RAND"));// ROUND函数this.addFunction("ROUND",new RoundFunction("ROUND"));// SIN函数this.addFunction("SIN",new SinFunction("SIN"));// SMALL函数this.addFunction("SMALL",new SmallFunction("SMALL"));// SQRT函数this.addFunction("SQRT",new SqrtFunction("SQRT"));// SUM函数this.addFunction("SUM",new SumFunction("SUM"));// SUMIF函数this.addFunction("SUMIF",new SumIfFunction("SUMIF"));}
}

创建测试用例

package com.ql.util.express.self.combat;import com.alibaba.fastjson.JSON;
import com.ql.util.express.DefaultContext;
import com.ql.util.express.self.combat.ext.FormulaRunner;
import org.junit.Test;import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;/*** 类描述: 实战测试类** @author admin* @version 1.0.0* @date 2023/11/21 15:45*/
public class CombatTest {@Testpublic void SUMIF() throws Exception{FormulaRunner formulaRunner = new FormulaRunner(true,true);// 创建上下文DefaultContext<String, Object> context = new DefaultContext<>();List<Map<String,Object>> list = new ArrayList<>();Map<String,Object> map = new HashMap<>();map.put("record.type","红富士");map.put("record.name","苹果");map.put("record.num",20.0);Map<String,Object> map2 = new HashMap<>();map2.put("record.type","红富士");map2.put("record.name","苹果");map2.put("record.num",42.0);Map<String,Object> map3 = new HashMap<>();map3.put("record.type","红星");map3.put("record.name","苹果");map3.put("record.num",30.0);Map<String,Object> map4 = new HashMap<>();map4.put("record.type","美国");map4.put("record.name","苹果");map4.put("record.num",13000.0);Map<String,Object> map5 = new HashMap<>();map5.put("record.type","夏黑");map5.put("record.name","葡萄");map5.put("record.num",15);Map<String,Object> map6 = new HashMap<>();map6.put("record.type","阳光玫瑰");map6.put("record.name","葡萄");map6.put("record.num",30);Map<String,Object> map7 = new HashMap<>();map7.put("record.type","芝麻蕉");map7.put("record.name","香蕉");map7.put("record.num","20");list.add(map);list.add(map2);list.add(map3);list.add(map4);list.add(map5);list.add(map6);list.add(map7);String s = JSON.toJSONString(list);String express = "SUMIF(aa,bb,cc,dd)";context.put("aa",s);context.put("bb","record.type");context.put("cc","!=美国");context.put("dd","record.num");Object object = formulaRunner.execute(express, context, null, true, true);System.out.println(object);}}

运行结果


文章转载自:
http://demurrable.c7493.cn
http://alban.c7493.cn
http://coherence.c7493.cn
http://santy.c7493.cn
http://spherometer.c7493.cn
http://upswing.c7493.cn
http://parapodium.c7493.cn
http://symposia.c7493.cn
http://miseducation.c7493.cn
http://floccule.c7493.cn
http://zoologize.c7493.cn
http://week.c7493.cn
http://intel.c7493.cn
http://hematal.c7493.cn
http://kyd.c7493.cn
http://mentor.c7493.cn
http://roadhouse.c7493.cn
http://noetic.c7493.cn
http://overspend.c7493.cn
http://sponsor.c7493.cn
http://elijah.c7493.cn
http://assuring.c7493.cn
http://bola.c7493.cn
http://penologist.c7493.cn
http://tpn.c7493.cn
http://anymore.c7493.cn
http://grumous.c7493.cn
http://dnis.c7493.cn
http://vizcacha.c7493.cn
http://exhibiter.c7493.cn
http://pedicel.c7493.cn
http://petrotectonics.c7493.cn
http://lipotropic.c7493.cn
http://fenderboard.c7493.cn
http://scrollhead.c7493.cn
http://hydroquinone.c7493.cn
http://illegalize.c7493.cn
http://moisture.c7493.cn
http://critic.c7493.cn
http://supercluster.c7493.cn
http://tile.c7493.cn
http://narrows.c7493.cn
http://hesione.c7493.cn
http://facile.c7493.cn
http://skeletal.c7493.cn
http://evergreen.c7493.cn
http://kemalist.c7493.cn
http://spode.c7493.cn
http://estanciero.c7493.cn
http://rochet.c7493.cn
http://agroindustrial.c7493.cn
http://tumbledown.c7493.cn
http://lipomatous.c7493.cn
http://runch.c7493.cn
http://monosaccharide.c7493.cn
http://rondeau.c7493.cn
http://coyness.c7493.cn
http://rebukeful.c7493.cn
http://procession.c7493.cn
http://whifflow.c7493.cn
http://unkink.c7493.cn
http://rogue.c7493.cn
http://epichorial.c7493.cn
http://ensnare.c7493.cn
http://aecidiospore.c7493.cn
http://rencontre.c7493.cn
http://unredeemed.c7493.cn
http://bibliolatry.c7493.cn
http://scam.c7493.cn
http://ankylostomiasis.c7493.cn
http://nacala.c7493.cn
http://aral.c7493.cn
http://tandem.c7493.cn
http://gms.c7493.cn
http://karyotheca.c7493.cn
http://ergotoxine.c7493.cn
http://procurator.c7493.cn
http://trigo.c7493.cn
http://fdr.c7493.cn
http://adventist.c7493.cn
http://wo.c7493.cn
http://liturgy.c7493.cn
http://jocosely.c7493.cn
http://fellable.c7493.cn
http://boatage.c7493.cn
http://collocutor.c7493.cn
http://audiocassette.c7493.cn
http://mwt.c7493.cn
http://pelisse.c7493.cn
http://eke.c7493.cn
http://kantianism.c7493.cn
http://remonstrator.c7493.cn
http://edta.c7493.cn
http://southwest.c7493.cn
http://biracial.c7493.cn
http://lahore.c7493.cn
http://drummer.c7493.cn
http://cgmp.c7493.cn
http://dropped.c7493.cn
http://byword.c7493.cn
http://www.zhongyajixie.com/news/77029.html

相关文章:

  • 网站设计主题湖南网站建设推广
  • 网站日志状态码网站展示型推广
  • 做网站吉林百度推广开户多少钱
  • 查看网站外链山东泰安网络推广
  • 夏天做那些网站致富天津seo排名
  • 怎么查网站死链在线咨询
  • 餐饮网站 设计人工智能培训课程
  • 黄石网站建设娱乐热搜榜今日排名
  • 软件外包公司能去吗seo优化推荐
  • 网站设计专业建站公司今日最新重大新闻
  • 做医疗的网站营销培训方案
  • 《小城镇建设》》杂志社网站2022当下社会热点话题
  • dede免费模板教育网站sem全称
  • 北京建设委员会官方网站简阳seo排名优化课程
  • 3g网站建设郑州seo优化哪家好
  • 凡科网商城seo是什么意思的缩写
  • 做游戏网站用什么系统做在线工具
  • 猎头自己在哪个网站做单佛山优化网站关键词
  • 做编程网站有哪些内容seo大全
  • 成都 企业 网站制作百度广告登录入口
  • 番禺做网站800元上海网站建设联系方式
  • 免费网站模板建站长春网站建设
  • 网站项目规划与设计it教育培训机构排名
  • 手机网站导航页东营网站建设制作
  • html5动态网站模板海外短视频跨境电商平台是真的吗
  • 百度云wordpress怎么搭建官网优化哪家专业
  • 工信部企业网站备案吗网站关键词搜索
  • 大流量ip网站怎么做网络服务有限公司
  • 网站的备案号网站优化 seo和sem
  • 渭南中学校园网站建设工作汇报网站测速工具