|
@@ -2,21 +2,33 @@ package com.diagbot.facade;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.diagbot.dto.CheckDeptDTO;
|
|
|
+import com.diagbot.dto.DeptCheckUserDTO;
|
|
|
+import com.diagbot.entity.BasDeptInfo;
|
|
|
+import com.diagbot.entity.BasDoctorInfo;
|
|
|
import com.diagbot.entity.MedCheckInfo;
|
|
|
+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.StringUtil;
|
|
|
import com.diagbot.util.SysUserUtils;
|
|
|
+import com.diagbot.vo.CheckUserVO;
|
|
|
import com.diagbot.vo.MedCheckInfoAddVO;
|
|
|
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.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author wangfeng
|
|
@@ -28,6 +40,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 +131,254 @@ 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 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)
|
|
|
+// .in("role_id",checkRoleIds)
|
|
|
+ ).stream().distinct().map(SysUserRole::getRoleId).collect(Collectors.toList());
|
|
|
+ List<Long> searchRoleIds = new ArrayList<>();
|
|
|
+ //当前用户是监管人员或者是超级管理员
|
|
|
+ if(roleIds.contains(-1))
|
|
|
+ {
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ //不同角色不同查询方式
|
|
|
+ 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;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return checkRoleMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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();
|
|
|
+ //1.2获取院级质控人员该角色的用户id集合
|
|
|
+ List<Long> userIds = sysUserRoleFacade.list(new QueryWrapper<SysUserRole>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("role_id",roleId)
|
|
|
+ ).stream().map(SysUserRole::getUserId).collect(Collectors.toList());
|
|
|
+ //1.3获取该用户id集合的科室id集合
|
|
|
+ List<String> deptIds = sysUserDeptFacade.list(new QueryWrapper<SysUserDept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .in("user_id",userIds)
|
|
|
+ ).stream().map(SysUserDept::getDeptId).collect(Collectors.toList());
|
|
|
+ //2.1获取质控人员的科室信息
|
|
|
+ List<BasDeptInfo> deptInfos = basDeptInfoFacade.list(new QueryWrapper<BasDeptInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .in("dept_id",deptIds));
|
|
|
+ //2.2获取监管科室集合所有的医生信息
|
|
|
+ List<BasDoctorInfo> doctorInfos = basDoctorInfoFacade.list(new QueryWrapper<BasDoctorInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .in("dept_id",deptIds));
|
|
|
+ //2.3获取所有医生信息的核查数
|
|
|
+ List<String> doctorIds = doctorInfos.stream().map(BasDoctorInfo::getDoctorId).collect(Collectors.toList());
|
|
|
+ CheckUserVO checkUserVO = new CheckUserVO();
|
|
|
+ checkUserVO.setJobType(1);
|
|
|
+ checkUserVO.setUserList(doctorIds);
|
|
|
+ //通过核查人员id获取核查人员的核查任务数
|
|
|
+ List<DeptCheckUserDTO> userJobs = this.getJobNumByUserId(checkUserVO);
|
|
|
+ addCheckInfoMap(checkRoleMap,doctorInfos,userJobs,deptInfos,6);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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))
|
|
|
+ {
|
|
|
+ //4.1获取所有科室
|
|
|
+ List<BasDeptInfo> deptInfos = basDeptInfoFacade.list(new QueryWrapper<BasDeptInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId));
|
|
|
+ //4.2获取所有医生信息
|
|
|
+ List<BasDoctorInfo> doctorInfos = basDoctorInfoFacade.list(new QueryWrapper<BasDoctorInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId));
|
|
|
+ //4.3获取所有医生信息的核查数
|
|
|
+ List<String> doctorIds = doctorInfos.stream().map(BasDoctorInfo::getDoctorId).collect(Collectors.toList());
|
|
|
+ CheckUserVO checkUserVO = new CheckUserVO();
|
|
|
+ checkUserVO.setJobType(2);
|
|
|
+ checkUserVO.setUserList(doctorIds);
|
|
|
+ //通过核查人员id获取核查人员的核查任务数
|
|
|
+ List<DeptCheckUserDTO> userJobs = this.getJobNumByUserId(checkUserVO);
|
|
|
+ addCheckInfoMap(checkRoleMap,doctorInfos,userJobs,deptInfos,5);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 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());
|
|
|
+ //2.1获取科室详情
|
|
|
+ List<BasDeptInfo> deptInfos = basDeptInfoFacade.list(new QueryWrapper<BasDeptInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .in("dept_id",deptIds));
|
|
|
+ //2.2获取监管科室集合所有的医生信息
|
|
|
+ List<BasDoctorInfo> doctorInfos = basDoctorInfoFacade.list(new QueryWrapper<BasDoctorInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id",hospitalId)
|
|
|
+ .in("dept_id",deptIds));
|
|
|
+ //2.3获取所有医生信息的核查数
|
|
|
+ List<String> doctorIds = doctorInfos.stream().map(BasDoctorInfo::getDoctorId).collect(Collectors.toList());
|
|
|
+ CheckUserVO checkUserVO = new CheckUserVO();
|
|
|
+ checkUserVO.setJobType(0);
|
|
|
+ checkUserVO.setUserList(doctorIds);
|
|
|
+ //通过核查人员id获取核查人员的核查任务数
|
|
|
+ List<DeptCheckUserDTO> userJobs = this.getJobNumByUserId(checkUserVO);
|
|
|
+ addCheckInfoMap(checkRoleMap,doctorInfos,userJobs,deptInfos,4);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ System.out.println(checkRoleMap.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @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;
|
|
|
+ }
|
|
|
}
|