|
@@ -1383,7 +1383,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
} else if (vo.getIsCopyData() == 0) {
|
|
|
tabOwner = "1,2,3,4,5,6"; //如果选择的是否复制数据=0(否),默认所属方123456
|
|
|
}
|
|
|
-
|
|
|
+ /*用来标识新旧工序结对*/
|
|
|
+ Map<Long,Long> peerMap = new HashMap<>();
|
|
|
//TODO 单份复制
|
|
|
if (("1").equals(vo.getCopyType())) {
|
|
|
//首先查询需要复制的节点及其下级所有子节点的信息
|
|
@@ -1431,6 +1432,9 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//重塑关键信息
|
|
|
//重塑primaryKeyId
|
|
|
newData.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ if(nodeOld.getNodeType()!=null&&nodeOld.getNodeType()==6){
|
|
|
+ peerMap.put(newData.getPKeyId(),nodeOld.getPKeyId());
|
|
|
+ }
|
|
|
//设置旧ID
|
|
|
if (StringUtils.isNotEmpty(nodeOld.getOldId())) {
|
|
|
newData.setOldId(nodeOld.getOldId());
|
|
@@ -1595,7 +1599,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
if (newTabs.size() > 0 && oldTabs.size() > 0 && vo.getIsCopyData() == 1) {
|
|
|
this.addCopyTabFile(new HashSet<>(newTabs), oldTabs);
|
|
|
}
|
|
|
-
|
|
|
+ /*复制formulaOption*/
|
|
|
+ this.copyFormulaOptions(saveList,peerMap);
|
|
|
//更新redis缓存
|
|
|
informationQueryService.delAsyncWbsTree(needCopyNode.getContractId());
|
|
|
|
|
@@ -1669,7 +1674,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
List<WbsTreeContract> needCopyTab = needCopyNodeAndTabMap.get("tab:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
|
|
//构造新的节点、表、数据
|
|
|
- this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 1, tabOwner, vo.getIsCopyData());
|
|
|
+ this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 1, tabOwner, vo.getIsCopyData(),peerMap);
|
|
|
|
|
|
//附件
|
|
|
addNewFileTabs.addAll(addTabList);
|
|
@@ -1698,7 +1703,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
List<WbsTreeContract> needCopyTab = needCopyNodeAndTabMap.get("tab:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
|
|
//构造新的节点、表、数据
|
|
|
- this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 0, tabOwner, vo.getIsCopyData());
|
|
|
+ this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 0, tabOwner, vo.getIsCopyData(),peerMap);
|
|
|
|
|
|
//附件
|
|
|
addNewFileTabs.addAll(addTabList);
|
|
@@ -1715,7 +1720,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
List<WbsTreeContract> needCopyTab = needCopyNodeAndTabMap.get("tab:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
|
|
//构造新的节点、表、数据
|
|
|
- this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 0, tabOwner, vo.getIsCopyData());
|
|
|
+ this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 0, tabOwner, vo.getIsCopyData(),peerMap);
|
|
|
|
|
|
//附件
|
|
|
addNewFileTabs.addAll(addTabList);
|
|
@@ -1778,7 +1783,10 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
throw new ServiceException("保存数据异常,请联系管理员");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ if(nodes.size()>0){
|
|
|
+ /*复制formulaOpion*/
|
|
|
+ this.copyFormulaOptions(nodes,peerMap);
|
|
|
+ }
|
|
|
if (row) {
|
|
|
//更新redis缓存
|
|
|
informationQueryService.delAsyncWbsTree(contractId);
|
|
@@ -1813,6 +1821,30 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
return R.fail("操作失败");
|
|
|
}
|
|
|
|
|
|
+ @Async
|
|
|
+ public void copyFormulaOptions( List<WbsTreeContract> saveList,Map<Long,Long> peerMap){
|
|
|
+ if(peerMap.size()>0){
|
|
|
+ try {
|
|
|
+ String sqlTemplate="INSERT INTO m_formula_option (id,parent_id,contract_id,val) select #1,#2,contract_id,val from m_formula_option where id=#3";
|
|
|
+ Map<Long,Long> idMap = saveList.stream().filter(e->e.getNodeType()!=null&&e.getNodeType()==6).collect(Collectors.toMap(WbsTreeContract::getPKeyId,WbsTreeContract::getId));
|
|
|
+ List<String> sqlList= new ArrayList<>();
|
|
|
+ for(Map.Entry<Long,Long> p:peerMap.entrySet()){
|
|
|
+ try {
|
|
|
+ String newPkeyId=p.getKey().toString();
|
|
|
+ String oldPkeyId=p.getValue().toString();
|
|
|
+ String newId=idMap.get(p.getKey()).toString();
|
|
|
+ sqlList.add(sqlTemplate.replace("#1", newPkeyId).replace("#2", newId).replace("#3", oldPkeyId));
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BaseUtils.splitList(sqlList,50).parallelStream().map(l->String.join(";",l)).forEach(this.jdbcTemplate::execute);
|
|
|
+ }catch (Exception e){
|
|
|
+ StaticLog.error("formulaOption复制失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
static String[] G8_TBN = new String[]{"m_20220922161954_1572863246099021824", "m_20220928134702_1574999102784012288"};
|
|
|
|
|
|
private boolean checkG8(String tableName) {
|
|
@@ -2147,7 +2179,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
private void addCopyNodesAndTabsBuildData
|
|
|
(List<WbsTreeContract> addNodeList, List<WbsTreeContract> addTabList, List<WbsTreeContract> needNodes, List<WbsTreeContract> needTabs, WbsTreeContract
|
|
|
needCopyNode, WbsTreeContract toCopyNode, List<String> resultTablesData, Integer isSameNode, String
|
|
|
- tabOwner, Integer isCopyData) {
|
|
|
+ tabOwner, Integer isCopyData,Map<Long,Long> peerMap ) {
|
|
|
int var = 0;
|
|
|
if (needNodes.size() == 1) {
|
|
|
//判断是否为最下级节点
|
|
@@ -2178,8 +2210,10 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
obj.setCreateTime(new Date());
|
|
|
//获取当前复制的节点的sort
|
|
|
obj.setSort(ObjectUtils.isNotEmpty(needNode.getSort()) ? needNode.getSort() : 0);
|
|
|
-
|
|
|
addNodeList.add(obj);
|
|
|
+ if(obj.getNodeType()!=null&&obj.getNodeType()==6){
|
|
|
+ peerMap.put(obj.getPKeyId(),needNode.getPKeyId());
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -2229,7 +2263,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
String delSql = "delete from " + tableName + " where p_key_id = " + obj.getPKeyId() + " ; ";
|
|
|
//insert into SQL
|
|
|
String testColVal = reviseCols(eMap, colVal, oldPKeyId, tableName);
|
|
|
- StaticLog.info("KT3356:" + testColVal);
|
|
|
+ /*StaticLog.info("KT3356:" + testColVal);*/
|
|
|
copyDataSql.append(delSql).append("insert into ").append(tableName).append(" (").append(col).append(") select ").append(testColVal).append(" from ").append(tableName).append(" where p_key_id='").append(oldPKeyId).append("' LIMIT 1;");
|
|
|
resultTablesData.add(copyDataSql.toString());
|
|
|
}
|
|
@@ -2284,7 +2318,9 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
obj.setSort(ObjectUtils.isNotEmpty(node.getSort()) ? node.getSort() : 0);
|
|
|
|
|
|
addNodeList.add(obj);
|
|
|
-
|
|
|
+ if(obj.getNodeType()!=null&&obj.getNodeType()==6){
|
|
|
+ peerMap.put(obj.getPKeyId(),node.getPKeyId());
|
|
|
+ }
|
|
|
//构造当前节点下所有元素表
|
|
|
List<WbsTreeContract> tabs = tabMap.get(oldId);
|
|
|
//构造节点下的表
|