فهرست منبع

fix: toomanyresults

李学松 2 سال پیش
والد
کامیت
6ded1f79e2

+ 17 - 14
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/WmDeptTaskTypeConfigController.java

@@ -1,5 +1,6 @@
 package com.qunzhixinxi.hnqz.admin.controller;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ArrayUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -93,24 +94,26 @@ public class WmDeptTaskTypeConfigController {
 			});
 		}
 		// 查询上级的deptId
-		SysDeptRelation ancestorDeptRelation = sysDeptRelationService.getOne(Wrappers.<SysDeptRelation>lambdaQuery()
+		List<SysDeptRelation> relationList = sysDeptRelationService.list(Wrappers.<SysDeptRelation>lambdaQuery()
 				.eq(SysDeptRelation::getDescendant, deptId)
 				.ne(SysDeptRelation::getAncestor, deptId)
 				.ne(SysDeptRelation::getAncestor, 1));
 		// 上级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);
-				ancestorConfigJsonDTOList.stream()
-						.forEach(configJsonDTO -> {
-							if (configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower()) {
-								configed.set(true);
-							}
-						});
-			}
+		if (CollUtil.isNotEmpty(relationList)) {
+			relationList.forEach(relation ->  {
+				WmDeptTaskTypeConfig ancestorDeptTaskTypeConfig = wmDeptTaskTypeConfigService.getOne(Wrappers.<WmDeptTaskTypeConfig>lambdaQuery()
+						.eq(WmDeptTaskTypeConfig::getDeptId, relation.getAncestor()));
+				if (ancestorDeptTaskTypeConfig != null) {
+					List<WmDeptTaskTypeConfigJsonDTO> ancestorConfigJsonDTOList =
+							JSON.parseArray(ancestorDeptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
+					ancestorConfigJsonDTOList
+							.forEach(configJsonDTO -> {
+								if (configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower()) {
+									configed.set(true);
+								}
+							});
+				}
+			});
 		}
 		resultMap.put("config", configed.get());
 		return R.ok(resultMap);

+ 48 - 34
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmDeptTaskTypeConfigServiceImpl.java

@@ -1,6 +1,7 @@
 package com.qunzhixinxi.hnqz.admin.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.ArrayUtil;
@@ -342,22 +343,27 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 					.collect(Collectors.toList());
 		}
 		// 查询上级
