|
|
@@ -1371,20 +1371,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
Long projectId = Long.parseLong(wtc.getProjectId());
|
|
|
|
|
|
StringBuilder data = new StringBuilder();
|
|
|
- for (TableInfo tableInfo : tableInfoList) {
|
|
|
- if (pKeyIds.toString().contains(tableInfo.getPkeyId())) {
|
|
|
- LinkedHashMap<String, String> dataMap = tableInfo.getDataMap();
|
|
|
- List<String> keys = pKeyIdKeyMap.get(tableInfo.getPkeyId());
|
|
|
- if (dataMap != null && keys != null) {
|
|
|
- for (String key : keys) {
|
|
|
- String value = dataMap.get(key);
|
|
|
- if (StringUtil.hasText(value)) {
|
|
|
- data.append(value).append(",");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ String resultData = "";
|
|
|
|
|
|
if (currentNode != null) {
|
|
|
TableElementConverter tec = new TableElementConverter(tableInfoList, keyMapperList, formulaList, coordinateMap, currentNode, tableAll);
|
|
|
@@ -1397,7 +1384,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
tec.before();
|
|
|
// 暂不执行特殊公式
|
|
|
this.formulaService.init(tec).sort(tec).pre(tec).calculate(tec).format(tec);
|
|
|
- tec.after();
|
|
|
} else {
|
|
|
tec.getLog().put(FormulaLog.OTHER, "没有执行任何公式");
|
|
|
}
|
|
|
@@ -1405,12 +1391,38 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
if (data.length() == 0) {
|
|
|
Map<String, FormData> map = tec.getFormDataMap();
|
|
|
List<String> relyList = formula.getRelyList();
|
|
|
- if (relyList != null) {
|
|
|
+ FormData resultFormData = map.get(wbsTreeTable.getInitTableName() + ":" + split1[0]);
|
|
|
+ int index = 0;
|
|
|
+ if (resultFormData != null && resultFormData.getValues() != null) {
|
|
|
+ List<ElementData> values = resultFormData.getValues();
|
|
|
+ int x = 0, y = 0;
|
|
|
+ if (split1.length > 1 && split1[1].contains("_")) {
|
|
|
+ String[] point = split1[1].split("_");
|
|
|
+ try {
|
|
|
+ y = Integer.parseInt(point[0]);
|
|
|
+ x = Integer.parseInt(point[1]);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ log.error("坐标转换错误,keyname = " + keyname);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int i = 0; i < values.size(); i++) {
|
|
|
+ if (values.get(i).getY() == y && values.get(i).getX() == x) {
|
|
|
+ resultData = (String)values.get(i).getValue();
|
|
|
+ index = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtil.hasText(resultData) && relyList != null) {
|
|
|
+ int tempIndex = index;
|
|
|
relyList.forEach(rely -> {
|
|
|
FormData formData = map.get(rely);
|
|
|
if (formData != null && formData.getValues() != null) {
|
|
|
- String value = formData.getValues().stream().map(ElementData::getValue).filter(Objects::nonNull).map(Objects::toString).collect(Collectors.joining(","));
|
|
|
- data.append(value).append( "☆");
|
|
|
+ if (formData.getValues().size() > tempIndex) {
|
|
|
+ ElementData elementData = formData.getValues().get(tempIndex);
|
|
|
+ data.append(elementData == null || elementData.getValue() == null ? "" : elementData.getValue().toString());
|
|
|
+ }
|
|
|
+ data.append(" ,");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -1424,31 +1436,30 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
result.put("elementName", elementName.length() == 0 ? "" : elementName.deleteCharAt(elementName.length() - 1).toString());
|
|
|
result.put("type", type == 0 ? "计算" : "数据获取");
|
|
|
String sourceData = data.length() == 0 ? "" : data.deleteCharAt(data.length() - 1).toString();
|
|
|
- String resultData = "";
|
|
|
- try {
|
|
|
- resultData = tableInfoList.get(0).getDataMap().get(split1[0]);
|
|
|
- if (split1.length > 1) {
|
|
|
- String index = split1[1];
|
|
|
- String[] split = resultData.split("☆");
|
|
|
- if (split.length > 1) {
|
|
|
- resultData = "";
|
|
|
- }
|
|
|
- for (int i = 0; i < split.length; i++) {
|
|
|
- String string = split[i];
|
|
|
- if (string.contains(index)) {
|
|
|
- resultData = string.split("_\\^_")[0];
|
|
|
- String[] split2 = data.toString().split("☆");
|
|
|
- if (i < split2.length) {
|
|
|
- sourceData = split2[i].split("_\\^_")[0];
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- resultData = resultData.replaceAll("(\" *)","");
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("公式计算异常:" + e.getMessage());
|
|
|
- }
|
|
|
+// try {
|
|
|
+// resultData = tableInfoList.get(0).getDataMap().get(split1[0]);
|
|
|
+// if (split1.length > 1) {
|
|
|
+// String index = split1[1];
|
|
|
+// String[] split = resultData.split("☆");
|
|
|
+// if (split.length > 1) {
|
|
|
+// resultData = "";
|
|
|
+// }
|
|
|
+// for (int i = 0; i < split.length; i++) {
|
|
|
+// String string = split[i];
|
|
|
+// if (string.contains(index)) {
|
|
|
+// resultData = string.split("_\\^_")[0];
|
|
|
+// String[] split2 = data.toString().split("☆");
|
|
|
+// if (i < split2.length) {
|
|
|
+// sourceData = split2[i].split("_\\^_")[0];
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// resultData = resultData.replaceAll("(\" *)","");
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("公式计算异常:" + e.getMessage());
|
|
|
+// }
|
|
|
if (resultData != null) {
|
|
|
resultData = resultData.replaceAll("(_\\^_\\d+_\\d+☆?)",",");
|
|
|
if (!resultData.isEmpty() && resultData.charAt(resultData.length() - 1) == ',') {
|
|
|
@@ -1456,6 +1467,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
}
|
|
|
if (sourceData != null) {
|
|
|
+ if (resultData == null || resultData.isEmpty()) {
|
|
|
+ sourceData = "";
|
|
|
+ }
|
|
|
sourceData = sourceData.replaceAll("(\" *)","").replaceAll("(_\\^_\\d+_\\d+☆?)",",");
|
|
|
if (!sourceData.isEmpty() && sourceData.charAt(sourceData.length() - 1) == ',') {
|
|
|
sourceData = sourceData.substring(0, sourceData.length() - 1);
|