hongchuangyanfa 2 роки тому
батько
коміт
871d4bddff

+ 15 - 6
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -1255,10 +1255,7 @@ public class InformationWriteQueryController extends BladeController {
         //首先查询需要复制的节点及其下级所有子节点的信息
         WbsTreeContract needCopyNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getNeedCopyPrimaryKeyId());
         // 获取当前节点的所有子节点
-       String vocational = SnowFlakeUtil.getId()+"";
-        // 插入数据库
-        // informationQueryService.copeNodeData(needCopyNode.getId()+"",vocational);
-        // 修改
+        String vocational = SnowFlakeUtil.getId()+"";
         //新增施工台账
         List<WbsTreeContract>   saveList = new ArrayList<>();
         List<ConstructionLedger> saveLedger = new ArrayList<>();
@@ -1268,6 +1265,7 @@ public class InformationWriteQueryController extends BladeController {
         List<QueryProcessDataVO> nodeTabCols = informationQueryService.getNodeChildTabColsAllByNodeId(needCopyNode.getId() + "", needCopyNode.getContractId());
         // 转化为map
         Map<String, String> nodeTabColsMap = nodeTabCols.stream().collect(Collectors.toMap(QueryProcessDataVO::getQueryType, QueryProcessDataVO::getAncestors, (key1, key2) -> key2));
+        StringBuilder copeSql = new StringBuilder();
 
         if (StringUtils.isNotEmpty(vo.getNeedCopyPrimaryKeyId())) {
             WbsTreeContract parent = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getParentPrimaryKeyId());
@@ -1280,7 +1278,6 @@ public class InformationWriteQueryController extends BladeController {
                 nodeMap.put(node.getId().toString(), node);
             });
 
-            System.out.println("4="+DateUtil.formatDateTime(DateUtil.now()));
             //todo 单份复制
             nodeChildAll.forEach(node -> {
                 WbsTreeContract newData = new WbsTreeContract();
@@ -1331,10 +1328,22 @@ public class InformationWriteQueryController extends BladeController {
                     //生成施工日志
                     this.createLedger(newData, saveLedger, nodeMap, null);
                 }
+
+                // 组织复制值Sql
+                if(nodeTabColsMap!=null && node.getType()==2){
+                    String tableName = newData.getInitTableName();
+                    String col = nodeTabColsMap.get(tableName);
+                    String colVal = nodeTabColsMap.get(tableName);
+                    colVal = colVal.replaceAll("id,p_key_id,","'"+SnowFlakeUtil.getId()+"' as id,'"+newData.getPKeyId()+"' as p_key_id,");
+                    copeSql.append("insert into "+tableName+"  ("+col+") select "+colVal+" from "+tableName+" where p_key_id='"+node.getPKeyId()+"' ;");
+                }
             });
         }
+        //保存节点信息
          R<Boolean> booleanR = this.saveOrCopyNodeTree(saveList, saveLedger, 32, needCopyNode);
-         jdbcTemplate.batchUpdate();
+
+        //复制数据逻辑
+         jdbcTemplate.execute(copeSql.toString());
         return booleanR;
     }
 

+ 0 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1055,7 +1055,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
     public R getBussPdfInfo(Long pkeyId) throws Exception {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
         //String file_path = "/Users/hongchuangyanfa/Desktop/";
-
         WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
                 .eq(WbsTreeContract::getPKeyId, pkeyId));