Browse Source

fix: TooManyResults

李学松 2 years ago
parent
commit
13c8106e01

+ 17 - 14
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmReportServiceImpl.java

@@ -812,24 +812,27 @@ public class WmReportServiceImpl extends ServiceImpl<WmReportMapper, WmReport> i
 		}
 
 			// 查询上级的deptId
-			SysDeptRelation ancestorDeptRelation = sysDeptRelationMapper.selectOne(Wrappers.<SysDeptRelation>lambdaQuery()
+			List<SysDeptRelation> ancestorDeptRelations = sysDeptRelationMapper.selectList(Wrappers.<SysDeptRelation>lambdaQuery()
 					.eq(SysDeptRelation::getDescendant, deptId)
 					.ne(SysDeptRelation::getAncestor, deptId)
 					.ne(SysDeptRelation::getAncestor, 1));
-			// 上级dept对应任务类型配置
-			List<WmDeptTaskTypeConfigJsonDTO> filterAncestorConfigList = null;
-			if (ancestorDeptRelation != null) {
-				WmDeptTaskTypeConfig ancestorDeptTaskTypeConfig = wmDeptTaskTypeConfigService.getOne(Wrappers.<WmDeptTaskTypeConfig>lambdaQuery()
-						.eq(WmDeptTaskTypeConfig::getDeptId, ancestorDeptRelation.getAncestor()));
-				if (ancestorDeptTaskTypeConfig != null) {
-					List<WmDeptTaskTypeConfigJsonDTO> ancestorConfigJsonDTOList =
-							JSON.parseArray(ancestorDeptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
-					// 转换为key value形式
-					filterAncestorConfigList = ancestorConfigJsonDTOList.stream()
-							.filter(configJsonDTO -> configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower())
-							.collect(Collectors.toList());
+			List<WmDeptTaskTypeConfigJsonDTO> filterAncestorConfigList = new ArrayList<>();
+			ancestorDeptRelations.forEach(ancestorDeptRelation -> {
+				// 上级dept对应任务类型配置
+				if (ancestorDeptRelation != null) {
+					WmDeptTaskTypeConfig ancestorDeptTaskTypeConfig = wmDeptTaskTypeConfigService.getOne(Wrappers.<WmDeptTaskTypeConfig>lambdaQuery()
+							.eq(WmDeptTaskTypeConfig::getDeptId, ancestorDeptRelation.getAncestor()));
+					if (ancestorDeptTaskTypeConfig != null) {
+						List<WmDeptTaskTypeConfigJsonDTO> ancestorConfigJsonDTOList =
+								JSON.parseArray(ancestorDeptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
+						// 转换为key value形式
+						filterAncestorConfigList.addAll(ancestorConfigJsonDTOList.stream()
+								.filter(configJsonDTO -> configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower())
+								.collect(Collectors.toList()));
+					}
 				}
-			}
+			});
+
 			// 任务配置为空,则直接返回空page
 			if (CollectionUtil.isEmpty(filterConfigJsonDTOList) && CollectionUtil.isEmpty(filterAncestorConfigList)) {
 				log.warn("任务类型权限不存在");