|
@@ -70,6 +70,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.SingleColumnRowMapper;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
@@ -650,7 +651,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//记录状态
|
|
|
String status = "1";
|
|
|
//查询填报状态,type=1资料填报
|
|
|
- InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, primaryKeyId).eq(InformationQuery::getClassify, classify).eq(InformationQuery::getType, 1));
|
|
|
+ InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, primaryKeyId).eq(InformationQuery::getClassify, classify).eq(InformationQuery::getType, 1).last("limit 1"));
|
|
|
if (businessData != null) {
|
|
|
switch (businessData.getStatus()) {
|
|
|
case 0:
|
|
@@ -3223,149 +3224,164 @@ public R<Boolean> removeContractTreeNode(@RequestParam String ids) {
|
|
|
@ApiOperation(value = "新增节点及其子节点")
|
|
|
@TreeCodeUpdate(type = ArgType.CID, value = "#vo.contractId")
|
|
|
public R<Boolean> saveContractTreeNode(@RequestBody AddContractTreeNodeVO vo) {
|
|
|
- //先获取当前节点的信息
|
|
|
- WbsTreeContract treeContract = this.wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(Long.parseLong(vo.getCurrentNodePrimaryKeyId()));
|
|
|
- if (treeContract == null) {
|
|
|
- informationQueryService.delAsyncWbsTree(vo.getContractId());
|
|
|
- throw new ServiceException("该节点为缓存信息,请重试");
|
|
|
- }
|
|
|
-
|
|
|
- //半选allSelectedNodeList = {ArrayList@21723} size = 206
|
|
|
- List<AddContractTreeNodeVO.Node> halfSelectedNodeList = vo.getHalfSelectedList();
|
|
|
- //全选
|
|
|
- List<AddContractTreeNodeVO.Node> allSelectedNodeList = vo.getAllSelectedList();
|
|
|
- //勾选的数据
|
|
|
- List<AddContractTreeNodeVO.Node> selectList = new ArrayList<>();
|
|
|
- selectList.addAll(halfSelectedNodeList);
|
|
|
- selectList.addAll(allSelectedNodeList);
|
|
|
-
|
|
|
- //结果集,匹配节点名称使用
|
|
|
- List<WbsTreePrivate> query = new ArrayList<>();
|
|
|
- List<String> pKeyIds = selectList.stream().map(AddContractTreeNodeVO.Node::getPrimaryKeyId).collect(Collectors.toList());
|
|
|
- //所有相关节点集合
|
|
|
- List<WbsTreePrivateAddVO> selectedNodeList = new ArrayList<>();
|
|
|
-
|
|
|
- //检查新增类型
|
|
|
- if ("1".equals(vo.getSaveType())||"3".equals(vo.getSaveType())) {
|
|
|
- //todo 当前及子节点 当前及父节点
|
|
|
- //当前及父节点时,半选说明其下的子节点并不是全部选中的,所以这时候只需要根据全选的查询其全部子节点即可
|
|
|
- if (allSelectedNodeList.size() > 0) {
|
|
|
- //查询数据
|
|
|
- selectedNodeList = this.unifiedCode(allSelectedNodeList, treeContract, "1", query);
|
|
|
-
|
|
|
- if (ObjectUtil.isEmpty(selectedNodeList)) {
|
|
|
- return R.data(null);
|
|
|
- }
|
|
|
- //检查当前操作的节点是否是填报节点,如果是则需要查询相关联表格
|
|
|
- List<Long> lowNodeIds = selectedNodeList.stream().filter(f -> f.getLow() == 0).map(WbsTreePrivateAddVO::getId).collect(Collectors.toList()); //最底层节点id
|
|
|
- List<WbsTreePrivateAddVO> childList = new ArrayList<>();
|
|
|
- if (lowNodeIds.size() > 0) {
|
|
|
- //只取原始表
|
|
|
- this.foreachQueryChild(lowNodeIds, childList, treeContract);
|
|
|
- //将表格数据设置
|
|
|
- selectedNodeList.addAll(childList);
|
|
|
- }
|
|
|
+ String currentNodePrimaryKeyIds = vo.getCurrentNodePrimaryKeyId();
|
|
|
+ String[] list = currentNodePrimaryKeyIds.split(",");
|
|
|
+ boolean flag;
|
|
|
+ for (String currentNodePrimaryKeyId : list) {
|
|
|
+ //先获取当前节点的信息
|
|
|
+ WbsTreeContract treeContract = this.wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(Long.parseLong(currentNodePrimaryKeyId));
|
|
|
+ if (treeContract == null) {
|
|
|
+ informationQueryService.delAsyncWbsTree(vo.getContractId());
|
|
|
+ throw new ServiceException("该节点为缓存信息,请重试");
|
|
|
+ }
|
|
|
+ //半选allSelectedNodeList = {ArrayList@21723} size = 206
|
|
|
+ List<AddContractTreeNodeVO.Node> halfSelectedNodeList = vo.getHalfSelectedList();
|
|
|
+ //全选
|
|
|
+ List<AddContractTreeNodeVO.Node> allSelectedNodeList = vo.getAllSelectedList();
|
|
|
+ //勾选的数据
|
|
|
+ List<AddContractTreeNodeVO.Node> selectList = new ArrayList<>();
|
|
|
+ selectList.addAll(halfSelectedNodeList);
|
|
|
+ selectList.addAll(allSelectedNodeList);
|
|
|
+
|
|
|
+ //结果集,匹配节点名称使用
|
|
|
+ List<WbsTreePrivate> query = new ArrayList<>();
|
|
|
+ List<String> pKeyIds = selectList.stream().map(AddContractTreeNodeVO.Node::getPrimaryKeyId).collect(Collectors.toList());
|
|
|
+ //所有相关节点集合
|
|
|
+ List<WbsTreePrivateAddVO> selectedNodeList = new ArrayList<>();
|
|
|
+
|
|
|
+ //检查新增类型
|
|
|
+ if ("1".equals(vo.getSaveType())||"3".equals(vo.getSaveType())) {
|
|
|
+ //todo 当前及子节点 当前及父节点
|
|
|
+ //当前及父节点时,半选说明其下的子节点并不是全部选中的,所以这时候只需要根据全选的查询其全部子节点即可
|
|
|
+ if (allSelectedNodeList.size() > 0) {
|
|
|
+ //查询数据
|
|
|
+ selectedNodeList = this.unifiedCode(allSelectedNodeList, treeContract, "1", query);
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(selectedNodeList)) {
|
|
|
+ return R.data(null);
|
|
|
+ }
|
|
|
+ //检查当前操作的节点是否是填报节点,如果是则需要查询相关联表格
|
|
|
+ List<Long> lowNodeIds = selectedNodeList.stream().filter(f -> f.getLow() == 0).map(WbsTreePrivateAddVO::getId).collect(Collectors.toList()); //最底层节点id
|
|
|
+ List<WbsTreePrivateAddVO> childList = new ArrayList<>();
|
|
|
+ if (lowNodeIds.size() > 0) {
|
|
|
+ //只取原始表
|
|
|
+ this.foreachQueryChild(lowNodeIds, childList, treeContract);
|
|
|
+ //将表格数据设置
|
|
|
+ selectedNodeList.addAll(childList);
|
|
|
+ }
|
|
|
|
|
|
- //处理重复的数据
|
|
|
- selectedNodeList = selectedNodeList.stream().collect(Collectors.collectingAndThen(
|
|
|
+ //处理重复的数据
|
|
|
+ selectedNodeList = selectedNodeList.stream().collect(Collectors.collectingAndThen(
|
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreePrivate::getId))),
|
|
|
ArrayList::new
|
|
|
- ));
|
|
|
- }
|
|
|
- //处理半选
|
|
|
- this.disposeHalfSelectList(treeContract, halfSelectedNodeList, selectedNodeList, query);
|
|
|
-
|
|
|
- } else if("2".equals(vo.getSaveType())){
|
|
|
- //todo 仅当前节点操作
|
|
|
- if (allSelectedNodeList.size() > 0) {
|
|
|
- if (allSelectedNodeList.size() != 1) {
|
|
|
- throw new ServiceException("只能选择单节点进行新增操作");
|
|
|
- }
|
|
|
- //查询数据
|
|
|
- selectedNodeList = this.unifiedCode2(allSelectedNodeList, treeContract, "0", query);
|
|
|
- if (ObjectUtil.isEmpty(selectedNodeList)) {
|
|
|
- return R.data(null);
|
|
|
- }
|
|
|
- //检查当前操作的节点是否是填报节点,如果是则需要查询相关联表格
|
|
|
- List<Long> lowNodeIds = selectedNodeList.stream().filter(f -> f.getLow() == 1).map(WbsTreePrivateAddVO::getId).collect(Collectors.toList()); //最底层节点id
|
|
|
- List<WbsTreePrivateAddVO> childList = new ArrayList<>();
|
|
|
- if (lowNodeIds.size() > 0) {
|
|
|
- //只取原始表
|
|
|
- this.foreachQueryChild(lowNodeIds, childList, treeContract);
|
|
|
- //将表格数据设置
|
|
|
- selectedNodeList.addAll(childList);
|
|
|
+ ));
|
|
|
}
|
|
|
+ //处理半选
|
|
|
+ this.disposeHalfSelectList(treeContract, halfSelectedNodeList, selectedNodeList, query);
|
|
|
+
|
|
|
+ } else if("2".equals(vo.getSaveType())||"4".equals(vo.getSaveType())){
|
|
|
+ //todo 仅当前节点操作
|
|
|
+ if (allSelectedNodeList.size() > 0) {
|
|
|
+ //节点划分需求:可以多对多关联
|
|
|
+ if("2".equals(vo.getSaveType())){
|
|
|
+ if (allSelectedNodeList.size() != 1) {
|
|
|
+ throw new ServiceException("只能选择单节点进行新增操作");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询数据
|
|
|
+ selectedNodeList = this.unifiedCode2(allSelectedNodeList, treeContract, "0", query);
|
|
|
+ if (ObjectUtil.isEmpty(selectedNodeList)) {
|
|
|
+ return R.data(null);
|
|
|
+ }
|
|
|
+ //检查当前操作的节点是否是填报节点,如果是则需要查询相关联表格
|
|
|
+ List<Long> lowNodeIds = selectedNodeList.stream().filter(f -> f.getLow() == 1).map(WbsTreePrivateAddVO::getId).collect(Collectors.toList()); //最底层节点id
|
|
|
+ List<WbsTreePrivateAddVO> childList = new ArrayList<>();
|
|
|
+ if (lowNodeIds.size() > 0) {
|
|
|
+ //只取原始表
|
|
|
+ this.foreachQueryChild(lowNodeIds, childList, treeContract);
|
|
|
+ //将表格数据设置
|
|
|
+ selectedNodeList.addAll(childList);
|
|
|
+ }
|
|
|
|
|
|
- //处理重复的数据
|
|
|
- selectedNodeList = selectedNodeList.stream().collect(Collectors.collectingAndThen(
|
|
|
+ //处理重复的数据
|
|
|
+ selectedNodeList = selectedNodeList.stream().collect(Collectors.collectingAndThen(
|
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreePrivate::getId))),
|
|
|
ArrayList::new
|
|
|
- ));
|
|
|
+ ));
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //新增节点类型不能大于选择节点类型
|
|
|
- Set<Integer> nodeType = query.stream()
|
|
|
- .filter(wbsTreeContract -> wbsTreeContract.getNodeType() != null)
|
|
|
- .map(WbsTreePrivate::getNodeType)
|
|
|
- .collect(Collectors.toSet());
|
|
|
- Integer type = treeContract.getNodeType();
|
|
|
- if(type<=6||type==18){
|
|
|
- type = (type == 1) ? 1 : (type == 18) ? 2 : type + 1;
|
|
|
- for (Integer i : nodeType) {
|
|
|
- i = (i == 1) ? 1 : (i == 18) ? 2 : i + 1;
|
|
|
- if (i <=type) {
|
|
|
- throw new ServiceException("当前新增节点类型不能大于或等于父级节点类型");
|
|
|
+ //新增节点类型不能大于选择节点类型
|
|
|
+ Set<Integer> nodeType = query.stream()
|
|
|
+ .filter(wbsTreeContract -> wbsTreeContract.getNodeType() != null)
|
|
|
+ .map(WbsTreePrivate::getNodeType)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ Integer type = treeContract.getNodeType();
|
|
|
+ if(type<=6||type==18){
|
|
|
+ type = (type == 1) ? 1 : (type == 18) ? 2 : type + 1;
|
|
|
+ for (Integer i : nodeType) {
|
|
|
+ i = (i == 1) ? 1 : (i == 18) ? 2 : i + 1;
|
|
|
+ if("1".equals(vo.getSaveType())){
|
|
|
+ if (i <type) {
|
|
|
+ throw new ServiceException("当前新增节点类型不能大于或等于父级节点类型");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (i <=type) {
|
|
|
+ throw new ServiceException("当前新增节点类型不能大于或等于父级节点类型");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
- //保存集合
|
|
|
- List<WbsTreeContract> saveList = new ArrayList<>();
|
|
|
- List<ConstructionLedger> saveLedger = new ArrayList<>();
|
|
|
+ //保存集合
|
|
|
+ List<WbsTreeContract> saveList = new ArrayList<>();
|
|
|
+ List<ConstructionLedger> saveLedger = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
- //封裝节点名称nodeName与id的Map
|
|
|
- Map<Long, String> idAndNodeNameMaps = query.stream()
|
|
|
+ //封裝节点名称nodeName与id的Map
|
|
|
+ Map<Long, String> idAndNodeNameMaps = query.stream()
|
|
|
.filter(wbsTreePrivate -> pKeyIds.contains(wbsTreePrivate.getPKeyId().toString()))
|
|
|
.collect(Collectors.toMap(WbsTreePrivate::getId,
|
|
|
- wbsTreePrivate -> selectList.stream()
|
|
|
- .filter(node -> node.getPrimaryKeyId().equals(wbsTreePrivate.getPKeyId().toString()))
|
|
|
- .findFirst()
|
|
|
- .map(AddContractTreeNodeVO.Node::getNodeName)
|
|
|
- .orElse("")));
|
|
|
+ wbsTreePrivate -> selectList.stream()
|
|
|
+ .filter(node -> node.getPrimaryKeyId().equals(wbsTreePrivate.getPKeyId().toString()))
|
|
|
+ .findFirst()
|
|
|
+ .map(AddContractTreeNodeVO.Node::getNodeName)
|
|
|
+ .orElse("")));
|
|
|
|
|
|
|
|
|
- //原始表ids,电签位置信息使用
|
|
|
- List<Long> oldTabIds = selectedNodeList.stream().filter(f -> new Integer(2).equals(f.getType())).map(WbsTreePrivate::getId).collect(Collectors.toList());
|
|
|
+ //原始表ids,电签位置信息使用
|
|
|
+ List<Long> oldTabIds = selectedNodeList.stream().filter(f -> new Integer(2).equals(f.getType())).map(WbsTreePrivate::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
- //构造参数
|
|
|
- if (selectedNodeList.size() > 0) {
|
|
|
- //重塑关键信息 旧id+新id
|
|
|
- Map<Long, Long> OldIdToNewIdMap = new HashMap<>();
|
|
|
- // 旧pKeyId+新pKeyId
|
|
|
- Map<Long, Long> OldPKeyIdToNewPKeyIdMap = new HashMap<>();
|
|
|
+ //构造参数
|
|
|
+ if (selectedNodeList.size() > 0) {
|
|
|
+ //重塑关键信息
|
|
|
+ Map<Long, Long> OldIdToNewIdMap = new HashMap<>();
|
|
|
+ // 旧pKeyId+新pKeyId
|
|
|
+ Map<Long, Long> OldPKeyIdToNewPKeyIdMap = new HashMap<>();
|
|
|
|
|
|
- Map<String, WbsTreePrivate> nodeMap = new HashMap<>();
|
|
|
- Map<String, WbsTreeContract> nodeMapContract = new HashMap<>();
|
|
|
- selectedNodeList.forEach(half -> {
|
|
|
- OldIdToNewIdMap.put(half.getId(), SnowFlakeUtil.getId());
|
|
|
- nodeMap.put(half.getId().toString(), half);
|
|
|
+ Map<String, WbsTreePrivate> nodeMap = new HashMap<>();
|
|
|
+ Map<String, WbsTreeContract> nodeMapContract = new HashMap<>();
|
|
|
+ selectedNodeList.forEach(half -> {
|
|
|
+ OldIdToNewIdMap.put(half.getId(), SnowFlakeUtil.getId());
|
|
|
+ nodeMap.put(half.getId().toString(), half);
|
|
|
|
|
|
- WbsTreeContract wbsTreeContract = BeanUtil.copyProperties(half, WbsTreeContract.class);
|
|
|
- nodeMapContract.put(half.getId().toString(), wbsTreeContract);
|
|
|
+ WbsTreeContract wbsTreeContract = BeanUtil.copyProperties(half, WbsTreeContract.class);
|
|
|
+ nodeMapContract.put(half.getId().toString(), wbsTreeContract);
|
|
|
|
|
|
- //20250414-lhb-新增 绑定旧keyId和新keyId
|
|
|
- OldPKeyIdToNewPKeyIdMap.put(half.getPKeyId(),SnowFlakeUtil.getId());
|
|
|
- });
|
|
|
+ //20250414-lhb-新增 绑定旧keyId和新keyId
|
|
|
+ OldPKeyIdToNewPKeyIdMap.put(half.getPKeyId(),SnowFlakeUtil.getId());
|
|
|
+
|
|
|
+ });
|
|
|
|
|
|
- //处理数据
|
|
|
- for (WbsTreePrivate half : selectedNodeList) {
|
|
|
- //处理合同段数据
|
|
|
- WbsTreeContract newData = new WbsTreeContract();
|
|
|
- BeanUtils.copyProperties(half, newData);
|
|
|
+ //处理数据
|
|
|
+ for (WbsTreePrivate half : selectedNodeList) {
|
|
|
+ //处理合同段数据
|
|
|
+ WbsTreeContract newData = new WbsTreeContract();
|
|
|
+ BeanUtils.copyProperties(half, newData);
|
|
|
|
|
|
//重塑pKeyId、id和parentId
|
|
|
newData.setPKeyId(OldPKeyIdToNewPKeyIdMap.get(half.getPKeyId()));
|
|
@@ -3373,54 +3389,73 @@ public R<Boolean> saveContractTreeNode(@RequestBody AddContractTreeNodeVO vo) {
|
|
|
newData.setId(OldIdToNewIdMap.containsKey(half.getId()) ? OldIdToNewIdMap.get(half.getId()) : SnowFlakeUtil.getId());
|
|
|
}
|
|
|
|
|
|
- //设置父级id
|
|
|
- boolean var = true;
|
|
|
- if ("1".equals(vo.getSaveType())||"3".equals(vo.getSaveType())) {
|
|
|
- //当前节点及其子节点操作
|
|
|
- if (OldIdToNewIdMap.containsKey(half.getParentId())) {
|
|
|
- //跨节点
|
|
|
- WbsTreePrivate wbsTreePrivate = nodeMap.get(half.getParentId() + "");
|
|
|
- if (treeContract.getNodeType().equals(wbsTreePrivate.getNodeType()) && treeContract.getNodeName().equals(wbsTreePrivate.getNodeName())) {
|
|
|
- newData.setParentId(treeContract.getId());
|
|
|
- newData.setPId(treeContract.getPKeyId());
|
|
|
- var = false;
|
|
|
-
|
|
|
- //从复制or新增节点开始操作-》选择新增节点,根节点会走到这里
|
|
|
- } else if (treeContract.getNodeType().equals(wbsTreePrivate.getNodeType()) && ObjectUtil.isNotEmpty(treeContract.getOldId()) && treeContract.getOldId().equals(wbsTreePrivate.getId().toString())) {
|
|
|
- newData.setParentId(treeContract.getId());
|
|
|
- newData.setPId(treeContract.getPKeyId());
|
|
|
- var = false;
|
|
|
+ //设置父级id
|
|
|
+ boolean var = true;
|
|
|
+ if ("1".equals(vo.getSaveType())||"3".equals(vo.getSaveType())) {
|
|
|
+ //当前节点及其子节点操作
|
|
|
+ if (OldIdToNewIdMap.containsKey(half.getParentId())) {
|
|
|
+ //跨节点
|
|
|
+ WbsTreePrivate wbsTreePrivate = nodeMap.get(half.getParentId() + "");
|
|
|
+ if (treeContract.getNodeType().equals(wbsTreePrivate.getNodeType()) && treeContract.getNodeName().equals(wbsTreePrivate.getNodeName())) {
|
|
|
+ newData.setParentId(treeContract.getId());
|
|
|
+ newData.setPId(treeContract.getPKeyId());
|
|
|
+ var = false;
|
|
|
+
|
|
|
+ //从复制or新增节点开始操作-》选择新增节点,根节点会走到这里
|
|
|
+ } else if (treeContract.getNodeType().equals(wbsTreePrivate.getNodeType()) && ObjectUtil.isNotEmpty(treeContract.getOldId()) && treeContract.getOldId().equals(wbsTreePrivate.getId().toString())) {
|
|
|
+ newData.setParentId(treeContract.getId());
|
|
|
+ newData.setPId(treeContract.getPKeyId());
|
|
|
+ var = false;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if (var) {
|
|
|
- if (ObjectUtil.isNotEmpty(treeContract.getIsCustom()) && treeContract.getIsCustom().equals(1)) {
|
|
|
- //自定义节点(非根节点才处理)
|
|
|
- if (!newData.getParentId().equals(0L)) {
|
|
|
- newData.setParentId(OldIdToNewIdMap.containsKey(half.getParentId())
|
|
|
+ if (var) {
|
|
|
+ if (ObjectUtil.isNotEmpty(treeContract.getIsCustom()) && treeContract.getIsCustom().equals(1)) {
|
|
|
+ //自定义节点(非根节点才处理)
|
|
|
+ if (!newData.getParentId().equals(0L)) {
|
|
|
+ newData.setParentId(OldIdToNewIdMap.containsKey(half.getParentId())
|
|
|
? OldIdToNewIdMap.get(half.getParentId()) : treeContract.getId().equals(half.getParentId())
|
|
|
||
|
|
|
half.getParentId().toString().equals(treeContract.getOldId())
|
|
|
? treeContract.getId() : SnowFlakeUtil.getId());
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- // TODO 现阶段 odlId为被复制节点的Id字段的值 不能不能拿来做PId的匹配 后面考虑优化
|
|
|
- if(!newData.getPId().equals(0L)){
|
|
|
- newData.setPId(OldPKeyIdToNewPKeyIdMap.containsKey(half.getPId())
|
|
|
- ? OldPKeyIdToNewPKeyIdMap.get(half.getPId()) : treeContract.getPKeyId().equals(half.getPId())
|
|
|
- ||
|
|
|
- half.getParentId().toString().equals(treeContract.getOldId())
|
|
|
- ? treeContract.getPKeyId() : SnowFlakeUtil.getId());
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- //非自定义节点
|
|
|
- //同节点
|
|
|
- newData.setParentId(OldIdToNewIdMap.containsKey(half.getParentId())
|
|
|
+ }
|
|
|
+ // TODO 现阶段 odlId为被复制节点的Id字段的值 不能不能拿来做PId的匹配 后面考虑优化
|
|
|
+ if(!newData.getPId().equals(0L)){
|
|
|
+ newData.setPId(OldPKeyIdToNewPKeyIdMap.containsKey(half.getPId())
|
|
|
+ ? OldPKeyIdToNewPKeyIdMap.get(half.getPId()) : treeContract.getPKeyId().equals(half.getPId())
|
|
|
+ ||
|
|
|
+ half.getParentId().toString().equals(treeContract.getOldId())
|
|
|
+ ? treeContract.getPKeyId() : SnowFlakeUtil.getId());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //非自定义节点
|
|
|
+ //同节点
|
|
|
+ newData.setParentId(OldIdToNewIdMap.containsKey(half.getParentId())
|
|
|
? OldIdToNewIdMap.get(half.getParentId()) : treeContract.getId().equals(half.getParentId())
|
|
|
||
|
|
|
half.getParentId().toString().equals(treeContract.getOldId())
|
|
|
? treeContract.getId() : SnowFlakeUtil.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //TODO 仅当前节点新增操作时,父级id=选择新增的节点父级id(同级情况) or 父级id=选择新增的节点id(不同级情况,也就是下级)
|
|
|
+ if (new Integer("1").equals(half.getType())) {
|
|
|
+ if (vo.getAllSelectedList().size() == 1) {
|
|
|
+ AddContractTreeNodeVO.Node node = vo.getAllSelectedList().get(0);
|
|
|
+ if (("1").equals(node.getIsPeer())) {
|
|
|
+ //同级
|
|
|
+ newData.setParentId(treeContract.getParentId());
|
|
|
+ newData.setPId(treeContract.getPId());
|
|
|
+
|
|
|
+ } else if (("2").equals(node.getIsPeer())) {
|
|
|
+ //下一级
|
|
|
+ newData.setParentId(treeContract.getId());
|
|
|
+ newData.setPId(treeContract.getPKeyId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (new Integer("2").equals(half.getType())) {
|
|
|
+ //表
|
|
|
+ newData.setParentId(OldIdToNewIdMap.containsKey(half.getParentId()) ? OldIdToNewIdMap.get(half.getParentId()) : treeContract.getId().equals(half.getParentId()) || treeContract.getOldId().equals(half.getParentId().toString()) ? treeContract.getId() : SnowFlakeUtil.getId());
|
|
|
// TODO 现阶段 odlId为被复制节点的Id字段的值 不能不能拿来做PId的匹配 后面考虑优化
|
|
|
newData.setPId(OldPKeyIdToNewPKeyIdMap.containsKey(half.getPId())
|
|
|
? OldPKeyIdToNewPKeyIdMap.get(half.getPId()) : treeContract.getPKeyId().equals(half.getPId())
|
|
@@ -3430,56 +3465,27 @@ public R<Boolean> saveContractTreeNode(@RequestBody AddContractTreeNodeVO vo) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- } else {
|
|
|
- //TODO 仅当前节点新增操作时,父级id=选择新增的节点父级id(同级情况) or 父级id=选择新增的节点id(不同级情况,也就是下级)
|
|
|
- if (new Integer("1").equals(half.getType())) {
|
|
|
- if (vo.getAllSelectedList().size() == 1) {
|
|
|
- AddContractTreeNodeVO.Node node = vo.getAllSelectedList().get(0);
|
|
|
- if (("1").equals(node.getIsPeer())) {
|
|
|
- //同级
|
|
|
- newData.setParentId(treeContract.getParentId());
|
|
|
- newData.setPId(treeContract.getPId());
|
|
|
-
|
|
|
- } else if (("2").equals(node.getIsPeer())) {
|
|
|
- //下一级
|
|
|
- newData.setParentId(treeContract.getId());
|
|
|
- newData.setPId(treeContract.getPKeyId());
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (new Integer("2").equals(half.getType())) {
|
|
|
- //表
|
|
|
- newData.setParentId(OldIdToNewIdMap.containsKey(half.getParentId()) ? OldIdToNewIdMap.get(half.getParentId()) : treeContract.getId().equals(half.getParentId()) || treeContract.getOldId().equals(half.getParentId().toString()) ? treeContract.getId() : SnowFlakeUtil.getId());
|
|
|
- // TODO 现阶段 odlId为被复制节点的Id字段的值 不能不能拿来做PId的匹配 后面考虑优化
|
|
|
- newData.setPId(OldPKeyIdToNewPKeyIdMap.containsKey(half.getPId())
|
|
|
- ? OldPKeyIdToNewPKeyIdMap.get(half.getPId()) : treeContract.getPKeyId().equals(half.getPId())
|
|
|
- ||
|
|
|
- half.getParentId().toString().equals(treeContract.getOldId())
|
|
|
- ? treeContract.getPKeyId() : SnowFlakeUtil.getId());
|
|
|
+ //记录旧ID
|
|
|
+ newData.setOldId(half.getId().toString());
|
|
|
+ //设置合同段等信息
|
|
|
+ newData.setWbsType(treeContract.getWbsType());
|
|
|
+ newData.setContractId(treeContract.getContractId());
|
|
|
+ newData.setContractIdRelation(treeContract.getContractIdRelation());
|
|
|
+ newData.setContractType(treeContract.getContractType());
|
|
|
+ newData.setCreateTime(new Date());
|
|
|
+ if (Optional.ofNullable(half.getNodeType()).orElse(7) <= 6) {
|
|
|
+ newData.setIsTypePrivatePid(half.getPKeyId());
|
|
|
+ }
|
|
|
+ if (half.getType() != null && new Integer("2").equals(half.getType())) {
|
|
|
+ //2023年8月1日14:41:03更改需求,isBussShow默认=1
|
|
|
+ newData.setIsBussShow(1);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- //记录旧ID
|
|
|
- newData.setOldId(half.getId().toString());
|
|
|
- //设置合同段等信息
|
|
|
- newData.setWbsType(treeContract.getWbsType());
|
|
|
- newData.setContractId(treeContract.getContractId());
|
|
|
- newData.setContractIdRelation(treeContract.getContractIdRelation());
|
|
|
- newData.setContractType(treeContract.getContractType());
|
|
|
- newData.setCreateTime(new Date());
|
|
|
- if (Optional.ofNullable(half.getNodeType()).orElse(7) <= 6) {
|
|
|
- newData.setIsTypePrivatePid(half.getPKeyId());
|
|
|
- }
|
|
|
- if (half.getType() != null && new Integer("2").equals(half.getType())) {
|
|
|
- //2023年8月1日14:41:03更改需求,isBussShow默认=1
|
|
|
- newData.setIsBussShow(1);
|
|
|
- }
|
|
|
|
|
|
- //获取当前所有复制的节点的最大sort
|
|
|
- newData.setSort(ObjectUtils.isNotEmpty(half.getSort()) ? half.getSort() : 0);
|
|
|
+ //获取当前所有复制的节点的最大sort
|
|
|
+ newData.setSort(ObjectUtils.isNotEmpty(half.getSort()) ? half.getSort() : 0);
|
|
|
|
|
|
- //设置节点名称
|
|
|
- newData.setFullName(ObjectUtil.isNotEmpty(idAndNodeNameMaps.get(half.getId())) ? idAndNodeNameMaps.get(half.getId()) : half.getFullName());
|
|
|
+ //设置节点名称
|
|
|
+ newData.setFullName(ObjectUtil.isNotEmpty(idAndNodeNameMaps.get(half.getId())) ? idAndNodeNameMaps.get(half.getId()) : half.getFullName());
|
|
|
|
|
|
/*//重塑父节点关联关系
|
|
|
String ancestors = newData.getAncestors();
|
|
@@ -3500,86 +3506,87 @@ public R<Boolean> saveContractTreeNode(@RequestBody AddContractTreeNodeVO vo) {
|
|
|
newData.setAncestors(stringBuilder.substring(1));
|
|
|
}*/
|
|
|
|
|
|
- //设置到保存集合中
|
|
|
- saveList.add(newData);
|
|
|
+ //设置到保存集合中
|
|
|
+ saveList.add(newData);
|
|
|
|
|
|
- if (new Integer("6").equals(newData.getNodeType()) || new Integer("102").equals(newData.getNodeType())) {
|
|
|
- //生成施工日志
|
|
|
+ if (new Integer("6").equals(newData.getNodeType()) || new Integer("102").equals(newData.getNodeType())) {
|
|
|
+ //生成施工日志
|
|
|
|
|
|
- this.createLedger(newData, saveLedger, null, nodeMapContract);
|
|
|
+ this.createLedger(newData, saveLedger, null, nodeMapContract);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- treeContract.setNodeName(vo.getAllSelectedList().get(0).getNodeName());
|
|
|
-
|
|
|
- /*如果是自定义新增节点处进行新增,那么需要把根节点替换为该节点*/
|
|
|
- List<WbsTreeContract> customResult = new ArrayList<>();
|
|
|
- if (ObjectUtil.isNotEmpty(treeContract.getIsCustom()) && treeContract.getIsCustom().equals(1)) {
|
|
|
- saveList.removeIf(obj -> obj.getParentId().equals(0L)); //删除根节点
|
|
|
-
|
|
|
- List<WbsTreeContract> roots = root(saveList); //选择多个根节点(多个顶层)
|
|
|
- if (roots.size() > 0) {
|
|
|
- for (WbsTreeContract root : roots) {
|
|
|
- List<WbsTreeContract> resultChild = new ArrayList<>();
|
|
|
- child(resultChild, saveList, root); //获取当前根节点对应子级节点
|
|
|
- resultChild.add(0, root);
|
|
|
- List<WbsTreeContract> sortList = sort(resultChild, root.getPKeyId()); //排序
|
|
|
- Map<Long, String> ancestorsMap = new HashMap<>();
|
|
|
- for (WbsTreeContract wbsTreeContract : sortList) { //重新赋值
|
|
|
- if (wbsTreeContract.getPKeyId().equals(root.getPKeyId())) { //根节点
|
|
|
- wbsTreeContract.setParentId(treeContract.getId());
|
|
|
- //20250414-lhb-新增
|
|
|
- wbsTreeContract.setPId(treeContract.getPKeyId());
|
|
|
- wbsTreeContract.setAncestors(treeContract.getAncestors() + "," + wbsTreeContract.getParentId());
|
|
|
- ancestorsMap.put(wbsTreeContract.getId(), wbsTreeContract.getAncestors());
|
|
|
- }
|
|
|
-
|
|
|
- if (ObjectUtil.isEmpty(wbsTreeContract.getAncestors())) { //子级
|
|
|
- String parentAncestors = ancestorsMap.getOrDefault(wbsTreeContract.getParentId(), null);
|
|
|
- if (ObjectUtil.isNotEmpty(parentAncestors)) {
|
|
|
- wbsTreeContract.setAncestors(parentAncestors + "," + wbsTreeContract.getParentId());
|
|
|
+ treeContract.setNodeName(vo.getAllSelectedList().get(0).getNodeName());
|
|
|
+
|
|
|
+ /*如果是自定义新增节点处进行新增,那么需要把根节点替换为该节点*/
|
|
|
+ List<WbsTreeContract> customResult = new ArrayList<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(treeContract.getIsCustom()) && treeContract.getIsCustom().equals(1)) {
|
|
|
+ saveList.removeIf(obj -> obj.getParentId().equals(0L)); //删除根节点
|
|
|
+
|
|
|
+ List<WbsTreeContract> roots = root(saveList); //选择多个根节点(多个顶层)
|
|
|
+ if (roots.size() > 0) {
|
|
|
+ for (WbsTreeContract root : roots) {
|
|
|
+ List<WbsTreeContract> resultChild = new ArrayList<>();
|
|
|
+ child(resultChild, saveList, root); //获取当前根节点对应子级节点
|
|
|
+ resultChild.add(0, root);
|
|
|
+ List<WbsTreeContract> sortList = sort(resultChild, root.getPKeyId()); //排序
|
|
|
+ Map<Long, String> ancestorsMap = new HashMap<>();
|
|
|
+ for (WbsTreeContract wbsTreeContract : sortList) { //重新赋值
|
|
|
+ if (wbsTreeContract.getPKeyId().equals(root.getPKeyId())) { //根节点
|
|
|
+ wbsTreeContract.setParentId(treeContract.getId());
|
|
|
+ wbsTreeContract.setAncestors(treeContract.getAncestors() + "," + wbsTreeContract.getParentId());
|
|
|
ancestorsMap.put(wbsTreeContract.getId(), wbsTreeContract.getAncestors());
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- customResult.add(wbsTreeContract);
|
|
|
+ if (ObjectUtil.isEmpty(wbsTreeContract.getAncestors())) { //子级
|
|
|
+ String parentAncestors = ancestorsMap.getOrDefault(wbsTreeContract.getParentId(), null);
|
|
|
+ if (ObjectUtil.isNotEmpty(parentAncestors)) {
|
|
|
+ wbsTreeContract.setAncestors(parentAncestors + "," + wbsTreeContract.getParentId());
|
|
|
+ ancestorsMap.put(wbsTreeContract.getId(), wbsTreeContract.getAncestors());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ customResult.add(wbsTreeContract);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (customResult.size() > 0) {
|
|
|
- saveList.clear();
|
|
|
- saveList.addAll(customResult);
|
|
|
- }
|
|
|
- //找到最顶级节点设置parentId
|
|
|
- WbsTreeContract topLevelNode = findTopLevelNode(saveList);
|
|
|
- if (ObjectUtils.isNotEmpty(topLevelNode)) {
|
|
|
- for (WbsTreeContract wbsTreeContract : saveList) {
|
|
|
- if (topLevelNode.getPKeyId().equals(wbsTreeContract.getPKeyId())) {
|
|
|
- wbsTreeContract.setParentId(treeContract.getId());
|
|
|
- //20250414-lhb-新增
|
|
|
- wbsTreeContract.setPId(treeContract.getPKeyId());
|
|
|
+ if (customResult.size() > 0) {
|
|
|
+ saveList.clear();
|
|
|
+ saveList.addAll(customResult);
|
|
|
+ }
|
|
|
+ //找到最顶级节点设置parentId
|
|
|
+ WbsTreeContract topLevelNode = findTopLevelNode(saveList);
|
|
|
+ if (ObjectUtils.isNotEmpty(topLevelNode)) {
|
|
|
+ for (WbsTreeContract wbsTreeContract : saveList) {
|
|
|
+ if (topLevelNode.getPKeyId().equals(wbsTreeContract.getPKeyId())) {
|
|
|
+ wbsTreeContract.setParentId(treeContract.getId());
|
|
|
+ //20250414-lhb-新增
|
|
|
+ wbsTreeContract.setPId(treeContract.getPKeyId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- //20250414-lhb-新增 添加ancestorsPId字段
|
|
|
- List<WbsTreeContract> contractWbsTreeByContractId = wbsTreeContractClient.getContractWbsTreeByContractId(Long.valueOf(treeContract.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);
|
|
|
- });
|
|
|
-
|
|
|
- R<Boolean> booleanR = this.saveOrCopyNodeTree(saveList, saveLedger, 2, treeContract);
|
|
|
+ //20250414-lhb-新增 添加ancestorsPId字段
|
|
|
+ List<WbsTreeContract> contractWbsTreeByContractId = wbsTreeContractClient.getContractWbsTreeByContractId(Long.valueOf(treeContract.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);
|
|
|
+ });
|
|
|
|
|
|
- List<WbsTreeContract> nowTabs = saveList.stream().filter(f -> new Integer(2).equals(f.getType())).collect(Collectors.toList());
|
|
|
- this.updateTextDictInfos(nowTabs, oldTabIds, vo.getProjectId());//获取电签信息、默认信息
|
|
|
+ R<Boolean> booleanR = this.saveOrCopyNodeTree(saveList, saveLedger, 2, treeContract);
|
|
|
|
|
|
- iUserClient.clearContractLocalCacheAndRedisCache();
|
|
|
+ List<WbsTreeContract> nowTabs = saveList.stream().filter(f -> new Integer(2).equals(f.getType())).collect(Collectors.toList());
|
|
|
+ this.updateTextDictInfos(nowTabs, oldTabIds, vo.getProjectId());//获取电签信息、默认信息
|
|
|
+ iUserClient.clearContractLocalCacheAndRedisCache();
|
|
|
+ flag=booleanR.getData();
|
|
|
+ if(!flag){
|
|
|
+ return R.data(false,"操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(true,"操作成功");
|
|
|
|
|
|
- return booleanR;
|
|
|
}
|
|
|
|
|
|
public static WbsTreeContract findTopLevelNode(List<WbsTreeContract> saveList) {
|