|
@@ -18,6 +18,7 @@ package com.qunzhixinxi.hnqz.admin.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
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.core.util.StrUtil;
|
|
@@ -30,23 +31,27 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.CacheConstants;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysDeptRelation;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmReportOpt;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.WmDaPharmacy;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.WmDeptTaskTypeConfig;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.WmReport;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.WmScorePackage;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.WmScorePackageStatus;
|
|
|
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.entity.vo.WmTaskVO;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.EnableEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.ReportEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.ScorePackageStatusEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.TaskStatusEnum;
|
|
|
+import com.qunzhixinxi.hnqz.admin.mapper.SysDeptRelationMapper;
|
|
|
import com.qunzhixinxi.hnqz.admin.mapper.WmReportMapper;
|
|
|
import com.qunzhixinxi.hnqz.admin.mapper.WmTaskMapper;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysUserService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmDaDistributionService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmDaHospitalService;
|
|
@@ -69,14 +74,14 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* 报告审核表
|
|
@@ -100,6 +105,8 @@ public class WmReportServiceImpl extends ServiceImpl<WmReportMapper, WmReport> i
|
|
|
private final WmDaPharmacyService wmDaPharmacyService;
|
|
|
private final WmDaHospitalService wmDaHospitalService;
|
|
|
private final WmDeptTaskTypeConfigService wmDeptTaskTypeConfigService;
|
|
|
+ private final SysDeptService sysDeptService;
|
|
|
+ private final SysDeptRelationMapper sysDeptRelationMapper;
|
|
|
private final RedisTemplate<String,String> redisTemplate;
|
|
|
|
|
|
@Override
|
|
@@ -501,7 +508,9 @@ public class WmReportServiceImpl extends ServiceImpl<WmReportMapper, WmReport> i
|
|
|
// 姓名
|
|
|
if (StringUtils.isNumeric(wmtask.getTaskUserId())) {
|
|
|
SysUser user = sysUserService.getById(Integer.parseInt(wmtask.getTaskUserId()));
|
|
|
- map.put("taskUsername", user.getRealname());
|
|
|
+ if (user != null) {
|
|
|
+ map.put("taskUsername", user.getRealname());
|
|
|
+ }
|
|
|
}
|
|
|
return map;
|
|
|
}).collect(Collectors.toList());
|
|
@@ -522,20 +531,64 @@ public class WmReportServiceImpl extends ServiceImpl<WmReportMapper, WmReport> i
|
|
|
@Override
|
|
|
public R<?> taskPageByTaskType(Page<WmTaskVO> page, String taskTypeName, String[] entTaskStatus) {
|
|
|
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
+
|
|
|
LambdaQueryWrapper<WmTaskType> queryWrapper = Wrappers.<WmTaskType>lambdaQuery()
|
|
|
.eq(WmTaskType::getTaskTypeLevel, "1")
|
|
|
.eq(WmTaskType::getEnableFlag, EnableEnum.ENABLE.val());
|
|
|
- if (StrUtil.isNotBlank(taskTypeName)) {
|
|
|
- queryWrapper.eq(WmTaskType::getTaskTypeName, taskTypeName);
|
|
|
- } else {
|
|
|
- // 查询该企业配置的任务类型
|
|
|
- WmDeptTaskTypeConfigDTO deptTaskTypeConfig =
|
|
|
- wmDeptTaskTypeConfigService.getDeptTaskTypeConfig(SecurityUtils.getUser().getDeptId());
|
|
|
- List<String> taskTypeNames = deptTaskTypeConfig.getConfigList().stream()
|
|
|
- .map(WmDeptTaskTypeConfigJsonDTO::getTaskTypeName)
|
|
|
+ if (StrUtil.isNotBlank(taskTypeName)) {
|
|
|
+ queryWrapper.eq(WmTaskType::getTaskTypeName, taskTypeName);
|
|
|
+ } else {
|
|
|
+ // 查询该企业可查询的任务类型权限
|
|
|
+ // 本级dept对应任务类型配置
|
|
|
+ WmDeptTaskTypeConfig deptTaskTypeConfig = wmDeptTaskTypeConfigService.getOne(Wrappers.<WmDeptTaskTypeConfig>lambdaQuery()
|
|
|
+ .eq(WmDeptTaskTypeConfig::getDeptId, deptId));
|
|
|
+ List<WmDeptTaskTypeConfigJsonDTO> filterConfigJsonDTOList = null;
|
|
|
+ if (deptTaskTypeConfig != null) {
|
|
|
+ // 查询该企业当前任务类型下 的任务类型配置数据
|
|
|
+ List<WmDeptTaskTypeConfigJsonDTO> configJsonDTOList =
|
|
|
+ JSON.parseArray(deptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
|
|
|
+ filterConfigJsonDTOList = configJsonDTOList.stream()
|
|
|
+ .filter(configJsonDTO -> configJsonDTO.getQualifiedTask())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询上级的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 = wmDeptTaskTypeConfigService.getOne(Wrappers.<WmDeptTaskTypeConfig>lambdaQuery()
|
|
|
+ .eq(WmDeptTaskTypeConfig::getDeptId, ancestorDeptRelation.getAncestor()));
|
|
|
+ if (ancestorDeptTaskTypeConfig != null) {
|
|
|
+ List<WmDeptTaskTypeConfigJsonDTO> ancestorConfigJsonDTOList =
|
|
|
+ JSON.parseArray(ancestorDeptTaskTypeConfig.getTaskTypeJson(), WmDeptTaskTypeConfigJsonDTO.class);
|
|
|
+ // 转换为key value形式
|
|
|
+ filterAncestorConfigList = ancestorConfigJsonDTOList.stream()
|
|
|
+ .filter(configJsonDTO -> configJsonDTO.getQualifiedTask() && configJsonDTO.getAssociateLower())
|
|
|
.collect(Collectors.toList());
|
|
|
- queryWrapper.in(WmTaskType::getTaskTypeName, taskTypeNames);
|
|
|
}
|
|
|
+ }
|
|
|
+ // 任务配置为空,则直接返回空page
|
|
|
+ if (CollectionUtil.isEmpty(filterConfigJsonDTOList) && CollectionUtil.isEmpty(filterAncestorConfigList)) {
|
|
|
+ log.warn("任务类型权限不存在");
|
|
|
+ return R.failed("任务类型不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<String> taskTypeNames = new HashSet<>();
|
|
|
+ if (CollUtil.isNotEmpty(filterConfigJsonDTOList)) {
|
|
|
+ taskTypeNames.addAll(filterConfigJsonDTOList.stream().map(WmDeptTaskTypeConfigJsonDTO::getTaskTypeName)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(filterAncestorConfigList)) {
|
|
|
+ taskTypeNames.addAll(filterAncestorConfigList.stream().map(WmDeptTaskTypeConfigJsonDTO::getTaskTypeName)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ queryWrapper.in(WmTaskType::getTaskTypeName, taskTypeNames);
|
|
|
+ }
|
|
|
List<WmTaskType> baseTaskTypeList = wmTaskTypeService.list(queryWrapper);
|
|
|
if (CollUtil.isEmpty(baseTaskTypeList)) {
|
|
|
log.warn("任务类型不存在tastTypeName={}", baseTaskTypeList);
|
|
@@ -551,16 +604,19 @@ public class WmReportServiceImpl extends ServiceImpl<WmReportMapper, WmReport> i
|
|
|
// queryReport.setTaskTypeIdList(baseTaskTypeList.stream().map(WmTaskType::getId).collect(Collectors.toList()));
|
|
|
|
|
|
Map<String, Object> entTaskStatusMap = new HashMap<>();
|
|
|
- entTaskStatusMap.put("drugEntId", SecurityUtils.getUser().getDeptId());
|
|
|
+ SysDept dept = sysDeptService.getById(deptId);
|
|
|
+ entTaskStatusMap.put("drugEntId", deptId);
|
|
|
entTaskStatusMap.put("taskTypeIdList", baseTaskTypeList.stream().map(WmTaskType::getId).collect(Collectors.toList()));
|
|
|
// entTaskStatusMap.put("reportIdList", wmReportList.stream().map(WmReport::getId).collect(Collectors.toList()));
|
|
|
+ // 用来判断是否为药企deptLevel=2
|
|
|
+ entTaskStatusMap.put("deptLevel", dept.getLevel());
|
|
|
|
|
|
// 拆分是否通过状态、待审核状态,用于sql优化~
|
|
|
if (ArrayUtil.isNotEmpty(entTaskStatus)) {
|
|
|
// 通过状态
|
|
|
String approvedStatus = null;
|
|
|
// 待审核状态
|
|
|
- String waitStatus = null;
|
|
|
+ Boolean waitFlag = false;
|
|
|
if (ArrayUtil.containsAll(entTaskStatus, "1", "2")) {
|
|
|
// 通过+不通过
|
|
|
approvedStatus = "3";
|
|
@@ -573,11 +629,11 @@ public class WmReportServiceImpl extends ServiceImpl<WmReportMapper, WmReport> i
|
|
|
}
|
|
|
if (ArrayUtil.contains(entTaskStatus, "0")) {
|
|
|
// 待审核
|
|
|
- waitStatus = "0";
|
|
|
+ waitFlag = true;
|
|
|
}
|
|
|
entTaskStatusMap.put("entTaskStatus", entTaskStatus);
|
|
|
entTaskStatusMap.put("approvedStatus", approvedStatus);
|
|
|
- entTaskStatusMap.put("waitStatus", waitStatus);
|
|
|
+ entTaskStatusMap.put("waitFlag", waitFlag);
|
|
|
// queryReport.setEntTaskStatus(entTaskStatusMap);
|
|
|
}
|
|
|
IPage<WmTaskVO> pages = wmTaskMapper.entTaskPageByTaskType(page, entTaskStatusMap);
|
|
@@ -589,11 +645,11 @@ public class WmReportServiceImpl extends ServiceImpl<WmReportMapper, WmReport> i
|
|
|
Map<String, Object> map = JSON.parseObject(JSON.toJSONString(wmtask), Map.class);
|
|
|
map.put("reportNo", wmtask.getReportNo());
|
|
|
map.put("scoreId", wmtask.getScoreId());
|
|
|
- if ("0".equals(wmtask.getTypeid())) {//药企
|
|
|
+ if (dept.getLevel() == 2) {//药企
|
|
|
map.put("reportApprovalOpinion", wmtask.getReportDrugApprovalOpinion());
|
|
|
- } else if ("1".equals(wmtask.getTypeid())) {//一级代理商类型
|
|
|
+ } else if (dept.getLevel() == 3) {//一级代理商类型
|
|
|
map.put("reportApprovalOpinion", wmtask.getReportDrugApprovalOpinion());
|
|
|
- } else if ("2".equals(wmtask.getTypeid())) {//二级代理商类型
|
|
|
+ } else if (dept.getLevel() == 4) {//二级代理商类型
|
|
|
map.put("reportApprovalOpinion", wmtask.getReportOneApprovalOpinion());
|
|
|
}
|
|
|
// 姓名
|
|
@@ -603,8 +659,20 @@ public class WmReportServiceImpl extends ServiceImpl<WmReportMapper, WmReport> i
|
|
|
map.put("taskUsername", user.getRealname());
|
|
|
}
|
|
|
}
|
|
|
- // 积分包名称设置到scorePackageId上 适配页面
|
|
|
- map.put("scorePackageId", wmtask.getScorePackageName());
|
|
|
+ map.put("scorePackageName", wmtask.getScorePackageName());
|
|
|
+ // 积分包名称取当前企业发的包包名
|
|
|
+ WmScorePackage scorePackage = wmScorePackageService.getById(wmtask.getScorePackageId());
|
|
|
+ // 判断此包是不是当前企业发的
|
|
|
+ if (!deptId.equals(Integer.parseInt(scorePackage.getSendPackageDeptId())) && StrUtil.isNotBlank(scorePackage.getRelationScoreId())) {
|
|
|
+ // 不是则继续查询父级包
|
|
|
+ WmScorePackage pScorePackage = wmScorePackageService.getById(scorePackage.getRelationScoreId());
|
|
|
+ map.put("scorePackageName", pScorePackage.getScorePackageName());
|
|
|
+ if (!deptId.equals(Integer.parseInt(pScorePackage.getSendPackageDeptId())) && StrUtil.isNotBlank(pScorePackage.getRelationScoreId())) {
|
|
|
+ // 不是则再继续查询父级包
|
|
|
+ WmScorePackage ppScorePackage = wmScorePackageService.getById(pScorePackage.getRelationScoreId());
|
|
|
+ map.put("scorePackageName", ppScorePackage.getScorePackageName());
|
|
|
+ }
|
|
|
+ }
|
|
|
return map;
|
|
|
}).collect(Collectors.toList());
|
|
|
|