|
@@ -68,7 +68,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
public static final Pattern AP=Pattern.compile("(E|WP)\\[([^]]+)]");
|
|
|
|
|
|
public static final String IF_REG= "(?<=T\\(com.mixsmart.utils.CustomFunction\\).ifelse\\()[^,]+(?=,)";
|
|
|
- public static final Pattern IF = Pattern.compile(IF_REG);
|
|
|
+ public static final Pattern IF = Pattern.compile(IF_REG);
|
|
|
|
|
|
public static final String ELE_CODE_REG= "(?<=E\\[)[^]]+(?=\\])";
|
|
|
public static final Pattern P = Pattern.compile(ELE_CODE_REG);
|
|
@@ -94,7 +94,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
this.tec=tec;
|
|
|
/*初始化变量>>依赖排序>>预处理>>特殊公式>>通用公式执行>>数据格式化*/
|
|
|
this.init().sort().pre().special().calculate().format();
|
|
|
- // WbsTreeContract one= this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,tec.getNodeId()));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -440,7 +439,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
int min =0;
|
|
|
List<Object> result = new ArrayList<>();
|
|
|
try {
|
|
|
- /*并发执行*/
|
|
|
List<Object> r= local.stream().map(e-> Expression.parse(e.getFormula()).calculate(e.getCurrentMap())).collect(Collectors.toList());
|
|
|
if(CollectionUtil.isNotEmpty(r)&&r.stream().anyMatch(StringUtils::isNotEmpty)){
|
|
|
result.addAll(r);
|
|
@@ -582,6 +580,33 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ public void batch(){
|
|
|
+ List<Map<String,Object>> list = this.jdbcTemplate.queryForList("select id,formula from m_formula where (formula like '%reasonable%' or formula like '%proportion%' or formula like '%goodSize%')");
|
|
|
+ if(ListUtils.isNotEmpty(list)){
|
|
|
+ Pattern p = Pattern.compile("^FC\\.(\\w+)\\(([^()]+)\\)");
|
|
|
+ for (Map<String,Object>map:list){
|
|
|
+ Long ident = (Long) map.get("id");
|
|
|
+ String formula = (String) map.get("formula");
|
|
|
+ Matcher m= p.matcher(formula);
|
|
|
+ if(m.find()){
|
|
|
+ String change=m.group(2);
|
|
|
+ String fn=m.group(1);
|
|
|
+ List<String> args=Arrays.stream(change.split(",")).collect(Collectors.toList());
|
|
|
+ if(args.size()<18){
|
|
|
+ args.addAll(Collections.nCopies(18-args.size(),"''"));
|
|
|
+ System.out.println("原:"+formula);
|
|
|
+ String newformula=("FC."+fn+"("+String.join(",",args)+")");
|
|
|
+ System.out.println("改:"+newformula);
|
|
|
+ this.update(Wrappers.<Formula>lambdaUpdate().set(Formula::getFormula,newformula).eq(Formula::getId,ident));
|
|
|
+ // this.jdbcTemplate.update("update m_formula set formula ='"+newformula+"' where id="+ident);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|