浏览代码

feat: 批量审批任务-查询我的任务

lixuesong 3 年之前
父节点
当前提交
b33c0a8c82

+ 16 - 12
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/WmTaskTypeController.java

@@ -20,10 +20,8 @@ package com.qunzhixinxi.hnqz.admin.controller;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.map.MapUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
 import com.qunzhixinxi.hnqz.admin.api.entity.SysDeptRelation;
 import com.qunzhixinxi.hnqz.admin.entity.WmDaAgent;
 import com.qunzhixinxi.hnqz.admin.entity.WmDaDrugEnt;
@@ -335,34 +333,40 @@ public class WmTaskTypeController {
 		taskTypeWrapper.eq(WmTaskType::getDeptId, deptId);
 		taskTypeWrapper.eq(WmTaskType::getDurgentId, wmDaDrugEnt.getId());
 		if (StringUtils.isNotBlank(taskTypeName)) {
-			taskTypeWrapper.eq(WmTaskType::getTaskTypeName, taskTypeName);
+			taskTypeWrapper.like(WmTaskType::getTaskTypeName, taskTypeName);
 		}
 		List<WmTaskType> taskTypeList = wmTaskTypeService.list(taskTypeWrapper);
 
-		Map<String, List<WmTaskType>> resultMap = new HashMap<>();
+		List<Map<String, Object>> resultList = new ArrayList<>();
 		if (CollectionUtil.isNotEmpty(taskTypeList)) {
 			// 查询基础任务类型,用于匹配任务类型大类
 			List<WmTaskType> baseTaskTypeList = wmTaskTypeService.list(Wrappers.<WmTaskType>lambdaQuery()
 					.eq(WmTaskType::getEnableFlag, EnableEnum.ENABLE.val())
 					.eq(WmTaskType::getTaskTypeLevel, "1"));
-			// 根据parentId去重,并转换为key-value格式
-			Map<String, String> baseTaskTypeMap = baseTaskTypeList
+			// 根据parentId去重
+			List<WmTaskType> baseTaskTypeFilterList = baseTaskTypeList
 					.stream()
 					.collect(
 							Collectors.collectingAndThen(
 									Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WmTaskType::getParentId))), ArrayList::new
 							)
-					)
-					.stream()
-					.collect(Collectors.toMap(WmTaskType::getParentId, WmTaskType::getBaseId));
+					);
 			// 转换为key是baseId,value是taskTypelist的列表map
 			Map<String, List<WmTaskType>> tempTaskTypeMap = taskTypeList.stream()
 					.filter(wmTaskType -> wmTaskType.getParentId() != null)
 					.collect(Collectors.groupingBy(WmTaskType::getParentId));
-			// 转换为key是taskTypeName,value是taskTypelist的列表map
-			baseTaskTypeMap.forEach((s, o) -> resultMap.put(o, tempTaskTypeMap.get(s)));
+			// 转换为list<map>
+			baseTaskTypeFilterList.forEach(taskType -> {
+				Map<String, Object> taskTypeMap = MapUtil.newHashMap(2);
+				List<WmTaskType> wmTaskTypes = tempTaskTypeMap.get(taskType.getParentId());
+				if (CollectionUtil.isNotEmpty(wmTaskTypes)) {
+					taskTypeMap.put("label", taskType.getTaskTypeName());
+					taskTypeMap.put("children", tempTaskTypeMap.get(taskType.getParentId()));
+					resultList.add(taskTypeMap);
+				}
+			});
 		}
 
-		return R.ok(resultMap);
+		return R.ok(resultList);
 	}
 }

+ 9 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/mapper/WmTaskMapper.java

