|
@@ -1,22 +1,47 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.diagbot.dto.CheckDeptDTO;
|
|
|
+import com.diagbot.dto.CheckJobDTO;
|
|
|
+import com.diagbot.dto.CheckUserDTO;
|
|
|
+import com.diagbot.dto.DeptCheckUserDTO;
|
|
|
+import com.diagbot.entity.BasDeptInfo;
|
|
|
+import com.diagbot.entity.BasDoctorInfo;
|
|
|
import com.diagbot.entity.MedCheckInfo;
|
|
|
+import com.diagbot.entity.QcresultInfo;
|
|
|
+import com.diagbot.entity.SysRole;
|
|
|
import com.diagbot.entity.SysUser;
|
|
|
+import com.diagbot.entity.SysUserDept;
|
|
|
+import com.diagbot.entity.SysUserRole;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.MedCheckInfoServiceImpl;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.util.SysUserUtils;
|
|
|
+import com.diagbot.vo.CheckJobPageVO;
|
|
|
+import com.diagbot.vo.CheckJobVO;
|
|
|
+import com.diagbot.vo.CheckUserVO;
|
|
|
+import com.diagbot.vo.DistributionJobVO;
|
|
|
import com.diagbot.vo.MedCheckInfoAddVO;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import org.apache.commons.collections4.ListUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author wangfeng
|
|
@@ -28,6 +53,17 @@ public class MedCheckInfoFacade extends MedCheckInfoServiceImpl {
|
|
|
|
|
|
@Autowired
|
|
|
SysUserFacade sysUserFacade;
|
|
|
+ @Autowired
|
|
|
+ SysUserRoleFacade sysUserRoleFacade;
|
|
|
+ @Autowired
|
|
|
+ SysRoleFacade sysRoleFacade;
|
|
|
+ @Autowired
|
|
|
+ SysUserDeptFacade sysUserDeptFacade;
|
|
|
+ @Autowired
|
|
|
+ BasDoctorInfoFacade basDoctorInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ BasDeptInfoFacade basDeptInfoFacade;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @param medCheckInfoAddVO
|
|
@@ -108,4 +144,578 @@ public class MedCheckInfoFacade extends MedCheckInfoServiceImpl {
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 获取操作用户的核查科室以及人员
|
|
|
+ * @Date 2021/5/14
|
|
|
+ * @Param []
|
|
|
+ * @Return java.util.Map<java.lang.String,java.util.List<com.diagbot.dto.CheckDeptDTO>>
|
|
|
+ * @MethodName getCheckUserMap
|
|
|
+ */
|
|
|
+ public IPage<CheckJobDTO> getUserCheckList(CheckJobPageVO checkJobVO) {
|
|
|
+ //校验
|
|
|
+ userCheckPageSet(checkJobVO);
|
|
|
+ //质控管理员要判断该角色是否是质控科
|
|
|
+ //1.获取质控科id
|
|
|
+ //获取人员id 和 该人员的医院id
|
|
|
+ Long hospitalId = Long.valueOf(SysUserUtils.getCurrentHospitalID());
|
|
|
+ Long principleId = Long.valueOf(SysUserUtils.getCurrentPrincipleID());
|
|
|
+ //获取核查监管相关角色id
|
|
|
+ List<Long> checkRoleIds = sysRoleFacade.list(new QueryWrapper<SysRole>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .like("name","监管人员")
|
|
|
+ ).stream().map(SysRole::getId).collect(Collectors.toList());
|
|
|
+ //查询该角色的所有角色id
|
|
|
+ List<Long> roleIds = sysUserRoleFacade.list(new QueryWrapper<SysUserRole>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("user_id", principleId)
|
|
|
+ ).stream().distinct().map(SysUserRole::getRoleId).collect(Collectors.toList());
|
|
|
+ List<Long> searchRoleIds = new ArrayList<>();
|
|
|
+ //当前用户是监管人员或者是超级管理员
|
|
|
+ if(roleIds.contains(-1L))
|
|
|
+ {
|
|
|
+ searchRoleIds.addAll(checkRoleIds);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ searchRoleIds.addAll(containsRole(checkRoleIds,roleIds));
|
|
|
+ }
|
|
|
+ if(searchRoleIds.isEmpty())
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该用户不是核查监管人员!");
|
|
|
+ }
|
|
|
+ //质控科监管人员
|
|
|
+ if(searchRoleIds.contains(5L)&&"2".equals(checkJobVO.getJobType()))
|
|
|
+ {
|
|
|
+ //用户是不是质管科人员校验
|
|
|
+ String zkkDeptId = basDeptInfoFacade.getOne(new QueryWrapper<BasDeptInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .like("dept_name","质管科")).getDeptId();
|
|
|
+ if(StringUtil.isBlank(zkkDeptId))
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "科室质管科不存在!");
|
|
|
+ }
|
|
|
+ //2.获取监管人员所在科室集合
|
|
|
+ List<String> deptIds = sysUserDeptFacade.list(new QueryWrapper<SysUserDept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .eq("user_id",principleId)
|
|
|
+ ).stream().map(SysUserDept::getDeptId).collect(Collectors.toList());
|
|
|
+ //3.判断这个人是否在质控科
|
|
|
+ if(deptIds.contains(zkkDeptId))
|
|
|
+ {
|
|
|
+ return getCheckList(checkJobVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //临床科室监管人员
|
|
|
+ else if(searchRoleIds.contains(4L)&&"0".equals(checkJobVO.getJobType()))
|
|
|
+ {
|
|
|
+ //获取监管人员所在科室集合
|
|
|
+ List<String> deptIds = sysUserDeptFacade.list(new QueryWrapper<SysUserDept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .eq("user_id",principleId)
|
|
|
+ ).stream().map(SysUserDept::getDeptId).collect(Collectors.toList());
|
|
|
+ if(deptIds!=null&&!deptIds.isEmpty()){
|
|
|
+ checkJobVO.setDeptList(deptIds);
|
|
|
+ }
|
|
|
+ return getCheckList(checkJobVO);
|
|
|
+ }
|
|
|
+ //院级监管人员
|
|
|
+ else if(searchRoleIds.contains(6L)&&"1".equals(checkJobVO.getJobType()))
|
|
|
+ {
|
|
|
+ //获取监管人员所在科室集合
|
|
|
+ List<String> deptIds = sysUserDeptFacade.list(new QueryWrapper<SysUserDept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .eq("user_id",principleId)
|
|
|
+ ).stream().map(SysUserDept::getDeptId).collect(Collectors.toList());
|
|
|
+ //分配除了监管人员以外其他科室的核查任务
|
|
|
+ if(deptIds!=null&&!deptIds.isEmpty()){
|
|
|
+ checkJobVO.setDeptList(deptIds);
|
|
|
+ }
|
|
|
+ return getCheckList(checkJobVO);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该用户的角色和任务类型不对应!");
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 待分配列表页面校验
|
|
|
+ * @Date 2021/5/18
|
|
|
+ * @Param [checkJobVO]
|
|
|
+ * @Return void
|
|
|
+ * @MethodName userCheckPageSet
|
|
|
+ */
|
|
|
+ private void userCheckPageSet(CheckJobPageVO checkJobVO) {
|
|
|
+ if(StringUtil.isBlank(checkJobVO.getStartTime())&&StringUtil.isBlank(checkJobVO.getEndTime())
|
|
|
+ &&StringUtil.isBlank(checkJobVO.getBehosDateStart())&&StringUtil.isBlank(checkJobVO.getBehosDateEnd()))
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "没有时间区间!");
|
|
|
+ }
|
|
|
+ if(StringUtil.isBlank(checkJobVO.getJobType()))
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "没有任务类型!");
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotBlank(checkJobVO.getBehosDateStart())&&StringUtil.isNotBlank(checkJobVO.getBehosDateEnd()))
|
|
|
+ {
|
|
|
+ if (DateUtil.after(DateUtil.parseDate(checkJobVO.getBehosDateStart()),
|
|
|
+ DateUtil.parseDate(checkJobVO.getBehosDateEnd()))) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "出院时间的开始时间必须小于结束时间!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotBlank(checkJobVO.getStartTime())&&StringUtil.isNotBlank(checkJobVO.getEndTime()))
|
|
|
+ {
|
|
|
+ if (DateUtil.after(DateUtil.parseDate(checkJobVO.getStartTime()),
|
|
|
+ DateUtil.parseDate(checkJobVO.getEndTime()))) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "任务生成的开始时间必须小于结束时间!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 获取操作用户的核查科室以及科室核查人员
|
|
|
+ * @Date 2021/5/14
|
|
|
+ * @Param []
|
|
|
+ * @Return java.util.Map<java.lang.String,java.util.List<com.diagbot.dto.CheckDeptDTO>>
|
|
|
+ * @MethodName getCheckUserMap
|
|
|
+ */
|
|
|
+ public Map<String, List<CheckDeptDTO>> getCheckUserMap() {
|
|
|
+
|
|
|
+ //1.获取当前用户对应的管理员角色
|
|
|
+ //获取人员id 和 该人员的医院id
|
|
|
+ Long hospitalId = Long.valueOf(SysUserUtils.getCurrentHospitalID());
|
|
|
+ Long principleId = Long.valueOf(SysUserUtils.getCurrentPrincipleID());
|
|
|
+ //获取核查监管相关角色id
|
|
|
+ List<Long> checkRoleIds = sysRoleFacade.list(new QueryWrapper<SysRole>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .like("name","监管人员")
|
|
|
+ ).stream().map(SysRole::getId).collect(Collectors.toList());
|
|
|
+ //查询该角色的所有角色id
|
|
|
+ List<Long> roleIds = sysUserRoleFacade.list(new QueryWrapper<SysUserRole>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("user_id", principleId)
|
|
|
+ ).stream().distinct().map(SysUserRole::getRoleId).collect(Collectors.toList());
|
|
|
+ List<Long> searchRoleIds = new ArrayList<>();
|
|
|
+ //当前用户是监管人员或者是超级管理员
|
|
|
+ if(roleIds.contains(-1L))
|
|
|
+ {
|
|
|
+ searchRoleIds.addAll(checkRoleIds);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ searchRoleIds.addAll(containsRole(checkRoleIds,roleIds));
|
|
|
+ }
|
|
|
+ if(searchRoleIds.isEmpty())
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该用户不是核查监管人员!");
|
|
|
+ }
|
|
|
+ //2.获取相应角色对应的科室以及核查人员
|
|
|
+ Map<String, List<CheckDeptDTO>> checkUserMap = getCheckRoleMap(searchRoleIds,hospitalId,principleId);
|
|
|
+ return checkUserMap;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 获取相应角色对应的科室以及核查人员
|
|
|
+ * @Date 2021/5/14
|
|
|
+ * @Param [searchRoleIds]
|
|
|
+ * @Return java.util.Map<java.lang.String,java.util.List<java.util.Map<java.lang.String,java.lang.Object>>>
|
|
|
+ * @MethodName getCheckRoleMap
|
|
|
+ */
|
|
|
+
|
|
|
+ private Map<String, List<CheckDeptDTO>> getCheckRoleMap(List<Long> searchRoleIds,Long hospitalId,Long principleId) {
|
|
|
+ Map<String, List<CheckDeptDTO>> checkRoleMap = new HashMap<>();
|
|
|
+ for(Long id:searchRoleIds)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //不同角色不同查询方式
|
|
|
+ switch (id.intValue())
|
|
|
+ {
|
|
|
+ //临床科室监管人员
|
|
|
+ case 4:
|
|
|
+ getDeptCheckInfo(checkRoleMap,hospitalId,principleId);
|
|
|
+ break;
|
|
|
+ //质控科监管人员
|
|
|
+ case 5:
|
|
|
+ getZKKCheckInfo(checkRoleMap,hospitalId,principleId);
|
|
|
+ break;
|
|
|
+ //院级监管人员
|
|
|
+ case 6:
|
|
|
+ getYQCheckInfo(checkRoleMap,hospitalId,principleId);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return checkRoleMap;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 院区管理员获取管理的科室以及科室包涵质控人员
|
|
|
+ * @Date 2021/5/17
|
|
|
+ * @Param [checkRoleMap, hospitalId, principleId]
|
|
|
+ * @Return void
|
|
|
+ * @MethodName getYQCheckInfo
|
|
|
+ */
|
|
|
+ private void getYQCheckInfo(Map<String, List<CheckDeptDTO>> checkRoleMap, Long hospitalId, Long principleId) {
|
|
|
+ //1.获取院级质控人员有哪些
|
|
|
+ //1.1获取院级质控人员角色id
|
|
|
+ Long roleId = sysRoleFacade.getOne(new QueryWrapper<SysRole>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("name","院级质控人员")).getId();
|
|
|
+ CheckUserVO checkUserVOS = new CheckUserVO();
|
|
|
+ checkUserVOS.setRoleIds(Lists.newArrayList(roleId));
|
|
|
+ checkUserVOS.setDeptStations(Lists.newArrayList("住院"));
|
|
|
+ checkUserVOS.setUserId(principleId);
|
|
|
+ checkUserVOS.setRoleId(6L);
|
|
|
+ checkUserVOS.setHospitalId(hospitalId);
|
|
|
+ List<CheckUserDTO> checkUserDTOS = baseMapper.getCheckUser(checkUserVOS);
|
|
|
+ //2.1获取科室详情
|
|
|
+ Map<String,String> deptMap = checkUserDTOS.stream()
|
|
|
+ .collect(Collectors.toMap(CheckUserDTO::getDeptId,CheckUserDTO::getDeptName, (v1, v2) -> v2));
|
|
|
+ //2.3获取所有医生信息的核查数
|
|
|
+ List<String> doctorIds = checkUserDTOS.stream().map(CheckUserDTO::getDoctorId).collect(Collectors.toList());
|
|
|
+ CheckUserVO checkUserVO = new CheckUserVO();
|
|
|
+ checkUserVO.setJobType(1);
|
|
|
+ checkUserVO.setUserList(doctorIds);
|
|
|
+ //通过核查人员id获取核查人员的核查任务数
|
|
|
+ List<DeptCheckUserDTO> userJobs = baseMapper.getJobNumByUserId(checkUserVO);
|
|
|
+ addCheckInfoMaps(checkRoleMap,deptMap,userJobs,checkUserDTOS,6);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 质控科管理员获取管理的科室以及科室包涵质控人员
|
|
|
+ * @Date 2021/5/17
|
|
|
+ * @Param [checkRoleMap, hospitalId, principleId]
|
|
|
+ * @Return void
|
|
|
+ * @MethodName getZKKCheckInfo
|
|
|
+ */
|
|
|
+ private void getZKKCheckInfo(Map<String, List<CheckDeptDTO>> checkRoleMap, Long hospitalId, Long principleId) {
|
|
|
+ //1.获取质控科id
|
|
|
+ String zkkDeptId = basDeptInfoFacade.getOne(new QueryWrapper<BasDeptInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .like("dept_name","质管科")).getDeptId();
|
|
|
+ if(StringUtil.isBlank(zkkDeptId))
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "科室质管科不存在!");
|
|
|
+ }
|
|
|
+ //2.获取监管人员所在科室集合
|
|
|
+ List<String> deptIds = sysUserDeptFacade.list(new QueryWrapper<SysUserDept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .eq("user_id",principleId)
|
|
|
+ ).stream().map(SysUserDept::getDeptId).collect(Collectors.toList());
|
|
|
+ //3.判断这个人是否在质控科
|
|
|
+ if(deptIds.contains(zkkDeptId))
|
|
|
+ {
|
|
|
+ CheckUserVO checkUserVOS = new CheckUserVO();
|
|
|
+ checkUserVOS.setRoleIds(Lists.newArrayList(7L,8L,9L));
|
|
|
+ checkUserVOS.setDeptStations(Lists.newArrayList("住院","质管"));
|
|
|
+ checkUserVOS.setUserId(principleId);
|
|
|
+ checkUserVOS.setRoleId(5L);
|
|
|
+ checkUserVOS.setHospitalId(hospitalId);
|
|
|
+ List<CheckUserDTO> checkUserDTOS = baseMapper.getCheckUser(checkUserVOS);
|
|
|
+ //2.1获取科室详情
|
|
|
+ Map<String,String> deptMap = checkUserDTOS.stream()
|
|
|
+ .collect(Collectors.toMap(CheckUserDTO::getDeptId,CheckUserDTO::getDeptName, (v1, v2) -> v2));
|
|
|
+ //2.3获取所有医生信息的核查数
|
|
|
+ List<String> doctorIds = checkUserDTOS.stream().map(CheckUserDTO::getDoctorId).collect(Collectors.toList());
|
|
|
+ CheckUserVO checkUserVO = new CheckUserVO();
|
|
|
+ checkUserVO.setJobType(2);
|
|
|
+ checkUserVO.setUserList(doctorIds);
|
|
|
+ //通过核查人员id获取核查人员的核查任务数
|
|
|
+ List<DeptCheckUserDTO> userJobs = baseMapper.getJobNumByUserId(checkUserVO);
|
|
|
+ addCheckInfoMaps(checkRoleMap,deptMap,userJobs,checkUserDTOS,5);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 临床科室管理员获取管理的科室以及科室包涵质控人员
|
|
|
+ * @Date 2021/5/17
|
|
|
+ * @Param [checkRoleMap, hospitalId, principleId]
|
|
|
+ * @Return void
|
|
|
+ * @MethodName getDeptCheckInfo
|
|
|
+ */
|
|
|
+ private void getDeptCheckInfo(Map<String, List<CheckDeptDTO>> checkRoleMap, Long hospitalId, Long principleId) {
|
|
|
+
|
|
|
+ //1.获取监管人员所在科室集合
|
|
|
+ List<String> deptIds = sysUserDeptFacade.list(new QueryWrapper<SysUserDept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .eq("user_id",principleId)
|
|
|
+ ).stream().map(SysUserDept::getDeptId).collect(Collectors.toList());
|
|
|
+ if(deptIds.isEmpty()){return;}
|
|
|
+ CheckUserVO checkUserVOS = new CheckUserVO();
|
|
|
+ checkUserVOS.setRoleIds(Lists.newArrayList(4L,7L));
|
|
|
+ checkUserVOS.setDeptIds(deptIds);
|
|
|
+ checkUserVOS.setDeptStations(Lists.newArrayList("住院"));
|
|
|
+ checkUserVOS.setHospitalId(hospitalId);
|
|
|
+ List<CheckUserDTO> checkUserDTOS = baseMapper.getCheckUser(checkUserVOS);
|
|
|
+ //2.1获取科室详情
|
|
|
+ Map<String,String> deptMap = checkUserDTOS.stream()
|
|
|
+ .collect(Collectors.toMap(CheckUserDTO::getDeptId,CheckUserDTO::getDeptName, (v1, v2) -> v2));
|
|
|
+ //2.3获取所有医生信息的核查数
|
|
|
+ List<String> doctorIds = checkUserDTOS.stream().map(CheckUserDTO::getDoctorId).collect(Collectors.toList());
|
|
|
+ CheckUserVO checkUserVO = new CheckUserVO();
|
|
|
+ checkUserVO.setJobType(0);
|
|
|
+ checkUserVO.setUserList(doctorIds);
|
|
|
+ //通过核查人员id获取核查人员的核查任务数
|
|
|
+ List<DeptCheckUserDTO> userJobs = baseMapper.getJobNumByUserId(checkUserVO);
|
|
|
+ addCheckInfoMaps(checkRoleMap,deptMap,userJobs,checkUserDTOS,4);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 拼装科室、核查人员、任务数对象
|
|
|
+ * @Date 2021/5/17
|
|
|
+ * @Param [checkRoleMap, doctorInfos, userJobs, deptInfos, roleId]
|
|
|
+ * @Return void
|
|
|
+ * @MethodName addCheckInfoMap
|
|
|
+ */
|
|
|
+ private void addCheckInfoMaps(Map<String, List<CheckDeptDTO>> checkRoleMap, Map<String, String> deptMap,
|
|
|
+ List<DeptCheckUserDTO> userJobs, List<CheckUserDTO> checkUserDTOS, int roleId) {
|
|
|
+ if(deptMap.isEmpty()||checkUserDTOS.isEmpty()){}
|
|
|
+ checkRoleMap.put(roleId+"",new ArrayList<CheckDeptDTO>());
|
|
|
+ //遍历科室
|
|
|
+ for(String deptId:deptMap.keySet())
|
|
|
+ {
|
|
|
+ //科室对象
|
|
|
+ CheckDeptDTO checkDeptDTO = new CheckDeptDTO();
|
|
|
+ checkDeptDTO.setDeptId(deptId);
|
|
|
+ checkDeptDTO.setDeptName(deptMap.get(deptId));
|
|
|
+ checkDeptDTO.setDeptcheckUsers(new ArrayList<DeptCheckUserDTO>());
|
|
|
+ //遍历医生
|
|
|
+ for(CheckUserDTO checkUserDTO:checkUserDTOS)
|
|
|
+ {
|
|
|
+ //同一科室
|
|
|
+ if(checkDeptDTO.getDeptId().equals(checkUserDTO.getDeptId()))
|
|
|
+ {
|
|
|
+ DeptCheckUserDTO deptCheckUserDTO = new DeptCheckUserDTO();
|
|
|
+ deptCheckUserDTO.setDeptId(checkUserDTO.getDeptId());
|
|
|
+ deptCheckUserDTO.setDeptName(checkUserDTO.getDeptName());
|
|
|
+ deptCheckUserDTO.setDoctorId(checkUserDTO.getDoctorId());
|
|
|
+ deptCheckUserDTO.setDoctorName(checkUserDTO.getDoctorName());
|
|
|
+ checkDeptDTO.getDeptcheckUsers().add(deptCheckUserDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(DeptCheckUserDTO deptCheckUserDTO:checkDeptDTO.getDeptcheckUsers())
|
|
|
+ {
|
|
|
+ //遍历数量
|
|
|
+ for(DeptCheckUserDTO jobNumDto:userJobs)
|
|
|
+ {
|
|
|
+ //有这个人
|
|
|
+ if(deptCheckUserDTO.getDoctorId().equals(jobNumDto.getDoctorId()))
|
|
|
+ {
|
|
|
+ deptCheckUserDTO.setJobNum(jobNumDto.getJobNum());
|
|
|
+ }
|
|
|
+ //没有这个人
|
|
|
+ else
|
|
|
+ {
|
|
|
+ deptCheckUserDTO.setJobNum(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ checkRoleMap.get(roleId+"").add(checkDeptDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 拼装科室、核查人员、任务数对象
|
|
|
+ * @Date 2021/5/17
|
|
|
+ * @Param [checkRoleMap, doctorInfos, userJobs, deptInfos, roleId]
|
|
|
+ * @Return void
|
|
|
+ * @MethodName addCheckInfoMap
|
|
|
+ */
|
|
|
+ private void addCheckInfoMap(Map<String, List<CheckDeptDTO>> checkRoleMap, List<BasDoctorInfo> doctorInfos,
|
|
|
+ List<DeptCheckUserDTO> userJobs, List<BasDeptInfo> deptInfos, int roleId) {
|
|
|
+ if(deptInfos.isEmpty()||doctorInfos.isEmpty()){}
|
|
|
+ checkRoleMap.put(roleId+"",new ArrayList<CheckDeptDTO>());
|
|
|
+ //遍历科室
|
|
|
+ for(BasDeptInfo deptInfo:deptInfos)
|
|
|
+ {
|
|
|
+ //科室对象
|
|
|
+ CheckDeptDTO checkDeptDTO = new CheckDeptDTO();
|
|
|
+ checkDeptDTO.setDeptId(deptInfo.getDeptId());
|
|
|
+ checkDeptDTO.setDeptName(deptInfo.getDeptName());
|
|
|
+ checkDeptDTO.setDeptcheckUsers(new ArrayList<DeptCheckUserDTO>());
|
|
|
+ //遍历医生
|
|
|
+ for(BasDoctorInfo doctorInfo:doctorInfos)
|
|
|
+ {
|
|
|
+ //同一科室
|
|
|
+ if(checkDeptDTO.getDeptId().equals(doctorInfo.getDeptId()))
|
|
|
+ {
|
|
|
+ DeptCheckUserDTO deptCheckUserDTO = new DeptCheckUserDTO();
|
|
|
+ deptCheckUserDTO.setDeptId(doctorInfo.getDeptId());
|
|
|
+ deptCheckUserDTO.setDeptName(deptInfo.getDeptName());
|
|
|
+ deptCheckUserDTO.setDoctorId(doctorInfo.getDoctorId());
|
|
|
+ deptCheckUserDTO.setDoctorName(doctorInfo.getName());
|
|
|
+ checkDeptDTO.getDeptcheckUsers().add(deptCheckUserDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(DeptCheckUserDTO deptCheckUserDTO:checkDeptDTO.getDeptcheckUsers())
|
|
|
+ {
|
|
|
+ //遍历数量
|
|
|
+ for(DeptCheckUserDTO jobNumDto:userJobs)
|
|
|
+ {
|
|
|
+ //有这个人
|
|
|
+ if(deptCheckUserDTO.getDoctorId().equals(jobNumDto.getDoctorId()))
|
|
|
+ {
|
|
|
+ deptCheckUserDTO.setJobNum(jobNumDto.getJobNum());
|
|
|
+ }
|
|
|
+ //没有这个人
|
|
|
+ else
|
|
|
+ {
|
|
|
+ deptCheckUserDTO.setJobNum(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ checkRoleMap.get(roleId+"").add(checkDeptDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description list求交集
|
|
|
+ * @Date 2021/5/14
|
|
|
+ * @Param [checkRoleIds, roleIds]
|
|
|
+ * @Return java.util.List<java.lang.Long>
|
|
|
+ * @MethodName containsRole
|
|
|
+ */
|
|
|
+ private List<Long> containsRole(List<Long> checkRoleIds, List<Long> roleIds) {
|
|
|
+
|
|
|
+ List<Long> searchRoleIds = new ArrayList<>();
|
|
|
+ for(Long id:roleIds)
|
|
|
+ {
|
|
|
+ if(checkRoleIds.contains(id))
|
|
|
+ {
|
|
|
+ searchRoleIds.add(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return searchRoleIds;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 分配/取消核查任务
|
|
|
+ * @Date 2021/5/17
|
|
|
+ * @Param [distributionJobVO]
|
|
|
+ * @Return boolean
|
|
|
+ * @MethodName distributionJobs
|
|
|
+ */
|
|
|
+ public boolean distributionJobs(DistributionJobVO distributionJobVO) {
|
|
|
+
|
|
|
+ //1非空校验
|
|
|
+ if(StringUtil.isBlank(distributionJobVO.getCheckId())||
|
|
|
+ StringUtil.isBlank(distributionJobVO.getCheckName())||
|
|
|
+ StringUtil.isBlank(distributionJobVO.getDistributionType())||
|
|
|
+ distributionJobVO.getBehospitalCodes()==null||
|
|
|
+ distributionJobVO.getBehospitalCodes().isEmpty())
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL,"入参为空");
|
|
|
+ }
|
|
|
+ //获取人员id 和 该人员的医院id
|
|
|
+ Long hospitalId = Long.valueOf(SysUserUtils.getCurrentHospitalID());
|
|
|
+ Long principleId = Long.valueOf(SysUserUtils.getCurrentPrincipleID());
|
|
|
+ //2.获取任务类型 0分配 1取消
|
|
|
+ String distributionType = distributionJobVO.getDistributionType();
|
|
|
+ //3 分配
|
|
|
+ if(StringUtil.isNotBlank(distributionType)&&"0".equals(distributionType))
|
|
|
+ {
|
|
|
+ //3.1 任务未分配校验
|
|
|
+ List<String> distributionNames = this.list(new QueryWrapper<MedCheckInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .in("behospital_code",distributionJobVO.getBehospitalCodes())
|
|
|
+ ).stream().filter(s-> s.getJobDistributionName() !=null).map(MedCheckInfo::getJobDistributionName)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if(distributionNames!=null&&distributionNames.size()>0)
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "待分配任务列表存在已分配任务!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取分配用户信息
|
|
|
+ QueryWrapper<SysUser> userQuer = new QueryWrapper<>();
|
|
|
+ userQuer.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("id",principleId)
|
|
|
+ .eq("status",1);
|
|
|
+ SysUser user = sysUserFacade.getOne(userQuer);
|
|
|
+ String principleName = user.getLinkman();
|
|
|
+ //用户名称如果是null(目的:分配用户名为null表示用户未分配)
|
|
|
+ if(principleName==null){principleName = "";}
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ //3.2分配核查任务
|
|
|
+ return this.update(new UpdateWrapper<MedCheckInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", hospitalId)
|
|
|
+ .in("behospital_code", distributionJobVO.getBehospitalCodes())
|
|
|
+ .set("job_distributor", principleId)
|
|
|
+ .set("job_distribution_name", principleName)
|
|
|
+ .set("check_id", distributionJobVO.getCheckId())
|
|
|
+ .set("check_name", distributionJobVO.getCheckName())
|
|
|
+ .set("job_distribution_time", now));
|
|
|
+
|
|
|
+ }
|
|
|
+ //4 取消分配
|
|
|
+ else if(StringUtil.isNotBlank(distributionType)&&"1".equals(distributionType))
|
|
|
+ {
|
|
|
+ //4.1 任务已取消校验
|
|
|
+ Set<Long> checkIds = this.list(new QueryWrapper<MedCheckInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .in("behospital_code",distributionJobVO.getBehospitalCodes())
|
|
|
+ ).stream().map(MedCheckInfo::getCheckId).collect(Collectors.toSet());
|
|
|
+ //4.2获取出来的核查用户存在但不是一个
|
|
|
+ if(checkIds==null||checkIds.isEmpty()||
|
|
|
+ (checkIds.size()!=1&&checkIds.contains(distributionJobVO.getCheckId())))
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "待取消分配任务列表不存在或存在不是该用户的任务!");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ //4.3取消分配
|
|
|
+ return this.update(new UpdateWrapper<MedCheckInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", hospitalId)
|
|
|
+ .eq("check_id", distributionJobVO.getCheckId())
|
|
|
+ .in("behospital_code", distributionJobVO.getBehospitalCodes())
|
|
|
+ .set("job_distributor",-1)
|
|
|
+ .set("job_distribution_name", null)
|
|
|
+ .set("check_id", -1)
|
|
|
+ .set("check_name", "")
|
|
|
+ .set("job_distribution_time", now));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 获取指定核查人员的核查任务
|
|
|
+ * @Date 2021/5/17
|
|
|
+ * @Param [checkJobVO]
|
|
|
+ * @Return java.util.List<com.diagbot.dto.CheckJobDTO>
|
|
|
+ * @MethodName getCheckListByUserId
|
|
|
+ */
|
|
|
+ public List<CheckJobDTO> getCheckListByUserId(CheckJobVO checkJobVO) {
|
|
|
+ //非空校验
|
|
|
+ if(StringUtil.isBlank(checkJobVO.getCheckId()))
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "没有传核查用户id!");
|
|
|
+ }
|
|
|
+ return baseMapper.getCheckListByUserId(checkJobVO);
|
|
|
+ }
|
|
|
}
|