|
@@ -1787,7 +1787,6 @@ public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo) {
|
|
|
|
|
|
/*获取元素表数据*/
|
|
|
Map<Long, Map<String, Object>> colMaps = new HashMap<>();
|
|
|
- Map<Long, String> colMap = new HashMap<>();
|
|
|
//是否需要复制数据
|
|
|
if (vo.getIsCopyData() == 1) {
|
|
|
//表名集合
|
|
@@ -1827,23 +1826,21 @@ public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo) {
|
|
|
List<WbsTreeContract> tabs = tabsGroup.get(tabName);
|
|
|
for (WbsTreeContract tab : tabs) {
|
|
|
//根据字段
|
|
|
-// String dataSql = "SELECT " + keys + " FROM " + tabName + " WHERE p_key_id = " + tab.getPKeyId() + " LIMIT 1;";
|
|
|
-// try {
|
|
|
-// //查询指定表指定表节点的数据
|
|
|
-// Map<String, Object> resultMap = jdbcTemplate.queryForMap(dataSql);
|
|
|
-// //删除空值
|
|
|
-// resultMap.values().removeIf(value -> value == null || (value instanceof String && ObjectUtil.isEmpty(value)));
|
|
|
-// colMaps.put(tab.getPKeyId(), resultMap);
|
|
|
-// } catch (EmptyResultDataAccessException e) {
|
|
|
-// continuePkeyIds.add(tab.getPKeyId());
|
|
|
-// }
|
|
|
- colMap.put(tab.getPKeyId(), keys);
|
|
|
+ String dataSql = "SELECT " + keys + " FROM " + tabName + " WHERE p_key_id = " + tab.getPKeyId() + " LIMIT 1;";
|
|
|
+ try {
|
|
|
+ //查询指定表指定表节点的数据
|
|
|
+ Map<String, Object> resultMap = jdbcTemplate.queryForMap(dataSql);
|
|
|
+ //删除空值
|
|
|
+ resultMap.values().removeIf(value -> value == null || (value instanceof String && ObjectUtil.isEmpty(value)));
|
|
|
+ colMaps.put(tab.getPKeyId(), resultMap);
|
|
|
+ } catch (EmptyResultDataAccessException e) {
|
|
|
+ continuePkeyIds.add(tab.getPKeyId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
logger.info("以下元素表没有获取到对应实体表数据,已跳过 ===> 表pKeyId:[{}]", StringUtils.join(continuePkeyIds, ","));
|
|
|
}
|
|
|
// 节点+表节点
|
|
|
- List<WbsTreeContract> wbsParamAndLedgerList = new ArrayList<>();
|
|
|
for (WbsTreeContract nodeOld : nodeChildAll) {
|
|
|
//新节点
|
|
|
WbsTreeContract newData = new WbsTreeContract();
|
|
@@ -1854,18 +1851,15 @@ public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo) {
|
|
|
if (nodeOld.getNodeType() != null && nodeOld.getNodeType() == 6) {
|
|
|
//新旧节点关联关系
|
|
|
peerMap.put(newData.getPKeyId(), nodeOld.getPKeyId());
|
|
|
-// //复制节点命名配置
|
|
|
-// //查询节点绑定的公共配置 文件提名信息
|
|
|
-// WbsParam wbsParam = wbsParamClient.getWbsParam(Long.parseLong(vo.getNeedCopyPrimaryKeyId()));
|
|
|
-// if(wbsParam!=null){
|
|
|
-// wbsParam.setId(SnowFlakeUtil.getId());
|
|
|
-// wbsParam.setNodeId(newData.getPKeyId());
|
|
|
-// //给复制的节点绑定的公共配置
|
|
|
-// wbsParamClient.saveWbsParam(wbsParam);
|
|
|
-// }
|
|
|
-// /*生成工序节点施工日志*/
|
|
|
-// this.createLedger(newData, saveLedger, nodeMap, null);
|
|
|
- wbsParamAndLedgerList.add(newData);
|
|
|
+ //复制节点命名配置
|
|
|
+ //查询节点绑定的公共配置 文件提名信息
|
|
|
+ WbsParam wbsParam = wbsParamClient.getWbsParam(Long.parseLong(vo.getNeedCopyPrimaryKeyId()));
|
|
|
+ if(wbsParam!=null){
|
|
|
+ wbsParam.setId(SnowFlakeUtil.getId());
|
|
|
+ wbsParam.setNodeId(newData.getPKeyId());
|
|
|
+ //给复制的节点绑定的公共配置
|
|
|
+ wbsParamClient.saveWbsParam(wbsParam);
|
|
|
+ }
|
|
|
}
|
|
|
//源节点是否为复制节点 如果是则设置源节点的源节点 如何不是设置源节点id
|
|
|
if (StringUtils.isNotEmpty(nodeOld.getOldId())) {
|
|
@@ -1910,9 +1904,9 @@ public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo) {
|
|
|
saveList.add(newData);
|
|
|
|
|
|
/*生成工序节点施工日志*/
|
|
|
-// if (new Integer("6").equals(nodeOld.getNodeType())) {
|
|
|
-// this.createLedger(newData, saveLedger, nodeMap, null);
|
|
|
-// }
|
|
|
+ if (new Integer("6").equals(nodeOld.getNodeType())) {
|
|
|
+ this.createLedger(newData, saveLedger, nodeMap, null);
|
|
|
+ }
|
|
|
|
|
|
/*处理复制表数据*/
|
|
|
if (nodeOld.getType() == 2 && vo.getIsCopyData() == 1
|
|
@@ -1920,101 +1914,64 @@ public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo) {
|
|
|
&& tabOwner.contains(nodeOld.getTableOwner())) {
|
|
|
|
|
|
/*获取表对应的实体数据*/
|
|
|
-// Map<String, Object> resultMap = colMaps.getOrDefault(nodeOld.getPKeyId(), null);
|
|
|
-// if (resultMap == null) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
- String keys = colMap.getOrDefault(nodeOld.getPKeyId(), null);
|
|
|
- if (keys == null || keys.isEmpty()) {
|
|
|
+ Map<String, Object> resultMap = colMaps.getOrDefault(nodeOld.getPKeyId(), null);
|
|
|
+ if (resultMap == null) {
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
/*重置*/
|
|
|
-// Map<String, String> eMap = reviseValue(nodeOld, null, ekvMap);
|
|
|
+ Map<String, String> eMap = reviseValue(nodeOld, null, ekvMap);
|
|
|
|
|
|
/*构造复制表数据*/
|
|
|
-// StringBuilder newString = new StringBuilder();
|
|
|
-// List<String> keySet = new LinkedList<>();
|
|
|
-// for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
|
|
|
-// keySet.add(entry.getKey());
|
|
|
-// Object value = reviseValue(eMap, entry.getKey(), entry.getValue());
|
|
|
-// if (value != null) {
|
|
|
-// if (value.toString().contains("\n")) {
|
|
|
-// value = value.toString().replace("\n", "\\n");
|
|
|
-// }
|
|
|
-// newString.append("'").append(value).append("',");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (newString.length() > 0) {
|
|
|
-// newString.insert(0, ',');
|
|
|
-// if (newString.charAt(newString.length() - 1) == ',') {
|
|
|
-// newString.deleteCharAt(newString.length() - 1);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// String keysHaveValue = StringUtils.join(keySet, ",");
|
|
|
-// if (keysHaveValue.length() > 0) {
|
|
|
-// keysHaveValue = "," + keysHaveValue;
|
|
|
-// }
|
|
|
+ StringBuilder newString = new StringBuilder();
|
|
|
+ List<String> keySet = new LinkedList<>();
|
|
|
+ for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
|
|
|
+ keySet.add(entry.getKey());
|
|
|
+ Object value = reviseValue(eMap, entry.getKey(), entry.getValue(), nodeOld.getPKeyId());
|
|
|
+ if (value != null) {
|
|
|
+ if (value.toString().contains("\n")) {
|
|
|
+ value = value.toString().replace("\n", "\\n");
|
|
|
+ }
|
|
|
+ newString.append("'").append(value).append("',");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (newString.length() > 0) {
|
|
|
+ newString.insert(0, ',');
|
|
|
+ if (newString.charAt(newString.length() - 1) == ',') {
|
|
|
+ newString.deleteCharAt(newString.length() - 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String keysHaveValue = StringUtils.join(keySet, ",");
|
|
|
+ if (keysHaveValue.length() > 0) {
|
|
|
+ keysHaveValue = "," + keysHaveValue;
|
|
|
+ }
|
|
|
//delete SQL (先删除旧数据,再新增)
|
|
|
String delSql = "DELETE FROM " + newData.getInitTableName() + " WHERE p_key_id = " + newData.getPKeyId() + " ; ";
|
|
|
//insert SQL
|
|
|
-// copySql.append(delSql)
|
|
|
-// .append("INSERT INTO ")
|
|
|
-// .append(newData.getInitTableName())
|
|
|
-// .append(" (id,p_key_id,group_id")
|
|
|
-// .append(keysHaveValue)
|
|
|
-// .append(") VALUES (")
|
|
|
-// .append(SnowFlakeUtil.getId()).append(",")
|
|
|
-// .append(newData.getPKeyId()).append(",null")
|
|
|
-// .append(newString)
|
|
|
-// .append(");");
|
|
|
copySql.append(delSql)
|
|
|
.append("INSERT INTO ")
|
|
|
.append(newData.getInitTableName())
|
|
|
- .append(" (id,p_key_id,group_id,")
|
|
|
- .append(keys).append(") select ")
|
|
|
+ .append(" (id,p_key_id,group_id")
|
|
|
+ .append(keysHaveValue)
|
|
|
+ .append(") VALUES (")
|
|
|
.append(SnowFlakeUtil.getId()).append(",")
|
|
|
- .append(newData.getPKeyId()).append(",null, ")
|
|
|
- .append(keys).append(" from ").append(newData.getInitTableName()).append(" where p_key_id =").append(nodeOld.getPKeyId()).append(" LIMIT 1;");
|
|
|
+ .append(newData.getPKeyId()).append(",null")
|
|
|
+ .append(newString)
|
|
|
+ .append(");");
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
- if (!wbsParamAndLedgerList.isEmpty()) {
|
|
|
- //复制节点命名配置
|
|
|
- //查询节点绑定的公共配置 文件提名信息
|
|
|
- WbsParam wbsParam = wbsParamClient.getWbsParam(Long.parseLong(vo.getNeedCopyPrimaryKeyId()));
|
|
|
- List<WbsParam> wbsParamList = new ArrayList<>();
|
|
|
- wbsParamAndLedgerList.forEach(newData -> {
|
|
|
- if(wbsParam!=null){
|
|
|
- WbsParam wbsParam1 = new WbsParam();
|
|
|
- BeanUtil.copy(wbsParam, wbsParam1);
|
|
|
- wbsParam1.setId(SnowFlakeUtil.getId());
|
|
|
- wbsParam1.setNodeId(newData.getPKeyId());
|
|
|
- //给复制的节点绑定的公共配置
|
|
|
- wbsParamList.add(wbsParam1);
|
|
|
- }
|
|
|
- /*生成工序节点施工日志*/
|
|
|
- this.createLedger(newData, saveLedger, nodeMap, null);
|
|
|
- });
|
|
|
- wbsParamClient.saveWbsParams(wbsParamList);
|
|
|
}
|
|
|
|
|
|
//TODO 20250414-lhb-新增 添加祖级字段 ancestorsPId
|
|
|
- //因为复制选中节点,所以要查询出选中节点的父节点信息 来组装祖级节点
|
|
|
- if(needCopyNode != null){
|
|
|
- Long parentPKeyId = null;
|
|
|
- String ancestorsPId = null;
|
|
|
- if(needCopyNode.getPId() == 0L){
|
|
|
- ancestorsPId = "0";
|
|
|
- parentPKeyId = 0L;
|
|
|
- }else{
|
|
|
- WbsTreeContract parentNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(String.valueOf(needCopyNode.getPId()));
|
|
|
- ancestorsPId = parentNode.getAncestorsPId();
|
|
|
- parentPKeyId = parentNode.getPKeyId();
|
|
|
- }
|
|
|
- attachNodesToTarget(saveList,parentPKeyId,ancestorsPId);
|
|
|
- }
|
|
|
+ List<WbsTreeContract> contractWbsTreeByContractId = wbsTreeContractClient.getContractWbsTreeByContractId(Long.valueOf(needCopyNode.getContractId()));
|
|
|
+ contractWbsTreeByContractId.addAll(saveList);
|
|
|
+ Map<Long, WbsTreeContract> collect = contractWbsTreeByContractId.stream().collect(Collectors.toMap(WbsTreeContract::getPKeyId, Function.identity()));
|
|
|
+ saveList.forEach(node -> {
|
|
|
+ String correctAncestors = createAncestorsPId(node,collect);;
|
|
|
+ node.setAncestorsPId(correctAncestors);
|
|
|
+ });
|
|
|
}
|
|
|
needCopyNode.setNodeName(vo.getNeedCopyNodeName());
|
|
|
|
|
@@ -2182,26 +2139,6 @@ public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo) {
|
|
|
this.addCopyTabData(needCopyNode, toCopyNode, tabOwner, resultTablesData, addTabList, vo.getIsCopyData(), addNewFileTabs);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- /*重构祖级id*/
|
|
|
- List<WbsTreeContract> resultAll = new ArrayList<>();
|
|
|
- resultAll.addAll(addNodeList);
|
|
|
- resultAll.addAll(addTabList);
|
|
|
- //因为复制选中节点,所以要查询出选中节点的父节点信息 来组装祖级节点
|
|
|
- if(needCopyNode != null && CollectionUtil.isNotEmpty(resultAll)){
|
|
|
- Long parentPKeyId = null;
|
|
|
- String ancestorsPId = null;
|
|
|
- if(needCopyNode.getPId() == 0L){
|
|
|
- ancestorsPId = "0";
|
|
|
- parentPKeyId = 0L;
|
|
|
- }else{
|
|
|
- WbsTreeContract parentNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(String.valueOf(toCopyVO.getPrimaryKeyId()));
|
|
|
- ancestorsPId = parentNode.getAncestorsPId();
|
|
|
- parentPKeyId = parentNode.getPKeyId();
|
|
|
- }
|
|
|
- attachNodesToTarget(resultAll,parentPKeyId,ancestorsPId);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2211,6 +2148,14 @@ public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo) {
|
|
|
resultAll.addAll(addNodeList);
|
|
|
resultAll.addAll(addTabList);
|
|
|
|
|
|
+ //TODO 20250414-lhb-新增
|
|
|
+ List<WbsTreeContract> contractWbsTreeByContractId = wbsTreeContractClient.getContractWbsTreeByContractId(Long.valueOf(contractId));
|
|
|
+ contractWbsTreeByContractId.addAll(resultAll);
|
|
|
+ Map<Long, WbsTreeContract> collect = contractWbsTreeByContractId.stream().collect(Collectors.toMap(WbsTreeContract::getPKeyId, Function.identity()));
|
|
|
+ resultAll.forEach(node -> {
|
|
|
+ String correctAncestors = createAncestorsPId(node,collect);;
|
|
|
+ node.setAncestorsPId(correctAncestors);
|
|
|
+ });
|
|
|
|
|
|
List<WbsTreeContract> allData = this.reBuildAncestors(resultAll);
|
|
|
List<WbsTreeContract> nodes = allData.stream().filter(f -> f.getType().equals(1)).collect(Collectors.toList());
|
|
@@ -2345,7 +2290,7 @@ private Map<String, String> reviseValue(WbsTreeContract wtc, WbsTreeContract par
|
|
|
if (!ekvMap.containsKey(tableName)) {
|
|
|
Map<String, String> map = ekvMap.computeIfAbsent(wtc.getInitTableName(), K -> new HashMap<>());
|
|
|
if (parent == null) {
|
|
|
- parent = this.wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(wtc.getPId());
|
|
|
+ parent = this.wbsTreeContractClient.getContractWbsTreeByContractIdAndId(wtc.getParentId(), Long.parseLong(wtc.getContractId()));
|
|
|
}
|
|
|
/*凡是关联了节点参数公式的元素都不复制数据*/
|
|
|
List<Map<String, Object>> paramKey = this.jdbcTemplate.queryForList("select DISTINCT b.e_key ek from m_table_info a join m_wbs_form_element b on a.id=b.f_id join m_element_formula_mapping c on b.id = c.element_id where a.tab_en_name='" + tableName + "' and b.is_deleted=0 and c.scope=35 and c.is_deleted=0");
|
|
@@ -2424,10 +2369,49 @@ private Object reviseValue(Map<String, String> p2, String key, Object value) {
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
+ private Object reviseValue(Map<String, String> p2, String key, Object value, Long pKeyId) {
|
|
|
+ try {
|
|
|
+ if (p2.containsKey(key)) {
|
|
|
+ String setting = p2.get(key);
|
|
|
+ if (StringPool.NULL.equals(setting)) {
|
|
|
+ /*擦除原来的内容*/
|
|
|
+ return setting;
|
|
|
+ } else {
|
|
|
+ /*重做随机值*/
|
|
|
+ List<RangeJson> rjs = JSON.parseArray(setting, RangeJson.class);
|
|
|
+ if (value != null && !value.toString().isEmpty() && Func.isNotEmpty(rjs)) {
|
|
|
+ List<RangeJson> rangeJsons = rjs.stream().filter(rj -> rj.getPkeyId().equals(pKeyId)).collect(Collectors.toList());
|
|
|
+ if (!rangeJsons.isEmpty()) {
|
|
|
+ List<String[]> la = Arrays.stream(value.toString().split("☆")).map(s -> s.split("_\\^_")).collect(Collectors.toList());
|
|
|
+ /*全部为一个数的时候不用修改*/
|
|
|
+ if (la.stream().map(a -> a[0]).collect(Collectors.toSet()).size() > 1 || la.size() == 1) {
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
+ for (String[] a : la) {
|
|
|
+ String v = a[0];
|
|
|
+ String sv;
|
|
|
+ if (v.contains("、")) {
|
|
|
+ sv = Arrays.stream(v.split("[、]")).map(e -> imitate(e, rangeJsons)).collect(Collectors.joining("、"));
|
|
|
+ } else {
|
|
|
+ sv = imitate(v, rangeJsons);
|
|
|
+ }
|
|
|
+ result.add(sv + "_^_" + a[1]);
|
|
|
+ }
|
|
|
+ return String.join("☆", result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ }
|
|
|
|
|
|
public String imitate(String v, List<RangeJson> rjs) {
|
|
|
try {
|
|
|
- RangeJson best = rjs.stream().min(Comparator.comparingDouble(j -> Double.parseDouble(v) - Double.parseDouble(j.getDesign()))).orElse(rjs.get(0));
|
|
|
+ RangeJson best = rjs.stream().filter(j -> BaseUtils.isNotEmpty(j.getDesign()))
|
|
|
+ .peek(j -> j.setDesign(j.getDesign().split("/")[0])).min(Comparator.comparingDouble(j -> Double.parseDouble(v) - Double.parseDouble(j.getDesign()))).orElse(rjs.get(0));
|
|
|
// int scale = Math.max(new StringBuilder(v).reverse().indexOf("."), 0);
|
|
|
int scale = BaseUtils.getScaleZero(v, best.getDev(), best.getDesign());
|
|
|
return BaseUtils.rangeList(1, best.getDesign(), best.getDev(), 1, scale, 1).get(0).toString();
|
|
@@ -2449,7 +2433,8 @@ private String reviseCols(Map<String, String> p2, String cols, Long pkeyId, Stri
|
|
|
List<String> colsList = target.stream().filter(k -> k.startsWith("key")).collect(Collectors.toList());
|
|
|
for (String k : colsList) {
|
|
|
if (p2.containsKey(k)) {
|
|
|
- Object value = reviseValue(p2, k, origin.get(k));
|
|
|
+// Object value = reviseValue(p2, k, origin.get(k));
|
|
|
+ Object value = reviseValue(p2, k, origin.get(k), pkeyId);
|
|
|
if (value != null) {
|
|
|
if (value.toString().contains("_^_")) {
|
|
|
value = "'" + value + "'";
|
|
@@ -2597,7 +2582,16 @@ private void addCopyTabData(WbsTreeContract needCopyNode, WbsTreeContract toCopy
|
|
|
String tableName = needTab.getInitTableName();
|
|
|
String col = nodeTabColsMap.get(tableName);
|
|
|
String colVal = nodeTabColsMap.get(tableName);
|
|
|
- colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + toCopyNodeTab.getPKeyId() + "' as p_key_id,");
|
|
|
+ String[] split = colVal.split(",");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String key = split[i];
|
|
|
+ if (key.equals("id")) {
|
|
|
+ split[i] = "'" + SnowFlakeUtil.getId() + "' as id";
|
|
|
+ } else if (key.equals("p_key_id")) {
|
|
|
+ split[i] = "'" + toCopyNodeTab.getPKeyId() + "' as p_key_id";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ colVal = String.join(",", split);
|
|
|
//delete SQL (先删除旧数据,再新增)
|
|
|
String delSql = "delete from " + tableName + " where p_key_id = " + toCopyNodeTab.getPKeyId() + " ; ";
|
|
|
//insert into SQL
|
|
@@ -2646,7 +2640,16 @@ private void addCopyTabData(WbsTreeContract needCopyNode, WbsTreeContract toCopy
|
|
|
String tableName = objTab.getInitTableName();
|
|
|
String col = nodeTabColsMap.get(tableName);
|
|
|
String colVal = nodeTabColsMap.get(tableName);
|
|
|
- colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + objTab.getPKeyId() + "' as p_key_id,");
|
|
|
+ String[] split = colVal.split(",");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String key = split[i];
|
|
|
+ if (key.equals("id")) {
|
|
|
+ split[i] = "'" + SnowFlakeUtil.getId() + "' as id";
|
|
|
+ } else if (key.equals("p_key_id")) {
|
|
|
+ split[i] = "'" + objTab.getPKeyId() + "' as p_key_id";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ colVal = String.join(",", split);
|
|
|
//delete SQL (先删除旧数据,再新增)
|
|
|
String delSql = "delete from " + tableName + " where p_key_id = " + objTab.getPKeyId() + " ; ";
|
|
|
//insert into SQL
|
|
@@ -2762,7 +2765,16 @@ private void addCopyNodesAndTabsBuildData(List<WbsTreeContract> addNodeList, Lis
|
|
|
String tableName = obj.getInitTableName();
|
|
|
String col = nodeTabColsMap.get(tableName);
|
|
|
String colVal = nodeTabColsMap.get(tableName);
|
|
|
- colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + obj.getPKeyId() + "' as p_key_id,");
|
|
|
+ String[] split = colVal.split(",");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String key = split[i];
|
|
|
+ if (key.equals("id")) {
|
|
|
+ split[i] = "'" + SnowFlakeUtil.getId() + "' as id";
|
|
|
+ } else if (key.equals("p_key_id")) {
|
|
|
+ split[i] = "'" + obj.getPKeyId() + "' as p_key_id";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ colVal = String.join(",", split);
|
|
|
//delete SQL (先删除旧数据,再新增)
|
|
|
String delSql = "delete from " + tableName + " where p_key_id = " + obj.getPKeyId() + " ; ";
|
|
|
//insert into SQL
|
|
@@ -2895,7 +2907,16 @@ private void addCopyNodesAndTabsBuildData(List<WbsTreeContract> addNodeList, Lis
|
|
|
StringBuilder copyDataSql = new StringBuilder();
|
|
|
String col = queryProcessDataVO.getAncestors();
|
|
|
String colVal = queryProcessDataVO.getAncestors();
|
|
|
- colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + objTab.getPKeyId() + "' as p_key_id,");
|
|
|
+ String[] split = colVal.split(",");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String key = split[i];
|
|
|
+ if (key.equals("id")) {
|
|
|
+ split[i] = "'" + SnowFlakeUtil.getId() + "' as id";
|
|
|
+ } else if (key.equals("p_key_id")) {
|
|
|
+ split[i] = "'" + objTab.getPKeyId() + "' as p_key_id";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ colVal = String.join(",", split);
|
|
|
//delete SQL (先删除旧数据,再新增)
|
|
|
String delSql = "delete from " + tableName + " where p_key_id = " + objTab.getPKeyId() + " ; ";
|
|
|
//insert into SQL
|