|
@@ -17,15 +17,19 @@
|
|
|
|
|
|
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;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.WmTaskTypeEntRef;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.output.WmTaskTypeDeptOutput;
|
|
|
+import com.qunzhixinxi.hnqz.admin.enums.EnableEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.*;
|
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
|
import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
|
|
@@ -41,6 +45,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -60,7 +65,7 @@ public class WmTaskTypeController {
|
|
|
private final WmDaDrugEntService wmDaDrugEntService;
|
|
|
private final WmDaAgentService wmDaAgentService;
|
|
|
private final WmTaskTypeEntRefService wmTaskTypeEntRefService;
|
|
|
-
|
|
|
+ private final SysDeptRelationService sysDeptRelationService;
|
|
|
|
|
|
/**
|
|
|
* 分页查询
|
|
@@ -305,4 +310,59 @@ public class WmTaskTypeController {
|
|
|
|
|
|
return wmTaskTypeService.getTaskTypeTree(description);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询任务类型树
|
|
|
+ *
|
|
|
+ * @param taskTypeName
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/list-task-type-tree")
|
|
|
+ public R<?> listTaskTypeTree(String taskTypeName) {
|
|
|
+ // 查询出当前dept对应的任务类型(药企或药企给CSO的任务类型)
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
+ List<SysDeptRelation> relationList = sysDeptRelationService.list(Wrappers.<SysDeptRelation>lambdaQuery()
|
|
|
+ .eq(SysDeptRelation::getDescendant, deptId));
|
|
|
+ SysDeptRelation deptRelation = relationList.stream()
|
|
|
+ .filter(sysDeptRelation -> !sysDeptRelation.getAncestor().equals(1))
|
|
|
+ .findFirst()
|
|
|
+ .get();
|
|
|
+ WmDaDrugEnt wmDaDrugEnt = wmDaDrugEntService.getOne(Wrappers.<WmDaDrugEnt>lambdaQuery()
|
|
|
+ .eq(WmDaDrugEnt::getDeptId, deptRelation.getAncestor())
|
|
|
+ .eq(WmDaDrugEnt::getEnableFlag, EnableEnum.ENABLE.val()));
|
|
|
+ // 查询企业对应的任务类型
|
|
|
+ LambdaQueryWrapper<WmTaskType> taskTypeWrapper = Wrappers.lambdaQuery();
|
|
|
+ taskTypeWrapper.eq(WmTaskType::getDeptId, deptId);
|
|
|
+ taskTypeWrapper.eq(WmTaskType::getDurgentId, wmDaDrugEnt.getId());
|
|
|
+ if (StringUtils.isNotBlank(taskTypeName)) {
|
|
|
+ taskTypeWrapper.eq(WmTaskType::getTaskTypeName, taskTypeName);
|
|
|
+ }
|
|
|
+ List<WmTaskType> taskTypeList = wmTaskTypeService.list(taskTypeWrapper);
|
|
|
+
|
|
|
+ Map<String, List<WmTaskType>> resultMap = new HashMap<>();
|
|
|
+ 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
|
|
|
+ .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)));
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok(resultMap);
|
|
|
+ }
|
|
|
}
|