Przeglądaj źródła

fix: 批量任务审核-查询任务类型、保存任务类型

lixuesong 3 lat temu
rodzic
commit
efd11d4ba6

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

@@ -74,6 +74,12 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 
 	private final WmDaAgentMapper wmDaAgentMapper;
 
+	/**
+	 * 兼职学术专员启用的任务类型
+	 */
+	private final String[] ENABLE_ZBDB_STATUS_ARR = {"医院拜访", "商业公司拜访", "药店拜访", "电子名片分享", "产品相册分享", "学术信息交流",
+			"受众打开产品相册", "受众阅读文章"};
+
 	/**
 	 * 任务类型Map
 	 */
@@ -145,6 +151,11 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 					.eq(WmTaskType::getTaskTypeLevel, "1")
 					.eq(WmTaskType::getTaskTypeName, configJsonDTO.getTaskTypeName()));
 			configJsonDTO.setTaskTypeId(baseTaskType.getId());
+			// 判断并确保兼职任务类型未启用时不可选中
+			if (!ArrayUtil.contains(ENABLE_ZBDB_STATUS_ARR, configJsonDTO.getTaskTypeName())) {
+				configJsonDTO.setZbdbStatusEnable(false);
+				configJsonDTO.setZbdbStatusSelect(false);
+			}
 		});
 		if (count <= 0) {
 			// 新增
@@ -177,8 +188,6 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 	 */
 	@Override
 	public WmDeptTaskTypeConfigDTO getDeptTaskTypeConfig(Integer deptId) {
-		String[] enableZbdbStatusArr = {"医院拜访", "商业公司拜访", "药店拜访", "电子名片分享", "产品相册分享", "学术信息交流",
-				"受众打开产品相册", "受众阅读文章"};
 		// 查询出当前dept对应的药企/代理商id
 		String durgentId = null;
 		SysDept dept = sysDeptMapper.selectById(deptId);
@@ -229,7 +238,7 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 				deptTaskTypeConfigJsonDTO.setTaskTypeId(taskType.getId());
 				deptTaskTypeConfigJsonDTO.setTaskTypeName(taskType.getTaskTypeName());
 				deptTaskTypeConfigJsonDTO.setScore(taskType.getScore());
-				if (ArrayUtil.contains(enableZbdbStatusArr, taskType.getTaskTypeName())) {
+				if (ArrayUtil.contains(ENABLE_ZBDB_STATUS_ARR, taskType.getTaskTypeName())) {
 					deptTaskTypeConfigJsonDTO.setZbdbStatusEnable(true);
 				} else {
 					deptTaskTypeConfigJsonDTO.setZbdbStatusEnable(false);
@@ -355,11 +364,13 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 					JSON.parseArray(deptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
 			if (StringUtils.isNotBlank(taskTypeName)) {
 				filterConfigJsonDTOList = configJsonDTOList.stream()
-						.filter(configJsonDTO -> configJsonDTO.getTaskTypeName().equals(taskTypeName) && configJsonDTO.getQualifiedTask())
+						.filter(configJsonDTO -> configJsonDTO.getTaskTypeName().equals(taskTypeName) && configJsonDTO.getQualifiedTask()
+								&& (configJsonDTO.getYydbStatusSelect() || configJsonDTO.getZbdbStatusSelect()))
 						.collect(Collectors.toList());
 			} else {
 				filterConfigJsonDTOList = configJsonDTOList.stream()
-						.filter(configJsonDTO -> configJsonDTO.getQualifiedTask())
+						.filter(configJsonDTO -> configJsonDTO.getQualifiedTask()
+								&& (configJsonDTO.getYydbStatusSelect() || configJsonDTO.getZbdbStatusSelect()))
 						.collect(Collectors.toList());
 			}
 		}
@@ -381,11 +392,13 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 				if (StringUtils.isNotBlank(taskTypeName)) {
 					filterAncestorConfigList = ancestorConfigJsonDTOList.stream()
 							.filter(configJsonDTO -> configJsonDTO.getTaskTypeName().equals(taskTypeName)
-									&& configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower())
+									&& configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower()
+									&& (configJsonDTO.getYydbStatusSelect() || configJsonDTO.getZbdbStatusSelect()))
 							.collect(Collectors.toList());
 				} else {
 					filterAncestorConfigList = ancestorConfigJsonDTOList.stream()
-							.filter(configJsonDTO -> configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower())
+							.filter(configJsonDTO -> configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower()
+									&& (configJsonDTO.getYydbStatusSelect() || configJsonDTO.getZbdbStatusSelect()))
 							.collect(Collectors.toList());
 				}
 			}
@@ -406,22 +419,18 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 					for (WmDeptTaskTypeConfigJsonDTO configJsonDTO : finalFilterConfigJsonDTOList) {
 						// 用户类型
 						List<String> typeIdList = new ArrayList<>();
-						if (configJsonDTO.getZbdbStatusEnable() && configJsonDTO.getZbdbStatusSelect()) {
+						if (configJsonDTO.getZbdbStatusSelect()) {
 							typeIdList.add("4");
 						}
-						if (configJsonDTO.getYydbStatusEnable() && configJsonDTO.getYydbStatusSelect()) {
+						if (configJsonDTO.getYydbStatusSelect()) {
 							typeIdList.add("3");
 						}
-						if (CollectionUtil.isNotEmpty(typeIdList)) {
-							wrapper.or(wrapper2 -> {
-								wrapper2.eq("t.task_type_id", configJsonDTO.getTaskTypeId());
-								wrapper2.eq("t.dept_id", deptId);
-								wrapper2.in("p.typeid", typeIdList);
-								wrapper2.isNull("p.relation_score_id");
-							});
-						} else {
-							wrapper.or(wrapper2 -> wrapper2.ne("1", "1"));
-						}
+						wrapper.or(wrapper2 -> {
+							wrapper2.eq("t.task_type_id", configJsonDTO.getTaskTypeId());
+							wrapper2.eq("t.dept_id", deptId);
+							wrapper2.in("p.typeid", typeIdList);
+							wrapper2.isNull("p.relation_score_id");
+						});
 					}
 				}
 				// 关联了上级企业的包的任务 条件
@@ -435,16 +444,12 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
 						if (configJsonDTO.getYydbStatusEnable() && configJsonDTO.getYydbStatusSelect()) {
 							typeIdList.add("3");
 						}
-						if (CollectionUtil.isNotEmpty(typeIdList)) {
-							wrapper.or(wrapper2 -> {
-								wrapper2.eq("t.task_type_id", configJsonDTO.getTaskTypeId());
-								wrapper2.eq("t.dept_id", deptId);
-								wrapper2.in("p.typeid", typeIdList);
-								wrapper2.isNotNull("p.relation_score_id");
-							});
-						} else {
-							wrapper.or(wrapper2 -> wrapper2.ne("1", "1"));
-						}
+						wrapper.or(wrapper2 -> {
+							wrapper2.eq("t.task_type_id", configJsonDTO.getTaskTypeId());
+							wrapper2.eq("t.dept_id", deptId);
+							wrapper2.in("p.typeid", typeIdList);
+							wrapper2.isNotNull("p.relation_score_id");
+						});
 					}
 				}
 			});