|
@@ -57,7 +57,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.math.BigInteger;
|
|
import java.math.BigInteger;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
+import java.util.concurrent.*;
|
|
import java.util.function.Function;
|
|
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;
|
|
@@ -732,13 +732,22 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
if (contractInfo != null) {
|
|
if (contractInfo != null) {
|
|
/*施工合同段*/
|
|
/*施工合同段*/
|
|
if (new Integer(1).equals(contractInfo.getContractType())) {
|
|
if (new Integer(1).equals(contractInfo.getContractType())) {
|
|
- //获取本地缓存节点信息
|
|
|
|
- List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(contractId);
|
|
|
|
-
|
|
|
|
//获取当前层懒加载节点
|
|
//获取当前层懒加载节点
|
|
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";
|
|
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));
|
|
List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
- if (lazyNodes.size() > 0 && nodesAll.size() > 0) {
|
|
|
|
|
|
+ if (lazyNodes.size() > 0) {
|
|
|
|
+
|
|
|
|
+ /*根节点直接返回*/
|
|
|
|
+ if (lazyNodes.stream().anyMatch(f -> f.getParentId().equals(0L))) {
|
|
|
|
+ for (WbsTreeContractLazyVO lazyNode : lazyNodes) {
|
|
|
|
+ lazyNode.setSubmitCounts(0);
|
|
|
|
+ lazyNode.setColorStatus(2);
|
|
|
|
+ }
|
|
|
|
+ return lazyNodes;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取本地缓存节点信息
|
|
|
|
+ List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(contractId);
|
|
List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
|
|
List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
|
|
.collect(Collectors.collectingAndThen(
|
|
.collect(Collectors.collectingAndThen(
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
@@ -764,6 +773,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).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 = this.getCachedParentCountNodes(contractId, lowestNodeParentIdsTB, nodesAll, tableOwner);
|
|
|
|
+ //List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
|
|
|
|
+ //this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
|
|
|
//最底层节点颜色构造后Map
|
|
//最底层节点颜色构造后Map
|
|
Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
|
|
Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
|
|
@@ -795,7 +806,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
long endTime = System.currentTimeMillis();
|
|
long endTime = System.currentTimeMillis();
|
|
long executionTime = endTime - startTime;
|
|
long executionTime = endTime - startTime;
|
|
- logger.info("处理颜色执行时间:" + executionTime + " ms");
|
|
|
|
|
|
+ logger.info("合同段 " + contractId + " 处理颜色 执行时间:" + executionTime + " ms");
|
|
|
|
|
|
/*处理最终结果集*/
|
|
/*处理最终结果集*/
|
|
if (lazyNodes.size() > 0) {
|
|
if (lazyNodes.size() > 0) {
|
|
@@ -861,10 +872,18 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
for (String sgContractId : contractIds) {
|
|
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);
|
|
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) {
|
|
if (sgContractInfo != null) {
|
|
- List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(sgContractId);
|
|
|
|
-
|
|
|
|
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));
|
|
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 && nodesAll.size() > 0) {
|
|
|
|
|
|
+ if (lazyNodes.size() > 0) {
|
|
|
|
+
|
|
|
|
+ if (lazyNodes.stream().anyMatch(f -> f.getParentId().equals(0L))) {
|
|
|
|
+ for (WbsTreeContractLazyVO lazyNode : lazyNodes) {
|
|
|
|
+ lazyNode.setSubmitCounts(0);
|
|
|
|
+ lazyNode.setColorStatus(2);
|
|
|
|
+ }
|
|
|
|
+ return lazyNodes;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(sgContractId);
|
|
List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
|
|
List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
|
|
.collect(Collectors.collectingAndThen(
|
|
.collect(Collectors.collectingAndThen(
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
@@ -964,21 +983,43 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
//获取本地缓存
|
|
//获取本地缓存
|
|
List<WbsTreeContractLazyVO> nodesAll = localCacheNodes.get(contractId);
|
|
List<WbsTreeContractLazyVO> nodesAll = localCacheNodes.get(contractId);
|
|
|
|
|
|
- if (nodesAll == null || nodesAll.size() == 0) {
|
|
|
|
|
|
+ if (nodesAll == null || nodesAll.isEmpty()) {
|
|
//从Redis获取数据
|
|
//从Redis获取数据
|
|
Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + contractId);
|
|
Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + contractId);
|
|
if (data != null) {
|
|
if (data != null) {
|
|
nodesAll = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
|
|
nodesAll = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
|
|
//更新本地缓存
|
|
//更新本地缓存
|
|
localCacheNodes.put(contractId, nodesAll);
|
|
localCacheNodes.put(contractId, nodesAll);
|
|
-
|
|
|
|
} else {
|
|
} else {
|
|
//返回数据库数据
|
|
//返回数据库数据
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
- nodesAll = jdbcTemplate.query("select a.p_key_id,a.id,a.parent_id from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and a.contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
|
|
|
+
|
|
|
|
+ /*分页查询,每次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 endTime = System.currentTimeMillis();
|
|
long executionTime = endTime - startTime;
|
|
long executionTime = endTime - startTime;
|
|
- logger.info("查询合同段 " + contractId + " 所有树执行时间:" + executionTime + " ms");
|
|
|
|
|
|
+ logger.info("合同段 " + contractId + " 查询所有wbs节点树 执行时间:" + executionTime + " ms");
|
|
|
|
|
|
if (nodesAll.size() > 0) {
|
|
if (nodesAll.size() > 0) {
|
|
//判断是否有子级,赋值
|
|
//判断是否有子级,赋值
|
|
@@ -994,6 +1035,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
vo.setHasChildren(0);
|
|
vo.setHasChildren(0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
//存储到Redis中
|
|
//存储到Redis中
|
|
JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAll));
|
|
JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAll));
|
|
redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + contractId, JSON.toJSON(array).toString());
|
|
redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + contractId, JSON.toJSON(array).toString());
|
|
@@ -1033,10 +1075,12 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
/*重新计算,进行递归获取父节点计数统计*/
|
|
/*重新计算,进行递归获取父节点计数统计*/
|
|
resultParentNodesTB = new ArrayList<>();
|
|
resultParentNodesTB = new ArrayList<>();
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
+
|
|
this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
|
+
|
|
long endTime = System.currentTimeMillis();
|
|
long endTime = System.currentTimeMillis();
|
|
long executionTime = endTime - startTime;
|
|
long executionTime = endTime - startTime;
|
|
- logger.info("节点树数量统计计算耗时:" + executionTime + " ms");
|
|
|
|
|
|
+ logger.info("合同段 " + contractId + " wbs节点树 数量计算 耗时:" + executionTime + " ms");
|
|
|
|
|
|
if (resultParentNodesTB.size() > 0) {
|
|
if (resultParentNodesTB.size() > 0) {
|
|
//存储到Redis中
|
|
//存储到Redis中
|
|
@@ -1072,7 +1116,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
//从Redis获取数据
|
|
//从Redis获取数据
|
|
Object dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + cacheKey);
|
|
Object dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + cacheKey);
|
|
|
|
|
|
- List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
|
|
|
|
|
|
+ List<WbsTreeContractLazyQueryInfoVO> queryInfoList = new ArrayList<>();
|
|
if (dataInformationQuery != null) {
|
|
if (dataInformationQuery != null) {
|
|
queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
|
|
queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
|
|
//更新本地缓存
|
|
//更新本地缓存
|
|
@@ -1081,13 +1125,33 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
} else {
|
|
} else {
|
|
//返回数据库数据
|
|
//返回数据库数据
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
- String querySql = "select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId + " and classify = " + tableOwner;
|
|
|
|
- queryInfoList = jdbcTemplate.query(querySql, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
|
|
|
+
|
|
|
|
+ /*分页查询,每次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 endTime = System.currentTimeMillis();
|
|
long executionTime = endTime - startTime;
|
|
long executionTime = endTime - startTime;
|
|
- logger.info("合同段资料信息查询耗时:" + executionTime + " ms");
|
|
|
|
|
|
+ logger.info("合同段 " + contractId + " 查询所有资料信息 执行时间:" + executionTime + " ms");
|
|
|
|
|
|
- if (!queryInfoList.isEmpty()) {
|
|
|
|
|
|
+ if (queryInfoList.size() > 0) {
|
|
JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
|
|
|
//存储到Redis中
|
|
//存储到Redis中
|
|
@@ -1479,26 +1543,26 @@ 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) {
|
|
|
|
|
|
+ /*public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
|
|
if (lowestNodeParentIds.isEmpty()) {
|
|
if (lowestNodeParentIds.isEmpty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
//父级Id与出现的次数Map
|
|
//父级Id与出现的次数Map
|
|
- Map<Long, Long> parentIdGroup = lowestNodeParentIds.parallelStream()
|
|
|
|
|
|
+ Map<Long, Long> parentIdGroup = lowestNodeParentIds.stream()
|
|
.collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
|
|
.collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
|
|
|
|
|
|
//批量查询单次节点
|
|
//批量查询单次节点
|
|
- List<WbsTreeContractLazyVO> parentNodes = parentIdGroup.entrySet().parallelStream()
|
|
|
|
|
|
+ List<WbsTreeContractLazyVO> parentNodes = parentIdGroup.entrySet().stream()
|
|
.filter(entry -> entry.getValue() == 1L)
|
|
.filter(entry -> entry.getValue() == 1L)
|
|
- .flatMap(entry -> nodesAll.parallelStream()
|
|
|
|
|
|
+ .flatMap(entry -> nodesAll.stream()
|
|
.filter(f -> entry.getKey().equals(f.getId())))
|
|
.filter(f -> entry.getKey().equals(f.getId())))
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
//批量查询多次节点
|
|
//批量查询多次节点
|
|
- List<WbsTreeContractLazyVO> multipleParentNodes = parentIdGroup.entrySet().parallelStream()
|
|
|
|
|
|
+ List<WbsTreeContractLazyVO> multipleParentNodes = parentIdGroup.entrySet().stream()
|
|
.filter(entry -> entry.getValue() > 1L)
|
|
.filter(entry -> entry.getValue() > 1L)
|
|
- .flatMap(entry -> nodesAll.parallelStream()
|
|
|
|
|
|
+ .flatMap(entry -> nodesAll.stream()
|
|
.filter(f -> entry.getKey().equals(f.getId()))
|
|
.filter(f -> entry.getKey().equals(f.getId()))
|
|
.limit(1)
|
|
.limit(1)
|
|
.flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).stream()))
|
|
.flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).stream()))
|
|
@@ -1514,6 +1578,51 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
result.addAll(multipleParentNodes);
|
|
result.addAll(multipleParentNodes);
|
|
this.recursiveGetParentNodes(result, collect, nodesAll);
|
|
this.recursiveGetParentNodes(result, collect, nodesAll);
|
|
}
|
|
}
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
|
|
|
|
+ if (lowestNodeParentIds.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //并行粒度4
|
|
|
|
+ ForkJoinPool customThreadPool = new ForkJoinPool(2);
|
|
|
|
+
|
|
|
|
+ //父级Id与出现的次数Map
|
|
|
|
+ Map<Long, Long> parentIdGroup = lowestNodeParentIds.parallelStream()
|
|
|
|
+ .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
|
|
|
|
+
|
|
|
|
+ //批量查询单次节点
|
|
|
|
+ CompletableFuture<List<WbsTreeContractLazyVO>> parentNodesFuture = CompletableFuture.supplyAsync(() ->
|
|
|
|
+ parentIdGroup.entrySet().parallelStream()
|
|
|
|
+ .filter(entry -> entry.getValue() == 1L)
|
|
|
|
+ .flatMap(entry -> nodesAll.parallelStream()
|
|
|
|
+ .filter(f -> entry.getKey().equals(f.getId())))
|
|
|
|
+ .collect(Collectors.toList()), customThreadPool);
|
|
|
|
+
|
|
|
|
+ //批量查询多次节点
|
|
|
|
+ CompletableFuture<List<WbsTreeContractLazyVO>> multipleParentNodesFuture = CompletableFuture.supplyAsync(() ->
|
|
|
|
+ parentIdGroup.entrySet().parallelStream()
|
|
|
|
+ .filter(entry -> entry.getValue() > 1L)
|
|
|
|
+ .flatMap(entry -> nodesAll.parallelStream()
|
|
|
|
+ .filter(f -> entry.getKey().equals(f.getId()))
|
|
|
|
+ .limit(1)
|
|
|
|
+ .flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).parallelStream()))
|
|
|
|
+ .collect(Collectors.toList()), customThreadPool);
|
|
|
|
+
|
|
|
|
+ //结果集
|
|
|
|
+ CompletableFuture<List<Long>> collectFuture = parentNodesFuture.thenCombine(multipleParentNodesFuture, (parentNodes, multipleParentNodes) ->
|
|
|
|
+ Stream.concat(parentNodes.parallelStream(), multipleParentNodes.parallelStream())
|
|
|
|
+ .map(WbsTreeContractLazyVO::getParentId)
|
|
|
|
+ .collect(Collectors.toList()));
|
|
|
|
+
|
|
|
|
+ List<Long> collect = collectFuture.join();
|
|
|
|
+
|
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
|
+ result.addAll(parentNodesFuture.join());
|
|
|
|
+ result.addAll(multipleParentNodesFuture.join());
|
|
|
|
+ this.recursiveGetParentNodes(result, collect, nodesAll);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -2677,6 +2786,10 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
iterator_2.remove();
|
|
iterator_2.remove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /*更新缓存,主动清理后,重新加载进本地缓存中*/
|
|
|
|
+ this.getNodeAll(contractId);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|