|
@@ -1,5 +1,6 @@
|
|
|
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.diagbot.dto.CheckDeptDTO;
|
|
@@ -8,6 +9,7 @@ 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;
|
|
@@ -21,6 +23,7 @@ import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.util.SysUserUtils;
|
|
|
import com.diagbot.vo.CheckJobVO;
|
|
|
import com.diagbot.vo.CheckUserVO;
|
|
|
+import com.diagbot.vo.DistributionJobVO;
|
|
|
import com.diagbot.vo.MedCheckInfoAddVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -28,8 +31,10 @@ 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;
|
|
|
|
|
|
/**
|
|
@@ -142,31 +147,76 @@ public class MedCheckInfoFacade extends MedCheckInfoServiceImpl {
|
|
|
* @MethodName getCheckUserMap
|
|
|
*/
|
|
|
public List<CheckJobDTO> getUserCheckList(CheckJobVO 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(checkJobVO.getDeptList()==null||checkJobVO.getDeptList().isEmpty())
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "没有传科室列表!");
|
|
|
+ }
|
|
|
+
|
|
|
//质控管理员要判断该角色是否是质控科
|
|
|
//1.获取质控科id
|
|
|
//获取人员id 和 该人员的医院id
|
|
|
Long hospitalId = Long.valueOf(SysUserUtils.getCurrentHospitalID());
|
|
|
Long principleId = Long.valueOf(SysUserUtils.getCurrentPrincipleID());
|
|
|
- String zkkDeptId = basDeptInfoFacade.getOne(new QueryWrapper<BasDeptInfo>()
|
|
|
+ //获取核查监管相关角色id
|
|
|
+ List<Long> checkRoleIds = sysRoleFacade.list(new QueryWrapper<SysRole>()
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("hospital_id",hospitalId)
|
|
|
- .like("dept_name","质管科")).getDeptId();
|
|
|
- if(StringUtil.isBlank(zkkDeptId))
|
|
|
+ .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))
|
|
|
{
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "科室质管科不存在!");
|
|
|
+ searchRoleIds.addAll(checkRoleIds);
|
|
|
}
|
|
|
- //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))
|
|
|
+ else{
|
|
|
+ searchRoleIds.addAll(containsRole(checkRoleIds,roleIds));
|
|
|
+ }
|
|
|
+ if(searchRoleIds.isEmpty())
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该用户不是核查监管人员!");
|
|
|
+ }
|
|
|
+ //质控科监管人员
|
|
|
+ if(searchRoleIds.contains(5L)&&"2".equals(checkJobVO.getCheckType()))
|
|
|
+ {
|
|
|
+ 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 baseMapper.getCheckList(checkJobVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //临床科室监管人员、院级监管人员
|
|
|
+ else if(searchRoleIds.contains(4L)&&"0".equals(checkJobVO.getCheckType())||
|
|
|
+ searchRoleIds.contains(6L)&&"1".equals(checkJobVO.getCheckType()))
|
|
|
{
|
|
|
return baseMapper.getCheckList(checkJobVO);
|
|
|
}
|
|
|
- return null;
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
/**
|
|
|
* @Author songxl
|
|
@@ -426,4 +476,118 @@ public class MedCheckInfoFacade extends MedCheckInfoServiceImpl {
|
|
|
}
|
|
|
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();
|
|
|
+ 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.getStartTime())&&StringUtil.isBlank(checkJobVO.getEndTime())
|
|
|
+ &&StringUtil.isBlank(checkJobVO.getBehosDateStart())&&StringUtil.isBlank(checkJobVO.getBehosDateEnd()))
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "没有时间区间!");
|
|
|
+ }
|
|
|
+ if(StringUtil.isBlank(checkJobVO.getCheckId()))
|
|
|
+ {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "没有传核查用户id!");
|
|
|
+ }
|
|
|
+ return baseMapper.getCheckListByUserId(checkJobVO);
|
|
|
+ }
|
|
|
}
|