Browse Source

合同段划分导入相关

liuyc 2 years ago
parent
commit
3aa3812682

+ 23 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/WbsTreeContractDTO2.java

@@ -0,0 +1,23 @@
+package org.springblade.manager.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.springblade.manager.entity.WbsTreeContract;
+import org.springblade.manager.vo.WbsTreeContractVO;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+public class WbsTreeContractDTO2 extends WbsTreeContract {
+    private static final long serialVersionUID = 1L;
+
+    @JsonProperty(value = "pKeyIdOld")
+    private String pKeyIdOld;
+
+    private WbsTreeContractVO wbsTreeContractVO;
+
+}

+ 2 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/InformationQueryMapper.xml

@@ -66,6 +66,7 @@
         <result column="nodeType" property="nodeType"/>
         <result column="colorStatus" property="colorStatus"/>
         <result column="type" property="type"/>
+        <result column="partitionCode" property="partitionCode"/>
     </resultMap>
 
     <resultMap id="intResultMap" type="java.lang.Integer"/>
@@ -155,6 +156,7 @@
             WHEN 0 THEN (select ci.contract_name from m_contract_info AS ci where wtc.contract_id = ci.id)
             ELSE IFNULL(if(length(trim(wtc.full_name)) > 0, wtc.full_name, wtc.node_name),wtc.node_name) END AS title,
             wtc.parent_id AS parentId,
+            wtc.partition_code AS partitionCode,
             wtc.contract_id AS contractId,
             wtc.old_id AS oldId,
             wtc.major_data_type AS majorDataType,

+ 18 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ContractInfoController.java

@@ -436,6 +436,24 @@ public class ContractInfoController extends BladeController {
         return R.fail(200, "未查询到信息");
     }
 
+    /**
+     * 客户端填报-划分变更手动关联树
+     */
+    @GetMapping("/tree2")
+    @ApiOperationSupport(order = 18)
+    @ApiOperation(value = "客户端填报-划分变更手动关联树", notes = "传入wbsId,项目id,合同段id")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "wbsId", value = "wbsId", required = true),
+            @ApiImplicitParam(name = "项目id", value = "projectId", required = true),
+            @ApiImplicitParam(name = "合同段id", value = "contractId", required = true)
+    })
+    public R tree2(String wbsId, String projectId, String contractId) {
+        List<WbsTreeContractVO> tree = contractInfoService.tree2(wbsId, projectId, contractId);
+        if (tree != null && tree.size() > 0) {
+            return R.data(tree);
+        }
+        return R.fail(200, "未查询到信息");
+    }
 
     /**
      * 查询所有施工合同wbs树根节点(新建监理或业主合同段时,加载当前项目下的施工WBS树,分配时使用)
@@ -454,7 +472,6 @@ public class ContractInfoController extends BladeController {
         return R.fail(200, "未查询到信息");
     }
 
-
     /**
      * 懒加载合同wbs节点树形结构
      */

+ 12 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeContractController.java

@@ -1,13 +1,12 @@
 package org.springblade.manager.controller;
 
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.tool.api.R;
+import org.springblade.manager.dto.WbsTreeContractDTO;
+import org.springblade.manager.dto.WbsTreeContractDTO2;
 import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.service.IWbsTreeContractService;
 import org.springblade.manager.vo.WbsTreeContractVO;
@@ -51,7 +50,6 @@ public class WbsTreeContractController extends BladeController {
         return R.fail(200, "未查询到数据");
     }
 
-
     @PostMapping("/import-wbs-contract")
     @ApiOperationSupport(order = 3)
     @ApiOperation(value = "导入合同段wbs划分", notes = "传入file、contractId、type、isSplicingNumber")
@@ -61,12 +59,17 @@ public class WbsTreeContractController extends BladeController {
             @ApiImplicitParam(name = "type", value = "工程类别", required = true),
             @ApiImplicitParam(name = "isSplicingNumber", value = "是否拼接划分编号", required = true)
     })
-    public R<WbsTreeContractVO4> importWbsContract(@RequestPart("file") MultipartFile file,
-                                                   @RequestParam("contractId") String contractId,
-                                                   @RequestParam("type") Integer type,
-                                                   @RequestParam("isSplicingNumber") Integer isSplicingNumber) throws IOException {
+    public R<WbsTreeContractVO4> importWbsContract(@RequestPart("file") MultipartFile file, @RequestParam("contractId") String contractId, @RequestParam("type") Integer type, @RequestParam("isSplicingNumber") Integer isSplicingNumber) throws IOException {
         WbsTreeContractVO4 list = iWbsTreeContractService.importWbsContract(file, contractId, type, isSplicingNumber);
         return R.data(list);
     }
 
+    @PostMapping("/import-relation")
+    @ApiOperationSupport(order = 4)
+    @ApiOperation(value = "合同段导入划分未识别关联保存", notes = "wbsTreeContractDTO2")
+    @ApiImplicitParams(value = {@ApiImplicitParam(name = "WbsTreeContractDTO2", value = "wbsTreeContractDTO2"),})
+    public R submitRelation(@RequestBody WbsTreeContractDTO2 wbsTreeContractDTO2) {
+        return R.status(iWbsTreeContractService.submitRelation(wbsTreeContractDTO2));
+    }
+
 }

