|
@@ -2,6 +2,7 @@ package com.qunzhixinxi.hnqz.admin.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -37,9 +38,11 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
+import java.util.TreeSet;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -141,6 +144,7 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
|
|
deptTaskTypeConfigDTO.setId(deptTaskTypeConfig.getId());
|
|
deptTaskTypeConfigDTO.setId(deptTaskTypeConfig.getId());
|
|
List<WmDeptTaskTypeConfigJsonDTO> configJsonDTOList = JSON.parseArray(deptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
|
|
List<WmDeptTaskTypeConfigJsonDTO> configJsonDTOList = JSON.parseArray(deptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
|
|
configMap = configJsonDTOList.stream()
|
|
configMap = configJsonDTOList.stream()
|
|
|
|
+ .distinct()
|
|
.collect(Collectors.toMap(WmDeptTaskTypeConfigJsonDTO::getTaskTypeName, wmDeptTaskTypeConfigJsonDTO -> wmDeptTaskTypeConfigJsonDTO));
|
|
.collect(Collectors.toMap(WmDeptTaskTypeConfigJsonDTO::getTaskTypeName, wmDeptTaskTypeConfigJsonDTO -> wmDeptTaskTypeConfigJsonDTO));
|
|
}
|
|
}
|
|
// 以企业的任务类型数据为基础,进行任务类型配置数据的拼接
|
|
// 以企业的任务类型数据为基础,进行任务类型配置数据的拼接
|
|
@@ -171,6 +175,104 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
|
|
return deptTaskTypeConfigDTO;
|
|
return deptTaskTypeConfigDTO;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询任务类型树
|
|
|
|
+ *
|
|
|
|
+ * @param taskTypeName
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public List<Map<String, Object>> listConfigedTaskTypeTree(String taskTypeName) {
|
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+ // 查询已配置的任务类型
|
|
|
|
+ // 当前企业配置
|
|
|
|
+ WmDeptTaskTypeConfig deptTaskTypeConfig = this.getOne(Wrappers.<WmDeptTaskTypeConfig>lambdaQuery()
|
|
|
|
+ .eq(WmDeptTaskTypeConfig::getDeptId, deptId));
|
|
|
|
+ List<String> configTaskTypeIdList = null;
|
|
|
|
+ if (deptTaskTypeConfig != null) {
|
|
|
|
+ List<WmDeptTaskTypeConfigJsonDTO> configJsonDTOList = JSON.parseArray(deptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
|
|
|
|
+ configTaskTypeIdList = configJsonDTOList.stream()
|
|
|
|
+ .filter(configJsonDTO -> configJsonDTO.getQualifiedTask())
|
|
|
|
+ .map(WmDeptTaskTypeConfigJsonDTO::getTaskTypeName)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ // 查询上级
|
|
|
|
+ SysDeptRelation ancestorDeptRelation = sysDeptRelationMapper.selectOne(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()));
|
|
|
|
+ List<WmDeptTaskTypeConfigJsonDTO> ancestorConfigJsonDTOList = JSON.parseArray(ancestorDeptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
|
|
|
|
+ ancestorConfigTaskTypeIdList = ancestorConfigJsonDTOList.stream()
|
|
|
|
+ .filter(configJsonDTO -> configJsonDTO.getQualifiedTask())
|
|
|
|
+ .map(WmDeptTaskTypeConfigJsonDTO::getTaskTypeName)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ if (CollectionUtil.isEmpty(configTaskTypeIdList) && CollectionUtil.isEmpty(ancestorConfigTaskTypeIdList)) {
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 查询出当前dept对应的任务类型(药企或药企给CSO的任务类型)
|
|
|
|
+ List<SysDeptRelation> relationList = sysDeptRelationMapper.selectList(Wrappers.<SysDeptRelation>lambdaQuery()
|
|
|
|
+ .eq(SysDeptRelation::getDescendant, deptId));
|
|
|
|
+ SysDeptRelation deptRelation = relationList.stream()
|
|
|
|
+ .filter(sysDeptRelation -> !sysDeptRelation.getAncestor().equals(1))
|
|
|
|
+ .findFirst()
|
|
|
|
+ .get();
|
|
|
|
+ WmDaDrugEnt wmDaDrugEnt = wmDaDrugEntMapper.selectOne(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 (org.apache.commons.lang.StringUtils.isNotBlank(taskTypeName)) {
|
|
|
|
+ taskTypeWrapper.like(WmTaskType::getTaskTypeName, taskTypeName);
|
|
|
|
+ }
|
|
|
|
+ List<WmTaskType> taskTypeList = wmTaskTypeService.list(taskTypeWrapper);
|
|
|
|
+
|
|
|
|
+ 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去重
|
|
|
|
+ List<WmTaskType> baseTaskTypeFilterList = baseTaskTypeList
|
|
|
|
+ .stream()
|
|
|
|
+ .collect(
|
|
|
|
+ Collectors.collectingAndThen(
|
|
|
|
+ Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WmTaskType::getParentId))), ArrayList::new
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ // 转换为key是baseId,value是taskTypelist的列表map
|
|
|
|
+ List<String> finalConfigTaskTypeIdList = configTaskTypeIdList;
|
|
|
|
+ List<String> finalAncestorConfigTaskTypeIdList = ancestorConfigTaskTypeIdList;
|
|
|
|
+ Map<String, List<WmTaskType>> tempTaskTypeMap = taskTypeList.stream()
|
|
|
|
+ .filter(wmTaskType -> wmTaskType.getParentId() != null
|
|
|
|
+ && (
|
|
|
|
+ (finalConfigTaskTypeIdList != null && finalConfigTaskTypeIdList.contains(wmTaskType.getTaskTypeName()))
|
|
|
|
+ || (finalAncestorConfigTaskTypeIdList != null && finalAncestorConfigTaskTypeIdList.contains(wmTaskType.getTaskTypeName()))
|
|
|
|
+ ))
|
|
|
|
+ .collect(Collectors.groupingBy(WmTaskType::getParentId));
|
|
|
|
+ // 转换为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 resultList;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据企业的任务类型配置查询任务列表
|
|
* 根据企业的任务类型配置查询任务列表
|
|
*
|
|
*
|
|
@@ -181,13 +283,14 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
|
|
@Override
|
|
@Override
|
|
public IPage<WmTask> listTaskByConfig(Page<WmTask> page, String taskTypeName, String[] taskStatus) {
|
|
public IPage<WmTask> listTaskByConfig(Page<WmTask> page, String taskTypeName, String[] taskStatus) {
|
|
Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+ // 本级dept对应任务类型配置
|
|
WmDeptTaskTypeConfig deptTaskTypeConfig = this.getOne(Wrappers.<WmDeptTaskTypeConfig>lambdaQuery()
|
|
WmDeptTaskTypeConfig deptTaskTypeConfig = this.getOne(Wrappers.<WmDeptTaskTypeConfig>lambdaQuery()
|
|
.eq(WmDeptTaskTypeConfig::getDeptId, deptId));
|
|
.eq(WmDeptTaskTypeConfig::getDeptId, deptId));
|
|
|
|
+ List<WmDeptTaskTypeConfigJsonDTO> filterConfigJsonDTOList = null;
|
|
if (deptTaskTypeConfig != null) {
|
|
if (deptTaskTypeConfig != null) {
|
|
// 查询该企业当前任务类型下 的任务类型配置数据
|
|
// 查询该企业当前任务类型下 的任务类型配置数据
|
|
List<WmDeptTaskTypeConfigJsonDTO> configJsonDTOList =
|
|
List<WmDeptTaskTypeConfigJsonDTO> configJsonDTOList =
|
|
JSON.parseArray(deptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
|
|
JSON.parseArray(deptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
|
|
- List<WmDeptTaskTypeConfigJsonDTO> filterConfigJsonDTOList = null;
|
|
|
|
if (StringUtils.isNotBlank(taskTypeName)) {
|
|
if (StringUtils.isNotBlank(taskTypeName)) {
|
|
filterConfigJsonDTOList = configJsonDTOList.stream()
|
|
filterConfigJsonDTOList = configJsonDTOList.stream()
|
|
.filter(configJsonDTO -> configJsonDTO.getTaskTypeName().equals(taskTypeName) && configJsonDTO.getQualifiedTask())
|
|
.filter(configJsonDTO -> configJsonDTO.getTaskTypeName().equals(taskTypeName) && configJsonDTO.getQualifiedTask())
|
|
@@ -197,50 +300,91 @@ public class WmDeptTaskTypeConfigServiceImpl extends ServiceImpl<WmDeptTaskTypeC
|
|
.filter(configJsonDTO -> configJsonDTO.getQualifiedTask())
|
|
.filter(configJsonDTO -> configJsonDTO.getQualifiedTask())
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
}
|
|
}
|
|
- if (CollectionUtil.isEmpty(filterConfigJsonDTOList)) {
|
|
|
|
- // 任务配置为空,则直接返回空page
|
|
|
|
- return page;
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 查询上级的deptId
|
|
|
|
+ SysDeptRelation ancestorDeptRelation = sysDeptRelationMapper.selectOne(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())
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ } else {
|
|
|
|
+ filterAncestorConfigList = ancestorConfigJsonDTOList.stream()
|
|
|
|
+ .filter(configJsonDTO -> configJsonDTO.getQualifiedTask())
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- // 查询本地和下级的deptId
|
|
|
|
- List<SysDeptRelation> relationList = sysDeptRelationMapper.selectList(Wrappers.<SysDeptRelation>lambdaQuery()
|
|
|
|
- .eq(SysDeptRelation::getAncestor, deptId));
|
|
|
|
- List<String> associateDeptIdList = relationList.stream()
|
|
|
|
- .map(deptRelation -> String.valueOf(deptRelation.getDescendant()))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- // 根据不同任务类型的不同条件 拼接sql
|
|
|
|
- QueryWrapper<WmTask> taskWrapper = Wrappers.query();
|
|
|
|
- taskWrapper.eq("t.del_flag", DelEnum.NOT_DEL.val());
|
|
|
|
- taskWrapper.eq("t.real_flag", "0");
|
|
|
|
- taskWrapper.in("t.task_status", taskStatus);
|
|
|
|
- List<WmDeptTaskTypeConfigJsonDTO> finalFilterConfigJsonDTOList = filterConfigJsonDTOList;
|
|
|
|
- taskWrapper.and(wrapper -> {
|
|
|
|
|
|
+ }
|
|
|
|
+ // 任务配置为空,则直接返回空page
|
|
|
|
+ if (CollectionUtil.isEmpty(filterConfigJsonDTOList) && CollectionUtil.isEmpty(filterAncestorConfigList)) {
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 根据不同任务类型的不同条件 拼接sql
|
|
|
|
+ QueryWrapper<WmTask> taskWrapper = Wrappers.query();
|
|
|
|
+ taskWrapper.eq("t.del_flag", DelEnum.NOT_DEL.val());
|
|
|
|
+ taskWrapper.eq("t.real_flag", "0");
|
|
|
|
+ taskWrapper.in("t.task_status", taskStatus);
|
|
|
|
+ List<WmDeptTaskTypeConfigJsonDTO> finalFilterConfigJsonDTOList = filterConfigJsonDTOList;
|
|
|
|
+ List<WmDeptTaskTypeConfigJsonDTO> finalFilterAncestorConfigList = filterAncestorConfigList;
|
|
|
|
+ taskWrapper.and(wrapper -> {
|
|
|
|
+ // 当前企业直接发包的任务 条件
|
|
|
|
+ if (finalFilterConfigJsonDTOList != null) {
|
|
for (WmDeptTaskTypeConfigJsonDTO configJsonDTO : finalFilterConfigJsonDTOList) {
|
|
for (WmDeptTaskTypeConfigJsonDTO configJsonDTO : finalFilterConfigJsonDTOList) {
|
|
// 用户类型
|
|
// 用户类型
|
|
- List<String> taskUserTypeList = new ArrayList<>();
|
|
|
|
|
|
+ List<String> typeIdList = new ArrayList<>();
|
|
if (configJsonDTO.getZbdbStatusEnable() && configJsonDTO.getZbdbStatusSelect()) {
|
|
if (configJsonDTO.getZbdbStatusEnable() && configJsonDTO.getZbdbStatusSelect()) {
|
|
- taskUserTypeList.add("5");
|
|
|
|
|
|
+ typeIdList.add("4");
|
|
}
|
|
}
|
|
if (configJsonDTO.getYydbStatusEnable() && configJsonDTO.getYydbStatusSelect()) {
|
|
if (configJsonDTO.getYydbStatusEnable() && configJsonDTO.getYydbStatusSelect()) {
|
|
- taskUserTypeList.add("6");
|
|
|
|
|
|
+ typeIdList.add("3");
|
|
}
|
|
}
|
|
- if (CollectionUtil.isNotEmpty(taskUserTypeList)) {
|
|
|
|
|
|
+ if (CollectionUtil.isNotEmpty(typeIdList)) {
|
|
wrapper.or(wrapper2 -> {
|
|
wrapper.or(wrapper2 -> {
|
|
wrapper2.eq("t.task_type_id", configJsonDTO.getTaskTypeId());
|
|
wrapper2.eq("t.task_type_id", configJsonDTO.getTaskTypeId());
|
|
- wrapper2.in("t.task_user_type", taskUserTypeList);
|
|
|
|
- if (configJsonDTO.getAssociateLower()) {
|
|
|
|
- // 关联了下级
|
|
|
|
- wrapper2.in("t.dept_id", associateDeptIdList);
|
|
|
|
- } else {
|
|
|
|
- // 没有关联下级
|
|
|
|
- wrapper2.eq("t.dept_id", deptId);
|
|
|
|
- }
|
|
|
|
|
|
+ wrapper2.eq("t.dept_id", deptId);
|
|
|
|
+ wrapper2.in("p.typeid", typeIdList);
|
|
|
|
+ wrapper2.isNull("p.relation_score_id");
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- });
|
|
|
|
- return wmTaskMapper.listWmTaskByWrapper(page, taskWrapper);
|
|
|
|
- }
|
|
|
|
- return page;
|
|
|
|
|
|
+ }
|
|
|
|
+ // 关联了上级企业的包的任务 条件
|
|
|
|
+ if (finalFilterAncestorConfigList != null) {
|
|
|
|
+ for (WmDeptTaskTypeConfigJsonDTO configJsonDTO : finalFilterAncestorConfigList) {
|
|
|
|
+ // 用户类型
|
|
|
|
+ List<String> typeIdList = new ArrayList<>();
|
|
|
|
+ if (configJsonDTO.getZbdbStatusEnable() && configJsonDTO.getZbdbStatusSelect()) {
|
|
|
|
+ typeIdList.add("4");
|
|
|
|
+ }
|
|
|
|
+ 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");
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ taskWrapper.orderByDesc("t.lookinto_date");
|
|
|
|
+ return wmTaskMapper.listWmTaskByWrapper(page, taskWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|