Переглянути джерело

义乌核查分配相关接口提交

songxinlu 4 роки тому
батько
коміт
74d479410b

+ 2 - 0
src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -236,6 +236,8 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/qc/behospitalInfo/logicDelCase").permitAll()
                 .antMatchers("/qc/medCheckInfo/getCheckUserMap").permitAll()
                 .antMatchers("/qc/medCheckInfo/getCheckList").permitAll()
+                .antMatchers("/qc/medCheckInfo//updateDistributionCheck").permitAll()
+                .antMatchers("/qc/medCheckInfo//getCheckListByUserId").permitAll()
                 .antMatchers("/**").authenticated();
         //                .antMatchers("/**").permitAll();
     }

+ 2 - 0
src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -280,6 +280,8 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/qc/behospitalInfo/logicDelCase", request)
                 || matchers("/qc/medCheckInfo/getCheckUserMap", request)
                 || matchers("/qc/medCheckInfo/getCheckList", request)
+                || matchers("/qc/medCheckInfo//updateDistributionCheck", request)
+                || matchers("/qc/medCheckInfo//getCheckListByUserId", request)
                 || matchers("/", request)) {
             return true;
         }

+ 2 - 0
src/main/java/com/diagbot/dto/CheckJobDTO.java

@@ -11,6 +11,8 @@ import lombok.Setter;
 @Getter
 @Setter
 public class CheckJobDTO {
+    //核查任务id
+    private int id;
     //病人住院序号
     private String behospitalCode;
     //病人姓名

+ 178 - 14
src/main/java/com/diagbot/facade/MedCheckInfoFacade.java

@@ -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);
+    }
 }

+ 1 - 1
src/main/java/com/diagbot/facade/MedCheckWorkFacade.java

@@ -54,7 +54,7 @@ public class MedCheckWorkFacade {
                 break;
         }
 
-        List<MedCheckWork> checkWorkList = new ArrayList<>();
+//        List<MedCheckWork> checkWorkList = new ArrayList<>();
 
 //        return medCheckWorkServiceImpl.saveBatch(checkWorkList, 10);
         return null;

+ 2 - 0
src/main/java/com/diagbot/mapper/MedCheckInfoMapper.java

@@ -32,4 +32,6 @@ public interface MedCheckInfoMapper extends BaseMapper<MedCheckInfo> {
      * @return
      */
     IPage<CheckWorkDTO> getCheckWorkPage(CheckWorkPageVO checkWorkPageVO);
+    //获取指定核查人员的核查任务
+    List<CheckJobDTO> getCheckListByUserId(CheckJobVO checkJobVO);
 }

+ 0 - 1
src/main/java/com/diagbot/service/impl/MedCheckInfoServiceImpl.java

@@ -24,5 +24,4 @@ import java.util.List;
 public class MedCheckInfoServiceImpl extends ServiceImpl<MedCheckInfoMapper, MedCheckInfo> implements MedCheckInfoService {
 
 
-
 }

+ 6 - 0
src/main/java/com/diagbot/vo/CheckJobVO.java

