|
@@ -58,6 +58,7 @@ import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigInteger;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
@@ -78,7 +79,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
@Autowired
|
|
|
StringRedisTemplate redisTemplate;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public List<WbsTreeContract> selectQueryCurrentNodeByAncestors(List<String> ids, String contractId) {
|
|
|
return this.baseMapper.selectQueryCurrentNodeByAncestors(ids, contractId);
|
|
@@ -710,6 +711,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + contractId, JSON.toJSON(array).toString());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//获取当前层懒加载节点
|
|
|
List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,contract_id,(SELECT id FROM u_contract_tree_drawings where process_id = p_key_id) 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", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
if (lazyNodes.size() > 0 && nodesAll.size() > 0) {
|
|
@@ -726,12 +728,30 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
ArrayList::new
|
|
|
));
|
|
|
|
|
|
- //获取当前合同段所有填报资料信息
|
|
|
+ //获取当前合同段所有填报资料缓存信息
|
|
|
List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
|
|
|
+ Object dataInformationQuery;
|
|
|
if (ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
+ dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1");
|
|
|
+ } else {
|
|
|
+ dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner);
|
|
|
+ }
|
|
|
+ if (dataInformationQuery != null) {
|
|
|
+ queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
|
|
|
} else {
|
|
|
- queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
+ if (ObjectUtil.isEmpty(tableOwner)) {
|
|
|
+ queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
+ if (queryInfoList.size() > 0) {
|
|
|
+ JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
+ redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1", JSON.toJSON(array).toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
+ if (queryInfoList.size() > 0) {
|
|
|
+ JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
+ redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner, JSON.toJSON(array).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
.collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
|
|
@@ -739,8 +759,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
//TODO 处理数量
|
|
|
//填报过的所有最底层节点
|
|
|
- List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.stream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
- List<Long> lowestNodeParentIdsTB = lowestNodesTB.stream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
|
|
|
+ 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 = new ArrayList<>();
|
|
|
this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
|
|
@@ -831,19 +851,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
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> nodesAll;
|
|
|
- Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + sgContractId);
|
|
|
- if (data != null) {
|
|
|
- nodesAll = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
|
|
|
- } else {
|
|
|
- nodesAll = jdbcTemplate.query("select a.p_key_id,a.id,a.parent_id,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND type = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where type = 1 and status = 1 and is_deleted = 0 and contract_id = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
- if (nodesAll.size() > 0) {
|
|
|
- JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAll));
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + sgContractId, JSON.toJSON(array).toString());
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
//获取当前合同段所有缓存节点信息
|
|
|
List<WbsTreeContractLazyVO> nodesAll;
|
|
|
Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + sgContractId);
|
|
@@ -886,12 +893,30 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
ArrayList::new
|
|
|
));
|
|
|
|
|
|
- //获取当前合同段所有填报资料信息
|
|
|
+ //获取当前合同段所有填报资料缓存信息
|
|
|
List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
|
|
|
+ Object dataInformationQuery;
|
|
|
if (ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
+ dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_1");
|
|
|
} else {
|
|
|
- queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + sgContractId + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
+ dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_" + tableOwner);
|
|
|
+ }
|
|
|
+ if (dataInformationQuery != null) {
|
|
|
+ queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
|
|
|
+ } else {
|
|
|
+ if (ObjectUtil.isEmpty(tableOwner)) {
|
|
|
+ queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
+ if (queryInfoList.size() > 0) {
|
|
|
+ JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
+ redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_1", JSON.toJSON(array).toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + sgContractId + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
+ if (queryInfoList.size() > 0) {
|
|
|
+ JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
+ redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_" + tableOwner, JSON.toJSON(array).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
.collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
|
|
@@ -1374,7 +1399,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
* @param lowestNodeParentIds 最底层节点ParentIds
|
|
|
* @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()) {
|
|
|
return;
|
|
|
}
|
|
@@ -1412,6 +1437,57 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //结果集
|
|
|
+ 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) {
|
|
|
+ if (lowestNodeParentIds.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //父级Id与出现的次数Map
|
|
|
+ Map<Long, Long> parentIdGroup = lowestNodeParentIds.parallelStream()
|
|
|
+ .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
|
|
|
+
|
|
|
+ Set<Long> keysWithValueOne = new HashSet<>(); //单次
|
|
|
+ Map<Long, Long> keysWithValueSome = new ConcurrentHashMap<>(); //多次
|
|
|
+
|
|
|
+ parentIdGroup.forEach((key, value) -> {
|
|
|
+ if (value == 1L) {
|
|
|
+ keysWithValueOne.add(key);
|
|
|
+ } else {
|
|
|
+ keysWithValueSome.put(key, value);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //批量查询单次节点
|
|
|
+ List<WbsTreeContractLazyVO> parentNodes = new ArrayList<>();
|
|
|
+ if (!keysWithValueOne.isEmpty()) {
|
|
|
+ parentNodes = nodesAll.parallelStream()
|
|
|
+ .filter(f -> keysWithValueOne.contains(f.getId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量查询多次节点
|
|
|
+ List<WbsTreeContractLazyVO> multipleParentNodes = new ArrayList<>();
|
|
|
+ keysWithValueSome.forEach((key, count) -> {
|
|
|
+ List<WbsTreeContractLazyVO> nodes = nodesAll.parallelStream()
|
|
|
+ .filter(f -> key.equals(f.getId()))
|
|
|
+ .limit(1) //限制只取一个
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!nodes.isEmpty()) {
|
|
|
+ multipleParentNodes.addAll(Collections.nCopies(count.intValue(), nodes.get(0)));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
//结果集
|
|
|
List<Long> collect = Stream.concat(parentNodes.stream(), multipleParentNodes.stream())
|
|
|
.map(WbsTreeContractLazyVO::getParentId)
|