|
@@ -1687,4 +1687,96 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R<Object> getCollectTreeNodeByQuery(String contractId, String tableOwner, Long folderId, String queryValue) {
|
|
|
+ if (StringUtils.isEmpty(contractId)) {
|
|
|
+ return R.fail(200, "合同段id错误");
|
|
|
+ }
|
|
|
+ if (folderId == null || folderId <= 0) {
|
|
|
+ return R.fail(200, "收藏夹不存在");
|
|
|
+ }
|
|
|
+ ContractInfo contractInfo = this.selectById(contractId);
|
|
|
+ if (contractInfo == null) {
|
|
|
+ return R.fail(200, "合同段不存在");
|
|
|
+ }
|
|
|
+ Set<String> syncPKeyIds = getSyncFlagIds(contractId, tableOwner);
|
|
|
+ List<ContractCollectFolder> contractCollectNodes = jdbcTemplate.query("select node_id, node_ancestors 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 and full_name like '%" + queryValue + "%')",
|
|
|
+ new BeanPropertyRowMapper<>(ContractCollectFolder.class));
|
|
|
+ if (!contractCollectNodes.isEmpty()) {
|
|
|
+ Set<Long> pKeyIds = new LinkedHashSet<>();
|
|
|
+ Map<Long, String> collectMap = new HashMap<>();
|
|
|
+ for (ContractCollectFolder node : contractCollectNodes) {
|
|
|
+ String ancestors = node.getNodeAncestors();
|
|
|
+ if (ancestors != null) {
|
|
|
+ String[] split = ancestors.split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ if (StringUtil.isNumeric(s)) {
|
|
|
+ pKeyIds.add(Long.parseLong(s));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ collectMap.put(node.getNodeId(), "");
|
|
|
+ pKeyIds.add(node.getNodeId());
|
|
|
+ }
|
|
|
+ List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, pKeyIds));
|
|
|
+ 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 + ")",
|
|
|
+ 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));
|
|
|
+ Map<Long, List<WbsTreeContractTreeAllVO>> resultMaps = new LinkedHashMap<>();
|
|
|
+ contractGroupMap.forEach((cId, list) -> {
|
|
|
+ List<WbsTreeContractTreeAllVO> wbsTreeContractTreeAllVOS = list.stream()
|
|
|
+ .map(node -> {
|
|
|
+ WbsTreeContractTreeAllVO vo = BeanUtil.copyProperties(node, WbsTreeContractTreeAllVO.class);
|
|
|
+ if (vo != null) {
|
|
|
+ vo.setContractIdRelation(node.getContractId());
|
|
|
+ vo.setType(ObjectUtils.isNotEmpty(node.getNodeType()) ? node.getNodeType() : 0);
|
|
|
+ vo.setTitle(ObjectUtil.isNotEmpty(node.getFullName()) ? node.getFullName() : node.getNodeName());
|
|
|
+ vo.setPrimaryKeyId(node.getPKeyId());
|
|
|
+ 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));
|
|
|
+ if (statistics.getLeafNum() > 0) {
|
|
|
+ vo.setHasChildren( true);
|
|
|
+ } else {
|
|
|
+ vo.setHasChildren(false);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ vo.setSubmitCounts(0L);
|
|
|
+ vo.setColorStatus(1);
|
|
|
+ vo.setHasChildren(false);
|
|
|
+ }
|
|
|
+ if(CollectionUtil.isNotEmpty(syncPKeyIds)){
|
|
|
+ //判断是否展示同步标识
|
|
|
+ vo.setIsSync(syncPKeyIds.contains(vo.getPrimaryKeyId().toString()) ? 1 : 0);
|
|
|
+ }
|
|
|
+ if (collectMap.containsKey(node.getPKeyId())) {
|
|
|
+ vo.setIsCollect(1);
|
|
|
+ } else {
|
|
|
+ vo.setIsCollect(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ List<WbsTreeContractTreeAllVO> resultList = this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS);
|
|
|
+ if (StringUtil.hasText(queryValue)) {
|
|
|
+ resultMaps.put(Long.parseLong(cId), this.queryTreeResult(resultList, queryValue));
|
|
|
+ } else {
|
|
|
+ resultMaps.put(Long.parseLong(cId), resultList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (contractInfo.getContractType() != null && contractInfo.getContractType() == 1) {
|
|
|
+ return R.data(resultMaps.get(contractInfo.getId()));
|
|
|
+ }
|
|
|
+ return R.data(resultMaps);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|