+ 137 - 17
blade-service/blade-manager/src/main/java/org/springblade/manager/excel/WbsExcelUtil.java

@@ -7,6 +7,7 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.manager.utils.DiffListUtil;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -17,12 +18,14 @@ import java.util.stream.Collectors;
 
 public class WbsExcelUtil {
     /*public static void main(String[] args) throws IOException {
-        *//*WbsExcelUtil excelUtil = new WbsExcelUtil();
+        WbsExcelUtil excelUtil = new WbsExcelUtil();
         //读取excel数据
         ArrayList<Map<String, String>> result = excelUtil.readExcelToObjContract("C:\\Users\\泓创开发\\Desktop\\合同段工程节点导入.xlsx");
         ArrayList<Map<String, String>> resultNow = excelUtil.getDataListByType(result, 1);
         List<Map<Integer, String>> resultList = new ArrayList<>();
 
+        int isSplicingNumber = 1;
+
         //构造map
         String str = "\\s*|\r|\n|\t";
         for (Map<String, String> map : resultNow) {
@@ -31,35 +34,152 @@ public class WbsExcelUtil {
                 String v1 = value1.replaceAll(str, "");
                 map.forEach((k2, value2) -> {
                     String v2 = value2.replaceAll(str, "");
+                    *//*if ("1".equals(k1) && "2".equals(k2)) {
+                        maps.put(1, v1 + ":::" + v2);
+                    } else if ("3".equals(k1) && "4".equals(k2)) {
+                        String s1 = "";
+                        if (number == 1) {
+                            if (StringUtils.isNotEmpty(v2)) {
+                                String s = maps.get(1);
+                                if (StringUtils.isNotEmpty(s.replaceAll(":::", ""))) {
+                                    s1 = s.split(":::")[1] + "-";
+                                }
+                            }
+                        }
+                        maps.put(2, v1 + ":::" + s1 + v2);
+
+                    } else if ("5".equals(k1) && "6".equals(k2)) {
+                        String s2 = "";
+                        if (number == 1) {
+                            if (StringUtils.isNotEmpty(v2)) {
+                                String s = maps.get(2);
+                                if (StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                    s = maps.get(1);
+                                }
+                                if (StringUtils.isNotEmpty(s.replaceAll(":::", ""))) {
+                                    s2 = s.split(":::")[1] + "-";
+                                }
+                            }
+                        }
+                        maps.put(3, v1 + ":::" + s2 + v2);
+
+                    } else if ("7".equals(k1) && "8".equals(k2)) {
+                        String s3 = "";
+                        if (number == 1) {
+                            if (StringUtils.isNotEmpty(v2)) {
+                                String s = maps.get(3);
+                                if (StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                    s = maps.get(2);
+                                    if (StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                        s = maps.get(1);
+                                    }
+                                }
+                                if (StringUtils.isNotEmpty(s.replaceAll(":::", ""))) {
+                                    s3 = s.split(":::")[1] + "-";
+                                }
+                            }
+                        }
+                        maps.put(4, v1 + ":::" + s3 + v2);
+
+                    } else if ("9".equals(k1) && "10".equals(k2)) {
+                        String s4 = "";
+                        if (StringUtils.isNotEmpty(v2)) {
+                            String s = maps.get(4);
+                            if (number == 1) {
+                                if (StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                    s = maps.get(3);
+                                    if (StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                        s = maps.get(2);
+                                    }
+                                    if (StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                        s = maps.get(1);
+                                    }
+                                }
+                                if (StringUtils.isNotEmpty(s.replaceAll(":::", ""))) {
+                                    s4 = s.split(":::")[1] + "-";
+                                }
+                            }
+                        }
+                        maps.put(5, v1 + ":::" + s4 + v2);
+                    }*//*
+
                     if ("1".equals(k1) && "2".equals(k2)) {
                         maps.put(1, v1 + ":::" + v2);
                     } else if ("3".equals(k1) && "4".equals(k2)) {
-                        maps.put(2, v1 + ":::" + v2);
+                        String s1 = "";
+                        if (isSplicingNumber == 1) {
+                            if (org.apache.commons.lang.StringUtils.isNotEmpty(v2)) {
+                                String s = maps.get(1);
+                                if (org.apache.commons.lang.StringUtils.isNotEmpty(s.replaceAll(":::", ""))) {
+                                    s1 = s.split(":::")[1] + "-";
+                                }
+                            }
+                        }
+                        maps.put(2, v1 + ":::" + s1 + v2);
+
                     } else if ("5".equals(k1) && "6".equals(k2)) {
-                        maps.put(3, v1 + ":::" + v2);
+                        String s2 = "";
+                        if (isSplicingNumber == 1) {
+                            if (org.apache.commons.lang.StringUtils.isNotEmpty(v2)) {
+                                String s = maps.get(2);
+                                if (org.apache.commons.lang.StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                    s = maps.get(1);
+                                }
+                                if (org.apache.commons.lang.StringUtils.isNotEmpty(s.replaceAll(":::", ""))) {
+                                    s2 = s.split(":::")[1] + "-";
+                                }
+                            }
+                        }
+                        maps.put(3, v1 + ":::" + s2 + v2);
+
                     } else if ("7".equals(k1) && "8".equals(k2)) {
-                        maps.put(4, v1 + ":::" + v2);
+                        String s3 = "";
+                        if (isSplicingNumber == 1) {
+                            if (org.apache.commons.lang.StringUtils.isNotEmpty(v2)) {
+                                String s = maps.get(3);
+                                if (org.apache.commons.lang.StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                    s = maps.get(2);
+                                    if (org.apache.commons.lang.StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                        s = maps.get(1);
+                                    }
+                                }
+                                if (org.apache.commons.lang.StringUtils.isNotEmpty(s.replaceAll(":::", ""))) {
+                                    s3 = s.split(":::")[1] + "-";
+                                }
+                            }
+                        }
+                        maps.put(4, v1 + ":::" + s3 + v2);
+
                     } else if ("9".equals(k1) && "10".equals(k2)) {
-                        maps.put(5, v1 + ":::" + v2);
+                        String s4 = "";
+                        if (org.apache.commons.lang.StringUtils.isNotEmpty(v2)) {
+                            String s = maps.get(4);
+                            if (isSplicingNumber == 1) {
+                                if (org.apache.commons.lang.StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                    s = maps.get(3);
+                                    if (org.apache.commons.lang.StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                        s = maps.get(2);
+                                    }
+                                    if (org.apache.commons.lang.StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                        s = maps.get(1);
+                                    }
+                                }
+                                if (org.apache.commons.lang.StringUtils.isNotEmpty(s.replaceAll(":::", ""))) {
+                                    s4 = s.split(":::")[1] + "-";
+                                }
+                            }
+                        }
+                        maps.put(5, v1 + ":::" + s4 + v2);
                     }
                 });
+
             });
             resultList.add(maps);
         }
-        resultList.forEach(System.out::println);*//*
-
-        String s1 = "K14+544~K16+176路基工程";
-        String s2 = "测试树-lyc,路基工程";
-
-        float similarityRatio = DiffListUtil.getSimilarityRatio(s1, s2);
-        boolean similarityRatio1 = DiffListUtil.getContains(s1, s2);
-        boolean similarityRatio2 = s1.contains(s2);
-        System.out.println(similarityRatio);
-        System.out.println(similarityRatio1);
-        System.out.println(similarityRatio2);
-
+        resultList.forEach(System.out::println);
     }*/
 
+
     /**
      * 读取excel数据
      *

+ 6 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.java

@@ -55,6 +55,11 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
                                   @Param("wbsType") Integer wbsType,
                                   @Param("parentId") String parentId);
 
+    List<WbsTreeContractVO> tree3(@Param("wbsId") String wbsId,
+                                  @Param("projectId") String projectId,
+                                  @Param("contractId") String contractId,
+                                  @Param("wbsType") Integer wbsType,
+                                  @Param("parentId") String parentId);
 
     List<WbsTreeContractVO3> selectLists(@Param("contractInfo") ContractInfo contractInfo, @Param("contractType") Integer contractType);
 
@@ -66,4 +71,5 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
 
     List<ContractInfo> selectContractIdByProjectId(String projectId);
 
+
 }

+ 42 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.xml

@@ -298,6 +298,48 @@
         ORDER BY d.sort
     </select>
 
+    <select id="tree3" resultType="org.springblade.manager.vo.WbsTreeContractVO">
+        SELECT
+        d.p_key_id AS "primaryKeyId",
+        d.wbs_type AS "wbsType",
+        d.id,
+        d.parent_id AS "parentId",
+        IFNULL(if(length(trim(full_name)) > 0, full_name, node_name),node_name) AS title,
+        d.node_name AS "nodeName",
+        d.full_name AS "fullName",
+        d.import_matching_info AS "importMatchingInfo",
+        d.type AS "type",
+        d.node_type AS "nodeType",
+        d.id AS "value",
+        d.id AS "key",
+        partition_code,
+        old_id,
+        sort
+        FROM m_wbs_tree_contract d
+        WHERE
+        d.is_deleted = 0
+        AND d.status = 1
+        AND d.type = 1
+        <if test="wbsId!=null and wbsId!=''">
+            and wbs_id = #{wbsId}
+        </if>
+        <if test="projectId !=null and projectId!=''">
+            and project_id = #{projectId}
+        </if>
+        <if test="contractId!=null and contractId!=''">
+            and contract_id = #{contractId}
+        </if>
+        <if test="wbsType != null and wbsType != ''">
+            and wbs_type = #{wbsType}
+        </if>
+        <if test="parentId != null and parentId != ''">
+            and parent_id = #{parentId}
+        </if>
+        /*改变划分节点,暂时未说明是否新增到新增、复制节点下,默认可以修改 old_id != null*/
+        /*AND old_id is null*/
+        ORDER BY d.sort
+    </select>
+
     <select id="selectByCondition" resultMap="resultMap2">
         SELECT t.p_key_id             AS "pKeyId",
                t.contract_id          AS "contractId",

+ 2 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IContractInfoService.java

@@ -41,6 +41,8 @@ public interface IContractInfoService extends BaseService<ContractInfo> {
 
     List<WbsTreeContractVO> tree(String wbsId, String projectId, String contractId);
 
+    List<WbsTreeContractVO> tree2(String wbsId, String projectId, String contractId);
+
     List<WbsTreeContractVO2> treeTwo(String projectId);
 
     List<WbsTreeContractTreeVO> queryContractWbsTreeByContractIdAndType(String contractId, Integer wbsType, String parentId);

+ 3 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IWbsTreeContractService.java

@@ -2,6 +2,7 @@ package org.springblade.manager.service;
 
 import org.springblade.core.mp.base.BaseService;
 import org.springblade.manager.dto.WbsTreeContractDTO;
+import org.springblade.manager.dto.WbsTreeContractDTO2;
 import org.springblade.manager.entity.ContractRelationJlyz;
 import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.entity.WbsTreePrivate;
@@ -41,4 +42,6 @@ public interface IWbsTreeContractService extends BaseService<WbsTreeContract> {
 
     WbsTreeContractVO4 importWbsContract(MultipartFile excelFile, String contractId, Integer type, Integer isSplicingNumber) throws IOException;
 
+    boolean submitRelation(WbsTreeContractDTO2 wbsTreeContractDTO2);
+
 }

+ 7 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -319,4 +319,11 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
         return baseMapper.selectByContractRelationJlyz(Long.valueOf(contractId));
     }
 
+    @Override
+    public List<WbsTreeContractVO> tree2(String wbsId, String projectId, String contractId) {
+        //方式2
+        List<WbsTreeContractVO> wbsTreeContractVOS = baseMapper.tree3(wbsId, projectId, contractId, null, null);
+        return buildWbsTreeByStream(wbsTreeContractVOS);
+    }
+
 }