@@ -110,6 +110,15 @@ public interface WmTaskMapper extends DataScopeMapper<WmTask> {
 
 	 IPage<WmTask> getWmTaskList(Page page, @Param("query") WmTask wmTask);
 
+	/**
+	 * 根据配置查询任务
+	 *
+	 * @param page
+	 * @param wmTask
+	 * @return
+	 */
+ 	IPage<WmTask> listWmTaskByConfig(Page<WmTask> page, @Param("query") WmTask wmTask);
+
 	List<Map<String,String>> PackageIsFinishByTask(@Param("query") WmTask wmTask);
 
 	Map<String, Timestamp> getMaxCreateTime(@Param("query") WmTask wmTask);

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

@@ -17,6 +17,7 @@ import com.qunzhixinxi.hnqz.admin.entity.WmTask;
 import com.qunzhixinxi.hnqz.admin.entity.WmTaskType;
 import com.qunzhixinxi.hnqz.admin.entity.dto.WmDeptTaskTypeConfigDTO;
 import com.qunzhixinxi.hnqz.admin.entity.dto.WmDeptTaskTypeConfigJsonDTO;
+import com.qunzhixinxi.hnqz.admin.enums.DelEnum;
 import com.qunzhixinxi.hnqz.admin.enums.EnableEnum;
 import com.qunzhixinxi.hnqz.admin.enums.PackageTypeEnum;
 import com.qunzhixinxi.hnqz.admin.enums.ScorePackageStatusEnum;
@@ -24,6 +25,7 @@ import com.qunzhixinxi.hnqz.admin.enums.TaskStatusEnum;
 import com.qunzhixinxi.hnqz.admin.mapper.SysDeptRelationMapper;
 import com.qunzhixinxi.hnqz.admin.mapper.WmDaDrugEntMapper;
 import com.qunzhixinxi.hnqz.admin.mapper.WmDeptTaskTypeConfigMapper;
+import com.qunzhixinxi.hnqz.admin.mapper.WmTaskMapper;
 import com.qunzhixinxi.hnqz.admin.service.WmDeptTaskTypeConfigService;
 import com.qunzhixinxi.hnqz.admin.service.WmScorePackageService;
 import com.qunzhixinxi.hnqz.admin.service.WmTaskService;
@@ -32,12 +34,15 @@ import com.qunzhixinxi.hnqz.common.core.util.R;
 import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -53,14 +58,14 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 
 	private final WmTaskTypeService wmTaskTypeService;
 
-	private final WmTaskService wmTaskService;
-
 	private final WmScorePackageService wmScorePackageService;
 
 	private final SysDeptRelationMapper sysDeptRelationMapper;
 
 	private final WmDaDrugEntMapper wmDaDrugEntMapper;
 
+	private final WmTaskMapper wmTaskMapper;
+
 	/**
 	 * 保存任务类型配置
 	 *
@@ -165,7 +170,7 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 	 * 根据企业的任务类型配置查询任务列表
 	 *
 	 * @param taskTypeName 任务类型名称
-	 * @param taskStatus 任务状态
+	 * @param taskStatus   任务状态
 	 * @return
 	 */
 	@Override
@@ -191,6 +196,7 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 			LambdaQueryWrapper<WmScorePackage> scorePackageWrapper = Wrappers.lambdaQuery();
 			scorePackageWrapper.eq(WmScorePackage::getSendPackageDeptId, deptId);
 			scorePackageWrapper.eq(WmScorePackage::getEnableFlag, EnableEnum.ENABLE.val());
+			scorePackageWrapper.eq(WmScorePackage::getDelFlag, DelEnum.NOT_DEL.val());
 			scorePackageWrapper.eq(WmScorePackage::getPackageType1, PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val());
 			scorePackageWrapper.eq(WmScorePackage::getPackageType2, PackageTypeEnum.TYPE2_TASK_PACKAGE.val());
 			scorePackageWrapper.ge(WmScorePackage::getScorePackageStatus, ScorePackageStatusEnum.IN_PROGRESS.val());
@@ -202,8 +208,13 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 				List<WmScorePackage> scorePackageList = wmScorePackageService.list(scorePackageWrapper);
 				if (CollectionUtil.isNotEmpty(scorePackageList)) {
 					// 遍历查找所有下级积分包
-					scorePackageList.forEach(scorePackage -> getAllLowerScorePackages(scorePackage.getId(), scorePackageList));
-					scorePackageIdList = scorePackageList.stream().map(WmScorePackage::getId).collect(Collectors.toList());
+					Set<String> ids = scorePackageList.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
+					getAllLowerScorePackages(ids, scorePackageList);
+
+					// 过滤只要发给个人的包
+					scorePackageIdList = scorePackageList.stream()
+							.filter(scorePackage -> StringUtils.isBlank(scorePackage.getAcceptSug()))
+							.map(WmScorePackage::getId).collect(Collectors.toList());
 				}
 			} else {
 				// 未勾选关联下级,则全部任务中只显示未关联积分包的任务,就是从企业直接下发给医药代表的任务 是未关联积分包吗?代理商可以有吧???
@@ -212,7 +223,10 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 						.apply("length(accept_sug) = 0"));
 				List<WmScorePackage> scorePackageList = wmScorePackageService.list(scorePackageWrapper);
 				if (CollectionUtil.isNotEmpty(scorePackageList)) {
-					scorePackageIdList = scorePackageList.stream().map(WmScorePackage::getId).collect(Collectors.toList());
+					scorePackageIdList = scorePackageList.stream()
+							// 过滤只要发给个人的包
+							.filter(scorePackage -> StringUtils.isBlank(scorePackage.getAcceptSug()))
+							.map(WmScorePackage::getId).collect(Collectors.toList());
 				}
 			}
 			// 用户类型
