|
@@ -216,6 +216,15 @@ public class FormulaController {
|
|
|
String rely = StringUtils.handleNull(map.get("rely"));
|
|
|
FormulaBean fb = BeanUtil.toBean(map, FormulaBean.class);
|
|
|
fb.setDict(this.service.getElementInfoByCodes(rely));
|
|
|
+ //多重if重新组装参数
|
|
|
+ String formula = fb.getFormula();
|
|
|
+ if(formula.contains(".ifelseMulti")){
|
|
|
+ //处理数据
|
|
|
+ formula = formula.replaceFirst("FC.ifelseMulti","");
|
|
|
+ List<FormulaMultipleIf> formulaMultipleIfs = new ArrayList<>();
|
|
|
+ strParse(formula,formulaMultipleIfs);
|
|
|
+ fb.setFormulas(formulaMultipleIfs);
|
|
|
+ }
|
|
|
return R.data(fb);
|
|
|
}
|
|
|
|
|
@@ -223,6 +232,100 @@ public class FormulaController {
|
|
|
return R.success("无数据");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private Boolean strParse(String str, List<FormulaMultipleIf> formulaMultipleIfs){
|
|
|
+ str = str.replaceFirst("\\(","").replaceFirst("\\)$","");
|
|
|
+ FormulaMultipleIf formulaMultipleIf = new FormulaMultipleIf();
|
|
|
+ List<String> split = parseParameters(str);
|
|
|
+ if(split.size() == 3){
|
|
|
+ List<FormulaIfElse> formulaIfElses = new ArrayList<>();
|
|
|
+ String s0 = split.get(0);
|
|
|
+ String s1 = split.get(1);
|
|
|
+ String s2 = split.get(2);
|
|
|
+ //处理 判断体 E[m_20220826103001_1562990720141230080:key_40]=2
|
|
|
+ String[] split1 = null;
|
|
|
+ String groupSymbol = null;
|
|
|
+ if(s0.contains("||") || s0.contains("&&")){
|
|
|
+
|
|
|
+
|
|
|
+ if(s0.contains("||")){
|
|
|
+ split1 = s0.split("\\|\\|");
|
|
|
+ groupSymbol = "||";
|
|
|
+ }else{
|
|
|
+ split1 = s0.split("&&");
|
|
|
+ groupSymbol = "&&";
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ split1 = new String[]{s0};
|
|
|
+ }
|
|
|
+ for (String s : split1) {
|
|
|
+ FormulaIfElse formulaIfElse = new FormulaIfElse();
|
|
|
+ String s3 = strContainsSymbol(s);
|
|
|
+ if(!s3.isEmpty()){
|
|
|
+ String[] split2 = s.split(s3);
|
|
|
+ formulaIfElse.setParameter1(split2[0]);
|
|
|
+ formulaIfElse.setSymbol(s3);
|
|
|
+ formulaIfElse.setParameter2(split2[1]);
|
|
|
+ formulaIfElse.setGroupTerm(groupSymbol);
|
|
|
+ formulaIfElses.add(formulaIfElse);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ formulaMultipleIf.setFormulaIfElse(formulaIfElses);
|
|
|
+ formulaMultipleIf.setTrueData(s1);
|
|
|
+ if(s2.contains("(")){
|
|
|
+ formulaMultipleIfs.add(formulaMultipleIf);
|
|
|
+ Boolean b = strParse(s2, formulaMultipleIfs);
|
|
|
+ if(!b){
|
|
|
+ formulaMultipleIf.setFalseData(s2);
|
|
|
+ formulaMultipleIfs.add(formulaMultipleIf);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ formulaMultipleIf.setFalseData(s2);
|
|
|
+ formulaMultipleIfs.add(formulaMultipleIf);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ public String strContainsSymbol(String str){
|
|
|
+ String s = null;
|
|
|
+ if(str.contains(">=")){
|
|
|
+ s = ">=";
|
|
|
+ }else if (str.contains("<=")){
|
|
|
+ s = "<=";
|
|
|
+ }else if (str.contains(">") && !str.contains("=")){
|
|
|
+ s = ">";
|
|
|
+ }else if (str.contains("<") && !str.contains("=")){
|
|
|
+ s = "<";
|
|
|
+ }else if (str.contains("=")){
|
|
|
+ s = "=";
|
|
|
+ }
|
|
|
+ return s;
|
|
|
+ }
|
|
|
+ // 添加参数解析方法,处理嵌套逗号
|
|
|
+ private List<String> parseParameters(String content) {
|
|
|
+ List<String> params = new ArrayList<>();
|
|
|
+ int depth = 0;
|
|
|
+ int start = 0;
|
|
|
+
|
|
|
+ for (int i = 0; i < content.length(); i++) {
|
|
|
+ char c = content.charAt(i);
|
|
|
+ if (c == '(') {
|
|
|
+ depth++;
|
|
|
+ } else if (c == ')') {
|
|
|
+ depth--;
|
|
|
+ } else if (c == ',' && depth == 0) {
|
|
|
+ // 只有在最外层才分割参数
|
|
|
+ params.add(content.substring(start, i).trim());
|
|
|
+ start = i + 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 添加最后一个参数
|
|
|
+ params.add(content.substring(start).trim());
|
|
|
+
|
|
|
+ return params;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperationSupport(order = 8)
|
|
|
@ApiOperation(value = "公式翻页查询", notes = "公式翻页查询")
|
|
|
@GetMapping("/page")
|