Browse Source

条目缺陷改善统计-内页

chengyao 3 years ago
parent
commit
1ee471efe1

+ 72 - 0
src/main/java/com/diagbot/dto/BehospitalCodeDetail.java

@@ -0,0 +1,72 @@
+package com.diagbot.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: cy
+ * @time: 2021/12/2 11:04
+ */
+@Data
+public class BehospitalCodeDetail {
+
+    /**
+     * 病人住院ID
+     */
+    private String behospitalCode;
+
+    /**
+     * 姓名
+     */
+    private String name;
+
+    /**
+     * 档案号
+     */
+    private String fileCode;
+
+    /**
+     * 入院时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date behospitalDate;
+
+    /**
+     * 出院时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date leaveHospitalDate;
+
+
+    /**
+     * 医生姓名
+     */
+    private String doctorName;
+
+    /**
+     * 年龄
+     */
+    private String age;
+
+    /**
+     * 病历等级
+     */
+    private String level;
+
+    /**
+     * 最后得分
+     */
+    private Double scoreRes;
+
+    /**
+     * 评分时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date gradeTime;
+
+    List<QcResultDetailInfo> qcResultDetailInfos;
+}

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

@@ -0,0 +1,24 @@
+package com.diagbot.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: cy
+ * @time: 2021/12/2 11:04
+ */
+@Data
+public class EntryDefectImproveInner {
+
+    /**
+     * 住院科室名称
+     */
+    private String behDeptName;
+
+
+    List<BehospitalCodeDetail> behospitalCodeInfos;
+}

+ 0 - 5
src/main/java/com/diagbot/dto/QcResultDetailInfo.java

@@ -12,11 +12,6 @@ import java.util.List;
 @Data
 public class QcResultDetailInfo {
 
-    /**
-     * 评分结果id
-     */
-    private Long qcresultInfoId;
-
     /**
      * 触发埋点病历质控缺陷id集
      */

+ 5 - 0
src/main/java/com/diagbot/entity/MedClickInfo.java

@@ -50,6 +50,11 @@ public class MedClickInfo implements Serializable {
      */
     private String doctorName;
 
+    /**
+     * 0-单模块质控 1-全病历质控
+     */
+    private Long optType;
+
     /**
      * 质控结果基本信息ID
      */

+ 277 - 177
src/main/java/com/diagbot/facade/DataAnalysisFacade.java

@@ -2,10 +2,12 @@ package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.diagbot.dto.BehospitalCodeDetail;
 import com.diagbot.dto.BehospitalCodeInfo;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.DeptBaseDTO;
 import com.diagbot.dto.EntryDefectImprove;
+import com.diagbot.dto.EntryDefectImproveInner;
 import com.diagbot.dto.ExportExcelBehospitalDTO;
 import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.GetEntryDefectImproveDTO;
@@ -105,6 +107,7 @@ public class DataAnalysisFacade {
         BehospitalInfo behospitalInfo = behospitalInfoFacade.lambdaQuery()
                 .eq(BehospitalInfo::getHospitalId, medClickInfoVO.getHospitalId())
                 .eq(BehospitalInfo::getBehospitalCode, medClickInfoVO.getBehospitalCode())
+                .ne(BehospitalInfo::getQcTypeId, "0")
                 .eq(BehospitalInfo::getIsDeleted, IsDeleteEnum.N.getKey())
                 .one();
         List<QcresultDetail> list = qcresultDetailFacade.lambdaQuery()
@@ -201,65 +204,93 @@ public class DataAnalysisFacade {
     }
 
     public IPage<GetEntryDefectImproveDTO> getEntryDefectImprove(GetEntryDefectImproveVO getEntryDefectImproveVO) {
-        int current = (int)getEntryDefectImproveVO.getCurrent();
-        int size = (int)getEntryDefectImproveVO.getSize();
-        getEntryDefectImproveVO.setCurrent(1L);
-        getEntryDefectImproveVO.setSize(Long.MAX_VALUE);
+        int current = (int) getEntryDefectImproveVO.getCurrent();
+        int size = (int) getEntryDefectImproveVO.getSize();
         IPage<GetEntryDefectImproveDTO> page = new Page<>();
         entryDefectSet(getEntryDefectImproveVO);
         List<GetEntryDefectImproveDTO> getEntryDefectImproveDTO = new ArrayList<>();
+        //获取标准缺陷信息
         List<GetEntryInfoDTO> entryInfo = medClickInfoService.getBaseMapper().getEntryInfo();
+        //查询基础数据源
         List<EntryDefectImprove> records = medClickInfoService.getBaseMapper().getEntryDefectImprove(getEntryDefectImproveVO);
+        //遍历科室
         for (EntryDefectImprove entryDefectImprove : records) {
-            //科室下
             Map<String, Long> totalMap = new HashMap<>();
             Map<String, Long> improveleMap = new HashMap<>();
             List<BehospitalCodeInfo> behospitalCodeInfoList = entryDefectImprove.getBehospitalCodeInfos();
-            for (BehospitalCodeInfo behospitalCodeInfo : behospitalCodeInfoList) {
-                //病历下
-                List<QcResultDetailInfo> qcResultDetailInfos = behospitalCodeInfo.getQcResultDetailInfos();
-                //获取科室下质控缺陷总量
-                totalMap = getEntryTotalMap(qcResultDetailInfos, totalMap);
-                //质控下获取科室下待改善总缺陷
-                QcResultDetailInfo qcResultDetailInfo = qcResultDetailInfos.get(qcResultDetailInfos.size() - 1);
-                improveleMap = getEntryImproveleMap(qcResultDetailInfo, improveleMap);
-            }
-
+            //多份病历多次质控评分得到质控缺陷总量、待改善总量
+            unitProcessing(behospitalCodeInfoList, totalMap, improveleMap);
+            //按照全院维度进行数据封装
             for (Map.Entry<String, Long> stringLongEntry : totalMap.entrySet()) {
                 GetEntryDefectImproveDTO getEntryDefectImprove = new GetEntryDefectImproveDTO();
                 getEntryDefectImprove.setDeptId(entryDefectImprove.getDeptId());
                 getEntryDefectImprove.setDeptName(entryDefectImprove.getDeptName());
                 getEntryDefectImprove.setEntryId(stringLongEntry.getKey());
-                entryInfo.parallelStream().filter(kfc->kfc.getEntryId().equals(stringLongEntry.getKey())).forEach(
-                        obj->{
-                            getEntryDefectImprove.setCasesId(obj.getCasesId());
-                            getEntryDefectImprove.setCasesName(obj.getCasesName());
-                            getEntryDefectImprove.setEntryName(obj.getEntryName());
-                        }
-                );
+                //封装信息
+                getEntryInfo(entryInfo, stringLongEntry, getEntryDefectImprove);
                 getEntryDefectImprove.setTotalNum(stringLongEntry.getValue());
-                if(improveleMap.containsKey(stringLongEntry.getKey())){
+                if (improveleMap.containsKey(stringLongEntry.getKey())) {
                     getEntryDefectImprove.setImproveleNum(improveleMap.get(stringLongEntry.getKey()));
                 }
-                getEntryDefectImprove.setHandleNum(getEntryDefectImprove.getTotalNum()-getEntryDefectImprove.getImproveleNum());
+                getEntryDefectImprove.setHandleNum(getEntryDefectImprove.getTotalNum() - getEntryDefectImprove.getImproveleNum());
                 getEntryDefectImproveDTO.add(getEntryDefectImprove);
             }
         }
 
-
         //导出操作
-        if(getEntryDefectImproveVO.getExportType()==1L){
+        if (getEntryDefectImproveVO.getExportType() == 1L) {
             size = getEntryDefectImproveDTO.size();
         }
         page.setSize(size);
         page.setTotal(getEntryDefectImproveDTO.size());
         page.setCurrent(current);
+        //分页操作
         List<GetEntryDefectImproveDTO> getEntryDefectImproveDTOS = page(getEntryDefectImproveDTO, size, current);
-        getEntryDefectImproveDTOS= sortList(getEntryDefectImproveDTOS, getEntryDefectImproveVO.getAsc() != null ? getEntryDefectImproveVO.getAsc() : getEntryDefectImproveVO.getDesc()+" desc");
+        //排序操作
+        getEntryDefectImproveDTOS = sortList(getEntryDefectImproveDTOS, getEntryDefectImproveVO.getAsc() != null ? getEntryDefectImproveVO.getAsc() : getEntryDefectImproveVO.getDesc() + " desc");
         page.setRecords(getEntryDefectImproveDTOS);
         return page;
     }
 
+    /**
+     * @Description: 缺陷信息封装
+     * @Param: [entryInfo, stringLongEntry, getEntryDefectImprove]
+     * @return: com.diagbot.dto.GetEntryDefectImproveDTO
+     * @Author: cy
+     * @Date: 2021/12/3
+     */
+    public GetEntryDefectImproveDTO getEntryInfo(List<GetEntryInfoDTO> entryInfo, Map.Entry<String, Long> stringLongEntry,
+                                                 GetEntryDefectImproveDTO getEntryDefectImprove) {
+        entryInfo.parallelStream().filter(kfc -> kfc.getEntryId().equals(stringLongEntry.getKey())).forEach(
+                obj -> {
+                    getEntryDefectImprove.setCasesId(obj.getCasesId());
+                    getEntryDefectImprove.setCasesName(obj.getCasesName());
+                    getEntryDefectImprove.setEntryName(obj.getEntryName());
+                }
+        );
+        return getEntryDefectImprove;
+    }
+
+    /**
+     * @Description: 多份病历多次质控评分得到质控缺陷总量、待改善总量
+     * @Param: [behospitalCodeInfoList, totalMap, improveleMap]
+     * @return: void
+     * @Author: cy
+     * @Date: 2021/12/3
+     */
+    public void unitProcessing(List<BehospitalCodeInfo> behospitalCodeInfoList, Map<String, Long> totalMap,
+                               Map<String, Long> improveleMap) {
+        for (BehospitalCodeInfo behospitalCodeInfo : behospitalCodeInfoList) {
+            //病历下
+            List<QcResultDetailInfo> qcResultDetailInfos = behospitalCodeInfo.getQcResultDetailInfos();
+            //获取多病历多质控质控缺陷总量
+            totalMap = getEntryTotalMap(qcResultDetailInfos, totalMap);
+            //获取多病历多质控质控缺陷待改善总量
+            QcResultDetailInfo qcResultDetailInfo = qcResultDetailInfos.get(qcResultDetailInfos.size() - 1);
+            improveleMap = getEntryImproveleMap(qcResultDetailInfo, improveleMap);
+        }
+    }
+
 
     /**
      * @Description:分页数据
@@ -268,27 +299,28 @@ public class DataAnalysisFacade {
      * @Author: cy
      * @Date: 2021/12/2
      */
-    public static List<GetEntryDefectImproveDTO> page(List<GetEntryDefectImproveDTO> retRecords, int pageSize,int currentPage) {
-        List<GetEntryDefectImproveDTO> currentPageList = new ArrayList<>();
+    public static<T> List<T> page(List<T> retRecords, int pageSize, int currentPage) {
+        List<T> currentPageList = new ArrayList<>();
         if (retRecords != null && retRecords.size() > 0) {
             int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0);
             for (int i = 0; i < pageSize && i < retRecords.size() - currIdx; i++) {
-                GetEntryDefectImproveDTO data = retRecords.get(currIdx + i);
+                T data = retRecords.get(currIdx + i);
                 currentPageList.add(data);
             }
         }
         return currentPageList;
     }
+
     /**
      * 内存数据排序 使用JoSQL
-   //  * @param list
-   //  * @param orderByString  a asc,b desc
+     *
+     * @param list
+     * @param orderByString a asc,b desc
      * @return
      */
 
-
-    public static<T> List<T> sortList(List<T> list, String orderByString) {
-        String josql = " select * from " + list.get(0).getClass().getName() + " order by "+ orderByString;
+    public static <T> List<T> sortList(List<T> list, String orderByString) {
+        String josql = " select * from " + list.get(0).getClass().getName() + " order by " + orderByString;
         Query query = new Query();
         try {
             query.parse(josql);
@@ -321,21 +353,21 @@ public class DataAnalysisFacade {
         return improveMap;
     }
 
-        public Set getSetEntry (String casesEntryIds, Set set){
-            if (StringUtils.isNotBlank(casesEntryIds) && !"0".equals(casesEntryIds)) {
-                if (casesEntryIds.contains("、")) {
-                    String[] split = casesEntryIds.split("、");
-                    for (String id : split) {
-                        set.add(id);
-                    }
-                } else {
-                    set.add(casesEntryIds);
+    public Set getSetEntry(String casesEntryIds, Set set) {
+        if (StringUtils.isNotBlank(casesEntryIds) && !"0".equals(casesEntryIds)) {
+            if (casesEntryIds.contains("、")) {
+                String[] split = casesEntryIds.split("、");
+                for (String id : split) {
+                    set.add(id);
                 }
+            } else {
+                set.add(casesEntryIds);
             }
-            return set;
         }
+        return set;
+    }
 
-    public Map getSetEntryCount ( Map<String, Long> map, Set<String> sets){
+    public Map getSetEntryCount(Map<String, Long> map, Set<String> sets) {
         for (String set : sets) {
             if (map.containsKey(set)) {
                 long count = map.get(set) + 1l;
@@ -347,155 +379,223 @@ public class DataAnalysisFacade {
         return map;
     }
 
-        public void getEntryDefectImproveByExport (HttpServletResponse response, GetEntryDefectImproveVO
-        getEntryDefectImproveVO){
-            getEntryDefectImproveVO.setExportType(1L);
-            getEntryDefectImproveVO.setCurrent(1L);
-            getEntryDefectImproveVO.setSize(Long.MAX_VALUE);
-            getEntryDefectImproveVO.setSearchCount(false);
-            IPage<GetEntryDefectImproveDTO> page = getEntryDefectImprove(getEntryDefectImproveVO);
-            String fileName = "条目缺陷改善统计.xls";
-            ExcelUtils.exportExcel(page.getRecords(), null, "sheet1", GetEntryDefectImproveDTO.class, fileName, response, 12.8f);
-        }
+    public void getEntryDefectImproveByExport(HttpServletResponse response, GetEntryDefectImproveVO
+            getEntryDefectImproveVO) {
+        getEntryDefectImproveVO.setExportType(1L);
+        getEntryDefectImproveVO.setCurrent(1L);
+        getEntryDefectImproveVO.setSize(Long.MAX_VALUE);
+        getEntryDefectImproveVO.setSearchCount(false);
+        IPage<GetEntryDefectImproveDTO> page = getEntryDefectImprove(getEntryDefectImproveVO);
+        String fileName = "条目缺陷改善统计.xls";
+        ExcelUtils.exportExcel(page.getRecords(), null, "sheet1", GetEntryDefectImproveDTO.class, fileName, response, 12.8f);
+    }
 
 
-        public IPage<BehospitalInfoDTO> getEntryDefectImproveInner (GetEntryDefectImproveInnerVO
-        getEntryDefectImproveInnerVO){
-            entryDefectInnerSet(getEntryDefectImproveInnerVO);
-            IPage<BehospitalInfoDTO> records = medClickInfoService.getBaseMapper().getEntryDefectImproveInner(getEntryDefectImproveInnerVO);
-            return records;
+    public IPage<BehospitalInfoDTO> getEntryDefectImproveInner(GetEntryDefectImproveInnerVO
+                                                                       getEntryDefectImproveInnerVO) {
+        int current = (int) getEntryDefectImproveInnerVO.getCurrent();
+        int size = (int) getEntryDefectImproveInnerVO.getSize();
+        IPage<BehospitalInfoDTO> page = new Page<>();
+        List<BehospitalInfoDTO> behospitalInfoDTOS = new ArrayList<>();
+        entryDefectInnerSet(getEntryDefectImproveInnerVO);
+        List<GetEntryInfoDTO> entryInfo = medClickInfoService.getBaseMapper().getEntryInfo();
+        List<EntryDefectImproveInner> records = medClickInfoService.getBaseMapper().getEntryDefectImproveInner(getEntryDefectImproveInnerVO);
+        if (ListUtil.isNotEmpty(records) && records.size() == 1) {
+            EntryDefectImproveInner entryDefectImproveInner = records.get(0);
+            List<BehospitalCodeDetail> behospitalCodeDetails = entryDefectImproveInner.getBehospitalCodeInfos();
+            for (BehospitalCodeDetail behospitalCodeDetail : behospitalCodeDetails) {
+                List<QcResultDetailInfo> qcResultDetailInfos = behospitalCodeDetail.getQcResultDetailInfos();
+                Set<String> totalSet = new HashSet<String>();
+                Set<String> improveleSet = new HashSet<String>();
+                for (QcResultDetailInfo qcResultDetailInfo : qcResultDetailInfos) {
+                    String casesEntryIds = qcResultDetailInfo.getCasesEntryIds();
+                    totalSet = getSetEntry(casesEntryIds, totalSet);
+                }
+                QcResultDetailInfo qcResultDetailInfo = qcResultDetailInfos.get(qcResultDetailInfos.size() - 1);
+                if(null != qcResultDetailInfo && StringUtils.isNotBlank(qcResultDetailInfo.getCasesEntryIds())){
+                    improveleSet = getSetEntry(qcResultDetailInfo.getCasesEntryIds(), improveleSet);
+                }
+                if ("0".equals(getEntryDefectImproveInnerVO.getTypeMark()) && totalSet.contains(getEntryDefectImproveInnerVO.getEntryId())) {
+                    behospitalInfoDTOS = getBehospitalInfoDTO(entryDefectImproveInner, behospitalCodeDetail, behospitalInfoDTOS);
+                }
+                if ("1".equals(getEntryDefectImproveInnerVO.getTypeMark()) && !improveleSet.contains(getEntryDefectImproveInnerVO.getEntryId())) {
+                    behospitalInfoDTOS = getBehospitalInfoDTO(entryDefectImproveInner, behospitalCodeDetail, behospitalInfoDTOS);
+                }
+                if ("2".equals(getEntryDefectImproveInnerVO.getTypeMark()) && improveleSet.contains(getEntryDefectImproveInnerVO.getEntryId())) {
+                    behospitalInfoDTOS = getBehospitalInfoDTO(entryDefectImproveInner, behospitalCodeDetail, behospitalInfoDTOS);
+                }
+            }
         }
+        page.setSize(size);
+        page.setTotal(behospitalInfoDTOS.size());
+        page.setCurrent(current);
+        //分页操作
+        List<BehospitalInfoDTO> behospitalInfoDTOList = page(behospitalInfoDTOS, size, current);
+        //排序操作
+        behospitalInfoDTOList = sortList(behospitalInfoDTOList, getEntryDefectImproveInnerVO.getAsc() != null ? getEntryDefectImproveInnerVO.getAsc() : getEntryDefectImproveInnerVO.getDesc() + " desc");
+        page.setRecords(behospitalInfoDTOList);
+        return page;
+    }
 
-        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);
-        }
+    /**
+     * @Description: 数据封装
+     * @Param: [entryDefectImproveInner, behospitalCodeDetail, qcResultDetailInfo, behospitalInfoDTOS]
+     * @return: java.util.List<com.diagbot.dto.BehospitalInfoDTO>
+     * @Author: cy
+     * @Date: 2021/12/3
+     */
+    public List<BehospitalInfoDTO> getBehospitalInfoDTO(EntryDefectImproveInner entryDefectImproveInner, BehospitalCodeDetail behospitalCodeDetail,
+                                                        List<BehospitalInfoDTO> behospitalInfoDTOS) {
+        BehospitalInfoDTO behospitalInfoDTO = new BehospitalInfoDTO();
+        behospitalInfoDTO.setLevel(behospitalCodeDetail.getLevel());
+        behospitalInfoDTO.setScoreRes(behospitalCodeDetail.getScoreRes());
+        behospitalInfoDTO.setFileCode(behospitalCodeDetail.getFileCode());
+        behospitalInfoDTO.setBehospitalCode(behospitalCodeDetail.getBehospitalCode());
+        behospitalInfoDTO.setName(behospitalCodeDetail.getName());
+        behospitalInfoDTO.setAge(behospitalCodeDetail.getAge());
+        behospitalInfoDTO.setBehospitalDate(behospitalCodeDetail.getBehospitalDate());
+        behospitalInfoDTO.setLeaveHospitalDate(behospitalCodeDetail.getLeaveHospitalDate());
+        behospitalInfoDTO.setDoctorName(behospitalCodeDetail.getDoctorName());
+        behospitalInfoDTO.setBehDeptName(entryDefectImproveInner.getBehDeptName());
+        behospitalInfoDTO.setGradeTime(behospitalCodeDetail.getGradeTime());
+        behospitalInfoDTOS.add(behospitalInfoDTO);
+        return behospitalInfoDTOS;
+    }
 
-        /**
-         * 增加全院记录
-         *
-         * @param records
-         * @return
-         */
-        public GetQcClickDTO getGlobleTitle (List < GetQcClickDTO > records) {
-            GetQcClickDTO item = new GetQcClickDTO();
-            if (ListUtil.isEmpty(records)) {
-                return null;
-            }
+    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);
+    }
 
-            //缺陷总数
-            Integer singleMode = records
-                    .stream()
-                    .map(GetQcClickDTO::getSingleModeNum)
-                    .reduce(0, Integer::sum);
-            if (singleMode == null) {
-                singleMode = 0;
-            }
-            Integer totalMode = records
-                    .stream()
-                    .map(GetQcClickDTO::getTotalModeNum)
-                    .reduce(0, Integer::sum);
-            if (totalMode == null) {
-                totalMode = 0;
-            }
-            item.setDeptName("全院");
-            item.setSingleModeNum(singleMode);
-            item.setTotalModeNum(totalMode);
-            return item;
+    /**
+     * 增加全院记录
+     *
+     * @param records
+     * @return
+     */
+    public GetQcClickDTO getGlobleTitle(List<GetQcClickDTO> records) {
+        GetQcClickDTO item = new GetQcClickDTO();
+        if (ListUtil.isEmpty(records)) {
+            return null;
         }
 
-        private void clickPageSet (GetQcClickVO getQcClickVO){
-            //入参验证
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
-            Date startDate = null;
-            Date endDate = null;
-            try {
-                startDate = simpleDateFormat.parse(getQcClickVO.getStartDate());
-                endDate = simpleDateFormat.parse(getQcClickVO.getEndDate());
-            } catch (ParseException e) {
-                e.printStackTrace();
-            }
-            if (DateUtil.after(startDate, endDate)) {
-                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
-            }
-            getQcClickVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
+        //缺陷总数
+        Integer singleMode = records
+                .stream()
+                .map(GetQcClickDTO::getSingleModeNum)
+                .reduce(0, Integer::sum);
+        if (singleMode == null) {
+            singleMode = 0;
         }
+        Integer totalMode = records
+                .stream()
+                .map(GetQcClickDTO::getTotalModeNum)
+                .reduce(0, Integer::sum);
+        if (totalMode == null) {
+            totalMode = 0;
+        }
+        item.setDeptName("全院");
+        item.setSingleModeNum(singleMode);
+        item.setTotalModeNum(totalMode);
+        return item;
+    }
 
-        private void clickInnerPageSet (GetQcClickInnerPageVO getQcClickInnerPageVO){
-            //入参验证
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
-            Date startDate = null;
-            Date endDate = null;
-            try {
-                startDate = simpleDateFormat.parse(getQcClickInnerPageVO.getStartDate());
-                endDate = simpleDateFormat.parse(getQcClickInnerPageVO.getEndDate());
-            } catch (ParseException e) {
-                e.printStackTrace();
-            }
-            if (DateUtil.after(startDate, endDate)) {
-                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
-            }
-            getQcClickInnerPageVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
+    private void clickPageSet(GetQcClickVO getQcClickVO) {
+        //入参验证
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+        Date startDate = null;
+        Date endDate = null;
+        try {
+            startDate = simpleDateFormat.parse(getQcClickVO.getStartDate());
+            endDate = simpleDateFormat.parse(getQcClickVO.getEndDate());
+        } catch (ParseException e) {
+            e.printStackTrace();
         }
+        if (DateUtil.after(startDate, endDate)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
+        }
+        getQcClickVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
+    }
 
-        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()));
+    private void clickInnerPageSet(GetQcClickInnerPageVO getQcClickInnerPageVO) {
+        //入参验证
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+        Date startDate = null;
+        Date endDate = null;
+        try {
+            startDate = simpleDateFormat.parse(getQcClickInnerPageVO.getStartDate());
+            endDate = simpleDateFormat.parse(getQcClickInnerPageVO.getEndDate());
+        } catch (ParseException e) {
+            e.printStackTrace();
         }
+        if (DateUtil.after(startDate, endDate)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
+        }
+        getQcClickInnerPageVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
+    }
 
-        private void entryDefectInnerSet (GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO){
-            //入参验证
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
-            Date startDate = null;
-            Date endDate = null;
-            try {
-                startDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getStartDate());
-                endDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getEndDate());
+    private void entryDefectSet(GetEntryDefectImproveVO getEntryDefectImproveVO) {
+        getEntryDefectImproveVO.setCurrent(1L);
+        getEntryDefectImproveVO.setSize(Long.MAX_VALUE);
+        //入参验证
+        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()));
+    }
+
+    private void entryDefectInnerSet(GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO) {
+        getEntryDefectImproveInnerVO.setCurrent(1L);
+        getEntryDefectImproveInnerVO.setSize(Long.MAX_VALUE);
+        //入参验证
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+        Date startDate = null;
+        Date endDate = null;
+        try {
+            startDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getStartDate());
+            endDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getEndDate());
 
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        if (DateUtil.after(startDate, endDate)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
+        }
+        if (StringUtils.isNotBlank(getEntryDefectImproveInnerVO.getChTimeStart())
+                && StringUtils.isNotBlank(getEntryDefectImproveInnerVO.getChTimeEnd())
+        ) {
+            Date chTimeStartDate = null;
+            Date chTimeEndDate = null;
+            try {
+                chTimeStartDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getChTimeStart());
+                chTimeEndDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getChTimeStart());
             } catch (ParseException e) {
                 e.printStackTrace();
             }
-            if (DateUtil.after(startDate, endDate)) {
-                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
-            }
-            if (StringUtils.isNotBlank(getEntryDefectImproveInnerVO.getChTimeStart())
-                    && StringUtils.isNotBlank(getEntryDefectImproveInnerVO.getChTimeEnd())
-            ) {
-                Date chTimeStartDate = null;
-                Date chTimeEndDate = null;
-                try {
-                    chTimeStartDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getChTimeStart());
-                    chTimeEndDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getChTimeStart());
-                } catch (ParseException e) {
-                    e.printStackTrace();
-                }
-                if (DateUtil.after(chTimeStartDate, chTimeEndDate)) {
-                    throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "病历核查开始时间必须小于结束时间!");
-                }
+            if (DateUtil.after(chTimeStartDate, chTimeEndDate)) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "病历核查开始时间必须小于结束时间!");
             }
-            getEntryDefectImproveInnerVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
         }
+        getEntryDefectImproveInnerVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
     }
+}

+ 2 - 1
src/main/java/com/diagbot/mapper/MedClickInfoMapper.java

@@ -3,6 +3,7 @@ package com.diagbot.mapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.EntryDefectImprove;
+import com.diagbot.dto.EntryDefectImproveInner;
 import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.GetEntryDefectImproveDTO;
 import com.diagbot.dto.GetEntryDefectImproveDeptDTO;
@@ -33,6 +34,6 @@ public interface MedClickInfoMapper extends BaseMapper<MedClickInfo> {
     public List<EntryDefectImprove> getEntryDefectImprove(GetEntryDefectImproveVO getEntryDefectImproveVO);
     public List<GetEntryInfoDTO> getEntryInfo();
     public IPage<GetEntryDefectImproveDeptDTO> getEntryDefectImproveDept(GetEntryDefectImproveDeptVO getEntryDefectImproveDeptVO);
-    public IPage<BehospitalInfoDTO> getEntryDefectImproveInner(GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO);
+    public List<EntryDefectImproveInner> getEntryDefectImproveInner(GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO);
     public List<ExportExcelDTO> getDefectImproveInnerByExport(GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO);
 }

+ 11 - 1
src/main/java/com/diagbot/vo/GetEntryDefectImproveInnerVO.java

@@ -31,7 +31,7 @@ public class GetEntryDefectImproveInnerVO extends Page {
     /**
      * 条目id
      */
-    private Long entryId;
+    private String entryId;
 
     /**
      * 条目缺陷名称
@@ -107,4 +107,14 @@ public class GetEntryDefectImproveInnerVO extends Page {
      * 总数量-0,已改善数量-1,待改善数量-2
      */
     private String typeMark;
+
+    /**
+     * 排序(升序)
+     */
+    private String asc;
+
+    /**
+     * 排序(降序)
+     */
+    private String desc;
 }

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

@@ -51,10 +51,4 @@ public class GetQcClickVO{
 
     @NotNull(message = "请输入截止时间")
     private String endDate;
-
-    /**
-     * 0-单模块质控 1-全病历质控
-     */
-    private Long optType;
-
 }

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

@@ -51,4 +51,10 @@ public class MedClickInfoVO implements Serializable {
      */
     @NotBlank(message = "请输入病历住院id")
     private String behospitalCode;
+
+    /**
+     * 0-单模块质控 1-全病历质控
+     */
+    private Long optType;
+
 }

+ 67 - 704
src/main/resources/mapper/MedClickInfoMapper.xml

@@ -10,6 +10,7 @@
         <result column="dept_name" property="deptName"/>
         <result column="doctor_id" property="doctorId"/>
         <result column="doctor_name" property="doctorName"/>
+        <result column="opt_type" property="optType"/>
         <result column="qcresult_info_id" property="qcresultInfoId"/>
         <result column="behospital_code" property="behospitalCode"/>
         <result column="is_deleted" property="isDeleted"/>
@@ -27,7 +28,6 @@
                     ofType="com.diagbot.dto.BehospitalCodeInfo">
             <result column="behospitalCode" property="behospitalCode"/>
             <collection property="qcResultDetailInfos" ofType="com.diagbot.dto.QcResultDetailInfo">
-                <result column="qcresultInfoId" property="qcresultInfoId"/>
                 <result column="CasesEntryIds" property="CasesEntryIds"/>
             </collection>
         </collection>
@@ -56,6 +56,27 @@
         </collection>
     </resultMap>
 
+
+    <resultMap id="entryDefectImproveInnerMap" type="com.diagbot.dto.EntryDefectImproveInner">
+        <result column="behDeptName" property="behDeptName"/>
+        <collection property="behospitalCodeInfos" ofType="com.diagbot.dto.BehospitalCodeDetail">
+            <result column="behospitalCode" property="behospitalCode"/>
+            <result column="name" property="name"/>
+            <result column="fileCode" property="fileCode"/>
+            <result column="behospitalDate" property="behospitalDate"/>
+            <result column="leaveHospitalDate" property="leaveHospitalDate"/>
+            <result column="doctorName" property="doctorName"/>
+            <result column="age" property="age"/>
+            <result column="level" property="level"/>
+            <result column="scoreRes" property="scoreRes"/>
+            <result column="gradeTime" property="gradeTime"/>
+            <collection property="qcResultDetailInfos" ofType="com.diagbot.dto.QcResultDetailInfo">
+                <result column="CasesEntryIds" property="CasesEntryIds"/>
+            </collection>
+        </collection>
+    </resultMap>
+
+
     <select id="getQcClick" resultType="com.diagbot.dto.GetQcClickDTO">
         SELECT
         a.dept_id AS deptId,
@@ -85,7 +106,7 @@
         a.dept_id,
         a.dept_name
         <if test="asc != null and asc !=''">
-        order by
+            order by
             <choose>
                 <when test='asc=="singleModeNum"'>singleModeNum asc</when>
                 <when test='asc=="totalModeNum"'>totalModeNum asc</when>
@@ -161,7 +182,6 @@
         a.dept_id as deptId,
         a.dept_name as deptName,
         a.behospital_code as behospitalCode,
-        a.qcresult_info_id as qcresultInfoId,
         a.cases_entry_ids as casesEntryIds
         FROM
         med_qcresult_click a
@@ -182,733 +202,76 @@
         <if test="endDate != null and endDate != ''">
             <![CDATA[ AND a.gmt_create <= #{endDate}]]>
         </if>
-         order by gmt_create
+        order by gmt_create
     </select>
 
-    <select id="getEntryDefectImproveInner" resultType="com.diagbot.dto.BehospitalInfoDTO">
-        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 id="getEntryDefectImproveInner" resultMap="entryDefectImproveInnerMap">
         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
-        (
+        t.*,
+        IF( n.age IS NULL,NULL,CONCAT(ifnull(n.age, ''),ifnull(n.age_unit, ''))) AS age
+        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 checkStatus != ''">
-            and j.status = #{checkStatus}
-        </if>
-        <if test="chName != null and chName !=''">
-            and j.check_name like CONCAT('%',#{chName},'%')
-        </if>
-        <if test="chTimeStart != null and chTimeStart !=''">
-            <![CDATA[ and j.check_time >= #{chTimeStart}]]>
-        </if>
-        <if test="chTimeEnd != null and chTimeEnd !=''">
-            <![CDATA[ and j.check_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
+        a.hospital_id as hospitalId,
+        a.dept_id as deptId,
+        a.dept_name as behDeptName,
+        b.file_code AS fileCode,
+        a.behospital_code as behospitalCode,
+        b.name,
+        b.behospital_date AS behospitalDate,
+        b.leave_hospital_date AS leaveHospitalDate,
+        b.doctor_id AS doctorId,
+        b.doctor_name AS doctorName,
+        ifnull(c. level, '未评分') AS `level`,
+        c.score_res AS scoreRes,
+        c.gmt_create AS gradeTime,
+        a.cases_entry_ids as casesEntryIds
         FROM
-        med_behospital_info q,
-        med_click_info w,
-        med_qcresult_detail e
+        med_qcresult_click a,
+        med_behospital_info b,
+        med_qcresult_info c
         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
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND a.hospital_id =b.hospital_id
+        AND a.hospital_id =c.hospital_id
+        AND a.behospital_code =b.behospital_code
+        AND a.behospital_code =c.behospital_code
         <if test="hospitalId != null and hospitalId != ''">
-            AND q.hospital_id = #{hospitalId}
+            AND a.hospital_id = #{hospitalId}
         </if>
         <if test="deptId != null and deptId != ''">
-            and q.beh_dept_id = #{deptId}
+            and a.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},'%')
+            and a.dept_name = #{deptName}
         </if>
         <if test="patName != null and patName != ''">
-            and q.name like CONCAT('%',#{patName},'%')
+            and b.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}, '%' )
+            and b.behospital_code like CONCAT('%',#{behospitalCode},'%')
         </if>
         <if test="doctorId != null and doctorId != ''">
-            and q.doctor_id = #{doctor_id}
+            and b.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
+            and b.doctor_name like CONCAT('%',#{doctorName},'%')
         </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="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 test="level != null and level != ''">
+            and c.level = #{level}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ AND w.gmt_create >= #{startDate}]]>
+            <![CDATA[ AND a.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},'%')
+            <![CDATA[ AND a.gmt_create <= #{endDate}]]>
         </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
+        order by a.gmt_create
+        )t LEFT JOIN med_home_page n
+        ON t.hospitalId = n.hospital_id
+        AND t.behospitalCode = 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 checkStatus != ''">
-            and j.status = #{checkStatus}
-        </if>
-        <if test="chName != null and chName !=''">
-            and j.check_name like CONCAT('%',#{chName},'%')
-        </if>
-        <if test="chTimeStart != null and chTimeStart !=''">
-            <![CDATA[ and j.check_time >= #{chTimeStart}]]>
-        </if>
-        <if test="chTimeEnd != null and chTimeEnd !=''">
-            <![CDATA[ and j.check_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">