|
@@ -59,6 +59,9 @@ import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.bean.NodeVO;
|
|
|
import org.springblade.manager.dto.*;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
+import org.springblade.manager.entity.cq.Attachment;
|
|
|
+import org.springblade.manager.entity.cq.QualityData;
|
|
|
+import org.springblade.manager.entity.cq.QualityDataFile;
|
|
|
import org.springblade.manager.excel.WbsExcelBatchUtil;
|
|
|
import org.springblade.manager.excel.WbsExcelUtil;
|
|
|
import org.springblade.manager.feign.ContractClient;
|
|
@@ -4588,101 +4591,101 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
executionTime.info("----查询开始----");
|
|
|
|
|
|
// 1. 查询符合条件的节点
|
|
|
- List<APIWbsContractSubdivisionVo> list = baseMapper.getWbsContractSubdivision(contractId);
|
|
|
+ List<APIWbsContractSubdivisionVo> list = baseMapper.getWbsContractSubdivision(contractId, null, 1);
|
|
|
if (CollectionUtil.isEmpty(list)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
|
|
|
// 2. 查询所有节点并构建快速查找结构
|
|
|
- List<WbsTreeContract> allContract = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
- .eq(WbsTreeContract::getContractId, contractId)
|
|
|
- .eq(WbsTreeContract::getType, 1)
|
|
|
- .isNotNull(WbsTreeContract::getAncestorsPId)
|
|
|
- .eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
+// List<WbsTreeContract> allContract = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
+// .eq(WbsTreeContract::getContractId, contractId)
|
|
|
+// .eq(WbsTreeContract::getType, 1)
|
|
|
+// .isNotNull(WbsTreeContract::getAncestorsPId)
|
|
|
+// .eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
|
|
|
// 构建祖先ID到节点列表的映射
|
|
|
- Map<Long, List<WbsTreeContract>> ancestorMap = new HashMap<>();
|
|
|
- for (WbsTreeContract node : allContract) {
|
|
|
- Arrays.stream(node.getAncestorsPId().split(","))
|
|
|
- .filter(StringUtils::isNotBlank)
|
|
|
- .map(Long::parseLong)
|
|
|
- .forEach(ancestorId -> {
|
|
|
- ancestorMap.computeIfAbsent(ancestorId, k -> new ArrayList<>()).add(node);
|
|
|
- });
|
|
|
- }
|
|
|
- executionTime.info("----构建节点映射完成----");
|
|
|
+// Map<Long, List<WbsTreeContract>> ancestorMap = new HashMap<>();
|
|
|
+// for (WbsTreeContract node : allContract) {
|
|
|
+// Arrays.stream(node.getAncestorsPId().split(","))
|
|
|
+// .filter(StringUtils::isNotBlank)
|
|
|
+// .map(Long::parseLong)
|
|
|
+// .forEach(ancestorId -> {
|
|
|
+// ancestorMap.computeIfAbsent(ancestorId, k -> new ArrayList<>()).add(node);
|
|
|
+// });
|
|
|
+// }
|
|
|
+// executionTime.info("----构建节点映射完成----");
|
|
|
|
|
|
// 3. 查询节点附件
|
|
|
- List<TableFile> nodeFiles = tableFileService.list(Wrappers.<TableFile>lambdaQuery()
|
|
|
- .eq(TableFile::getContractId, contractId)
|
|
|
- .in(TableFile::getType, FILE_TYPES)
|
|
|
- .eq(TableFile::getIsDeleted, 0));
|
|
|
-
|
|
|
- // 构建附件查找表 (tabId -> 类型集合)
|
|
|
- Map<Long, Set<Integer>> fileTypeMap = new HashMap<>();
|
|
|
- for (TableFile file : nodeFiles) {
|
|
|
- fileTypeMap.computeIfAbsent(Long.valueOf(file.getTabId()), k -> new HashSet<>())
|
|
|
- .add(file.getType());
|
|
|
- }
|
|
|
- executionTime.info("----构建附件映射完成----");
|
|
|
+// List<TableFile> nodeFiles = tableFileService.list(Wrappers.<TableFile>lambdaQuery()
|
|
|
+// .eq(TableFile::getContractId, contractId)
|
|
|
+// .in(TableFile::getType, FILE_TYPES)
|
|
|
+// .eq(TableFile::getIsDeleted, 0));
|
|
|
+//
|
|
|
+// // 构建附件查找表 (tabId -> 类型集合)
|
|
|
+// Map<Long, Set<Integer>> fileTypeMap = new HashMap<>();
|
|
|
+// for (TableFile file : nodeFiles) {
|
|
|
+// fileTypeMap.computeIfAbsent(Long.valueOf(file.getTabId()), k -> new HashSet<>())
|
|
|
+// .add(file.getType());
|
|
|
+// }
|
|
|
+// executionTime.info("----构建附件映射完成----");
|
|
|
|
|
|
// 4. 查询审批信息
|
|
|
- List<InformationQuery> oneQuery = informationQueryClient.getInformationByContractId(Long.valueOf(contractId), 1);
|
|
|
- Set<Long> oneQueryWbsIds = oneQuery.stream().map(InformationQuery::getWbsId).collect(Collectors.toSet());
|
|
|
-
|
|
|
- List<InformationQuery> twoQuery = informationQueryClient.getInformationByContractId(Long.valueOf(contractId), 2);
|
|
|
- Set<Long> twoQueryWbsIds = twoQuery.stream().map(InformationQuery::getWbsId).collect(Collectors.toSet());
|
|
|
-
|
|
|
- Set<Long> allQueryIds = new HashSet<>();
|
|
|
- allQueryIds.addAll(oneQueryWbsIds);
|
|
|
- allQueryIds.addAll(twoQueryWbsIds);
|
|
|
- executionTime.info("----获取审批信息完成----");
|
|
|
-
|
|
|
+// List<InformationQuery> oneQuery = informationQueryClient.getInformationByContractId(Long.valueOf(contractId), 1);
|
|
|
+// Set<Long> oneQueryWbsIds = oneQuery.stream().map(InformationQuery::getWbsId).collect(Collectors.toSet());
|
|
|
+//
|
|
|
+// List<InformationQuery> twoQuery = informationQueryClient.getInformationByContractId(Long.valueOf(contractId), 2);
|
|
|
+// Set<Long> twoQueryWbsIds = twoQuery.stream().map(InformationQuery::getWbsId).collect(Collectors.toSet());
|
|
|
+//
|
|
|
+// Set<Long> allQueryIds = new HashSet<>();
|
|
|
+// allQueryIds.addAll(oneQueryWbsIds);
|
|
|
+// allQueryIds.addAll(twoQueryWbsIds);
|
|
|
+// executionTime.info("----获取审批信息完成----");
|
|
|
+//
|
|
|
// 5. 处理每个节点
|
|
|
- for (APIWbsContractSubdivisionVo vo : list) {
|
|
|
- // 6. 从映射中直接获取子节点
|
|
|
- List<WbsTreeContract> children = ancestorMap.getOrDefault(vo.getId(), Collections.emptyList());
|
|
|
- if (CollectionUtil.isEmpty(children)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 7. 数据匹配处理
|
|
|
- Set<Long> childrenIds = children.stream()
|
|
|
- .map(WbsTreeContract::getPKeyId)
|
|
|
- .collect(Collectors.toSet());
|
|
|
-
|
|
|
- // 交工证书判断
|
|
|
- List<Long> completionCertificate = children.stream()
|
|
|
- .filter(node -> node.getMajorDataType() != null && node.getMajorDataType() == 3)
|
|
|
- .map(WbsTreeContract::getPKeyId)
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (CollectionUtil.isNotEmpty(completionCertificate)) {
|
|
|
- vo.setCompletionCertificate(allQueryIds.containsAll(completionCertificate));
|
|
|
- }
|
|
|
-
|
|
|
- // 附件报告判断
|
|
|
- vo.setStrengthReportSeven(childrenIds.stream().anyMatch(id ->
|
|
|
- fileTypeMap.getOrDefault(id, Collections.emptySet()).contains(11)));
|
|
|
- vo.setStrengthReportTwentyEight(childrenIds.stream().anyMatch(id ->
|
|
|
- fileTypeMap.getOrDefault(id, Collections.emptySet()).contains(12)));
|
|
|
- vo.setPileInspectionReport(childrenIds.stream().anyMatch(id ->
|
|
|
- fileTypeMap.getOrDefault(id, Collections.emptySet()).contains(13)));
|
|
|
-
|
|
|
- // 评定资料判断
|
|
|
- List<Long> evaluationNodes = children.stream()
|
|
|
- .filter(node -> node.getMajorDataType() != null && node.getMajorDataType() == 2)
|
|
|
- .map(WbsTreeContract::getPKeyId)
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (CollectionUtil.isNotEmpty(evaluationNodes)) {
|
|
|
- vo.setEvaluationData(allQueryIds.containsAll(evaluationNodes));
|
|
|
- }
|
|
|
-
|
|
|
- // 施工收监报告
|
|
|
- processApprovalData(vo, children, SG_SET, oneQueryWbsIds, "qualityInspectionData");
|
|
|
-
|
|
|
- // 监理收监报告
|
|
|
- processApprovalData(vo, children, JL_SET, twoQueryWbsIds, "supervisionData");
|
|
|
- }
|
|
|
+// for (APIWbsContractSubdivisionVo vo : list) {
|
|
|
+// // 6. 从映射中直接获取子节点
|
|
|
+// List<WbsTreeContract> children = ancestorMap.getOrDefault(vo.getId(), Collections.emptyList());
|
|
|
+// if (CollectionUtil.isEmpty(children)) {
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 7. 数据匹配处理
|
|
|
+// Set<Long> childrenIds = children.stream()
|
|
|
+// .map(WbsTreeContract::getPKeyId)
|
|
|
+// .collect(Collectors.toSet());
|
|
|
+//
|
|
|
+// // 交工证书判断
|
|
|
+// List<Long> completionCertificate = children.stream()
|
|
|
+// .filter(node -> node.getMajorDataType() != null && node.getMajorDataType() == 3)
|
|
|
+// .map(WbsTreeContract::getPKeyId)
|
|
|
+// .collect(Collectors.toList());
|
|
|
+// if (CollectionUtil.isNotEmpty(completionCertificate)) {
|
|
|
+// vo.setCompletionCertificate(allQueryIds.containsAll(completionCertificate));
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 附件报告判断
|
|
|
+// vo.setStrengthReportSeven(childrenIds.stream().anyMatch(id ->
|
|
|
+// fileTypeMap.getOrDefault(id, Collections.emptySet()).contains(11)));
|
|
|
+// vo.setStrengthReportTwentyEight(childrenIds.stream().anyMatch(id ->
|
|
|
+// fileTypeMap.getOrDefault(id, Collections.emptySet()).contains(12)));
|
|
|
+// vo.setPileInspectionReport(childrenIds.stream().anyMatch(id ->
|
|
|
+// fileTypeMap.getOrDefault(id, Collections.emptySet()).contains(13)));
|
|
|
+//
|
|
|
+// // 评定资料判断
|
|
|
+// List<Long> evaluationNodes = children.stream()
|
|
|
+// .filter(node -> node.getMajorDataType() != null && node.getMajorDataType() == 2)
|
|
|
+// .map(WbsTreeContract::getPKeyId)
|
|
|
+// .collect(Collectors.toList());
|
|
|
+// if (CollectionUtil.isNotEmpty(evaluationNodes)) {
|
|
|
+// vo.setEvaluationData(allQueryIds.containsAll(evaluationNodes));
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 施工收监报告
|
|
|
+// processApprovalData(vo, children, SG_SET, oneQueryWbsIds, "qualityInspectionData");
|
|
|
+//
|
|
|
+// // 监理收监报告
|
|
|
+// processApprovalData(vo, children, JL_SET, twoQueryWbsIds, "supervisionData");
|
|
|
+// }
|
|
|
|
|
|
executionTime.info("----组装完成----");
|
|
|
executionTime.brief();
|
|
@@ -5733,7 +5736,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
|
|
|
// 抽取公共处理逻辑
|
|
|
- private void processApprovalData(APIWbsContractSubdivisionVo vo,
|
|
|
+ private void processApprovalData(APIWbsContractSubdivisionExpandVo vo,
|
|
|
List<WbsTreeContract> children,
|
|
|
Set<Integer> ownerSet,
|
|
|
Set<Long> approvalIds,
|
|
@@ -5771,4 +5774,314 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
return baseMapper.selectList(eq);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getWbsContractSubdivisionMeasurable(String projectId, String contractId, String pid, Boolean judgment) {
|
|
|
+ // 1. 静态数组转为静态常量
|
|
|
+ final Set<Integer> SG_SET = Collections.unmodifiableSet(
|
|
|
+ new HashSet<>(Arrays.asList(1, 2, 3))
|
|
|
+ );
|
|
|
+ final Set<Integer> JL_SET = Collections.unmodifiableSet(
|
|
|
+ new HashSet<>(Arrays.asList(4,5,6))
|
|
|
+ );
|
|
|
+ final Set<Integer> FILE_TYPES = Collections.unmodifiableSet(
|
|
|
+ new HashSet<>(Arrays.asList(11, 12, 13))
|
|
|
+ );
|
|
|
+ ExecutionTime executionTime = new ExecutionTime();
|
|
|
+ executionTime.info("----查询开始----");
|
|
|
+
|
|
|
+ // 1. 查询符合条件的节点
|
|
|
+ List<APIWbsContractSubdivisionVo> list1 = baseMapper.getWbsContractSubdivision(contractId, pid, 1);
|
|
|
+
|
|
|
+ List<APIWbsContractSubdivisionExpandVo> list = BeanUtil.copyProperties(list1, APIWbsContractSubdivisionExpandVo.class);
|
|
|
+
|
|
|
+
|
|
|
+ if (CollectionUtil.isEmpty(list)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 2. 查询所有节点并构建快速查找结构
|
|
|
+ List<WbsTreeContract> allContract = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
+ .eq(WbsTreeContract::getContractId, contractId)
|
|
|
+ .eq(WbsTreeContract::getType, 1)
|
|
|
+ .isNotNull(WbsTreeContract::getAncestorsPId)
|
|
|
+ .eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
+
|
|
|
+ // 构建祖先ID到节点列表的映射
|
|
|
+ Map<Long, List<WbsTreeContract>> ancestorMap = new HashMap<>();
|
|
|
+ for (WbsTreeContract node : allContract) {
|
|
|
+ Arrays.stream(node.getAncestorsPId().split(","))
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .map(Long::parseLong)
|
|
|
+ .forEach(ancestorId -> {
|
|
|
+ ancestorMap.computeIfAbsent(ancestorId, k -> new ArrayList<>()).add(node);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ executionTime.info("----构建节点映射完成----");
|
|
|
+
|
|
|
+ // 3. 查询节点附件
|
|
|
+ List<TableFile> nodeFiles = tableFileService.list(Wrappers.<TableFile>lambdaQuery()
|
|
|
+ .eq(TableFile::getContractId, contractId)
|
|
|
+ .in(TableFile::getType, FILE_TYPES)
|
|
|
+ .eq(TableFile::getIsDeleted, 0));
|
|
|
+
|
|
|
+ // 构建附件查找表 (tabId -> 类型集合)
|
|
|
+ Map<Long, Set<Integer>> fileTypeMap = new HashMap<>();
|
|
|
+ for (TableFile file : nodeFiles) {
|
|
|
+ fileTypeMap.computeIfAbsent(Long.valueOf(file.getTabId()), k -> new HashSet<>())
|
|
|
+ .add(file.getType());
|
|
|
+ }
|
|
|
+ executionTime.info("----构建附件映射完成----");
|
|
|
+
|
|
|
+ // 4. 查询审批信息
|
|
|
+ List<InformationQuery> oneQuery = informationQueryClient.getInformationByContractId(Long.valueOf(contractId), 1);
|
|
|
+ Set<Long> oneQueryWbsIds = oneQuery.stream().map(InformationQuery::getWbsId).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ List<InformationQuery> twoQuery = informationQueryClient.getInformationByContractId(Long.valueOf(contractId), 2);
|
|
|
+ Set<Long> twoQueryWbsIds = twoQuery.stream().map(InformationQuery::getWbsId).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ Set<Long> allQueryIds = new HashSet<>();
|
|
|
+ allQueryIds.addAll(oneQueryWbsIds);
|
|
|
+ allQueryIds.addAll(twoQueryWbsIds);
|
|
|
+ executionTime.info("----获取审批信息完成----");
|
|
|
+ // 5. 处理每个节点
|
|
|
+ for (APIWbsContractSubdivisionExpandVo vo : list) {
|
|
|
+ // 6. 从映射中直接获取子节点
|
|
|
+ List<WbsTreeContract> children = ancestorMap.getOrDefault(vo.getId(), Collections.emptyList());
|
|
|
+ if (CollectionUtil.isEmpty(children)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 7. 数据匹配处理
|
|
|
+ Set<Long> childrenIds = children.stream()
|
|
|
+ .map(WbsTreeContract::getPKeyId)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ // 交工证书判断
|
|
|
+ List<Long> completionCertificate = children.stream()
|
|
|
+ .filter(node -> node.getMajorDataType() != null && node.getMajorDataType() == 3)
|
|
|
+ .map(WbsTreeContract::getPKeyId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(completionCertificate)) {
|
|
|
+ vo.setCompletionCertificate(allQueryIds.containsAll(completionCertificate));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 附件报告判断
|
|
|
+ vo.setStrengthReportSeven(childrenIds.stream().anyMatch(id ->
|
|
|
+ fileTypeMap.getOrDefault(id, Collections.emptySet()).contains(11)));
|
|
|
+ vo.setStrengthReportTwentyEight(childrenIds.stream().anyMatch(id ->
|
|
|
+ fileTypeMap.getOrDefault(id, Collections.emptySet()).contains(12)));
|
|
|
+ vo.setPileInspectionReport(childrenIds.stream().anyMatch(id ->
|
|
|
+ fileTypeMap.getOrDefault(id, Collections.emptySet()).contains(13)));
|
|
|
+ // 评定资料判断
|
|
|
+ List<Long> evaluationNodes = children.stream()
|
|
|
+ .filter(node -> node.getMajorDataType() != null && node.getMajorDataType() == 2)
|
|
|
+ .map(WbsTreeContract::getPKeyId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(evaluationNodes)) {
|
|
|
+ vo.setEvaluationData(allQueryIds.containsAll(evaluationNodes));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 施工收监报告
|
|
|
+ processApprovalData(vo, children, SG_SET, oneQueryWbsIds, "qualityInspectionData");
|
|
|
+
|
|
|
+ // 监理收监报告
|
|
|
+ processApprovalData(vo, children, JL_SET, twoQueryWbsIds, "supervisionData");
|
|
|
+
|
|
|
+ }
|
|
|
+ executionTime.info("----组装完成----");
|
|
|
+ executionTime.brief();
|
|
|
+ if(judgment){
|
|
|
+ return list.stream().filter(f -> f.getCompletionCertificate() || f.getStrengthReportSeven() || f.getStrengthReportTwentyEight()).collect(Collectors.toList());
|
|
|
+ }else{
|
|
|
+ List<String> collect = list.stream().filter(f -> !f.getCompletionCertificate() && !f.getStrengthReportSeven() && !f.getStrengthReportTwentyEight()).map(APIWbsContractSubdivisionExpandVo::getId).map(String::valueOf).collect(Collectors.toList());
|
|
|
+ //若返回合同段ID,则表示该合同段都不允许计量
|
|
|
+ if(collect.size() == list.size()){
|
|
|
+ collect.clear();
|
|
|
+ collect.add(contractId);
|
|
|
+ }
|
|
|
+ return collect;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<QualityData> qualityDataAcquisition(String projectId, String contractId, String codesId) {
|
|
|
+ final Set<Integer> NODE_TYPES = Collections.unmodifiableSet(
|
|
|
+ new HashSet<>(Arrays.asList(2, 8, 9))
|
|
|
+ );
|
|
|
+ //所有表单父级id
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
+ ArrayList<QualityData> qualityDatas = new ArrayList<>();
|
|
|
+
|
|
|
+ //1、根据codesId 获取所有子级节点的表单
|
|
|
+ List<String> pIds = Arrays.asList(codesId.split(","));
|
|
|
+ // 1. 查询符合条件的节点
|
|
|
+ pIds.forEach(pId -> {
|
|
|
+ List<APIWbsContractSubdivisionVo> list = baseMapper.getWbsContractSubdivision(contractId, pId, 2);
|
|
|
+ if(CollectionUtil.isNotEmpty(list)){
|
|
|
+ ids.addAll(list.stream().map(APIWbsContractSubdivisionVo::getPid).collect(Collectors.toSet()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //查询所有有pdf的资料
|
|
|
+ List<InformationQuery> oneQuery = informationQueryClient.getInformationByContractIdAll(Long.valueOf(contractId));
|
|
|
+ if(CollectionUtil.isEmpty(oneQuery)){
|
|
|
+ oneQuery = new ArrayList<>();
|
|
|
+ }
|
|
|
+ //根据wbs分组
|
|
|
+ Map<Long, List<InformationQuery>> collect = oneQuery.stream().filter(f -> StringUtils.isNotBlank(f.getPdfUrl())).collect(Collectors.groupingBy(InformationQuery::getWbsId));
|
|
|
+ //查询当前合同下所有附件资料
|
|
|
+ List<TableFile> list = tableFileService.list(Wrappers.<TableFile>lambdaQuery().eq(TableFile::getContractId, Long.valueOf(contractId)));
|
|
|
+ Map<String, List<TableFile>> collect1 = list.stream().collect(Collectors.groupingBy(TableFile::getTabId));
|
|
|
+
|
|
|
+
|
|
|
+ //查询所有父节点
|
|
|
+ List<WbsTreeContract> list1 = wbsTreeContractMapper.selectBatchIds(ids);
|
|
|
+ list1 = list1.stream().sorted(Comparator.comparing(WbsTreeContract::getSort)).collect(Collectors.toList());
|
|
|
+ //排序
|
|
|
+ list1.sort(this::compareAncestors);
|
|
|
+
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
+ WbsTreeContract wbsTreeContract = list1.get(i);
|
|
|
+ Long f = wbsTreeContract.getPKeyId();
|
|
|
+ QualityData qualityData = new QualityData();
|
|
|
+
|
|
|
+ List<InformationQuery> informationQueries = collect.get(f);
|
|
|
+ if(CollectionUtil.isNotEmpty(informationQueries)){
|
|
|
+ String type = "99";
|
|
|
+ String typename;
|
|
|
+ if(wbsTreeContract.getMajorDataType() == 1){
|
|
|
+ type = "1";
|
|
|
+ typename = "开工报告";
|
|
|
+ }else if(NODE_TYPES.contains(wbsTreeContract.getMajorDataType())){
|
|
|
+ type = "4";
|
|
|
+ typename = "评定报告及表格对应的附件";
|
|
|
+ }else if(wbsTreeContract.getMajorDataType() == 4){
|
|
|
+ if(informationQueries.size() == 2){
|
|
|
+ type = "2,3";
|
|
|
+ typename = "工序资料、监理抽检资料";
|
|
|
+ }else{
|
|
|
+ if(informationQueries.get(0).getClassify() == 1){
|
|
|
+ type = "2";
|
|
|
+ typename = "工序资料";
|
|
|
+ }else{
|
|
|
+ type = "3";
|
|
|
+ typename = "监理抽检资料";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ typename = "其他";
|
|
|
+ }
|
|
|
+ //当前节点下的附件
|
|
|
+ List<TableFile> tableFiles = collect1.get(f.toString());
|
|
|
+ //根据类型分组
|
|
|
+ Map<Integer, List<TableFile>> collect2;
|
|
|
+ if(CollectionUtil.isNotEmpty(tableFiles)){
|
|
|
+ //根据类型分组
|
|
|
+ collect2 = tableFiles.stream().collect(Collectors.groupingBy(TableFile::getClassify));
|
|
|
+ } else {
|
|
|
+ collect2 = null;
|
|
|
+ }
|
|
|
+ //封装数据
|
|
|
+ qualityData.setType(type);
|
|
|
+ qualityData.setTypename(typename);
|
|
|
+ qualityData.setTypeOrder(i + 1);
|
|
|
+
|
|
|
+ ArrayList<QualityDataFile> qualityDataFiles = new ArrayList<>();
|
|
|
+ //封装文件
|
|
|
+ informationQueries.forEach(f1 -> {
|
|
|
+ QualityDataFile file = new QualityDataFile();
|
|
|
+ file.setName(f1.getName());
|
|
|
+ if(f1.getClassify() == 1) {
|
|
|
+ file.setTypeName("工序资料");
|
|
|
+ } else {
|
|
|
+ file.setTypeName("监理抽检资料");
|
|
|
+ }
|
|
|
+ file.setOrder(String.valueOf(f1.getSort()));
|
|
|
+ file.setUrl(f1.getPdfUrl());
|
|
|
+
|
|
|
+ //封装附件
|
|
|
+ if(collect2 != null){
|
|
|
+ List<TableFile> tableFiles1 = collect2.get(f1.getClassify());
|
|
|
+ if(CollectionUtil.isNotEmpty(tableFiles1)){
|
|
|
+ List<Attachment> attachmentArrList = new ArrayList<Attachment>();
|
|
|
+ tableFiles1.forEach(f2 -> {
|
|
|
+ Attachment attachment = new Attachment();
|
|
|
+ attachment.setName(f2.getName());
|
|
|
+ attachment.setOrder(String.valueOf(f2.getSort()));
|
|
|
+ attachment.setUrl(f2.getDomainPdfUrl());
|
|
|
+ attachmentArrList.add(attachment);
|
|
|
+ });
|
|
|
+ file.setAttachments(attachmentArrList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ qualityDataFiles.add(file);
|
|
|
+ });
|
|
|
+ qualityData.setFiles(qualityDataFiles);
|
|
|
+ qualityDatas.add(qualityData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //3、根据id获取query表中资料文件
|
|
|
+ return qualityDatas;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 比较两个祖级路径
|
|
|
+ */
|
|
|
+ private int compareAncestors(WbsTreeContract obj1, WbsTreeContract obj2) {
|
|
|
+ String ancestors1 = obj1.getAncestorsPId();
|
|
|
+ String ancestors2 = obj2.getAncestorsPId();
|
|
|
+ if (ancestors1 == null && ancestors2 == null) return 0;
|
|
|
+ if (ancestors1 == null) return -1;
|
|
|
+ if (ancestors2 == null) return 1;
|
|
|
+
|
|
|
+ String[] arr1 = ancestors1.split(",");
|
|
|
+ String[] arr2 = ancestors2.split(",");
|
|
|
+
|
|
|
+ int minLength = Math.min(arr1.length, arr2.length);
|
|
|
+
|
|
|
+ // 比较相同索引的ID
|
|
|
+ for (int i = 0; i < minLength; i++) {
|
|
|
+ String id1 = arr1[i].trim();
|
|
|
+ String id2 = arr2[i].trim();
|
|
|
+
|
|
|
+ if (!id1.equals(id2)) {
|
|
|
+ // 查询数据库获取排序值
|
|
|
+ Integer sort1 = wbsTreeContractMapper.selectById(id1).getSort();
|
|
|
+ Integer sort2 = wbsTreeContractMapper.selectById(id2).getSort();
|
|
|
+
|
|
|
+ // 比较排序值
|
|
|
+ if (sort1 != null && sort2 != null) {
|
|
|
+ return Integer.compare(sort1, sort2);
|
|
|
+ } else if (sort1 != null) {
|
|
|
+ return -1;
|
|
|
+ } else if (sort2 != null) {
|
|
|
+ return 1;
|
|
|
+ } else {
|
|
|
+ return id1.compareTo(id2); // 降级方案
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果共同部分都相同,说明是同级节点
|
|
|
+ if (arr1.length == arr2.length) {
|
|
|
+ Integer sort1 = obj1.getSort();
|
|
|
+ Integer sort2 = obj2.getSort();
|
|
|
+ if (sort1 != null && sort2 != null) {
|
|
|
+ return Integer.compare(sort1, sort2);
|
|
|
+ } else if (sort1 != null) {
|
|
|
+ return -1;
|
|
|
+ } else if (sort2 != null) {
|
|
|
+ return 1;
|
|
|
+ } else {
|
|
|
+ return 0; // 都没有排序值,保持原顺序
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果共同部分都相同,长度短的排在前面(父级在子级前面)
|
|
|
+ return Integer.compare(arr1.length, arr2.length);
|
|
|
+ }
|
|
|
}
|