|
@@ -62,16 +62,17 @@ import java.util.function.Function;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
+
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractMapper, WbsTreeContract> implements IWbsTreeContractService {
|
|
public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractMapper, WbsTreeContract> implements IWbsTreeContractService {
|
|
|
|
|
|
- /*static {
|
|
|
|
- *//*parallelStream并行流粒度*//*
|
|
|
|
|
|
+ /*保留 image/lazyQueryContractWbsTree 接口在使用*/
|
|
|
|
+ static {
|
|
|
|
+ /*parallelStream并行流粒度*/
|
|
System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "4");
|
|
System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "4");
|
|
- }*/
|
|
|
|
|
|
+ }
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(WbsTreeContractServiceImpl.class);
|
|
private static final Logger logger = LoggerFactory.getLogger(WbsTreeContractServiceImpl.class);
|
|
private final ConstructionLedgerFeignClient constructionLedgerFeign;
|
|
private final ConstructionLedgerFeignClient constructionLedgerFeign;
|
|
@@ -727,462 +728,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
baseMapper.syncCurrentFormToAllContract(wbsTreePrivate);
|
|
baseMapper.syncCurrentFormToAllContract(wbsTreePrivate);
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public List<WbsTreeContractLazyVO> lazyQueryContractWbsTree(String id, String contractId, String contractIdRelation, String tableOwner) {
|
|
|
|
- if (StringUtils.isEmpty(tableOwner)) {
|
|
|
|
- throw new ServiceException("tableOwner is not null");
|
|
|
|
- }
|
|
|
|
- if (ObjectUtil.isNotEmpty(contractId)) {
|
|
|
|
- ContractInfo contractInfo = contractInfoMapper.selectOne(Wrappers.<ContractInfo>lambdaQuery().select(ContractInfo::getContractName, ContractInfo::getContractType).eq(ContractInfo::getId, contractId));
|
|
|
|
- if (contractInfo != null) {
|
|
|
|
- /*施工合同段*/
|
|
|
|
- if (new Integer(1).equals(contractInfo.getContractType())) {
|
|
|
|
- //获取当前层懒加载节点
|
|
|
|
- String sql = "select p_key_id,contract_id,(SELECT id FROM u_contract_tree_drawings where process_id = p_key_id and is_deleted = 0 limit 1) AS drawingsId,id,parent_id,node_type,type,wbs_type,is_concrete,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,CASE (SELECT count(1) FROM u_tree_contract_first AS tcf WHERE tcf.is_deleted = 0 AND tcf.wbs_node_id = a.p_key_id) WHEN 0 THEN 'false' ELSE 'true' END AS isFirst,IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.type = 1 and b.status = 1 AND b.contract_id = " + contractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.node_type != 111 and a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + contractId + " ORDER BY a.sort,title,a.create_time";
|
|
|
|
- List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
|
- if (lazyNodes.size() > 0) {
|
|
|
|
-
|
|
|
|
- /*根节点直接返回*/
|
|
|
|
- if (lazyNodes.stream().anyMatch(f -> f.getParentId().equals(0L))) {
|
|
|
|
- for (WbsTreeContractLazyVO lazyNode : lazyNodes) {
|
|
|
|
- lazyNode.setSubmitCounts(0);
|
|
|
|
- lazyNode.setColorStatus(2);
|
|
|
|
- lazyNode.setType(lazyNode.getNodeType());
|
|
|
|
- lazyNode.setNotExsitChild(!lazyNode.getHasChildren().equals(1));
|
|
|
|
- lazyNode.setPrimaryKeyId(lazyNode.getPKeyId());
|
|
|
|
- lazyNode.setTitle(contractInfo.getContractName());
|
|
|
|
- }
|
|
|
|
- return lazyNodes;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //获取本地缓存节点信息
|
|
|
|
- List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(contractId);
|
|
|
|
- List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
|
|
|
|
- .collect(Collectors.collectingAndThen(
|
|
|
|
- Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
|
|
- ArrayList::new
|
|
|
|
- ));
|
|
|
|
-
|
|
|
|
- //所有最底层节点
|
|
|
|
- List<WbsTreeContractLazyVO> distinctLowestNodesAll = distinctNodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.collectingAndThen(
|
|
|
|
- Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
|
|
- ArrayList::new
|
|
|
|
- ));
|
|
|
|
-
|
|
|
|
- //获取本地缓存资料信息
|
|
|
|
- List<WbsTreeContractLazyQueryInfoVO> queryInfoList = this.getQueryInfoList(contractId, tableOwner);
|
|
|
|
-
|
|
|
|
- Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
|
- .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
|
|
|
|
- List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
|
|
|
|
-
|
|
|
|
- /*处理数量*/
|
|
|
|
- //填报过的所有最底层节点
|
|
|
|
- List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
|
- List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
|
|
|
|
- //获取本地缓存节点数量统计
|
|
|
|
- List<WbsTreeContractLazyVO> resultParentNodesTB = this.getCachedParentCountNodes(contractId, lowestNodeParentIdsTB, nodesAll, tableOwner);
|
|
|
|
-
|
|
|
|
- /*List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
|
|
|
|
- long startTime1 = System.currentTimeMillis();
|
|
|
|
- this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
|
- long endTime1 = System.currentTimeMillis();
|
|
|
|
- long executionTime1 = endTime1 - startTime1;
|
|
|
|
- logger.info("合同段 " + contractId + " wbs节点树 数量计算 耗时:" + executionTime1 + " ms");*/
|
|
|
|
-
|
|
|
|
- //最底层节点颜色构造后Map
|
|
|
|
- Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
|
|
|
|
- .peek(vo -> {
|
|
|
|
- Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
|
|
|
|
- if (colorStatus != null) {
|
|
|
|
- //任务状态0=未上报=颜色2蓝色、任务状态1=待审批=颜色3橙色、任务状态2=已审批=颜色4绿色、
|
|
|
|
- ///*任务状态3=已废除=颜色1黑色*/(2023年10月16日13:59:00 已废除改为=颜色2蓝色)
|
|
|
|
- vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 2)));
|
|
|
|
- } else {
|
|
|
|
- //未填报的=颜色1黑色
|
|
|
|
- vo.setColorStatus(1);
|
|
|
|
- }
|
|
|
|
- }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
|
|
|
|
-
|
|
|
|
- /*处理颜色*/
|
|
|
|
- long startTime = System.currentTimeMillis();
|
|
|
|
- //先将WbsTreeContractLazyVO转为NodeVO
|
|
|
|
- List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
|
|
|
|
- //转为Map<Long, NodeVO>
|
|
|
|
- Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
|
|
|
|
- //把distinctNodesAll把所有节点转为树形结构,再转为List<NodeVO>对象
|
|
|
|
- List<NodeVO> treeNodeVOList = this.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
|
|
|
|
- //处理节点颜色
|
|
|
|
- NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
|
- //把树形结构转为普通List集合
|
|
|
|
- List<NodeVO> nodeVOS = this.flattenTree(treeNodeVOList);
|
|
|
|
- //获取所有节点颜色Map
|
|
|
|
- Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
|
|
- long endTime = System.currentTimeMillis();
|
|
|
|
- long executionTime = endTime - startTime;
|
|
|
|
- logger.info("合同段 " + contractId + " 处理颜色 执行时间:" + executionTime + " ms");
|
|
|
|
-
|
|
|
|
- /*处理最终结果集*/
|
|
|
|
- if (lazyNodes.size() > 0) {
|
|
|
|
- //处理填报数量
|
|
|
|
- Map<Long, Integer> countMap = new HashMap<>();
|
|
|
|
- for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
|
|
- Long key = node.getPKeyId();
|
|
|
|
- if (countMap.containsKey(key)) {
|
|
|
|
- countMap.put(key, countMap.get(key) + 1);
|
|
|
|
- } else {
|
|
|
|
- countMap.put(key, 1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //返回最终结果集
|
|
|
|
- for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
|
|
|
|
- lazyNodeVO.setType(lazyNodeVO.getNodeType()); //前端显示需要一样的,所以修改成一样的
|
|
|
|
- lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
|
|
|
|
- lazyNodeVO.setPrimaryKeyId(lazyNodeVO.getPKeyId());
|
|
|
|
- if (lazyNodeVO.getParentId() == 0L) {
|
|
|
|
- if (ObjectUtil.isNotEmpty(contractInfo.getContractName())) {
|
|
|
|
- lazyNodeVO.setTitle(contractInfo.getContractName());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //设置数量
|
|
|
|
- lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(lazyNodeVO.getPKeyId())) ? 1 : 0));
|
|
|
|
-
|
|
|
|
- //设置颜色
|
|
|
|
- if (lazyNodeVO.getSubmitCounts().equals(0)) {
|
|
|
|
- lazyNodeVO.setColorStatus(1);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Integer parentColorStatus = nodeColorStatusMap.get(lazyNodeVO.getPKeyId());
|
|
|
|
- if (parentColorStatus != null) {
|
|
|
|
- lazyNodeVO.setColorStatus(parentColorStatus);
|
|
|
|
- } else {
|
|
|
|
- WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(lazyNodeVO.getPKeyId());
|
|
|
|
- if (lowestNode != null) {
|
|
|
|
- lazyNodeVO.setColorStatus(lowestNode.getColorStatus());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return lazyNodes;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /*监理、业主合同段*/
|
|
|
|
- } else if (new Integer("2").equals(contractInfo.getContractType()) || new Integer("3").equals(contractInfo.getContractType())) {
|
|
|
|
- List<WbsTreeContractLazyVO> lazyNodesAll = new ArrayList<>();
|
|
|
|
- List<String> contractIds = new ArrayList<>();
|
|
|
|
- if (ObjectUtil.isNotEmpty(contractIdRelation) && ObjectUtil.isNotEmpty(id)) {
|
|
|
|
- //非根节点时选择加载施工合同段的树
|
|
|
|
- contractIds.add(contractIdRelation);
|
|
|
|
- } else {
|
|
|
|
- //根节点时默认加载所有施工合同段的树
|
|
|
|
- contractIds = this.contractClient.getProcessContractByJLContractId(contractId);
|
|
|
|
- }
|
|
|
|
- if (ObjectUtil.isEmpty(contractIds) || contractIds.size() <= 0) {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- for (String sgContractId : contractIds) {
|
|
|
|
- ContractInfo sgContractInfo = jdbcTemplate.query("select contract_name from m_contract_info where id = " + sgContractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
|
|
|
|
- if (sgContractInfo != null) {
|
|
|
|
- List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,contract_id,(SELECT id FROM u_contract_tree_drawings where process_id = p_key_id and is_deleted = 0 limit 1) AS drawingsId,id,parent_id,node_type,type,wbs_type,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,CASE (SELECT count(1) FROM u_tree_contract_first AS tcf WHERE tcf.is_deleted = 0 AND tcf.wbs_node_id = a.p_key_id) WHEN 0 THEN 'false' ELSE 'true' END AS isFirst,IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.type = 1 and b.status = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.node_type != 111 and a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + sgContractId + " ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
|
- if (lazyNodes.size() > 0) {
|
|
|
|
-
|
|
|
|
- if (lazyNodes.stream().anyMatch(f -> f.getParentId().equals(0L))) {
|
|
|
|
- for (WbsTreeContractLazyVO lazyNode : lazyNodes) {
|
|
|
|
- lazyNode.setSubmitCounts(0);
|
|
|
|
- lazyNode.setColorStatus(2);
|
|
|
|
- lazyNode.setType(lazyNode.getNodeType());
|
|
|
|
- lazyNode.setNotExsitChild(!lazyNode.getHasChildren().equals(1));
|
|
|
|
- lazyNode.setPrimaryKeyId(lazyNode.getPKeyId());
|
|
|
|
- lazyNode.setContractIdRelation(sgContractId);
|
|
|
|
- lazyNode.setTitle(sgContractInfo.getContractName());
|
|
|
|
- }
|
|
|
|
- return lazyNodes;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(sgContractId);
|
|
|
|
- List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
|
|
|
|
- .collect(Collectors.collectingAndThen(
|
|
|
|
- Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
|
|
- ArrayList::new
|
|
|
|
- ));
|
|
|
|
- List<WbsTreeContractLazyVO> distinctLowestNodesAll = distinctNodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.collectingAndThen(
|
|
|
|
- Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
|
|
- ArrayList::new
|
|
|
|
- ));
|
|
|
|
-
|
|
|
|
- List<WbsTreeContractLazyQueryInfoVO> queryInfoList = this.getQueryInfoList(sgContractId, tableOwner);
|
|
|
|
-
|
|
|
|
- Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
|
- .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
|
|
|
|
- List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
|
|
|
|
-
|
|
|
|
- List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
|
- List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- List<WbsTreeContractLazyVO> resultParentNodesTB = this.getCachedParentCountNodes(sgContractId, lowestNodeParentIdsTB, nodesAll, tableOwner);
|
|
|
|
-
|
|
|
|
- Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
|
|
|
|
- .peek(vo -> {
|
|
|
|
- Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
|
|
|
|
- if (colorStatus != null) {
|
|
|
|
- vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 2)));
|
|
|
|
- } else {
|
|
|
|
- vo.setColorStatus(1);
|
|
|
|
- }
|
|
|
|
- }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
|
|
|
|
-
|
|
|
|
- List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
|
|
|
|
- Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
|
|
|
|
- List<NodeVO> treeNodeVOList = this.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
|
|
|
|
- NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
|
- List<NodeVO> nodeVOS = this.flattenTree(treeNodeVOList);
|
|
|
|
- Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
|
|
-
|
|
|
|
- if (lazyNodes.size() > 0) {
|
|
|
|
- Map<Long, Integer> countMap = new HashMap<>();
|
|
|
|
- for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
|
|
- Long key = node.getPKeyId();
|
|
|
|
- if (countMap.containsKey(key)) {
|
|
|
|
- countMap.put(key, countMap.get(key) + 1);
|
|
|
|
- } else {
|
|
|
|
- countMap.put(key, 1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
|
|
|
|
- lazyNodeVO.setType(lazyNodeVO.getNodeType());
|
|
|
|
- lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
|
|
|
|
- lazyNodeVO.setPrimaryKeyId(lazyNodeVO.getPKeyId());
|
|
|
|
- lazyNodeVO.setContractIdRelation(sgContractId);
|
|
|
|
- if (lazyNodeVO.getParentId() == 0L) {
|
|
|
|
- if (ObjectUtil.isNotEmpty(sgContractInfo.getContractName())) {
|
|
|
|
- lazyNodeVO.setTitle(sgContractInfo.getContractName());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(lazyNodeVO.getPKeyId())) ? 1 : 0));
|
|
|
|
- if (lazyNodeVO.getSubmitCounts().equals(0)) {
|
|
|
|
- lazyNodeVO.setColorStatus(1);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Integer parentColorStatus = nodeColorStatusMap.get(lazyNodeVO.getPKeyId());
|
|
|
|
- if (parentColorStatus != null) {
|
|
|
|
- lazyNodeVO.setColorStatus(parentColorStatus);
|
|
|
|
- } else {
|
|
|
|
- WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(lazyNodeVO.getPKeyId());
|
|
|
|
- if (lowestNode != null) {
|
|
|
|
- lazyNodeVO.setColorStatus(lowestNode.getColorStatus());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- lazyNodesAll.addAll(lazyNodes);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return lazyNodesAll;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取当前合同段所有节点缓存
|
|
|
|
- *
|
|
|
|
- * @param contractId
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public List<WbsTreeContractLazyVO> getNodeAll(String contractId) {
|
|
|
|
- //获取本地缓存
|
|
|
|
- List<WbsTreeContractLazyVO> nodesAll = localCacheNodes.get(contractId);
|
|
|
|
-
|
|
|
|
- if (nodesAll == null || nodesAll.isEmpty()) {
|
|
|
|
- //从Redis获取数据
|
|
|
|
- Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + contractId);
|
|
|
|
- if (data != null) {
|
|
|
|
- nodesAll = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
|
|
|
|
- //更新本地缓存
|
|
|
|
- localCacheNodes.put(contractId, nodesAll);
|
|
|
|
- } else {
|
|
|
|
- //返回数据库数据
|
|
|
|
- long startTime = System.currentTimeMillis();
|
|
|
|
-
|
|
|
|
- /*分页查询,每次5000条*/
|
|
|
|
- int pageSize = 5000;
|
|
|
|
- int pageNumber = 1;
|
|
|
|
- int offset;
|
|
|
|
-
|
|
|
|
- nodesAll = new ArrayList<>();
|
|
|
|
- List<WbsTreeContractLazyVO> nodesAllPage;
|
|
|
|
- do {
|
|
|
|
- offset = (pageNumber - 1) * pageSize;
|
|
|
|
- nodesAllPage = jdbcTemplate.query(
|
|
|
|
- "SELECT p_key_id, id, parent_id FROM m_wbs_tree_contract " +
|
|
|
|
- "WHERE type = 1 " +
|
|
|
|
- "AND status = 1 " +
|
|
|
|
- "AND is_deleted = 0 " +
|
|
|
|
- "AND contract_id = ? " +
|
|
|
|
- "LIMIT ? OFFSET ?",
|
|
|
|
- new Object[]{contractId, pageSize, offset},
|
|
|
|
- new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class)
|
|
|
|
- );
|
|
|
|
- nodesAll.addAll(nodesAllPage);
|
|
|
|
- pageNumber++;
|
|
|
|
- } while (nodesAllPage.size() == pageSize);
|
|
|
|
-
|
|
|
|
- long endTime = System.currentTimeMillis();
|
|
|
|
- long executionTime = endTime - startTime;
|
|
|
|
- logger.info("合同段 " + contractId + " 查询所有wbs节点树 执行时间:" + executionTime + " ms");
|
|
|
|
-
|
|
|
|
- if (nodesAll.size() > 0) {
|
|
|
|
- //判断是否有子级,赋值
|
|
|
|
- Map<Long, List<WbsTreeContractLazyVO>> groupedByParentId = nodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
|
|
|
|
- for (WbsTreeContractLazyVO vo : nodesAll) {
|
|
|
|
- if (vo.getParentId() == 0) {
|
|
|
|
- vo.setHasChildren(1);
|
|
|
|
- }
|
|
|
|
- List<WbsTreeContractLazyVO> childNodes = groupedByParentId.getOrDefault(vo.getId(), null);
|
|
|
|
- if (childNodes != null && childNodes.size() > 0) {
|
|
|
|
- vo.setHasChildren(1);
|
|
|
|
- } else {
|
|
|
|
- vo.setHasChildren(0);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //存储到Redis中
|
|
|
|
- JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAll));
|
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + contractId, JSON.toJSON(array).toString());
|
|
|
|
-
|
|
|
|
- //更新本地缓存
|
|
|
|
- localCacheNodes.put(contractId, nodesAll);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return nodesAll;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取节点数量统计缓存
|
|
|
|
- *
|
|
|
|
- * @param contractId
|
|
|
|
- * @param lowestNodeParentIdsTB
|
|
|
|
- * @param nodesAll
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public List<WbsTreeContractLazyVO> getCachedParentCountNodes(String contractId, List<Long> lowestNodeParentIdsTB, List<WbsTreeContractLazyVO> nodesAll, String tableOwner) {
|
|
|
|
- //从本地缓存获取数据
|
|
|
|
- String cacheKey = contractId + "_" + tableOwner;
|
|
|
|
- List<WbsTreeContractLazyVO> resultParentNodesTB = localCacheParentCountNodes.get(cacheKey);
|
|
|
|
-
|
|
|
|
- if (resultParentNodesTB == null || resultParentNodesTB.isEmpty()) {
|
|
|
|
-
|
|
|
|
- //从Redis获取数据
|
|
|
|
- Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byParentCountNodes:" + cacheKey);
|
|
|
|
- if (data != null) {
|
|
|
|
- resultParentNodesTB = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
|
|
|
|
- //更新本地缓存
|
|
|
|
- localCacheParentCountNodes.put(cacheKey, resultParentNodesTB);
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- /*重新计算,进行递归获取父节点计数统计*/
|
|
|
|
- resultParentNodesTB = new ArrayList<>();
|
|
|
|
- long startTime = System.currentTimeMillis();
|
|
|
|
-
|
|
|
|
- this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
|
-
|
|
|
|
- long endTime = System.currentTimeMillis();
|
|
|
|
- long executionTime = endTime - startTime;
|
|
|
|
- logger.info("合同段 " + contractId + " wbs节点树 数量计算 耗时:" + executionTime + " ms");
|
|
|
|
-
|
|
|
|
- if (resultParentNodesTB.size() > 0) {
|
|
|
|
- //存储到Redis中
|
|
|
|
- JSONArray array = JSONArray.parseArray(JSON.toJSONString(resultParentNodesTB));
|
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byParentCountNodes:" + cacheKey, JSON.toJSON(array).toString());
|
|
|
|
-
|
|
|
|
- //更新本地缓存
|
|
|
|
- localCacheParentCountNodes.put(cacheKey, resultParentNodesTB);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return resultParentNodesTB;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取当前合同段所有填报资料缓存信息
|
|
|
|
- *
|
|
|
|
- * @param contractId
|
|
|
|
- * @param tableOwner
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public List<WbsTreeContractLazyQueryInfoVO> getQueryInfoList(String contractId, String tableOwner) {
|
|
|
|
- //从本地缓存获取
|
|
|
|
- String cacheKey = contractId + "_" + tableOwner;
|
|
|
|
- List<WbsTreeContractLazyQueryInfoVO> cachedQueryInfoList = localCacheQueryInfos.get(cacheKey);
|
|
|
|
-
|
|
|
|
- if (cachedQueryInfoList != null && !cachedQueryInfoList.isEmpty()) {
|
|
|
|
- return cachedQueryInfoList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //从Redis获取数据
|
|
|
|
- Object dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + cacheKey);
|
|
|
|
-
|
|
|
|
- List<WbsTreeContractLazyQueryInfoVO> queryInfoList = new ArrayList<>();
|
|
|
|
- if (dataInformationQuery != null) {
|
|
|
|
- queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
|
|
|
|
- //更新本地缓存
|
|
|
|
- localCacheQueryInfos.put(cacheKey, queryInfoList);
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- //返回数据库数据
|
|
|
|
- long startTime = System.currentTimeMillis();
|
|
|
|
-
|
|
|
|
- /*分页查询,每次5000条*/
|
|
|
|
- int pageSize = 5000;
|
|
|
|
- int pageNumber = 1;
|
|
|
|
- int offset;
|
|
|
|
-
|
|
|
|
- List<WbsTreeContractLazyQueryInfoVO> queryInfoListPage;
|
|
|
|
-
|
|
|
|
- do {
|
|
|
|
- offset = (pageNumber - 1) * pageSize;
|
|
|
|
- queryInfoListPage = jdbcTemplate.query(
|
|
|
|
- "SELECT wbs_id, status FROM u_information_query " +
|
|
|
|
- "WHERE type = 1 " +
|
|
|
|
- "AND contract_id = ? " +
|
|
|
|
- "AND classify = ? " +
|
|
|
|
- "LIMIT ? OFFSET ?",
|
|
|
|
- new Object[]{contractId, tableOwner, pageSize, offset},
|
|
|
|
- new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
|
- queryInfoList.addAll(queryInfoListPage);
|
|
|
|
- pageNumber++;
|
|
|
|
- } while (queryInfoListPage.size() == pageSize);
|
|
|
|
-
|
|
|
|
- long endTime = System.currentTimeMillis();
|
|
|
|
- long executionTime = endTime - startTime;
|
|
|
|
- logger.info("合同段 " + contractId + " 查询所有资料信息 执行时间:" + executionTime + " ms");
|
|
|
|
-
|
|
|
|
- if (queryInfoList.size() > 0) {
|
|
|
|
- JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
|
-
|
|
|
|
- //存储到Redis中
|
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + cacheKey, JSON.toJSON(array).toString());
|
|
|
|
-
|
|
|
|
- //更新本地缓存
|
|
|
|
- localCacheQueryInfos.put(cacheKey, queryInfoList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return queryInfoList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public List<WbsTreeContractLazyVO> imageLazyQueryContractWbsTree(String id, String contractId, String
|
|
public List<WbsTreeContractLazyVO> imageLazyQueryContractWbsTree(String id, String contractId, String
|
|
contractIdRelation, String classId) {
|
|
contractIdRelation, String classId) {
|
|
@@ -1237,7 +782,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
));
|
|
));
|
|
List<Long> pKeyIdList = new ArrayList<>(queryFileMaps.keySet());
|
|
List<Long> pKeyIdList = new ArrayList<>(queryFileMaps.keySet());
|
|
|
|
|
|
- //填报过的所有最底层节点,处理数量
|
|
|
|
List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.stream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.stream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
List<WbsTreeContractLazyVO> lowestNodesTBNew = BeanUtil.copyProperties(lowestNodesTB, WbsTreeContractLazyVO.class);
|
|
List<WbsTreeContractLazyVO> lowestNodesTBNew = BeanUtil.copyProperties(lowestNodesTB, WbsTreeContractLazyVO.class);
|
|
for (WbsTreeContractLazyVO vo : lowestNodesTB) {
|
|
for (WbsTreeContractLazyVO vo : lowestNodesTB) {
|
|
@@ -1561,42 +1105,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
* @param lowestNodeParentIds 最底层节点ParentIds
|
|
* @param lowestNodeParentIds 最底层节点ParentIds
|
|
* @param nodesAll 所有节点
|
|
* @param nodesAll 所有节点
|
|
*/
|
|
*/
|
|
- /*public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
|
|
|
|
- if (lowestNodeParentIds.isEmpty()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //父级Id与出现的次数Map
|
|
|
|
- Map<Long, Long> parentIdGroup = lowestNodeParentIds.parallelStream()
|
|
|
|
- .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
|
|
|
|
-
|
|
|
|
- //批量查询单次节点
|
|
|
|
- List<WbsTreeContractLazyVO> parentNodes = parentIdGroup.entrySet().parallelStream()
|
|
|
|
- .filter(entry -> entry.getValue() == 1L)
|
|
|
|
- .flatMap(entry -> nodesAll.stream()
|
|
|
|
- .filter(f -> entry.getKey().equals(f.getId())))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- //批量查询多次节点
|
|
|
|
- List<WbsTreeContractLazyVO> multipleParentNodes = parentIdGroup.entrySet().parallelStream()
|
|
|
|
- .filter(entry -> entry.getValue() > 1L)
|
|
|
|
- .flatMap(entry -> nodesAll.stream()
|
|
|
|
- .filter(f -> entry.getKey().equals(f.getId()))
|
|
|
|
- .limit(1)
|
|
|
|
- .flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).stream()))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- //结果集
|
|
|
|
- List<Long> collect = Stream.concat(parentNodes.stream(), multipleParentNodes.stream())
|
|
|
|
- .map(WbsTreeContractLazyVO::getParentId)
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- if (!collect.isEmpty()) {
|
|
|
|
- result.addAll(parentNodes);
|
|
|
|
- result.addAll(multipleParentNodes);
|
|
|
|
- this.recursiveGetParentNodes(result, collect, nodesAll);
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
|
|
public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
|
|
if (lowestNodeParentIds.isEmpty()) {
|
|
if (lowestNodeParentIds.isEmpty()) {
|
|
return;
|
|
return;
|