+ 2 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsFormElementServiceImpl.java

@@ -623,7 +623,7 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
                     baseMapper.deleteElementByfId(formElementDTO);
                     //删除关联
                     baseMapper.deleteWbsTabRelationExcelTab(String.valueOf(formElementDTO.getId()), String.valueOf(formElementDTO.getExcelTabId()));
-                    throw new ServiceException("新增元素表异常,操作失败");
+                    throw new ServiceException("新增元素表异常,操作失败 " + e.getMessage());
                 }
             }
         }
@@ -650,7 +650,7 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
             //初始化否存在表单
             wbsTreeMapper.updateIsExistFormById(parent.getId());
         }
-        if (StringUtils.isEmpty(dept.getFillRate())){
+        if (StringUtils.isEmpty(dept.getFillRate())) {
             dept.setFillRate("80%");
         }
         dept.setType(2);

+ 274 - 83
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -1,5 +1,7 @@
 package org.springblade.manager.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
@@ -14,6 +16,7 @@ import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.manager.dto.WbsTreeContractDTO;
+import org.springblade.manager.dto.WbsTreeContractDTO2;
 import org.springblade.manager.entity.*;
 import org.springblade.manager.excel.WbsExcelBatchUtil;
 import org.springblade.manager.excel.WbsExcelUtil;
@@ -26,6 +29,7 @@ import org.springblade.manager.vo.WbsTreeContractTreeVO;
 import org.springblade.manager.vo.WbsTreeContractTreeVO3;
 import org.springblade.manager.vo.WbsTreeContractVO;
 import org.springblade.manager.vo.WbsTreeContractVO4;
+import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
@@ -398,19 +402,63 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         return null;
     }
 
