|
@@ -45,8 +45,7 @@ import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
|
-import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
|
+import java.util.concurrent.*;
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -68,8 +67,8 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
private final TextdictInfoServiceImpl textDictInfoService;
|
|
private final TextdictInfoServiceImpl textDictInfoService;
|
|
private final InformationQueryClient informationQueryClient;
|
|
private final InformationQueryClient informationQueryClient;
|
|
|
|
|
|
- @Resource(name = "taskExecutor1")
|
|
|
|
- private final ThreadPoolExecutor executor;
|
|
|
|
|
|
+ //创建线程池任务
|
|
|
|
+ private final ExecutorService executor = Executors.newFixedThreadPool(4);
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<WbsTreePrivateVO> tree(String wbsId, String projectId) {
|
|
public List<WbsTreePrivateVO> tree(String wbsId, String projectId) {
|
|
@@ -598,218 +597,245 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
@Override
|
|
@Override
|
|
public boolean syncNodeParam(String projectId) {
|
|
public boolean syncNodeParam(String projectId) {
|
|
if (StringUtils.isNotEmpty(projectId)) {
|
|
if (StringUtils.isNotEmpty(projectId)) {
|
|
- //获取项目节点树
|
|
|
|
|
|
+ //结果集
|
|
|
|
+ List<WbsParam> updateList = new ArrayList<>();
|
|
|
|
+ List<WbsParam> insertList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ //获取项目节点树、包括试验、资料填报
|
|
List<WbsTreePrivate> wbsTreePrivateAllNow = baseMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
List<WbsTreePrivate> wbsTreePrivateAllNow = baseMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
.select(WbsTreePrivate::getPKeyId, WbsTreePrivate::getId, WbsTreePrivate::getWbsId)
|
|
.select(WbsTreePrivate::getPKeyId, WbsTreePrivate::getId, WbsTreePrivate::getWbsId)
|
|
- .eq(WbsTreePrivate::getProjectId, projectId).eq(WbsTreePrivate::getStatus, 1).eq(WbsTreePrivate::getType, 1));
|
|
|
|
- String wbsId = wbsTreePrivateAllNow.stream().map(WbsTreePrivate::getWbsId).findAny().orElse(null);
|
|
|
|
- if (StringUtils.isNotEmpty(wbsId)) {
|
|
|
|
- List<WbsParamVO> paramListData = new ArrayList<>();
|
|
|
|
- //获取公有树
|
|
|
|
- Map<Long, WbsTree> treePublicNodeAll = wbsTreeMapper.selectList(Wrappers.<WbsTree>query().lambda()
|
|
|
|
- .select(WbsTree::getId)
|
|
|
|
- .eq(WbsTree::getWbsId, wbsId).eq(WbsTree::getStatus, 1)
|
|
|
|
- .eq(WbsTree::getType, 1))
|
|
|
|
- .stream().collect(Collectors.toMap(WbsTree::getId, Function.identity()));
|
|
|
|
-
|
|
|
|
- if (treePublicNodeAll.size() > 0) {
|
|
|
|
- //TODO ---------公有引用同步---------
|
|
|
|
- Map<String, Long> map = new HashMap<>();
|
|
|
|
- for (WbsTreePrivate wbsTreePrivate : wbsTreePrivateAllNow) {
|
|
|
|
- WbsTree wbsTree = treePublicNodeAll.get(wbsTreePrivate.getId());
|
|
|
|
- if (wbsTree != null) {
|
|
|
|
- map.put(wbsTreePrivate.getPKeyId() + "," + wbsTree.getId(), wbsTree.getId());
|
|
|
|
|
|
+ .eq(WbsTreePrivate::getProjectId, projectId)
|
|
|
|
+ .eq(WbsTreePrivate::getStatus, 1)
|
|
|
|
+ .eq(WbsTreePrivate::getType, 1)
|
|
|
|
+ .in(WbsTreePrivate::getWbsType, Arrays.asList(1, 2)));
|
|
|
|
+
|
|
|
|
+ Map<String, List<String>> collect = wbsTreePrivateAllNow.stream().map(WbsTreePrivate::getWbsId).collect(Collectors.groupingBy(Object::toString));
|
|
|
|
+ for (Map.Entry<String, List<String>> wbsIds : collect.entrySet()) {
|
|
|
|
+ String wbsId = wbsIds.getKey();
|
|
|
|
+ if (StringUtils.isNotEmpty(wbsId)) {
|
|
|
|
+ List<WbsParamVO> paramListData = new ArrayList<>();
|
|
|
|
+ //获取公有树
|
|
|
|
+ Map<Long, WbsTree> treePublicNodeAll = wbsTreeMapper.selectList(Wrappers.<WbsTree>query().lambda()
|
|
|
|
+ .select(WbsTree::getId)
|
|
|
|
+ .eq(WbsTree::getWbsId, wbsId)
|
|
|
|
+ .eq(WbsTree::getStatus, 1)
|
|
|
|
+ .eq(WbsTree::getType, 1))
|
|
|
|
+ .stream().collect(Collectors.toMap(WbsTree::getId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ if (treePublicNodeAll.size() > 0) {
|
|
|
|
+ //TODO ---------公有引用同步---------
|
|
|
|
+ Map<String, Long> map = new HashMap<>();
|
|
|
|
+ for (WbsTreePrivate wbsTreePrivate : wbsTreePrivateAllNow) {
|
|
|
|
+ WbsTree wbsTree = treePublicNodeAll.get(wbsTreePrivate.getId());
|
|
|
|
+ if (wbsTree != null) {
|
|
|
|
+ map.put(wbsTreePrivate.getPKeyId() + "," + wbsTree.getId(), wbsTree.getId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- Set<String> keyIds = map.keySet();
|
|
|
|
- List<Long> wbsTreeIds = new ArrayList<>(map.values());
|
|
|
|
- List<WbsParam> wbsParamList = new ArrayList<>();
|
|
|
|
- //分组查询
|
|
|
|
- List<List<Long>> partition = Lists.partition(wbsTreeIds, 1000);
|
|
|
|
- for (List<Long> ids : partition) {
|
|
|
|
- String sql = "select id,name,k,v,node_id,remark from m_wbs_param where node_id in (" + org.apache.commons.lang.StringUtils.join(ids, ",") + ")";
|
|
|
|
- List<WbsParam> wbsParams = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsParam.class));
|
|
|
|
- wbsParamList.addAll(wbsParams);
|
|
|
|
- }
|
|
|
|
|
|
+ Set<String> keyIds = map.keySet();
|
|
|
|
+ List<Long> wbsTreeIds = new ArrayList<>(map.values());
|
|
|
|
+ List<WbsParam> wbsParamList = new ArrayList<>();
|
|
|
|
+ //分组查询
|
|
|
|
+ List<List<Long>> partition = Lists.partition(wbsTreeIds, 1000);
|
|
|
|
+ for (List<Long> ids : partition) {
|
|
|
|
+ String sql = "select id,name,k,v,node_id,remark from m_wbs_param where node_id in (" + org.apache.commons.lang.StringUtils.join(ids, ",") + ")";
|
|
|
|
+ List<WbsParam> wbsParams = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsParam.class));
|
|
|
|
+ wbsParamList.addAll(wbsParams);
|
|
|
|
+ }
|
|
|
|
|
|
- for (String ids : keyIds) {
|
|
|
|
- String nodePKeyIdNow = ids.split(",")[0];
|
|
|
|
- String nodeIdOld = ids.split(",")[1];
|
|
|
|
- List<WbsParam> wbsParams = wbsParamList.stream().filter(f -> ObjectUtils.isNotEmpty(f.getNodeId()) && f.getNodeId().toString().equals(nodeIdOld)).collect(Collectors.toList());
|
|
|
|
- //获取引用的节点参数
|
|
|
|
- if (wbsParams.size() > 0) {
|
|
|
|
- for (WbsParam wbsParam : wbsParams) {
|
|
|
|
- WbsParamVO param = BeanUtil.copyProperties(wbsParam, WbsParamVO.class);
|
|
|
|
- if (param != null) {
|
|
|
|
- param.setProjectId(Long.parseLong(projectId));
|
|
|
|
- param.setId(SnowFlakeUtil.getId());
|
|
|
|
- param.setNodeId(Long.parseLong(nodePKeyIdNow));
|
|
|
|
- param.setOldId(wbsParam.getId());
|
|
|
|
- param.setType(1);
|
|
|
|
- param.setStatus(1);
|
|
|
|
- param.setIsDeleted(0);
|
|
|
|
- paramListData.add(param);
|
|
|
|
|
|
+ for (String ids : keyIds) {
|
|
|
|
+ String nodePKeyIdNow = ids.split(",")[0];
|
|
|
|
+ String nodeIdOld = ids.split(",")[1];
|
|
|
|
+ List<WbsParam> wbsParams = wbsParamList.stream().filter(f -> ObjectUtils.isNotEmpty(f.getNodeId()) && f.getNodeId().toString().equals(nodeIdOld)).collect(Collectors.toList());
|
|
|
|
+ //获取引用的节点参数
|
|
|
|
+ if (wbsParams.size() > 0) {
|
|
|
|
+ for (WbsParam wbsParam : wbsParams) {
|
|
|
|
+ WbsParamVO param = BeanUtil.copyProperties(wbsParam, WbsParamVO.class);
|
|
|
|
+ if (param != null) {
|
|
|
|
+ param.setProjectId(Long.parseLong(projectId));
|
|
|
|
+ param.setId(SnowFlakeUtil.getId());
|
|
|
|
+ param.setNodeId(Long.parseLong(nodePKeyIdNow));
|
|
|
|
+ param.setOldId(wbsParam.getId());
|
|
|
|
+ param.setType(1);
|
|
|
|
+ param.setStatus(1);
|
|
|
|
+ param.setIsDeleted(0);
|
|
|
|
+ paramListData.add(param);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
- } else {
|
|
|
|
- //TODO ---------私有引用同步---------
|
|
|
|
- Map<String, Long> map = new HashMap<>();
|
|
|
|
- WbsTreePrivate treePrivateRootNode = baseMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
|
- .select(WbsTreePrivate::getWbsId, WbsTreePrivate::getProjectId)
|
|
|
|
- .eq(WbsTreePrivate::getPKeyId, wbsId).eq(WbsTreePrivate::getParentId, 0L).eq(WbsTreePrivate::getStatus, 1).eq(WbsTreePrivate::getType, 1));
|
|
|
|
-
|
|
|
|
- Map<Long, WbsTreePrivate> treePrivateNodeAll = baseMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
|
- .select(WbsTreePrivate::getPKeyId, WbsTreePrivate::getId)
|
|
|
|
- .eq(WbsTreePrivate::getWbsId, treePrivateRootNode.getWbsId()).eq(WbsTreePrivate::getProjectId, treePrivateRootNode.getProjectId())
|
|
|
|
- .eq(WbsTreePrivate::getStatus, 1).eq(WbsTreePrivate::getType, 1)).stream().collect(Collectors.toMap(WbsTreePrivate::getId, Function.identity()));
|
|
|
|
-
|
|
|
|
- for (WbsTreePrivate wbsTreePrivate : wbsTreePrivateAllNow) {
|
|
|
|
- WbsTreePrivate wbsTreePrivateYS = treePrivateNodeAll.get(wbsTreePrivate.getId());
|
|
|
|
- if (wbsTreePrivateYS != null) {
|
|
|
|
- map.put(wbsTreePrivate.getPKeyId() + "," + wbsTreePrivateYS.getPKeyId(), wbsTreePrivateYS.getPKeyId());
|
|
|
|
|
|
+ } else {
|
|
|
|
+ //TODO ---------私有引用同步---------
|
|
|
|
+ Map<String, Long> map = new HashMap<>();
|
|
|
|
+ WbsTreePrivate treePrivateRootNode = baseMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
|
+ .select(WbsTreePrivate::getWbsId, WbsTreePrivate::getProjectId)
|
|
|
|
+ .eq(WbsTreePrivate::getPKeyId, wbsId).eq(WbsTreePrivate::getParentId, 0L).eq(WbsTreePrivate::getStatus, 1).eq(WbsTreePrivate::getType, 1));
|
|
|
|
+
|
|
|
|
+ Map<Long, WbsTreePrivate> treePrivateNodeAll = baseMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
|
+ .select(WbsTreePrivate::getPKeyId, WbsTreePrivate::getId)
|
|
|
|
+ .eq(WbsTreePrivate::getWbsId, treePrivateRootNode.getWbsId()).eq(WbsTreePrivate::getProjectId, treePrivateRootNode.getProjectId())
|
|
|
|
+ .eq(WbsTreePrivate::getStatus, 1).eq(WbsTreePrivate::getType, 1)).stream().collect(Collectors.toMap(WbsTreePrivate::getId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ for (WbsTreePrivate wbsTreePrivate : wbsTreePrivateAllNow) {
|
|
|
|
+ WbsTreePrivate wbsTreePrivateYS = treePrivateNodeAll.get(wbsTreePrivate.getId());
|
|
|
|
+ if (wbsTreePrivateYS != null) {
|
|
|
|
+ map.put(wbsTreePrivate.getPKeyId() + "," + wbsTreePrivateYS.getPKeyId(), wbsTreePrivateYS.getPKeyId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- Set<String> keyIds = map.keySet();
|
|
|
|
- List<Long> wbsTreeIds = new ArrayList<>(map.values());
|
|
|
|
- List<WbsParam> wbsParamList = new ArrayList<>();
|
|
|
|
- //分组查询
|
|
|
|
- List<List<Long>> partition = Lists.partition(wbsTreeIds, 1000);
|
|
|
|
- for (List<Long> ids : partition) {
|
|
|
|
- String sql = "select id,name,k,v,node_id,remark from m_wbs_param where node_id in (" + org.apache.commons.lang.StringUtils.join(ids, ",") + ")";
|
|
|
|
- List<WbsParam> wbsParams = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsParam.class));
|
|
|
|
- wbsParamList.addAll(wbsParams);
|
|
|
|
- }
|
|
|
|
|
|
+ Set<String> keyIds = map.keySet();
|
|
|
|
+ List<Long> wbsTreeIds = new ArrayList<>(map.values());
|
|
|
|
+ List<WbsParam> wbsParamList = new ArrayList<>();
|
|
|
|
+ //分组查询
|
|
|
|
+ List<List<Long>> partition = Lists.partition(wbsTreeIds, 1000);
|
|
|
|
+ for (List<Long> ids : partition) {
|
|
|
|
+ String sql = "select id,name,k,v,node_id,remark from m_wbs_param where node_id in (" + org.apache.commons.lang.StringUtils.join(ids, ",") + ")";
|
|
|
|
+ List<WbsParam> wbsParams = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsParam.class));
|
|
|
|
+ wbsParamList.addAll(wbsParams);
|
|
|
|
+ }
|
|
|
|
|
|
- for (String ids : keyIds) {
|
|
|
|
- String nodePKeyIdNow = ids.split(",")[0];
|
|
|
|
- String nodePKeyIdYs = ids.split(",")[1];
|
|
|
|
- List<WbsParam> wbsParams = wbsParamList.stream().filter(f -> ObjectUtils.isNotEmpty(f.getNodeId()) && f.getNodeId().toString().equals(nodePKeyIdYs)).collect(Collectors.toList());
|
|
|
|
- //获取引用的节点参数
|
|
|
|
- if (wbsParams.size() > 0) {
|
|
|
|
- for (WbsParam wbsParam : wbsParams) {
|
|
|
|
- WbsParamVO param = BeanUtil.copyProperties(wbsParam, WbsParamVO.class);
|
|
|
|
- if (param != null) {
|
|
|
|
- param.setProjectId(Long.parseLong(projectId));
|
|
|
|
- param.setId(SnowFlakeUtil.getId());
|
|
|
|
- param.setNodeId(Long.parseLong(nodePKeyIdNow));
|
|
|
|
- param.setOldId(wbsParam.getId());
|
|
|
|
- param.setType(1);
|
|
|
|
- param.setStatus(1);
|
|
|
|
- param.setIsDeleted(0);
|
|
|
|
- paramListData.add(param);
|
|
|
|
|
|
+ for (String ids : keyIds) {
|
|
|
|
+ String nodePKeyIdNow = ids.split(",")[0];
|
|
|
|
+ String nodePKeyIdYs = ids.split(",")[1];
|
|
|
|
+ List<WbsParam> wbsParams = wbsParamList.stream().filter(f -> ObjectUtils.isNotEmpty(f.getNodeId()) && f.getNodeId().toString().equals(nodePKeyIdYs)).collect(Collectors.toList());
|
|
|
|
+ //获取引用的节点参数
|
|
|
|
+ if (wbsParams.size() > 0) {
|
|
|
|
+ for (WbsParam wbsParam : wbsParams) {
|
|
|
|
+ WbsParamVO param = BeanUtil.copyProperties(wbsParam, WbsParamVO.class);
|
|
|
|
+ if (param != null) {
|
|
|
|
+ param.setProjectId(Long.parseLong(projectId));
|
|
|
|
+ param.setId(SnowFlakeUtil.getId());
|
|
|
|
+ param.setNodeId(Long.parseLong(nodePKeyIdNow));
|
|
|
|
+ param.setOldId(wbsParam.getId());
|
|
|
|
+ param.setType(1);
|
|
|
|
+ param.setStatus(1);
|
|
|
|
+ param.setIsDeleted(0);
|
|
|
|
+ paramListData.add(param);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- List<WbsParam> updateList = new ArrayList<>();
|
|
|
|
- List<WbsParam> insertList = new ArrayList<>();
|
|
|
|
- List<WbsParam> paramListOldAll = new ArrayList<>();
|
|
|
|
|
|
+ List<WbsParam> paramListOldAll = new ArrayList<>();
|
|
|
|
|
|
- List<Long> oldIds = paramListData.stream().map(WbsParamVO::getOldId).distinct().collect(Collectors.toList());
|
|
|
|
- //分组查询
|
|
|
|
- List<List<Long>> partition = Lists.partition(oldIds, 1000);
|
|
|
|
- for (List<Long> ids : partition) {
|
|
|
|
- String sql1 = "select id,name,k,v,node_id,remark from m_wbs_param where id in( " + org.apache.commons.lang.StringUtils.join(ids, ",") + ")";
|
|
|
|
- List<WbsParam> query = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(WbsParam.class));
|
|
|
|
- paramListOldAll.addAll(query);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //转换为map
|
|
|
|
- Map<Long, WbsParam> mapOld = paramListOldAll.stream().collect(Collectors.toMap(WbsParam::getId, Function.identity()));
|
|
|
|
-
|
|
|
|
- //获取当前项目的节点参数
|
|
|
|
- List<WbsParam> paramListNow = wbsParamMapper.selectList(Wrappers.<WbsParam>lambdaQuery()
|
|
|
|
- .select(WbsParam::getK, WbsParam::getV, WbsParam::getName, WbsParam::getId, WbsParam::getRemark, WbsParam::getNodeId)
|
|
|
|
- .eq(WbsParam::getProjectId, Long.parseLong(projectId)));
|
|
|
|
-
|
|
|
|
- //判断是否存在
|
|
|
|
- Iterator<WbsParamVO> iterator = paramListData.iterator();
|
|
|
|
- while (iterator.hasNext()) {
|
|
|
|
- WbsParamVO next = iterator.next();
|
|
|
|
-
|
|
|
|
- //获取引用的节点上的源参数信息
|
|
|
|
- WbsParam oldObj = mapOld.get(next.getOldId());
|
|
|
|
- //获取被引用的节点上的现参数信息
|
|
|
|
- WbsParam newObj = paramListNow.stream().filter(f -> f.getK().equals(next.getK())
|
|
|
|
- && f.getV().equals(next.getV())
|
|
|
|
- && f.getName().equals(next.getName())
|
|
|
|
- && f.getRemark().equals(next.getRemark())
|
|
|
|
- && f.getNodeId().equals(next.getNodeId())
|
|
|
|
- ).findAny().orElse(null);
|
|
|
|
-
|
|
|
|
- if (oldObj != null && newObj != null) {
|
|
|
|
- //如果源节点参数与现节点参数名称、K、V、备注一致,那么就跳过
|
|
|
|
- if (oldObj.getName().equals(newObj.getName()) && oldObj.getK().equals(newObj.getK()) && oldObj.getV().equals(newObj.getV()) && oldObj.getRemark().equals(newObj.getRemark())) {
|
|
|
|
- iterator.remove();
|
|
|
|
-
|
|
|
|
- //如果源节点参数与现节点参数名称、K一致,V、备注不一致,那么就修改当前名称下的节点参数
|
|
|
|
- } else if (oldObj.getName().equals(newObj.getName()) && oldObj.getK().equals(newObj.getK()) && (!oldObj.getV().equals(newObj.getV()) || !oldObj.getRemark().equals(newObj.getRemark()))) {
|
|
|
|
- newObj.setProjectId(Long.parseLong(projectId));
|
|
|
|
- newObj.setName(oldObj.getName());
|
|
|
|
- newObj.setK(oldObj.getK());
|
|
|
|
- newObj.setV(oldObj.getV());
|
|
|
|
- newObj.setRemark(oldObj.getRemark());
|
|
|
|
- newObj.setType(1);
|
|
|
|
- newObj.setStatus(1);
|
|
|
|
- newObj.setIsDeleted(0);
|
|
|
|
- updateList.add(newObj);
|
|
|
|
-
|
|
|
|
- //如果源节点参数与现节点参数名称不一致,那么新增
|
|
|
|
- } else if (!oldObj.getName().equals(newObj.getName())) {
|
|
|
|
- insertList.add(next);
|
|
|
|
- }
|
|
|
|
|
|
+ List<Long> oldIds = paramListData.stream().map(WbsParamVO::getOldId).distinct().collect(Collectors.toList());
|
|
|
|
+ //分组查询
|
|
|
|
+ List<List<Long>> partition = Lists.partition(oldIds, 1000);
|
|
|
|
+ for (List<Long> ids : partition) {
|
|
|
|
+ String sql1 = "select id,name,k,v,node_id,remark from m_wbs_param where id in( " + org.apache.commons.lang.StringUtils.join(ids, ",") + ")";
|
|
|
|
+ List<WbsParam> query = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(WbsParam.class));
|
|
|
|
+ paramListOldAll.addAll(query);
|
|
|
|
+ }
|
|
|
|
|
|
- } else if (oldObj != null) {
|
|
|
|
- //二次过滤,节点名称、节点id相同,修改
|
|
|
|
- List<WbsParam> query = paramListNow.stream().filter(f -> f.getName().equals(next.getName())
|
|
|
|
|
|
+ //转换为map
|
|
|
|
+ Map<Long, WbsParam> mapOld = paramListOldAll.stream().collect(Collectors.toMap(WbsParam::getId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ //获取当前项目的节点参数
|
|
|
|
+ List<WbsParam> paramListNow = wbsParamMapper.selectList(Wrappers.<WbsParam>lambdaQuery()
|
|
|
|
+ .select(WbsParam::getK, WbsParam::getV, WbsParam::getName, WbsParam::getId, WbsParam::getRemark, WbsParam::getNodeId)
|
|
|
|
+ .eq(WbsParam::getProjectId, Long.parseLong(projectId)));
|
|
|
|
+
|
|
|
|
+ //判断是否存在
|
|
|
|
+ Iterator<WbsParamVO> iterator = paramListData.iterator();
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ WbsParamVO next = iterator.next();
|
|
|
|
+
|
|
|
|
+ //获取引用的节点上的源参数信息
|
|
|
|
+ WbsParam oldObj = mapOld.get(next.getOldId());
|
|
|
|
+ //获取被引用的节点上的现参数信息
|
|
|
|
+ WbsParam newObj = paramListNow.stream().filter(f -> f.getK().equals(next.getK())
|
|
|
|
+ && f.getV().equals(next.getV())
|
|
|
|
+ && f.getName().equals(next.getName())
|
|
|
|
+ && f.getRemark().equals(next.getRemark())
|
|
&& f.getNodeId().equals(next.getNodeId())
|
|
&& f.getNodeId().equals(next.getNodeId())
|
|
- ).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- if (query.size() > 0) {
|
|
|
|
- for (WbsParam wbsParam : query) {
|
|
|
|
- if (oldObj.getName().equals(wbsParam.getName())) {
|
|
|
|
- //修改
|
|
|
|
- wbsParam.setProjectId(Long.parseLong(projectId));
|
|
|
|
- wbsParam.setName(next.getName());
|
|
|
|
- wbsParam.setK(next.getK());
|
|
|
|
- wbsParam.setV(next.getV());
|
|
|
|
- wbsParam.setRemark(next.getRemark());
|
|
|
|
- wbsParam.setType(1);
|
|
|
|
- wbsParam.setStatus(1);
|
|
|
|
- wbsParam.setIsDeleted(0);
|
|
|
|
- updateList.add(wbsParam);
|
|
|
|
|
|
+ ).findAny().orElse(null);
|
|
|
|
+
|
|
|
|
+ if (oldObj != null && newObj != null) {
|
|
|
|
+ //如果源节点参数与现节点参数名称、K、V、备注一致,那么就跳过
|
|
|
|
+ if (oldObj.getName().equals(newObj.getName()) && oldObj.getK().equals(newObj.getK()) && oldObj.getV().equals(newObj.getV()) && oldObj.getRemark().equals(newObj.getRemark())) {
|
|
|
|
+ iterator.remove();
|
|
|
|
+
|
|
|
|
+ //如果源节点参数与现节点参数名称、K一致,V、备注不一致,那么就修改当前名称下的节点参数
|
|
|
|
+ } else if (oldObj.getName().equals(newObj.getName()) && oldObj.getK().equals(newObj.getK()) && (!oldObj.getV().equals(newObj.getV()) || !oldObj.getRemark().equals(newObj.getRemark()))) {
|
|
|
|
+ newObj.setProjectId(Long.parseLong(projectId));
|
|
|
|
+ newObj.setName(oldObj.getName());
|
|
|
|
+ newObj.setK(oldObj.getK());
|
|
|
|
+ newObj.setV(oldObj.getV());
|
|
|
|
+ newObj.setRemark(oldObj.getRemark());
|
|
|
|
+ newObj.setType(1);
|
|
|
|
+ newObj.setStatus(1);
|
|
|
|
+ newObj.setIsDeleted(0);
|
|
|
|
+ updateList.add(newObj);
|
|
|
|
+
|
|
|
|
+ //如果源节点参数与现节点参数名称不一致,那么新增
|
|
|
|
+ } else if (!oldObj.getName().equals(newObj.getName())) {
|
|
|
|
+ insertList.add(next);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else if (oldObj != null) {
|
|
|
|
+ //二次过滤,节点名称、节点id相同,修改
|
|
|
|
+ List<WbsParam> query = paramListNow.stream().filter(f -> f.getName().equals(next.getName())
|
|
|
|
+ && f.getNodeId().equals(next.getNodeId())
|
|
|
|
+ ).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ if (query.size() > 0) {
|
|
|
|
+ for (WbsParam wbsParam : query) {
|
|
|
|
+ if (oldObj.getName().equals(wbsParam.getName())) {
|
|
|
|
+ //修改
|
|
|
|
+ wbsParam.setProjectId(Long.parseLong(projectId));
|
|
|
|
+ wbsParam.setName(next.getName());
|
|
|
|
+ wbsParam.setK(next.getK());
|
|
|
|
+ wbsParam.setV(next.getV());
|
|
|
|
+ wbsParam.setRemark(next.getRemark());
|
|
|
|
+ wbsParam.setType(1);
|
|
|
|
+ wbsParam.setStatus(1);
|
|
|
|
+ wbsParam.setIsDeleted(0);
|
|
|
|
+ updateList.add(wbsParam);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ //新增
|
|
|
|
+ insertList.add(next);
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- //新增
|
|
|
|
- insertList.add(next);
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if (updateList.size() > 0) {
|
|
|
|
- this.wbsParamServiceImpl.updateBatchById(updateList, 1000);
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if (insertList.size() > 0) {
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ if (updateList.size() > 0) {
|
|
|
|
+ this.wbsParamServiceImpl.updateBatchById(updateList, 1000);
|
|
|
|
+ }
|
|
|
|
+ if (insertList.size() > 0) {
|
|
|
|
+ try {
|
|
List<List<WbsParam>> partition1 = Lists.partition(insertList, 1000);
|
|
List<List<WbsParam>> partition1 = Lists.partition(insertList, 1000);
|
|
- CompletableFuture<Void> handle = CompletableFuture.allOf(partition1.stream().map(addList ->
|
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
|
- wbsParamServiceImpl.insertBatch(addList, 1000);
|
|
|
|
- }, executor)).toArray(CompletableFuture[]::new));
|
|
|
|
- handle.join();
|
|
|
|
|
|
+ CompletionService<Void> completionService = new ExecutorCompletionService<>(executor);
|
|
|
|
+ for (List<WbsParam> addList : partition1) {
|
|
|
|
+ completionService.submit(() -> {
|
|
|
|
+ wbsParamServiceImpl.insertBatch(addList, 1000);
|
|
|
|
+ return null;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ for (int i = 0; i < partition1.size(); i++) {
|
|
|
|
+ try {
|
|
|
|
+ completionService.take().get();
|
|
|
|
+ } catch (ExecutionException e) {
|
|
|
|
+ // 异常处理
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ //释放线程
|
|
|
|
+ executor.shutdown();
|
|
}
|
|
}
|
|
- return true;
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -825,7 +851,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
.eq(ProjectInfo::getId, wbsTreePrivate.getProjectId()));
|
|
.eq(ProjectInfo::getId, wbsTreePrivate.getProjectId()));
|
|
|
|
|
|
List<WbsTreePrivate> insertDataPrivateList = new ArrayList<>();
|
|
List<WbsTreePrivate> insertDataPrivateList = new ArrayList<>();
|
|
- //List<WbsTreeContract> insertDataContractList = new ArrayList<>();
|
|
|
|
|
|
|
|
if (("1").equals(wbsTreePrivate.getWbsType())) {
|
|
if (("1").equals(wbsTreePrivate.getWbsType())) {
|
|
if (("public").equals(projectInfo.getReferenceWbsTemplateType())) {
|
|
if (("public").equals(projectInfo.getReferenceWbsTemplateType())) {
|
|
@@ -863,16 +888,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
List<WbsTree> addPublicTables = addPublicTable.stream().filter(node ->
|
|
List<WbsTree> addPublicTables = addPublicTable.stream().filter(node ->
|
|
wbsTreePrivatesProjectNodes.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).contains(node.getParentId())).collect(Collectors.toList());
|
|
wbsTreePrivatesProjectNodes.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).contains(node.getParentId())).collect(Collectors.toList());
|
|
|
|
|
|
- //获取当前项目下所有施工合同段id
|
|
|
|
- /*List<ContractInfo> contractInfos = contractInfoMapper.selectList(Wrappers.<ContractInfo>lambdaQuery()
|
|
|
|
- .select(ContractInfo::getId, ContractInfo::getContractType)
|
|
|
|
- .eq(ContractInfo::getPId, wbsTreePrivate.getProjectId()));
|
|
|
|
-
|
|
|
|
- //获取当前项目下所有合同段树
|
|
|
|
- List<WbsTreeContract> treeContractListAll = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getProjectId, wbsTreePrivate.getProjectId()).eq(WbsTreeContract::getStatus, 1));
|
|
|
|
- List<WbsTreeContract> treeContractListAllNodes = treeContractListAll.stream().filter(f -> f.getType().equals(1)).collect(Collectors.toList());
|
|
|
|
- List<WbsTreeContract> treeContractListAllTables = treeContractListAll.stream().filter(f -> f.getType().equals(2)).collect(Collectors.toList());*/
|
|
|
|
-
|
|
|
|
//构造
|
|
//构造
|
|
for (WbsTree tree : addPublicTables) {
|
|
for (WbsTree tree : addPublicTables) {
|
|
WbsTreePrivate dataPrivate = BeanUtil.copyProperties(tree, WbsTreePrivate.class);
|
|
WbsTreePrivate dataPrivate = BeanUtil.copyProperties(tree, WbsTreePrivate.class);
|
|
@@ -885,75 +900,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
dataPrivate.setInitTableId(tree.getInitTableId().toString());
|
|
dataPrivate.setInitTableId(tree.getInitTableId().toString());
|
|
//新增
|
|
//新增
|
|
insertDataPrivateList.add(dataPrivate);
|
|
insertDataPrivateList.add(dataPrivate);
|
|
-
|
|
|
|
- /*同步到该项目下所有合同段*/
|
|
|
|
- //找到当前新增成功的元素表
|
|
|
|
- /*for (ContractInfo contractInfo : contractInfos) {
|
|
|
|
- WbsTreeContract dataContract = BeanUtil.copyProperties(dataPrivate, WbsTreeContract.class);
|
|
|
|
- if (dataContract != null) {
|
|
|
|
- Long idContract = SnowFlakeUtil.getId();
|
|
|
|
- dataContract.setPKeyId(idContract);
|
|
|
|
- dataContract.setContractType(contractInfo.getContractType());
|
|
|
|
- dataContract.setWbsType(Integer.valueOf(dataPrivate.getWbsType()));
|
|
|
|
- dataContract.setWbsId(dataPrivate.getWbsId());
|
|
|
|
- dataContract.setContractId(String.valueOf(contractInfo.getId()));
|
|
|
|
- dataContract.setFullName(dataContract.getNodeName());
|
|
|
|
- dataContract.setIsBussShow(1);
|
|
|
|
- if (dataPrivate.getType() == 2) {
|
|
|
|
- dataContract.setIsTypePrivatePid(dataPrivate.getPKeyId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //判断元素表是否存在合同段,存在则不新增;不存在则表示没被引用,新增
|
|
|
|
- WbsTreeContract resultTreeContract = treeContractListAllTables.stream().filter(f ->
|
|
|
|
- f.getId().equals(dataContract.getId())
|
|
|
|
- && f.getNodeName().equals(dataContract.getNodeName())
|
|
|
|
- && f.getWbsId().equals(dataContract.getWbsId())
|
|
|
|
- && f.getProjectId().equals(wbsTreePrivate.getProjectId())
|
|
|
|
- && f.getContractId().equals(String.valueOf(contractInfo.getId()))
|
|
|
|
- && f.getStatus().equals(1)
|
|
|
|
- ).findAny().orElse(null);
|
|
|
|
- if (resultTreeContract != null) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //判断元素表在合同段wbs树中是否存在上级节点,存在则新增;不存在则不新增
|
|
|
|
- WbsTreeContract dataContractParent = treeContractListAllNodes.stream().filter(f ->
|
|
|
|
- f.getContractId().equals(String.valueOf(contractInfo.getId()))
|
|
|
|
- && f.getProjectId().equals(dataContract.getProjectId())
|
|
|
|
- && f.getStatus().equals(1)
|
|
|
|
- && f.getType().equals(1)
|
|
|
|
- && f.getId().equals(dataContract.getParentId())
|
|
|
|
- ).findAny().orElse(null);
|
|
|
|
-
|
|
|
|
- if (dataContractParent != null) {
|
|
|
|
- //新增
|
|
|
|
- insertDataContractList.add(dataContract);
|
|
|
|
-
|
|
|
|
- //获取上级父级节点同级别的复制或新增节点
|
|
|
|
- List<WbsTreeContract> dataContractEquallyNodes = treeContractListAllNodes.stream().filter(f ->
|
|
|
|
- (ObjectUtils.isNotEmpty(f.getOldId()) && f.getOldId().equals(String.valueOf(dataContractParent.getId())))
|
|
|
|
- && f.getContractId().equals(String.valueOf(contractInfo.getId()))
|
|
|
|
- && f.getWbsId().equals(dataContractParent.getWbsId())
|
|
|
|
- && f.getProjectId().equals(dataContractParent.getProjectId())
|
|
|
|
- && f.getStatus().equals(1)
|
|
|
|
- && f.getType().equals(1)
|
|
|
|
- ).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- if (dataContractEquallyNodes.size() > 0) {
|
|
|
|
- //将表单同步到复制或新增的节点下
|
|
|
|
- for (WbsTreeContract treeContractCopy : dataContractEquallyNodes) {
|
|
|
|
- WbsTreeContract dataContractCopyOrAdd = BeanUtil.copyProperties(dataContract, WbsTreeContract.class);
|
|
|
|
- if (dataContractCopyOrAdd != null) {
|
|
|
|
- dataContractCopyOrAdd.setPKeyId(SnowFlakeUtil.getId());
|
|
|
|
- dataContractCopyOrAdd.setParentId(treeContractCopy.getId());
|
|
|
|
-
|
|
|
|
- insertDataContractList.add(dataContractCopyOrAdd);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -992,14 +938,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
List<WbsTreePrivate> addPrivateTables = addPrivateTable.stream().filter(node ->
|
|
List<WbsTreePrivate> addPrivateTables = addPrivateTable.stream().filter(node ->
|
|
wbsTreePrivatesProjectNodes.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).contains(node.getParentId())).collect(Collectors.toList());
|
|
wbsTreePrivatesProjectNodes.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).contains(node.getParentId())).collect(Collectors.toList());
|
|
|
|
|
|
- //获取当前项目下所有施工合同段id
|
|
|
|
- /*List<ContractInfo> contractInfos = contractInfoMapper.selectContractIdByProjectId(wbsTreePrivate.getProjectId());
|
|
|
|
-
|
|
|
|
- //获取当前项目下所有合同段树
|
|
|
|
- List<WbsTreeContract> treeContractListAll = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getProjectId, wbsTreePrivate.getProjectId()).eq(WbsTreeContract::getStatus, 1));
|
|
|
|
- List<WbsTreeContract> treeContractListAllNodes = treeContractListAll.stream().filter(f -> f.getType().equals(1)).collect(Collectors.toList());
|
|
|
|
- List<WbsTreeContract> treeContractListAllTables = treeContractListAll.stream().filter(f -> f.getType().equals(2)).collect(Collectors.toList());*/
|
|
|
|
-
|
|
|
|
//构造
|
|
//构造
|
|
for (WbsTreePrivate tree : addPrivateTables) {
|
|
for (WbsTreePrivate tree : addPrivateTables) {
|
|
WbsTreePrivate dataPrivate = BeanUtil.copyProperties(tree, WbsTreePrivate.class);
|
|
WbsTreePrivate dataPrivate = BeanUtil.copyProperties(tree, WbsTreePrivate.class);
|
|
@@ -1010,73 +948,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
dataPrivate.setProjectId(wbsTreePrivate.getProjectId());
|
|
dataPrivate.setProjectId(wbsTreePrivate.getProjectId());
|
|
dataPrivate.setInitTableId(tree.getInitTableId());
|
|
dataPrivate.setInitTableId(tree.getInitTableId());
|
|
insertDataPrivateList.add(dataPrivate);
|
|
insertDataPrivateList.add(dataPrivate);
|
|
-
|
|
|
|
- //同步到该项目下的所有合同段
|
|
|
|
- /*for (ContractInfo contractInfo : contractInfos) {
|
|
|
|
- WbsTreeContract wbsTreeContract = BeanUtil.copyProperties(dataPrivate, WbsTreeContract.class);
|
|
|
|
- if (wbsTreeContract != null) {
|
|
|
|
- wbsTreeContract.setPKeyId(SnowFlakeUtil.getId());
|
|
|
|
- wbsTreeContract.setWbsId(dataPrivate.getWbsId());
|
|
|
|
- wbsTreeContract.setWbsType(Integer.valueOf(dataPrivate.getWbsType()));
|
|
|
|
- wbsTreeContract.setProjectId(wbsTreePrivate.getProjectId());
|
|
|
|
- wbsTreeContract.setContractType(contractInfo.getContractType());
|
|
|
|
- wbsTreeContract.setContractId(String.valueOf(contractInfo.getId()));
|
|
|
|
- wbsTreeContract.setIsBussShow(1);
|
|
|
|
- if (dataPrivate.getType() == 2) {
|
|
|
|
- wbsTreeContract.setIsTypePrivatePid(dataPrivate.getPKeyId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //判断元素表是否存在合同段,存在则不新增;不存在则新增
|
|
|
|
- WbsTreeContract resultTreeContract = treeContractListAllTables.stream().filter(f ->
|
|
|
|
- f.getId().equals(wbsTreeContract.getId())
|
|
|
|
- && f.getNodeName().equals(wbsTreeContract.getNodeName())
|
|
|
|
- && f.getWbsId().equals(wbsTreeContract.getWbsId())
|
|
|
|
- && f.getProjectId().equals(wbsTreePrivate.getProjectId())
|
|
|
|
- && f.getContractId().equals(String.valueOf(contractInfo.getId()))
|
|
|
|
- && f.getStatus().equals(1)
|
|
|
|
- ).findAny().orElse(null);
|
|
|
|
- if (resultTreeContract != null) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //判断元素表是否存在上级节点,存在则新增;不存在则表示没被引用,不新增
|
|
|
|
- WbsTreeContract wbsTreeContract1 = treeContractListAllNodes.stream().filter(f ->
|
|
|
|
- f.getContractId().equals(wbsTreeContract.getContractId())
|
|
|
|
- && f.getProjectId().equals(wbsTreeContract.getProjectId())
|
|
|
|
- && f.getWbsId().equals(wbsTreeContract.getWbsId())
|
|
|
|
- && f.getStatus().equals(1)
|
|
|
|
- && f.getType().equals(1)
|
|
|
|
- && f.getId().equals(wbsTreeContract.getParentId())
|
|
|
|
- ).findAny().orElse(null);
|
|
|
|
-
|
|
|
|
- if (wbsTreeContract1 != null) {
|
|
|
|
- insertDataContractList.add(wbsTreeContract);
|
|
|
|
-
|
|
|
|
- //获取上级父级节点同级别的复制或新增节点
|
|
|
|
- List<WbsTreeContract> wbsTreeContracts2 = treeContractListAllNodes.stream().filter(f ->
|
|
|
|
- (ObjectUtils.isNotEmpty(f.getOldId()) && f.getOldId().equals(String.valueOf(wbsTreeContract1.getId())))
|
|
|
|
- && f.getContractId().equals(String.valueOf(contractInfo.getId()))
|
|
|
|
- && f.getWbsId().equals(wbsTreePrivate.getWbsId())
|
|
|
|
- && f.getProjectId().equals(wbsTreePrivate.getProjectId())
|
|
|
|
- && f.getStatus().equals(1)
|
|
|
|
- && f.getType().equals(1)
|
|
|
|
- ).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- if (wbsTreeContracts2.size() > 0) {
|
|
|
|
- //将表单同步到复制或新增的节点下
|
|
|
|
- for (WbsTreeContract treeContract : wbsTreeContracts2) {
|
|
|
|
- WbsTreeContract wbsTreeContract2 = BeanUtil.copyProperties(wbsTreeContract, WbsTreeContract.class);
|
|
|
|
- if (wbsTreeContract2 != null) {
|
|
|
|
- wbsTreeContract2.setPKeyId(SnowFlakeUtil.getId());
|
|
|
|
- wbsTreeContract2.setParentId(treeContract.getId());
|
|
|
|
-
|
|
|
|
- insertDataContractList.add(wbsTreeContract2);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1114,14 +985,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
List<WbsTree> addPublicTables = addPublicTable.stream().filter(node ->
|
|
List<WbsTree> addPublicTables = addPublicTable.stream().filter(node ->
|
|
wbsTreePrivatesProjectNodes.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).contains(node.getParentId())).collect(Collectors.toList());
|
|
wbsTreePrivatesProjectNodes.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).contains(node.getParentId())).collect(Collectors.toList());
|
|
|
|
|
|
- //获取当前项目下所有施工合同段id
|
|
|
|
- /*List<ContractInfo> contractInfos = contractInfoMapper.selectList(Wrappers.<ContractInfo>query().lambda().eq(ContractInfo::getPId, wbsTreePrivate.getProjectId()));
|
|
|
|
-
|
|
|
|
- //获取当前项目下所有合同段树
|
|
|
|
- List<WbsTreeContract> treeContractListAll = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getProjectId, wbsTreePrivate.getProjectId()).eq(WbsTreeContract::getStatus, 1));
|
|
|
|
- List<WbsTreeContract> treeContractListAllNodes = treeContractListAll.stream().filter(f -> f.getType().equals(1)).collect(Collectors.toList());
|
|
|
|
- List<WbsTreeContract> treeContractListAllTables = treeContractListAll.stream().filter(f -> f.getType().equals(2)).collect(Collectors.toList());*/
|
|
|
|
-
|
|
|
|
//构造
|
|
//构造
|
|
for (WbsTree tree : addPublicTables) {
|
|
for (WbsTree tree : addPublicTables) {
|
|
WbsTreePrivate dataPrivate = BeanUtil.copyProperties(tree, WbsTreePrivate.class);
|
|
WbsTreePrivate dataPrivate = BeanUtil.copyProperties(tree, WbsTreePrivate.class);
|
|
@@ -1134,75 +997,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
dataPrivate.setInitTableId(ObjectUtils.isNotEmpty(tree.getInitTableId()) ? tree.getInitTableId().toString() : null);
|
|
dataPrivate.setInitTableId(ObjectUtils.isNotEmpty(tree.getInitTableId()) ? tree.getInitTableId().toString() : null);
|
|
//新增
|
|
//新增
|
|
insertDataPrivateList.add(dataPrivate);
|
|
insertDataPrivateList.add(dataPrivate);
|
|
-
|
|
|
|
- /*同步到该项目下所有合同段*/
|
|
|
|
- //找到当前新增成功的元素表
|
|
|
|
- /*for (ContractInfo contractInfo : contractInfos) {
|
|
|
|
- WbsTreeContract dataContract = BeanUtil.copyProperties(dataPrivate, WbsTreeContract.class);
|
|
|
|
- if (dataContract != null) {
|
|
|
|
- Long idContract = SnowFlakeUtil.getId();
|
|
|
|
- dataContract.setPKeyId(idContract);
|
|
|
|
- dataContract.setContractType(contractInfo.getContractType());
|
|
|
|
- dataContract.setWbsType(Integer.valueOf(dataPrivate.getWbsType()));
|
|
|
|
- dataContract.setWbsId(dataPrivate.getWbsId());
|
|
|
|
- dataContract.setContractId(String.valueOf(contractInfo.getId()));
|
|
|
|
- dataContract.setFullName(dataContract.getNodeName());
|
|
|
|
- dataContract.setIsBussShow(1);
|
|
|
|
- if (dataPrivate.getType() == 2) {
|
|
|
|
- dataContract.setIsTypePrivatePid(dataPrivate.getPKeyId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //判断元素表是否存在合同段,存在则不新增;不存在则表示没被引用,新增
|
|
|
|
- WbsTreeContract resultTreeContract = treeContractListAllTables.stream().filter(f ->
|
|
|
|
- f.getId().equals(dataContract.getId())
|
|
|
|
- && f.getNodeName().equals(dataContract.getNodeName())
|
|
|
|
- && f.getWbsId().equals(dataContract.getWbsId())
|
|
|
|
- && f.getProjectId().equals(wbsTreePrivate.getProjectId())
|
|
|
|
- && f.getContractId().equals(String.valueOf(contractInfo.getId()))
|
|
|
|
- && f.getStatus().equals(1)
|
|
|
|
- ).findAny().orElse(null);
|
|
|
|
- if (resultTreeContract != null) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //判断元素表在合同段wbs树中是否存在上级节点,存在则新增;不存在则不新增
|
|
|
|
- WbsTreeContract dataContractParent = treeContractListAllNodes.stream().filter(f ->
|
|
|
|
- f.getContractId().equals(String.valueOf(contractInfo.getId()))
|
|
|
|
- && f.getProjectId().equals(dataContract.getProjectId())
|
|
|
|
- && f.getStatus().equals(1)
|
|
|
|
- && f.getType().equals(1)
|
|
|
|
- && f.getId().equals(dataContract.getParentId())
|
|
|
|
- ).findAny().orElse(null);
|
|
|
|
-
|
|
|
|
- if (dataContractParent != null) {
|
|
|
|
- //新增
|
|
|
|
- insertDataContractList.add(dataContract);
|
|
|
|
-
|
|
|
|
- //获取上级父级节点同级别的复制或新增节点
|
|
|
|
- List<WbsTreeContract> dataContractEquallyNodes = treeContractListAllNodes.stream().filter(f ->
|
|
|
|
- (ObjectUtils.isNotEmpty(f.getOldId()) && f.getOldId().equals(String.valueOf(dataContractParent.getId())))
|
|
|
|
- && f.getContractId().equals(String.valueOf(contractInfo.getId()))
|
|
|
|
- && f.getWbsId().equals(dataContractParent.getWbsId())
|
|
|
|
- && f.getProjectId().equals(dataContractParent.getProjectId())
|
|
|
|
- && f.getStatus().equals(1)
|
|
|
|
- && f.getType().equals(1)
|
|
|
|
- ).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- if (dataContractEquallyNodes.size() > 0) {
|
|
|
|
- //将表单同步到复制或新增的节点下
|
|
|
|
- for (WbsTreeContract treeContractCopy : dataContractEquallyNodes) {
|
|
|
|
- WbsTreeContract dataContractCopyOrAdd = BeanUtil.copyProperties(dataContract, WbsTreeContract.class);
|
|
|
|
- if (dataContractCopyOrAdd != null) {
|
|
|
|
- dataContractCopyOrAdd.setPKeyId(SnowFlakeUtil.getId());
|
|
|
|
- dataContractCopyOrAdd.setParentId(treeContractCopy.getId());
|
|
|
|
-
|
|
|
|
- insertDataContractList.add(dataContractCopyOrAdd);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1239,14 +1033,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
List<WbsTreePrivate> addPrivateTables = addPrivateTable.stream().filter(node ->
|
|
List<WbsTreePrivate> addPrivateTables = addPrivateTable.stream().filter(node ->
|
|
wbsTreePrivatesProjectNodes.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).contains(node.getParentId())).collect(Collectors.toList());
|
|
wbsTreePrivatesProjectNodes.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).contains(node.getParentId())).collect(Collectors.toList());
|
|
|
|
|
|
- //获取当前项目下所有施工合同段id
|
|
|
|
- /*List<ContractInfo> contractInfos = contractInfoMapper.selectContractIdByProjectId(wbsTreePrivate.getProjectId());
|
|
|
|
-
|
|
|
|
- //获取当前项目下所有合同段树
|
|
|
|
- List<WbsTreeContract> treeContractListAll = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getProjectId, wbsTreePrivate.getProjectId()).eq(WbsTreeContract::getStatus, 1));
|
|
|
|
- List<WbsTreeContract> treeContractListAllNodes = treeContractListAll.stream().filter(f -> f.getType().equals(1)).collect(Collectors.toList());
|
|
|
|
- List<WbsTreeContract> treeContractListAllTables = treeContractListAll.stream().filter(f -> f.getType().equals(2)).collect(Collectors.toList());*/
|
|
|
|
-
|
|
|
|
//构造
|
|
//构造
|
|
for (WbsTreePrivate tree : addPrivateTables) {
|
|
for (WbsTreePrivate tree : addPrivateTables) {
|
|
WbsTreePrivate dataPrivate = BeanUtil.copyProperties(tree, WbsTreePrivate.class);
|
|
WbsTreePrivate dataPrivate = BeanUtil.copyProperties(tree, WbsTreePrivate.class);
|
|
@@ -1258,73 +1044,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
dataPrivate.setInitTableId(ObjectUtils.isNotEmpty(tree.getInitTableId()) ? tree.getInitTableId() : null);
|
|
dataPrivate.setInitTableId(ObjectUtils.isNotEmpty(tree.getInitTableId()) ? tree.getInitTableId() : null);
|
|
|
|
|
|
insertDataPrivateList.add(dataPrivate);
|
|
insertDataPrivateList.add(dataPrivate);
|
|
-
|
|
|
|
- //同步到该项目下的所有合同段
|
|
|
|
- /*for (ContractInfo contractInfo : contractInfos) {
|
|
|
|
- WbsTreeContract wbsTreeContract = BeanUtil.copyProperties(dataPrivate, WbsTreeContract.class);
|
|
|
|
- if (wbsTreeContract != null) {
|
|
|
|
- wbsTreeContract.setPKeyId(SnowFlakeUtil.getId());
|
|
|
|
- wbsTreeContract.setWbsId(dataPrivate.getWbsId());
|
|
|
|
- wbsTreeContract.setWbsType(Integer.valueOf(dataPrivate.getWbsType()));
|
|
|
|
- wbsTreeContract.setProjectId(wbsTreePrivate.getProjectId());
|
|
|
|
- wbsTreeContract.setContractType(contractInfo.getContractType());
|
|
|
|
- wbsTreeContract.setContractId(String.valueOf(contractInfo.getId()));
|
|
|
|
- wbsTreeContract.setIsBussShow(1);
|
|
|
|
- if (dataPrivate.getType() == 2) {
|
|
|
|
- wbsTreeContract.setIsTypePrivatePid(dataPrivate.getPKeyId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //判断元素表是否存在合同段,存在则不新增;不存在则新增
|
|
|
|
- WbsTreeContract resultTreeContract = treeContractListAllTables.stream().filter(f ->
|
|
|
|
- f.getId().equals(wbsTreeContract.getId())
|
|
|
|
- && f.getNodeName().equals(wbsTreeContract.getNodeName())
|
|
|
|
- && f.getWbsId().equals(wbsTreeContract.getWbsId())
|
|
|
|
- && f.getProjectId().equals(wbsTreePrivate.getProjectId())
|
|
|
|
- && f.getContractId().equals(String.valueOf(contractInfo.getId()))
|
|
|
|
- && f.getStatus().equals(1)
|
|
|
|
- ).findAny().orElse(null);
|
|
|
|
- if (resultTreeContract != null) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //判断元素表是否存在上级节点,存在则新增;不存在则表示没被引用,不新增
|
|
|
|
- WbsTreeContract wbsTreeContract1 = treeContractListAllNodes.stream().filter(f ->
|
|
|
|
- f.getContractId().equals(wbsTreeContract.getContractId())
|
|
|
|
- && f.getProjectId().equals(wbsTreeContract.getProjectId())
|
|
|
|
- && f.getWbsId().equals(wbsTreeContract.getWbsId())
|
|
|
|
- && f.getStatus().equals(1)
|
|
|
|
- && f.getType().equals(1)
|
|
|
|
- && f.getId().equals(wbsTreeContract.getParentId())
|
|
|
|
- ).findAny().orElse(null);
|
|
|
|
-
|
|
|
|
- if (wbsTreeContract1 != null) {
|
|
|
|
- insertDataContractList.add(wbsTreeContract);
|
|
|
|
-
|
|
|
|
- //获取上级父级节点同级别的复制或新增节点
|
|
|
|
- List<WbsTreeContract> wbsTreeContracts2 = treeContractListAllNodes.stream().filter(f ->
|
|
|
|
- (ObjectUtils.isNotEmpty(f.getOldId()) && f.getOldId().equals(String.valueOf(wbsTreeContract1.getId())))
|
|
|
|
- && f.getContractId().equals(String.valueOf(contractInfo.getId()))
|
|
|
|
- && f.getWbsId().equals(wbsTreePrivate.getWbsId())
|
|
|
|
- && f.getProjectId().equals(wbsTreePrivate.getProjectId())
|
|
|
|
- && f.getStatus().equals(1)
|
|
|
|
- && f.getType().equals(1)
|
|
|
|
- ).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- if (wbsTreeContracts2.size() > 0) {
|
|
|
|
- //将表单同步到复制或新增的节点下
|
|
|
|
- for (WbsTreeContract treeContract : wbsTreeContracts2) {
|
|
|
|
- WbsTreeContract wbsTreeContract2 = BeanUtil.copyProperties(wbsTreeContract, WbsTreeContract.class);
|
|
|
|
- if (wbsTreeContract2 != null) {
|
|
|
|
- wbsTreeContract2.setPKeyId(SnowFlakeUtil.getId());
|
|
|
|
- wbsTreeContract2.setParentId(treeContract.getId());
|
|
|
|
-
|
|
|
|
- insertDataContractList.add(wbsTreeContract2);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1333,9 +1052,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
if (insertDataPrivateList.size() > 0) {
|
|
if (insertDataPrivateList.size() > 0) {
|
|
this.insertBatch(insertDataPrivateList, 1000);
|
|
this.insertBatch(insertDataPrivateList, 1000);
|
|
}
|
|
}
|
|
- /*if (insertDataContractList.size() > 0) {
|
|
|
|
- wbsTreeContractService.insertBatch(insertDataContractList, 1000);
|
|
|
|
- }*/
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
@@ -1432,12 +1148,29 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
jdbcTemplate.execute(delSql);
|
|
jdbcTemplate.execute(delSql);
|
|
}
|
|
}
|
|
|
|
|
|
- List<List<TextdictInfo>> partition1 = Lists.partition(insertData, 1000);
|
|
|
|
- CompletableFuture<Void> handle = CompletableFuture.allOf(partition1.stream().map(addList ->
|
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
|
|
|
+ try {
|
|
|
|
+ List<List<TextdictInfo>> partition1 = Lists.partition(insertData, 1000);
|
|
|
|
+ CompletionService<Void> completionService = new ExecutorCompletionService<>(executor);
|
|
|
|
+ for (List<TextdictInfo> addList : partition1) {
|
|
|
|
+ completionService.submit(() -> {
|
|
textDictInfoService.insertBatch(addList, 1000);
|
|
textDictInfoService.insertBatch(addList, 1000);
|
|
- }, executor)).toArray(CompletableFuture[]::new));
|
|
|
|
- handle.join();
|
|
|
|
|
|
+ return null;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ for (int i = 0; i < partition1.size(); i++) {
|
|
|
|
+ try {
|
|
|
|
+ completionService.take().get();
|
|
|
|
+ } catch (ExecutionException e) {
|
|
|
|
+ // 异常处理
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ //释放线程
|
|
|
|
+ executor.shutdown();
|
|
|
|
+ }
|
|
|
|
|
|
return true;
|
|
return true;
|
|
} else {
|
|
} else {
|