|
@@ -2,6 +2,7 @@ package com.qunzhixinxi.hnqz.admin.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -9,9 +10,13 @@ import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskSubmissionPercentRule;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskSubmissionRule;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.WmTaskType;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.WmTaskTypeSubCate2;
|
|
|
+import com.qunzhixinxi.hnqz.admin.enums.DelEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionPercentRuleService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionRuleService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeSubCate2Service;
|
|
|
import com.qunzhixinxi.hnqz.common.core.constant.enums.CommonFlag;
|
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
@@ -28,6 +33,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
@@ -49,6 +56,7 @@ public class WmTaskSubmissionRuleController {
|
|
|
private final SysDeptService deptService;
|
|
|
private final WmTaskTypeSubCate2Service wmTaskTypeSubCate2Service;
|
|
|
private final WmTaskSubmissionPercentRuleService taskSubmissionPercentRuleService;
|
|
|
+ private final WmTaskTypeService wmTaskTypeService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -70,8 +78,48 @@ public class WmTaskSubmissionRuleController {
|
|
|
*/
|
|
|
@GetMapping("/list-task-type")
|
|
|
public R<?> listTaskType(@RequestParam(value = "deptId") Integer deptId) {
|
|
|
- List<Map<String, Object>> taskTypeList = wmTaskTypeSubCate2Service.listTaskTypeTree(deptId);
|
|
|
+
|
|
|
+ // 查询基础任务类型
|
|
|
+ List<WmTaskType> taskTypeList = wmTaskTypeService.list(Wrappers.<WmTaskType>lambdaQuery()
|
|
|
+ .eq(WmTaskType::getTaskTypeLevel, "1")
|
|
|
+ .eq(WmTaskType::getDelFlag, DelEnum.NOT_DEL.val()));
|
|
|
+ Map<String, String> baseTaskTypeMap = taskTypeList.stream()
|
|
|
+ .collect(Collectors.toMap(WmTaskType::getTaskTypeName, WmTaskType::getId));
|
|
|
+
|
|
|
+ // 查询任务类型分类表
|
|
|
+ List<WmTaskTypeSubCate2> list = wmTaskTypeSubCate2Service.list();
|
|
|
+ // key-任务类型父类型, value-任务类型名称列表
|
|
|
+ Map<String, List<String>> listMap = list.stream()
|
|
|
+ .collect(
|
|
|
+ Collectors.groupingBy(
|
|
|
+ WmTaskTypeSubCate2::getSubCate, Collectors.mapping(WmTaskTypeSubCate2::getTypeName, Collectors.toList())
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
if (CollectionUtil.isNotEmpty(taskTypeList)) {
|
|
|
+ // 根据任务类型分类表,给企业任务类型分类
|
|
|
+ listMap.forEach((key, val) -> {
|
|
|
+ List<Map<String, String>> childTypeList = taskTypeList.stream()
|
|
|
+ .filter(wmTaskType -> val.contains(wmTaskType.getTaskTypeName())).map(wmTaskType -> {
|
|
|
+ Map<String, String> typeMap = new HashMap<>();
|
|
|
+ typeMap.put("taskTypeName", wmTaskType.getTaskTypeName());
|
|
|
+ typeMap.put("taskTypeId", baseTaskTypeMap.get(wmTaskType.getTaskTypeName()));
|
|
|
+ return typeMap;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(childTypeList)) {
|
|
|
+ Map<String, Object> taskTypeMap = MapUtil.newHashMap(2);
|
|
|
+ taskTypeMap.put("category", key);
|
|
|
+ taskTypeMap.put("categoryName", UpmsType.TaskSubCategory2.valueOf(key).getDescription());
|
|
|
+ taskTypeMap.put("children", childTypeList);
|
|
|
+ resultList.add(taskTypeMap);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(resultList)) {
|
|
|
// 查询任务类型启用状态
|
|
|
List<WmTaskSubmissionPercentRule> rules = taskSubmissionPercentRuleService.list(Wrappers.<WmTaskSubmissionPercentRule>lambdaQuery()
|
|
|
.eq(WmTaskSubmissionPercentRule::getDeptId, deptId)
|
|
@@ -84,7 +132,7 @@ public class WmTaskSubmissionRuleController {
|
|
|
}
|
|
|
|
|
|
// 设置任务类型是否启用状态
|
|
|
- taskTypeList.forEach(map -> {
|
|
|
+ resultList.forEach(map -> {
|
|
|
List<Map<String, Object>> children = (List<Map<String, Object>>) map.get("children");
|
|
|
if (CollUtil.isNotEmpty(children)) {
|
|
|
// child添加是否启用标记
|
|
@@ -100,7 +148,7 @@ public class WmTaskSubmissionRuleController {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- return R.ok(taskTypeList);
|
|
|
+ return R.ok(resultList);
|
|
|
}
|
|
|
|
|
|
/**
|