-		SysDeptRelation ancestorDeptRelation = sysDeptRelationMapper.selectOne(Wrappers.<SysDeptRelation>lambdaQuery()
+		List<SysDeptRelation> relationList = sysDeptRelationMapper.selectList(Wrappers.<SysDeptRelation>lambdaQuery()
 				.eq(SysDeptRelation::getDescendant, deptId)
 				.ne(SysDeptRelation::getAncestor, deptId)
 				.ne(SysDeptRelation::getAncestor, 1));
-		List<String> ancestorConfigTaskTypeIdList = null;
-		if (ancestorDeptRelation != null) {
-			// 上级企业配置
-			WmDeptTaskTypeConfig ancestorDeptTaskTypeConfig = this.getOne(Wrappers.<WmDeptTaskTypeConfig>lambdaQuery()
-					.eq(WmDeptTaskTypeConfig::getDeptId, ancestorDeptRelation.getAncestor()));
-			if (ancestorDeptTaskTypeConfig != null) {
-				List<WmDeptTaskTypeConfigJsonDTO> ancestorConfigJsonDTOList = JSON.parseArray(ancestorDeptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
-				ancestorConfigTaskTypeIdList = ancestorConfigJsonDTOList.stream()
-						.filter(configJsonDTO -> configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower())
-						.map(WmDeptTaskTypeConfigJsonDTO::getTaskTypeName)
-						.collect(Collectors.toList());
-			}
+		List<String> ancestorConfigTaskTypeIdList = new ArrayList<>();
+		if (CollUtil.isNotEmpty(relationList)) {
+			relationList.forEach(relation -> {
+				// 上级企业配置
+				WmDeptTaskTypeConfig ancestorDeptTaskTypeConfig = this.getOne(Wrappers.<WmDeptTaskTypeConfig>lambdaQuery()
+						.eq(WmDeptTaskTypeConfig::getDeptId, relation.getAncestor()));
+				if (ancestorDeptTaskTypeConfig != null) {
+					List<WmDeptTaskTypeConfigJsonDTO> ancestorConfigJsonDTOList = JSON.parseArray(ancestorDeptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
+					List<String> collect = ancestorConfigJsonDTOList.stream()
+							.filter(configJsonDTO -> configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower())
+							.map(WmDeptTaskTypeConfigJsonDTO::getTaskTypeName)
+							.collect(Collectors.toList());
+					if (CollUtil.isNotEmpty(collect)) {
+						ancestorConfigTaskTypeIdList.addAll(collect);
+					}
+				}
+			});
 		}
 		if (CollectionUtil.isEmpty(configTaskTypeIdList) && CollectionUtil.isEmpty(ancestorConfigTaskTypeIdList)) {
 			return new ArrayList<>();
@@ -447,32 +453,40 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 		}
 
 		// 查询上级的deptId
-		SysDeptRelation ancestorDeptRelation = sysDeptRelationMapper.selectOne(Wrappers.<SysDeptRelation>lambdaQuery()
+		List<SysDeptRelation> relationList = 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 = this.getOne(Wrappers.<WmDeptTaskTypeConfig>lambdaQuery()
-					.eq(WmDeptTaskTypeConfig::getDeptId, ancestorDeptRelation.getAncestor()));
-			if (ancestorDeptTaskTypeConfig != null) {
-				List<WmDeptTaskTypeConfigJsonDTO> ancestorConfigJsonDTOList =
-						JSON.parseArray(ancestorDeptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
-				// 转换为key value形式
-				if (StringUtils.isNotBlank(taskTypeName)) {
-					filterAncestorConfigList = ancestorConfigJsonDTOList.stream()
-							.filter(configJsonDTO -> configJsonDTO.getTaskTypeName().equals(taskTypeName)
-									&& configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower()
-									&& (configJsonDTO.getYydbStatusSelect() || configJsonDTO.getZbdbStatusSelect()))
-							.collect(Collectors.toList());
-				} else {
-					filterAncestorConfigList = ancestorConfigJsonDTOList.stream()
-							.filter(configJsonDTO -> configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower()
-									&& (configJsonDTO.getYydbStatusSelect() || configJsonDTO.getZbdbStatusSelect()))
-							.collect(Collectors.toList());
+		List<WmDeptTaskTypeConfigJsonDTO> filterAncestorConfigList = new ArrayList<>();
+		if (CollUtil.isNotEmpty(relationList)) {
+			relationList.forEach(relation -> {
+				WmDeptTaskTypeConfig ancestorDeptTaskTypeConfig = this.getOne(Wrappers.<WmDeptTaskTypeConfig>lambdaQuery()
+						.eq(WmDeptTaskTypeConfig::getDeptId, relation.getAncestor()));
+				if (ancestorDeptTaskTypeConfig != null) {
+					List<WmDeptTaskTypeConfigJsonDTO> ancestorConfigJsonDTOList =
+							JSON.parseArray(ancestorDeptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
+					// 转换为key value形式
+					if (StringUtils.isNotBlank(taskTypeName)) {
+						List<WmDeptTaskTypeConfigJsonDTO> collect = ancestorConfigJsonDTOList.stream()
+								.filter(configJsonDTO -> configJsonDTO.getTaskTypeName().equals(taskTypeName)
+										&& configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower()
+										&& (configJsonDTO.getYydbStatusSelect() || configJsonDTO.getZbdbStatusSelect()))
+								.collect(Collectors.toList());
+						if (CollUtil.isNotEmpty(collect)) {
+							filterAncestorConfigList.addAll(collect);
+						}
+					} else {
+						List<WmDeptTaskTypeConfigJsonDTO> collect = ancestorConfigJsonDTOList.stream()
+								.filter(configJsonDTO -> configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower()
+										&& (configJsonDTO.getYydbStatusSelect() || configJsonDTO.getZbdbStatusSelect()))
+								.collect(Collectors.toList());
+						if (CollUtil.isNotEmpty(collect)) {
+							filterAncestorConfigList.addAll(collect);
+						}
+					}
 				}
-			}
+			});
 		}
 		// 任务配置为空,则直接返回空page
 		if (CollectionUtil.isEmpty(filterConfigJsonDTOList) && CollectionUtil.isEmpty(filterAncestorConfigList)) {