+    @Override
+    public boolean submitRelation(WbsTreeContractDTO2 wbsTreeContractDTO2) {
+        if (StringUtils.isEmpty(wbsTreeContractDTO2.getPKeyIdOld())) {
+            throw new ServiceException("请选择一个关联节点");
+        }
+        //获取当前节点
+        WbsTreeContract wbsTreeContract = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getPKeyId, wbsTreeContractDTO2.getPKeyIdOld()));
+        Long idOld = wbsTreeContract.getId();
+        //该节点下所有子级节点、元素表
+        List<WbsTreeContract> wbsTreeContracts = baseMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
+                .eq(WbsTreeContract::getProjectId, wbsTreeContract.getProjectId())
+                .eq(WbsTreeContract::getContractId, wbsTreeContract.getContractId())
+                .eq(WbsTreeContract::getParentId, wbsTreeContract.getId())
+                .eq(WbsTreeContract::getStatus, 1)
+                .or()
+                .eq(WbsTreeContract::getAncestors, wbsTreeContract.getId())
+
+        );
+
+        for (WbsTreeContract treeContract : wbsTreeContracts) {
+            //设置主键
+            treeContract.setPKeyId(SnowFlakeUtil.getId());
+        }
+
+        //修改根节点信息
+        Long idNew = SnowFlakeUtil.getId();
+        wbsTreeContract.setPKeyId(idNew);
+        wbsTreeContract.setId(idNew);
+        wbsTreeContract.setNodeName(wbsTreeContractDTO2.getWbsTreeContractVO().getFullName());
+        wbsTreeContract.setFullName(wbsTreeContractDTO2.getWbsTreeContractVO().getFullName());
+        wbsTreeContract.setImportMatchingInfo(wbsTreeContractDTO2.getWbsTreeContractVO().getImportMatchingInfo());
+        wbsTreeContract.setIsImportIdentificationNode(1);
+        wbsTreeContract.setPartitionCode(wbsTreeContractDTO2.getWbsTreeContractVO().getPartitionCode());
+        wbsTreeContract.setNodeType(wbsTreeContractDTO2.getWbsTreeContractVO().getNodeType());
+
+        wbsTreeContracts.add(wbsTreeContract);
+
+        String jsonListOld = JSONObject.toJSONString(wbsTreeContracts);
+
+        String jsonListNew = jsonListOld.replaceAll(String.valueOf(idOld), String.valueOf(idNew));
+
+        List<WbsTreeContract> wbsTreeContractsNew = JSONArray.parseArray(jsonListNew, WbsTreeContract.class);
+
+        this.saveBatch(wbsTreeContractsNew, 1000);
+
+        return true;
+    }
+
     private WbsTreeContractVO4 updateContractNodeNames(ArrayList<Map<String, String>> resultNow, String contractId, Integer isSplicingNumber) {
         //获取当前合同段树
         List<WbsTreeContractVO> wbsTreeContractVOS = contractInfoMapper.tree2(null, null, contractId, null, null);
         if (wbsTreeContractVOS.size() <= 0) {
             throw new ServiceException("请从项目级中分配合同段wbs划分模板");
         }
-        List<Map<Integer, String>> resultList = new ArrayList<>();
-
-        if (isSplicingNumber == 1) {
-            //构建拼接划分编号
-        }
 
-        //构造map
+        //构造resultList
+        List<Map<Integer, String>> resultList = new ArrayList<>();
         String str = "\\s*|\r|\n|\t";
         for (Map<String, String> map : resultNow) {
             Map<Integer, String> maps = new HashMap<>();
@@ -418,16 +466,74 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                 String v1 = value1.replaceAll(str, "");
                 map.forEach((k2, value2) -> {
                     String v2 = value2.replaceAll(str, "");
+
                     if ("1".equals(k1) && "2".equals(k2)) {
                         maps.put(1, v1 + ":::" + v2);
                     } else if ("3".equals(k1) && "4".equals(k2)) {
-                        maps.put(2, v1 + ":::" + v2);
+                        String s1 = "";
+                        if (isSplicingNumber == 1) {
+                            if (StringUtils.isNotEmpty(v2)) {
+                                String s = maps.get(1);
+                                if (StringUtils.isNotEmpty(s.replaceAll(":::", ""))) {
+                                    s1 = s.split(":::")[1] + "-";
+                                }
+                            }
+                        }
+                        maps.put(2, v1 + ":::" + s1 + v2);
+
                     } else if ("5".equals(k1) && "6".equals(k2)) {
-                        maps.put(3, v1 + ":::" + v2);
+                        String s2 = "";
+                        if (isSplicingNumber == 1) {
+                            if (StringUtils.isNotEmpty(v2)) {
+                                String s = maps.get(2);
+                                if (StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                    s = maps.get(1);
+                                }
+                                if (StringUtils.isNotEmpty(s.replaceAll(":::", ""))) {
+                                    s2 = s.split(":::")[1] + "-";
+                                }
+                            }
+                        }
+                        maps.put(3, v1 + ":::" + s2 + v2);
+
                     } else if ("7".equals(k1) && "8".equals(k2)) {
-                        maps.put(4, v1 + ":::" + v2);
+                        String s3 = "";
+                        if (isSplicingNumber == 1) {
+                            if (StringUtils.isNotEmpty(v2)) {
+                                String s = maps.get(3);
+                                if (StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                    s = maps.get(2);
+                                    if (StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                        s = maps.get(1);
+                                    }
+                                }
+                                if (StringUtils.isNotEmpty(s.replaceAll(":::", ""))) {
+                                    s3 = s.split(":::")[1] + "-";
+                                }
+                            }
+                        }
+                        maps.put(4, v1 + ":::" + s3 + v2);
+
                     } else if ("9".equals(k1) && "10".equals(k2)) {
-                        maps.put(5, v1 + ":::" + v2);
+                        String s4 = "";
+                        if (StringUtils.isNotEmpty(v2)) {
+                            String s = maps.get(4);
+                            if (isSplicingNumber == 1) {
+                                if (StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                    s = maps.get(3);
+                                    if (StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                        s = maps.get(2);
+                                    }
+                                    if (StringUtils.isEmpty(s.replaceAll(":::", ""))) {
+                                        s = maps.get(1);
+                                    }
+                                }
+                                if (StringUtils.isNotEmpty(s.replaceAll(":::", ""))) {
+                                    s4 = s.split(":::")[1] + "-";
+                                }
+                            }
+                        }
+                        maps.put(5, v1 + ":::" + s4 + v2);
                     }
                 });
             });