@@ -226,16 +240,12 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 
 			if (CollectionUtil.isNotEmpty(scorePackageIdList) && CollectionUtil.isNotEmpty(taskUserTypeList)) {
 				// 查询任务列表
-				LambdaQueryWrapper<WmTask> taskWrapper = Wrappers.lambdaQuery();
-				taskWrapper.eq(WmTask::getTaskTypeId, baseTaskType.getId());
-				taskWrapper.in(WmTask::getScorePackageId, scorePackageIdList);
-				taskWrapper.in(WmTask::getTaskUserType, taskUserTypeList);
-				if (ArrayUtil.isNotEmpty(taskStatus)) {
-					taskWrapper.in(WmTask::getTaskStatus, taskStatus);
-				} else {
-					taskWrapper.eq(WmTask::getTaskStatus, TaskStatusEnum.UNDER_REVIEW.val());
-				}
-				Page<WmTask> taskPage = wmTaskService.page(page, taskWrapper);
+				WmTask queryTask = new WmTask();
+				queryTask.setTaskTypeId(baseTaskType.getId());
+				queryTask.setScorePackageId(String.join(",", scorePackageIdList));
+				queryTask.setTaskUserType(String.join(",", taskUserTypeList));
+				queryTask.setTaskStatus(String.join(",", taskStatus));
+				IPage<WmTask> taskPage = wmTaskMapper.listWmTaskByConfig(page, queryTask);
 				return taskPage;
 			}
 		}
@@ -246,18 +256,18 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 	/**
 	 * 查询所有下级的积分包
 	 *
-	 * @param scorePackageId
-	 * @param scorePackageList
+	 * @param ids
+	 * @param res
 	 */
-	private void getAllLowerScorePackages(String scorePackageId, List<WmScorePackage> scorePackageList) {
-		if (scorePackageList.size() <= 999) {
-			List<WmScorePackage> subList = wmScorePackageService.list(Wrappers.<WmScorePackage>lambdaQuery()
-					.eq(WmScorePackage::getRelationScoreId, scorePackageId)
-					.eq(WmScorePackage::getEnableFlag, EnableEnum.ENABLE.val()));
-			if (CollectionUtil.isNotEmpty(subList)) {
-				scorePackageList.addAll(subList);
-				subList.forEach(scorePackage -> getAllLowerScorePackages(scorePackage.getId(), scorePackageList));
-			}
+	private void getAllLowerScorePackages(Set<String> ids, List<WmScorePackage> res) {
+		List<WmScorePackage> subList = wmScorePackageService.list(Wrappers.<WmScorePackage>lambdaQuery()
+				.in(WmScorePackage::getRelationScoreId, ids)
+				.eq(WmScorePackage::getEnableFlag, EnableEnum.ENABLE.val()));
+
+		if (CollectionUtil.isNotEmpty(subList)) {
+			Set<String> idSet = subList.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
+			res.addAll(subList);
+			getAllLowerScorePackages(idSet, res);
 		}
 	}
 }

+ 56 - 0
hnqz-upms/hnqz-upms-biz/src/main/resources/mapper/WmTaskMapper.xml

@@ -1002,6 +1002,62 @@
 
 	</select>
 
+	<!-- 根据配置查询任务 -->
+	<select id="listWmTaskByConfig" resultMap="wmTaskMap">
+		SELECT
+		t.id AS id,
+		t.task_rule_id AS task_rule_id,
+		t.score AS score,
+		p.score_package_name AS score_package_id,
+		t.task_type_id AS task_type_id,
+		t.lookinto_date AS lookinto_date,
+		t.province AS province,
+		t.city AS city,
+		t.area AS area,
+		t.address AS address,
+		t.lookinto_type_id AS lookinto_type_id,
+		t.task_content_id AS task_content_id,
+		t.task_status AS task_status,
+		u.realname AS task_user_id,
+		t.task_user_type AS task_user_type,
+		t.drug_ent_id AS drug_ent_id,
+		d.`name` AS dept_id,
+		t.del_flag AS del_flag,
+		t.enable_flag AS enable_flag,
+		t.tenant_id AS tenant_id,
+		t.lookinto_date AS create_time,
+		t.create_user AS create_user,
+		t.update_time AS update_time,
+		t.update_user AS update_user,
+		t.submit_status AS submit_status,
+		t.share_img_url AS share_img_url,
+		t.plat_audit_status AS plat_audit_status,
+		t.task_info_img AS task_info_img
+		FROM wm_task t
+		left join sys_user u on  u.user_id=t.task_user_id
+		left join sys_dept d on d.dept_id=t.dept_id
+		left join wm_score_package p on p.id=t.score_package_id
+		where t.del_flag=0
+		and t.real_flag=0
+		and t.task_status !='1'
+		<if test="query.taskUserId!=null and query.taskUserId!=''">
+			and t.task_user_id = #{query.taskUserId}
+		</if>
+		<if test="query.taskTypeId != null and query.taskTypeId != ''">
+			and t.task_type_id = #{query.taskTypeId}
+		</if>
+		<if test="query.taskStatus!=null and query.taskStatus!=''">
+			and t.task_status in (${query.taskStatus})
+		</if>
+		<if test="query.scorePackageId!=null and query.scorePackageId!=''">
+			and t.score_package_id in (${query.scorePackageId})
+		</if>
+		<if test="query.taskUserType != null and query.taskUserType != ''">
+			and t.task_user_type in (${query.taskUserType})
+		</if>
+		order by t.lookinto_date
+	</select>
+
 
 	<select id="selectByTask" resultMap="wmTaskMap">
 		select t.* FROM wm_task t