|
@@ -14,6 +14,8 @@ import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springblade.business.entity.ConstructionLedger;
|
|
|
import org.springblade.business.feign.ConstructionLedgerFeignClient;
|
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
@@ -25,7 +27,6 @@ import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
-import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.bean.NodeVO;
|
|
@@ -52,10 +53,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedCaseInsensitiveMap;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.*;
|
|
|
import java.math.BigInteger;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
@@ -69,6 +68,7 @@ import java.util.stream.Stream;
|
|
|
@AllArgsConstructor
|
|
|
public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractMapper, WbsTreeContract> implements IWbsTreeContractService {
|
|
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(WbsTreeContractServiceImpl.class);
|
|
|
private final ConstructionLedgerFeignClient constructionLedgerFeign;
|
|
|
private final WbsTreePrivateMapper wbsTreePrivateMapper;
|
|
|
private final ContractInfoMapper contractInfoMapper;
|
|
@@ -79,6 +79,12 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
@Autowired
|
|
|
StringRedisTemplate redisTemplate;
|
|
|
|
|
|
+ //存储当前合同段contractId对应的合同段树
|
|
|
+ private final Map<String, List<WbsTreeContractLazyVO>> localCacheNodes = new ConcurrentHashMap<>();
|
|
|
+ //存储当前合同段contractId_tableOwner对应的资料查询信息
|
|
|
+ private final Map<String, List<WbsTreeContractLazyQueryInfoVO>> localCacheQueryInfos = new ConcurrentHashMap<>();
|
|
|
+ //存储当前合同段contractId_tableOwner对应的节点数量统计缓存信息
|
|
|
+ private final Map<String, List<WbsTreeContractLazyVO>> localCacheParentCountNodes = new ConcurrentHashMap<>();
|
|
|
|
|
|
@Override
|
|
|
public List<WbsTreeContract> selectQueryCurrentNodeByAncestors(List<String> ids, String contractId) {
|
|
@@ -415,7 +421,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<AppWbsTreeContractVO> searchNodeAllTable(String primaryKeyId, String tableOwner, String contractId, String projectId) {
|
|
|
+ public List<AppWbsTreeContractVO> searchNodeAllTable(String primaryKeyId, String tableOwner, String contractId, String projectId, HttpServletRequest request) {
|
|
|
//由于Feign调用时,获取不到UserId
|
|
|
Long userId;
|
|
|
if (StringUtils.isNotEmpty(primaryKeyId) && primaryKeyId.contains(":")) {
|
|
@@ -428,7 +434,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
} else {
|
|
|
userId = AuthUtil.getUserId();
|
|
|
}
|
|
|
+
|
|
|
WbsTreeContract wbsTreeContract = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .select(WbsTreeContract::getId, WbsTreeContract::getProjectId, WbsTreeContract::getContractId, WbsTreeContract::getContractIdRelation, WbsTreeContract::getWbsId)
|
|
|
.eq(WbsTreeContract::getPKeyId, primaryKeyId));
|
|
|
if (wbsTreeContract == null) {
|
|
|
return Collections.emptyList();
|
|
@@ -447,12 +455,15 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
throw new ServiceException("当前用户角色未授权,请先分配角色查看元素表相对应的权限");
|
|
|
}
|
|
|
|
|
|
- List<String> tableOwnerNumbers = wbsTableOwnerRoleList.stream().map(WbsTableOwnerRole::getTableOwnerNumber).collect(Collectors.toList());
|
|
|
+ //角色表单权限(后管权限配置)
|
|
|
+ Set<String> roleTableOwnerSets = wbsTableOwnerRoleList.stream().map(WbsTableOwnerRole::getTableOwnerNumber).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ //接口请求表单类型(施工质检 或 监理抽检)
|
|
|
+ Set<String> tabTableOwnerSets = new HashSet<>();
|
|
|
|
|
|
- List<String> tableOwnerList = null;
|
|
|
+ /*tableOwner!=null,表示从资料填报查询,查权限数据,roleTableOwnerSets=取交集后*/
|
|
|
if (StringUtils.isNotEmpty(tableOwner)) {
|
|
|
String tableOwners;
|
|
|
- //字典owner_type
|
|
|
if (tableOwner.equals("1")) {
|
|
|
tableOwners = "1,2,3";
|
|
|
} else if (tableOwner.equals("2")) {
|
|
@@ -460,14 +471,46 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
} else {
|
|
|
tableOwners = "7,8,9";
|
|
|
}
|
|
|
- tableOwnerList = Func.toStrList(tableOwners);
|
|
|
+ tabTableOwnerSets.addAll(Func.toStrList(tableOwners));
|
|
|
+
|
|
|
+ //取交集
|
|
|
+ roleTableOwnerSets.retainAll(tabTableOwnerSets);
|
|
|
}
|
|
|
|
|
|
- List<AppWbsTreeContractVO> resultTabs = baseMapper.selectWbsTreeContractList(tableOwnerNumbers, wbsTreeContract.getProjectId(), wbsTreeContract.getWbsId(), wbsTreeContract.getContractId(), wbsTreeContract.getId(), wbsTreeContract.getContractIdRelation(), tableOwnerList);
|
|
|
+ /*tableOwner=null,表示从工程划分处查询,默认查询所有类型数据,roleTableOwnerSets=原始*/
|
|
|
+
|
|
|
+ //判断是客户端还是APP
|
|
|
+ List<AppWbsTreeContractVO> resultTabs;
|
|
|
+ if (ObjectUtil.isNotEmpty(request)) {
|
|
|
+ /*暂时通过获取请求头,不通过Auth获取clientId标识来判断是客户端或APP*/
|
|
|
+ String userAgent = request.getHeader("User-Agent");
|
|
|
+ if (userAgent != null && (userAgent.contains("Windows") || userAgent.contains("windows") || userAgent.contains("Mac") || userAgent.contains("mac"))) {
|
|
|
+ //客户端查询
|
|
|
+ resultTabs = baseMapper.selectWbsTreeContractListClient(roleTableOwnerSets,
|
|
|
+ wbsTreeContract.getProjectId(), wbsTreeContract.getWbsId(),
|
|
|
+ wbsTreeContract.getContractId(), wbsTreeContract.getId(),
|
|
|
+ wbsTreeContract.getContractIdRelation());
|
|
|
+ } else {
|
|
|
+ //APP查询
|
|
|
+ resultTabs = baseMapper.selectWbsTreeContractList(roleTableOwnerSets,
|
|
|
+ wbsTreeContract.getProjectId(), wbsTreeContract.getWbsId(),
|
|
|
+ wbsTreeContract.getContractId(), wbsTreeContract.getId(),
|
|
|
+ wbsTreeContract.getContractIdRelation());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //其他接口调用默认保持原始调用方式查询
|
|
|
+ resultTabs = baseMapper.selectWbsTreeContractList(roleTableOwnerSets,
|
|
|
+ wbsTreeContract.getProjectId(), wbsTreeContract.getWbsId(),
|
|
|
+ wbsTreeContract.getContractId(), wbsTreeContract.getId(),
|
|
|
+ wbsTreeContract.getContractIdRelation());
|
|
|
+ }
|
|
|
|
|
|
//表单排序
|
|
|
- List<AppWbsTreeContractVO> resultTabsToCopy = this.sortTabs(resultTabs, "__"); //复制表排序
|
|
|
- return this.sortTabs(resultTabsToCopy, "_PL_"); //频率表排序
|
|
|
+ if (resultTabs.size() > 0) {
|
|
|
+ List<AppWbsTreeContractVO> resultTabsToCopy = this.sortTabs(resultTabs, "__"); //复制表排序
|
|
|
+ return this.sortTabs(resultTabsToCopy, "_PL_"); //频率表排序
|
|
|
+ }
|
|
|
+ return resultTabs;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -681,58 +724,21 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
@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 = jdbcTemplate.query("select contract_name,contract_type from m_contract_info where id = " + contractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
|
|
|
+ ContractInfo contractInfo = contractInfoMapper.selectOne(Wrappers.<ContractInfo>lambdaQuery().select(ContractInfo::getContractName, ContractInfo::getContractType).eq(ContractInfo::getId, contractId));
|
|
|
if (contractInfo != null) {
|
|
|
- //TODO ************ 施工合同段 ************
|
|
|
+ /*施工合同段*/
|
|
|
if (new Integer(1).equals(contractInfo.getContractType())) {
|
|
|
- //获取当前合同段所有缓存节点信息
|
|
|
- List<WbsTreeContractLazyVO> nodesAll;
|
|
|
- /*Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + contractId);
|
|
|
- if (data != null) {
|
|
|
- nodesAll = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
|
|
|
- } else {*/
|
|
|
-
|
|
|
- //long startTime1 = System.currentTimeMillis();
|
|
|
-
|
|
|
- /*开启mybatis-plus二级缓存*/
|
|
|
- List<WbsTreeContract> wbsTreeContracts = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
- .select(WbsTreeContract::getId, WbsTreeContract::getPKeyId, WbsTreeContract::getParentId)
|
|
|
- .eq(WbsTreeContract::getType, 1)
|
|
|
- .eq(WbsTreeContract::getStatus, 1)
|
|
|
- .eq(WbsTreeContract::getContractId, contractId)
|
|
|
- );
|
|
|
-
|
|
|
- /*long endTime1 = System.currentTimeMillis();
|
|
|
- long executionTime1 = endTime1 - startTime1;
|
|
|
- System.out.println("1111111111111:" + executionTime1);*/
|
|
|
-
|
|
|
- nodesAll = BeanUtil.copyProperties(wbsTreeContracts, WbsTreeContractLazyVO.class);
|
|
|
-
|
|
|
- //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));
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
- /*JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAll));
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + contractId, JSON.toJSON(array).toString());*/
|
|
|
- }
|
|
|
- //}
|
|
|
+ //获取本地缓存节点信息
|
|
|
+ List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(contractId);
|
|
|
|
|
|
//获取当前层懒加载节点
|
|
|
- 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));
|
|
|
+ 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 && nodesAll.size() > 0) {
|
|
|
- //所有节点
|
|
|
List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
|
|
|
.collect(Collectors.collectingAndThen(
|
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
@@ -745,49 +751,19 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
ArrayList::new
|
|
|
));
|
|
|
|
|
|
- //获取当前合同段所有填报资料缓存信息
|
|
|
- List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
|
|
|
- Object dataInformationQuery;
|
|
|
- if (ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- 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 {
|
|
|
- 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());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //获取本地缓存资料信息
|
|
|
+ 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());
|
|
|
|
|
|
-
|
|
|
- //TODO 处理数量
|
|
|
+ /*处理数量*/
|
|
|
//填报过的所有最底层节点
|
|
|
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<>();
|
|
|
-
|
|
|
- //long startTime2 = System.currentTimeMillis();
|
|
|
-
|
|
|
- this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
-
|
|
|
- /*long endTime2 = System.currentTimeMillis();
|
|
|
- long executionTime2 = endTime2 - startTime2;
|
|
|
- System.out.println("2222222222222:" + executionTime2);*/
|
|
|
+ //获取本地缓存节点数量统计
|
|
|
+ List<WbsTreeContractLazyVO> resultParentNodesTB = this.getCachedParentCountNodes(contractId, lowestNodeParentIdsTB, nodesAll, tableOwner);
|
|
|
|
|
|
//最底层节点颜色构造后Map
|
|
|
Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
|
|
@@ -803,8 +779,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
|
|
|
|
|
|
- //long startTime3 = System.currentTimeMillis();
|
|
|
- //TODO 处理颜色
|
|
|
+ /*处理颜色*/
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
//先将WbsTreeContractLazyVO转为NodeVO
|
|
|
List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
|
|
|
//转为Map<Long, NodeVO>
|
|
@@ -817,12 +793,11 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
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("处理颜色执行时间:" + executionTime + " ms");
|
|
|
|
|
|
- /*long endTime3 = System.currentTimeMillis();
|
|
|
- long executionTime3 = endTime3- startTime3;
|
|
|
- System.out.println("3333333333333:" + executionTime3);*/
|
|
|
-
|
|
|
- //TODO 处理最终结果集
|
|
|
+ /*处理最终结果集*/
|
|
|
if (lazyNodes.size() > 0) {
|
|
|
//处理填报数量
|
|
|
Map<Long, Integer> countMap = new HashMap<>();
|
|
@@ -850,6 +825,11 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
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);
|
|
@@ -864,7 +844,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return lazyNodes;
|
|
|
}
|
|
|
|
|
|
- //TODO ************ 监理、业主合同段 ************
|
|
|
+ /*监理、业主合同段*/
|
|
|
} else if (new Integer("2").equals(contractInfo.getContractType()) || new Integer("3").equals(contractInfo.getContractType())) {
|
|
|
List<WbsTreeContractLazyVO> lazyNodesAll = new ArrayList<>();
|
|
|
List<String> contractIds = new ArrayList<>();
|
|
@@ -881,125 +861,49 @@ 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 {*/
|
|
|
-
|
|
|
- List<WbsTreeContract> wbsTreeContracts = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
- .select(WbsTreeContract::getId, WbsTreeContract::getPKeyId, WbsTreeContract::getParentId)
|
|
|
- .eq(WbsTreeContract::getType, 1)
|
|
|
- .eq(WbsTreeContract::getStatus, 1)
|
|
|
- .eq(WbsTreeContract::getContractId, sgContractId)
|
|
|
- );
|
|
|
- nodesAll = BeanUtil.copyProperties(wbsTreeContracts, WbsTreeContractLazyVO.class);
|
|
|
-
|
|
|
- //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 = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /*JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAll));
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + sgContractId, JSON.toJSON(array).toString());*/
|
|
|
- }
|
|
|
- //}
|
|
|
+ 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) 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) {
|
|
|
- //所有节点
|
|
|
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;
|
|
|
- Object dataInformationQuery;
|
|
|
- if (ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_1");
|
|
|
- } else {
|
|
|
- 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());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ 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());
|
|
|
|
|
|
- //TODO 处理数量
|
|
|
- //填报过的所有最底层节点
|
|
|
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);
|
|
|
|
|
|
- //最底层节点颜色构造后Map
|
|
|
+ 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) {
|
|
|
- //任务状态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()));
|
|
|
|
|
|
- //TODO 处理颜色
|
|
|
- //先将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));
|
|
|
|
|
|
- //TODO 处理最终结果集
|
|
|
if (lazyNodes.size() > 0) {
|
|
|
- //处理填报数量
|
|
|
Map<Long, Integer> countMap = new HashMap<>();
|
|
|
for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
|
Long key = node.getPKeyId();
|
|
@@ -1010,9 +914,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //返回最终结果集
|
|
|
for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
|
|
|
- lazyNodeVO.setType(lazyNodeVO.getNodeType()); //前端显示需要一样的,所以修改成一样的
|
|
|
+ lazyNodeVO.setType(lazyNodeVO.getNodeType());
|
|
|
lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
|
|
|
lazyNodeVO.setPrimaryKeyId(lazyNodeVO.getPKeyId());
|
|
|
lazyNodeVO.setContractIdRelation(sgContractId);
|
|
@@ -1022,10 +925,12 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //设置数量
|
|
|
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);
|
|
@@ -1048,14 +953,162 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前合同段所有节点缓存
|
|
|
+ *
|
|
|
+ * @param contractId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<WbsTreeContractLazyVO> getNodeAll(String contractId) {
|
|
|
+ //获取本地缓存
|
|
|
+ List<WbsTreeContractLazyVO> nodesAll = localCacheNodes.get(contractId);
|
|
|
+
|
|
|
+ if (nodesAll == null || nodesAll.size() == 0) {
|
|
|
+ //从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();
|
|
|
+ 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));
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
+ long executionTime = endTime - startTime;
|
|
|
+ logger.info("查询合同段 " + contractId + " 所有树执行时间:" + 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("节点树数量统计计算耗时:" + 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;
|
|
|
+ if (dataInformationQuery != null) {
|
|
|
+ queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
|
|
|
+ //更新本地缓存
|
|
|
+ localCacheQueryInfos.put(cacheKey, queryInfoList);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //返回数据库数据
|
|
|
+ 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));
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
+ long executionTime = endTime - startTime;
|
|
|
+ logger.info("合同段资料信息查询耗时:" + executionTime + " ms");
|
|
|
+
|
|
|
+ if (!queryInfoList.isEmpty()) {
|
|
|
+ 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
|
|
|
- public List<WbsTreeContractLazyVO> imageLazyQueryContractWbsTree(String id, String contractId, String contractIdRelation, String classId) {
|
|
|
+ public List<WbsTreeContractLazyVO> imageLazyQueryContractWbsTree(String id, String contractId, String
|
|
|
+ contractIdRelation, String classId) {
|
|
|
if (ObjectUtil.isNotEmpty(contractId)) {
|
|
|
ContractInfo contractInfo = jdbcTemplate.query("select contract_name,contract_type from m_contract_info where id = " + contractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
|
|
|
if (contractInfo != null) {
|
|
|
- //TODO 施工合同段
|
|
|
+ /*质检施工合同段*/
|
|
|
if (new Integer(1).equals(contractInfo.getContractType())) {
|
|
|
- //获取当前合同段所有缓存节点信息
|
|
|
List<WbsTreeContractLazyVO> nodesAll;
|
|
|
Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + contractId);
|
|
|
if (data != null) {
|
|
@@ -1063,7 +1116,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
} else {
|
|
|
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));
|
|
|
if (nodesAll.size() > 0) {
|
|
|
- //判断是否有子级,赋值
|
|
|
Map<Long, List<WbsTreeContractLazyVO>> groupedByParentId = nodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
|
|
|
for (WbsTreeContractLazyVO vo : nodesAll) {
|
|
|
if (vo.getParentId() == 0) {
|
|
@@ -1080,24 +1132,21 @@ 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,(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));
|
|
|
+ List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_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", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
if (lazyNodes.size() > 0 && nodesAll.size() > 0) {
|
|
|
- //所有节点
|
|
|
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<WbsTreeContractLazyFileVO> queryFileList = jdbcTemplate.query("select wbs_id,id from u_image_classification_file where status = 1 and is_deleted = 0 and contract_id = " + contractId + " and classify_id = " + classId, new BeanPropertyRowMapper<>(WbsTreeContractLazyFileVO.class));
|
|
|
- //最底层节点与存储文件数量map
|
|
|
+
|
|
|
Map<Long, Integer> queryFileMaps = queryFileList.stream()
|
|
|
.filter(f -> ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
.collect(Collectors.groupingBy(
|
|
@@ -1124,7 +1173,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
|
|
|
this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
|
|
|
- //处理最终结果集
|
|
|
if (lazyNodes.size() > 0) {
|
|
|
Map<Long, Integer> countMap = new HashMap<>();
|
|
|
for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
@@ -1136,7 +1184,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //返回最终结果集
|
|
|
for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
|
|
|
lazyNodeVO.setType(lazyNodeVO.getNodeType());
|
|
|
lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
|
|
@@ -1146,14 +1193,13 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
lazyNodeVO.setTitle(contractInfo.getContractName());
|
|
|
}
|
|
|
}
|
|
|
- //设置数量
|
|
|
lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryFileMaps.get(lazyNodeVO.getPKeyId())) ? queryFileMaps.get(lazyNodeVO.getPKeyId()) : 0));
|
|
|
}
|
|
|
}
|
|
|
return lazyNodes;
|
|
|
}
|
|
|
|
|
|
- //TODO 监理、业主合同段
|
|
|
+ /*监理、业主合同段*/
|
|
|
} else if (new Integer("2").equals(contractInfo.getContractType()) || new Integer("3").equals(contractInfo.getContractType())) {
|
|
|
List<WbsTreeContractLazyVO> lazyNodesAll = new ArrayList<>();
|
|
|
List<String> contractIds = new ArrayList<>();
|
|
@@ -1170,7 +1216,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) {
|
|
@@ -1178,7 +1223,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
} else {
|
|
|
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 = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
if (nodesAll.size() > 0) {
|
|
|
- //判断是否有子级,赋值
|
|
|
Map<Long, List<WbsTreeContractLazyVO>> groupedByParentId = nodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
|
|
|
for (WbsTreeContractLazyVO vo : nodesAll) {
|
|
|
if (vo.getParentId() == 0) {
|
|
@@ -1196,17 +1240,13 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //获取当前层懒加载节点
|
|
|
- List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,(SELECT id FROM u_contract_tree_drawings where process_id = p_key_id) 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,(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) {
|
|
|
- //所有节点
|
|
|
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
|
|
@@ -1214,7 +1254,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
//获取当前合同段所有影像文件信息(只查看监理自己的,资料填报是查看的施工合同段的,这里有区别)
|
|
|
List<WbsTreeContractLazyFileVO> queryFileList = jdbcTemplate.query("select wbs_id,id from u_image_classification_file where status = 1 and contract_id = " + contractId + " and classify_id = " + classId, new BeanPropertyRowMapper<>(WbsTreeContractLazyFileVO.class));
|
|
|
- //最底层节点与存储文件数量map
|
|
|
+
|
|
|
Map<Long, Integer> queryFileMaps = queryFileList.stream()
|
|
|
.filter(f -> ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
.collect(Collectors.groupingBy(
|
|
@@ -1239,7 +1279,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
|
|
|
this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
|
|
|
- //处理最终结果集
|
|
|
if (lazyNodes.size() > 0) {
|
|
|
Map<Long, Integer> countMap = new HashMap<>();
|
|
|
for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
@@ -1251,9 +1290,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //返回最终结果集
|
|
|
for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
|
|
|
- lazyNodeVO.setType(lazyNodeVO.getNodeType()); //前端显示需要一样的,所以修改成一样的
|
|
|
+ lazyNodeVO.setType(lazyNodeVO.getNodeType());
|
|
|
lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
|
|
|
lazyNodeVO.setPrimaryKeyId(lazyNodeVO.getPKeyId());
|
|
|
lazyNodeVO.setContractIdRelation(sgContractId);
|
|
@@ -1262,7 +1300,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
lazyNodeVO.setTitle(sgContractInfo.getContractName());
|
|
|
}
|
|
|
}
|
|
|
- //设置数量
|
|
|
lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryFileMaps.get(lazyNodeVO.getPKeyId())) ? queryFileMaps.get(lazyNodeVO.getPKeyId()) : 0));
|
|
|
}
|
|
|
}
|
|
@@ -1298,8 +1335,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<AppWbsTreeContractVO> searchNodeAllTableAndFile(String primaryKeyId, String type, String contractId, String projectId) {
|
|
|
- List<AppWbsTreeContractVO> vos = this.searchNodeAllTable(primaryKeyId, type, contractId, projectId);
|
|
|
+ public List<AppWbsTreeContractVO> searchNodeAllTableAndFile(String primaryKeyId, String type, String
|
|
|
+ contractId, String projectId) {
|
|
|
+ List<AppWbsTreeContractVO> vos = this.searchNodeAllTable(primaryKeyId, type, contractId, projectId, null);
|
|
|
if (vos != null && vos.size() > 0) {
|
|
|
List<Long> list = vos.stream().map(AppWbsTreeContractVO::getPKeyId).collect(Collectors.toList());
|
|
|
List<TableFile> files = tableFileService.getAllFileByIds(list);
|
|
@@ -1383,7 +1421,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
* @param initNode 初始化节点入参
|
|
|
* @param contractId 合同段id
|
|
|
*/
|
|
|
- private void getConcealedWorkParentNode(Set<WbsTreeContract> resultAllNodes, List<WbsTreeContract> initNode, String contractId) {
|
|
|
+ private void getConcealedWorkParentNode
|
|
|
+ (Set<WbsTreeContract> resultAllNodes, List<WbsTreeContract> initNode, String contractId) {
|
|
|
Set<Long> parentIds = initNode.stream().map(WbsTreeContract::getParentId).collect(Collectors.toSet());
|
|
|
if (parentIds.size() > 0) {
|
|
|
List<WbsTreeContract> parentNodes = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getId, parentIds).eq(WbsTreeContract::getContractId, contractId).eq(WbsTreeContract::getType, 1));
|
|
@@ -1401,7 +1440,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
* @param initNode 初始化节点入参
|
|
|
* @param contractId 合同段id
|
|
|
*/
|
|
|
- private void getConcealedWorkChildNode(Set<WbsTreeContract> resultAllNodes, List<WbsTreeContract> initNode, String contractId) {
|
|
|
+ private void getConcealedWorkChildNode
|
|
|
+ (Set<WbsTreeContract> resultAllNodes, List<WbsTreeContract> initNode, String contractId) {
|
|
|
Set<Long> childIds = initNode.stream().map(WbsTreeContract::getId).collect(Collectors.toSet());
|
|
|
if (childIds.size() > 0) {
|
|
|
List<WbsTreeContract> childNodes = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getParentId, childIds).eq(WbsTreeContract::getContractId, contractId).eq(WbsTreeContract::getType, 1));
|
|
@@ -1439,43 +1479,31 @@ 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;
|
|
|
}
|
|
|
|
|
|
//父级Id与出现的次数Map
|
|
|
- Map<Long, Long> parentIdGroup = lowestNodeParentIds.stream()
|
|
|
- .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
|
|
-
|
|
|
- List<String> keysWithValueOne = new ArrayList<>();
|
|
|
- Map<Long, Long> keysWithValueSome = new HashMap<>();
|
|
|
-
|
|
|
- for (Map.Entry<Long, Long> entry : parentIdGroup.entrySet()) {
|
|
|
- if (entry.getValue() == 1L) {
|
|
|
- keysWithValueOne.add(entry.getKey().toString());
|
|
|
- } else {
|
|
|
- keysWithValueSome.put(entry.getKey(), entry.getValue());
|
|
|
- }
|
|
|
- }
|
|
|
+ Map<Long, Long> parentIdGroup = lowestNodeParentIds.parallelStream()
|
|
|
+ .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
|
|
|
|
|
|
//批量查询单次节点
|
|
|
- List<WbsTreeContractLazyVO> parentNodes = new ArrayList<>();
|
|
|
- if (keysWithValueOne.size() > 0) {
|
|
|
- parentNodes = nodesAll.stream().filter(f -> keysWithValueOne.contains(f.getId().toString())).collect(Collectors.toList());
|
|
|
- }
|
|
|
+ List<WbsTreeContractLazyVO> parentNodes = parentIdGroup.entrySet().parallelStream()
|
|
|
+ .filter(entry -> entry.getValue() == 1L)
|
|
|
+ .flatMap(entry -> nodesAll.parallelStream()
|
|
|
+ .filter(f -> entry.getKey().equals(f.getId())))
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
//批量查询多次节点
|
|
|
- List<WbsTreeContractLazyVO> multipleParentNodes = new ArrayList<>();
|
|
|
- for (Map.Entry<Long, Long> entry : keysWithValueSome.entrySet()) {
|
|
|
- Long key = entry.getKey();
|
|
|
- Long count = entry.getValue();
|
|
|
-
|
|
|
- List<WbsTreeContractLazyVO> nodes = nodesAll.stream().filter(f -> key.equals(f.getId())).collect(Collectors.toList());
|
|
|
- if (!nodes.isEmpty()) {
|
|
|
- multipleParentNodes.addAll(Collections.nCopies(count.intValue(), nodes.get(0)));
|
|
|
- }
|
|
|
- }
|
|
|
+ List<WbsTreeContractLazyVO> multipleParentNodes = 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).stream()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
//结果集
|
|
|
List<Long> collect = Stream.concat(parentNodes.stream(), multipleParentNodes.stream())
|
|
@@ -1487,8 +1515,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
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()) {
|
|
|
return;
|
|
|
}
|
|
@@ -1538,7 +1567,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
result.addAll(multipleParentNodes);
|
|
|
this.recursiveGetParentNodes(result, collect, nodesAll);
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
@Override
|
|
|
public boolean syncTabData(String pKeyId) throws Exception {
|
|
@@ -2525,13 +2554,15 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
* @param distinctNodesAll 去重后所有节点数据
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<NodeVO> buildNodeTreeByStream(List<WbsTreeContractLazyVO> distinctNodesAll, Map<Long, WbsTreeContractLazyVO> lowestNodesMap) {
|
|
|
+ public List<NodeVO> buildNodeTreeByStream
|
|
|
+ (List<WbsTreeContractLazyVO> distinctNodesAll, Map<Long, WbsTreeContractLazyVO> lowestNodesMap) {
|
|
|
List<WbsTreeContractLazyVO> list = distinctNodesAll.stream().filter(f -> f.getParentId().equals(0L)).collect(Collectors.toList());
|
|
|
Map<Long, List<WbsTreeContractLazyVO>> map = distinctNodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
|
|
|
return recursionFnNodeTree(list, map, lowestNodesMap);
|
|
|
}
|
|
|
|
|
|
- public List<NodeVO> recursionFnNodeTree(List<WbsTreeContractLazyVO> list, Map<Long, List<WbsTreeContractLazyVO>> map, Map<Long, WbsTreeContractLazyVO> lowestNodesMap) {
|
|
|
+ public List<NodeVO> recursionFnNodeTree
|
|
|
+ (List<WbsTreeContractLazyVO> list, Map<Long, List<WbsTreeContractLazyVO>> map, Map<Long, WbsTreeContractLazyVO> lowestNodesMap) {
|
|
|
List<NodeVO> result = new ArrayList<>();
|
|
|
for (WbsTreeContractLazyVO vo : list) {
|
|
|
if (vo.getHasChildren().equals(0)) {
|
|
@@ -2675,5 +2706,30 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ /*删除合同段本地缓存*/
|
|
|
+ public void deleteContractLocalCache(String contractId) {
|
|
|
+ /*删除节点缓存*/
|
|
|
+ localCacheNodes.remove(contractId);
|
|
|
+
|
|
|
+ /*删除资料缓存*/
|
|
|
+ Iterator<Map.Entry<String, List<WbsTreeContractLazyQueryInfoVO>>> iterator_1 = localCacheQueryInfos.entrySet().iterator();
|
|
|
+ while (iterator_1.hasNext()) {
|
|
|
+ Map.Entry<String, List<WbsTreeContractLazyQueryInfoVO>> entry = iterator_1.next();
|
|
|
+ String cacheKey = entry.getKey();
|
|
|
+ if (cacheKey.startsWith(contractId + "_")) {
|
|
|
+ iterator_1.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*删除节点计算统计缓存*/
|
|
|
+ Iterator<Map.Entry<String, List<WbsTreeContractLazyVO>>> iterator_2 = localCacheParentCountNodes.entrySet().iterator();
|
|
|
+ while (iterator_2.hasNext()) {
|
|
|
+ Map.Entry<String, List<WbsTreeContractLazyVO>> entry = iterator_2.next();
|
|
|
+ String cacheKey = entry.getKey();
|
|
|
+ if (cacheKey.startsWith(contractId + "_")) {
|
|
|
+ iterator_2.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|