Browse Source

解决公式说明复制表获取数据和计算错误的问题

lvy 14 hours ago
parent
commit
917cea6efc

+ 6 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1269,7 +1269,11 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
 
         // 所有
         List<KeyMapper> keyMappers = formulaService.getKeyMapperList(tableAll.stream().map(NodeTable::getPKeyId).collect(Collectors.toList()), wbsTreeTable.getProjectId(), wbsTreeTable.getPId() + "", ExecuteType.INSPECTION, null);
-        Map<String, KeyMapper> keyMapperMap = keyMappers.stream().collect(toMap(KeyMapper::getCode, e -> e, (a, b) -> a));
+        Map<String, KeyMapper> keyMapperMap = keyMappers.stream().collect(toMap(KeyMapper::getCode, e -> e, (a, b) -> {
+            if (Objects.equals(a.getPkId(), wbsTreeTable.getPKeyId())) return a;
+            if (Objects.equals(b.getPkId(), wbsTreeTable.getPKeyId())) return b;
+            return a;
+        }));
 
         List<Formula> formulas = this.formulaService.getFormulaList(keyMappers);
         Map<Long, Formula> formulaMap = formulas.stream().collect(toMap(Formula::getId, e -> e, (a, b) -> a));
@@ -1300,7 +1304,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         {
             List<String> relyList = formula.getRelyList();
             String fc = formula.getFormula();
-            if (fc != null && fc.startsWith("E[") && !fc.matches("\\+-*/%")) {
+            if (fc != null && fc.startsWith("E[") && !fc.matches(".*(\\+-\\*/%).*")) {
                 type = 1;
             }
             if (relyList ==  null || relyList.isEmpty()) {