@@ -437,7 +543,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         List<WbsTreeContractVO> successData = new ArrayList<>();
         List<WbsTreeContractVO> failData = new ArrayList<>();
 
-        //解析mapList
+        //解析resultList
         for (Map<Integer, String> map : resultList) {
             for (Map.Entry<Integer, String> entry : map.entrySet()) {
                 Integer k = entry.getKey();
@@ -449,7 +555,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                 String nodeName = split[0];
                 String partitionCode = split[1];
 
-                //先判断是否循环到下一行,是否已经匹配成功名称类似节点
                 int count = 0;
                 if (successData.size() > 0) {
                     for (WbsTreeContractVO successDatum : successData) {
@@ -475,9 +580,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                         }
                     }
                 }
-
                 if (count == 1) {
-                    //如果添加了类似名称节点成功,那么结束当前循环,进入下一列,不执行修改、失败构造
                     continue;
                 }
 
@@ -485,13 +588,10 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                     if (nodeOld.getNodeType().equals(k)) {
                         String nodeNameOld = nodeOld.getNodeName();
                         String importMatchingInfoOld = nodeOld.getImportMatchingInfo();
-                        List<WbsTreeContractVO> collect = successData.stream().filter(f ->
-                                f.getFullName().contains(nodeName)
-                                        && f.getPartitionCode().equals(partitionCode)
-                        ).collect(Collectors.toList());
+                        List<WbsTreeContractVO> collect = successData.stream().filter(f -> f.getFullName().contains(nodeName) && f.getPartitionCode().equals(partitionCode)).collect(Collectors.toList());
                         //匹配名称、别名
                         if (collect.size() == 0) {
-                            if (nodeName.contains(nodeNameOld) || nodeName.contains(importMatchingInfoOld)) {
+                            if (nodeName.contains(nodeNameOld) || (StringUtils.isNotEmpty(importMatchingInfoOld) && nodeName.contains(importMatchingInfoOld))) {
                                 //匹配成功 修改名称、划分编号 不修改原始节点id,只修改别名id
                                 nodeOld.setFullName(nodeName);
                                 nodeOld.setPartitionCode(partitionCode);
@@ -504,18 +604,12 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                         }
                     }
                 }
-
                 if (count == 2) {
-                    //不执行失败构造
                     continue;
                 }
 
-                List<WbsTreeContractVO> collect = successData.stream().filter(f ->
-                        f.getFullName().contains(nodeName)
-                ).collect(Collectors.toList());
-                List<WbsTreeContractVO> collect1 = failData.stream().filter(f ->
-                        f.getFullName().contains(nodeName)
-                ).collect(Collectors.toList());
+                List<WbsTreeContractVO> collect = successData.stream().filter(f -> f.getFullName().contains(nodeName)).collect(Collectors.toList());
+                List<WbsTreeContractVO> collect1 = failData.stream().filter(f -> f.getFullName().contains(nodeName)).collect(Collectors.toList());
 
                 if (collect.size() == 0 && collect1.size() == 0) {
                     //未匹配成功 构建参数
@@ -559,8 +653,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         return res;
     }
 
-    private List<WbsTreeContractVO> buildFailDataTree
-            (List<Map<Integer, String>> resultList, List<WbsTreeContractVO> failData, List<WbsTreeContractVO> successData) {
+    private List<WbsTreeContractVO> buildFailDataTree(List<Map<Integer, String>> resultList, List<WbsTreeContractVO> failData, List<WbsTreeContractVO> successData) {
         List<WbsTreeContractVO> resultData = new ArrayList<>();
         for (Map<Integer, String> map : resultList) {//行
             Long nodeParentIdLv1 = 0L;
@@ -581,100 +674,196 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                 }
                 String[] split = v.split(":::");
                 String nodeName = split[0];
-
-                for (WbsTreeContractVO failDatum : failData) {
-                    if (k.equals(failDatum.getNodeType()) && nodeName.equals(failDatum.getFullName())) {
-                        failList.add(failDatum);
+                if (failData.size() > 0) {
+                    for (WbsTreeContractVO failDatum : failData) {
+                        if (k.equals(failDatum.getNodeType()) && nodeName.equals(failDatum.getFullName())) {
+                            failList.add(failDatum);
+                        }
                     }
                 }
+                if (successData.size() > 0) {
+                    for (WbsTreeContractVO successDatum : successData) {
+                        if (k.equals(successDatum.getNodeType()) && nodeName.equals(successDatum.getFullName())) {
+                            successList.add(successDatum);
+                        }
+                    }
+                }
+            }
 
-                for (WbsTreeContractVO successDatum : successData) {
-                    if (k.equals(successDatum.getNodeType()) && nodeName.equals(successDatum.getFullName())) {
-                        successList.add(successDatum);
+            //如果没有匹配成功的节点,那么就用excel所有节点参数构建新的失败树的上级id
+            if (successList.size() == 0 && failList.size() > 0) {
+                for (WbsTreeContractVO wbsTreeContractVO : failList) {
+                    if (wbsTreeContractVO.getNodeType() == 1) {
+                        nodeParentIdLv1 = wbsTreeContractVO.getId();
+                    } else
+                    if (wbsTreeContractVO.getNodeType() == 2) {
+                        nodeParentIdLv2 = wbsTreeContractVO.getId();
+                    } else if (wbsTreeContractVO.getNodeType() == 3) {
+                        nodeParentIdLv3 = wbsTreeContractVO.getId();
+                    } else if (wbsTreeContractVO.getNodeType() == 4) {
+                        nodeParentIdLv4 = wbsTreeContractVO.getId();
+                    } else if (wbsTreeContractVO.getNodeType() == 5) {
+                        nodeParentIdLv5 = wbsTreeContractVO.getId();
                     }
                 }
             }
 
-            //初始化上级id
-            for (WbsTreeContractVO successDatum : successList) {
-                if (successDatum.getNodeType() == 1) {
-                    nodeParentIdLv1 = successDatum.getId();
-                } else if (successDatum.getNodeType() == 2) {
-                    nodeParentIdLv2 = successDatum.getId();
-                } else if (successDatum.getNodeType() == 3) {
-                    nodeParentIdLv3 = successDatum.getId();
-                } else if (successDatum.getNodeType() == 4) {
-                    nodeParentIdLv4 = successDatum.getId();
-                } else if (successDatum.getNodeType() == 5) {
-                    nodeParentIdLv5 = successDatum.getId();
+            //如果有匹配成功的节点,那么就是要该节点作为构建失败树的上级id
+            if (successList.size() > 0) {
+                for (WbsTreeContractVO successDatum : successList) {
+                    if (successDatum.getNodeType() == 1) {
+                        nodeParentIdLv1 = successDatum.getId();
+                    } else
+                    if (successDatum.getNodeType() == 2) {
+                        nodeParentIdLv2 = successDatum.getId();
+                    } else if (successDatum.getNodeType() == 3) {
+                        nodeParentIdLv3 = successDatum.getId();
+                    } else if (successDatum.getNodeType() == 4) {
+                        nodeParentIdLv4 = successDatum.getId();
+                    } else if (successDatum.getNodeType() == 5) {
+                        nodeParentIdLv5 = successDatum.getId();
+                    }
                 }
             }
 
             //构建未成功节点的父级id
-            for (WbsTreeContractVO failDatum : failList) {
-                if (failDatum.getNodeType() == 1) {
-                    failDatum.setParentId(nodeParentIdLv1);
-
-                } else if (failDatum.getNodeType() == 2) {
-                    if (nodeParentIdLv2 == 0L) {
-                        failDatum.setParentId(nodeParentIdLv1);
-                    } else {
-                        failDatum.setParentId(nodeParentIdLv2);
-                        nodeParentIdLv2 = failDatum.getId();
-                    }
+            if (successList.size() > 0 && failList.size() > 0) {
+                for (WbsTreeContractVO failDatum : failList) {
+                    if (failDatum.getNodeType() == 1) {
+                        failDatum.setParentId(0L);
 
-                } else if (failDatum.getNodeType() == 3) {
-                    if (nodeParentIdLv3 == 0L) {
+                    } else if (failDatum.getNodeType() == 2) {
                         if (nodeParentIdLv2 == 0L) {
-                            failDatum.setParentId(nodeParentIdLv1);
+                            failDatum.setParentId(0L);
                         } else {
                             failDatum.setParentId(nodeParentIdLv2);
-                            nodeParentIdLv3 = failDatum.getId();
+                            nodeParentIdLv2 = failDatum.getId();
                         }
-                    } else {
-                        failDatum.setParentId(nodeParentIdLv3);
-                        nodeParentIdLv3 = failDatum.getId();
-                    }
 
-                } else if (failDatum.getNodeType() == 4) {
-                    if (nodeParentIdLv4 == 0L) {
+                    } else if (failDatum.getNodeType() == 3) {
                         if (nodeParentIdLv3 == 0L) {
                             if (nodeParentIdLv2 == 0L) {
-                                failDatum.setParentId(nodeParentIdLv1);
+                                failDatum.setParentId(0L);
                             } else {
                                 failDatum.setParentId(nodeParentIdLv2);
-                                nodeParentIdLv4 = failDatum.getId();
+                                nodeParentIdLv3 = failDatum.getId();
                             }
                         } else {
                             failDatum.setParentId(nodeParentIdLv3);
+                            nodeParentIdLv3 = failDatum.getId();
+                        }
+
+                    } else if (failDatum.getNodeType() == 4) {
+                        if (nodeParentIdLv4 == 0L) {
+                            if (nodeParentIdLv3 == 0L) {
+                                if (nodeParentIdLv2 == 0L) {
+                                    failDatum.setParentId(0L);
+                                } else {
+                                    failDatum.setParentId(nodeParentIdLv2);
+                                    nodeParentIdLv4 = failDatum.getId();
+                                }
+                            } else {
+                                failDatum.setParentId(nodeParentIdLv3);
+                                nodeParentIdLv4 = failDatum.getId();
+                            }
+                        } else {
+                            failDatum.setParentId(nodeParentIdLv4);
                             nodeParentIdLv4 = failDatum.getId();
                         }
-                    } else {
-                        failDatum.setParentId(nodeParentIdLv4);
-                        nodeParentIdLv4 = failDatum.getId();
+
+                    } else if (failDatum.getNodeType() == 5) {
+                        if (nodeParentIdLv5 == 0L) {
+                            if (nodeParentIdLv4 == 0L) {
+                                if (nodeParentIdLv3 == 0L) {
+                                    if (nodeParentIdLv2 == 0L) {
+                                        failDatum.setParentId(0L);
+                                    } else {
+                                        failDatum.setParentId(nodeParentIdLv2);
+                                        nodeParentIdLv5 = failDatum.getId();
+                                    }
+                                } else {
+                                    failDatum.setParentId(nodeParentIdLv3);
+                                    nodeParentIdLv5 = failDatum.getId();
+                                }
+                            } else {
+                                failDatum.setParentId(nodeParentIdLv4);
+                                nodeParentIdLv5 = failDatum.getId();
+                            }
+                        } else {
+                            failDatum.setParentId(nodeParentIdLv5);
+                            nodeParentIdLv5 = failDatum.getId();
+                        }
                     }
+                }
+            }
+
+            //所有都是失败节点
+            if (successList.size() == 0 && failList.size() > 0) {
+                for (WbsTreeContractVO failDatum : failList) {
+                    if (failDatum.getNodeType() == 1) {
+                        failDatum.setParentId(0L);
 
-                } else if (failDatum.getNodeType() == 5) {
-                    if (nodeParentIdLv5 == 0L) {
+                    } else if (failDatum.getNodeType() == 2) {
+                        if (nodeParentIdLv2 == 0L) {
+                            failDatum.setParentId(nodeParentIdLv1);
+                        } else {
+                            failDatum.setParentId(nodeParentIdLv1);
+                            nodeParentIdLv2 = failDatum.getId();
+                        }
+
+                    } else if (failDatum.getNodeType() == 3) {
+                        if (nodeParentIdLv3 == 0L) {
+                            if (nodeParentIdLv2 == 0L) {
+                                failDatum.setParentId(0L);
+                            } else {
+                                failDatum.setParentId(nodeParentIdLv2);
+                                nodeParentIdLv3 = failDatum.getId();
+                            }
+                        } else {
+                            failDatum.setParentId(nodeParentIdLv3);
+                            nodeParentIdLv3 = failDatum.getId();
+                        }
+
+                    } else if (failDatum.getNodeType() == 4) {
                         if (nodeParentIdLv4 == 0L) {
                             if (nodeParentIdLv3 == 0L) {
                                 if (nodeParentIdLv2 == 0L) {
-                                    failDatum.setParentId(nodeParentIdLv1);
+                                    failDatum.setParentId(0L);
                                 } else {
                                     failDatum.setParentId(nodeParentIdLv2);
-                                    nodeParentIdLv5 = failDatum.getId();
+                                    nodeParentIdLv4 = failDatum.getId();
                                 }
                             } else {
                                 failDatum.setParentId(nodeParentIdLv3);
-                                nodeParentIdLv5 = failDatum.getId();
+                                nodeParentIdLv4 = failDatum.getId();
                             }
                         } else {
                             failDatum.setParentId(nodeParentIdLv4);
+                            nodeParentIdLv4 = failDatum.getId();
+                        }
+
+                    } else if (failDatum.getNodeType() == 5) {
+                        if (nodeParentIdLv5 == 0L) {
+                            if (nodeParentIdLv4 == 0L) {
+                                if (nodeParentIdLv3 == 0L) {
+                                    if (nodeParentIdLv2 == 0L) {
+                                        failDatum.setParentId(0L);
+                                    } else {
+                                        failDatum.setParentId(nodeParentIdLv2);
+                                        nodeParentIdLv5 = failDatum.getId();
+                                    }
+                                } else {
+                                    failDatum.setParentId(nodeParentIdLv3);
+                                    nodeParentIdLv5 = failDatum.getId();
+                                }
+                            } else {
+                                failDatum.setParentId(nodeParentIdLv4);
+                                nodeParentIdLv5 = failDatum.getId();
+                            }
+                        } else {
+                            failDatum.setParentId(nodeParentIdLv5);
                             nodeParentIdLv5 = failDatum.getId();
                         }
-                    } else {
-                        failDatum.setParentId(nodeParentIdLv5);
-                        nodeParentIdLv5 = failDatum.getId();
                     }
                 }
             }
@@ -684,7 +873,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
 
             //添加构建成功节点
             resultData.addAll(failList);
-            resultData.addAll(successList);
+            if (failList.size() > 0) {
+                resultData.addAll(successList);
+            }
         }
 
         return resultData;