Przeglądaj źródła

条目缺陷改善统计增加科室接口

chengyao 3 lat temu
rodzic
commit
b52f3946ff

+ 23 - 0
doc/037.20211117_2.1.3/qc_initv2.1.3.sql

@@ -1,6 +1,29 @@
 
 use `qc`;
 -- 执行前请看注意事项!
+CREATE TABLE `med_click_info` (
+  `id` int(20) NOT NULL AUTO_INCREMENT,
+  `hospital_id` tinyint(5) DEFAULT '0' COMMENT '医院ID',
+  `dept_id` varchar(16) DEFAULT NULL COMMENT '科室ID',
+  `dept_name` varchar(64) DEFAULT NULL COMMENT '科室名称',
+  `doctor_id` varchar(16) DEFAULT NULL COMMENT '医生ID',
+  `doctor_name` varchar(64) DEFAULT NULL COMMENT '医生姓名',
+  `qcresult_info_id` int(16) DEFAULT NULL COMMENT '质控结果基本信息ID',
+  `behospital_code` varchar(16) DEFAULT NULL COMMENT '病人住院ID',
+  `is_deleted` char(3) DEFAULT 'N' COMMENT '是否删除,N:未删除,Y:删除',
+  `gmt_create` datetime DEFAULT '1970-01-01 12:00:00' COMMENT ' 记录创建时间',
+  `gmt_modified` datetime DEFAULT '1970-01-01 12:00:00' COMMENT ' 记录修改时间,如果时间是1970年则表示纪录未修改',
+  `creator` varchar(20) DEFAULT '0' COMMENT '创建人,0表示无创建人值',
+  `modifier` varchar(20) DEFAULT '0' COMMENT '修改人,如果为0则表示纪录未修改',
+  PRIMARY KEY (`id`),
+  KEY `idx_all` (`hospital_id`,`behospital_code`) USING BTREE,
+  KEY `qcresult_info_id` (`qcresult_info_id`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=37918 DEFAULT CHARSET=utf8 COMMENT='临床医生点击质控病历次数基本表';
+
+
+ALTER TABLE `med_qcresult_cases` ADD   `qcresult_info_id`  bigint(20) DEFAULT NULL COMMENT '评分结果id' AFTER `hospital_id`;
+ALTER TABLE `med_qcresult_detail` ADD   `qcresult_info_id`  bigint(20) DEFAULT NULL COMMENT '评分结果id' AFTER `hospital_id`;
+
 --全院
 INSERT INTO `sys_menu` ( `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `parent_id`, `code`, `show_status`, `maintain_status`, `order_no`, `remark`) VALUES ( 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '数据分析', '-1', 'YH-SJFX', '1', '1', '12', '用户-数据分析');
 SET @id =@@identity;

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

@@ -271,8 +271,13 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/qc/analysis/getEntryDefectImprove").permitAll()
                 .antMatchers("/qc/analysis/getEntryDefectImproveByExport").permitAll()
                 .antMatchers("/qc/analysis/getEntryDefectImproveInner").permitAll()
+                .antMatchers("/qc/analysis/getDefectImproveInnerByExport").permitAll()
                 .antMatchers("/qc/analysisDept/getQcClickDept").permitAll()
                 .antMatchers("/qc/analysisDept/getQcClickByDeptExport").permitAll()
+                .antMatchers("/qc/analysisDept/getEntryDefectImproveDept").permitAll()
+                .antMatchers("/qc/analysisDept/getEntryDefectImproveByDeptExport").permitAll()
+                .antMatchers("/qc/analysisDept/getEntryDefectImproveInnerDept").permitAll()
+                .antMatchers("/qc/analysisDept/getDefectImproveInnerByDeptExport").permitAll()
                 .antMatchers("/**").authenticated();
         //                .antMatchers("/**").permitAll();
     }

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

@@ -315,8 +315,13 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/qc/analysis/getEntryDefectImprove", request)
                 || matchers("/qc/analysis/getEntryDefectImproveByExport", request)
                 || matchers("/qc/analysis/getEntryDefectImproveInner", request)
+                || matchers("/qc/analysis/getDefectImproveInnerByExport", request)
                 || matchers("/qc/analysisDept/getQcClickDept", request)
                 || matchers("/qc/analysisDept/getQcClickByDeptExport", request)
+                || matchers("/qc/analysisDept/getEntryDefectImproveDept", request)
+                || matchers("/qc/analysisDept/getEntryDefectImproveByDeptExport", request)
+                || matchers("/qc/analysisDept/getEntryDefectImproveInnerDept", request)
+                || matchers("/qc/analysisDept/getDefectImproveInnerByDeptExport", request)
                 || matchers("/", request)) {
             return true;
         }

+ 85 - 0
src/main/java/com/diagbot/dto/GetEntryDefectImproveDeptDTO.java

@@ -0,0 +1,85 @@
+package com.diagbot.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+/**
+ * @Description:
+ * @author: cy
+ * @time: 2020/9/4 14:59
+ */
+@Data
+public class GetEntryDefectImproveDeptDTO {
+    /**
+     * 科室id
+     */
+    private String deptId;
+
+
+    /**
+     * 科室名称
+     */
+    @Excel(name = "科室", width = 25d, orderNum = "1")
+    private String deptName;
+
+    /**
+     * 模块id
+     */
+    private String casesId;
+
+    /**
+     * 模块名称
+     */
+    @Excel(name = "模块名称", width = 15d, orderNum = "2")
+    private String casesName;
+
+    /**
+     * 缺陷id
+     */
+    private String entryId;
+
+    /**
+     * 缺陷名称
+     */
+    @Excel(name = "缺陷名称", width = 30d, orderNum = "3")
+    private String entryName;
+
+    /**
+     * 主管医生
+     */
+    @Excel(name = "主管医生", width = 10d, orderNum = "4")
+    private String doctorName;
+
+    /**
+     * 医师工号
+     */
+    @Excel(name = "医师工号", width = 10d, orderNum = "5")
+    private String doctorId;
+
+
+
+    /**
+     * 缺陷总数
+     */
+    @Excel(name = "总数量", width = 10d, orderNum = "6")
+    private Integer totalNum;
+
+    /**
+     * 已改善数
+     */
+    @Excel(name = "已改善数量", width = 13d, orderNum = "7")
+    private Integer handleNum;
+
+    /**
+     * 待改善数
+     */
+    @Excel(name = "待改善数量", width = 13d, orderNum = "8")
+    private Integer improveleNum;
+
+    /**
+     * 改善率
+     */
+    @Excel(name = "改善率", width = 10d, orderNum = "9")
+    private String handleStr;
+
+}

+ 66 - 0
src/main/java/com/diagbot/facade/DataAnalysisDeptFacade.java

@@ -0,0 +1,66 @@
+package com.diagbot.facade;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.GetEntryDefectImproveDeptDTO;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.impl.MedClickInfoServiceImpl;
+import com.diagbot.util.BeanUtil;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.ExcelUtils;
+import com.diagbot.util.SysUserUtils;
+import com.diagbot.vo.GetEntryDefectImproveDeptVO;
+import com.diagbot.vo.GetEntryDefectImproveVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+import javax.servlet.http.HttpServletResponse;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+
+/**
+ * @Description:数据分析
+ * @Author: cy
+ * @time: 2021/11/16 18:28
+ */
+@Component
+public class DataAnalysisDeptFacade {
+    @Autowired
+    @Qualifier("medClickInfoServiceImpl")
+    private MedClickInfoServiceImpl medClickInfoService;
+
+    public IPage<GetEntryDefectImproveDeptDTO> getEntryDefectImproveDept(GetEntryDefectImproveDeptVO getEntryDefectImproveDeptVO) {
+        GetEntryDefectImproveVO getEntryDefectImproveVO = new GetEntryDefectImproveVO();
+        BeanUtil.copyProperties(getEntryDefectImproveDeptVO,getEntryDefectImproveVO);
+        entryDefectSet(getEntryDefectImproveVO);
+        IPage<GetEntryDefectImproveDeptDTO> records = medClickInfoService.getBaseMapper().getEntryDefectImproveDept(getEntryDefectImproveDeptVO);
+        return records;
+    }
+
+    public void getEntryDefectImproveByDeptExport(HttpServletResponse response,GetEntryDefectImproveDeptVO getEntryDefectImproveDeptVO) {
+        getEntryDefectImproveDeptVO.setCurrent(1L);
+        getEntryDefectImproveDeptVO.setSize(Long.MAX_VALUE);
+        getEntryDefectImproveDeptVO.setSearchCount(false);
+        IPage<GetEntryDefectImproveDeptDTO> page = getEntryDefectImproveDept(getEntryDefectImproveDeptVO);
+        String fileName = "条目缺陷改善统计(科室).xls";
+        ExcelUtils.exportExcel(page.getRecords(), null, "sheet1", GetEntryDefectImproveDeptDTO.class, fileName, response, 12.8f);
+    }
+
+    private void entryDefectSet(GetEntryDefectImproveVO getEntryDefectImproveVO) {
+        //入参验证
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+        Date startDate = null;
+        Date endDate = null;
+        try {
+            startDate = simpleDateFormat.parse(getEntryDefectImproveVO.getStartDate());
+            endDate = simpleDateFormat.parse(getEntryDefectImproveVO.getEndDate());
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        if (DateUtil.after(startDate,endDate)){
+            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
+        }
+        getEntryDefectImproveVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
+    }
+}

+ 18 - 0
src/main/java/com/diagbot/facade/DataAnalysisFacade.java

@@ -2,6 +2,8 @@ package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.BehospitalInfoDTO;
+import com.diagbot.dto.ExportExcelBehospitalDTO;
+import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.GetEntryDefectImproveDTO;
 import com.diagbot.dto.GetQcClickDTO;
 import com.diagbot.dto.GetQcClickInnerPageDTO;
@@ -32,6 +34,7 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 
 /**
@@ -130,6 +133,21 @@ public class DataAnalysisFacade {
         return records;
     }
 
+    public void getDefectImproveInnerByExport(HttpServletResponse response,GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO) {
+        entryDefectInnerSet(getEntryDefectImproveInnerVO);
+        getEntryDefectImproveInnerVO.setCurrent(1L);
+        getEntryDefectImproveInnerVO.setSize(Long.MAX_VALUE);
+        getEntryDefectImproveInnerVO.setSearchCount(false);
+        String fileName = "条目缺陷改善统计病历列表.xls";
+        List<ExportExcelDTO> record = medClickInfoService.getBaseMapper().getDefectImproveInnerByExport(getEntryDefectImproveInnerVO);
+        record.stream().forEach(kfc->{
+            List<ExportExcelBehospitalDTO> excelBehospitalDTOS = kfc.getExcelBehospitalDTOS();
+            Double avgScore = excelBehospitalDTOS.stream().parallel().collect(Collectors.averagingDouble(ExportExcelBehospitalDTO::getScore));
+            kfc.setAvgScore(avgScore);
+        });
+        ExcelUtils.exportExcelUser(record, null, "sheet1", ExportExcelDTO.class, fileName, response);
+    }
+
     /**
      * 增加全院记录
      *

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

@@ -2,11 +2,14 @@ package com.diagbot.mapper;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.BehospitalInfoDTO;
+import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.GetEntryDefectImproveDTO;
+import com.diagbot.dto.GetEntryDefectImproveDeptDTO;
 import com.diagbot.dto.GetQcClickDTO;
 import com.diagbot.dto.GetQcClickInnerPageDTO;
 import com.diagbot.entity.MedClickInfo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.vo.GetEntryDefectImproveDeptVO;
 import com.diagbot.vo.GetEntryDefectImproveInnerVO;
 import com.diagbot.vo.GetEntryDefectImproveVO;
 import com.diagbot.vo.GetQcClickInnerPageVO;
@@ -26,5 +29,7 @@ public interface MedClickInfoMapper extends BaseMapper<MedClickInfo> {
     public List<GetQcClickDTO> getQcClick(GetQcClickVO getQcClickVO);
     public IPage<GetQcClickInnerPageDTO> getQcClickInnerPage(GetQcClickInnerPageVO getQcClickInnerPageVO);
     public IPage<GetEntryDefectImproveDTO> getEntryDefectImprove(GetEntryDefectImproveVO getEntryDefectImproveVO);
+    public IPage<GetEntryDefectImproveDeptDTO> getEntryDefectImproveDept(GetEntryDefectImproveDeptVO getEntryDefectImproveDeptVO);
     public IPage<BehospitalInfoDTO> getEntryDefectImproveInner(GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO);
+    public List<ExportExcelDTO> getDefectImproveInnerByExport(GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO);
 }

+ 60 - 0
src/main/java/com/diagbot/vo/GetEntryDefectImproveDeptVO.java

@@ -0,0 +1,60 @@
+package com.diagbot.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description:
+ * @author: cy
+ * @time: 2020/9/4 14:59
+ */
+@Getter
+@Setter
+public class GetEntryDefectImproveDeptVO extends Page {
+    /**
+     * 医院id
+     */
+    @ApiModelProperty(hidden = true)
+    private Long hospitalId;
+
+    /**
+     * 科室id
+     */
+    private String deptId;
+
+    /**
+     * 科室名称
+     */
+    private String deptName;
+
+    /**
+     * 主管医生
+     */
+    private String doctorName;
+
+    /**
+     * 医师工号
+     */
+    private String doctorId;
+
+    /**
+     * 缺陷名称
+     */
+    private String entryName;
+
+    /**
+     * 模块名称
+     */
+    private String casesName;
+
+    @NotNull(message = "请输入起始时间")
+    private String startDate;
+
+    @NotNull(message = "请输入截止时间")
+    private String endDate;
+
+}

+ 17 - 5
src/main/java/com/diagbot/web/DataAnalysisController.java

@@ -68,7 +68,7 @@ public class DataAnalysisController {
     @PostMapping("/getQcClickByExport")
     @SysLogger("getQcClickByExport")
     public void getQcClickByExport(HttpServletResponse response, @RequestBody @Valid GetQcClickVO getQcClickVO) {
-         dataAnalysisFacade.getQcClickByExport(response,getQcClickVO);
+        dataAnalysisFacade.getQcClickByExport(response, getQcClickVO);
     }
 
 
@@ -94,8 +94,8 @@ public class DataAnalysisController {
     @ApiOperation(value = "临床质控使用统计-内页导出[by:cy]")
     @PostMapping("/getQcClickInnerPageByExport")
     @SysLogger("getQcClickInnerPageByExport")
-    public void getQcClickInnerPageByExport(HttpServletResponse response,@RequestBody @Valid GetQcClickInnerPageVO getQcClickInnerPageVO) {
-       dataAnalysisFacade.getQcClickInnerPageByExport(response,getQcClickInnerPageVO);
+    public void getQcClickInnerPageByExport(HttpServletResponse response, @RequestBody @Valid GetQcClickInnerPageVO getQcClickInnerPageVO) {
+        dataAnalysisFacade.getQcClickInnerPageByExport(response, getQcClickInnerPageVO);
     }
 
     /**
@@ -120,8 +120,8 @@ public class DataAnalysisController {
     @ApiOperation(value = "条目缺陷改善统计-导出[by:cy]")
     @PostMapping("/getEntryDefectImproveByExport")
     @SysLogger("getEntryDefectImproveByExport")
-    public void getEntryDefectImproveByExport(HttpServletResponse response,@RequestBody @Valid GetEntryDefectImproveVO getEntryDefectImproveVO) {
-       dataAnalysisFacade.getEntryDefectImproveByExport(response,getEntryDefectImproveVO);
+    public void getEntryDefectImproveByExport(HttpServletResponse response, @RequestBody @Valid GetEntryDefectImproveVO getEntryDefectImproveVO) {
+        dataAnalysisFacade.getEntryDefectImproveByExport(response, getEntryDefectImproveVO);
     }
 
 
@@ -138,4 +138,16 @@ public class DataAnalysisController {
         return RespDTO.onSuc(dataAnalysisFacade.getEntryDefectImproveInner(getEntryDefectImproveInnerVO));
     }
 
+    /**
+     * 条目缺陷改善统计-内页导出
+     *
+     * @param getEntryDefectImproveInnerVO
+     * @return
+     */
+    @ApiOperation(value = "条目缺陷改善统计-内页导出[by:cy]")
+    @PostMapping("/getDefectImproveInnerByExport")
+    @SysLogger("getDefectImproveInnerByExport")
+    public void getDefectImproveInnerByExport(HttpServletResponse response, @RequestBody GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO) {
+        dataAnalysisFacade.getDefectImproveInnerByExport(response, getEntryDefectImproveInnerVO);
+    }
 }

+ 48 - 16
src/main/java/com/diagbot/web/DataAnalysisDeptController.java

@@ -1,9 +1,15 @@
 package com.diagbot.web;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.BehospitalInfoDTO;
+import com.diagbot.dto.GetEntryDefectImproveDeptDTO;
 import com.diagbot.dto.GetQcClickDTO;
 import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.DataAnalysisDeptFacade;
 import com.diagbot.facade.DataAnalysisFacade;
+import com.diagbot.vo.GetEntryDefectImproveDeptVO;
+import com.diagbot.vo.GetEntryDefectImproveInnerVO;
 import com.diagbot.vo.GetQcClickInnerPageVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -29,6 +35,8 @@ public class DataAnalysisDeptController {
 
     @Autowired
     DataAnalysisFacade dataAnalysisFacade;
+    @Autowired
+    DataAnalysisDeptFacade dataAnalysisDeptFacade;
 
     /**
      * 临床质控使用统计(科室)
@@ -58,31 +66,55 @@ public class DataAnalysisDeptController {
 
 
     /**
-     * 条目缺陷改善统计
+     * 条目缺陷改善统计(科室)
      *
-     * @param getEntryDefectImproveVO
+     * @param getEntryDefectImproveDeptVO
      * @return
      */
-/*
-    @ApiOperation(value = "条目缺陷改善统计[by:cy]")
-    @PostMapping("/getEntryDefectImprove")
-    @SysLogger("getEntryDefectImprove")
-    public RespDTO<IPage<GetEntryDefectImproveDTO>> getEntryDefectImprove(@RequestBody @Valid GetEntryDefectImproveVO getEntryDefectImproveVO) {
-        return RespDTO.onSuc(dataAnalysisFacade.getEntryDefectImprove(getEntryDefectImproveVO));
+    @ApiOperation(value = "条目缺陷改善统计(科室)[by:cy]")
+    @PostMapping("/getEntryDefectImproveDept")
+    @SysLogger("getEntryDefectImproveDept")
+    public RespDTO<IPage<GetEntryDefectImproveDeptDTO>> getEntryDefectImprove(@RequestBody @Valid GetEntryDefectImproveDeptVO getEntryDefectImproveDeptVO) {
+        return RespDTO.onSuc(dataAnalysisDeptFacade.getEntryDefectImproveDept(getEntryDefectImproveDeptVO));
     }
-*/
 
     /**
      * 条目缺陷改善统计(科室)-导出
      *
-     * @param getEntryDefectImproveVO
+     * @param getEntryDefectImproveDeptVO
+     * @return
+     */
+    @ApiOperation(value = "条目缺陷改善统计(科室)-导出[by:cy]")
+    @PostMapping("/getEntryDefectImproveByDeptExport")
+    @SysLogger("getEntryDefectImproveByDeptExport")
+    public void getEntryDefectImproveByDeptExport(HttpServletResponse response,@RequestBody @Valid GetEntryDefectImproveDeptVO getEntryDefectImproveDeptVO) {
+        dataAnalysisDeptFacade.getEntryDefectImproveByDeptExport(response,getEntryDefectImproveDeptVO);
+    }
+
+    /**
+     * 条目缺陷改善统计(科室)-内页
+     *
+     * @param getEntryDefectImproveInnerVO
      * @return
      */
-  /*  @ApiOperation(value = "条目缺陷改善统计(科室)-导出[by:cy]")
-    @PostMapping("/getEntryDefectImproveByExport")
-    @SysLogger("getEntryDefectImproveByExport")
-    public void getEntryDefectImproveByExport(HttpServletResponse response,@RequestBody @Valid GetEntryDefectImproveVO getEntryDefectImproveVO) {
-       dataAnalysisFacade.getEntryDefectImproveByExport(response,getEntryDefectImproveVO);
-    }*/
+    @ApiOperation(value = "条目缺陷改善统计(科室)-内页[by:cy]")
+    @PostMapping("/getEntryDefectImproveInnerDept")
+    @SysLogger("getEntryDefectImproveInnerDept")
+    public RespDTO<IPage<BehospitalInfoDTO>> getEntryDefectImproveInnerDept(@RequestBody GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO) {
+        return RespDTO.onSuc(dataAnalysisFacade.getEntryDefectImproveInner(getEntryDefectImproveInnerVO));
+    }
+
+    /**
+     * 条目缺陷改善统计(科室)-内页导出
+     *
+     * @param getEntryDefectImproveInnerVO
+     * @return
+     */
+    @ApiOperation(value = "条目缺陷改善统计(科室)-内页导出[by:cy]")
+    @PostMapping("/getDefectImproveInnerByDeptExport")
+    @SysLogger("getDefectImproveInnerByDeptExport")
+    public void getDefectImproveInnerByDeptExport(HttpServletResponse response, @RequestBody GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO) {
+        dataAnalysisFacade.getDefectImproveInnerByExport(response, getEntryDefectImproveInnerVO);
+    }
 
 }

+ 673 - 1
src/main/resources/mapper/MedClickInfoMapper.xml

@@ -19,6 +19,28 @@
         <result column="modifier" property="modifier"/>
     </resultMap>
 
+    <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
+        <result column="deptName" property="behDeptName"/>
+        <result column="avgScore" property="avgScore"/>
+        <collection property="excelBehospitalDTOS"
+                    ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
+            <result column="doctorName" property="doctorName"/>
+            <result column="NAME" property="patName"/>
+            <result column="behospitalCode" property="behospitalCode"/>
+            <result column="behospitalDate" property="behospitalDate"/>
+            <result column="leaveHospitalDate" property="leaveHospitalDate"/>
+            <result column="scoreRes" property="score"/>
+            <result column="scoreBn" property="scoreBn"/>
+            <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
+                <result column="casesName" property="caseName"/>
+                <collection property="exportExcelMsgDTOS"
+                            ofType="com.diagbot.dto.ExportExcelMsgDTO">
+                    <result column="entryName" property="msg"/>
+                </collection>
+            </collection>
+        </collection>
+    </resultMap>
+
     <select id="getQcClick" resultType="com.diagbot.dto.GetQcClickDTO">
         select
         t.deptId,
@@ -319,7 +341,38 @@
     </select>
 
     <select id="getEntryDefectImproveInner" resultType="com.diagbot.dto.BehospitalInfoDTO">
-        SELECT y.* from(
+        SELECT distinct
+        y.hospitalId,
+        y.deptId,
+        y.deptName,
+        y.fileCode,
+        y.behospitalCode,
+        y. NAME,
+        y.sex,
+        y.bedCode,
+        y.behospitalDate,
+        y.leaveHospitalDate,
+        y.placefileDate,
+        y.diagnose,
+        y.doctorId,
+        y.doctorName,
+        y.behDoctorId,
+        y.behDoctorName,
+        y.directorDoctorId,
+        y.directorDoctorName,
+        y.wardCode,
+        y.wardName,
+        y.`level`,
+        y.gradeType,
+        y.scoreRes,
+        y.gradeTime,
+        y.age,
+        y.scoreBn,
+        y.checkStatus,
+        y.chType,
+        y.chName,
+        y.chTime
+        from(
         SELECT
         s.hospitalId,
         s.deptId,
@@ -551,6 +604,21 @@
         <if test="deptName != null and deptName != ''">
             and q.beh_dept_name like CONCAT('%',#{deptName},'%')
         </if>
+        <if test="diagnose != null and diagnose != ''">
+            AND q.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
+        </if>
+        <if test="doctorId != null and doctorId != ''">
+            and q.doctor_id = #{doctor_id}
+        </if>
+        <if test="doctorName != null and doctorName != ''">
+            and q.doctor_name like CONCAT('%',#{doctorName},'%')
+        </if>
+        <if test="patName != null and patName != ''">
+            and q.name like CONCAT('%',#{patName},'%')
+        </if>
+        <if test="behospitalCode != null and behospitalCode != ''">
+            and q.behospital_code like CONCAT('%',#{behospitalCode},'%')
+        </if>
         GROUP BY
         q.beh_dept_id,
         q.beh_dept_name,
@@ -580,6 +648,21 @@
         <if test="deptName != null and deptName != ''">
             and q.beh_dept_name like CONCAT('%',#{deptName},'%')
         </if>
+        <if test="diagnose != null and diagnose != ''">
+            AND q.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
+        </if>
+        <if test="doctorId != null and doctorId != ''">
+            and q.doctor_id = #{doctor_id}
+        </if>
+        <if test="doctorName != null and doctorName != ''">
+            and q.doctor_name like CONCAT('%',#{doctorName},'%')
+        </if>
+        <if test="patName != null and patName != ''">
+            and q.name like CONCAT('%',#{patName},'%')
+        </if>
+        <if test="behospitalCode != null and behospitalCode != ''">
+            and q.behospital_code like CONCAT('%',#{behospitalCode},'%')
+        </if>
         GROUP BY
         q.beh_dept_id,
         q.beh_dept_name,
@@ -636,4 +719,593 @@
             AND y.improveleNum = 1
         </if>
     </select>
+    <select id="getDefectImproveInnerByExport" resultMap="ExportExcelMap">
+        SELECT y.* from(
+        SELECT
+        s.hospitalId,
+        s.deptId,
+        s.deptName,
+        s.fileCode,
+        s.behospitalCode,
+        s. NAME,
+        s.sex,
+        s.bedCode,
+        s.behospitalDate,
+        s.leaveHospitalDate,
+        s.placefileDate,
+        s.diagnose,
+        s.doctorId,
+        s.doctorName,
+        s.behDoctorId,
+        s.behDoctorName,
+        s.directorDoctorId,
+        s.directorDoctorName,
+        s.wardCode,
+        s.wardName,
+        s.lastQcresultInfoId,
+        s.`level`,
+        s.gradeType,
+        s.scoreRes,
+        s.gradeTime,
+        s.age,
+        s.scoreBn,
+        s.checkStatus,
+        s.chType,
+        s.chName,
+        s.chTime,
+        s.casesId,
+        s.casesName,
+        s.entryName,
+        s.beforeCasesEntryId AS entryId,
+        sum(s.totalNum) AS totalNum,
+        sum(s.improveleNum) AS improveleNum,
+        sum(s.totalNum) - sum(s.improveleNum) AS handleNum
+        FROM
+        (
+        SELECT
+        f.*,
+        count(f.beforeCasesEntryId) AS totalNum,
+        CASE
+        WHEN count(f.lastCasesEntryId) &gt; 0 AND count(f.beforeCasesEntryId) - count(f.lastCasesEntryId) &lt;= 0 THEN
+        count(f.beforeCasesEntryId)
+        WHEN count(f.lastCasesEntryId) &gt; 0 AND count(f.beforeCasesEntryId) - count(f.lastCasesEntryId) &gt; 0 THEN
+        count(f.beforeCasesEntryId) - count(f.lastCasesEntryId)
+        WHEN count(f.lastCasesEntryId) = 0 THEN 0
+        END AS improveleNum
+        FROM
+        (
+        SELECT
+        k.*, i. NAME AS casesName,
+        o. NAME AS entryName,
+        y.cases_entry_id AS lastCasesEntryId
+        FROM
+        (
+        SELECT
+        e.*, t.beforeQcresultInfoId,
+        u.cases_id AS casesId,
+        u.cases_entry_id AS beforeCasesEntryId
+        FROM
+        (
+        SELECT
+        h.*
+        FROM
+        (
+        SELECT DISTINCT
+        w.hospital_id,
+        w.behospital_code
+        FROM
+        med_click_info w
+        WHERE
+        w.is_deleted = 'N'
+        <if test="hospitalId != null and hospitalId != ''">
+            AND w.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ AND w.gmt_create >= #{startDate}]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[ AND w.gmt_create <= #{endDate}]]>
+        </if>
+        ) g
+        LEFT JOIN (
+        SELECT
+        v.hospital_id AS hospitalId,
+        v.beh_dept_id AS deptId,
+        v.beh_dept_name AS deptName,
+        v.file_code AS fileCode,
+        v.behospital_code AS behospitalCode,
+        v. NAME,
+        v.sex,
+        v.bed_code AS bedCode,
+        v.behospital_date AS behospitalDate,
+        v.leave_hospital_date AS leaveHospitalDate,
+        v.placefile_date AS placefileDate,
+        v.diagnose AS diagnose,
+        v.doctor_id AS doctorId,
+        v.doctor_name AS doctorName,
+        v.beh_doctor_id AS behDoctorId,
+        v.beh_doctor_name AS behDoctorName,
+        v.director_doctor_id AS directorDoctorId,
+        v.director_doctor_name AS directorDoctorName,
+        v.ward_code AS wardCode,
+        v.ward_name AS wardName,
+        v.lastQcresultInfoId,
+        ifnull(p. LEVEL, '未评分') AS `level`,
+        p.grade_type AS gradeType,
+        p.score_res AS scoreRes,
+        p.gmt_create AS gradeTime,
+        IF ( n.age IS NULL,NULL,CONCAT(ifnull(n.age, ''),ifnull(n.age_unit, ''))) AS age,
+        r.score_res AS scoreBn,
+        CASE WHEN ISNULL(j. STATUS) THEN 0 ELSE j.STATUS END checkStatus,
+        j.check_type AS chType,
+        j.check_name AS chName,
+        j.check_time AS chTime
+        FROM
+        (
+        SELECT
+        q.*,
+        max(w.qcresult_info_id) AS lastQcresultInfoId
+        FROM
+        med_behospital_info q,
+        med_click_info w
+        WHERE
+        q.is_deleted = 'N'
+        AND w.is_deleted = 'N'
+        AND q.hospital_id = w.hospital_id
+        AND q.behospital_code = w.behospital_code
+        AND q.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND q.hospital_id = #{hospitalId}
+        </if>
+        <if test="deptId != null and deptId != ''">
+            and q.beh_dept_id = #{deptId}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and q.beh_dept_name like CONCAT('%',#{deptName},'%')
+        </if>
+        <if test="diagnose != null and diagnose != ''">
+            AND q.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
+        </if>
+        <if test="doctorId != null and doctorId != ''">
+            and q.doctor_id = #{doctor_id}
+        </if>
+        <if test="doctorName != null and doctorName != ''">
+            and q.doctor_name like CONCAT('%',#{doctorName},'%')
+        </if>
+        <if test="patName != null and patName != ''">
+            and q.name like CONCAT('%',#{patName},'%')
+        </if>
+        <if test="behospitalCode != null and behospitalCode != ''">
+            and q.behospital_code like CONCAT('%',#{behospitalCode},'%')
+        </if>
+        GROUP BY
+        q.beh_dept_id,
+        q.beh_dept_name,
+        q.behospital_code
+        ) v
+        LEFT JOIN med_qcresult_info p ON v.hospital_id = p.hospital_id
+        AND v.behospital_code = p.behospital_code
+        AND p.is_deleted = 'N'
+        LEFT JOIN med_home_page n ON v.hospital_id = n.hospital_id
+        AND v.behospital_code = n.behospital_code
+        AND n.is_deleted = 'N'
+        LEFT JOIN med_qcresult_cases r ON v.hospital_id = r.hospital_id
+        AND v.behospital_code = r.behospital_code
+        AND r.is_deleted = 'N'
+        AND r.cases_id = 243
+        LEFT JOIN (
+        SELECT
+        *
+        FROM
+        med_check_info
+        WHERE
+        is_deleted = 'N'
+        AND check_type IN (0, 2)
+        ) j ON v.behospital_code = j.behospital_code
+        AND v.hospital_id = j.hospital_id
+        where 1=1
+        <if test="level != null and level != ''">
+            and p.level = #{level}
+        </if>
+        <if test="checkStatus != null ">
+            and j.check_status = #{checkStatus}
+        </if>
+
+        <if test="chName != null and chName !=''">
+            AND j.ch_name like CONCAT('%',#{chName},'%')
+        </if>
+        <if test="chTimeStart != null">
+            <![CDATA[ and j.ch_time >= #{chTimeStart}]]>
+        </if>
+        <if test="chTimeEnd != null">
+            <![CDATA[ and j.ch_time < #{chTimeEnd}]]>
+        </if>
+        ) h ON g.hospital_id = h.hospitalId
+        AND g.behospital_code = h.behospitalCode
+        ) e
+        LEFT JOIN (
+        SELECT
+        q.hospital_id,
+        q.beh_dept_id AS dept_id,
+        q.beh_dept_name AS dept_name,
+        w.behospital_code,
+        min(w.qcresult_info_id) AS beforeQcresultInfoId
+        FROM
+        med_behospital_info q,
+        med_click_info w,
+        med_qcresult_detail e
+        WHERE
+        q.is_deleted = 'N'
+        AND w.is_deleted = 'N'
+        AND e.is_deleted = 'Y'
+        AND q.hospital_id = w.hospital_id
+        AND q.hospital_id = e.hospital_id
+        AND q.behospital_code = w.behospital_code
+        AND w.qcresult_info_id = e.qcresult_info_id
+        AND q.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND q.hospital_id = #{hospitalId}
+        </if>
+        <if test="deptId != null and deptId != ''">
+            and q.beh_dept_id = #{deptId}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and q.beh_dept_name like CONCAT('%',#{deptName},'%')
+        </if>
+        <if test="diagnose != null and diagnose != ''">
+            AND q.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
+        </if>
+        <if test="doctorId != null and doctorId != ''">
+            and q.doctor_id = #{doctor_id}
+        </if>
+        <if test="doctorName != null and doctorName != ''">
+            and q.doctor_name like CONCAT('%',#{doctorName},'%')
+        </if>
+        <if test="patName != null and patName != ''">
+            and q.name like CONCAT('%',#{patName},'%')
+        </if>
+        <if test="behospitalCode != null and behospitalCode != ''">
+            and q.behospital_code like CONCAT('%',#{behospitalCode},'%')
+        </if>
+        GROUP BY
+        q.beh_dept_id,
+        q.beh_dept_name,
+        q.behospital_code
+        UNION
+        SELECT
+        q.hospital_id,
+        q.beh_dept_id AS dept_id,
+        q.beh_dept_name AS dept_name,
+        w.behospital_code,
+        min(w.qcresult_info_id) AS beforeQcresultInfoId
+        FROM
+        med_behospital_info q,
+        med_click_info w
+        WHERE
+        q.is_deleted = 'N'
+        AND w.is_deleted = 'N'
+        AND q.hospital_id = w.hospital_id
+        AND q.behospital_code = w.behospital_code
+        AND q.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND q.hospital_id = #{hospitalId}
+        </if>
+        <if test="deptId != null and deptId != ''">
+            and q.beh_dept_id = #{deptId}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and q.beh_dept_name like CONCAT('%',#{deptName},'%')
+        </if>
+        <if test="diagnose != null and diagnose != ''">
+            AND q.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
+        </if>
+        <if test="doctorId != null and doctorId != ''">
+            and q.doctor_id = #{doctor_id}
+        </if>
+        <if test="doctorName != null and doctorName != ''">
+            and q.doctor_name like CONCAT('%',#{doctorName},'%')
+        </if>
+        <if test="patName != null and patName != ''">
+            and q.name like CONCAT('%',#{patName},'%')
+        </if>
+        <if test="behospitalCode != null and behospitalCode != ''">
+            and q.behospital_code like CONCAT('%',#{behospitalCode},'%')
+        </if>
+        GROUP BY
+        q.beh_dept_id,
+        q.beh_dept_name,
+        q.behospital_code
+        HAVING
+        count(q.behospital_code) = 1
+        ) t ON e.hospitalId = t.hospital_id
+        AND e.behospitalCode = t.behospital_code
+        LEFT JOIN med_qcresult_detail u ON t.hospital_id = u.hospital_id
+        AND t.beforeQcresultInfoId = u.qcresult_info_id
+        WHERE
+        u.grade_type = 1
+        ORDER BY
+        t.dept_name
+        ) k
+        LEFT JOIN med_qcresult_detail y ON k.hospitalId = y.hospital_id
+        AND k.lastQcresultInfoId = y.qcresult_info_id
+        AND k.beforeCasesEntryId = y.cases_entry_id
+        LEFT JOIN qc_cases i ON i.id = k.casesId
+        AND i.is_deleted = 'N'
+        LEFT JOIN qc_cases_entry o ON o.id = k.beforeCasesEntryId
+        AND o.is_deleted = 'N'
+        WHERE
+        (y.grade_type = 1 OR y.cases_entry_id IS NULL)
+        <if test="casesName != null and casesName != ''">
+            and i.name like CONCAT('%',#{casesName},'%')
+        </if>
+        <if test="entryName != null and entryName != ''">
+            and o.name like CONCAT('%',#{entryName},'%')
+        </if>
+        ) f
+        GROUP BY
+        f.deptId,
+        f.deptName,
+        f.behospitalCode,
+        f.casesId,
+        f.beforeCasesEntryId
+        ) s
+        GROUP BY
+        s.deptId,
+        s.deptName,
+        s.casesId,
+        s.behospitalCode,
+        s.beforeCasesEntryId)y
+        where
+        1=1
+        <if test="typeMark != null and typeMark !='' and typeMark == 0">
+            AND y.totalNum = 1
+        </if>
+        <if test="typeMark != null and typeMark !='' and typeMark == 1">
+            AND y.handleNum = 1
+        </if>
+        <if test="typeMark != null and typeMark !='' and typeMark == 2">
+            AND y.improveleNum = 1
+        </if>
+    </select>
+
+    <select id="getEntryDefectImproveDept" resultType="com.diagbot.dto.GetEntryDefectImproveDeptDTO">
+        SELECT
+        s.hospitalId,
+        s.deptId,
+        s.deptName,
+        s.doctorId,
+        s.doctorName,
+        s.casesId,
+        s.casesName,
+        s.entryName,
+        s.entryId,
+        sum(s.totalNum) AS totalNum,
+        sum(s.improveleNum) AS improveleNum,
+        sum(s.totalNum) - sum(s.improveleNum) AS handleNum,
+        concat(ROUND((sum(s.totalNum) - sum(s.improveleNum)) / sum(s.totalNum) * 100,2),'%') AS handleStr
+        FROM
+        (
+        SELECT
+        f.hospitalId,
+        f.deptId,
+        f.deptName,
+        f.doctorId,
+        f.doctorName,
+        f.behospitalCode,
+        f.casesId,
+        f.casesName,
+        f.casesEntryName as entryName,
+        f.beforeCasesEntryId as entryId,
+        count(f.beforeCasesEntryId) AS totalNum,
+        CASE
+        WHEN count(f.lastCasesEntryId) &gt; 0 AND count(f.beforeCasesEntryId) - count(f.lastCasesEntryId) &lt;= 0 THEN
+        count(f.beforeCasesEntryId)
+        WHEN count(f.lastCasesEntryId) &gt; 0 AND count(f.beforeCasesEntryId) - count(f.lastCasesEntryId) &gt; 0 THEN
+        count(f.beforeCasesEntryId) - count(f.lastCasesEntryId)
+        WHEN count(f.lastCasesEntryId) = 0 THEN 0
+        END AS improveleNum
+        FROM
+        (
+        SELECT
+        k.*, i. NAME AS casesName,
+        o. NAME AS casesEntryName,
+        y.cases_entry_id AS lastCasesEntryId
+        FROM
+        (
+        SELECT
+        e.hospital_id AS hospitalId,
+        e.dept_id AS deptId,
+        e.dept_name AS deptName,
+        e.doctor_id AS doctorId,
+        e.doctor_name AS doctorName,
+        e.behospital_code AS behospitalCode,
+        e.lastQcresultInfoId,
+        t.beforeQcresultInfoId,
+        u.cases_id AS casesId,
+        u.cases_entry_id AS beforeCasesEntryId
+        FROM
+        (
+        SELECT
+        h.hospital_id,
+        h.dept_id,
+        h.dept_name,
+        h.doctor_id,
+        h.doctor_name,
+        h.behospital_code,
+        h.lastQcresultInfoId
+        FROM
+        (
+        SELECT DISTINCT
+        w.hospital_id,
+        w.behospital_code
+        FROM
+        med_click_info w
+        WHERE
+        w.is_deleted = 'N'
+        <if test="hospitalId != null and hospitalId != ''">
+            AND w.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ AND w.gmt_create >= #{startDate}]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[ AND w.gmt_create <= #{endDate}]]>
+        </if>
+        ) g
+        LEFT JOIN (
+        SELECT
+        q.hospital_id,
+        q.beh_dept_id AS dept_id,
+        q.beh_dept_name AS dept_name,
+        q.doctor_id,
+        q.doctor_name,
+        w.behospital_code,
+        max(w.qcresult_info_id) AS lastQcresultInfoId
+        FROM
+        med_behospital_info q,
+        med_click_info w
+        WHERE
+        q.is_deleted = 'N'
+        AND w.is_deleted = 'N'
+        AND q.hospital_id = w.hospital_id
+        AND q.behospital_code = w.behospital_code
+        AND q.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND q.hospital_id = #{hospitalId}
+        </if>
+        <if test="deptId != null and deptId != ''">
+            and q.beh_dept_id = #{deptId}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and q.beh_dept_name like CONCAT('%',#{deptName},'%')
+        </if>
+        <if test="doctorId != null and doctorId != ''">
+            and q.doctor_id =,#{doctorId}
+        </if>
+        <if test="doctorName != null and doctorName != ''">
+            and q.doctor_name like CONCAT('%',#{doctorName},'%')
+        </if>
+        GROUP BY
+        q.beh_dept_id,
+        q.beh_dept_name,
+        q.behospital_code
+        ) h ON g.hospital_id = h.hospital_id
+        AND g.behospital_code = h.behospital_code
+        ) e
+        LEFT JOIN (
+        SELECT
+        q.hospital_id,
+        q.beh_dept_id AS dept_id,
+        q.beh_dept_name AS dept_name,
+        w.behospital_code,
+        min(w.qcresult_info_id) AS beforeQcresultInfoId
+        FROM
+        med_behospital_info q,
+        med_click_info w,
+        med_qcresult_detail e
+        WHERE
+        q.is_deleted = 'N'
+        AND w.is_deleted = 'N'
+        AND e.is_deleted = 'Y'
+        AND q.hospital_id = w.hospital_id
+        AND q.hospital_id = e.hospital_id
+        AND q.behospital_code = w.behospital_code
+        AND w.qcresult_info_id =e.qcresult_info_id
+        AND q.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND q.hospital_id = #{hospitalId}
+        </if>
+        <if test="deptId != null and deptId != ''">
+            and q.beh_dept_id = #{deptId}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and q.beh_dept_name like CONCAT('%',#{deptName},'%')
+        </if>
+        <if test="doctorId != null and doctorId != ''">
+            and q.doctor_id =,#{doctorId}
+        </if>
+        <if test="doctorName != null and doctorName != ''">
+            and q.doctor_name like CONCAT('%',#{doctorName},'%')
+        </if>
+        GROUP BY
+        q.beh_dept_id,
+        q.beh_dept_name,
+        q.behospital_code
+        UNION
+        SELECT
+        q.hospital_id,
+        q.beh_dept_id AS dept_id,
+        q.beh_dept_name AS dept_name,
+        w.behospital_code,
+        min(w.qcresult_info_id) AS beforeQcresultInfoId
+        FROM
+        med_behospital_info q,
+        med_click_info w
+        WHERE
+        q.is_deleted = 'N'
+        AND w.is_deleted = 'N'
+        AND q.hospital_id = w.hospital_id
+        AND q.behospital_code = w.behospital_code
+        AND q.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND q.hospital_id = #{hospitalId}
+        </if>
+        <if test="deptId != null and deptId != ''">
+            and q.beh_dept_id = #{deptId}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and q.beh_dept_name like CONCAT('%',#{deptName},'%')
+        </if>
+        <if test="doctorId != null and doctorId != ''">
+            and q.doctor_id =,#{doctorId}
+        </if>
+        <if test="doctorName != null and doctorName != ''">
+            and q.doctor_name like CONCAT('%',#{doctorName},'%')
+        </if>
+        GROUP BY
+        q.beh_dept_id,
+        q.beh_dept_name,
+        q.behospital_code
+        HAVING
+        count(q.behospital_code) = 1
+        ) t ON e.hospital_id = t.hospital_id
+        AND e.behospital_code = t.behospital_code
+        LEFT JOIN med_qcresult_detail u ON t.hospital_id = u.hospital_id
+        AND t.beforeQcresultInfoId = u.qcresult_info_id
+        WHERE
+        u.grade_type = 1
+        ORDER BY
+        t.dept_name
+        ) k
+        LEFT JOIN med_qcresult_detail y ON k.hospitalId = y.hospital_id
+        AND k.lastQcresultInfoId = y.qcresult_info_id
+        AND k.beforeCasesEntryId = y.cases_entry_id
+        LEFT JOIN qc_cases i ON i.id = k.casesId
+        AND i.is_deleted = 'N'
+        LEFT JOIN qc_cases_entry o ON o.id = k.beforeCasesEntryId
+        AND o.is_deleted = 'N'
+        WHERE
+        (y.grade_type = 1 OR y.cases_entry_id IS NULL)
+        <if test="casesName != null and casesName != ''">
+            and i.name like CONCAT('%',#{casesName},'%')
+        </if>
+        <if test="entryName != null and entryName != ''">
+            and o.name like CONCAT('%',#{entryName},'%')
+        </if>
+        ) f
+        GROUP BY
+        f.deptId,
+        f.deptName,
+        f.behospitalCode,
+        f.casesId,
+        f.beforeCasesEntryId
+        ) s
+        GROUP BY
+        s.deptId,
+        s.deptName,
+        s.doctorId,
+        s.doctorName,
+        s.casesId,
+        s.entryId
+    </select>
 </mapper>