瀏覽代碼

Merge branch '20210512_yw_check' into develop

songxinlu 4 年之前
父節點
當前提交
0a9bec28f3
共有 67 個文件被更改,包括 3782 次插入176 次删除
  1. 2 2
      pom.xml
  2. 1 7
      src/main/java/com/diagbot/config/ResourceServerConfigurer.java
  3. 2 6
      src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java
  4. 28 0
      src/main/java/com/diagbot/dto/BehospitalInfoAgeDTO.java
  5. 23 0
      src/main/java/com/diagbot/dto/CheckDeptDTO.java
  6. 39 0
      src/main/java/com/diagbot/dto/CheckJobDTO.java
  7. 24 0
      src/main/java/com/diagbot/dto/CheckUserDTO.java
  8. 122 0
      src/main/java/com/diagbot/dto/CheckWorkDTO.java
  9. 140 0
      src/main/java/com/diagbot/dto/CheckedRecordListDTO.java
  10. 26 0
      src/main/java/com/diagbot/dto/DeptCheckUserDTO.java
  11. 6 0
      src/main/java/com/diagbot/dto/JwtDTO.java
  12. 4 0
      src/main/java/com/diagbot/dto/MedicalRecordDTO.java
  13. 8 0
      src/main/java/com/diagbot/dto/MsgDTO.java
  14. 71 0
      src/main/java/com/diagbot/entity/MedBehospitalType.java
  15. 56 99
      src/main/java/com/diagbot/entity/MedCheckInfo.java
  16. 4 0
      src/main/java/com/diagbot/entity/QcresultDetail.java
  17. 51 0
      src/main/java/com/diagbot/enums/CheckJobTypeEnum.java
  18. 50 0
      src/main/java/com/diagbot/enums/CheckStatusEnum.java
  19. 51 0
      src/main/java/com/diagbot/enums/CheckTypeEnum.java
  20. 54 0
      src/main/java/com/diagbot/enums/CheckerRoleEnum.java
  21. 36 2
      src/main/java/com/diagbot/facade/AlgorithmFacade.java
  22. 130 12
      src/main/java/com/diagbot/facade/BehospitalInfoFacade.java
  23. 751 0
      src/main/java/com/diagbot/facade/MedCheckInfoFacade.java
  24. 312 0
      src/main/java/com/diagbot/facade/MedCheckWorkFacade.java
  25. 59 0
      src/main/java/com/diagbot/facade/QcresultInfoFacade.java
  26. 211 0
      src/main/java/com/diagbot/facade/RecordCheckFacade.java
  27. 1 0
      src/main/java/com/diagbot/facade/SysDictionaryFacade.java
  28. 89 14
      src/main/java/com/diagbot/facade/SysUserFacade.java
  29. 26 3
      src/main/java/com/diagbot/mapper/BehospitalInfoMapper.java
  30. 16 0
      src/main/java/com/diagbot/mapper/MedBehospitalTypeMapper.java
  31. 27 1
      src/main/java/com/diagbot/mapper/MedCheckInfoMapper.java
  32. 5 0
      src/main/java/com/diagbot/mapper/MedicalRecordMapper.java
  33. 16 0
      src/main/java/com/diagbot/service/MedBehospitalTypeService.java
  34. 9 1
      src/main/java/com/diagbot/service/MedCheckInfoService.java
  35. 5 0
      src/main/java/com/diagbot/service/MedicalRecordService.java
  36. 20 0
      src/main/java/com/diagbot/service/impl/MedBehospitalTypeServiceImpl.java
  37. 19 0
      src/main/java/com/diagbot/service/impl/MedCheckInfoServiceImpl.java
  38. 12 0
      src/main/java/com/diagbot/service/impl/MedicalRecordServiceImpl.java
  39. 71 0
      src/main/java/com/diagbot/task/BehospitalInfoTypeTask.java
  40. 3 1
      src/main/java/com/diagbot/vo/AlgorithmVO.java
  41. 6 0
      src/main/java/com/diagbot/vo/AnalyzeVO.java
  42. 54 0
      src/main/java/com/diagbot/vo/CheckJobPageVO.java
  43. 51 0
      src/main/java/com/diagbot/vo/CheckJobVO.java
  44. 29 0
      src/main/java/com/diagbot/vo/CheckUserVO.java
  45. 115 0
      src/main/java/com/diagbot/vo/CheckWorkPageVO.java
  46. 104 0
      src/main/java/com/diagbot/vo/CheckedRecordListVO.java
  47. 42 0
      src/main/java/com/diagbot/vo/DistributionJobVO.java
  48. 34 0
      src/main/java/com/diagbot/vo/MedCheckWorkAddVO.java
  49. 4 0
      src/main/java/com/diagbot/vo/QcResultAlgVO.java
  50. 2 0
      src/main/java/com/diagbot/vo/QcresultVO.java
  51. 24 0
      src/main/java/com/diagbot/vo/RecordCheckVO.java
  52. 24 0
      src/main/java/com/diagbot/vo/RecordTypeVO.java
  53. 13 0
      src/main/java/com/diagbot/web/BehospitalInfoController.java
  54. 72 0
      src/main/java/com/diagbot/web/MedCheckInfoController.java
  55. 67 0
      src/main/java/com/diagbot/web/MedCheckWorkController.java
  56. 57 0
      src/main/java/com/diagbot/web/RecordCheckController.java
  57. 1 1
      src/main/resources/application-pre.yml
  58. 6 3
      src/main/resources/application-test.yml
  59. 1 1
      src/main/resources/bootstrap.yml
  60. 2 1
      src/main/resources/mapper/BasDeptInfoMapper.xml
  61. 45 19
      src/main/resources/mapper/BehospitalInfoMapper.xml
  62. 16 0
      src/main/resources/mapper/MedBehospitalTypeMapper.xml
  63. 388 0
      src/main/resources/mapper/MedCheckInfoMapper.xml
  64. 41 0
      src/main/resources/mapper/MedicalRecordMapper.xml
  65. 1 1
      src/main/resources/mapper/QcCasesEntryHospitalMapper.xml
  66. 1 0
      src/main/resources/mapper/QcresultDetailMapper.xml
  67. 2 2
      src/test/java/com/diagbot/CodeGeneration.java

+ 2 - 2
pom.xml

@@ -37,8 +37,8 @@
         <okhttp.version>4.2.2</okhttp.version>
         <easypoi.version>4.2.0</easypoi.version>
         <docker-maven-plugin.version>1.2.1</docker-maven-plugin.version>
-        <docker.image.prefix>192.168.2.236:5000/diagbotcloud</docker.image.prefix>
-        <registryUrl>http://192.168.2.236:5000/repository/diagbotcloud/</registryUrl>
+        <docker.image.prefix>192.168.2.241:5000/diagbotcloud</docker.image.prefix>
+        <registryUrl>http://192.168.2.241:5000/repository/diagbotcloud/</registryUrl>
     </properties>
 
     <dependencyManagement>

+ 1 - 7
src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -235,12 +235,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/consoleByDept/medicalCheckFormKs").permitAll()
                 .antMatchers("/print/export/medicalCheckExportByDept").permitAll()
                 .antMatchers("/consoleByDept/medicalCheckTitleKs").permitAll()
-                .antMatchers("/console/qualityControl").permitAll()
-                .antMatchers("/console/export/qualityControlExport").permitAll()
-                .antMatchers("/consoleByDept/qualityControlByDept").permitAll()
-                .antMatchers("/print/export/qualityControlExportByDept").permitAll()
-                .antMatchers("/qc/behospitalInfo/getMedQualityCoList").permitAll()
-                .antMatchers("/console/saveMedicaIndicator").permitAll()
+                .antMatchers("/qc/medCheckInfo/createMedBeHospitalInfoType").permitAll()
                 .antMatchers("/**").authenticated();
         //                .antMatchers("/**").permitAll();
     }
@@ -249,7 +244,6 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
         log.info("Configuring ResourceServerSecurityConfigurer");
         resources.resourceId("user-service").tokenStore(new JwtTokenStore(jwtTokenEnhancerClient()));
     }
-
     @Autowired
     private CustomAccessTokenConverter customAccessTokenConverter;
 

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

@@ -279,18 +279,14 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/consoleByDept/medicalCheckFormKs", request)
                 || matchers("/print/export/medicalCheckExportByDept", request)
                 || matchers("/consoleByDept/medicalCheckTitleKs", request)
-                || matchers("/console/qualityControl", request)
-                || matchers("/console/export/qualityControlExport", request)
-                || matchers("/consoleByDept/qualityControlByDept", request)
-                || matchers("/print/export/qualityControlExportByDept", request)
-                || matchers("/qc/behospitalInfo/getMedQualityCoList", request)
-                || matchers("/console/saveMedicaIndicator", request)
+                || matchers("/qc/medCheckInfo/createMedBeHospitalInfoType", request)
                 || matchers("/", request)) {
             return true;
         }
         return false;
     }
 
