|
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.business.entity.WbsTreeContractStatistics;
|
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
|
import org.springblade.common.utils.BaiduApiUtil;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
@@ -372,7 +373,11 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
if (contractInfo.getContractType().equals(1)) {
|
|
|
LambdaQueryWrapper<WbsTreeContract> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.select(WbsTreeContract::getParentId, WbsTreeContract::getId, WbsTreeContract::getPKeyId);
|
|
|
- queryWrapper.like(WbsTreeContract::getFullName, queryValue);
|
|
|
+ if (queryValue.startsWith(contractInfo.getContractName() + "\\") && queryValue.lastIndexOf("\\") + 1 < queryValue.length()) {
|
|
|
+ queryWrapper.like(WbsTreeContract::getFullName, queryValue.substring(queryValue.lastIndexOf("\\") + 1));
|
|
|
+ } else {
|
|
|
+ queryWrapper.like(WbsTreeContract::getFullName, queryValue);
|
|
|
+ }
|
|
|
queryWrapper.eq(WbsTreeContract::getContractId, contractId);
|
|
|
queryWrapper.eq(WbsTreeContract::getType, 1);
|
|
|
List<WbsTreeContract> nodes = wbsTreeContractMapper.selectList(queryWrapper);
|
|
@@ -401,15 +406,15 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- List<WbsTreeContractLazyVO> distinctNodesAll = nodesAllTemp.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<WbsTreeContractLazyVO> distinctNodesAll = nodesAllTemp.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<Long> parentIds = nodes.stream().map(WbsTreeContract::getParentId).collect(Collectors.toList());
|
|
|
List<Long> ids = nodes.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
|
|
@@ -420,68 +425,72 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
resultNodesPKeyIds.addAll(nodes.stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList()));
|
|
|
List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, resultNodesPKeyIds));
|
|
|
|
|
|
- List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
|
|
|
- Object dataInformationQuery;
|
|
|
- if (cn.hutool.core.util.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 (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? GROUP BY wbs_id ) as a)"
|
|
|
- , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractId);
|
|
|
- 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 id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? AND classify = ? GROUP BY wbs_id) as a)"
|
|
|
- , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractId,tableOwner);
|
|
|
- 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 -> cn.hutool.core.util.ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
- .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
|
|
|
- List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
|
|
|
-
|
|
|
- List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId()) && resultNodesPKeyIds.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
- List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
|
|
|
- List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
|
|
|
- wbsTreeContractServiceImpl.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAllTemp);
|
|
|
-
|
|
|
- Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
|
|
|
- .peek(vo -> {
|
|
|
- Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
|
|
|
- if (colorStatus != null) {
|
|
|
- vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 2)));
|
|
|
- } else {
|
|
|
- vo.setColorStatus(1);
|
|
|
- }
|
|
|
- }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
|
|
|
-
|
|
|
- List<NodeVO> nodeVOList = distinctNodesAll.stream().map(wbsTreeContractServiceImpl::convertToNodeVO).collect(Collectors.toList());
|
|
|
- Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
|
|
|
- List<NodeVO> treeNodeVOList = wbsTreeContractServiceImpl.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
|
|
|
- NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
- List<NodeVO> nodeVOS = wbsTreeContractServiceImpl.flattenTree(treeNodeVOList);
|
|
|
- Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
|
+// List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
|
|
|
+// Object dataInformationQuery;
|
|
|
+// if (cn.hutool.core.util.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 (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
|
|
|
+// queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? GROUP BY wbs_id ) as a)"
|
|
|
+// , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractId);
|
|
|
+// 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 id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? AND classify = ? GROUP BY wbs_id) as a)"
|
|
|
+// , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractId,tableOwner);
|
|
|
+// 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 -> cn.hutool.core.util.ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
+// .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
|
|
|
+// List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
|
|
|
+
|
|
|
+// List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId()) && resultNodesPKeyIds.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
+// List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
|
|
|
+// List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
|
|
|
+// wbsTreeContractServiceImpl.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAllTemp);
|
|
|
+//
|
|
|
+// Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
|
|
|
+// .peek(vo -> {
|
|
|
+// Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
|
|
|
+// if (colorStatus != null) {
|
|
|
+// vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 2)));
|
|
|
+// } else {
|
|
|
+// vo.setColorStatus(1);
|
|
|
+// }
|
|
|
+// }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
|
|
|
+//
|
|
|
+// List<NodeVO> nodeVOList = distinctNodesAll.stream().map(wbsTreeContractServiceImpl::convertToNodeVO).collect(Collectors.toList());
|
|
|
+// Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
|
|
|
+// List<NodeVO> treeNodeVOList = wbsTreeContractServiceImpl.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
|
|
|
+// NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
+// List<NodeVO> nodeVOS = wbsTreeContractServiceImpl.flattenTree(treeNodeVOList);
|
|
|
+// Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
|
|
|
|
if (wbsTreeContractList.size() > 0) {
|
|
|
- Map<Long, Long> countMap = new HashMap<>();
|
|
|
- for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
|
- Long key = node.getPKeyId();
|
|
|
- if (countMap.containsKey(key)) {
|
|
|
- countMap.put(key, countMap.get(key) + 1L);
|
|
|
- } else {
|
|
|
- countMap.put(key, 1L);
|
|
|
- }
|
|
|
- }
|
|
|
+// Map<Long, Long> countMap = new HashMap<>();
|
|
|
+// for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
|
+// Long key = node.getPKeyId();
|
|
|
+// if (countMap.containsKey(key)) {
|
|
|
+// countMap.put(key, countMap.get(key) + 1L);
|
|
|
+// } else {
|
|
|
+// countMap.put(key, 1L);
|
|
|
+// }
|
|
|
+// }
|
|
|
+ String pKeyIds = wbsTreeContractList.stream().map(item -> item.getPKeyId() + "").collect(Collectors.joining(","));
|
|
|
+ List<WbsTreeContractStatistics> wbsTreeContractStatisticsList = jdbcTemplate.query("select id, leaf_num, fill_num, approve_num, complete_num,jl_fill_num, jl_approve_num, jl_complete_num from m_wbs_tree_contract_statistics where id in (" + pKeyIds + ")",
|
|
|
+ new BeanPropertyRowMapper<>(WbsTreeContractStatistics.class));
|
|
|
+ Map<Long, WbsTreeContractStatistics> wbsTreeContractStatisticsMap = wbsTreeContractStatisticsList.stream().collect(Collectors.toMap(WbsTreeContractStatistics::getId, item -> item));
|
|
|
List<WbsTreeContractTreeAllVO> wbsTreeContractTreeAllVOS = wbsTreeContractList.stream()
|
|
|
.map(node -> {
|
|
|
WbsTreeContractTreeAllVO vo = BeanUtil.copyProperties(node, WbsTreeContractTreeAllVO.class);
|
|
@@ -490,22 +499,30 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
vo.setType(ObjectUtils.isNotEmpty(node.getNodeType()) ? node.getNodeType() : 0);
|
|
|
vo.setTitle(ObjectUtil.isNotEmpty(node.getFullName()) ? node.getFullName() : node.getNodeName());
|
|
|
vo.setPrimaryKeyId(node.getPKeyId());
|
|
|
-
|
|
|
- vo.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(vo.getPrimaryKeyId())) ? countMap.get(vo.getPrimaryKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(vo.getPrimaryKeyId())) ? 1L : 0L));
|
|
|
-
|
|
|
- Integer parentColorStatus = nodeColorStatusMap.get(vo.getPrimaryKeyId());
|
|
|
- if (parentColorStatus != null) {
|
|
|
- vo.setColorStatus(parentColorStatus);
|
|
|
+ WbsTreeContractStatistics statistics = wbsTreeContractStatisticsMap.get(node.getPKeyId());
|
|
|
+ if (statistics != null) {
|
|
|
+ Integer nums = statistics.calculateSubmitNums(tableOwner);
|
|
|
+ vo.setSubmitCounts(nums == null ? 0 : nums.longValue());
|
|
|
+ vo.setColorStatus(statistics.calculateColorStatus(tableOwner));
|
|
|
} else {
|
|
|
- WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(vo.getPrimaryKeyId());
|
|
|
- if (lowestNode != null) {
|
|
|
- vo.setColorStatus(lowestNode.getColorStatus());
|
|
|
- }
|
|
|
+ vo.setSubmitCounts(0L);
|
|
|
+ vo.setColorStatus(1);
|
|
|
}
|
|
|
+// vo.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(vo.getPrimaryKeyId())) ? countMap.get(vo.getPrimaryKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(vo.getPrimaryKeyId())) ? 1L : 0L));
|
|
|
+//
|
|
|
+// Integer parentColorStatus = nodeColorStatusMap.get(vo.getPrimaryKeyId());
|
|
|
+// if (parentColorStatus != null) {
|
|
|
+// vo.setColorStatus(parentColorStatus);
|
|
|
+// } else {
|
|
|
+// WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(vo.getPrimaryKeyId());
|
|
|
+// if (lowestNode != null) {
|
|
|
+// vo.setColorStatus(lowestNode.getColorStatus());
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
- return R.data(this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS));
|
|
|
+ return R.data(this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS, queryValue));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -517,9 +534,14 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
return null;
|
|
|
}
|
|
|
for (ContractRelationJlyz contractRelationJlyz : relationJLYZList) {
|
|
|
+ ContractInfo contractInfoJlYz = this.getBaseMapper().selectById(contractRelationJlyz.getContractIdSg());
|
|
|
LambdaQueryWrapper<WbsTreeContract> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.select(WbsTreeContract::getParentId, WbsTreeContract::getId, WbsTreeContract::getPKeyId);
|
|
|
- queryWrapper.like(WbsTreeContract::getFullName, queryValue);
|
|
|
+ if (queryValue.startsWith(contractInfoJlYz.getContractName() + "\\") && queryValue.lastIndexOf("\\") + 1 < queryValue.length()) {
|
|
|
+ queryWrapper.like(WbsTreeContract::getFullName, queryValue.substring(queryValue.lastIndexOf("\\") + 1));
|
|
|
+ } else {
|
|
|
+ queryWrapper.like(WbsTreeContract::getFullName, queryValue);
|
|
|
+ }
|
|
|
queryWrapper.eq(WbsTreeContract::getContractId, contractRelationJlyz.getContractIdSg());
|
|
|
queryWrapper.eq(WbsTreeContract::getType, 1);
|
|
|
List<WbsTreeContract> nodes = wbsTreeContractMapper.selectList(queryWrapper);
|
|
@@ -549,15 +571,15 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- List<WbsTreeContractLazyVO> distinctNodesAll = nodesAllTemp.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<WbsTreeContractLazyVO> distinctNodesAll = nodesAllTemp.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<Long> parentIds = nodes.stream().map(WbsTreeContract::getParentId).collect(Collectors.toList());
|
|
|
List<Long> ids = nodes.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
|
|
@@ -567,69 +589,73 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
resultNodesPKeyIds.addAll(nodes.stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList()));
|
|
|
List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, resultNodesPKeyIds));
|
|
|
|
|
|
- List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
|
|
|
- Object dataInformationQuery;
|
|
|
- if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_1");
|
|
|
- } else {
|
|
|
- dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_" + tableOwner);
|
|
|
- }
|
|
|
- if (dataInformationQuery != null) {
|
|
|
- queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
|
|
|
- } else {
|
|
|
- if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? GROUP BY wbs_id) as a)"
|
|
|
- , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractRelationJlyz.getContractIdSg());
|
|
|
- if (queryInfoList.size() > 0) {
|
|
|
- JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_1", JSON.toJSON(array).toString());
|
|
|
- }
|
|
|
- } else {
|
|
|
- queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? AND classify = ? GROUP BY wbs_id) as a)"
|
|
|
- , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractRelationJlyz.getContractIdSg(), tableOwner);
|
|
|
- if (queryInfoList.size() > 0) {
|
|
|
- JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_" + tableOwner, JSON.toJSON(array).toString());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> cn.hutool.core.util.ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
- .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
|
|
|
- List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
|
|
|
-
|
|
|
- //数量
|
|
|
- List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId()) && resultNodesPKeyIds.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
- List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
|
|
|
- List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
|
|
|
- wbsTreeContractServiceImpl.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAllTemp);
|
|
|
-
|
|
|
- Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
|
|
|
- .peek(vo -> {
|
|
|
- Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
|
|
|
- if (colorStatus != null) {
|
|
|
- vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 2)));
|
|
|
- } else {
|
|
|
- vo.setColorStatus(1);
|
|
|
- }
|
|
|
- }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
|
|
|
-
|
|
|
- List<NodeVO> nodeVOList = distinctNodesAll.stream().map(wbsTreeContractServiceImpl::convertToNodeVO).collect(Collectors.toList());
|
|
|
- Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
|
|
|
- List<NodeVO> treeNodeVOList = wbsTreeContractServiceImpl.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
|
|
|
- NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
- List<NodeVO> nodeVOS = wbsTreeContractServiceImpl.flattenTree(treeNodeVOList);
|
|
|
- Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
|
+// List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
|
|
|
+// Object dataInformationQuery;
|
|
|
+// if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
|
|
|
+// dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_1");
|
|
|
+// } else {
|
|
|
+// dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_" + tableOwner);
|
|
|
+// }
|
|
|
+// if (dataInformationQuery != null) {
|
|
|
+// queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
|
|
|
+// } else {
|
|
|
+// if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
|
|
|
+// queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? GROUP BY wbs_id) as a)"
|
|
|
+// , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractRelationJlyz.getContractIdSg());
|
|
|
+// if (queryInfoList.size() > 0) {
|
|
|
+// JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
+// redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_1", JSON.toJSON(array).toString());
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where id in (SELECT id from (SELECT max(id) as id FROM u_information_query WHERE is_deleted = 0 AND type = 1 AND contract_id = ? AND classify = ? GROUP BY wbs_id) as a)"
|
|
|
+// , new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class), contractRelationJlyz.getContractIdSg(), tableOwner);
|
|
|
+// if (queryInfoList.size() > 0) {
|
|
|
+// JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
+// redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_" + tableOwner, JSON.toJSON(array).toString());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> cn.hutool.core.util.ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
+// .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
|
|
|
+// List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
|
|
|
+//
|
|
|
+// //数量
|
|
|
+// List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId()) && resultNodesPKeyIds.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
+// List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
|
|
|
+// List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
|
|
|
+// wbsTreeContractServiceImpl.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAllTemp);
|
|
|
+//
|
|
|
+// Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
|
|
|
+// .peek(vo -> {
|
|
|
+// Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
|
|
|
+// if (colorStatus != null) {
|
|
|
+// vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 2)));
|
|
|
+// } else {
|
|
|
+// vo.setColorStatus(1);
|
|
|
+// }
|
|
|
+// }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
|
|
|
+//
|
|
|
+// List<NodeVO> nodeVOList = distinctNodesAll.stream().map(wbsTreeContractServiceImpl::convertToNodeVO).collect(Collectors.toList());
|
|
|
+// Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
|
|
|
+// List<NodeVO> treeNodeVOList = wbsTreeContractServiceImpl.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
|
|
|
+// NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
+// List<NodeVO> nodeVOS = wbsTreeContractServiceImpl.flattenTree(treeNodeVOList);
|
|
|
+// Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
|
|
|
|
if (wbsTreeContractList.size() > 0) {
|
|
|
- Map<Long, Long> countMap = new HashMap<>();
|
|
|
- for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
|
- Long key = node.getPKeyId();
|
|
|
- if (countMap.containsKey(key)) {
|
|
|
- countMap.put(key, countMap.get(key) + 1L);
|
|
|
- } else {
|
|
|
- countMap.put(key, 1L);
|
|
|
- }
|
|
|
- }
|
|
|
+// Map<Long, Long> countMap = new HashMap<>();
|
|
|
+// for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
|
+// Long key = node.getPKeyId();
|
|
|
+// if (countMap.containsKey(key)) {
|
|
|
+// countMap.put(key, countMap.get(key) + 1L);
|
|
|
+// } else {
|
|
|
+// countMap.put(key, 1L);
|
|
|
+// }
|
|
|
+// }
|
|
|
+ String pKeyIds = wbsTreeContractList.stream().map(item -> item.getPKeyId() + "").collect(Collectors.joining(","));
|
|
|
+ List<WbsTreeContractStatistics> wbsTreeContractStatisticsList = jdbcTemplate.query("select id, leaf_num, fill_num, approve_num, complete_num,jl_fill_num, jl_approve_num, jl_complete_num from m_wbs_tree_contract_statistics where id in (" + pKeyIds + ")",
|
|
|
+ new BeanPropertyRowMapper<>(WbsTreeContractStatistics.class));
|
|
|
+ Map<Long, WbsTreeContractStatistics> wbsTreeContractStatisticsMap = wbsTreeContractStatisticsList.stream().collect(Collectors.toMap(WbsTreeContractStatistics::getId, item -> item));
|
|
|
List<WbsTreeContractTreeAllVO> wbsTreeContractTreeAllVOS = wbsTreeContractList.stream()
|
|
|
.map(node -> {
|
|
|
WbsTreeContractTreeAllVO vo = BeanUtil.copyProperties(node, WbsTreeContractTreeAllVO.class);
|
|
@@ -638,21 +664,30 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
vo.setType(ObjectUtils.isNotEmpty(node.getNodeType()) ? node.getNodeType() : 0);
|
|
|
vo.setTitle(ObjectUtil.isNotEmpty(node.getFullName()) ? node.getFullName() : node.getNodeName());
|
|
|
vo.setPrimaryKeyId(node.getPKeyId());
|
|
|
- vo.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(vo.getPrimaryKeyId())) ? countMap.get(vo.getPrimaryKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(vo.getPrimaryKeyId())) ? 1L : 0L));
|
|
|
-
|
|
|
- Integer parentColorStatus = nodeColorStatusMap.get(vo.getPrimaryKeyId());
|
|
|
- if (parentColorStatus != null) {
|
|
|
- vo.setColorStatus(parentColorStatus);
|
|
|
+ WbsTreeContractStatistics statistics = wbsTreeContractStatisticsMap.get(node.getPKeyId());
|
|
|
+ if (statistics != null) {
|
|
|
+ Integer nums = statistics.calculateSubmitNums(tableOwner);
|
|
|
+ vo.setSubmitCounts(nums == null ? 0 : nums.longValue());
|
|
|
+ vo.setColorStatus(statistics.calculateColorStatus(tableOwner));
|
|
|
} else {
|
|
|
- WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(vo.getPrimaryKeyId());
|
|
|
- if (lowestNode != null) {
|
|
|
- vo.setColorStatus(lowestNode.getColorStatus());
|
|
|
- }
|
|
|
+ vo.setSubmitCounts(0L);
|
|
|
+ vo.setColorStatus(1);
|
|
|
}
|
|
|
+// vo.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(vo.getPrimaryKeyId())) ? countMap.get(vo.getPrimaryKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(vo.getPrimaryKeyId())) ? 1L : 0L));
|
|
|
+//
|
|
|
+// Integer parentColorStatus = nodeColorStatusMap.get(vo.getPrimaryKeyId());
|
|
|
+// if (parentColorStatus != null) {
|
|
|
+// vo.setColorStatus(parentColorStatus);
|
|
|
+// } else {
|
|
|
+// WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(vo.getPrimaryKeyId());
|
|
|
+// if (lowestNode != null) {
|
|
|
+// vo.setColorStatus(lowestNode.getColorStatus());
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
- resultMaps.put(contractRelationJlyz.getContractIdSg(), this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS));
|
|
|
+ resultMaps.put(contractRelationJlyz.getContractIdSg(), this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS, queryValue));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -759,6 +794,41 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
this.recursionFnTreeAll(list, map);
|
|
|
return list;
|
|
|
}
|
|
|
+ public List<WbsTreeContractTreeAllVO> buildWbsTreeByStreamByTreeAll(List<WbsTreeContractTreeAllVO> wbsTreeVO2s, String position) {
|
|
|
+ String[] split = position.split("\\\\");
|
|
|
+ if (split.length > 1 && split[1] != null && !split[1].isEmpty()) {
|
|
|
+ List<WbsTreeContractTreeAllVO> list = wbsTreeVO2s.stream().filter(f -> f.getParentId() == 0L).collect(Collectors.toList());
|
|
|
+ Map<Long, List<WbsTreeContractTreeAllVO>> map = wbsTreeVO2s.stream().collect(Collectors.groupingBy(WbsTreeContractTreeAllVO::getParentId));
|
|
|
+ this.recursionFnTreeAll(list, map, split, 0);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ return buildWbsTreeByStreamByTreeAll(wbsTreeVO2s);
|
|
|
+ }
|
|
|
+ public void recursionFnTreeAll(List<WbsTreeContractTreeAllVO> list, Map<Long, List<WbsTreeContractTreeAllVO>> map, String[] positions, int i) {
|
|
|
+ for (WbsTreeContractTreeAllVO wbsTreeContractVO : list) {
|
|
|
+ String position;
|
|
|
+ if (i == 0 || i >= positions.length) {
|
|
|
+ position = null;
|
|
|
+ } else {
|
|
|
+ position = positions[i];
|
|
|
+ }
|
|
|
+ i++;
|
|
|
+ if (wbsTreeContractVO.getTitle() != null && (position == null || wbsTreeContractVO.getTitle().contains(position))) {
|
|
|
+ List<WbsTreeContractTreeAllVO> childrenList = map.get(wbsTreeContractVO.getId());
|
|
|
+ if (childrenList != null && !childrenList.isEmpty()) {
|
|
|
+ if (i < positions.length) {
|
|
|
+ String temp = positions[i];
|
|
|
+ childrenList = childrenList.stream().filter(item -> item.getTitle().contains(temp)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ wbsTreeContractVO.setChildren(childrenList);
|
|
|
+ if (!childrenList.isEmpty()) {
|
|
|
+ wbsTreeContractVO.setHasChildren(true);
|
|
|
+ recursionFnTreeAll(childrenList, map, positions, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public void recursionFnTree(List<WbsTreeContractVO> list, Map<Long, List<WbsTreeContractVO>> map) {
|
|
|
for (WbsTreeContractVO wbsTreeContractVO : list) {
|