|
|
@@ -6158,6 +6158,109 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //合格点数公式
|
|
|
+ if(f.contains(".passingPoints")){
|
|
|
+ //Fc.passingPoints(参数1,参数2,=,参数3,返回类型(1数量,2内容),判定规则同行/同列)
|
|
|
+ Matcher m = RegexUtils.matcher(FC_REG + "(passingPoints)\\(([^)]+)\\)", f);
|
|
|
+ while (m.find()) {
|
|
|
+ String el = m.group();
|
|
|
+ String[] args = m.group(2).split(",");
|
|
|
+ if(args.length == 6){
|
|
|
+ //前进方向一侧
|
|
|
+ List<FormData> fronts = getFormDataByCode(args[0], tec);
|
|
|
+ //相反方向一侧
|
|
|
+ List<FormData> afters = getFormDataByCode(args[1], tec);
|
|
|
+ //统计规则,x 同列,y,同行
|
|
|
+ String arg = args[5];
|
|
|
+ List<Object> data = new ArrayList<>();
|
|
|
+ Map<Integer, List<ElementData>> collect1;
|
|
|
+ Map<Integer, List<ElementData>> collect2;
|
|
|
+ if(CollectionUtil.isNotEmpty(fronts)){
|
|
|
+ List<ElementData> values = fronts.get(0).getValues();
|
|
|
+ //同行还是同列
|
|
|
+ if("x".equals(arg)){
|
|
|
+ collect1 = values.stream().collect(Collectors.groupingBy(ElementData::getX));
|
|
|
+ }else{
|
|
|
+ collect1 = values.stream().collect(Collectors.groupingBy(ElementData::getY));
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ collect1 = null;
|
|
|
+ }
|
|
|
+ if(CollectionUtil.isNotEmpty(afters)){
|
|
|
+ List<ElementData> values = afters.get(0).getValues();
|
|
|
+ if("x".equals(arg)){
|
|
|
+ collect2 = values.stream().collect(Collectors.groupingBy(ElementData::getX));
|
|
|
+ }else{
|
|
|
+ collect2 = values.stream().collect(Collectors.groupingBy(ElementData::getY));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ collect2 = null;
|
|
|
+ }
|
|
|
+ //默认统计数量
|
|
|
+ boolean type;
|
|
|
+ //统计数量
|
|
|
+ if("2".equals(args[4])){
|
|
|
+ type = false;
|
|
|
+ } else {
|
|
|
+ type = true;
|
|
|
+ }
|
|
|
+ fd.getValues().forEach(v -> {
|
|
|
+ long count = 0;
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+
|
|
|
+ //两个数据源都为空
|
|
|
+ boolean isOneFalse = true;
|
|
|
+ boolean isTwoFalse = true;
|
|
|
+ if (collect1 != null) {
|
|
|
+ //根据坐标获取数据
|
|
|
+ List<ElementData> elementData = collect1.get("x".equals(arg) ? v.getX() : v.getY());
|
|
|
+ if(CollectionUtil.isNotEmpty(elementData)){
|
|
|
+
|
|
|
+ List<ElementData> collect = elementData.stream().filter(e -> StringUtils.isNotEmpty(e.getValue())).collect(Collectors.toList());
|
|
|
+ //如果全部参数不为空,统计值
|
|
|
+ if(CollectionUtil.isNotEmpty(collect)){
|
|
|
+ if(type){
|
|
|
+ count += collect.stream().filter(e -> evaluateCondition(e.getValue().toString(), args[2], args[3])).count();
|
|
|
+ }else{
|
|
|
+ list.addAll(collect.stream().map(ElementData::getValue).filter(value -> evaluateCondition(value.toString(), args[2], args[3])).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
+ isOneFalse = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (collect2 != null) {
|
|
|
+ List<ElementData> elementData = collect2.get("x".equals(arg) ? v.getX() : v.getY());
|
|
|
+ if(CollectionUtil.isNotEmpty(elementData)){
|
|
|
+ List<ElementData> collect = elementData.stream().filter(e -> StringUtils.isNotEmpty(e.getValue())).collect(Collectors.toList());
|
|
|
+ if(CollectionUtil.isNotEmpty(collect)){
|
|
|
+ if(type){
|
|
|
+ count += collect.stream().filter(e -> evaluateCondition(e.getValue().toString(), args[2], args[3])).count();
|
|
|
+ }else{
|
|
|
+ list.addAll(collect.stream().map(ElementData::getValue).filter(value -> evaluateCondition(value.toString(), args[2], args[3])).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ isTwoFalse = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果两个组数据都是空的 那么值也设置为空
|
|
|
+ if(isOneFalse && isTwoFalse){
|
|
|
+ data.add("");
|
|
|
+ }else{
|
|
|
+ if(type){
|
|
|
+ data.add(count);
|
|
|
+ }else{
|
|
|
+ data.add(StringUtil.join(list, "、"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ f = f.replace(el, putDataWithKey(data, tec));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
formula.setFormula(f);
|
|
|
if (f.contains("quantity")) {
|
|
|
quantity(formula, fd, f, tec);
|
|
|
@@ -8029,5 +8132,32 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
return wbsTreeContract;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ public boolean evaluateCondition(String value1, String operator, String value2) {
|
|
|
+ try {
|
|
|
+ // 尝试将字符串转换为数字(支持整数和浮点数)
|
|
|
+ double num1 = Double.parseDouble(value1);
|
|
|
+ double num2 = Double.parseDouble(value2);
|
|
|
+
|
|
|
+ switch (operator) {
|
|
|
+ case "=":
|
|
|
+ case "==":
|
|
|
+ return num1 == num2;
|
|
|
+ case ">":
|
|
|
+ return num1 > num2;
|
|
|
+ case "<":
|
|
|
+ return num1 < num2;
|
|
|
+ case ">=":
|
|
|
+ return num1 >= num2;
|
|
|
+ case "<=":
|
|
|
+ return num1 <= num2;
|
|
|
+ case "!=":
|
|
|
+ return num1 != num2;
|
|
|
+ default:
|
|
|
+ throw new IllegalArgumentException("无效的运算符: " + operator);
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ throw new IllegalArgumentException("数值格式错误: " + value1 + " 或 " + value2);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|