+
     private boolean matchers(String url, HttpServletRequest request) {
         AntPathRequestMatcher matcher = new AntPathRequestMatcher(url);
         if (matcher.matches(request)) {

+ 28 - 0
src/main/java/com/diagbot/dto/BehospitalInfoAgeDTO.java

@@ -0,0 +1,28 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: wangsy
+ * @time: 2021/5/13 15:00
+ */
+@Getter
+@Setter
+public class BehospitalInfoAgeDTO {
+
+    /**
+     * 病人住院序号
+     */
+    private String behospitalCode;
+
+    /**
+     * 年龄
+     */
+    private String age;
+    private String ageYear;
+    private String ageMon;
+    private String ageDay;
+
+}

+ 23 - 0
src/main/java/com/diagbot/dto/CheckDeptDTO.java

@@ -0,0 +1,23 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description: 核查科室输出类
+ * @Author:songxl
+ * @time: 2021/5/14 13:45
+ */
+@Getter
+@Setter
+public class CheckDeptDTO {
+    //科室id
+    private String deptId;
+    //科室名称
+    private String deptName;
+    //科室质控人员列表
+    private List<DeptCheckUserDTO> deptcheckUsers = new ArrayList<>();
+}

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

@@ -0,0 +1,39 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description: 科室核查人员输出类
+ * @Author:songxl
+ * @time: 2021/5/14 13:45
+ */
+@Getter
+@Setter
+public class CheckJobDTO {
+    //核查任务id
+    private int id;
+    //病人住院序号
+    private String behospitalCode;
+    //病人姓名
+    private String name;
+    //科室
+    private String behospitalDept;
+    //主管医生
+    private String attendingDoctor;
+    //出院日期
+    private String leaveHospitalDate;
+    //核查任务生成时间
+    private String jobCreateTime;
+    //任务分配人员id
+    private Long jobDistributor;
+    //任务分配人员名称
+    private String jobDistributorName;
+    //科室id
+    private String behospitalDeptId;
+
+    //筛选分值
+    private int value;
+    //取消分配标志
+    private Boolean delFlag;
+}

+ 24 - 0
src/main/java/com/diagbot/dto/CheckUserDTO.java

@@ -0,0 +1,24 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description: 核查人员用户科室、姓名、角色输出类
+ * @Author:songxl
+ * @time: 2021/5/14 13:45
+ */
+@Getter
+@Setter
+public class CheckUserDTO {
+    //科室id
+    private String deptId;
+    //科室名称
+    private String deptName;
+    //医生id
+    private String doctorId;
+    //医生名称
+    private String doctorName;
+    //角色id
+    private int roleId;
+}

+ 122 - 0
src/main/java/com/diagbot/dto/CheckWorkDTO.java

@@ -0,0 +1,122 @@
+package com.diagbot.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * @Description:
+ * @author: wangsy
+ * @time: 2021/5/13 15:00
+ */
+@Getter
+@Setter
+public class CheckWorkDTO {
+
+    /**
+     * 病人住院序号
+     */
+    private String behospitalCode;
+
+    /**
+     * 病人姓名
+     */
+    private String name;
+
+
+    /**
+     * 病案号
+     */
+    private String fileCode;
+
+    /**
+     * 性别
+     */
+    private String sex;
+
+    /**
+     * 年龄
+     */
+    private String age;
+    private String ageYear;
+    private String ageMon;
+    private String ageDay;
+
+    /**
+     * 科室
+     */
+    private String behDeptName;
+
+    /**
+     * 出院日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date leaveHospitalDate;
+
+    /**
+     * 住院天数
+     */
+    private String behospitalDayNum;
+
+    /**
+     * 主管医生
+     */
+    private String doctorName;
+
+    /**
+     * 病历等级
+     */
+    private String level;
+
+    /**
+     * 病历得分
+     */
+    private String scoreRes;
+
+    /**
+     * 主诊断
+     */
+    private String diagnose;
+
+    /**
+     * 筛选分值
+     */
+    private String score;
+
+    /**
+     * 生成状态
+     */
+    private String creatStatus;
+
+    /**
+     * 生成日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date jobCreateTime;
+
+    /**
+     * 核查任务生成人编号
+     */
+    private Long jobCreator;
+    /**
+     * 核查任务生成人
+     */
+    private String jobCreatorName;
+
+    /**
+     * 核查日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date checkTime;
+
+    /**
+     * 分配日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date jobDistributionTime;
+
+    //取消分配标志
+    private Boolean delFlag = false;
+}

+ 140 - 0
src/main/java/com/diagbot/dto/CheckedRecordListDTO.java

@@ -0,0 +1,140 @@
+package com.diagbot.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2021/5/17 18:47
+ */
+@Getter
+@Setter
+@ApiModel("核查任务列表-获取核查任务列表-接口出参")
+public class CheckedRecordListDTO {
+
+    /**
+     * 病人住院序号
+     */
+    @ApiModelProperty("病人住院序号")
+    private String behospitalCode;
+
+    /**
+     * 病历核查状态
+     */
+    @ApiModelProperty("病历核查状态")
+    private String status;
+
+    /**
+     * 科室Id
+     */
+    @ApiModelProperty("科室Id")
+    private String behDeptId;
+    /**
+     * 任务来源
+     */
+    @ApiModelProperty("任务来源")
+    private String jobTypeName;
+
+    /**
+     * 科室
+     */
+    @ApiModelProperty("科室")
+    private String behDeptName;
+
+    /**
+     * 病人姓名
+     */
+    @ApiModelProperty("病人姓名")
+    private String name;
+
+    /**
+     * 病案号
+     */
+    @ApiModelProperty("病案号")
+    private String fileCode;
+
+    /**
+     * 主管医生
+     */
+    @ApiModelProperty("主管医生")
+    private String doctorName;
+
+    /**
+     * 出院日期
+     */
+    @ApiModelProperty("出院日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date leaveHospitalDate;
+
+    /**
+     * 生成日期
+     */
+    @ApiModelProperty("生成日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date jobCreateTime;
+
+    /**
+     * 分配日期
+     */
+    @ApiModelProperty("分配日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date jobDistributionTime;
+
+    /**
+     * 任务月份
+     */
+    @ApiModelProperty("任务月份")
+    @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8")
+    private Date month;
+
+    /**
+     * 核查员id
+     */
+    @ApiModelProperty("核查员id")
+    private Long checkId;
+
+    /**
+     * 核查员
+     */
+    @ApiModelProperty("核查员")
+    private String checkName;
+
+    /**
+     * 核查日期
+     */
+    @ApiModelProperty("核查日期")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+    private Date checkTime;
+
+    /**
+     * 缺陷数
+     */
+    @ApiModelProperty("缺陷数")
+    private int casesEntryNum;
+
+    /**
+     * 病历等级
+     */
+    @ApiModelProperty("病历等级")
+    private String level;
+
+    /**
+     * 病历得分
+     */
+    @ApiModelProperty("病历得分")
+    private BigDecimal scoreRes;
+
+    /**
+     * 年龄
+     */
+    @ApiModelProperty("年龄")
+    private String age;
+
+}

+ 26 - 0
src/main/java/com/diagbot/dto/DeptCheckUserDTO.java

@@ -0,0 +1,26 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description: 科室核查人员输出类
+ * @Author:songxl
+ * @time: 2021/5/14 13:45
+ */
+@Getter
+@Setter
+public class DeptCheckUserDTO {
+    //科室id
+    private String deptId;
+    //科室名称
+    private String deptName;
+    //医生id
+    private String doctorId;
+    //医生名称
+    private String doctorName;
+    //核查数
+    private int jobNum;
+    private int checkNum;
+    private int status;
+}

+ 6 - 0
src/main/java/com/diagbot/dto/JwtDTO.java

@@ -3,6 +3,8 @@ package com.diagbot.dto;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * @Description: jwt 输出类
  * @author: gaodm
@@ -15,4 +17,8 @@ public class JwtDTO {
     private String refreshToken;
     private Integer type; //用户类型
     private String typeCn; //用户类型中文
+    //用户权限列表
+    private List<SysRoleDTO> selRoles;
+    //用户密码复杂度是否符合
+//    private String passwordComplexity;
 }

+ 4 - 0
src/main/java/com/diagbot/dto/MedicalRecordDTO.java

@@ -17,6 +17,10 @@ public class MedicalRecordDTO implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
+    /**
+     * 病人住院ID
+     */
+    private String behospitalCode;
     /**
      * 模块id
      */

+ 8 - 0
src/main/java/com/diagbot/dto/MsgDTO.java

@@ -52,6 +52,14 @@ public class MsgDTO {
     private Date gmtCreate;
     // 记录修改时间,如果时间是1970年则表示纪录未修改
     private Date gmtModified;
+    // 记录修改人id
+    private String modifier;
+    // 记录修改人姓名
+    private String linkman;
+    // 逻辑删除标志位
+    private String isDeleted;
+    // 缺陷说明
+    private String explainInfo;
     // 条目id对应页面数据的key值
     private List<Long> pageKeyList = new ArrayList<>();
 }

+ 71 - 0
src/main/java/com/diagbot/entity/MedBehospitalType.java

@@ -0,0 +1,71 @@
+package com.diagbot.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author songxl
+ * @since 2021-05-11
+ */
+@TableName("med_behospital_type")
+@Data
+public class MedBehospitalType implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 医院ID
+     */
+    private Long hospitalId;
+
+    /**
+     * 病历号
+     */
+    private String behospitalCode;
+
+    /**
+     * 患者类型
+     */
+    private String behospitalType;
+
+    /**
+     * 类型分值
+     */
+    private Integer value;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 是否删除
+     */
+    private String isDeleted;
+
+    @Override
+    public String toString() {
+        return "MedBehospitalType{" +
+            "id=" + id +
+            ", hospitalId=" + hospitalId +
+            ", behospitalCode=" + behospitalCode +
+            ", behospitalType=" + behospitalType +
+            ", value=" + value +
+            ", createTime=" + createTime +
+            ", isDeleted=" + isDeleted +
+        "}";
+    }
+}

+ 56 - 99
src/main/java/com/diagbot/entity/MedCheckInfo.java

@@ -2,8 +2,10 @@ package com.diagbot.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
 
 import java.io.Serializable;
+import java.time.LocalDateTime;
 import java.util.Date;
 
 /**
@@ -14,6 +16,7 @@ import java.util.Date;
  * @author wangfeng
  * @since 2020-07-06
  */
+@Data
 public class MedCheckInfo implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -79,116 +82,70 @@ public class MedCheckInfo implements Serializable {
      */
     private Integer status;
 
-    private Integer checkType;
-
-    public Integer getCheckType() {
-        return checkType;
-    }
-
-    public void setCheckType(Integer checkType) {
-        this.checkType = checkType;
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-    public String getIsDeleted() {
-        return isDeleted;
-    }
-
-    public void setIsDeleted(String isDeleted) {
-        this.isDeleted = isDeleted;
-    }
-    public Date getGmtCreate() {
-        return gmtCreate;
-    }
-
-    public void setGmtCreate(Date gmtCreate) {
-        this.gmtCreate = gmtCreate;
-    }
-    public Date getGmtModified() {
-        return gmtModified;
-    }
-
-    public void setGmtModified(Date gmtModified) {
-        this.gmtModified = gmtModified;
-    }
-    public String getCreator() {
-        return creator;
-    }
+    /**
+     * 核查类型(0病历,1病案首页,2全部)
+     */
+    private Integer checkType = 2;
 
-    public void setCreator(String creator) {
-        this.creator = creator;
-    }
-    public String getModifier() {
-        return modifier;
-    }
+    /**
+     * 核查任务创建人编号
+     */
+    private Long jobCreator;
 
-    public void setModifier(String modifier) {
-        this.modifier = modifier;
-    }
-    public String getBehospitalCode() {
-        return behospitalCode;
-    }
+    /**
+     * 核查任务创建人
+     */
+    private String jobCreatorName;
 
-    public void setBehospitalCode(String behospitalCode) {
-        this.behospitalCode = behospitalCode;
-    }
-    public Long getHospitalId() {
-        return hospitalId;
-    }
+    /**
+     * 核查任务生成时间
+     */
+    private Date jobCreateTime;
 
-    public void setHospitalId(Long hospitalId) {
-        this.hospitalId = hospitalId;
-    }
-    public Long getCheckId() {
-        return checkId;
-    }
+    /**
+     * 核查任务类型(0-科室任务 1-院级 2-质控科)
+     */
+    private Integer jobType;
 
-    public void setCheckId(Long checkId) {
-        this.checkId = checkId;
-    }
-    public String getCheckName() {
-        return checkName;
-    }
+    /**
+     * 核查任务分配人编号
+     */
+    private Long jobDistributor;
 
-    public void setCheckName(String checkName) {
-        this.checkName = checkName;
-    }
-    public Date getCheckTime() {
-        return checkTime;
-    }
+    /**
+     * 核查任务分配人姓名
+     */
+    private String jobDistributionName;
 
-    public void setCheckTime(Date checkTime) {
-        this.checkTime = checkTime;
-    }
-    public Integer getStatus() {
-        return status;
-    }
+    /**
+     * 核查任务分配时间
+     */
+    private Date jobDistributionTime;
 
-    public void setStatus(Integer status) {
-        this.status = status;
-    }
 
     @Override
     public String toString() {
         return "MedCheckInfo{" +
-            "id=" + id +
-            ", isDeleted=" + isDeleted +
-            ", gmtCreate=" + gmtCreate +
-            ", gmtModified=" + gmtModified +
-            ", creator=" + creator +
-            ", modifier=" + modifier +
-            ", behospitalCode=" + behospitalCode +
-            ", hospitalId=" + hospitalId +
-            ", checkId=" + checkId +
-            ", checkName=" + checkName +
-            ", checkTime=" + checkTime +
-            ", status=" + status +
-        "}";
+                "id=" + id +
+                ", isDeleted=" + isDeleted +
+                ", gmtCreate=" + gmtCreate +
+                ", gmtModified=" + gmtModified +
+                ", creator=" + creator +
+                ", modifier=" + modifier +
+                ", behospitalCode=" + behospitalCode +
+                ", hospitalId=" + hospitalId +
+                ", checkId=" + checkId +
+                ", checkName=" + checkName +
+                ", checkTime=" + checkTime +
+                ", status=" + status +
+                ", checkType=" + checkType +
+                ", jobCreator=" + jobCreator +
+                ", jobCreatorName=" + jobCreatorName +
+                ", jobCreateTime=" + jobCreateTime +
+                ", jobType=" + jobType +
+                ", jobDistributor=" + jobDistributor +
+                ", jobDistributionName=" + jobDistributionName +
+                ", jobDistributionTime=" + jobDistributionTime +
+                "}";
     }
 }

+ 4 - 0
src/main/java/com/diagbot/entity/QcresultDetail.java

@@ -111,4 +111,8 @@ public class QcresultDetail implements Serializable {
      * 备注
      */
     private String remark;
+    /**
+     * 质控条目说明
+     */
+    private String explainInfo;
 }

+ 51 - 0
src/main/java/com/diagbot/enums/CheckJobTypeEnum.java

@@ -0,0 +1,51 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @author wangfeng
+ * @Description: 核查任务类型
+ * @date 2018年11月21日 下午2:31:42
+ */
+public enum CheckJobTypeEnum implements KeyedNamed {
+    DEPT_SUPERVISOR(0, "科室任务"),
+    QUAT_SUPERVISOR(1, "质控科任务"),
+    HOSP_SUPERVISOR(2, "院级任务");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    CheckJobTypeEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static CheckJobTypeEnum getEnum(int key) {
+        for (CheckJobTypeEnum item : CheckJobTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        CheckJobTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+}
+

+ 50 - 0
src/main/java/com/diagbot/enums/CheckStatusEnum.java

@@ -0,0 +1,50 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @author wangfeng
+ * @Description: TODO
+ * @date 2018年11月21日 下午2:31:42
+ */
+public enum CheckStatusEnum implements KeyedNamed {
+    Disable(0, "未核查"),
+    Enable(1, "已核查");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    CheckStatusEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static CheckStatusEnum getEnum(int key) {
+        for (CheckStatusEnum item : CheckStatusEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        CheckStatusEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+}
+

+ 51 - 0
src/main/java/com/diagbot/enums/CheckTypeEnum.java

@@ -0,0 +1,51 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @author wangfeng
+ * @Description: 核查类型
+ * @date 2018年11月21日 下午2:31:42
+ */
+public enum CheckTypeEnum implements KeyedNamed {
+    COURSE(0, "病历"),
+    HOMEPAGE(1, "病案首页"),
+    ALL(2, "全部");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    CheckTypeEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static CheckTypeEnum getEnum(int key) {
+        for (CheckTypeEnum item : CheckTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        CheckTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+}
+

+ 54 - 0
src/main/java/com/diagbot/enums/CheckerRoleEnum.java

@@ -0,0 +1,54 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @author wangfeng
+ * @Description: TODO
+ * @date 2018年11月21日 下午2:31:42
+ */
+public enum CheckerRoleEnum implements KeyedNamed {
+    DEPT_SUPERVISOR(4, "临床科室监管人员"),
+    DEPT_GENERAL(7, "临床科室质控人员"),
+    QUAT_SUPERVISOR(5, "质控科监管人员"),
+    QUAT_GENERAL(8, "质控科质控人员"),
+    HOSP_SUPERVISOR(6, "院级监管人员"),
+    HOSP_GENERAL(9, "院级质控人员");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    CheckerRoleEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static CheckerRoleEnum getEnum(int key) {
+        for (CheckerRoleEnum item : CheckerRoleEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        CheckerRoleEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+}
+

+ 36 - 2
src/main/java/com/diagbot/facade/AlgorithmFacade.java

@@ -1,6 +1,8 @@
 package com.diagbot.facade;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.dto.AlgorithmDTO;
+import com.diagbot.entity.QcresultDetail;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.util.BeanUtil;
@@ -28,10 +30,12 @@ import java.util.Map;
  */
 @Component
 public class AlgorithmFacade {
-    private final static List<Integer> types = Arrays.asList(0, 1, 2, 3);
+    private final static List<Integer> types = Arrays.asList(0, 1, 2, 3,4);
 
     @Autowired
     private SysHospitalSetFacade sysHospitalSetFacade;
+    @Autowired
+    private QcresultDetailFacade qcresultDetailFacade;
 
     /**
      * 获取评分结果和等级
@@ -196,7 +200,7 @@ public class AlgorithmFacade {
 
         }
         //删除
-        else if (algorithmVO.getType().equals(2)) {
+        else if (algorithmVO.getType().equals(2)||(algorithmVO.getType().equals(4)&&0==algorithmVO.getDelStatus())) {
             if (null == algorithmVO.getOptResultAlgVO()) {
                 throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "删除操作条目不能为空!");
             }
@@ -216,6 +220,36 @@ public class AlgorithmFacade {
                 }
             }
         }
+        //恢复
+        else if (algorithmVO.getType().equals(4)&&1==algorithmVO.getDelStatus()) {
+            if (null == algorithmVO.getOptResultAlgVO()) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "恢复操作条目不能为空!");
+            }
+            //操作数据
+            if (ListUtil.isNotEmpty(qcResultAlgVOList)) {
+                Boolean hasData = false;
+                Long optId = algorithmVO.getOptResultAlgVO().getId(); // 操作id
+                QcresultDetail qcresultDetail = qcresultDetailFacade.getOne(new QueryWrapper<QcresultDetail>()
+                        .eq("id",optId));
+                if(qcresultDetail!=null)
+                {
+                    QcResultAlgVO qcResultAlgVO = new QcResultAlgVO();
+                    qcResultAlgVO.setScore(qcresultDetail.getScore());
+                    qcResultAlgVO.setId(qcresultDetail.getId());
+                    qcResultAlgVO.setCasesEntryId(qcresultDetail.getCasesEntryId());
+                    qcResultAlgVO.setCasesId(qcresultDetail.getCasesId());
+                    qcResultAlgVO.setMsg(qcresultDetail.getMsg());
+                    qcResultAlgVO.setIsReject(qcresultDetail.getIsReject());
+                    qcResultAlgVO.setCasesScore(qcresultDetail.getCasesScore());
+                    qcResultAlgVOList.add(qcResultAlgVO);
+                    hasData = true;
+                }
+                if (!hasData) {
+                    throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "恢复的条目不存在!");
+                }
+            }
+        }
+
         //修改
         else if (algorithmVO.getType().equals(3)) {
             if (null == algorithmVO.getOptResultAlgVO()) {

+ 130 - 12
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -7,12 +7,37 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.client.AuthServiceClient;
 import com.diagbot.dto.*;
 import com.diagbot.entity.*;
+import com.diagbot.enums.CheckStatusEnum;
+import com.diagbot.enums.CheckerRoleEnum;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.BehospitalInfoServiceImpl;
-import com.diagbot.util.*;
-import com.diagbot.vo.*;
+import com.diagbot.util.BeanUtil;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.EncrypDES;
+import com.diagbot.util.EntityUtil;
+import com.diagbot.util.ExcelUtils;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.MapUtil;
+import com.diagbot.util.StringUtil;
+import com.diagbot.util.SysUserUtils;
+import com.diagbot.vo.AlgorithmVO;
+import com.diagbot.vo.AnalyzeCdsVO;
+import com.diagbot.vo.AnalyzeCodeVO;
+import com.diagbot.vo.AnalyzeRunVO;
+import com.diagbot.vo.AnalyzeVO;
+import com.diagbot.vo.BasDeptInfoVO;
+import com.diagbot.vo.BehospitalPageVO;
+import com.diagbot.vo.ExportQcresultVO;
+import com.diagbot.vo.FilterVO;
+import com.diagbot.vo.GetDetailVO;
+import com.diagbot.vo.MedrecVo;
+import com.diagbot.vo.QcResultAlgQueryVO;
+import com.diagbot.vo.QcResultAlgVO;
+import com.diagbot.vo.QueryVo;
+import com.diagbot.vo.RecordContentVO;
+import com.diagbot.vo.TaskVO;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import org.apache.commons.lang3.StringUtils;
@@ -25,8 +50,15 @@ import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -139,7 +171,8 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
     SysHospitalSetFacade sysHospitalSetFacade;
     @Autowired
     QcCasesRelevanceEntryFacade qcCasesRelevanceEntryFacade;
-
+    @Autowired
+    SysUserRoleFacade sysUserRoleFacade;
 
 
     /**
@@ -238,13 +271,12 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
             }
             res.put("result", qcResultDTO);
             //增加该病历是否核查状态
-            Map<String, Object> mapAll = new HashMap<String, Object>();
-            mapAll.put("is_deleted", IsDeleteEnum.N.getKey());
-            mapAll.put("behospital_code", getDetailVO.getBehospitalCode());
-            mapAll.put("hospital_id", hospitalId);
-            mapAll.put("check_type", 0);
             QueryWrapper<MedCheckInfo> medCheckInfoQuerys = new QueryWrapper<>();
-            medCheckInfoQuerys.allEq(mapAll);
+            medCheckInfoQuerys.eq("is_deleted", IsDeleteEnum.N.getKey());
+            medCheckInfoQuerys.eq("behospital_code", getDetailVO.getBehospitalCode());
+            medCheckInfoQuerys.eq("hospital_id", hospitalId);
+            medCheckInfoQuerys.in("check_type", 0, 2);
+            medCheckInfoQuerys.eq("status", 1);
             int count = medCheckInfoFacade.count(medCheckInfoQuerys);
             if (count > 0) {
                 res.put("checkStatus", 1);
@@ -265,6 +297,46 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
             } else {
                 res.put("mrStatus", 0);
             }
+            //新增如果当前用户不是核查人员返回标志位用户核查按钮、修改、删除、隐藏显示
+            //1.获取病历核查人员id,该操作只能是核查员操作
+            List<MedCheckInfo> medCheckInfos = medCheckInfoFacade.list(new QueryWrapper<MedCheckInfo>()
+                    .eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("hospital_id", hospitalId)
+                    .eq("behospital_code", getDetailVO.getBehospitalCode()));
+            if (medCheckInfos.size() == 1 && medCheckInfos.get(0).getCheckId() != null
+                    && medCheckInfos.get(0).getCheckId().equals(Long.parseLong(SysUserUtils.getCurrentPrincipleID()))) {
+                //2.1获取核查类型,判断当前用户有没有对应核查类型的角色
+                int jobType = medCheckInfoFacade.list(new QueryWrapper<MedCheckInfo>()
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .eq("behospital_code",  getDetailVO.getBehospitalCode())
+                        .eq("hospital_id", hospitalId)
+                        .eq("check_id", SysUserUtils.getCurrentPrincipleID())).get(0).getJobType();
+                //2.2获取用户角色
+                List<Long> roleIds = sysUserRoleFacade.list(new QueryWrapper<SysUserRole>()
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .eq("user_id", SysUserUtils.getCurrentPrincipleID())
+                ).stream().distinct().map(SysUserRole::getRoleId).collect(Collectors.toList());
+                switch (jobType){
+                    case 0:
+                        if(roleIds.contains(CheckerRoleEnum.DEPT_GENERAL.getKey()*1l)){res.put("checkShow", 1);}
+                        else {res.put("checkShow", 0);}
+                        break;
+                    case 1:
+                        if(roleIds.contains(CheckerRoleEnum.QUAT_GENERAL.getKey()*1l)){res.put("checkShow", 1);}
+                        else {res.put("checkShow", 0);}
+                        break;
+                    case 2:
+                        if(roleIds.contains(CheckerRoleEnum.HOSP_GENERAL.getKey()*1l)){res.put("checkShow", 1);}
+                        else {res.put("checkShow", 0);}
+                        break;
+                    default:
+                        res.put("checkShow", 0);
+                        break;
+                }
+
+            } else {
+                res.put("checkShow", 0);
+            }
         }
 
         // 获取提示信息
@@ -720,6 +792,7 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         //使用sql进行关联优化数据查询
         List<MedPacsResultDTO> medPacsResultList = medPacsResultFacade.getMedPacsResultList(behospitalInfoList.get(0));
 
+
         /**
          * 结构化/文书数据兼容处理
          */
@@ -976,6 +1049,7 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
      * @return
      */
     public AnalyzeDTO analyze(AnalyzeVO analyzeVO) {
+
         Long hospitalId = analyzeVO.getHospitalId();
         if (!analyzeVO.getIsTask()) {
             hospitalId = Long.parseLong(SysUserUtils.getCurrentHospitalID());
@@ -984,8 +1058,16 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         analyzeVO.setHospitalId(hospitalId);
 
         // 处理公共数据
-            QueryVo  queryVo = dealCommonData(hospitalId, analyzeVO);
+        QueryVo  queryVo = dealCommonData(hospitalId, analyzeVO);
         queryVo.setUseCrfCache(analyzeVO.isUseCrfCache());
+        //已核查抛出以评分
+        List<MedCheckInfo> medCheckInfos = medCheckInfoFacade.list(new QueryWrapper<MedCheckInfo>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", analyzeVO.getHospitalId())
+                .eq("behospital_code", analyzeVO.getBehospitalCode()));
+        if (medCheckInfos.size() == 1 && medCheckInfos.get(0).getStatus()==CheckStatusEnum.Enable.getKey() && analyzeVO.getCheckFlag()) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该病例已经核查无需评分!");
+        }
         //  调用质控接口
         Response<OutputInfo> response = qcServiceClient.extract(queryVo);
         if (response == null || response.getData() == null) {
@@ -1656,6 +1738,12 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
 
         List<MsgDTO> msgDTOList = getMsg(analyzeVO);
         if (ListUtil.isNotEmpty(msgDTOList)) {
+            msgDTOList.forEach(msgDTO ->{
+                if(StringUtils.isNotEmpty(msgDTO.getInfo()) && StringUtils.isNotEmpty(msgDTO.getInfo().trim()) &&
+                        StringUtils.isNotEmpty(msgDTO.getMsg())){
+                    msgDTO.setMsg(msgDTO.getMsg()+"("+msgDTO.getInfo().trim()+")");
+                }
+            });
             // 从qc_question_info的cases_entry_ids获取
             Map<String, Object> paramMap = new HashMap<>();
             paramMap.put("hospitalId",  analyzeRunVO.getHospitalId());
@@ -2343,4 +2431,34 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
     public List<Map<String,String>> malignancy(@Param("filterVO") FilterVO filterVO){
         return  baseMapper.malignancy(filterVO);
     }
+
+    /**
+     * 获取患者年龄信息(通过出生日期和入院日期重新计算)
+     * @param hospitalId
+     * @param behospitalCodes
+     * @return
+     */
+    public List<BehospitalInfoAgeDTO> getBehospitalInfoAge(Long hospitalId, List<String> behospitalCodes) {
+        if (hospitalId == null || ListUtil.isEmpty(behospitalCodes)) {
+            return new ArrayList<>();
+        }
+        List<BehospitalInfoAgeDTO> behospitalInfoAgeDTOList = this.baseMapper.getBehospitalInfoAge(hospitalId, behospitalCodes);
+        if (behospitalInfoAgeDTOList == null) {
+            return new ArrayList<>();
+        }
+
+        behospitalInfoAgeDTOList.forEach(behospitalInfoAgeDTO -> {
+            String age = "";
+            if (StringUtil.isNotBlank(behospitalInfoAgeDTO.getAgeYear()) && !behospitalInfoAgeDTO.getAgeYear().equals("0")) {
+                age += behospitalInfoAgeDTO.getAgeYear() + "岁";
+            } else {
+                age += (StringUtil.isNotBlank(behospitalInfoAgeDTO.getAgeMon()) && !behospitalInfoAgeDTO.getAgeMon().equals("0") ? (behospitalInfoAgeDTO.getAgeMon() + "个月") : "")
+                        + (StringUtil.isNotBlank(behospitalInfoAgeDTO.getAgeDay()) && !behospitalInfoAgeDTO.getAgeDay().equals("0") ? (behospitalInfoAgeDTO.getAgeDay() + "天") : "");
+            }
+            behospitalInfoAgeDTO.setAge(age);
+        });
+
+        return behospitalInfoAgeDTOList;
+    }
+
 }

+ 751 - 0
src/main/java/com/diagbot/facade/MedCheckInfoFacade.java

@@ -2,21 +2,43 @@ package com.diagbot.facade;
 
 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.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.CheckJobTypeEnum;
+import com.diagbot.enums.CheckerRoleEnum;
 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.CheckUserVO;
+import com.diagbot.vo.DistributionJobVO;
 import com.diagbot.vo.MedCheckInfoAddVO;
+import com.google.common.collect.Lists;
 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.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
 
 /**
  * @author wangfeng
@@ -28,6 +50,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 +141,722 @@ 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(CheckerRoleEnum.QUAT_SUPERVISOR.getKey()*1l)
+                &&(CheckJobTypeEnum.QUAT_SUPERVISOR.getKey()+"").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(CheckerRoleEnum.DEPT_SUPERVISOR.getKey()*1l)
+                ||searchRoleIds.contains(CheckerRoleEnum.HOSP_SUPERVISOR.getKey()*1l))
+        {
+            //查询没有指定科室
+            if(checkJobVO.getDeptList()==null||checkJobVO.getDeptList().isEmpty())
+            {
+                //科室获取待分配任务所在科室集合
+                if(CheckJobTypeEnum.DEPT_SUPERVISOR.getKey()==Integer.parseInt(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
+                    {
+                        return  new CheckJobPageVO();
+                    }
+                }
+                //院区获取
+                if(CheckJobTypeEnum.HOSP_SUPERVISOR.getKey()==Integer.parseInt(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());
+//                    //获取所有院区核查人员所在科室
+//                    CheckUserVO checkUserVOS = new CheckUserVO();
+//                    checkUserVOS.setRoleIds(Lists.newArrayList(CheckerRoleEnum.HOSP_GENERAL.getKey()*1l));
+//                    checkUserVOS.setDeptStations(Lists.newArrayList("住院"));
+//                    checkUserVOS.setHospitalId(hospitalId);
+//                    List<CheckUserDTO> checkUserDTOS = baseMapper.getCheckUser(checkUserVOS);
+//                    Set<String> hospGeneralDeptIds= checkUserDTOS.stream()
+//                            .map(CheckUserDTO::getDeptId).collect(Collectors.toSet());
+//                    //去除管理员所在科室
+//                    if(hospGeneralDeptIds!=null&&!hospGeneralDeptIds.isEmpty()&&deptIds!=null){
+//                        hospGeneralDeptIds.removeAll(deptIds);
+//                        checkJobVO.setDeptList(new ArrayList<>(hospGeneralDeptIds));
+//                    }
+                    return getCheckList(checkJobVO);
+                }
+            }
+            return getCheckList(checkJobVO);
+        }
+        else
+        {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该用户的角色和任务类型不对应!");
+        }
+    }
+    /**
+     * @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
+        CheckUserVO checkUserVOS = new CheckUserVO();
+        checkUserVOS.setRoleIds(Lists.newArrayList(CheckerRoleEnum.HOSP_GENERAL.getKey()*1l));
+        checkUserVOS.setDeptStations(Lists.newArrayList("住院"));
+        checkUserVOS.setHospitalId(hospitalId);
+        List<CheckUserDTO> checkUserDTOS = baseMapper.getCheckUser(checkUserVOS);
+        //2.用户科室整合
+        margeDept(checkRoleMap,checkUserDTOS,CheckerRoleEnum.HOSP_SUPERVISOR.getKey()+"");
+        if(!ListUtil.isEmpty(checkRoleMap.get(CheckerRoleEnum.HOSP_SUPERVISOR.getKey()+""))){
+            //2.3获取所有医生信息的核查数
+            CheckUserVO checkUserVO = new CheckUserVO();
+            checkUserVO.setJobType(CheckJobTypeEnum.HOSP_SUPERVISOR.getKey());
+            //通过核查人员id获取核查人员的核查任务数
+            List<DeptCheckUserDTO> userJobs = baseMapper.getDeptJobNumByUserId(checkUserVO);
+            addCheckInfoMaps(checkRoleMap,null,userJobs,checkUserDTOS,CheckerRoleEnum.HOSP_SUPERVISOR.getKey(),CheckJobTypeEnum.HOSP_SUPERVISOR.getKey());
+        }
+        else {
+            checkRoleMap.put(CheckerRoleEnum.HOSP_SUPERVISOR.getKey()+"",new ArrayList<>());
+        }
+
+    }
+    /**
+     * @Author songxl
+     * @Description 院区人员用户科室合并
+     * @Date  2021/6/1
+     * @Param [checkRoleMap, checkUserDTOS, s]
+     * @Return void
+     * @MethodName margeDept
+     */
+    private void margeDept(Map<String, List<CheckDeptDTO>> checkRoleMap, List<CheckUserDTO> checkUserDTOS, String roleId) {
+        if(ListUtil.isEmpty(checkUserDTOS)){return;}
+        Set<String> userIds = checkUserDTOS.stream().map(CheckUserDTO::getDoctorId).collect(Collectors.toSet());
+        try {
+            List<CheckDeptDTO> tempDepts = new ArrayList<>();
+            //全部
+            CheckDeptDTO allCheckDept = new CheckDeptDTO();
+            allCheckDept.setDeptId("-1");
+            allCheckDept.setDeptName("全部");
+            userIds.stream().forEach(userId -> {
+                //获取该用户的科室拼接
+                StringBuilder deptIdBuilder = new StringBuilder();
+                StringBuilder deptNameBuilder = new StringBuilder();
+                StringBuilder userName = new StringBuilder();
+                checkUserDTOS.stream().forEach(checkUserDTO -> {
+                    if(userId.equals(checkUserDTO.getDoctorId())){
+                        deptIdBuilder.append(checkUserDTO.getDeptId()).append(",");
+                        deptNameBuilder.append(checkUserDTO.getDeptName()).append(",");
+                        if(userName.length()==0){userName.append(checkUserDTO.getDoctorName());}
+                        //除了全部以外添加科室信息
+                        if(!tempDepts.stream().map(CheckDeptDTO::getDeptId).collect(Collectors.toList())
+                                .contains(checkUserDTO.getDeptId())){
+                            CheckDeptDTO oneCheckUser = new CheckDeptDTO();
+                            oneCheckUser.setDeptId(checkUserDTO.getDeptId());
+                            oneCheckUser.setDeptName(checkUserDTO.getDeptName());
+                            tempDepts.add(oneCheckUser);
+                        }
+                    }
+                });
+
+                //合并科室
+                String deptId = deptIdBuilder.substring(0,deptIdBuilder.length()-1);
+                String deptName = deptNameBuilder.substring(0,deptNameBuilder.length()-1);
+                //科室用户
+                DeptCheckUserDTO deptCheckUserDTO = new DeptCheckUserDTO();
+                deptCheckUserDTO.setDoctorId(userId);
+                deptCheckUserDTO.setDoctorName(userName.toString());
+                deptCheckUserDTO.setDeptId(deptId);
+                deptCheckUserDTO.setDeptName(deptName);
+                AtomicBoolean hasFlag = new AtomicBoolean(false);
+                //全部处理
+                if(ListUtil.isEmpty(allCheckDept.getDeptcheckUsers())){
+                    allCheckDept.getDeptcheckUsers().add(deptCheckUserDTO);
+                }
+                allCheckDept.getDeptcheckUsers().forEach(oneDeptCheckUser -> {
+                    if(!deptId.equals(oneDeptCheckUser.getDeptId())&&!userId.equals(oneDeptCheckUser.getDoctorId()))
+                    {
+                        hasFlag.set(true);
+                    }
+                });
+                if(hasFlag.get()){
+                    allCheckDept.getDeptcheckUsers().add(deptCheckUserDTO);
+                }
+
+                tempDepts.stream().forEach(checkDeptDTO -> {
+                    if(deptId.contains(checkDeptDTO.getDeptId())){
+                        checkDeptDTO.getDeptcheckUsers().add(deptCheckUserDTO);
+                    }
+                });
+            });
+            tempDepts.add(0,allCheckDept);
+            checkRoleMap.put(roleId+"",tempDepts);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+    }
+
+    /**
+     * @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(CheckerRoleEnum.QUAT_GENERAL.getKey()*1l));
+        //质管科
+        checkUserVOS.setDeptStations(Lists.newArrayList("质管"));
+        checkUserVOS.setDeptIds(Lists.newArrayList(zkkDeptId));
+        checkUserVOS.setHospitalId(hospitalId);
+        List<CheckUserDTO> checkUserDTOS = baseMapper.getCheckUser(checkUserVOS);
+        //2.1获取科室详情
+        Map<String,String> deptMap = basDeptInfoFacade.list(new QueryWrapper<BasDeptInfo>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id",hospitalId)
+                .in("dept_id",Lists.newArrayList(zkkDeptId))).stream()
+                .collect(Collectors.toMap(BasDeptInfo::getDeptId,BasDeptInfo::getDeptName, (v1, v2) -> v2));
+        if(deptMap!=null&&!deptMap.isEmpty())
+        {
+            //2.3获取质控科核查人员的核查数
+            List<String> doctorIds = checkUserDTOS.stream().map(CheckUserDTO::getDoctorId).collect(Collectors.toList());
+            CheckUserVO checkUserVO = new CheckUserVO();
+            checkUserVO.setJobType(CheckJobTypeEnum.QUAT_SUPERVISOR.getKey());
+            checkUserVO.setUserList(doctorIds);
+            //通过核查人员id获取核查人员的核查任务数
+            List<DeptCheckUserDTO> userJobs = baseMapper.getDeptJobNumByUserId(checkUserVO);
+            userJobs.stream().forEach(deptCheckUserDTO -> {
+                deptCheckUserDTO.setDeptId(zkkDeptId);
+            });
+            addCheckInfoMaps(checkRoleMap,deptMap,userJobs,checkUserDTOS,CheckerRoleEnum.QUAT_SUPERVISOR.getKey(),CheckJobTypeEnum.QUAT_SUPERVISOR.getKey());
+        }
+        else {
+            checkRoleMap.put(CheckerRoleEnum.QUAT_SUPERVISOR.getKey()+"",new ArrayList<>());
+        }
+
+    }
+    /**
+     * @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;}
+        //1.2去除质管科
+        String zkkDeptId = basDeptInfoFacade.getOne(new QueryWrapper<BasDeptInfo>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id",hospitalId)
+                .like("dept_name","质管科")).getDeptId();
+        if(StringUtil.isNotBlank(zkkDeptId)){deptIds.remove(zkkDeptId);}
+        CheckUserVO checkUserVOS = new CheckUserVO();
+        //科室普通核查人员角色筛选
+        checkUserVOS.setRoleIds(Lists.newArrayList(CheckerRoleEnum.DEPT_GENERAL.getKey()*1l));
+        checkUserVOS.setDeptIds(deptIds);
+        checkUserVOS.setDeptStations(Lists.newArrayList("住院"));
+        checkUserVOS.setHospitalId(hospitalId);
+        List<CheckUserDTO> checkUserDTOS = baseMapper.getCheckUser(checkUserVOS);
+        //2.1获取科室详情
+        Map<String,String> deptMap = basDeptInfoFacade.list(new QueryWrapper<BasDeptInfo>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id",hospitalId)
+                .in("dept_id",deptIds)).stream()
+                .collect(Collectors.toMap(BasDeptInfo::getDeptId,BasDeptInfo::getDeptName, (v1, v2) -> v2));
+        if(deptMap!=null&&!deptMap.isEmpty())
+        {
+            //2.3获取所有医生信息的核查数
+            List<String> doctorIds = checkUserDTOS.stream().map(CheckUserDTO::getDoctorId).collect(Collectors.toList());
+            CheckUserVO checkUserVO = new CheckUserVO();
+            checkUserVO.setJobType(CheckJobTypeEnum.DEPT_SUPERVISOR.getKey());
+            checkUserVO.setUserList(doctorIds);
+            checkUserVO.setDeptIds(deptIds);
+            //通过核查人员id获取核查人员的核查任务数
+            List<DeptCheckUserDTO> userJobs = baseMapper.getDeptJobNumByUserId(checkUserVO);
+            addCheckInfoMaps(checkRoleMap,deptMap,userJobs,checkUserDTOS,CheckerRoleEnum.DEPT_SUPERVISOR.getKey(),CheckJobTypeEnum.DEPT_SUPERVISOR.getKey());
+        }
+        else {
+            checkRoleMap.put(CheckerRoleEnum.DEPT_SUPERVISOR.getKey()+"",new ArrayList<>());
+        }
+
+
+
+    }
+
+    /**
+     * @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,int jobType) {
+        //非院区任务
+        if(CheckJobTypeEnum.HOSP_SUPERVISOR.getKey()!=jobType){
+            if(deptMap.isEmpty()||checkUserDTOS.isEmpty()){return;}
+            checkRoleMap.put(roleId+"",new ArrayList<>());
+            //遍历科室
+            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.getDeptId().equals(jobNumDto.getDeptId()))
+                        {
+                            if(deptCheckUserDTO.getDoctorId().equals(jobNumDto.getDoctorId()))
+                            {
+                                if(jobNumDto.getStatus()==0){
+                                    deptCheckUserDTO.setJobNum(jobNumDto.getJobNum());
+                                }
+                                if(jobNumDto.getStatus()==1){
+
+                                    deptCheckUserDTO.setCheckNum(jobNumDto.getJobNum());
+                                }
+                            }
+
+                        }
+                    }
+                }
+                checkRoleMap.get(roleId+"").add(checkDeptDTO);
+            }
+        }
+        //院区任务不是同一科室的人员数量增加
+        else if(CheckJobTypeEnum.HOSP_SUPERVISOR.getKey()==jobType)
+        {
+            checkRoleMap.get(roleId+"").stream().forEach(checkDeptDTO -> {
+                if(!ListUtil.isEmpty(checkDeptDTO.getDeptcheckUsers())){
+                    checkDeptDTO.getDeptcheckUsers().stream().forEach(deptCheckUser -> {
+                        userJobs.stream().forEach(userJob -> {
+                            if(deptCheckUser.getDoctorId().equals(userJob.getDoctorId())){
+                                if(userJob.getStatus()==0){
+                                    deptCheckUser.setJobNum(userJob.getJobNum());
+                                }
+                                if(userJob.getStatus()==1){
+                                    deptCheckUser.setCheckNum(userJob.getJobNum());
+                                }
+                            }
+                        });
+                    });
+                }
+            });
+        }
+    }
+
+
+
+    /**
+     * @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,"入参为空");
+        }
+        if(StringUtil.isBlank(distributionJobVO.getCheckDept())){
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,"核查人科室(checkDept)为空");
+        }
+        if(distributionJobVO.getBehospitalDepts()==null
+                ||distributionJobVO.getBehospitalDepts().isEmpty()){
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,"核查任务科室集合(behospitalDepts)为空");
+        }
+        if(StringUtil.isEmpty(distributionJobVO.getJobType()))
+        {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL,"核查任务类型(jobType)为空");
+        }
+        //全院的话要判断院级核查人员和核查病历不是同一科室
+        if(CheckJobTypeEnum.HOSP_SUPERVISOR.getKey()==Integer.parseInt(distributionJobVO.getJobType())){
+            for(String deptId:distributionJobVO.getCheckDept().split(",")){
+                if(distributionJobVO.getBehospitalDepts().contains(deptId)){
+                    throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,"院级核查人员和核查病历是同一科室");
+                }
+            }
+
+        }
+        //获取人员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取消分配
+                Long a = null;
+                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",a)
+                        .set("job_distribution_name", a)
+                        .set("check_id", a)
+                        .set("check_name", a)
+                        .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 IPage<CheckJobDTO> getCheckListByUserId(CheckJobPageVO checkJobVO) {
+        //非空校验
+        if(StringUtil.isBlank(checkJobVO.getCheckId()))
+        {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "没有传核查用户id!");
+        }
+        IPage<CheckJobDTO> checkJobDTOS= baseMapper.getCheckListByUserId(checkJobVO);
+        //获取当前登录人员
+        Long principleId = Long.valueOf(SysUserUtils.getCurrentPrincipleID());
+        List<CheckJobDTO> outCheckJobDTOS = new ArrayList<>();
+        //判断分配人员是否是当前人员
+        for(CheckJobDTO checkJobDTO:checkJobDTOS.getRecords())
+        {
+            if (principleId.equals(checkJobDTO.getJobDistributor()))
+            {
+                checkJobDTO.setDelFlag(true);
+            }
+            else {
+                checkJobDTO.setDelFlag(false);
+            }
+            outCheckJobDTOS.add(checkJobDTO);
+        }
+        checkJobDTOS.setRecords(outCheckJobDTOS);
+        return checkJobDTOS;
+    }
 }

+ 312 - 0
src/main/java/com/diagbot/facade/MedCheckWorkFacade.java

@@ -0,0 +1,312 @@
+package com.diagbot.facade;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.BasDeptInfoDTO;
+import com.diagbot.dto.BehospitalInfoAgeDTO;
+import com.diagbot.dto.CheckWorkDTO;
+import com.diagbot.dto.MedicalRecordDTO;
+import com.diagbot.entity.MedBehospitalType;
+import com.diagbot.entity.MedCheckInfo;
+import com.diagbot.entity.SysTaskCron;
+import com.diagbot.entity.SysUser;
+import com.diagbot.enums.CheckJobTypeEnum;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.impl.MedBehospitalTypeServiceImpl;
+import com.diagbot.service.impl.MedCheckInfoServiceImpl;
+import com.diagbot.service.impl.MedicalRecordServiceImpl;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.StringUtil;
+import com.diagbot.util.SysUserUtils;
+import com.diagbot.vo.CheckWorkPageVO;
+import com.diagbot.vo.MedCheckWorkAddVO;
+import com.diagbot.vo.RecordTypeVO;
+import com.diagbot.vo.SysUserBaseVO;
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+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.Set;
+import java.util.stream.Collectors;
+
+
+/**
+ * @author songxl
+ * @since 2021-05-11
+ */
+@Slf4j
+@Component
+public class MedCheckWorkFacade {
+    @Autowired
+    SysUserFacade sysUserFacade;
+    @Autowired
+    private MedCheckInfoServiceImpl medCheckInfoServiceImpl;
+    @Autowired
+    private MedCheckInfoFacade medCheckInfoFacade;
+    @Autowired
+    private MedBehospitalTypeServiceImpl medBehospitalTypeServiceImpl;
+    @Autowired
+    private MedicalRecordServiceImpl medicalRecordServiceImpl;
+    @Autowired
+    private SysTaskCronFacade sysTaskCronFacade;
+    @Autowired
+    private BehospitalInfoFacade behospitalInfoFacade;
+
+    /**
+     * @Author songxl
+     * @Description 批量操作核查任务(增加和删除)
+     * @Date 2021/5/11
+     * @Param [medCheckWorkVO]
+     * @Return java.lang.Boolean
+     * @MethodName addCheck
+     */
+    public Boolean addCheckWork(MedCheckWorkAddVO medCheckWorkVO) {
+
+        boolean flag = false;
+        Date now = DateUtil.now();
+        //获取核查任务类型(0-科室任务 1-院级 2-质控科)
+        Integer workType = medCheckWorkVO.getJobType();
+        //获取操作类型(0-取消,1-添加)
+        Integer checkStatus = medCheckWorkVO.getCheckStatus();
+        Long hospitalId = Long.parseLong(SysUserUtils.getCurrentHospitalID());
+        Long principleId = Long.valueOf(SysUserUtils.getCurrentPrincipleID());
+        SysUser user = sysUserFacade.getOne(new QueryWrapper<SysUser>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("id", principleId)
+                .eq("status", 1));
+        String principleName = user.getLinkman();
+        //取消核查任务【操作类型(0-取消,1-添加)】
+        if (checkStatus != null && checkStatus == 0) {
+            //判断核查任务是否生成
+            QueryWrapper<MedCheckInfo> medicalRecordQe = new QueryWrapper<>();
+            medicalRecordQe.eq("hospital_id", hospitalId);
+            medicalRecordQe.eq("is_deleted", IsDeleteEnum.N.getKey());
+            if (medCheckWorkVO.getBehospitalCodeList().size() > 0) {
+                medicalRecordQe.in("behospital_code", medCheckWorkVO.getBehospitalCodeList());
+            }
+            List<MedCheckInfo> list = medCheckInfoFacade.list(medicalRecordQe);
+            if (ListUtil.isEmpty(list)) {
+                throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL, "存在未生成核查任务!");
+            }
+
+            //创建用户集合
+            Set<Long> creaters = list.stream().map(MedCheckInfo::getJobCreator).collect(Collectors.toSet());
+            if (creaters != null) {
+                //移除当前用户如果还有其他用户
+                creaters.remove(principleId);
+                if (creaters.size() > 0) {
+                    throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL, "无法取消他人生成任务!");
+                }
+            }
+            int i = medCheckInfoFacade.getBaseMapper().deleteBatchCodes(medCheckWorkVO.getBehospitalCodeList());
+            if (i != 0) {
+                return true;
+            }
+        } else if (checkStatus != null && checkStatus == 1) {
+            //生成核查任务
+            MedCheckInfo data = medCheckInfoFacade.getOne(new QueryWrapper<MedCheckInfo>()
+                    .eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("hospital_id", hospitalId)
+                    .in("behospital_code", medCheckWorkVO.getBehospitalCodeList())
+            );
+            //任务是否存在
+            if (data != null) {
+                throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL, "核查任务已存在!");
+            }
+
+            //该病历没有核查的时候, 就添加核查记录
+            List<MedCheckInfo> medCheckInfoList = new ArrayList<>();
+            for (String behospitalCode : medCheckWorkVO.getBehospitalCodeList()) {
+                MedCheckInfo medCheckInfo = new MedCheckInfo();
+                medCheckInfo.setIsDeleted(IsDeleteEnum.N.getKey());
+                medCheckInfo.setGmtCreate(now);
+                medCheckInfo.setBehospitalCode(behospitalCode);
+                medCheckInfo.setHospitalId(hospitalId);
+                medCheckInfo.setCheckType(medCheckWorkVO.getCheckType());
+                medCheckInfo.setJobCreator(principleId);
+                medCheckInfo.setJobCreatorName(principleName);
+                medCheckInfo.setJobCreateTime(now);
+                medCheckInfo.setJobType(medCheckWorkVO.getJobType());
+                medCheckInfoList.add(medCheckInfo);
+            }
+            flag = medCheckInfoServiceImpl.saveBatch(medCheckInfoList);
+        }
+        return flag;
+    }
+
+    /**
+     * @Author songxl
+     * @Description 获取每日住院患者的类型(出院、病危、抢救。。。)
+     * @Date 2021/5/11
+     * @Param [param]
+     * @Return void
+     * @MethodName execute
+     */
+    public void execute(String param) {
+        JSONObject paramJson = JSONObject.parseObject(param);
+        Long hospiatlId = paramJson.getLong("hospital");
+        JSONObject typeValue = paramJson.getJSONObject("typeVal");
+        JSONObject typeName = paramJson.getJSONObject("typeName");
+        int searchSize = paramJson.getInteger("searchSize");
+        int batchSize = paramJson.getInteger("batchSize");
+
+
+        //定义批量插入的集合
+        HashMap<String, MedBehospitalType> medBehospitalTypeMap = new HashMap<>();
+        //1.获取有指定文书、没有患者类型的患者数据
+        RecordTypeVO recordContentVO = new RecordTypeVO();
+        recordContentVO.setHospitalId(hospiatlId);
+        recordContentVO.setModeList(new ArrayList<>(typeValue.keySet()));
+        List<MedicalRecordDTO> medicalRecordList = medicalRecordServiceImpl.getMedicalRecord(recordContentVO);
+        if (medicalRecordList != null && !medicalRecordList.isEmpty()) {
+            getPatientRecordType(medBehospitalTypeMap, medicalRecordList, typeValue, typeName, hospiatlId);
+        }
+        //2.批量执行插入操作
+        try {
+            if (medBehospitalTypeMap != null && medBehospitalTypeMap.size() > 0) {
+                List<MedBehospitalType> medBehospitalTypeList = new ArrayList<>(medBehospitalTypeMap.values());
+                medBehospitalTypeServiceImpl.saveOrUpdateBatch(medBehospitalTypeList, batchSize);
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * @Author songxl
+     * @Description 获取患者类型存入批量插入map
+     * @Date 2021/5/11
+     * @Param [medBehospitalTypeMap, medicalRecordList, typeValue, typeName, hospiatlId]
+     * @Return void
+     * @MethodName getPatientRecordType
+     */
+    private void getPatientRecordType(HashMap<String, MedBehospitalType> medBehospitalTypeMap,
+                                      List<MedicalRecordDTO> medicalRecordList,
+                                      JSONObject typeValue,
+                                      JSONObject typeName, Long hospiatlId) {
+
+        if (medicalRecordList == null || medicalRecordList.isEmpty()) {
+            return;
+        }
+        //1.遍历查询出来的结果
+        for (MedicalRecordDTO medicalRecordDTO : medicalRecordList) {
+            //2.判断批量插入map中有没有这个患者
+            if (medBehospitalTypeMap.containsKey(medicalRecordDTO.getBehospitalCode())) {
+                //3.比较这两次的分值大小
+                int lval = medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).getValue();
+                int nval = typeValue.getInteger(medicalRecordDTO.getModeId() + "");
+                if (nval > lval) {
+                    medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).setValue(nval);
+                    medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode())
+                            .setBehospitalType(typeName.getString(medicalRecordDTO.getModeId() + ""));
+                }
+            } else {
+                //4.获取分值记录这个患者
+                MedBehospitalType medBehospitalType = new MedBehospitalType();
+                medBehospitalType.setBehospitalCode(medicalRecordDTO.getBehospitalCode());
+                medBehospitalType.setBehospitalType(typeName.getString(medicalRecordDTO.getModeId() + ""));
+                medBehospitalType.setValue(typeValue.getInteger(medicalRecordDTO.getModeId() + ""));
+                medBehospitalType.setCreateTime(DateUtil.now());
+                medBehospitalType.setHospitalId(hospiatlId);
+                medBehospitalTypeMap.put(medicalRecordDTO.getBehospitalCode(), medBehospitalType);
+            }
+        }
+    }
+
+
+    /**
+     * 分页
+     *
+     * @param checkWorkPageVO
+     * @return
+     */
+    public IPage<CheckWorkDTO> pageFac(CheckWorkPageVO checkWorkPageVO) {
+        checkWorkPageSet(checkWorkPageVO);
+        IPage<CheckWorkDTO> res = medCheckInfoFacade.getBaseMapper().getCheckWorkPage(checkWorkPageVO);
+        if (res == null || ListUtil.isEmpty(res.getRecords())) {
+            return res;
+        }
+
+        List<String> behospitalCodes = res.getRecords().stream().map(CheckWorkDTO::getBehospitalCode).collect(Collectors.toList());
+        Map<String, BehospitalInfoAgeDTO> ageMap = behospitalInfoFacade.getBehospitalInfoAge(checkWorkPageVO.getHospitalId(), behospitalCodes).stream().collect(Collectors.toMap(i -> i.getBehospitalCode(), i -> i));
+        res.getRecords().forEach(i -> {
+            i.setAge(ageMap.get(i.getBehospitalCode()) == null ? "" : ageMap.get(i.getBehospitalCode()).getAge());
+        });
+
+        //更新delFlag
+        Long principleId = Long.valueOf(SysUserUtils.getCurrentPrincipleID());
+        res.getRecords().stream().forEach(checkWorkDTO -> {
+            if (principleId.equals(checkWorkDTO.getJobCreator())) {
+                checkWorkDTO.setDelFlag(true);
+            }
+        });
+        return res;
+    }
+
+    private void checkWorkPageSet(CheckWorkPageVO checkWorkPageVO) {
+        //入参验证
+        //出院时间
+        if (null != checkWorkPageVO && null != checkWorkPageVO.getStartDate()) {
+            checkWorkPageVO.setStartDate(DateUtil.getFirstTimeOfDay(checkWorkPageVO.getStartDate()));
+        }
+        if (null != checkWorkPageVO && null != checkWorkPageVO.getEndDate()) {
+            checkWorkPageVO.setEndDate(DateUtil.getFirstTimeOfDay(DateUtil.addDay(checkWorkPageVO.getEndDate(), 1)));
+        }
+        if (null != checkWorkPageVO && null != checkWorkPageVO.getStartDate() && null != checkWorkPageVO.getEndDate()) {
+            if (DateUtil.after(checkWorkPageVO.getStartDate(), checkWorkPageVO.getEndDate())) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "出院时间的开始时间必须小于结束时间!");
+            }
+        }
+        //住院天数
+        if (null != checkWorkPageVO && null != checkWorkPageVO.getSmallDay() && null != checkWorkPageVO.getBigDay()) {
+            if (checkWorkPageVO.getSmallDay() > checkWorkPageVO.getBigDay()) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "住院天数区间有误!");
+            }
+        }
+        checkWorkPageVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
+
+        if (StringUtil.isNotBlank(checkWorkPageVO.getJobType()) && (CheckJobTypeEnum.DEPT_SUPERVISOR.getKey() + "").equals(checkWorkPageVO.getJobType())) {
+            SysUserBaseVO sysUserBaseVO = new SysUserBaseVO();
+            sysUserBaseVO.setUserId(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
+            List<String> deptIds = Lists.newArrayList();
+            List<BasDeptInfoDTO> selDepts = sysUserFacade.getUserDepts(sysUserBaseVO).getSelDepts();
+            if (ListUtil.isNotEmpty(selDepts)) {
+                deptIds = selDepts.stream().map(i -> i.getDeptId()).collect(Collectors.toList());
+            }
+            if (ListUtil.isNotEmpty(checkWorkPageVO.getDepartment())) {
+                deptIds.retainAll(checkWorkPageVO.getDepartment());
+            }
+            if (ListUtil.isEmpty(deptIds)) {
+                deptIds.add("999999999999");
+            }
+            checkWorkPageVO.setDepartment(deptIds);
+        }
+    }
+
+    public boolean createMedBeHospitalInfoType() {
+        //1.获取定时任务
+        SysTaskCron task = sysTaskCronFacade.getOne(new QueryWrapper<SysTaskCron>()
+                .eq("cron_code", "TASK019"), false);
+        //2.执行定时任务
+        if (null != task && StringUtil.isNotBlank(task.getCron())) {
+            try {
+                execute(task.getParam());
+            } catch (Exception e) {
+                e.printStackTrace();
+                return false;
+            }
+            return true;
+        }
+        return false;
+    }
+}

+ 59 - 0
src/main/java/com/diagbot/facade/QcresultInfoFacade.java

@@ -6,6 +6,7 @@ import com.diagbot.dto.AlgorithmDTO;
 import com.diagbot.dto.AnalyzeDTO;
 import com.diagbot.dto.QcResultDTO;
 import com.diagbot.entity.BehospitalInfo;
+import com.diagbot.entity.MedCheckInfo;
 import com.diagbot.entity.MedQcresultCases;
 import com.diagbot.entity.QcresultDetail;
 import com.diagbot.entity.QcresultInfo;
@@ -49,6 +50,8 @@ public class QcresultInfoFacade extends QcresultInfoServiceImpl {
     @Autowired
     private BehospitalInfoFacade behospitalInfoFacade;
     @Autowired
+    private MedCheckInfoFacade medCheckInfoFacade;
+    @Autowired
     @Qualifier("medQcresultCasesServiceImpl")
     private MedQcresultCasesServiceImpl medQcresultCasesService;
 
@@ -107,11 +110,13 @@ public class QcresultInfoFacade extends QcresultInfoServiceImpl {
         algorithmVO.setHospitalId(hospitalId);
         algorithmVO.setBehospitalCode(qcresultVO.getBehospitalCode());
         algorithmVO.setIsPlacefile(behospitalInfos.get(0).getIsPlacefile());
+        algorithmVO.setDelStatus(qcresultVO.getDelStatus());
         AlgorithmDTO algorithmDTO = algorithmFacade.getAlgorithmRes(algorithmVO);
         //更新质控评分结果信息
         AnalyzeVO analyzeVO = new AnalyzeVO();
         analyzeVO.setHospitalId(hospitalId);
         analyzeVO.setBehospitalCode(qcresultVO.getBehospitalCode());
+        analyzeVO.setDelStatus(qcresultVO.getDelStatus());
         Date date = this.saveQcResult(algorithmDTO, algorithmVO, analyzeVO, null, null, false, qcresultInfo);
         //返回参数组装
         AnalyzeDTO analyzeDTO = new AnalyzeDTO();
@@ -248,9 +253,63 @@ public class QcresultInfoFacade extends QcresultInfoServiceImpl {
                         .set("msg", algorithmVO.getOptResultAlgVO().getMsg())
                         .set("score", algorithmVO.getOptResultAlgVO().getScore())
                         .set("opt_type", 3)
+                        .set("grade_type",2)
                         .set("modifier", useId)
                         .set("gmt_modified", now)
+                        .set("explain_info",algorithmVO.getOptResultAlgVO().getExplainInfo())
                 );
+                break;
+            case 4:
+                //获取病历核查人员id,该操作只能是核查员操作
+                Long checkId = medCheckInfoFacade.getOne(new QueryWrapper<MedCheckInfo>()
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .eq("hospital_id", analyzeVO.getHospitalId())
+                        .eq("behospital_code", analyzeVO.getBehospitalCode())).getCheckId();
+                if(checkId==null)
+                {
+                    throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "病历没有分配核查人员");
+                }
+                if(!checkId.equals(useId))
+                {
+                    throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "当前用户不是分配的核查人员");
+                }
+                //逻辑删除质控明细 0删除
+                if(analyzeVO.getDelStatus()==0)
+                {
+                    qcresultDetailServiceImpl.update(new UpdateWrapper<QcresultDetail>()
+                            .eq("id", algorithmVO.getOptResultAlgVO().getId())
+                            .eq("is_deleted", IsDeleteEnum.N.getKey())
+                            .eq("hospital_id", analyzeVO.getHospitalId())
+                            .eq("behospital_code", analyzeVO.getBehospitalCode())
+                            .set("is_deleted", IsDeleteEnum.Y.getKey())
+                            .set("grade_type",2)
+                            .set("opt_type", 2)
+                            .set("modifier", useId)
+                            .set("gmt_modified", now)
+                    );
+                }
+                //1恢复
+                else if(analyzeVO.getDelStatus()==1)
+                {
+                    //该条目是机器插入条目
+                    qcresultDetailServiceImpl.update(new UpdateWrapper<QcresultDetail>()
+                            .eq("id", algorithmVO.getOptResultAlgVO().getId())
+                            .eq("is_deleted", IsDeleteEnum.Y.getKey())
+                            .eq("hospital_id", analyzeVO.getHospitalId())
+                            .eq("behospital_code", analyzeVO.getBehospitalCode())
+                            .set("is_deleted", IsDeleteEnum.N.getKey())
+                            .set("grade_type",2)
+                            .set("opt_type", 1)
+                            .set("modifier", useId)
+                            .set("remark", null)
+                            .set("gmt_modified", now)
+                    );
+                }
+                else {
+                    throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "delStatus参数错误");
+                }
+
+
                 break;
             default:
                 /* DO NOTHING */

+ 211 - 0
src/main/java/com/diagbot/facade/RecordCheckFacade.java

@@ -0,0 +1,211 @@
+package com.diagbot.facade;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.BehospitalInfoAgeDTO;
+import com.diagbot.dto.CheckedRecordListDTO;
+import com.diagbot.dto.SysUserDeptDTO;
+import com.diagbot.entity.BasDeptInfo;
+import com.diagbot.entity.MedBehospitalType;
+import com.diagbot.entity.MedCheckInfo;
+import com.diagbot.entity.SysUserDept;
+import com.diagbot.entity.SysUserRole;
+import com.diagbot.enums.CheckJobTypeEnum;
+import com.diagbot.enums.CheckStatusEnum;
+import com.diagbot.enums.CheckTypeEnum;
+import com.diagbot.enums.CheckerRoleEnum;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.MedQcresultDetailService;
+import com.diagbot.service.impl.MedBehospitalTypeServiceImpl;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.SysUserUtils;
+import com.diagbot.vo.CheckedRecordListVO;
+import com.diagbot.vo.RecordCheckVO;
+import com.diagbot.vo.SysUserBaseVO;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2021/5/17 18:43
+ */
+@Component
+public class RecordCheckFacade {
+
+    @Autowired
+    SysUserFacade sysUserFacade;
+    @Autowired
+    SysUserDeptFacade sysUserDeptFacade;
+    @Autowired
+    SysUserRoleFacade sysUserRoleFacade;
+    @Autowired
+    MedCheckInfoFacade medCheckInfoFacade;
+    @Autowired
+    MedQcresultDetailService medQcresultDetailService;
+    @Autowired
+    BehospitalInfoFacade behospitalInfoFacade;
+    @Autowired
+    BasDeptInfoFacade basDeptInfoFacade;
+    @Autowired
+    MedBehospitalTypeServiceImpl medBehospitalTypeServiceImpl;
+
+
+    public IPage<CheckedRecordListDTO> checkedRecordList(CheckedRecordListVO checkedRecordListVO) {
+        Long hospitalId = Long.parseLong(SysUserUtils.getCurrentHospitalID());
+        Long userId = Long.parseLong(SysUserUtils.getCurrentPrincipleID());
+        SysUserBaseVO sysUserBaseVO = new SysUserBaseVO();
+        sysUserBaseVO.setUserId(userId);
+        List<Long> roleIds = sysUserFacade.getUserRoles(sysUserBaseVO).getSelRoles().stream().map(i -> i.getId()).collect(Collectors.toList());
+        List<String> deptIds = Lists.newArrayList();
+        SysUserDeptDTO sysUserDeptDTO = sysUserFacade.getUserDepts(sysUserBaseVO);
+        if (ListUtil.isNotEmpty(sysUserDeptDTO.getSelDepts())) {
+            deptIds.addAll(sysUserDeptDTO.getSelDepts().stream().map(i -> i.getDeptId()).collect(Collectors.toList()));
+        }
+        //1.2去除质管科
+        String zkkDeptId = basDeptInfoFacade.getOne(new QueryWrapper<BasDeptInfo>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id",hospitalId)
+                .eq("station","质管")).getDeptId();
+        List<Long> userIds = Lists.newArrayList();
+        List<String> JobTypes = Lists.newArrayList();
+        roleIds.forEach(roleId -> {
+            if (roleId.intValue() == CheckerRoleEnum.HOSP_SUPERVISOR.getKey()
+                    && (ListUtil.isEmpty(checkedRecordListVO.getCheckJobTypes()) || checkedRecordListVO.getCheckJobTypes().contains(CheckJobTypeEnum.HOSP_SUPERVISOR.getKey() + ""))) {
+                userIds.addAll(getUserIdsOfRoleId(hospitalId, null, CheckerRoleEnum.HOSP_GENERAL.getKey()));
+                JobTypes.add(CheckJobTypeEnum.HOSP_SUPERVISOR.getKey() + "");
+            } else if (roleId.intValue() == CheckerRoleEnum.QUAT_SUPERVISOR.getKey()
+                    && (ListUtil.isEmpty(checkedRecordListVO.getCheckJobTypes()) || checkedRecordListVO.getCheckJobTypes().contains(CheckJobTypeEnum.QUAT_SUPERVISOR.getKey() + ""))) {
+                //添加质管科人员
+                deptIds.add(zkkDeptId);
+                userIds.addAll(getUserIdsOfRoleId(hospitalId, deptIds, CheckerRoleEnum.QUAT_GENERAL.getKey()));
+                JobTypes.add(CheckJobTypeEnum.QUAT_SUPERVISOR.getKey() + "");
+            } else if (roleId.intValue() == CheckerRoleEnum.DEPT_SUPERVISOR.getKey() && ListUtil.isNotEmpty(deptIds)
+                    && (ListUtil.isEmpty(checkedRecordListVO.getCheckJobTypes()) || checkedRecordListVO.getCheckJobTypes().contains(CheckJobTypeEnum.DEPT_SUPERVISOR.getKey() + ""))) {
+                //移除质管科人员
+                deptIds.remove(zkkDeptId);
+                JobTypes.add(CheckJobTypeEnum.DEPT_SUPERVISOR.getKey() + "");
+                userIds.addAll(getUserIdsOfRoleId(hospitalId, deptIds, CheckerRoleEnum.DEPT_GENERAL.getKey()));
+            } else if ((roleId.intValue() == CheckerRoleEnum.DEPT_GENERAL.getKey() && ListUtil.isNotEmpty(deptIds))
+                    || roleId.intValue() == CheckerRoleEnum.QUAT_GENERAL.getKey() || roleId.intValue() == CheckerRoleEnum.HOSP_GENERAL.getKey()) {
+                userIds.add(userId);
+            }
+        });
+
+        //如果用户是质控科核查人员,在不传入任务类型的时候要添加质控科任务类型进行筛选
+        if(roleIds.contains(CheckerRoleEnum.QUAT_GENERAL.getKey()*1l)){
+            JobTypes.add(CheckJobTypeEnum.QUAT_SUPERVISOR.getKey() + "");
+        }
+        if(roleIds.contains(CheckerRoleEnum.DEPT_GENERAL.getKey()*1l)){
+            JobTypes.add(CheckJobTypeEnum.DEPT_SUPERVISOR.getKey() + "");
+        }
+        if(roleIds.contains(CheckerRoleEnum.HOSP_GENERAL.getKey()*1l)){
+            JobTypes.add(CheckJobTypeEnum.HOSP_SUPERVISOR.getKey() + "");
+        }
+
+        if(ListUtil.isEmpty(checkedRecordListVO.getCheckJobTypes())){
+            checkedRecordListVO.setCheckJobTypes(JobTypes);
+        }
+        if (ListUtil.isEmpty(userIds)) {
+            userIds.add(999999999999999999l);
+        }
+        checkedRecordListVO.setCurrentDeptIds(String.join(",", deptIds));
+        checkedRecordListVO.setCurrentGeneralUserIds(userIds);
+        checkedRecordListVO.setHospitalId(hospitalId);
+        IPage<CheckedRecordListDTO> iPage = medCheckInfoFacade.getBaseMapper().checkedRecordList(checkedRecordListVO);
+
+        if (ListUtil.isNotEmpty(iPage.getRecords())) {
+            List<String> behospitalCodes = iPage.getRecords().stream().map(i -> i.getBehospitalCode()).collect(Collectors.toList());
+            Map<String, BehospitalInfoAgeDTO> ageMap = behospitalInfoFacade.getBehospitalInfoAge(hospitalId, behospitalCodes).stream().collect(Collectors.toMap(i -> i.getBehospitalCode(), i -> i));
+            iPage.getRecords().forEach(i -> {
+                i.setMonth(i.getJobDistributionTime());
+                i.setStatus(CheckStatusEnum.getName(Integer.parseInt(i.getStatus())));
+                i.setAge(ageMap.get(i.getBehospitalCode()) == null ? "" : ageMap.get(i.getBehospitalCode()).getAge());
+            });
+        }
+
+        return iPage;
+    }
+
+    private List<Long> getUserIdsOfRoleId(Long hospitalId, List<String> deptIds, long roleId) {
+        QueryWrapper<SysUserDept> sysUserDeptQueryWrapper = new QueryWrapper<>();
+        sysUserDeptQueryWrapper.eq("hospital_id", hospitalId);
+        sysUserDeptQueryWrapper.in(ListUtil.isNotEmpty(deptIds), "dept_id", deptIds);
+        List<Long> userIds = sysUserDeptFacade.list(sysUserDeptQueryWrapper).stream().map(i -> i.getUserId()).collect(Collectors.toList());
+
+        if (ListUtil.isEmpty(userIds)) {
+            return null;
+        }
+        QueryWrapper<SysUserRole> sysUserRoleQueryWrapper = new QueryWrapper<>();
+        sysUserRoleQueryWrapper.in("user_id", userIds);
+        sysUserRoleQueryWrapper.eq("role_id", roleId);
+        return sysUserRoleFacade.list(sysUserRoleQueryWrapper).stream().map(i -> i.getUserId()).collect(Collectors.toList());
+    }
+
+    public boolean recordCheck(RecordCheckVO recordCheckVO) {
+        Long hospitalId = Long.parseLong(SysUserUtils.getCurrentHospitalID());
+        Long userId = Long.parseLong(SysUserUtils.getCurrentPrincipleID());
+
+        QueryWrapper<MedCheckInfo> medCheckInfoQueryWrapper = new QueryWrapper<>();
+        medCheckInfoQueryWrapper.eq("behospital_code", recordCheckVO.getBehospitalCode());
+        medCheckInfoQueryWrapper.eq("hospital_id", hospitalId);
+        medCheckInfoQueryWrapper.eq("check_id", userId);
+        medCheckInfoQueryWrapper.eq("check_type", CheckTypeEnum.ALL.getKey());
+        MedCheckInfo medCheckInfo = medCheckInfoFacade.getOne(medCheckInfoQueryWrapper);
+        if (medCheckInfo == null) {
+            throw new CommonException(CommonErrorCode.NOT_EXISTS, "该数据您暂无核查权限!");
+        }
+
+        medCheckInfo.setStatus(1);
+        medCheckInfo.setCheckTime(DateUtil.now());
+        medCheckInfoFacade.updateById(medCheckInfo);
+
+        return true;
+    }
+    /**
+     * @Author songxl
+     * @Description获取当前用户的任务来源 和筛选分值
+     * @Date  2021/5/28
+     * @Param []
+     * @Return java.util.Map<java.lang.String,java.lang.String>
+     * @MethodName getCheckType
+     */
+    public Map<String, Object> getCheckType() {
+        Map<String,Object> out = Maps.newLinkedHashMap();
+        Map<Integer,String> checkTypes = Maps.newLinkedHashMap();
+        Long userId = Long.parseLong(SysUserUtils.getCurrentPrincipleID());
+        SysUserBaseVO sysUserBaseVO = new SysUserBaseVO();
+        sysUserBaseVO.setUserId(userId);
+        List<Long> roleIds = sysUserFacade.getUserRoles(sysUserBaseVO).getSelRoles().stream().map(i -> i.getId()).collect(Collectors.toList());
+        roleIds.stream().forEach(roleId -> {
+            if (roleId.intValue() == CheckerRoleEnum.DEPT_SUPERVISOR.getKey()||roleId.intValue() == CheckerRoleEnum.DEPT_GENERAL.getKey()){
+                checkTypes.put(CheckJobTypeEnum.DEPT_SUPERVISOR.getKey(),CheckJobTypeEnum.DEPT_SUPERVISOR.getName());
+            }
+            if (roleId.intValue() == CheckerRoleEnum.QUAT_SUPERVISOR.getKey()||roleId.intValue() == CheckerRoleEnum.QUAT_GENERAL.getKey()){
+                checkTypes.put(CheckJobTypeEnum.QUAT_SUPERVISOR.getKey(),CheckJobTypeEnum.QUAT_SUPERVISOR.getName());
+            }
+            if (roleId.intValue() == CheckerRoleEnum.HOSP_SUPERVISOR.getKey()||roleId.intValue() == CheckerRoleEnum.HOSP_GENERAL.getKey()){
+                checkTypes.put(CheckJobTypeEnum.HOSP_SUPERVISOR.getKey(),CheckJobTypeEnum.HOSP_SUPERVISOR.getName());
+            }
+        });
+        Long hospitalId = Long.parseLong(SysUserUtils.getCurrentHospitalID());
+        List<Integer> valus = medBehospitalTypeServiceImpl.list(new QueryWrapper<MedBehospitalType>()
+                .eq("hospital_id", hospitalId)
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .isNotNull("value")
+                .groupBy("value")).stream().map(MedBehospitalType::getValue).collect(Collectors.toList());
+        out.put("source",checkTypes);
+        out.put("value",valus);
+        return out;
+    }
+}

+ 1 - 0
src/main/java/com/diagbot/facade/SysDictionaryFacade.java

@@ -60,4 +60,5 @@ public class SysDictionaryFacade extends SysDictionaryInfoServiceImpl {
         }
         return res;
     }
+
 }

+ 89 - 14
src/main/java/com/diagbot/facade/SysUserFacade.java

@@ -4,16 +4,7 @@ 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.client.AuthServiceClient;
-import com.diagbot.dto.BasDeptInfoDTO;
-import com.diagbot.dto.BasHospitalInfoDTO;
-import com.diagbot.dto.JwtDTO;
-import com.diagbot.dto.LoginDTO;
-import com.diagbot.dto.SysRoleDTO;
-import com.diagbot.dto.SysUserDeptDTO;
-import com.diagbot.dto.SysUserPermissionDTO;
-import com.diagbot.dto.SysUserQueryDTO;
-import com.diagbot.dto.SysUserRoleDTO;
-import com.diagbot.dto.UserLoginDTO;
+import com.diagbot.dto.*;
 import com.diagbot.entity.BasHospitalInfo;
 import com.diagbot.entity.JWT;
 import com.diagbot.entity.JwtStore;
@@ -90,6 +81,8 @@ public class SysUserFacade extends SysUserServiceImpl {
     private SysUserHospitalFacade sysUserHospitalFacade;
     @Autowired
     private SysUserRoleFacade sysUserRoleFacade;
+    @Autowired
+    private SysDictionaryFacade sysDictionaryFacade;
 
     /**
      * 获取jwt
@@ -129,11 +122,43 @@ public class SysUserFacade extends SysUserServiceImpl {
         data.setRefreshToken(jwt.getRefresh_token());
         data.setType(user.getType());
         data.setTypeCn(ConstantEnum.getName(user.getType()));//返回中文
+        //获取用户角色
+        try {
+            SysUserBaseVO sysUserBaseVO = new SysUserBaseVO();
+            sysUserBaseVO.setUserId(user.getId());
+            List<SysRoleDTO> selRoles =getlocalUserRoles(sysUserBaseVO);
+            if(selRoles!=null&&!selRoles.isEmpty())
+            {
+                data.setSelRoles(selRoles);
+            }
+
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
         //token存入redis
         JwtStore jwtStore = new JwtStore();
         jwtStore.setAccessToken(jwt.getAccess_token());
         jwtStore.setRefreshToken(jwt.getRefresh_token());
         tokenFacade.createToken(jwtStore);
+        /***
+         * 未加密密码复杂度判断
+         */
+        //获取用户医院id
+//        String hospitalID = SysUserUtils.getCurrentHospitalID();
+//        Long id = user.getId();
+//        QueryWrapper<SysUserHospital> UserHospitalQueryWrapper = new QueryWrapper<>();
+//        UserHospitalQueryWrapper
+//                .eq("user_id", id)
+//                .eq("is_deleted", IsDeleteEnum.N.getKey());
+//        SysUserHospital userHospital = sysUserHospitalFacade.getOne(UserHospitalQueryWrapper, false);
+//        Long hospitalId = userHospital.getHospitalId();
+//        String idStr = String.valueOf(hospitalId);
+//        Boolean passwordRegular = passwordRegular(password,idStr);
+//        if(!passwordRegular){
+//            data.setPasswordComplexity("密码复杂度过低,请及时修改密码");
+//        }
         return data;
     }
 
@@ -242,7 +267,6 @@ public class SysUserFacade extends SysUserServiceImpl {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
                     "原密码和新密码不能相同");
         }
-
         String userId = SysUserUtils.getCurrentPrincipleID();
         SysUser user = this.getOne(new QueryWrapper<SysUser>()
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
@@ -251,13 +275,16 @@ public class SysUserFacade extends SysUserServiceImpl {
         if (null == user) {
             throw new CommonException(ServiceErrorCode.USER_NOT_FOUND);
         }
-
         PasswordEncoder passwordEncoder
                 = PasswordEncoderFactories.createDelegatingPasswordEncoder();
         if (!passwordEncoder.matches(password, user.getPassword())) {
             throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "原密码错误");
         }
-
+//        String hospitalID = SysUserUtils.getCurrentHospitalID();
+//        Boolean regularBoolean = passwordRegular(modifyPassword,hospitalID);
+//        if(!regularBoolean){
+//            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "请输入正确格式的新密码");
+//        }
         String entryPassword = passwordEncoder.encode(modifyPassword);
         user.setPassword(entryPassword);
         user.setGmtModified(DateUtil.now());
@@ -266,6 +293,24 @@ public class SysUserFacade extends SysUserServiceImpl {
         return true;
     }
 
+    /**
+     * 未加密密文正则表达式  至少8个字符,1个大写字母,1个小写字母,1个数字和1个特殊字符:
+     * @param password
+     * @return
+     */
+    public Boolean passwordRegular(String password,String hospitalId){
+        //获取字点表中存储的正则表达式   "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&])[A-Za-z\\d$@$!%*?&]{8,}"
+        boolean check=true;
+        Map<String, Map<String, String>> dictionaryWithKey = sysDictionaryFacade.getDictionaryWithKey();
+        if(dictionaryWithKey!=null){
+            Map<String, String> stringStringMap = dictionaryWithKey.get("30");
+            if(stringStringMap!=null) {
+                String regular = stringStringMap.get(hospitalId);
+                check = password.matches(regular);
+            }
+        }
+        return check;
+    }
     /**
      * 登录
      *
@@ -285,7 +330,7 @@ public class SysUserFacade extends SysUserServiceImpl {
         List<SysUserRole> sysUserRoleList = sysUserRoleFacade.list(sysUserRoleQueryWrapper);
         if(ListUtil.isNotEmpty(sysUserRoleList)){
             sysUserRoleList.forEach(sysUserRole ->{
-                    roleSet.add(sysUserRole.getRoleId()+"");
+                roleSet.add(sysUserRole.getRoleId()+"");
             } );
         }
         if (user == null) {
@@ -466,6 +511,36 @@ public class SysUserFacade extends SysUserServiceImpl {
 
         return sysUserRoleDTO;
     }
+    /**
+     * 获取用户角色
+     *
+     * @param sysUserBaseVO 获取用户角色入参
+     * @return 用户角色信息
+     */
+    private List<SysRoleDTO> getlocalUserRoles(SysUserBaseVO sysUserBaseVO) {
+        SysUserRoleDTO sysUserRoleDTO = new SysUserRoleDTO();
+        sysUserRoleDTO.setUserId(sysUserBaseVO.getUserId());
+        List<SysRoleDTO> sysRoleDTOList = sysRoleFacade.listFac();
+        List<SysUserRole> sysUserRoleList
+                = sysUserRoleService.list(new QueryWrapper<SysUserRole>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("user_id", sysUserBaseVO.getUserId())
+        );
+        List<SysRoleDTO> selRoles = new ArrayList<>();
+        if (ListUtil.isNotEmpty(sysUserRoleList)) {
+            Set<Long> selRoleIds = sysUserRoleList.stream()
+                    .map(SysUserRole::getRoleId)
+                    .collect(Collectors.toSet());
+            for (SysRoleDTO sysRoleDTO : sysRoleDTOList) {
+                if (selRoleIds.contains(sysRoleDTO.getId())) {
+                    selRoles.add(sysRoleDTO);
+                }
+            }
+            sysUserRoleDTO.setSelRoles(selRoles);
+        }
+
+        return selRoles;
+    }
 
     /**
      * 用户启用

+ 26 - 3
src/main/java/com/diagbot/mapper/BehospitalInfoMapper.java

@@ -4,11 +4,26 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.*;
 import com.diagbot.entity.BehospitalInfo;
-import com.diagbot.entity.FilterRecordVO;
-import com.diagbot.vo.*;
+import com.diagbot.vo.AnalyzeCodeVO;
+import com.diagbot.vo.AnalyzeVO;
+import com.diagbot.vo.BehospitalPageVO;
+import com.diagbot.vo.CaseScoreVO;
+import com.diagbot.vo.EntryStatisticsVO;
+import com.diagbot.vo.ExportQcresultVO;
+import com.diagbot.vo.FilterMedicalCheckVO;
+import com.diagbot.vo.FilterOrderByDeptVO;
+import com.diagbot.vo.FilterOrderVO;
+import com.diagbot.vo.FilterPageByDeptVO;
+import com.diagbot.vo.FilterPageVO;
+import com.diagbot.vo.FilterUnModifyMRVO;
+import com.diagbot.vo.FilterVO;
+import com.diagbot.vo.MedIndexFilterVO;
+import com.diagbot.vo.QcResultPageVO;
+import com.diagbot.vo.QcResultShortPageVO;
+import com.diagbot.vo.ReBeHosPageVO;
+import com.diagbot.vo.TaskVO;
 import org.apache.ibatis.annotations.Param;
 
-import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -729,4 +744,12 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @return
      */
     public List<Map<String,String>> malignancy(@Param("filterVO") FilterVO filterVO);
+
+    /**
+     * 获取患者年龄信息(通过出生日期和入院日期重新计算)
+     * @param hospitalId
+     * @param behospitalCodes
+     * @return
+     */
+    List<BehospitalInfoAgeDTO> getBehospitalInfoAge(Long hospitalId, List<String> behospitalCodes);
 }

+ 16 - 0
src/main/java/com/diagbot/mapper/MedBehospitalTypeMapper.java

@@ -0,0 +1,16 @@
+package com.diagbot.mapper;
+
+import com.diagbot.entity.MedBehospitalType;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author songxl
+ * @since 2021-05-11
+ */
+public interface MedBehospitalTypeMapper extends BaseMapper<MedBehospitalType> {
+
+}

+ 27 - 1
src/main/java/com/diagbot/mapper/MedCheckInfoMapper.java

@@ -1,7 +1,20 @@
 package com.diagbot.mapper;
 
-import com.diagbot.entity.MedCheckInfo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.CheckJobDTO;
+import com.diagbot.dto.CheckUserDTO;
+import com.diagbot.dto.CheckWorkDTO;
+import com.diagbot.dto.CheckedRecordListDTO;
+import com.diagbot.dto.DeptCheckUserDTO;
+import com.diagbot.entity.MedCheckInfo;
+import com.diagbot.vo.CheckJobPageVO;
+import com.diagbot.vo.CheckJobVO;
+import com.diagbot.vo.CheckUserVO;
+import com.diagbot.vo.CheckWorkPageVO;
+import com.diagbot.vo.CheckedRecordListVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -12,5 +25,18 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @since 2020-07-06
  */
 public interface MedCheckInfoMapper extends BaseMapper<MedCheckInfo> {
+    //获取未分配的核查任务
+    IPage<CheckJobDTO> getCheckList(CheckJobPageVO checkJobVO);
+    //临床科室核查人员通过id获取核查人员的核查任务数
+    List<DeptCheckUserDTO> getDeptJobNumByUserId(CheckUserVO checkUserVO);
+    //核查任务列表
+    IPage<CheckWorkDTO> getCheckWorkPage(CheckWorkPageVO checkWorkPageVO);
+    //获取指定核查人员的核查任务
+    IPage<CheckJobDTO> getCheckListByUserId(CheckJobPageVO checkJobVO);
+    //取消核查任务
+    int deleteBatchCodes(List<String> list);
 
+    IPage<CheckedRecordListDTO> checkedRecordList(CheckedRecordListVO checkedRecordListVO);
+    //获取核查人员用户科室、姓名、角色
+    List<CheckUserDTO> getCheckUser(CheckUserVO checkUserVOS);
 }

+ 5 - 0
src/main/java/com/diagbot/mapper/MedicalRecordMapper.java

@@ -1,10 +1,12 @@
 package com.diagbot.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.dto.MedicalRecordDTO;
 import com.diagbot.dto.RecordContentDTO;
 import com.diagbot.entity.MedicalRecord;
 import com.diagbot.vo.RecordContentVO;
 import com.diagbot.vo.RecordDataVO;
+import com.diagbot.vo.RecordTypeVO;
 
 import java.util.List;
 
@@ -22,4 +24,7 @@ public interface MedicalRecordMapper extends BaseMapper<MedicalRecord> {
     public List<RecordContentDTO> getRecordData(RecordDataVO recordContentVO);
 
     public void updateBatchByKey(List<MedicalRecord> list);
+    public int getRecordCount(RecordTypeVO recordContentVO);
+
+    List<MedicalRecordDTO> getMedicalRecord(RecordTypeVO recordContentVO);
 }

+ 16 - 0
src/main/java/com/diagbot/service/MedBehospitalTypeService.java

@@ -0,0 +1,16 @@
+package com.diagbot.service;
+
+import com.diagbot.entity.MedBehospitalType;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author songxl
+ * @since 2021-05-11
+ */
+public interface MedBehospitalTypeService extends IService<MedBehospitalType> {
+
+}

+ 9 - 1
src/main/java/com/diagbot/service/MedCheckInfoService.java

@@ -1,7 +1,15 @@
 package com.diagbot.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.CheckJobDTO;
+import com.diagbot.dto.DeptCheckUserDTO;
 import com.diagbot.entity.MedCheckInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.vo.CheckJobPageVO;
+import com.diagbot.vo.CheckJobVO;
+import com.diagbot.vo.CheckUserVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -12,5 +20,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2020-07-06
  */
 public interface MedCheckInfoService extends IService<MedCheckInfo> {
-
+    public IPage<CheckJobDTO> getCheckList(CheckJobPageVO checkJobVO);
 }

+ 5 - 0
src/main/java/com/diagbot/service/MedicalRecordService.java

@@ -1,10 +1,12 @@
 package com.diagbot.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.dto.MedicalRecordDTO;
 import com.diagbot.dto.RecordContentDTO;
 import com.diagbot.entity.MedicalRecord;
 import com.diagbot.vo.RecordContentVO;
 import com.diagbot.vo.RecordDataVO;
+import com.diagbot.vo.RecordTypeVO;
 
 import java.util.List;
 
@@ -20,4 +22,7 @@ public interface MedicalRecordService extends IService<MedicalRecord> {
 
     public List<RecordContentDTO> getRecordContent(RecordContentVO recordContentVO);
     public List<RecordContentDTO> getRecordData(RecordDataVO recordContentVO);
+    public int getRecordCount(RecordTypeVO recordContentVO);
+
+    public List<MedicalRecordDTO> getMedicalRecord(RecordTypeVO recordContentVO);
 }

+ 20 - 0
src/main/java/com/diagbot/service/impl/MedBehospitalTypeServiceImpl.java

@@ -0,0 +1,20 @@
+package com.diagbot.service.impl;
+
+import com.diagbot.entity.MedBehospitalType;
+import com.diagbot.mapper.MedBehospitalTypeMapper;
+import com.diagbot.service.MedBehospitalTypeService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author songxl
+ * @since 2021-05-11
+ */
+@Service
+public class MedBehospitalTypeServiceImpl extends ServiceImpl<MedBehospitalTypeMapper, MedBehospitalType> implements MedBehospitalTypeService {
+
+}

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

@@ -1,11 +1,19 @@
 package com.diagbot.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.CheckJobDTO;
+import com.diagbot.dto.CheckWorkDTO;
 import com.diagbot.entity.MedCheckInfo;
 import com.diagbot.mapper.MedCheckInfoMapper;
 import com.diagbot.service.MedCheckInfoService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.vo.CheckJobPageVO;
+import com.diagbot.vo.CheckJobVO;
+import com.diagbot.vo.CheckWorkPageVO;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 核查表 服务实现类
@@ -17,4 +25,15 @@ import org.springframework.stereotype.Service;
 @Service
 public class MedCheckInfoServiceImpl extends ServiceImpl<MedCheckInfoMapper, MedCheckInfo> implements MedCheckInfoService {
 
+    public IPage<CheckWorkDTO> getCheckWorkPage(CheckWorkPageVO checkWorkPageVO) {
+        return baseMapper.getCheckWorkPage(checkWorkPageVO);
+    }
+
+    public int deleteBatchCodes(List<String> list){
+        return baseMapper.deleteBatchCodes(list);
+    }
+    @Override
+    public IPage<CheckJobDTO> getCheckList(CheckJobPageVO checkJobVO) {
+        return baseMapper.getCheckList(checkJobVO);
+    }
 }

+ 12 - 0
src/main/java/com/diagbot/service/impl/MedicalRecordServiceImpl.java

@@ -1,5 +1,6 @@
 package com.diagbot.service.impl;
 
+import com.diagbot.dto.MedicalRecordDTO;
 import com.diagbot.dto.RecordContentDTO;
 import com.diagbot.entity.MedicalRecord;
 import com.diagbot.mapper.MedicalRecordMapper;
@@ -7,6 +8,7 @@ import com.diagbot.service.MedicalRecordService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.diagbot.vo.RecordContentVO;
 import com.diagbot.vo.RecordDataVO;
+import com.diagbot.vo.RecordTypeVO;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -31,6 +33,16 @@ public class MedicalRecordServiceImpl extends ServiceImpl<MedicalRecordMapper, M
         return baseMapper.getRecordData(recordContentVO);
     }
 
+    @Override
+    public int getRecordCount(RecordTypeVO recordContentVO) {
+        return baseMapper.getRecordCount(recordContentVO);
+    }
+
+    @Override
+    public List<MedicalRecordDTO> getMedicalRecord(RecordTypeVO recordContentVO) {
+        return baseMapper.getMedicalRecord(recordContentVO);
+    }
+
     /**
      * 根据文书编码、医院编码、病人住院编码
      * @param list

+ 71 - 0
src/main/java/com/diagbot/task/BehospitalInfoTypeTask.java

@@ -0,0 +1,71 @@
+package com.diagbot.task;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.entity.SysTaskCron;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.facade.BehospitalInfoFacade;
+import com.diagbot.facade.MedCheckWorkFacade;
+import com.diagbot.facade.SysTaskCronFacade;
+import com.diagbot.util.StringUtil;
+import com.diagbot.vo.TaskVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.Trigger;
+import org.springframework.scheduling.TriggerContext;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.SchedulingConfigurer;
+import org.springframework.scheduling.config.ScheduledTaskRegistrar;
+import org.springframework.scheduling.support.CronTrigger;
+
+import java.time.LocalDateTime;
+import java.util.Date;
+
+@Configuration      //1.主要用于标记配置类,兼备Component的效果。
+@EnableScheduling   // 2.开启定时任务(每隔半小时检查今天患者,然后修改今天的患者的类型)
+@Slf4j
+public class BehospitalInfoTypeTask implements SchedulingConfigurer{
+    @Autowired
+    private SysTaskCronFacade sysTaskCronFacade;
+
+    private SysTaskCron task001 = new SysTaskCron();
+
+    private String param = "";
+
+    //添加核查任务
+    @Autowired
+    private MedCheckWorkFacade medCheckWorkFacade;
+    /**
+     * 执行定时任务.
+     */
+    @Override
+    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
+        taskRegistrar.addTriggerTask(new Runnable() {
+            @Override
+            public void run() {
+                //1.添加任务内容(Runnable)
+                if (null != task001
+                        && task001.getIsDeleted().equals(IsDeleteEnum.N.getKey())
+                        && task001.getIsUsed().equals(1)) {
+                    log.info("执行动态定时任务: " + LocalDateTime.now().toLocalTime());
+                    medCheckWorkFacade.execute(param);
+                }
+            }
+        }, new Trigger() {
+            @Override
+            public Date nextExecutionTime(TriggerContext triggerContext) {
+                //2.1 从数据库获取执行周期
+                task001 = sysTaskCronFacade.getOne(new QueryWrapper<SysTaskCron>()
+                        .eq("cron_code", "TASK019"), false);
+                String cron = "0 0/30 * * * ?";
+                //2.2 合法性校验.
+                if (null != task001 && StringUtil.isNotBlank(task001.getCron())) {
+                    cron = task001.getCron();
+                    param = task001.getParam();
+                }
+                CronTrigger trigger = new CronTrigger(cron);
+                return trigger.nextExecutionTime(triggerContext);
+            }
+        });
+    }
+}

+ 3 - 1
src/main/java/com/diagbot/vo/AlgorithmVO.java

@@ -14,8 +14,10 @@ import java.util.List;
 @Getter
 @Setter
 public class AlgorithmVO {
-    //操作类型(0:基础评分,1:新增条目评分,2:删除条目,3:修改条目)
+    //操作类型(0:基础评分,1:新增条目评分,2:删除条目,3:修改条目,4:逻辑删除、恢复条目)
     private Integer type;
+    //0删除 1恢复
+    private Integer delStatus;
     //操作条目
     private QcResultAlgVO optResultAlgVO;
     //扣分条目

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

@@ -24,4 +24,10 @@ public class AnalyzeVO {
     //是否有病案首页(0:无,1:有)
     @ApiModelProperty(hidden = true)
     private Integer haveHomePage;
+    //逻辑删除接口(1-恢复和0-删除)标志
+    @ApiModelProperty(hidden = true)
+    private Integer delStatus;
+    //已核查不能再次评分校验
+    @ApiModelProperty(hidden = true)
+    private Boolean checkFlag = false;
 }

+ 54 - 0
src/main/java/com/diagbot/vo/CheckJobPageVO.java

@@ -0,0 +1,54 @@
+package com.diagbot.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @description: 分配任务入参对象-分页
+ * @author: songxl
+ * @time: 2021/05/17
+ */
+@Data
+public class CheckJobPageVO extends Page implements Serializable {
+    private static final long serialVersionUID = 1L;
+    //生成任务开始时间
+    @ApiModelProperty("生成任务开始时间,格式为:yyyy-MM-dd")
+    private String startTime;
+    //生成任务结束时间
+    @ApiModelProperty("生成任务结束时间,格式为:yyyy-MM-dd")
+    private String endTime;
+    //出院开始时间
+    @ApiModelProperty("出院开始时间,格式为:yyyy-MM-dd")
+    private String behosDateStart;
+    //出院结束时间
+    @ApiModelProperty("出院结束时间,格式为:yyyy-MM-dd")
+    private String behosDateEnd;
+    //任务类型
+    @ApiModelProperty("任务类型 0-科室任务 1-院级 2-质控科")
+    private String jobType;
+    //核查用户id
+    @ApiModelProperty("核查用户id")
+    private String checkId;
+    //病人姓名
+    @ApiModelProperty("病人姓名")
+    private String name;
+    //病人住院序号
+    @ApiModelProperty("病人住院序号")
+    private String behospitalCode;
+    //主诊断医生
+    @ApiModelProperty("主诊断医生")
+    private String doctorName;
+    //科室id集合
+    @ApiModelProperty(hidden = true)
+    private List<String> deptList;
+    //筛选分值集合
+    @ApiModelProperty("筛选分值集合")
+    private List<String> values;
+
+
+
+}

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

@@ -0,0 +1,51 @@
+package com.diagbot.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @description: 分配任务入参对象
+ * @author: songxl
+ * @time: 2021/05/17
+ */
+@Data
+public class CheckJobVO {
+    //生成任务开始时间
+    @ApiModelProperty("生成任务开始时间,格式为:yyyy-MM-dd")
+    private String startTime;
+    //生成任务结束时间
+    @ApiModelProperty("生成任务结束时间,格式为:yyyy-MM-dd")
+    private String endTime;
+    //出院开始时间
+    @ApiModelProperty("出院开始时间,格式为:yyyy-MM-dd")
+    private String behosDateStart;
+    //出院结束时间
+    @ApiModelProperty("出院结束时间,格式为:yyyy-MM-dd")
+    private String behosDateEnd;
+    //核查用户id
+    @ApiModelProperty("核查用户id")
+    private String checkId;
+    //任务类型
+    @ApiModelProperty(hidden = true)
+    private String jobType;
+    //病人姓名
+    @ApiModelProperty(hidden = true)
+    private String name;
+    //病人住院序号
+    @ApiModelProperty(hidden = true)
+    private String behospitalCode;
+    //主诊断医生
+    @ApiModelProperty(hidden = true)
+    private String doctorName;
+    //科室id集合
+    @ApiModelProperty(hidden = true)
+    private List<String> deptList;
+
+
+
+}

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

@@ -0,0 +1,29 @@
+package com.diagbot.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @description:
+ * @author: zhoutg
+ * @time: 2020/4/13 18:31
+ */
+@Data
+public class CheckUserVO {
+    //任务类型
+    private Integer jobType;
+    //核查用户id集合
+    private List<String> userList;
+    //用户角色集合
+    private List<Long> roleIds;
+    //用户科室集合
+    private List<String> deptIds;
+    //医院
+    private Long hospitalId;
+    //核查状态 0未核查1核查
+    private int status;
+    //科室类型集合
+    private List<String> deptStations;
+
+}

+ 115 - 0
src/main/java/com/diagbot/vo/CheckWorkPageVO.java

@@ -0,0 +1,115 @@
+package com.diagbot.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 核查患者病历信息
+ * </p>
+ *
+ * @author wangsy
+ * @since 2021-05-13
+ */
+@Data
+public class CheckWorkPageVO extends Page implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 出院开始时间
+     */
+    @ApiModelProperty("出院开始时间")
+    private Date startDate;
+
+    /**
+     * 出院结束时间
+     */
+    @ApiModelProperty("出院结束时间")
+    private Date endDate;
+
+    /**
+     * 生成状态[0-未生成 1-已生成(默认未生成)]
+     */
+    @ApiModelProperty("生成状态[0-未生成 1-已生成(默认未生成)]")
+    private String creatStatus="0";
+
+    /**
+     * 核查任务类型(0-科室任务 2-院级 1-质控科)
+     */
+    private String jobType;
+
+    /**
+     * 医院ID
+     */
+
+    @ApiModelProperty(hidden = true)
+    private Long hospitalId;
+
+    /**
+     * 病人住院序号
+     */
+    @ApiModelProperty("病人住院序号")
+    private String behospitalCode;
+
+    /**
+     * 科室编号集合
+     */
+    @ApiModelProperty("科室编号集合")
+    private List<String> department;
+    /**
+     * 病人住院序号集合
+     */
+    @ApiModelProperty(hidden = true)
+    private List<String> behospitalCodes;
+
+    /**
+     * 病历等级
+     */
+    @ApiModelProperty("病历等级")
+    private String level;
+
+    /**
+     * 病人姓名
+     */
+    @ApiModelProperty("病人姓名")
+    private String name;
+
+    /**
+     * 医生姓名
+     */
+    @ApiModelProperty("医生姓名")
+    private String doctorName;
+
+    /**
+     * 主诊断
+     */
+    @ApiModelProperty("主诊断")
+    private String diagnose;
+
+    /**
+     * 最小天数
+     */
+    @ApiModelProperty("最小天数")
+    private Integer smallDay;
+
+    /**
+     * 最大天数
+     */
+    @ApiModelProperty("最大天数")
+    private Integer bigDay;
+
+    /**
+     * 是否归档(0:未归档,1:已归档)
+     */
+    @ApiModelProperty("是否归档(0:未归档,1:已归档)")
+    private String isPlacefile = "1";
+    //筛选分值集合
+    @ApiModelProperty("筛选分值集合")
+    private List<String> values;
+}

+ 104 - 0
src/main/java/com/diagbot/vo/CheckedRecordListVO.java

@@ -0,0 +1,104 @@
+package com.diagbot.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2021/5/17 18:48
+ */
+@Getter
+@Setter
+@ApiModel("核查任务列表-获取核查任务列表-接口入参")
+public class CheckedRecordListVO extends Page implements Serializable {
+
+    /**
+     * 病历核查状态
+     */
+    @ApiModelProperty("病历核查状态,0-未核查,1-已核查")
+    private Integer status;
+
+    /**
+     * 任务类型
+     */
+    @ApiModelProperty("任务类型,0-科室任务 1-院级 2-质控科")
+    private List<String> checkJobTypes;
+
+    /**
+     * 科室
+     */
+    @ApiModelProperty("科室")
+    private String behDeptId;
+
+    /**
+     * 病人姓名
+     */
+    @ApiModelProperty("病人姓名")
+    private String name;
+
+    /**
+     * 病人住院序号
+     */
+    @ApiModelProperty("病人住院序号")
+    private String behospitalCode;
+
+    /**
+     * 医生姓名
+     */
+    @ApiModelProperty("医生姓名")
+    private String doctorName;
+
+    /**
+     * 分配日期起始日期
+     */
+    @ApiModelProperty("分配日期起始日期,格式为:2018-11-28")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private Date jobDistributionTimeStart;
+
+    /**
+     * 分配日期终止日期
+     */
+    @ApiModelProperty("分配日期终止日期,格式为:2018-11-28")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private Date jobDistributionTimeEnd;
+
+    /**
+     * 核查员
+     */
+    @ApiModelProperty("核查员")
+    private String checkName;
+
+    /**
+     * 病历等级
+     */
+    @ApiModelProperty("病历等级")
+    private String level;
+
+    /**
+     * 当前用户归属科室Id集合,多个科室用英文逗号隔开
+     */
+    @ApiModelProperty(hidden = true)
+    private String currentDeptIds;
+
+    /**
+     * 当前用户下级普通质控员Id集合
+     */
+    @ApiModelProperty(hidden = true)
+    private List<Long> currentGeneralUserIds;
+
+    /**
+     * 当前用户归属医院Id
+     */
+    @ApiModelProperty(hidden = true)
+    private long hospitalId;
+
+}

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

@@ -0,0 +1,42 @@
+package com.diagbot.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @description: 分配核查任务入参对象
+ * @author: songxl
+ * @time: 2021/05/17
+ */
+@Data
+public class DistributionJobVO {
+    //病人住院序号集合
+    @ApiModelProperty("病人住院序号集合")
+    private List<String> behospitalCodes;
+    //医院id
+    @ApiModelProperty(hidden = true)
+    private String hospitalId;
+    //分配用户id
+    @ApiModelProperty(hidden = true)
+    private String jobDistributor;
+    //核查用户id
+    @ApiModelProperty("核查用户id")
+    private String checkId;
+    //核查用户姓名
+    @ApiModelProperty("核查用户姓名")
+    private String checkName;
+    @ApiModelProperty("核查用户科室id")
+    private String checkDept;
+    @ApiModelProperty("病人住院科室集合")
+    private List<String> behospitalDepts;
+    @ApiModelProperty("任务类型 0科室、1质控科额、2院级")
+    private String jobType;
+    //操作类型 分配或取消 0-分配,1-取消分配
+    @ApiModelProperty("操作类型 分配或取消 0-分配,1-取消分配")
+    private String distributionType;
+
+
+
+}

+ 34 - 0
src/main/java/com/diagbot/vo/MedCheckWorkAddVO.java

@@ -0,0 +1,34 @@
+package com.diagbot.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author songxl
+ * @Description:核查任务添加对象
+ * @author songxl
+ * @since 2021-05-11
+ */
+@Getter
+@Setter
+public class MedCheckWorkAddVO {
+    @ApiModelProperty(hidden = true)
+    private Long hospitalId;            //医院id
+    @ApiModelProperty("病历id集合")
+    private List<String> behospitalCodeList = new ArrayList<>(); // 病历id
+    @ApiModelProperty(hidden = true)
+    private String jobCreator;         // 创建用户编号
+    @ApiModelProperty("任务类型 0-科室任务 1-院级 1-质控科")
+    private Integer jobType;           // 任务类型 0-科室任务 1-院级 1-质控科
+    @ApiModelProperty("操作类型 0-取消,1-添加")
+    private Integer checkStatus;        // 操作类型 0-取消,1-添加
+    @ApiModelProperty("操作时间")
+    private String createTime;          // 操作时间
+    @ApiModelProperty("核查类型 0病历,1病案首页,2全部 默认")
+    private Integer checkType=2;          // 核查类型 0病历,1病案首页,2全部 默认
+}

+ 4 - 0
src/main/java/com/diagbot/vo/QcResultAlgVO.java

@@ -1,5 +1,6 @@
 package com.diagbot.vo;
 
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -29,6 +30,9 @@ public class QcResultAlgVO {
     private String code;
     //质控返回info
     private String info;
+    //质控条目说明
+    @ApiModelProperty(hidden = true)
+    private String explainInfo;
     //单项否决(1-单项否决 0-非)
     private Integer isReject;
 }

+ 2 - 0
src/main/java/com/diagbot/vo/QcresultVO.java

@@ -20,6 +20,8 @@ public class QcresultVO {
     //操作类型(0:基础评分,1:新增条目评分,2:删除条目,3:修改条目)
     @ApiModelProperty(hidden = true)
     private Integer type;
+    @ApiModelProperty("逻辑删除接口(1-恢复和0-删除)标志")
+    private Integer delStatus;
     //操作条目
     private QcResultAlgVO optResultAlgVO;
 }

+ 24 - 0
src/main/java/com/diagbot/vo/RecordCheckVO.java

@@ -0,0 +1,24 @@
+package com.diagbot.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2021/5/18 20:15
+ */
+@Getter
+@Setter
+@ApiModel("核查任务列表-病历核查-接口入参")
+public class RecordCheckVO {
+
+    /**
+     * 病人住院序号
+     */
+    @ApiModelProperty("病人住院序号")
+    private String behospitalCode;
+
+}

+ 24 - 0
src/main/java/com/diagbot/vo/RecordTypeVO.java

@@ -0,0 +1,24 @@
+package com.diagbot.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @description:
+ * @author: zhoutg
+ * @time: 2020/4/13 18:31
+ */
+@Data
+public class RecordTypeVO {
+
+    private String behospitalCode; // 病历id
+    private Long hospitalId; //医院ID
+    private Long start; //开始
+    private Long end; //结束
+    private List<String> modeList;//所属模块
+    private Long isPlacefile;//是否归档
+    private String startTime;//筛选开始时间
+    private String endTime;//结束时间
+
+}

+ 13 - 0
src/main/java/com/diagbot/web/BehospitalInfoController.java

@@ -86,6 +86,7 @@ public class BehospitalInfoController {
     @Transactional
     public RespDTO<AnalyzeDTO> analyze(@RequestBody AnalyzeVO analyzeVO) {
         analyzeVO.setUseCrfCache(true);
+        analyzeVO.setCheckFlag(true);
         return RespDTO.onSuc(behospitalInfoFacade.analyze(analyzeVO));
     }
 
@@ -148,6 +149,18 @@ public class BehospitalInfoController {
         return RespDTO.onSuc(qcresultInfoFacade.changeQcResult(qcresultVO));
     }
 
+    @ApiOperation(value = "逻辑删除质控条目[by:songxl]",
+            notes = "behospitalCode:病历号,必填<br>" +
+                    "id:明细id,必填<br>" +
+                    "delStatus:逻辑删除接口(1-还原和0-删除)标志 必填<br>")
+    @PostMapping("/logicDelCase")
+    @SysLogger("logicDelCase")
+    @Transactional
+    public RespDTO<AnalyzeDTO> logicDelCase(@RequestBody QcresultVO qcresultVO) {
+        qcresultVO.setType(4);
+        return RespDTO.onSuc(qcresultInfoFacade.changeQcResult(qcresultVO));
+    }
+
     @ApiOperation(value = "修改质控条目[by:zhoutg]",
             notes = "")
     @PostMapping("/updCase")

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

@@ -1,9 +1,16 @@
 package com.diagbot.web;
 
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.CheckDeptDTO;
+import com.diagbot.dto.CheckJobDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.MedCheckInfoFacade;
+import com.diagbot.facade.MedCheckWorkFacade;
+import com.diagbot.vo.CheckJobPageVO;
+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;
@@ -12,6 +19,10 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -29,14 +40,75 @@ public class MedCheckInfoController {
 
     @Autowired
     MedCheckInfoFacade medCheckInfoFacade;
+    @Autowired
+    MedCheckWorkFacade medCheckWorkFacade;
 
     @ApiOperation(value = "核查数据接口[by:wangfeng]",
             notes = "核查数据接口")
     @PostMapping("/addMedCheckInfo")
     @SysLogger("addMedCheckInfo")
+    @ApiIgnore
     public RespDTO<Boolean> addMedCheckInfo(@RequestBody MedCheckInfoAddVO medCheckInfoAddVO) {
         Boolean res = medCheckInfoFacade.addMedCheckInfos(medCheckInfoAddVO);
         return RespDTO.onSuc(res);
     }
 
+
+
+    @ApiOperation(value = "分配核查任务--获取核查人员列表[by:songxl]",
+            notes = "获取核查人员列表")
+    @PostMapping("/getCheckUserMap")
+    @SysLogger("getCheckUserMap")
+    public RespDTO<Map<String, List<CheckDeptDTO>>> getCheckUserMap() {
+        Map<String, List<CheckDeptDTO>> userInfoMap = medCheckInfoFacade.getCheckUserMap();
+        return RespDTO.onSuc(userInfoMap);
+    }
+
+
+    @ApiOperation(value = "分配核查任务--获取待分配核查任务列表[by:songxl]",
+            notes = "startTime:任务生成开始时间 必填<br>" +
+                    "endTime:  任务生成结束时间 必填<br>" +
+                    "或<br>" +
+                    "behosDateStart:  出院开始时间 必填<br>" +
+                    "behosDateEnd:  出院结束时间 必填<br>" +
+                    "jobType:核查任务类型 必填 0-科室任务  1-质控科 2-院级<br>" )
+    @PostMapping("/getCheckList")
+    @SysLogger("getCheckList")
+    public RespDTO<IPage<CheckJobDTO>> getCheckList(@RequestBody CheckJobPageVO checkJobPageVO) {
+        IPage<CheckJobDTO> userInfos = medCheckInfoFacade.getUserCheckList(checkJobPageVO);
+        return RespDTO.onSuc(userInfos);
+    }
+
+    @ApiOperation(value = "分配核查任务--分配/取消核查任务[by:songxl]",
+            notes = "behospitalCodes:病人住院序号集合 必填<br>" +
+                    "checkId:  核查用户id 必填<br>" +
+                    "checkName:  核查用户姓名 必填<br>" +
+                    "checkDept:  核查人科室id 必填<br>" +
+                    "behospitalDepts:  核查任务科室id集合 必填<br>" +
+                    "jobType:  任务类型 0科室、1质控科额、2院级 必填<br>" +
+                    "distributionType:操作类型 必填 分配或取消 0-分配,1-取消分配<br>")
+    @PostMapping("/updateDistributionCheck")
+    @SysLogger("updateDistributionCheck")
+    public RespDTO<Boolean> distributionJobs(@RequestBody DistributionJobVO distributionJobVO) {
+        return RespDTO.onSuc(medCheckInfoFacade.distributionJobs(distributionJobVO));
+    }
+
+
+    @ApiOperation(value = "分配核查任务--获取指定核查人员的核查任务[by:songxl]",
+            notes = "checkId:核查用户id")
+    @PostMapping("/getCheckListByUserId")
+    @SysLogger("getCheckListByUserId")
+    public RespDTO<IPage<CheckJobDTO>> getCheckListByUserId(@RequestBody CheckJobPageVO checkJobVO) {
+        IPage<CheckJobDTO> userInfos = medCheckInfoFacade.getCheckListByUserId(checkJobVO);
+        return RespDTO.onSuc(userInfos);
+    }
+
+    @ApiOperation(value = "质控核查--生成患者病历类型[by:songxl]",
+            notes = "生成患者病历类型 <br>" +
+                    "备注:如果历史患者病历类型已经生成,接口只会筛选当前时间前半个小时入院患者生成类型")
+    @PostMapping("/createMedBeHospitalInfoType")
+    @SysLogger("createMedBeHospitalInfoType")
+    public RespDTO<Boolean> createMedBeHospitalInfoType() {
+        return RespDTO.onSuc(medCheckWorkFacade.createMedBeHospitalInfoType());
+    }
 }

+ 67 - 0
src/main/java/com/diagbot/web/MedCheckWorkController.java

@@ -0,0 +1,67 @@
+package com.diagbot.web;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.CheckWorkDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.MedCheckWorkFacade;
+import com.diagbot.vo.CheckWorkPageVO;
+import com.diagbot.vo.MedCheckWorkAddVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ *
+ * @author songxl
+ * @since 2021-05-11
+ */
+@RestController
+@RequestMapping("/qc/medCheckWork")
+@Api(value = "生成核查任务--相关接口API", tags = { "生成核查任务--相关接口API" })
+public class MedCheckWorkController {
+    @Autowired
+    MedCheckWorkFacade medCheckworkFacade;
+
+    @ApiOperation(value = "生成/取消核查任务[by:wangsy]",
+            notes = "生成/取消核查任务 <br>" +
+            "behospitalCodeList:病历id(List) 【必填】<br>" +
+            "jobType:核查任务类型(0-科室任务 1-院级 1-质控科) 【必填】<br>" +
+            "checkStatus:操作类型(0-取消,1-添加) 【必填】<br>" +
+            "createTime: 操作时间<br>" +
+            "checkType:核查类型(0病历,1病案首页,2全部 默认)<br>")
+    @PostMapping("/addCheckWork")
+    @SysLogger("addCheckWork")
+    public RespDTO<Boolean> addCheckTask(@RequestBody MedCheckWorkAddVO medCheckWorkVO) {
+        Boolean res = medCheckworkFacade.addCheckWork(medCheckWorkVO);
+        return RespDTO.onSuc(res);
+    }
+
+    @ApiOperation(value = "获取患者病历列表[by:wangsy]",
+            notes = "startDate:出院开始时间 【必填】<br>" +
+                    "endDate:出院结束时间 【必填】<br>" +
+                    "creatStatus:生成状态(0-未生成 1-已生成) 【必填】<br>" +
+                    "jobType:核查任务类型(0-科室任务 1-质控科 2-院级) <br>" +
+                    "hospitalId: 医院ID<br>" +
+                    "behospitalCode:病人住院序号<br>" +
+                    "departments:科室<br>" +
+                    "level:病历等级<br>" +
+                    "name:病人姓名<br>" +
+                    "doctorName:医生姓名<br>" +
+                    "diagnose:主诊断<br>" +
+                    "smallDay:最小天数<br>" +
+                    "bigDay:最大天数<br>" +
+                    "isPlacefile:是否归档<br>")
+    @PostMapping("/getUserList")
+    @SysLogger("getUserList")
+    public RespDTO<IPage<CheckWorkDTO>> checkWorkPage(@RequestBody CheckWorkPageVO checkWorkPageVO) {
+        IPage<CheckWorkDTO> data = medCheckworkFacade.pageFac(checkWorkPageVO);
+        return RespDTO.onSuc(data);
+    }
+}

+ 57 - 0
src/main/java/com/diagbot/web/RecordCheckController.java

@@ -0,0 +1,57 @@
+package com.diagbot.web;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.CheckedRecordListDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.RecordCheckFacade;
+import com.diagbot.vo.CheckedRecordListVO;
+import com.diagbot.vo.RecordCheckVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * @author rengb
+ * @since 2021-05-11
+ */
+@RestController
+@RequestMapping("/qc/recCheck")
+@Api(value = "核查任务列表--相关接口API", tags = { "核查任务列表--相关接口API" })
+public class RecordCheckController {
+
+    @Autowired
+    RecordCheckFacade recordCheckFacade;
+
+    @ApiOperation(value = "获取核查任务列表[by:rengb]")
+    @PostMapping("/checkedRecordList")
+    @SysLogger("checkedRecordList")
+    public RespDTO<IPage<CheckedRecordListDTO>> checkedRecordList(@RequestBody CheckedRecordListVO checkedRecordListVO) {
+        IPage<CheckedRecordListDTO> data = recordCheckFacade.checkedRecordList(checkedRecordListVO);
+        return RespDTO.onSuc(data);
+    }
+
+    @ApiOperation(value = "病历核查[by:rengb]")
+    @PostMapping("/recordCheck")
+    @SysLogger("recordCheck")
+    @Transactional
+    public RespDTO<Boolean> recordCheck(@RequestBody RecordCheckVO recordCheckVO) {
+        Boolean res = recordCheckFacade.recordCheck(recordCheckVO);
+        return RespDTO.onSuc(res);
+    }
+
+    @ApiOperation(value = "获取核查任务来源[by:songxl]")
+    @PostMapping("/getCheckType")
+    @SysLogger("getCheckType")
+    public RespDTO<Map<String, Object>> getCheckType() {
+        Map<String, Object> data = recordCheckFacade.getCheckType();
+        return RespDTO.onSuc(data);
+    }
+}

+ 1 - 1
src/main/resources/application-pre.yml

@@ -164,7 +164,7 @@ oath.self.address: http://${myhost}:${server.port}
 
 # 加解密开关
 encrypt:
-  enable: false
+  enable: true
 
 swagger:
   enable: true

+ 6 - 3
src/main/resources/application-test.yml

@@ -109,9 +109,12 @@ spring:
   #redis
   redis:
     database:
-      cache: 8 # cache索引
-      token: 8 # Token索引
-    host: 192.168.2.241  #Redis服务器地址
+#      cache: 8 # cache索引
+#      token: 8 # Token索引
+#    host: 192.168.2.241  #Redis服务器地址
+      cache: 3 # cache索引
+      token: 3 # Token索引
+    host: 192.168.2.236  #Redis服务器地址
     port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
     password: lantone # Redis服务器连接密码(默认为空)
     lettuce:

+ 1 - 1
src/main/resources/bootstrap.yml

@@ -2,7 +2,7 @@ spring:
   application:
     name: mrqc-sys
   profiles:
-    active: local
+    active: test
   main:
     allow-bean-definition-overriding: true
 

+ 2 - 1
src/main/resources/mapper/BasDeptInfoMapper.xml

@@ -27,7 +27,7 @@
             `bas_dept_info` t
         WHERE
             t.is_deleted = 'N'
-        AND t.station = '住院'
+        AND (t.station = '住院' or t.station = '质管')
         AND t.hospital_id = #{hospitalId}
         <if test="inputStr !=null and inputStr != ''">
             AND (UPPER(t.spell) LIKE CONCAT('%', UPPER(TRIM(#{inputStr})),'%') OR UPPER(t.dept_name) LIKE CONCAT('%', UPPER(TRIM(#{inputStr})),'%'))
@@ -69,6 +69,7 @@
         AND b.is_deleted = 'N'
         AND a.hospital_id = b.hospital_id
         AND a.dept_id = b.dept_id
+        AND b.station = '住院'
         <if test="userId!=null">
             AND a.user_id = #{userId}
         </if>

+ 45 - 19
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -37,6 +37,7 @@
         <result column="gmt_modified" property="gmtModified"/>
         <result column="creator" property="creator"/>
         <result column="modifier" property="modifier"/>
+        <result column="linkman" property="linkman"/>
     </resultMap>
 
     <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
@@ -62,7 +63,7 @@
         AND e.is_deleted = 'N'
         and e.cases_id = 243
         ) t
-        LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
+        LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
         ON t.behospital_code = g.behospital_code
         AND t.hospital_id = g.hospital_id
         LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
@@ -679,21 +680,27 @@
     </select>-->
 
     <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
-        SELECT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info,
-        a.cases_id cases_id, d.score cases_score,b.id model_id, a.name standard_msg,
-        c.opt_type, c.grade_type, c.gmt_create, c.gmt_modified,
+        SELECT a.*, u.linkman
+        FROM
+        (
+        SELECT DISTINCT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info, a.cases_id cases_id, d.score cases_score,
+        b.id model_id, a.name standard_msg, c.opt_type, c.grade_type,
+         c.gmt_create, c.gmt_modified, c.modifier,c.is_deleted,c.explain_info as explainInfo,
         a.type, a.drgs
-        FROM `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
-        where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N' and d.is_deleted = 'N'
-        and a.id = c.cases_entry_id
-        and a.mode_id = b.id
-        AND c.cases_id = d.cases_id
-        and c.hospital_id = d.hospital_id
+        FROM
+        `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
+        where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
+        and a.id = c.cases_entry_id and a.mode_id = b.id
+        AND c.cases_id = d.cases_id and c.hospital_id = d.hospital_id
         and c.hospital_id = #{hospitalId}
         and c.behospital_code = #{behospitalCode}
-        order by b.order_no, c.grade_type desc, a.order_no
+        order by b.order_no, c.grade_type desc, a.order_no) a
+        LEFT JOIN sys_user u  on u.id = a.modifier  and u.is_deleted = 'N'
     </select>
 
+
+
+
     <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
         SELECT b.id model_id,b.`name` model_name,
         d.score,d.msg,d.cases_entry_id,d.is_reject,
@@ -1035,7 +1042,7 @@
         WHERE d.is_deleted = 'N'
         AND d.user_id = #{userId}
         ) t
-        LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
+        LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
         ON t.behospital_code = g.behospital_code
         AND t.hospital_id = g.hospital_id
         LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
@@ -1167,7 +1174,7 @@
         or   a.beh_doctor_name = u1.linkman
         or   a.director_doctor_name =  u1.linkman
         ) t
-        LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
+        LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
         ON t.behospital_code = g.behospital_code
         AND t.hospital_id = g.hospital_id
         LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
@@ -1259,7 +1266,7 @@
         left join med_home_page c
         on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
         ) t
-        LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
+        LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
         ON t.behospital_code = g.behospital_code
         AND t.hospital_id = g.hospital_id
         LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
@@ -4218,10 +4225,7 @@
         FROM
         (
         SELECT
-        CONCAT(
-        ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
-        a.doctor_name
-        ) AS doctorName,
+        a.doctor_name AS doctorName,
         a.`name` AS patName,
         a.behospital_code AS behospitalCode,
         a.behospital_date AS behospitalDate,
@@ -7775,7 +7779,7 @@
         AND a.behospital_code = c.behospital_code
         AND a.qc_type_id != 0
         AND ifnull(c.`status`,0) = 1
-        AND c.check_type = 0
+        AND c.check_type in (0,2)
         <if test="isPlacefile != null and isPlacefile != ''">
             and a.is_placefile = #{isPlacefile}
         </if>
@@ -17878,4 +17882,26 @@
         )
         )
     </select>
+
+    <!-- 获取患者年龄信息(通过出生日期和入院日期重新计算) -->
+    <select id="getBehospitalInfoAge" resultType="com.diagbot.dto.BehospitalInfoAgeDTO">
+        SELECT
+        mbi.behospital_code behospitalCode,
+        mhp.age,
+        TIMESTAMPDIFF(year,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) as ageYear,
+        TIMESTAMPDIFF(month,DATE_ADD(ifnull(mhp.birthday,mbi.birthday),INTERVAL TIMESTAMPDIFF(year,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) year),mbi.behospital_date) as ageMon,
+        TIMESTAMPDIFF(day,DATE_ADD(ifnull(mhp.birthday,mbi.birthday),INTERVAL TIMESTAMPDIFF(month,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) month),mbi.behospital_date) as ageDay
+        FROM
+        med_behospital_info mbi
+        LEFT JOIN med_home_page mhp
+        ON mbi.behospital_code=mhp.behospital_code
+        AND mbi.hospital_id = mhp.hospital_id AND mhp.is_deleted = 'N'
+        WHERE mbi.hospital_id=#{hospitalId} AND mbi.is_deleted = 'N'
+        <if test="behospitalCodes !=null and behospitalCodes.size > 0">
+            and mbi.behospital_code in
+            <foreach collection="behospitalCodes" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+    </select>
 </mapper>

+ 16 - 0
src/main/resources/mapper/MedBehospitalTypeMapper.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.MedBehospitalTypeMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.MedBehospitalType">
+        <id column="id" property="id" />
+        <result column="hospital_id" property="hospitalId" />
+        <result column="behospital_code" property="behospitalCode" />
+        <result column="behospital_type" property="behospitalType" />
+        <result column="value" property="value" />
+        <result column="create_time" property="createTime" />
+        <result column="is_deleted" property="isDeleted" />
+    </resultMap>
+
+</mapper>

+ 388 - 0
src/main/resources/mapper/MedCheckInfoMapper.xml

@@ -17,6 +17,394 @@
         <result column="check_time" property="checkTime" />
         <result column="status" property="status" />
         <result column="check_type" property="checkType" />
+        <result column="job_creator" property="jobCreator" />
+        <result column="job_creator_name" property="jobCreatorName" />
+        <result column="job_create_time" property="jobCreateTime" />
+        <result column="job_type" property="jobType" />
+        <result column="job_distributor" property="jobDistributor" />
+        <result column="job_distribution_name" property="jobDistributionName" />
+        <result column="job_distribution_time" property="jobDistributionTime" />
     </resultMap>
+    <!--获取核查人员用户科室、姓名、角色-->
+    <select id="getCheckUser" resultType="com.diagbot.dto.CheckUserDTO">
+        SELECT DISTINCT
+        a.id doctorId,
+        a.linkman doctorName,
+        c.dept_id deptId,
+        d.dept_name deptName
+        from
+        sys_user a,sys_user_role b,sys_user_dept c ,bas_dept_info d
+        where a.id = b.user_id and a.is_deleted = "N" and b.is_deleted = "N" and c.is_deleted = "N" and a.id = c.user_id
+        and d.dept_id = c.dept_id and c.hospital_id = d.hospital_id
+        and c.hospital_id = #{hospitalId}
+        <if test="roleIds !=null and roleIds.size()!=0 ">
+            and b.role_id in
+            <foreach collection="roleIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+
+        <if test="deptIds !=null and deptIds.size()!=0">
+            and c.dept_id in
+            <foreach collection="deptIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="deptStations !=null and deptStations.size()!=0">
+            and d.station in
+            <foreach collection="deptStations" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        order by c.dept_id
+    </select>
+    <!--核查人员通过id获取核查人员的核查任务数-->
+    <select id="getDeptJobNumByUserId" resultType="com.diagbot.dto.DeptCheckUserDTO">
+        SELECT
+        a.beh_dept_id deptId ,
+        b.check_id doctorId,
+        count(*) as jobNum,
+        b.`status`
+        from
+        med_behospital_info a LEFT JOIN med_check_info b on a.behospital_code = b.behospital_code and a.hospital_id = b.hospital_id
+        where b.is_deleted = 'N' and a.is_deleted = 'N' and b.job_distribution_name is not null  and b.`status` is not null
+        <if test="jobType != null ">
+            and b.job_type = #{jobType}
+        </if>
+
+        <if test="userList !=null and userList.size!=0">
+            and b.check_id in
+            <foreach collection="userList" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="deptIds !=null and deptIds.size()!=0 and jobType ==0">
+            and a.beh_dept_id in
+            <foreach collection="deptIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="deptIds !=null and deptIds.size()!=0 and jobType ==2">
+            and a.beh_dept_id not in
+            <foreach collection="deptIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="jobType ==0">
+            GROUP BY a.beh_dept_id,b.check_id,b.`status`
+        </if>
+        <if test="jobType ==1 or jobType ==2">
+            GROUP BY b.check_id,b.`status`
+        </if>
+    </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`,
+        a.id,
+        a.beh_dept_id behospitalDeptId,
+        a.job_create_time jobCreateTime
+        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.job_create_time,
+            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_distribution_name is NULL  and b.`status` = 0
+                <if test="jobType !=null and jobType != ''">
+                    and b.job_type = #{jobType}
+                </if>
+                <if test="startTime != null and startTime != ''">
+                    <![CDATA[ AND b.job_create_time >= #{startTime}]]>
+                </if>
+                <if test="endTime != null and endTime != ''">
+                    <![CDATA[ AND b.job_create_time <= #{endTime}]]>
+                </if>
+
+                <if test="behosDateStart != null and behosDateStart != ''">
+                    <![CDATA[ AND a.leave_hospital_date >= #{behosDateStart}]]>
+                </if>
+                <if test="behosDateEnd != null and behosDateEnd != ''">
+                    <![CDATA[ AND a.leave_hospital_date <= #{behosDateEnd}]]>
+                 </if>
+                <if test="doctorName !=null and doctorName != ''">
+                    and a.doctor_name LIKE CONCAT('%',#{doctorName},'%')
+                </if>
+                <if test="behospitalCode !=null and behospitalCode != ''">
+                    and a.behospital_code LIKE CONCAT('%',#{behospitalCode},'%')
+                </if>
+                <if test="name !=null and name != ''">
+                    and a.`name` LIKE CONCAT('%',#{name},'%')
+                </if>
+                <if test="deptList !=null and deptList.size()!=0 ">
+                    and a.beh_dept_id in
+                    <foreach collection="deptList" item="item" open="(" close=")" separator=",">
+                        #{item}
+                    </foreach>
+                </if>
+        ) a  JOIN med_behospital_type b on a.behospital_code = b.behospital_code
+        and a.hospital_id = b.hospital_id and b.is_deleted = 'N' and  b.`value` is not null
+        <if test="values !=null and values.size()!=0 ">
+            and b.`value` in
+            <foreach collection="values" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+    </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,
+        a.job_distributor jobDistributor,
+        a.job_distribution_name jobDistributorName
+        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,
+            b.job_distributor,
+            b.job_distribution_name
+            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.`status` = 0
+            <if test="jobType !=null and jobType != ''">
+                and b.job_type = #{jobType}
+            </if>
+            <if test="startTime != null and startTime != ''">
+                <![CDATA[ AND b.job_create_time >= #{startTime}]]>
+            </if>
+            <if test="endTime != null and endTime != ''">
+                <![CDATA[ AND b.job_create_time <= #{endTime}]]>
+            </if>
+
+            <if test="behosDateStart != null and behosDateStart != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{behosDateStart}]]>
+            </if>
+            <if test="behosDateEnd != null and behosDateEnd != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{behosDateEnd}]]>
+            </if>
+            <if test="checkId !=null and checkId != ''">
+                and b.check_id = #{checkId}
+            </if>
+            <if test="deptList !=null and deptList.size()!=0 and jobType==0">
+                and a.beh_dept_id in
+                <foreach collection="deptList" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="deptList !=null and deptList.size()!=0 and jobType==2">
+                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'
+    </select>
+    <select id="getCheckWorkPage" resultType="com.diagbot.dto.CheckWorkDTO">
+        SELECT
+        mbi.behospital_code behospitalCode,
+        mbi.`name`,
+        mbi.file_code fileCode,
+        mbi.sex,
+        mhp.age,
+        mbi.beh_dept_name behDeptName,
+        mbi.leave_hospital_date leaveHospitalDate,
+        mhp.behospital_day_num behospitalDayNum,
+        mbi.doctor_name doctorName,
+        mqi.score_res scoreRes,
+        mqi.`level`,
+        mbi.diagnose,
+        CASE WHEN mbt.behospital_type='出院病人' THEN '6'
+        WHEN mbt.behospital_type='死亡病人' THEN '6'
+        WHEN mbt.behospital_type='危重病人' THEN '4'
+        WHEN mbt.behospital_type='抢救病人' THEN '5'
+        WHEN mbt.behospital_type='手术病人' THEN '2'
+        WHEN mbt.behospital_type='疑难病人' THEN '3'
+        WHEN mbt.behospital_type='输血病人' THEN '4' ELSE '0' END AS score,
+        CASE WHEN ISNULL(mci.job_create_time) THEN '未生成' ELSE '已生成' END AS creatStatus,
+        mci.job_create_time jobCreateTime,
+        mci.job_creator jobCreator,
+        mci.job_creator_name jobCreatorName,
+        mci.check_time checkTime,
+        mci.job_distribution_time jobDistributionTime
+        FROM
+        med_behospital_info mbi
+        LEFT JOIN med_home_page mhp
+        ON mbi.behospital_code=mhp.behospital_code
+        AND mbi.hospital_id = mhp.hospital_id AND mhp.is_deleted = 'N'
+        LEFT JOIN med_check_info mci
+        ON mbi.behospital_code = mci.behospital_code
+        AND mbi.hospital_id = mci.hospital_id AND mci.is_deleted = 'N'
+        LEFT JOIN med_qcresult_info mqi
+        ON mbi.behospital_code = mqi.behospital_code
+        AND mbi.hospital_id = mqi.hospital_id AND mqi.is_deleted = 'N'
+        JOIN med_behospital_type mbt ON mbi.behospital_code = mbt.behospital_code
+        AND mbi.hospital_id = mbt.hospital_id AND mbt.is_deleted = 'N'
+        WHERE mbi.hospital_id=#{hospitalId} AND mbi.is_deleted = 'N' and mqi.score_res is not null
+        AND mci.check_id is null
+        <if test="startDate != null">
+            <![CDATA[ AND mbi.leave_hospital_date >= #{startDate}]]>
+        </if>
+        <if test="endDate != null">
+            <![CDATA[ AND mbi.leave_hospital_date < #{endDate}]]>
+        </if>
+        <if test="creatStatus != null and creatStatus == '1'.toString()">
+            AND mci.job_create_time is not null
+            <if test="jobType != null and jobType != ''">
+                AND mci.job_type=#{jobType}
+            </if>
+        </if>
+        <if test="creatStatus != null and creatStatus == '0'.toString()">
+            AND mci.job_create_time is null
+        </if>
+        <if test="name != null and name != ''">
+            AND mbi.`name` like CONCAT('%',#{name},'%')
+        </if>
+        <if test="behospitalCode != null and behospitalCode != ''">
+            AND mbi.behospital_code like CONCAT('%',#{behospitalCode},'%')
+        </if>
+        <if test="department !=null and department.size > 0">
+            and mbi.beh_dept_id in
+            <foreach collection="department" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="smallDay != null">
+            <![CDATA[ AND mhp.behospital_day_num >= #{smallDay}]]>
+        </if>
+        <if test="bigDay != null">
+            <![CDATA[ AND mhp.behospital_day_num <= #{bigDay}]]>
+        </if>
+        <if test="doctorName != null and doctorName != ''">
+            AND mbi.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
+        </if>
+        <if test="diagnose != null and diagnose != ''">
+            AND mbi.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
+        </if>
+        <if test="level != null and level != ''">
+            AND mqi.`level`= #{level}
+        </if>
+        <if test="isPlacefile != null and isPlacefile != ''">
+            AND mbi.is_placefile = #{isPlacefile}
+        </if>
+        <if test="values !=null and values.size > 0">
+            and mbt.`value` in
+            <foreach collection="values" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+    <!--通过住院号,取消核查任务-->
+    <update id="deleteBatchCodes">
+        <foreach collection="list" item="item"  separator=";">
+            delete from
+            med_check_info
+            where behospital_code = #{item} and is_deleted = 'N'
+        </foreach>
+    </update>
+
+    <select id="checkedRecordList" resultType="com.diagbot.dto.CheckedRecordListDTO">
+        SELECT t1.*,SUM(if(t2.behospital_code is null,0,1)) as casesEntryNum
+        from
+        (select
+        b.behospital_code as behospitalCode,
+        a.`status` as status,
+        b.beh_dept_id as behDeptId,
+        b.beh_dept_name as behDeptName,
+        b.`name` as name,
+        b.file_code as fileCode,
+        b.doctor_name as doctorName,
+        b.leave_hospital_date as leaveHospitalDate,
+        a.job_create_time as jobCreateTime,
+        a.job_distribution_time as jobDistributionTime,
+        a.check_id as checkId,
+        a.check_name as checkName,
+        a.check_time as checkTime,
+        c.`level` as level,
+        c.score_res as scoreRes,
+        CASE WHEN a.job_type='0' THEN '科室任务'
+        WHEN a.job_type='1' THEN '质控科任务'
+        WHEN a.job_type='2' THEN '院级任务' END AS jobTypeName,
+        <!-- 张三是A科室的监管员,李四是A科室和B科室的普通质控员,那么张三在核查任务列表中不能看到李四B科室的数据  -->
+        case when a.job_type='0' and FIND_IN_SET(b.beh_dept_id,#{currentDeptIds})=0 then 0 else 1 end as isDel
+        from med_check_info a join med_behospital_info b on a.hospital_id=b.hospital_id and
+        a.behospital_code=b.behospital_code
+        join med_qcresult_info c on b.hospital_id=c.hospital_id and b.behospital_code=c.behospital_code and
+        b.is_deleted='N' and c.is_deleted = 'N'
+        where a.hospital_id=#{hospitalId} and a.is_deleted='N'
+        and b.hospital_id=#{hospitalId} and b.is_deleted='N'
+        and c.hospital_id=#{hospitalId}
+        and a.check_id in
+        <foreach collection="currentGeneralUserIds" item="currentGeneralUserId" separator="," close=")" open="(">
+            #{currentGeneralUserId}
+        </foreach>
+        <if test="status!=null">
+            and a.`status`=#{status}
+        </if>
+        <if test="behDeptId!=null and behDeptId!=''">
+            and b.beh_dept_id=#{behDeptId}
+        </if>
+        <if test="name!=null and name!=''">
+            and b.`name` like concat('%',#{name},'%')
+        </if>
+        <if test="behospitalCode!=null and behospitalCode!=''">
+            and b.behospital_code like concat('%',#{behospitalCode},'%')
+        </if>
+        <if test="doctorName!=null and doctorName!=''">
+            and b.doctor_name like concat('%',#{doctorName},'%')
+        </if>
+        <if test="jobDistributionTimeStart!=null">
+            and a.job_distribution_time >= #{jobDistributionTimeStart}
+        </if>
+        <if test="jobDistributionTimeEnd!=null">
+            and #{jobDistributionTimeEnd} >= a.job_distribution_time
+        </if>
+        <if test="checkName!=null and checkName!=''">
+            and a.check_name like concat('%',#{checkName},'%')
+        </if>
+        <if test="level!=null and level!=''">
+            and c.`level`=#{level}
+        </if>
+        <if test="checkJobTypes!=null and checkJobTypes.size>0">
+            and a.job_type in
+            <foreach collection="checkJobTypes" item="checkJobType" separator="," close=")" open="(">
+                #{checkJobType}
+            </foreach>
+        </if>
+        ) t1 left join med_qcresult_detail t2 on t1.behospitalCode=t2.behospital_code and t2.hospital_id=#{hospitalId} and t2.is_deleted='N'
+        where isDel>0
+        group by t1.behospitalCode
+    </select>
 
 </mapper>

+ 41 - 0
src/main/resources/mapper/MedicalRecordMapper.xml

@@ -49,6 +49,47 @@
         and t3.xml_text != ''
     </select>
 
+    <select id="getRecordCount"  resultType="java.lang.Integer">
+        select count(*) as num from
+          (select  DISTINCT behospital_code,mode_id  from med_medical_record where behospital_code in
+                (select  behospital_code from med_behospital_info   where hospital_id = #{hospitalId}
+                <if test="isPlacefile !=null and isPlacefile !=''">
+                    and is_placefile  =#{isPlacefile}
+                </if>
+                <if test="startTime !=null and endTime !=null">
+                    and placefile_date BETWEEN #{startTime} AND #{endTime}
+                </if>
+                )
+                <if test="modeList != null and modeList.size() > 0">
+                    and mode_id in
+                    <foreach collection="modeList" open="(" separator="," close=")" item="item">
+                        '${item}'
+                    </foreach>
+                </if>
+                <if test="start != null and end !=null">
+                    limit #{start},#{end}
+                </if>
+        ) a
+    </select>
+
+    <select id="getMedicalRecord"  resultType="com.diagbot.dto.MedicalRecordDTO">
+        SELECT DISTINCT
+        a.behospital_code,
+        c.mode_id
+        from
+        med_behospital_info a LEFT JOIN med_behospital_type b
+        on a.behospital_code = b.behospital_code and a.hospital_id = b.hospital_id and a.is_deleted = 'N' and b.is_deleted = 'N'
+        LEFT JOIN med_medical_record c
+        on a.behospital_code = c.behospital_code and a.hospital_id = c.hospital_id and a.is_deleted = 'N' and c.is_deleted = 'N'
+        where  b.`value` is null
+        <if test="modeList != null and modeList.size() > 0">
+            and c.mode_id in
+            <foreach collection="modeList" open="(" separator="," close=")" item="item">
+                '${item}'
+            </foreach>
+        </if>
+    </select>
+
     <update id="updateBatchByKey">
         <foreach collection="list" item="item"  separator=";">
             update med_medical_record

+ 1 - 1
src/main/resources/mapper/QcCasesEntryHospitalMapper.xml

@@ -128,7 +128,7 @@
         cases_entry_id
         FROM
         med_qcresult_detail
-        WHERE is_deleted = "N"
+        WHERE 1=1
         <if test="behospitalCode != null and behospitalCode != ''">
             AND behospital_code = #{behospitalCode}
         </if>

+ 1 - 0
src/main/resources/mapper/QcresultDetailMapper.xml

@@ -22,6 +22,7 @@
         <result column="creator" property="creator" />
         <result column="modifier" property="modifier" />
         <result column="remark" property="remark" />
+        <result column="explain_info" property="explainInfo" />
     </resultMap>
 
 </mapper>

+ 2 - 2
src/test/java/com/diagbot/CodeGeneration.java

@@ -27,7 +27,7 @@ public class CodeGeneration {
 
         // 全局配置
         GlobalConfig gc = new GlobalConfig();
-        gc.setOutputDir("E://code//mrqcsys");
+        gc.setOutputDir("D://code");
         gc.setFileOverride(true);
         gc.setActiveRecord(false);// 不需要ActiveRecord特性的请改为false
         gc.setEnableCache(false);// XML 二级缓存
@@ -56,7 +56,7 @@ public class CodeGeneration {
         StrategyConfig strategy = new StrategyConfig();
 //        strategy.setTablePrefix(new String[] { "med_" });// 此处可以修改为您的表前缀
         strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
-        strategy.setInclude(new String[] { "med_qcresult_info"}); // 需要生成的表
+        strategy.setInclude(new String[] { "med_check_info"}); // 需要生成的表
 
         strategy.setSuperServiceClass(null);
         strategy.setSuperServiceImplClass(null);