|
@@ -72,6 +72,7 @@ import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.core.SingleColumnRowMapper;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -83,6 +84,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
@@ -726,7 +728,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
String sql = "SELECT is_custom,p_key_id,contract_id," +
|
|
|
"(SELECT is_reference_number FROM m_contract_info WHERE id="+contractId+") AS isReferenceNumber,"+
|
|
|
"(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_buss_show as isBussShow,is_concrete,major_data_type,class_name,unit_name,node_class,unit_num,excellent_num,is_classifition,digitize_time,partition_code,old_id,contract_id_relation,is_concealed_works_node,wbs_id,sort,create_time," +
|
|
|
+ "id,parent_id,node_type,type,wbs_type,is_buss_show as isBussShow,is_concrete,major_data_type,class_name,unit_name,node_class,unit_num,excellent_num,is_classifition,digitize_time,partition_code,old_id,contract_id_relation,is_concealed_works_node,wbs_id,sort,create_time,is_type_private_pid," +
|
|
|
"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" +
|
|
@@ -788,12 +790,16 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
|
|
|
/* ================ 处理颜色 ================ */
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
- 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> 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));
|
|
|
+// NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
+ Map<Long, Integer> nodeColorStatusMap = new HashMap<>();
|
|
|
+ NodeVO.calculateStatusToDFS1(treeNodeVOList, nodeColorStatusMap);
|
|
|
+// buildNodeTreeByStream(distinctNodesAll, lowestNodesMap, nodeColorStatusMap);
|
|
|
+ // 将树形结构展开成列表
|
|
|
+// List<NodeVO> nodeVOS = this.flattenTree(treeNodeVOList);
|
|
|
+// 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");
|
|
@@ -810,6 +816,25 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
}
|
|
|
}
|
|
|
for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
|
|
|
+ if(lazyNodeVO.getIsCustom()!=null&&lazyNodeVO.getIsCustom()==1){
|
|
|
+ lazyNodeVO.setPrivateTemplate("当前节点为自定义节点,无法定位后管位置");
|
|
|
+ }else {
|
|
|
+ try {
|
|
|
+ if(lazyNodeVO.getIsTypePrivatePid()!=null){
|
|
|
+ String privateSql="select p_key_id, ancestors_p_id from m_wbs_tree_private where p_key_id="+lazyNodeVO.getIsTypePrivatePid()+" and is_deleted=0";
|
|
|
+ WbsTreePrivate ancestor = jdbcTemplate.queryForObject(privateSql,new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
+ String ancestorsPId=ancestor.getAncestorsPId()+","+ancestor.getPKeyId();
|
|
|
+ String privateNodeNameSql="select node_name from m_wbs_tree_private where p_key_id in ("+ancestorsPId+")";
|
|
|
+ List<String> wbsTreePrivates = jdbcTemplate.query(privateNodeNameSql,new SingleColumnRowMapper<>(String.class));
|
|
|
+ if(wbsTreePrivates.size()>0){
|
|
|
+ String result = wbsTreePrivates.stream().collect(Collectors.joining("/"));
|
|
|
+ lazyNodeVO.setPrivateTemplate(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ lazyNodeVO.setPrivateTemplate("");
|
|
|
+ }
|
|
|
+ }
|
|
|
lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
|
|
|
lazyNodeVO.setPrimaryKeyId(lazyNodeVO.getPKeyId());
|
|
|
if (lazyNodeVO.getParentId() == 0L) {
|
|
@@ -834,6 +859,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
lazyNodeVO.setColorStatus(lowestNode.getColorStatus());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
return lazyNodes;
|
|
@@ -864,7 +890,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
String sql = "SELECT is_custom,p_key_id,contract_id," +
|
|
|
"(SELECT is_reference_number FROM m_contract_info WHERE id="+contractId+") AS isReferenceNumber,"+
|
|
|
"(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,class_name,unit_name,node_class,unit_num,excellent_num,is_classifition,digitize_time,partition_code,old_id,contract_id_relation,is_concealed_works_node,wbs_id,sort,create_time," +
|
|
|
+ "id,parent_id,node_type,type,wbs_type,is_concrete,major_data_type,class_name,unit_name,node_class,unit_num,excellent_num,is_classifition,digitize_time,partition_code,old_id,contract_id_relation,is_concealed_works_node,wbs_id,sort,create_time,is_type_private_pid," +
|
|
|
"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" +
|
|
@@ -907,13 +933,15 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
}
|
|
|
}).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> 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));
|
|
|
-
|
|
|
+// 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));
|
|
|
+ Map<Long, Integer> nodeColorStatusMap = new HashMap<>();
|
|
|
+ NodeVO.calculateStatusToDFS1(treeNodeVOList, nodeColorStatusMap);
|
|
|
+// buildNodeTreeByStream(distinctNodesAll, lowestNodesMap, nodeColorStatusMap);
|
|
|
if (lazyNodes.size() > 0) {
|
|
|
Map<Long, Integer> countMap = new HashMap<>();
|
|
|
for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
@@ -926,6 +954,25 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
}
|
|
|
|
|
|
for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
|
|
|
+ if(lazyNodeVO.getIsCustom()!=null&&lazyNodeVO.getIsCustom()==1){
|
|
|
+ lazyNodeVO.setPrivateTemplate("当前节点为自定义节点,无法定位后管位置");
|
|
|
+ }else {
|
|
|
+ try {
|
|
|
+ if(lazyNodeVO.getIsTypePrivatePid()!=null){
|
|
|
+ String privateSql="select p_key_id, ancestors_p_id from m_wbs_tree_private where p_key_id="+lazyNodeVO.getIsTypePrivatePid()+" and is_deleted=0";
|
|
|
+ WbsTreePrivate ancestor = jdbcTemplate.queryForObject(privateSql,new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
+ String ancestorsPId=ancestor.getAncestorsPId()+","+ancestor.getPKeyId();
|
|
|
+ String privateNodeNameSql="select node_name from m_wbs_tree_private where p_key_id in ("+ancestorsPId+")";
|
|
|
+ List<String> wbsTreePrivates = jdbcTemplate.query(privateNodeNameSql,new SingleColumnRowMapper<>(String.class));
|
|
|
+ if(wbsTreePrivates.size()>0){
|
|
|
+ String result = wbsTreePrivates.stream().collect(Collectors.joining("/"));
|
|
|
+ lazyNodeVO.setPrivateTemplate(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ lazyNodeVO.setPrivateTemplate("");
|
|
|
+ }
|
|
|
+ }
|
|
|
lazyNodeVO.setType(lazyNodeVO.getNodeType());
|
|
|
lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
|
|
|
lazyNodeVO.setPrimaryKeyId(lazyNodeVO.getPKeyId());
|
|
@@ -951,6 +998,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
lazyNodeVO.setColorStatus(lowestNode.getColorStatus());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
lazyNodesAll.addAll(lazyNodes);
|
|
@@ -1384,8 +1432,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
|
/*重新计算,进行递归获取父节点计数统计*/
|
|
|
- this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
-
|
|
|
+// this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
+ Map<Long, List<WbsTreeContractLazyVO>> map = nodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getId));
|
|
|
+ recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, map);
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
long executionTime = endTime - startTime;
|
|
|
_logger.info("合同段 " + contractId + " wbs节点树 数量计算 执行时间:" + executionTime + " ms");
|
|
@@ -1441,6 +1490,40 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, Map<Long, List<WbsTreeContractLazyVO>> nodeMap) {
|
|
|
+ if (lowestNodeParentIds == null || lowestNodeParentIds.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Long, Long> parentIdGroup = lowestNodeParentIds.stream()
|
|
|
+ .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
|
|
|
+
|
|
|
+ List<WbsTreeContractLazyVO> collectedNodes = parentIdGroup.entrySet().stream()
|
|
|
+ .flatMap(entry -> {
|
|
|
+ List<WbsTreeContractLazyVO> nodes = nodeMap.get(entry.getKey());
|
|
|
+ if (nodes == null || nodes.isEmpty()) {
|
|
|
+ return Stream.empty();
|
|
|
+ }
|
|
|
+ if (entry.getValue() > 1L) {
|
|
|
+ nodes = nodes.stream().limit(1)
|
|
|
+ .flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).stream())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return nodes.stream();
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (collectedNodes.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Long> collect = collectedNodes.stream()
|
|
|
+ .map(WbsTreeContractLazyVO::getParentId).filter(Objects::nonNull).distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
+ result.addAll(collectedNodes);
|
|
|
+ this.recursiveGetParentNodes(result, collect, nodeMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 转换VO
|
|
|
*
|
|
@@ -1452,7 +1535,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
nodeVO.setId(wbsTreeContractLazyVO.getId());
|
|
|
nodeVO.setParentId(wbsTreeContractLazyVO.getParentId());
|
|
|
nodeVO.setPKeyId(wbsTreeContractLazyVO.getPKeyId());
|
|
|
- nodeVO.setStatus(cn.hutool.core.util.ObjectUtil.isNotEmpty(wbsTreeContractLazyVO.getColorStatus()) ? wbsTreeContractLazyVO.getColorStatus() : 1);
|
|
|
+ nodeVO.setStatus(wbsTreeContractLazyVO.getColorStatus() != null ? wbsTreeContractLazyVO.getColorStatus() : 1);
|
|
|
return nodeVO;
|
|
|
}
|
|
|
|
|
@@ -1476,7 +1559,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
for (WbsTreeContractLazyVO vo : list) {
|
|
|
if (vo.getHasChildren().equals(0)) {
|
|
|
WbsTreeContractLazyVO lowestNodeVO = lowestNodesMap.getOrDefault(vo.getPKeyId(), null);
|
|
|
- if (lowestNodeVO != null && cn.hutool.core.util.ObjectUtil.isNotEmpty(lowestNodeVO.getColorStatus())) {
|
|
|
+ if (lowestNodeVO != null && lowestNodeVO.getColorStatus() != null) {
|
|
|
//最底层颜色初始化
|
|
|
vo.setColorStatus(lowestNodeVO.getColorStatus());
|
|
|
}
|