|
@@ -73,8 +73,13 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
**/
|
|
|
@Override
|
|
|
public void execute(List<FormData> list ,Long contractId,Long primaryKeyId){
|
|
|
- /*初始化变量>>依赖排序>>预处理>>特殊公式>>通用公式执行*/
|
|
|
- this.init(list,contractId,primaryKeyId).sort().pre().special().calculate();
|
|
|
+ /*初始化变量>>依赖排序>>预处理>>特殊公式>>通用公式执行>>数据格式化*/
|
|
|
+ this.init(list,contractId,primaryKeyId)
|
|
|
+ .sort()
|
|
|
+ .pre()
|
|
|
+ .special()
|
|
|
+ .calculate()
|
|
|
+ .format();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -218,8 +223,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
fd.getValues().add(new ElementData(0,0,Expression.parse(formula.getFormula()).calculate(currentMap)));
|
|
|
}
|
|
|
}
|
|
|
- if(fd.getValues().size()>0&&cp.size()!=fd.getValues().size()){
|
|
|
- /*往后还要判断是否更新*/
|
|
|
+ if(notEquals(cp,fd.getValues())){
|
|
|
+ /*数量不相等*/
|
|
|
fd.setUpdate(1);
|
|
|
}
|
|
|
}
|
|
@@ -227,6 +232,19 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ /**对比内容再觉得是否刷新,如果允许牺牲部分性能,也可以不做判断进行全部刷新*/
|
|
|
+ public boolean notEquals(List<ElementData> old,List<ElementData> enw){
|
|
|
+ List<Object> a=old.stream().map(ElementData::getValue).collect(Collectors.toList());
|
|
|
+ List<Object> b=enw.stream().map(ElementData::getValue).collect(Collectors.toList());
|
|
|
+ if(a.size()!=b.size()){
|
|
|
+ return true;
|
|
|
+ }else if(!a.containsAll(b)){
|
|
|
+ return true;
|
|
|
+ }else {
|
|
|
+ return !a.stream().map(Func::toStr).collect(Collectors.joining()).equals(b.stream().map(Func::toStr).collect(Collectors.joining()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void format() {
|
|
|
for(FormData fd:this.env.formDataList){
|
|
@@ -351,7 +369,9 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
Map<String, Object> E = getMap(currentMap, "E");
|
|
|
tmp.forEach(e -> E.put(e.getCode(), e.getValues().stream().map(ElementData::getValue).collect(Collectors.toList())));
|
|
|
Object data = Expression.parse(CustomFunction.CLASS_CALL + m.group()).calculate(currentMap);
|
|
|
- f = f.replace(CustomFunction.CLASS_CALL + m.group(), data.toString());
|
|
|
+ data=StringUtils.number2String(data,StringUtils.getScale(data));
|
|
|
+ /*必须要用括号套壳,不然无法处理负数*/
|
|
|
+ f = f.replace(CustomFunction.CLASS_CALL + m.group(), "("+data.toString()+")");
|
|
|
fd.getFormula().setFormula(f);
|
|
|
}
|
|
|
}
|