@@ -15,8 +15,14 @@ public class CheckJobVO {
     private String startTime;
     //生成任务结束时间
     private String endTime;
+    //出院开始时间
+    private String behosDateStart;
+    //出院结束时间
+    private String behosDateEnd;
     //任务类型
     private String checkType;
+    //核查用户id
+    private String checkId;
     //病人姓名
     private String name;
     //病人住院序号

+ 29 - 0
src/main/java/com/diagbot/vo/DistributionJobVO.java

@@ -0,0 +1,29 @@
+package com.diagbot.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @description: 分配核查任务入参对象
+ * @author: songxl
+ * @time: 2021/05/17
+ */
+@Data
+public class DistributionJobVO {
+    //病人住院序号集合
+    private List<String> behospitalCodes;
+    //医院id
+    private String hospitalId;
+    //分配用户id
+    private String jobDistributor;
+    //核查用户id
+    private String checkId;
+    //核查用户姓名
+    private String checkName;
+    //操作类型 分配或取消 0-分配,1-取消分配分配或取消 0-分配,1-取消分配
+    private String distributionType;
+
+
+
+}

+ 30 - 0
src/main/java/com/diagbot/web/MedCheckInfoController.java

@@ -7,6 +7,7 @@ import com.diagbot.dto.CheckJobDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.MedCheckInfoFacade;
 import com.diagbot.vo.CheckJobVO;
+import com.diagbot.vo.DistributionJobVO;
 import com.diagbot.vo.MedCheckInfoAddVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -62,6 +63,9 @@ public class MedCheckInfoController {
     @ApiOperation(value = "分配核查任务--获取待分配核查任务列表[by:songxl]",
             notes = "startTime:任务生成开始时间 必填<br>" +
                     "endTime:  任务生成结束时间 必填<br>" +
+                    "或<br>" +
+                    "behosDateStart:  出院开始时间 必填<br>" +
+                    "behosDateEnd:  出院结束时间 必填<br>" +
                     "checkType:核查类型 必填 0-科室任务 1-院级 2-质控科<br>" +
                     "deptList:科室id集合,必填<br>")
     @PostMapping("/getCheckList")
@@ -70,4 +74,30 @@ public class MedCheckInfoController {
         List<CheckJobDTO> userInfos = medCheckInfoFacade.getUserCheckList(checkJobVO);
         return RespDTO.onSuc(userInfos);
     }
+
+    @ApiOperation(value = "分配核查任务--分配/取消核查任务[by:songxl]",
+            notes = "behospitalCodes:病人住院序号集合 必填<br>" +
+                    "checkId:  核查用户id 必填<br>" +
+                    "checkName:  核查用户姓名 必填<br>" +
+                    "checkType:操作类型 必填 分配或取消 0-分配,1-取消分配<br>")
+    @PostMapping("/updateDistributionCheck")
+    @SysLogger("getCheckList")
+    public RespDTO<Boolean> distributionJobs(@RequestBody DistributionJobVO distributionJobVO) {
+        return RespDTO.onSuc(medCheckInfoFacade.distributionJobs(distributionJobVO));
+    }
+
+
+    @ApiOperation(value = "分配核查任务--获取指定核查人员的核查任务[by:songxl]",
+            notes = "startTime:任务生成开始时间 必填<br>" +
+                    "endTime:  任务生成结束时间 必填<br>" +
+                    "或<br>" +
+                    "behosDateStart:  出院开始时间 必填<br>" +
+                    "behosDateEnd:  出院结束时间 必填<br>" +
+                    "checkId:核查用户id")
+    @PostMapping("/getCheckListByUserId")
+    @SysLogger("getCheckListByUserId")
+    public RespDTO<List<CheckJobDTO>> getCheckListByUserId(@RequestBody CheckJobVO checkJobVO) {
+        List<CheckJobDTO> userInfos = medCheckInfoFacade.getCheckListByUserId(checkJobVO);
+        return RespDTO.onSuc(userInfos);
+    }
 }

+ 33 - 9
src/main/resources/mapper/MedCheckInfoMapper.xml

@@ -27,36 +27,39 @@
     </resultMap>
     <!--通过核查人员id获取核查人员的核查任务数-->
     <select id="getJobNumByUserId" resultType="com.diagbot.dto.DeptCheckUserDTO">
-        SELECT job_distributor doctorId, count(*) as jobNum
+        SELECT check_id doctorId, count(*) as jobNum
         from med_check_info
-        where is_deleted = 'N'
+        where is_deleted = 'N' and job_distribution_name is not null
         <if test="jobType != null">
             and job_type = #{jobType}
         </if>
         <if test="userList !=null">
-            and job_distributor in
+            and check_id in
             <foreach collection="userList" item="item" open="(" close=")" separator=",">
                 #{item}
             </foreach>
         </if>
-        GROUP BY job_distributor
+        GROUP BY check_id
     </select>
 
     <!--获取待分配核查任务列表-->
     <select id="getCheckList" resultType="com.diagbot.dto.CheckJobDTO">
         SELECT a.behospital_code behospitalCode,a.beh_dept_name behospitalDept,
         a.doctor_name attendingDoctor,a.leave_hospital_date leaveHospitalDate,
-        a.`name`,b.`value` from
+        a.`name`,b.`value`,a.id from
         (select a.behospital_code,a.`name`,a.beh_dept_name,a.doctor_name,a.leave_hospital_date,a.hospital_id,
-            a.beh_dept_id from med_behospital_info a ,med_check_info b
+            a.beh_dept_id,b.id from med_behospital_info a ,med_check_info b
               where a.behospital_code = b.behospital_code and a.hospital_id = b.hospital_id and a.is_deleted = 'N'
-                and b.is_deleted = 'N' and b.job_distributor is NULL  and b.check_type = 0
+                and b.is_deleted = 'N' and b.job_distribution_name is NULL  and b.`status` = 0
                 <if test="checkType !=null">
                     and b.job_type = #{checkType}
                 </if>
                 <if test="startTime !=null and endTime !=null">
                     and b.job_create_time BETWEEN #{startTime} AND #{endTime}
                 </if>
+                <if test="behosDateStart !=null and behosDateEnd !=null">
+                    and a.leave_hospital_date BETWEEN #{behosDateStart} AND #{behosDateEnd}
+                </if>
                 <if test="name !=null">
                     and a.doctor_name = #{name}
                 </if>
@@ -66,26 +69,44 @@
                 <if test="name !=null">
                     and a.`name` LIKE CONCAT('%',#{name},'%')
                 </if>
-                <if test="deptList !=null and job_type =0">
+                <if test="deptList !=null and checkType ==0">
                     and a.beh_dept_id in
                     <foreach collection="deptList" item="item" open="(" close=")" separator=",">
                         #{item}
                     </foreach>
                 </if>
-                <if test="deptList !=null and job_type =1">
+                <if test="deptList !=null and checkType ==1">
                     and a.beh_dept_id not in
                     <foreach collection="deptList" item="item" open="(" close=")" separator=",">
                         #{item}
                     </foreach>
                 </if>
 
         ) a LEFT JOIN med_behospital_type b on a.behospital_code = b.behospital_code
         and a.hospital_id = b.hospital_id and b.is_deleted = 'N' ORDER BY b.`value` DESC ,a.leave_hospital_date DESC
     </select>
 
+
+    <!--获取指定核查人员的核查任务-->
+    <select id="getCheckListByUserId" resultType="com.diagbot.dto.CheckJobDTO">
+        SELECT a.behospital_code behospitalCode,a.beh_dept_name behospitalDept,
+        a.doctor_name attendingDoctor,a.leave_hospital_date leaveHospitalDate,
+        a.`name`,b.`value`,a.id from
+        (select a.behospital_code,a.`name`,a.beh_dept_name,a.doctor_name,a.leave_hospital_date,a.hospital_id,
+        a.beh_dept_id,b.id from med_behospital_info a ,med_check_info b
+        where a.behospital_code = b.behospital_code and a.hospital_id = b.hospital_id and a.is_deleted = 'N'
+        and b.is_deleted = 'N'
+        <if test="startTime !=null and endTime !=null">
+            and b.job_create_time BETWEEN #{startTime} AND #{endTime}
+        </if>
+        <if test="behosDateStart !=null and behosDateEnd !=null">
+            and a.leave_hospital_date BETWEEN #{behosDateStart} AND #{behosDateEnd}
+        </if>
+        <if test="checkId !=null">
+            and b.check_id = #{checkId}
+        </if>) a LEFT JOIN med_behospital_type b on a.behospital_code = b.behospital_code
+        and a.hospital_id = b.hospital_id and b.is_deleted = 'N' ORDER BY b.`value` DESC ,a.leave_hospital_date DESC
+    </select>
     <select id="getCheckWorkPage" resultType="com.diagbot.dto.CheckWorkDTO">
         SELECT
         mbi.behospital_code,