|
@@ -1,9 +1,9 @@
|
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -15,7 +15,6 @@ import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
-import org.springblade.core.tool.utils.DateUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.core.tool.utils.StringUtil;
|
|
|
import org.springblade.manager.dto.WbsTreeContractDTO;
|
|
@@ -29,15 +28,12 @@ import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
import org.springblade.manager.service.IWbsTreeContractService;
|
|
|
import org.springblade.manager.utils.DiffListUtil;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
-import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
-import springfox.documentation.spring.web.json.Json;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
-import java.sql.Timestamp;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -91,53 +87,36 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
List<String> collect2 = new ArrayList<>();
|
|
|
|
|
|
if (list.size() > 0) {
|
|
|
- //所有表单
|
|
|
List<WbsTreeContract> collect3 = list.stream().filter(f -> f.getType() == 2).collect(Collectors.toList());
|
|
|
collect1 = collect3.stream().map(WbsTreeContract::getId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
-
|
|
|
- //所有节点
|
|
|
List<WbsTreeContract> collect4 = list.stream().filter(f -> f.getType() == 1).collect(Collectors.toList());
|
|
|
collect2 = collect4.stream().map(WbsTreeContract::getId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
- //新增节点ids
|
|
|
List<String> collect5 = collect2;
|
|
|
List<String> saveIds = idList1.stream().filter(f -> !collect5.contains(f)).collect(Collectors.toList());
|
|
|
- //删除节点ids
|
|
|
List<String> delIds = collect5.stream().filter(f -> !idList1.contains(f)).collect(Collectors.toList());
|
|
|
|
|
|
if (saveIds.size() == 0 && delIds.size() == 0) {
|
|
|
//节点id未变,只进行节点下的元素表的同步
|
|
|
List<WbsTreePrivate> wbsTreePrivateList2 = new ArrayList<>();
|
|
|
- //获取私有wbs树下所有元素表
|
|
|
- List<WbsTreePrivate> wbsTreePrivateList = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
- .eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId())
|
|
|
- .eq(WbsTreePrivate::getWbsId, pawDTO.getWbsId())
|
|
|
- .eq(WbsTreePrivate::getType, 2)
|
|
|
- );
|
|
|
+ List<WbsTreePrivate> wbsTreePrivateList = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda().eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId()).eq(WbsTreePrivate::getWbsId, pawDTO.getWbsId()).eq(WbsTreePrivate::getType, 2));
|
|
|
|
|
|
- //获取当前引用节点下的所有表
|
|
|
wbsTreePrivateList.forEach(wbsTreePrivate -> {
|
|
|
idList1.forEach(id -> {
|
|
|
if (Long.parseLong(id) == (wbsTreePrivate.getParentId()) && wbsTreePrivate.getType() == 2) {
|
|
|
- //表
|
|
|
wbsTreePrivateList2.add(wbsTreePrivate);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- //私有wbs树下所有元素表的Id
|
|
|
List<String> collect = wbsTreePrivateList2.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
|
|
|
- //获取所有wbsTreePrivate新增的表单Id
|
|
|
List<String> diffRent1 = DiffListUtil.getDiffRent(collect, collect1);
|
|
|
-
|
|
|
if (collect.size() == collect1.size()) {
|
|
|
return true;
|
|
|
-
|
|
|
}
|
|
|
if (collect.size() > collect1.size()) {
|
|
|
- //初始化
|
|
|
List<WbsTreeContract> wbsTreeContracts = new ArrayList<>();
|
|
|
wbsTreePrivateList.forEach(wbsTreePrivate -> {
|
|
|
diffRent1.forEach(id -> {
|
|
@@ -157,15 +136,12 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- //同步新增
|
|
|
this.insertBatch(wbsTreeContracts, 1000);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
-
|
|
|
//删除
|
|
|
if (delIds.size() > 0) {
|
|
|
- //是否被监理合同引用
|
|
|
List<ContractRelationJlyz> contractRelationJLYZList = baseMapper.selectContractRelationInfoByidSG2(pawDTO.getContractId());
|
|
|
if (contractRelationJLYZList.size() > 0) {
|
|
|
throw new ServiceException("当前施工合同段wbs树被监理或业主合同段引用中,删除失败!");
|
|
@@ -200,14 +176,11 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
//获取wbs私有树下节点、表
|
|
|
List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateMapper.selectNodeAndTable2(pawDTO.getWbsId(), pawDTO.getProjectId());
|
|
|
-
|
|
|
for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
|
|
|
for (String id : saveIds) {
|
|
|
if (Long.parseLong(id) == (wbsTreePrivate.getId())) {
|
|
|
- //节点
|
|
|
wbsTreePrivatesList.add(wbsTreePrivate);
|
|
|
} else if (Long.parseLong(id) == (wbsTreePrivate.getParentId()) && wbsTreePrivate.getType() == 2) {
|
|
|
- //表
|
|
|
wbsTreePrivatesList.add(wbsTreePrivate);
|
|
|
}
|
|
|
}
|
|
@@ -215,7 +188,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
//初始化
|
|
|
wbsTreePrivatesList.forEach(wbsTreePrivate -> {
|
|
|
- //节点、表
|
|
|
WbsTreeContract wbsTreeContract = BeanUtil.copyProperties(wbsTreePrivate, WbsTreeContract.class);
|
|
|
if (wbsTreeContract != null) {
|
|
|
wbsTreeContract.setPKeyId(SnowFlakeUtil.getId());
|
|
@@ -228,7 +200,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
if (wbsTreePrivate.getType() == 2) {
|
|
|
wbsTreeContract.setIsTypePrivatePid(wbsTreePrivate.getPKeyId());
|
|
|
}
|
|
|
- //导入划分匹配字段
|
|
|
if (wbsTreePrivate.getType() == 1) {
|
|
|
wbsTreeContract.setImportMatchingInfo(wbsTreePrivate.getFullName());
|
|
|
}
|
|
@@ -247,10 +218,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- //新增合同段节点、表
|
|
|
this.insertBatch(wbsTreeContractList, 1000);
|
|
|
-
|
|
|
- //新增施工台账
|
|
|
constructionLedgerFeign.initConstructionLedger(constructionLedgerList);
|
|
|
}
|
|
|
}
|
|
@@ -378,7 +346,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
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();
|
|
|
//该节点下所有子级节点、元素表
|
|
@@ -392,7 +359,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
);
|
|
|
|
|
|
for (WbsTreeContract treeContract : wbsTreeContracts) {
|
|
|
- //主键
|
|
|
treeContract.setPKeyId(SnowFlakeUtil.getId());
|
|
|
}
|
|
|
|
|
@@ -425,7 +391,11 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
if (StringUtils.isNotEmpty(pKeyId)) {
|
|
|
//获取节点信息
|
|
|
WbsTreeContract wbsTreeContract = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getPKeyId, pKeyId));
|
|
|
- List<ContractInfo> contractInfos = contractInfoMapper.selectList(Wrappers.<ContractInfo>query().lambda().eq(ContractInfo::getPId, wbsTreeContract.getProjectId()).eq(ContractInfo::getStatus, 1));
|
|
|
+ List<ContractInfo> contractInfos = contractInfoMapper.selectList(Wrappers.<ContractInfo>query().lambda()
|
|
|
+ .eq(ContractInfo::getPId, wbsTreeContract.getProjectId())
|
|
|
+ .eq(ContractInfo::getStatus, 1)
|
|
|
+ .eq(ContractInfo::getContractType, 1)
|
|
|
+ );
|
|
|
List<WbsTreeContract> wbsTreeContractList = new ArrayList<>();
|
|
|
for (ContractInfo contractInfo : contractInfos) {
|
|
|
WbsTreeContract node = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
@@ -439,7 +409,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
//标记是否隐蔽工程节点
|
|
|
for (WbsTreeContract treeContract : wbsTreeContractList) {
|
|
|
- if (ObjectUtils.isEmpty(treeContract.getIsConcealedWorksNode())) {
|
|
|
+ if (ObjectUtil.isEmpty(treeContract.getIsConcealedWorksNode())) {
|
|
|
treeContract.setIsConcealedWorksNode(0);
|
|
|
}
|
|
|
treeContract.setIsConcealedWorksNode(treeContract.getIsConcealedWorksNode().equals(0) ? 1 : 0);
|
|
@@ -473,7 +443,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
//解析excel
|
|
|
WbsExcelUtil excelUtil = new WbsExcelUtil();
|
|
|
ArrayList<Map<String, String>> result = excelUtil.readExcelToObjContract(canonicalPath);
|
|
|
- //匹配对应工程类别修改对应合同段节点名称
|
|
|
return this.importSubmitWbsContractNodes(result, primaryKeyId, isSplicingNumber);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -481,111 +450,28 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
} finally {
|
|
|
File file2 = new File(canonicalPath);
|
|
|
if (file2.isFile() && file2.exists()) {
|
|
|
- file2.delete();
|
|
|
- System.gc();
|
|
|
+ if (file2.delete()) {
|
|
|
+ System.gc();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
private WbsTreeContractVO4 importSubmitWbsContractNodes(ArrayList<Map<String, String>> result, String primaryKeyId, Integer isSplicingNumber) {
|
|
|
- //获取当前根节点
|
|
|
- WbsTreeContract wbsTreeContractRoot = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
- .eq(WbsTreeContract::getPKeyId, primaryKeyId)
|
|
|
- );
|
|
|
+ WbsTreeContract wbsTreeContractRoot = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getPKeyId, primaryKeyId));
|
|
|
//获取当前节点下所有子节点
|
|
|
List<WbsTreeContractVO> wbsTreeContractVOS = contractInfoMapper.tree4(wbsTreeContractRoot.getContractId(), String.valueOf(wbsTreeContractRoot.getId()));
|
|
|
if (wbsTreeContractVOS.size() <= 0) {
|
|
|
throw new ServiceException("未查询到当前合同段的wbs树,请先分配该合同的合同段wsb树");
|
|
|
}
|
|
|
+ List<Map<Integer, String>> resultList = this.getResultList(result, isSplicingNumber);
|
|
|
|
|
|
- //构造resultList
|
|
|
- List<Map<Integer, String>> resultList = new ArrayList<>();
|
|
|
- String str = "\\s*|\r|\n|\t";
|
|
|
- for (Map<String, String> map : result) {
|
|
|
- Map<Integer, String> maps = new HashMap<>();
|
|
|
- map.forEach((k1, value1) -> {
|
|
|
- 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 (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)) {
|
|
|
- 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)) {
|
|
|
- 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)) {
|
|
|
- String s4 = "";
|
|
|
- if (isSplicingNumber == 1) {
|
|
|
- if (StringUtils.isNotEmpty(v2)) {
|
|
|
- String s = maps.get(4);
|
|
|
- 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);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- resultList.add(maps);
|
|
|
- }
|
|
|
-
|
|
|
- //解析resultList
|
|
|
+ //解析
|
|
|
List<WbsTreeContractVO> successData = new ArrayList<>();
|
|
|
Set<ImportContractNodeVO> sets = new HashSet<>();
|
|
|
- for (Map<Integer, String> map : resultList) {//行
|
|
|
- for (Map.Entry<Integer, String> entry : map.entrySet()) {//列
|
|
|
+ for (Map<Integer, String> map : resultList) {
|
|
|
+ for (Map.Entry<Integer, String> entry : map.entrySet()) {
|
|
|
Integer k = entry.getKey();
|
|
|
String v = entry.getValue();
|
|
|
if (StringUtil.isEmpty(v.replaceAll(":::", ""))) {
|
|
@@ -595,102 +481,97 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
String nodeName = split[0];
|
|
|
String partitionCode = split[1];
|
|
|
|
|
|
- //excel中所有节点信息
|
|
|
+ //构造set
|
|
|
ImportContractNodeVO obj = new ImportContractNodeVO();
|
|
|
obj.setNodeType(k);
|
|
|
obj.setNodeName(nodeName);
|
|
|
obj.setPartitionCode(partitionCode);
|
|
|
sets.add(obj);
|
|
|
-
|
|
|
- for (WbsTreeContractVO nodeOld : wbsTreeContractVOS) {
|
|
|
- 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());
|
|
|
- if (collect.size() == 0) {
|
|
|
- if (nodeName.contains(nodeNameOld) || (StringUtils.isNotEmpty(importMatchingInfoOld) && nodeName.contains(importMatchingInfoOld))) {
|
|
|
- WbsTreeContractVO wbsTreeContractVO2 = BeanUtil.copyProperties(nodeOld, WbsTreeContractVO.class);
|
|
|
- assert wbsTreeContractVO2 != null;
|
|
|
- //匹配成功 修改名称、划分编号 不修改原始节点id,只修改别名id
|
|
|
- wbsTreeContractVO2.setFullName(nodeName);
|
|
|
- wbsTreeContractVO2.setPartitionCode(partitionCode);
|
|
|
- wbsTreeContractVO2.setIsImportIdentificationNode(1); //识别成功
|
|
|
- wbsTreeContractVO2.setImportMatchingInfo(importMatchingInfoOld);
|
|
|
- //判断是否存在pKeyId一样
|
|
|
- boolean b = false;
|
|
|
- for (WbsTreeContractVO successDatum : successData) {
|
|
|
- if (successDatum.getPKeyId().equals(wbsTreeContractVO2.getPKeyId())) {
|
|
|
- b = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!b) {
|
|
|
- LambdaUpdateWrapper<WbsTreeContract> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.eq(WbsTreeContract::getPKeyId, wbsTreeContractVO2.getPKeyId());
|
|
|
- updateWrapper.set(WbsTreeContract::getFullName, wbsTreeContractVO2.getFullName());
|
|
|
- updateWrapper.set(WbsTreeContract::getPartitionCode, wbsTreeContractVO2.getPartitionCode());
|
|
|
- updateWrapper.set(WbsTreeContract::getIsImportIdentificationNode, wbsTreeContractVO2.getIsImportIdentificationNode());
|
|
|
- updateWrapper.set(WbsTreeContract::getImportMatchingInfo, wbsTreeContractVO2.getImportMatchingInfo());
|
|
|
- baseMapper.update(null, updateWrapper);
|
|
|
- successData.add(wbsTreeContractVO2);
|
|
|
- //重新赋值用于下方条件判断
|
|
|
- nodeOld.setFullName(wbsTreeContractVO2.getFullName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<ImportContractNodeVO> setsList = sets.stream().sorted(Comparator.comparing(ImportContractNodeVO::getPartitionCode)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //不存在类似名称节点,修改
|
|
|
+ for (ImportContractNodeVO set : setsList) {
|
|
|
+ Iterator<WbsTreeContractVO> iterator = wbsTreeContractVOS.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ WbsTreeContractVO nodeOld = iterator.next();
|
|
|
+ if (nodeOld.getNodeType().equals(set.getNodeType())) {
|
|
|
+ String nodeNameOld = nodeOld.getNodeName();
|
|
|
+ String importMatchingInfoOld = nodeOld.getImportMatchingInfo();
|
|
|
+
|
|
|
+ List<WbsTreeContractVO> collect = successData.stream().filter(f -> f.getFullName().contains(set.getNodeName()) && f.getPartitionCode().equals(set.getPartitionCode())).collect(Collectors.toList());
|
|
|
+ if (collect.size() == 0) {
|
|
|
+ if ((set.getNodeName().equals(nodeNameOld) || (StringUtils.isNotEmpty(importMatchingInfoOld) && set.getNodeName().contains(importMatchingInfoOld)))) {
|
|
|
+ WbsTreeContractVO wbsTreeContractVO2 = BeanUtil.copyProperties(nodeOld, WbsTreeContractVO.class);
|
|
|
+ assert wbsTreeContractVO2 != null;
|
|
|
+ //匹配成功 修改名称、划分编号、状态、匹配字段
|
|
|
+ wbsTreeContractVO2.setFullName(set.getNodeName());
|
|
|
+ wbsTreeContractVO2.setPartitionCode(set.getPartitionCode());
|
|
|
+ wbsTreeContractVO2.setIsImportIdentificationNode(1);
|
|
|
+ wbsTreeContractVO2.setImportMatchingInfo(importMatchingInfoOld);
|
|
|
+
|
|
|
+ boolean b = true;
|
|
|
+ for (WbsTreeContractVO successDatum : successData) {
|
|
|
+ if (successDatum.getId().equals(wbsTreeContractVO2.getId())) {
|
|
|
+ b = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- //存在类似名称节点,新增
|
|
|
- List<WbsTreeContractVO> collect1 = successData.stream().filter(f ->
|
|
|
- (DiffListUtil.getSimilarityRatio(nodeName, f.getFullName()) > 0 && DiffListUtil.getSimilarityRatio(nodeName, f.getFullName()) != 100)
|
|
|
- && !f.getPartitionCode().equals(partitionCode)).collect(Collectors.toList());
|
|
|
- if (collect1.size() > 0) {
|
|
|
- if (nodeName.equals(nodeOld.getFullName())) {
|
|
|
+ if (b) {
|
|
|
+ LambdaUpdateWrapper<WbsTreeContract> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.eq(WbsTreeContract::getPKeyId, wbsTreeContractVO2.getPKeyId());
|
|
|
+ updateWrapper.set(WbsTreeContract::getFullName, wbsTreeContractVO2.getFullName());
|
|
|
+ updateWrapper.set(WbsTreeContract::getPartitionCode, wbsTreeContractVO2.getPartitionCode());
|
|
|
+ updateWrapper.set(WbsTreeContract::getIsImportIdentificationNode, wbsTreeContractVO2.getIsImportIdentificationNode());
|
|
|
+ updateWrapper.set(WbsTreeContract::getImportMatchingInfo, wbsTreeContractVO2.getImportMatchingInfo());
|
|
|
+ baseMapper.update(null, updateWrapper);
|
|
|
+ successData.add(wbsTreeContractVO2);
|
|
|
+
|
|
|
+ iterator.remove();
|
|
|
break;
|
|
|
- } else {
|
|
|
- if ((nodeName.contains(nodeOld.getFullName()) && DiffListUtil.getSimilarityRatio(nodeName, nodeOld.getFullName()) != 100)
|
|
|
- && !nodeOld.getPartitionCode().equals(partitionCode)) {
|
|
|
- //构造类似名称节点
|
|
|
- WbsTreeContract wbsTreeContract = BeanUtil.copyProperties(nodeOld, WbsTreeContract.class);
|
|
|
- assert wbsTreeContract != null;
|
|
|
- Long id = SnowFlakeUtil.getId();
|
|
|
- wbsTreeContract.setPKeyId(id);
|
|
|
- wbsTreeContract.setId(id);
|
|
|
- wbsTreeContract.setNodeName(nodeOld.getNodeName() + "_copy");
|
|
|
- wbsTreeContract.setFullName(nodeName);
|
|
|
- wbsTreeContract.setPartitionCode(partitionCode);
|
|
|
- wbsTreeContract.setIsImportIdentificationNode(1);
|
|
|
- wbsTreeContract.setIsConcealedWorksNode(0);
|
|
|
-
|
|
|
- baseMapper.insert(wbsTreeContract);
|
|
|
- WbsTreeContractVO wbsTreeContractVO = BeanUtil.copyProperties(wbsTreeContract, WbsTreeContractVO.class);
|
|
|
- successData.add(wbsTreeContractVO);
|
|
|
- break;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //存在类似名称节点,新增
|
|
|
+ List<WbsTreeContractVO> collect1 = successData.stream().filter(f -> (set.getNodeName().contains(f.getFullName())) && f.getNodeType().equals(set.getNodeType()) && !f.getPartitionCode().equals(set.getPartitionCode())
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ if (collect1.size() > 0) {
|
|
|
+ for (WbsTreeContractVO obj : collect1) {
|
|
|
+ if (!set.getNodeName().equals(obj.getFullName())) {
|
|
|
+ //构造类似名称节点
|
|
|
+ WbsTreeContract wbsTreeContract = BeanUtil.copyProperties(obj, WbsTreeContract.class);
|
|
|
+ assert wbsTreeContract != null;
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
+ wbsTreeContract.setPKeyId(id);
|
|
|
+ wbsTreeContract.setId(id);
|
|
|
+ wbsTreeContract.setNodeName(set.getNodeName() + "_copy");
|
|
|
+ wbsTreeContract.setFullName(set.getNodeName());
|
|
|
+ wbsTreeContract.setPartitionCode(set.getPartitionCode());
|
|
|
+ wbsTreeContract.setIsImportIdentificationNode(1);
|
|
|
+ wbsTreeContract.setIsConcealedWorksNode(0);
|
|
|
+ baseMapper.insert(wbsTreeContract);
|
|
|
+ WbsTreeContractVO wbsTreeContractVO = BeanUtil.copyProperties(wbsTreeContract, WbsTreeContractVO.class);
|
|
|
+ successData.add(wbsTreeContractVO);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //所有失败节点
|
|
|
- Iterator<ImportContractNodeVO> iterator = sets.iterator();
|
|
|
+ //所有节点
|
|
|
+ Iterator<ImportContractNodeVO> iterator = setsList.iterator();
|
|
|
while (iterator.hasNext()) {
|
|
|
ImportContractNodeVO next = iterator.next();
|
|
|
- for (WbsTreeContractVO successDatum : successData) {
|
|
|
- if (successDatum.getFullName().equals(next.getNodeName())
|
|
|
- && successDatum.getPartitionCode().equals(next.getPartitionCode())
|
|
|
- && successDatum.getNodeType().equals(next.getNodeType())) {
|
|
|
- iterator.remove();
|
|
|
- }
|
|
|
- }
|
|
|
+ successData.stream().filter(f -> f.getFullName().equals(next.getNodeName()) && f.getPartitionCode().equals(next.getPartitionCode()) && f.getNodeType().equals(next.getNodeType())).findAny().ifPresent(wbsTreeContractVO -> iterator.remove());
|
|
|
}
|
|
|
- List<WbsTreeContractVO> failData = this.buildFailData(sets);
|
|
|
+ List<WbsTreeContractVO> failData = this.buildFailData(setsList);
|
|
|
|
|
|
- //把successData的节点的上级节点都添加进去
|
|
|
+ //构造successData节点的上级节点
|
|
|
Set<WbsTreeContractVO> set = new HashSet<>();
|
|
|
if (successData.size() > 0) {
|
|
|
//通过ancestors获取所有上级节点
|
|
@@ -709,36 +590,19 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
set.addAll(successData);
|
|
|
|
|
|
- //构造数据
|
|
|
WbsTreeContractVO4 res = new WbsTreeContractVO4();
|
|
|
try {
|
|
|
- //构建成功树
|
|
|
- List<WbsTreeContractVO> collect1 = set.stream().collect(
|
|
|
- Collectors.collectingAndThen(
|
|
|
- Collectors.toCollection(() -> new TreeSet<>(
|
|
|
- Comparator.comparing(o -> o.getId() + ";" + o.getFullName()))), ArrayList::new));
|
|
|
+ //成功
|
|
|
+ List<WbsTreeContractVO> collect1 = set.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getId() + ";" + o.getFullName()))), ArrayList::new));
|
|
|
List<WbsTreeContractVO> successWbsTreeContractVOS = this.buildWbsTreeByStream(collect1, wbsTreeContractRoot.getParentId());
|
|
|
- List<WbsTreeContractVO> collect2 = successWbsTreeContractVOS.stream().sorted(Comparator.comparing(WbsTreeContract::getCreateTime, Comparator.reverseOrder())).collect(Collectors.toList());
|
|
|
- res.setMatchedData(collect2);
|
|
|
+ res.setMatchedData(successWbsTreeContractVOS);
|
|
|
|
|
|
- //构建失败树
|
|
|
+ //失败
|
|
|
List<WbsTreeContractVO> successDataCopyToFail = WbsExcelBatchUtil.deepCopy(successData);
|
|
|
List<WbsTreeContractVO> failDataTree = this.buildFailDataTree(failData, successDataCopyToFail, wbsTreeContractRoot.getParentId());
|
|
|
- List<WbsTreeContractVO> collect3 = failDataTree.stream().collect(
|
|
|
- Collectors.collectingAndThen(
|
|
|
- Collectors.toCollection(() -> new TreeSet<>(
|
|
|
- Comparator.comparing(o -> o.getId() + ";" + o.getFullName()))), ArrayList::new));
|
|
|
+ List<WbsTreeContractVO> collect3 = failDataTree.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getId() + ";" + o.getFullName()))), ArrayList::new));
|
|
|
List<WbsTreeContractVO> failWbsTreeContractVOS = this.buildWbsTreeByStream(collect3, wbsTreeContractRoot.getParentId());
|
|
|
- List<WbsTreeContractVO> collect4 = failWbsTreeContractVOS.stream().sorted(Comparator.comparing(WbsTreeContract::getCreateTime, Comparator.reverseOrder())).collect(Collectors.toList());
|
|
|
- res.setUnmatchedData(collect4);
|
|
|
-
|
|
|
- //重复导入时删除多余节点信息
|
|
|
- List<WbsTreeContract> wbsTreeContractDel = baseMapper.selectList(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()));
|
|
|
- List<Long> delIds = wbsTreeContractDel.stream().filter(f -> f.getNodeName().contains(("_copy_copy")) && f.getId().equals(f.getPKeyId())).collect(Collectors.toList())
|
|
|
- .stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
|
|
|
- if (delIds.size() > 0) {
|
|
|
- baseMapper.deleteByIds(delIds);
|
|
|
- }
|
|
|
+ res.setUnmatchedData(failWbsTreeContractVOS);
|
|
|
|
|
|
return res;
|
|
|
} catch (IOException | ClassNotFoundException e) {
|
|
@@ -747,7 +611,32 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- private List<WbsTreeContractVO> buildFailDataTree(List<WbsTreeContractVO> failData, List<WbsTreeContractVO> successData, Long parentIdRoot) {
|
|
|
+ private List<WbsTreeContractVO> buildFailData(List<ImportContractNodeVO> sets) {
|
|
|
+ List<WbsTreeContractVO> list = new ArrayList<>();
|
|
|
+ for (ImportContractNodeVO next : sets) {
|
|
|
+ String nodeName = next.getNodeName();
|
|
|
+ String partitionCode = next.getPartitionCode();
|
|
|
+ Integer nodeType = next.getNodeType();
|
|
|
+
|
|
|
+ WbsTreeContractVO wbsTreeContract = new WbsTreeContractVO();
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
+ wbsTreeContract.setPKeyId(id);
|
|
|
+ wbsTreeContract.setId(id);
|
|
|
+ wbsTreeContract.setNodeName(nodeName);
|
|
|
+ wbsTreeContract.setFullName(nodeName);
|
|
|
+ wbsTreeContract.setImportMatchingInfo(nodeName);
|
|
|
+ wbsTreeContract.setPartitionCode(partitionCode);
|
|
|
+ wbsTreeContract.setType(1);
|
|
|
+ wbsTreeContract.setNodeType(nodeType);
|
|
|
+ wbsTreeContract.setIsImportIdentificationNode(0);
|
|
|
+ wbsTreeContract.setIsConcealedWorksNode(0);
|
|
|
+ list.add(wbsTreeContract);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<WbsTreeContractVO> buildFailDataTree
|
|
|
+ (List<WbsTreeContractVO> failData, List<WbsTreeContractVO> successData, Long parentIdRoot) {
|
|
|
List<WbsTreeContractVO> resultData = new ArrayList<>();
|
|
|
resultData.addAll(successData);
|
|
|
resultData.addAll(failData);
|
|
@@ -788,32 +677,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return resultData;
|
|
|
}
|
|
|
|
|
|
- private List<WbsTreeContractVO> buildFailData(Set<ImportContractNodeVO> sets) {
|
|
|
- List<WbsTreeContractVO> list = new ArrayList<>();
|
|
|
- Iterator<ImportContractNodeVO> iterator = sets.iterator();
|
|
|
- while (iterator.hasNext()) {
|
|
|
- ImportContractNodeVO next = iterator.next();
|
|
|
- String nodeName = next.getNodeName();
|
|
|
- String partitionCode = next.getPartitionCode();
|
|
|
- Integer nodeType = next.getNodeType();
|
|
|
-
|
|
|
- WbsTreeContractVO wbsTreeContract = new WbsTreeContractVO();
|
|
|
- Long id = SnowFlakeUtil.getId();
|
|
|
- wbsTreeContract.setPKeyId(id);
|
|
|
- wbsTreeContract.setId(id);
|
|
|
- wbsTreeContract.setNodeName(nodeName);
|
|
|
- wbsTreeContract.setFullName(nodeName);
|
|
|
- wbsTreeContract.setImportMatchingInfo(nodeName);
|
|
|
- wbsTreeContract.setPartitionCode(partitionCode);
|
|
|
- wbsTreeContract.setType(1);
|
|
|
- wbsTreeContract.setNodeType(nodeType);
|
|
|
- wbsTreeContract.setIsImportIdentificationNode(0); //识别失败
|
|
|
- wbsTreeContract.setIsConcealedWorksNode(0);
|
|
|
- list.add(wbsTreeContract);
|
|
|
- }
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
private List<WbsTreeContractVO> buildWbsTreeByStream(List<WbsTreeContractVO> wbsTreeVO2s, Long id) {
|
|
|
List<WbsTreeContractVO> list = wbsTreeVO2s.stream().filter(f -> f.getParentId().equals(id)).collect(Collectors.toList());
|
|
|
Map<Long, List<WbsTreeContractVO>> map = wbsTreeVO2s.stream().collect(Collectors.groupingBy(WbsTreeContractVO::getParentId));
|
|
@@ -832,5 +695,88 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private List<Map<Integer, String>> getResultList(ArrayList<Map<String, String>> result, Integer isSplicingNumber) {
|
|
|
+ List<Map<Integer, String>> resultList = new ArrayList<>();
|
|
|
+ String str = "\\s*|\r|\n|\t";
|
|
|
+ for (Map<String, String> map : result) {
|
|
|
+ Map<Integer, String> maps = new HashMap<>();
|
|
|
+ map.forEach((k1, value1) -> {
|
|
|
+ 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 (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)) {
|
|
|
+ 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)) {
|
|
|
+ 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)) {
|
|
|
+ String s4 = "";
|
|
|
+ if (isSplicingNumber == 1) {
|
|
|
+ if (StringUtils.isNotEmpty(v2)) {
|
|
|
+ String s = maps.get(4);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ resultList.add(maps);
|
|
|
+ }
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
|
|
|
}
|