|
@@ -1615,31 +1615,22 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
for (int i = 0; i < split.length; i++) {
|
|
|
String s = split[i];
|
|
|
if (StringUtil.isNumeric(s)) {
|
|
|
-// pKeyIds.add(Long.parseLong(s));
|
|
|
- if (s.equals(pKeyId + "") && i + 1 < split.length) {
|
|
|
- pKeyIds.add(Long.parseLong(split[i + 1]));
|
|
|
- break;
|
|
|
- }
|
|
|
+ pKeyIds.add(Long.parseLong(s));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
collectMap.put(node.getNodeId(), "");
|
|
|
-// pKeyIds.add(node.getNodeId());
|
|
|
+ pKeyIds.add(node.getNodeId());
|
|
|
}
|
|
|
List<WbsTreeContract> wbsTreeContractList = new ArrayList<>();
|
|
|
if (!pKeyIds.isEmpty()) {
|
|
|
LambdaQueryWrapper<WbsTreeContract> wrapper = Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, pKeyIds);
|
|
|
- if (pKeyId == null || pKeyId == 0) {
|
|
|
- wrapper.and(wrapper1 -> wrapper1.isNull(WbsTreeContract::getPId).or().eq(WbsTreeContract::getPId, 0));
|
|
|
- } else {
|
|
|
- wrapper.eq(WbsTreeContract::getPId, pKeyId);
|
|
|
- }
|
|
|
wrapper.and(wrapper1 -> wrapper1.isNull(WbsTreeContract::getIsBussShow).or().ne(WbsTreeContract::getIsBussShow, 2));
|
|
|
wbsTreeContractList = wbsTreeContractMapper.selectList(wrapper);
|
|
|
}
|
|
|
if (!wbsTreeContractList.isEmpty()) {
|
|
|
String pKeyIdStr = 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 (" + pKeyIdStr + ")",
|
|
|
+ List<WbsTreeContractStatistics> wbsTreeContractStatisticsList = jdbcTemplate.query("select id, parent_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 (" + pKeyIdStr + ")",
|
|
|
new BeanPropertyRowMapper<>(WbsTreeContractStatistics.class));
|
|
|
Map<Long, WbsTreeContractStatistics> wbsTreeContractStatisticsMap = wbsTreeContractStatisticsList.stream().collect(Collectors.toMap(WbsTreeContractStatistics::getId, item -> item));
|
|
|
Map<String, List<WbsTreeContract>> contractGroupMap = wbsTreeContractList.stream().collect(Collectors.groupingBy(WbsTreeContract::getContractId));
|
|
@@ -1653,6 +1644,7 @@ 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.setParentId(node.getPId());
|
|
|
WbsTreeContractStatistics statistics = wbsTreeContractStatisticsMap.get(node.getPKeyId());
|
|
|
if (statistics != null) {
|
|
|
Integer nums = statistics.calculateSubmitNums(tableOwner);
|
|
@@ -1663,6 +1655,9 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
} else {
|
|
|
vo.setHasChildren(false);
|
|
|
}
|
|
|
+ if (vo.getParentId() == null) {
|
|
|
+ vo.setParentId(statistics.getParentId());
|
|
|
+ }
|
|
|
} else {
|
|
|
vo.setSubmitCounts(0L);
|
|
|
vo.setColorStatus(1);
|
|
@@ -1681,20 +1676,8 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
}
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
-// List<WbsTreeContractTreeAllVO> resultList = this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS);
|
|
|
- Comparator<WbsTreeContractTreeAllVO> safeComparator = Comparator
|
|
|
- .comparing(WbsTreeContractTreeAllVO::getSort, Comparator.nullsFirst(Comparator.naturalOrder()))
|
|
|
- .thenComparing(new ComplexStringComparator<>(obj ->
|
|
|
- obj.getTitle() != null ? obj.getTitle() : ""))
|
|
|
- .thenComparing(
|
|
|
- WbsTreeContractTreeAllVO::getPrimaryKeyId,
|
|
|
- Comparator.nullsLast(Comparator.reverseOrder()));
|
|
|
- wbsTreeContractTreeAllVOS.sort(safeComparator);
|
|
|
- if (StringUtil.hasText(queryValue)) {
|
|
|
- resultMaps.put(Long.parseLong(cId), this.queryTreeResult(wbsTreeContractTreeAllVOS, queryValue));
|
|
|
- } else {
|
|
|
- resultMaps.put(Long.parseLong(cId), wbsTreeContractTreeAllVOS);
|
|
|
- }
|
|
|
+ List<WbsTreeContractTreeAllVO> resultList = this.buildWbsTreeByStreamByTreeAll1(wbsTreeContractTreeAllVOS, pKeyId);
|
|
|
+ resultMaps.put(Long.parseLong(cId), resultList);
|
|
|
});
|
|
|
if (contractInfo.getContractType() != null && contractInfo.getContractType() == 1) {
|
|
|
return R.data(resultMaps.get(contractInfo.getId()));
|
|
@@ -1704,6 +1687,64 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+ public List<WbsTreeContractTreeAllVO> buildWbsTreeByStreamByTreeAll1(List<WbsTreeContractTreeAllVO> wbsTreeVO2s, Long pKeyId) {
|
|
|
+ List<WbsTreeContractTreeAllVO> list = wbsTreeVO2s.stream().filter(f -> f.getParentId() == 0L).collect(Collectors.toList());
|
|
|
+ // 修改比较器链,处理空值情况
|
|
|
+ Comparator<WbsTreeContractTreeAllVO> safeComparator = Comparator
|
|
|
+ .comparing(WbsTreeContractTreeAllVO::getSort, Comparator.nullsFirst(Comparator.naturalOrder()))
|
|
|
+ .thenComparing(new ComplexStringComparator<>(obj ->
|
|
|
+ obj.getTitle() != null ? obj.getTitle() : ""))
|
|
|
+ .thenComparing(
|
|
|
+ WbsTreeContractTreeAllVO::getId,
|
|
|
+ Comparator.nullsLast(Comparator.reverseOrder()));
|
|
|
+ list.sort(safeComparator);
|
|
|
+ Map<Long, List<WbsTreeContractTreeAllVO>> map = wbsTreeVO2s.stream().collect(Collectors.groupingBy(WbsTreeContractTreeAllVO::getParentId,
|
|
|
+ Collectors.collectingAndThen(Collectors.toList(), items -> items.stream().sorted(safeComparator).collect(Collectors.toList()))));
|
|
|
+ List<WbsTreeContractTreeAllVO> list1 = map.get(pKeyId);
|
|
|
+ if (list1 == null || list1.isEmpty()) {
|
|
|
+ return list1;
|
|
|
+ }
|
|
|
+ List<WbsTreeContractTreeAllVO> resultList = new ArrayList<>();
|
|
|
+ for (WbsTreeContractTreeAllVO vo : list1) {
|
|
|
+ List<WbsTreeContractTreeAllVO> list2 = map.get(vo.getPrimaryKeyId());
|
|
|
+ if ((list2 == null || list2.isEmpty())) {
|
|
|
+ if (vo.getIsCollect() != null && vo.getIsCollect() == 1) {
|
|
|
+ resultList.add(vo);
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ long count = list2.stream().filter(f -> f.getIsCollect() != null && f.getIsCollect() == 1).count();
|
|
|
+ if (count > 0) {
|
|
|
+ resultList.add(vo);
|
|
|
+ } else {
|
|
|
+ if (isShow(list2, map)) {
|
|
|
+ resultList.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isShow(List<WbsTreeContractTreeAllVO> list, Map<Long, List<WbsTreeContractTreeAllVO>> map){
|
|
|
+ for (WbsTreeContractTreeAllVO vo : list) {
|
|
|
+ List<WbsTreeContractTreeAllVO> list2 = map.get(vo.getPrimaryKeyId());
|
|
|
+ if ((list2 == null || list2.isEmpty())) {
|
|
|
+ if (vo.getIsCollect() != null && vo.getIsCollect() == 1) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ long count = list2.stream().filter(f -> f.getIsCollect() != null && f.getIsCollect() == 1).count();
|
|
|
+ if (count > 0) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ if (isShow(list2, map)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public R<Object> getCollectTreeNodeByQuery(String contractId, String tableOwner, Long folderId, String queryValue) {
|
|
@@ -1718,8 +1759,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
return R.fail(200, "合同段不存在");
|
|
|
}
|
|
|
Set<String> syncPKeyIds = getSyncFlagIds(contractId, tableOwner);
|
|
|
- List<ContractCollectFolder> contractCollectNodes = jdbcTemplate.query("select node_id, ifnull((select ancestors_p_id from m_wbs_tree_contract where p_key_id = a.node_id), (select ancestors from m_wbs_tree_contract_statistics where id = a.node_id)) as nodeAncestors from m_contract_collect_folder a where type = 1 and parent_id = " + folderId
|
|
|
- + " and EXISTS (SELECT 1 from m_wbs_tree_contract where p_key_id = a.node_id)",
|
|
|
+ List<ContractCollectFolder> contractCollectNodes = jdbcTemplate.query("select node_id, ifnull((select ancestors_p_id from m_wbs_tree_contract where p_key_id = a.node_id), (select ancestors from m_wbs_tree_contract_statistics where id = a.node_id)) as nodeAncestors from m_contract_collect_folder a where type = 1 and parent_id = " + folderId,
|
|
|
new BeanPropertyRowMapper<>(ContractCollectFolder.class));
|
|
|
if (!contractCollectNodes.isEmpty()) {
|
|
|
Set<Long> pKeyIds = new LinkedHashSet<>();
|
|
@@ -1737,7 +1777,8 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
collectMap.put(node.getNodeId(), "");
|
|
|
pKeyIds.add(node.getNodeId());
|
|
|
}
|
|
|
- List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, pKeyIds));
|
|
|
+ List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, pKeyIds).
|
|
|
+ and(wrapper1 -> wrapper1.isNull(WbsTreeContract::getIsBussShow).or().ne(WbsTreeContract::getIsBussShow, 2)));
|
|
|
if (!wbsTreeContractList.isEmpty()) {
|
|
|
String pKeyIdStr = 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 (" + pKeyIdStr + ")",
|