Просмотр исходного кода

优化公式说明源数据和结果

lvy 1 неделя назад
Родитель
Сommit
cf6c3fd13f

+ 17 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1423,7 +1423,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         result.put("tableName", name.length() == 0 ? "" :  name.deleteCharAt(name.length() - 1).toString());
         result.put("elementName", elementName.length() == 0 ? "" : elementName.deleteCharAt(elementName.length() - 1).toString());
         result.put("type", type == 0 ? "计算" : "数据获取");
-        result.put("data", data.length() == 0 ? "" : data.deleteCharAt(data.length() - 1).toString());
+        String sourceData = data.length() == 0 ? "" : data.deleteCharAt(data.length() - 1).toString();
         String resultData = "";
         try {
             resultData = tableInfoList.get(0).getDataMap().get(split1[0]);
@@ -1436,18 +1436,30 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         resultData = string.split("_\\^_")[0];
                         String[] split2 = data.toString().split("☆");
                         if (i < split2.length) {
-                            result.put("data", split2[i].split("_\\^_")[0]);
+                            sourceData = split2[i].split("_\\^_")[0];
                         }
                         break;
                     }
                 }
             }
             resultData = resultData.replaceAll("(\" *)","");
-            result.put("data", result.get("data").replaceAll("(\" *)",""));
-            result.put("result", resultData);
         } catch (Exception e) {
-            result.put("result", resultData);
+            log.error("公式计算异常:" + e.getMessage());
         }
+        if (resultData != null) {
+            resultData = resultData.replaceAll("(_\\^_\\d+_\\d+☆?)",",");
+            if (resultData.charAt(resultData.length() - 1) == ',') {
+                resultData = resultData.substring(0, resultData.length() - 1);
+            }
+        }
+        if (sourceData != null) {
+            sourceData = sourceData.replaceAll("(\" *)","").replaceAll("(_\\^_\\d+_\\d+☆?)",",");
+            if (sourceData.charAt(sourceData.length() - 1) == ',') {
+                sourceData = sourceData.substring(0, sourceData.length() - 1);
+            }
+        }
+        result.put("data", sourceData);
+        result.put("result", resultData);
 
 
         return result;