Browse Source

条目缺陷改善统计逻辑修改

chengyao 3 years atrás
parent
commit
a310498195

+ 15 - 0
pom.xml

@@ -217,6 +217,21 @@
             <artifactId>ojdbc6</artifactId>
             <version>11.2.0.3</version>
         </dependency>
+        <!--<dependency>-->
+            <!--<groupId>org.JoSQL</groupId>-->
+            <!--<artifactId>JoSQL</artifactId>-->
+            <!--<version>2.2</version>-->
+            <!--<scope>system</scope>-->
+            <!--<systemPath>${project.basedir}/src/main/resources/lib/josql-2.2.jar</systemPath>-->
+        <!--</dependency>-->
+
+        <!--<dependency>-->
+            <!--<groupId>net.sf.josql</groupId>-->
+            <!--<artifactId>gentlyweb-utils</artifactId>-->
+            <!--<version>1.5</version>-->
+            <!--<scope>system</scope>-->
+            <!--<systemPath>${project.basedir}/src/main/resources/lib/gentlyweb-utils-1.5.jar</systemPath>-->
+        <!--</dependency>-->
 
         <dependency>
             <groupId>com.microsoft.sqlserver</groupId>

+ 20 - 0
src/main/java/com/diagbot/dto/BehospitalCodeInfo.java

@@ -0,0 +1,20 @@
+package com.diagbot.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: cy
+ * @time: 2021/12/2 11:04
+ */
+@Data
+public class BehospitalCodeInfo {
+    /**
+     * 住院号
+     */
+    private String behospitalCode;
+
+    List<QcResultDetailInfo> qcResultDetailInfos;
+}

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

@@ -0,0 +1,26 @@
+package com.diagbot.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: cy
+ * @time: 2021/12/2 11:04
+ */
+@Data
+public class EntryDefectImprove {
+    /**
+     * 科室id
+     */
+    private String deptId;
+
+    /**
+     * 科室name
+     */
+    private String deptName;
+
+    List<BehospitalCodeInfo> behospitalCodeInfos;
+
+}

+ 5 - 7
src/main/java/com/diagbot/dto/GetEntryDefectImproveDTO.java

@@ -14,7 +14,7 @@ import java.text.DecimalFormat;
  * @time: 2020/9/4 14:59
  */
 @Data
-public class GetEntryDefectImproveDTO{
+public class GetEntryDefectImproveDTO {
     /**
      * 科室id
      */
@@ -50,30 +50,28 @@ public class GetEntryDefectImproveDTO{
     private String entryName;
 
 
-
-
     /**
      * 缺陷总数
      */
     @Excel(name = "总数量", width = 10d, orderNum = "4")
-    private Integer totalNum;
+    private Long totalNum = 0L;
 
     /**
      * 已改善数
      */
     @Excel(name = "已改善数量", width = 13d, orderNum = "5")
-    private Integer handleNum;
+    private Long handleNum = 0L;
 
     /**
      * 待改善数
      */
     @Excel(name = "待改善数量", width = 13d, orderNum = "6")
-    private Integer improveleNum;
+    private Long improveleNum = 0L;
 
     /**
      * 改善率
      */
     @Excel(name = "改善率", width = 10d, orderNum = "7")
-    private String handleStr;
+    private String handleStr = "0.00%";
 
 }

+ 35 - 0
src/main/java/com/diagbot/dto/GetEntryInfoDTO.java

@@ -0,0 +1,35 @@
+package com.diagbot.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: cy
+ * @time: 2021/12/2 11:04
+ */
+@Data
+public class GetEntryInfoDTO {
+    /**
+     * 模块id
+     */
+    private String casesId;
+
+    /**
+     * 模块名称
+     */
+    private String casesName;
+
+    /**
+     * 缺陷id
+     */
+    private String entryId;
+
+    /**
+     * 缺陷名称
+     */
+    private String entryName;
+
+}

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

@@ -0,0 +1,25 @@
+package com.diagbot.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: cy
+ * @time: 2021/12/2 11:04
+ */
+@Data
+public class QcResultDetailInfo {
+
+    /**
+     * 评分结果id
+     */
+    private Long qcresultInfoId;
+
+    /**
+     * 触发埋点病历质控缺陷id集
+     */
+    private String CasesEntryIds;
+
+}

+ 60 - 0
src/main/java/com/diagbot/entity/MedQcresultClick.java

@@ -0,0 +1,60 @@
+package com.diagbot.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author zhanghang
+ * @since 2021-12-02
+ */
+@Data
+public class MedQcresultClick implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 医院ID
+     */
+    private Long hospitalId;
+
+    /**
+     * 住院号
+     */
+    private String behospitalCode;
+
+    /**
+     * 科室id
+     */
+    private String deptId;
+
+    /**
+     * 科室name
+     */
+    private String deptName;
+
+    /**
+     * 评分结果id
+     */
+    private Long qcresultInfoId;
+
+    /**
+     * 触发埋点病历质控缺陷id集
+     */
+    private String CasesEntryIds;
+
+    /**
+     *  记录创建时间
+     */
+    private Date gmtCreate;
+}

+ 334 - 116
src/main/java/com/diagbot/facade/DataAnalysisFacade.java

@@ -1,19 +1,33 @@
 package com.diagbot.facade;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.diagbot.dto.BehospitalCodeInfo;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.DeptBaseDTO;
+import com.diagbot.dto.EntryDefectImprove;
 import com.diagbot.dto.ExportExcelBehospitalDTO;
 import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.GetEntryDefectImproveDTO;
+import com.diagbot.dto.GetEntryInfoDTO;
 import com.diagbot.dto.GetQcClickDTO;
 import com.diagbot.dto.GetQcClickInnerPageDTO;
+import com.diagbot.dto.HomePageNumDTO;
+import com.diagbot.dto.QcResultDetailInfo;
+import com.diagbot.entity.BehospitalInfo;
 import com.diagbot.entity.MedClickInfo;
+import com.diagbot.entity.MedQcresultClick;
+import com.diagbot.entity.QcresultDetail;
 import com.diagbot.entity.QcresultInfo;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
+import com.diagbot.service.MedQcresultClickService;
+import com.diagbot.service.QcresultDetailService;
 import com.diagbot.service.impl.MedClickInfoServiceImpl;
+import com.diagbot.service.impl.QcresultDetailServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.ExcelUtils;
@@ -36,7 +50,12 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 
@@ -54,6 +73,14 @@ public class DataAnalysisFacade {
     @Autowired
     private QcresultInfoFacade qcresultInfoFacade;
 
+    @Autowired
+    private QcresultDetailFacade qcresultDetailFacade;
+
+    @Autowired
+    private MedQcresultClickService medQcresultClickService;
+
+    @Autowired
+    private BehospitalInfoFacade behospitalInfoFacade;
 
     /**
      * @Description:医生质控信息次数
@@ -70,13 +97,47 @@ public class DataAnalysisFacade {
                 .eq(QcresultInfo::getBehospitalCode, medClickInfoVO.getBehospitalCode())
                 .eq(QcresultInfo::getIsDeleted, IsDeleteEnum.N.getKey())
                 .select(QcresultInfo::getId).one();
-        if(null == qcresultInfo || null == qcresultInfo.getId()
-        ){
+        if (null == qcresultInfo || null == qcresultInfo.getId()
+        ) {
             throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "内部参数异常");
         }
         medClickInfo.setQcresultInfoId(qcresultInfo.getId());
         medClickInfo.setGmtCreate(new Date());
-        return medClickInfoService.save(medClickInfo);
+        medClickInfoService.save(medClickInfo);
+        BehospitalInfo behospitalInfo = behospitalInfoFacade.lambdaQuery()
+                .eq(BehospitalInfo::getHospitalId, medClickInfoVO.getHospitalId())
+                .eq(BehospitalInfo::getBehospitalCode, medClickInfoVO.getBehospitalCode())
+                .eq(BehospitalInfo::getIsDeleted, IsDeleteEnum.N.getKey())
+                .one();
+        List<QcresultDetail> list = qcresultDetailFacade.lambdaQuery()
+                .eq(QcresultDetail::getHospitalId, medClickInfoVO.getHospitalId())
+                .eq(QcresultDetail::getBehospitalCode, medClickInfoVO.getBehospitalCode())
+                .eq(QcresultDetail::getQcresultInfoId, qcresultInfo.getId())
+                .eq(QcresultDetail::getIsDeleted, IsDeleteEnum.N.getKey()).list();
+        if (ListUtil.isNotEmpty(list)) {
+            StringBuilder sbFir = new StringBuilder();
+            for (QcresultDetail qcresultDetail : list) {
+                if (1 == qcresultDetail.getGradeType()) {
+                    if (null != qcresultDetail.getCasesEntryId()) {
+                        sbFir.append(qcresultDetail.getCasesEntryId() + "、");
+                    }
+                }
+            }
+            if (sbFir.length() > 0) {
+                sbFir = sbFir.deleteCharAt(sbFir.length() - 1);
+            }
+            MedQcresultClick medQcresultClick = new MedQcresultClick();
+            medQcresultClick.setHospitalId(medClickInfoVO.getHospitalId());
+            medQcresultClick.setBehospitalCode(medClickInfoVO.getBehospitalCode());
+            if (null != behospitalInfo) {
+                medQcresultClick.setDeptId(behospitalInfo.getBehDeptId());
+                medQcresultClick.setDeptName(behospitalInfo.getBehDeptName());
+            }
+            medQcresultClick.setQcresultInfoId(qcresultInfo.getId());
+            medQcresultClick.setCasesEntryIds(sbFir.toString());
+            medQcresultClickService.save(medQcresultClick);
+        }
+        return true;
     }
 
     public List<DeptBaseDTO> getQcClickDeptList(BasDeptInfoVO basDeptInfoVO) {
@@ -85,14 +146,14 @@ public class DataAnalysisFacade {
         List<MedClickInfo> deptList = medClickInfoService.lambdaQuery()
                 .eq(MedClickInfo::getHospitalId, hospitalId)
                 .eq(MedClickInfo::getIsDeleted, IsDeleteEnum.N.getKey())
-                .like(MedClickInfo::getDeptName,basDeptInfoVO.getInputStr())
+                .like(MedClickInfo::getDeptName, basDeptInfoVO.getInputStr())
                 .select(MedClickInfo::getDeptId, MedClickInfo::getDeptName)
                 .groupBy(MedClickInfo::getDeptId)
                 .groupBy(MedClickInfo::getDeptName)
                 .list();
-        if(ListUtil.isNotEmpty(deptList)){
+        if (ListUtil.isNotEmpty(deptList)) {
             for (MedClickInfo kfc : deptList) {
-                if(null == kfc){
+                if (null == kfc) {
                     return deptDTO;
                 }
                 DeptBaseDTO deptBaseDTO = new DeptBaseDTO();
@@ -103,6 +164,7 @@ public class DataAnalysisFacade {
         }
         return deptDTO;
     }
+
     public List<GetQcClickDTO> getQcClick(GetQcClickVO getQcClickVO) {
         clickPageSet(getQcClickVO);
         List<GetQcClickDTO> records = medClickInfoService.getBaseMapper().getQcClick(getQcClickVO);
@@ -129,7 +191,7 @@ public class DataAnalysisFacade {
         return records;
     }
 
-    public void getQcClickInnerPageByExport(HttpServletResponse response,GetQcClickInnerPageVO getQcClickInnerPageVO) {
+    public void getQcClickInnerPageByExport(HttpServletResponse response, GetQcClickInnerPageVO getQcClickInnerPageVO) {
         getQcClickInnerPageVO.setCurrent(1L);
         getQcClickInnerPageVO.setSize(Long.MAX_VALUE);
         getQcClickInnerPageVO.setSearchCount(false);
@@ -139,148 +201,304 @@ public class DataAnalysisFacade {
     }
 
     public IPage<GetEntryDefectImproveDTO> getEntryDefectImprove(GetEntryDefectImproveVO getEntryDefectImproveVO) {
-        entryDefectSet(getEntryDefectImproveVO);
-        IPage<GetEntryDefectImproveDTO> records = medClickInfoService.getBaseMapper().getEntryDefectImprove(getEntryDefectImproveVO);
-        return records;
-    }
-
-    public void getEntryDefectImproveByExport(HttpServletResponse response,GetEntryDefectImproveVO getEntryDefectImproveVO) {
+        long size = getEntryDefectImproveVO.getSize();
+        long current = getEntryDefectImproveVO.getCurrent();
         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);
-    }
+        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);
+            }
 
+            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());
+                        }
+                );
+                getEntryDefectImprove.setTotalNum(stringLongEntry.getValue());
+                if(improveleMap.containsKey(stringLongEntry.getKey())){
+                    getEntryDefectImprove.setImproveleNum(improveleMap.get(stringLongEntry.getKey()));
+                }
+                getEntryDefectImprove.setHandleNum(getEntryDefectImprove.getTotalNum()-getEntryDefectImprove.getImproveleNum());
+                getEntryDefectImproveDTO.add(getEntryDefectImprove);
+            }
+            System.out.println("getEntryDefectImproveDTO = " + getEntryDefectImproveDTO);
+        }
 
-    public IPage<BehospitalInfoDTO> getEntryDefectImproveInner(GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO) {
-        entryDefectInnerSet(getEntryDefectImproveInnerVO);
-        IPage<BehospitalInfoDTO> records = medClickInfoService.getBaseMapper().getEntryDefectImproveInner(getEntryDefectImproveInnerVO);
-        return records;
+
+        //导出操作
+        if(getEntryDefectImproveVO.getExportType()==1L){
+            size = getEntryDefectImproveDTO.size();
+        }
+        page.setSize(size);
+        page.setTotal(getEntryDefectImproveDTO.size());
+        page.setCurrent(current);
+        List<GetEntryDefectImproveDTO> getEntryDefectImproveDTOS = indexPaging(getEntryDefectImproveDTO, current, size);
+       String orderByAsc = null;
+       String orderByDesc = null;
+        for (Object order : getEntryDefectImproveVO.getOrders()) {
+            OrderItem e = (OrderItem) order;
+            String column = e.getColumn();
+            boolean asc = e.isAsc();
+           if(asc){
+               orderByAsc= column;
+           }else{
+               orderByDesc=column;
+           }
+
+        }
+      //  getEntryDefectImproveDTOS= sortList(getEntryDefectImproveDTOS, orderByAsc != null ? orderByAsc : orderByDesc);
+        page.setRecords(getEntryDefectImproveDTOS);
+        return new Page<>();
     }
+    public List<GetEntryDefectImproveDTO> indexPaging(List<GetEntryDefectImproveDTO> retRecords ,long current,long size){
+        //数据返回索引处理
+        if(0 == current){
+            current = 1;
+        }
+        int startIndex = ((int)current -1)*10;
+        int endIndex = startIndex + (int) size;
 
-    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);
+        if(retRecords.size()>1){
+            if( retRecords.size()-startIndex<(int)size){
+                retRecords = retRecords.subList(startIndex,retRecords.size());
+            }else{
+                retRecords = retRecords.subList(startIndex,endIndex );
+            }
+        }
+        return retRecords;
     }
 
     /**
-     * 增加全院记录
-     *
-     * @param records
+     * 内存数据排序 使用JoSQL
+   //  * @param list
+   //  * @param orderByString  a asc,b desc
      * @return
      */
-    public GetQcClickDTO getGlobleTitle(List<GetQcClickDTO> records) {
-        GetQcClickDTO item = new GetQcClickDTO();
-        if (ListUtil.isEmpty(records)) {
-            return null;
-        }
 
-        //缺陷总数
-        Integer clickTol = records
-                .stream()
-                .map(GetQcClickDTO::getClickNum)
-                .reduce(0, Integer::sum);
-        if (clickTol == null) {
-            clickTol = 0;
-        }
-        item.setDeptName("全院");
-        item.setClickNum(clickTol);
-        return item;
-    }
 
-    private void clickPageSet(GetQcClickVO getQcClickVO) {
-        //入参验证
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
-        Date startDate = null;
-        Date endDate = null;
+/*    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 {
-            startDate = simpleDateFormat.parse(getQcClickVO.getStartDate());
-            endDate = simpleDateFormat.parse(getQcClickVO.getEndDate());
-        } catch (ParseException e) {
+            query.parse(josql);
+            QueryResults results = query.execute(list);
+            list = results.getResults();
+        } catch (QueryParseException e) {
+            e.printStackTrace();
+        } catch (QueryExecutionException e) {
             e.printStackTrace();
         }
-        if (DateUtil.after(startDate,endDate)){
-            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
+        return list;
+    }*/
+
+    public Map getEntryTotalMap(List<QcResultDetailInfo> qcResultDetailInfos, Map<String, Long> totalMap) {
+        Set<String> totalSet = new HashSet<String>();
+        for (QcResultDetailInfo qcResultDetailInfo : qcResultDetailInfos) {
+            //质控下获取科室下总缺陷
+            String casesEntryIds = qcResultDetailInfo.getCasesEntryIds();
+            totalSet = getSetEntry(casesEntryIds, totalSet);
         }
-        getQcClickVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
+        totalMap = getSetEntryCount(totalMap, totalSet);
+        return totalMap;
     }
 
-    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();
+    public Map getEntryImproveleMap(QcResultDetailInfo qcResultDetailInfo, Map<String, Long> improveMap) {
+        Set<String> improveleSet = new HashSet<String>();
+        String casesEntryIds = qcResultDetailInfo.getCasesEntryIds();
+        improveleSet = getSetEntry(casesEntryIds, improveleSet);
+        improveMap = getSetEntryCount(improveMap, improveleSet);
+        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);
+                }
+            }
+            return set;
         }
-        if (DateUtil.after(startDate,endDate)){
-            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
+
+    public Map getSetEntryCount ( Map<String, Long> map, Set<String> sets){
+        for (String set : sets) {
+            if (map.containsKey(set)) {
+                long count = map.get(set) + 1l;
+                map.put(set, count);
+            } else {
+                map.put(set, 1L);
+            }
         }
-        getQcClickInnerPageVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
+        return map;
     }
 
-    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();
+        public void getEntryDefectImproveByExport (HttpServletResponse response, GetEntryDefectImproveVO
+        getEntryDefectImproveVO){
+            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);
         }
-        if (DateUtil.after(startDate,endDate)){
-            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
+
+
+        public IPage<BehospitalInfoDTO> getEntryDefectImproveInner (GetEntryDefectImproveInnerVO
+        getEntryDefectImproveInnerVO){
+            entryDefectInnerSet(getEntryDefectImproveInnerVO);
+            IPage<BehospitalInfoDTO> records = medClickInfoService.getBaseMapper().getEntryDefectImproveInner(getEntryDefectImproveInnerVO);
+            return records;
         }
-        getEntryDefectImproveVO.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());
+        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);
+        }
 
-        } catch (ParseException e) {
-            e.printStackTrace();
+        /**
+         * 增加全院记录
+         *
+         * @param records
+         * @return
+         */
+        public GetQcClickDTO getGlobleTitle (List < GetQcClickDTO > records) {
+            GetQcClickDTO item = new GetQcClickDTO();
+            if (ListUtil.isEmpty(records)) {
+                return null;
+            }
+
+            //缺陷总数
+            Integer clickTol = records
+                    .stream()
+                    .map(GetQcClickDTO::getClickNum)
+                    .reduce(0, Integer::sum);
+            if (clickTol == null) {
+                clickTol = 0;
+            }
+            item.setDeptName("全院");
+            item.setClickNum(clickTol);
+            return item;
         }
-        if (DateUtil.after(startDate,endDate)){
-            throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
+
+        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()));
         }
-        if(StringUtils.isNotBlank(getEntryDefectImproveInnerVO.getChTimeStart())
-                && StringUtils.isNotBlank(getEntryDefectImproveInnerVO.getChTimeEnd())
-        ){
-            Date chTimeStartDate = null;
-            Date chTimeEndDate = null;
+
+        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 entryDefectSet (GetEntryDefectImproveVO getEntryDefectImproveVO){
+            //入参验证
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+            Date startDate = null;
+            Date endDate = null;
             try {
-                chTimeStartDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getChTimeStart());
-                chTimeEndDate = simpleDateFormat.parse(getEntryDefectImproveInnerVO.getChTimeStart());
+                startDate = simpleDateFormat.parse(getEntryDefectImproveVO.getStartDate());
+                endDate = simpleDateFormat.parse(getEntryDefectImproveVO.getEndDate());
             } catch (ParseException e) {
                 e.printStackTrace();
             }
-            if (DateUtil.after(chTimeStartDate,chTimeEndDate)){
-                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "病历核查开始时间必须小于结束时间!");
+            if (DateUtil.after(startDate, endDate)) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "开始时间必须小于结束时间!");
+            }
+            getEntryDefectImproveVO.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());
+
+            } 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, "病历核查开始时间必须小于结束时间!");
+                }
             }
+            getEntryDefectImproveInnerVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
         }
-        getEntryDefectImproveInnerVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
     }
-}

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

@@ -2,9 +2,11 @@ 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.ExportExcelDTO;
 import com.diagbot.dto.GetEntryDefectImproveDTO;
 import com.diagbot.dto.GetEntryDefectImproveDeptDTO;
+import com.diagbot.dto.GetEntryInfoDTO;
 import com.diagbot.dto.GetQcClickDTO;
 import com.diagbot.dto.GetQcClickInnerPageDTO;
 import com.diagbot.entity.MedClickInfo;
@@ -28,7 +30,8 @@ import java.util.List;
 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 List<EntryDefectImprove> getEntryDefectImprove(GetEntryDefectImproveVO getEntryDefectImproveVO);
+    public List<GetEntryInfoDTO> getEntryInfo();
     public IPage<GetEntryDefectImproveDeptDTO> getEntryDefectImproveDept(GetEntryDefectImproveDeptVO getEntryDefectImproveDeptVO);
     public IPage<BehospitalInfoDTO> getEntryDefectImproveInner(GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO);
     public List<ExportExcelDTO> getDefectImproveInnerByExport(GetEntryDefectImproveInnerVO getEntryDefectImproveInnerVO);

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

@@ -0,0 +1,16 @@
+package com.diagbot.mapper;
+
+import com.diagbot.entity.MedQcresultClick;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author zhanghang
+ * @since 2021-12-02
+ */
+public interface MedQcresultClickMapper extends BaseMapper<MedQcresultClick> {
+
+}

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

@@ -0,0 +1,16 @@
+package com.diagbot.service;
+
+import com.diagbot.entity.MedQcresultClick;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author zhanghang
+ * @since 2021-12-02
+ */
+public interface MedQcresultClickService extends IService<MedQcresultClick> {
+
+}

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

@@ -0,0 +1,20 @@
+package com.diagbot.service.impl;
+
+import com.diagbot.entity.MedQcresultClick;
+import com.diagbot.mapper.MedQcresultClickMapper;
+import com.diagbot.service.MedQcresultClickService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author zhanghang
+ * @since 2021-12-02
+ */
+@Service
+public class MedQcresultClickServiceImpl extends ServiceImpl<MedQcresultClickMapper, MedQcresultClick> implements MedQcresultClickService {
+
+}

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

@@ -47,5 +47,9 @@ public class GetEntryDefectImproveVO extends Page {
 
     @NotNull(message = "请输入截止时间")
     private String endDate;
+    /**
+     * 0-不导出 1-导出
+     */
+    private Long exportType = 0L;
 
 }

+ 2 - 0
src/main/java/com/diagbot/web/DataAnalysisController.java

@@ -18,6 +18,7 @@ import com.diagbot.vo.MedClickInfoVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -43,6 +44,7 @@ public class DataAnalysisController {
     @ApiOperation(value = "记录医生点击质控病历信息[by:cy]")
     @PostMapping("/addMedClickInfo")
     @SysLogger("addMedClickInfo")
+    @Transactional
     public RespDTO<Boolean> addMedClickInfo(@RequestBody @Valid MedClickInfoVO medClickInfoVO) {
         return RespDTO.onSuc(dataAnalysisFacade.addMedClickInfo(medClickInfoVO));
     }

+ 49 - 196
src/main/resources/mapper/MedClickInfoMapper.xml

@@ -19,6 +19,21 @@
         <result column="modifier" property="modifier"/>
     </resultMap>
 
+
+    <resultMap id="entryDefectImproveMap" type="com.diagbot.dto.EntryDefectImprove">
+        <result column="deptId" property="deptId"/>
+        <result column="deptName" property="deptName"/>
+        <collection property="behospitalCodeInfos"
+                    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>
+    </resultMap>
+
+
     <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
         <result column="deptName" property="behDeptName"/>
         <result column="avgScore" property="avgScore"/>
@@ -42,11 +57,7 @@
     </resultMap>
 
     <select id="getQcClick" resultType="com.diagbot.dto.GetQcClickDTO">
-        select
-        t.deptId,
-        t.deptName,
-        t.clickNum
-        from(
+
         SELECT
         a.dept_id as deptId,
         a.dept_name as deptName,
@@ -73,23 +84,15 @@
         group by
         a.dept_id,
         a.dept_name
-        )t
         <if test="asc == 'clickNum'">
-            order by t.clickNum
+            order by clickNum
         </if>
         <if test="desc =='clickNum'">
-            order by t.clickNum desc
+            order by clickNum desc
         </if>
     </select>
 
     <select id="getQcClickInnerPage" resultType="com.diagbot.dto.GetQcClickInnerPageDTO">
-        select
-        t.deptId,
-        t.deptName,
-        t.doctorId,
-        t.doctorName,
-        t.clickNum
-        from(
         SELECT
         a.dept_id as deptId,
         a.dept_name as deptName,
@@ -126,202 +129,52 @@
         a.dept_name,
         a.doctor_id,
         a.doctor_name
-       )t
+        )t
     </select>
 
-    <select id="getEntryDefectImprove" resultType="com.diagbot.dto.GetEntryDefectImproveDTO">
-        SELECT
-        s.hospitalId,
-        s.deptId,
-        s.deptName,
-        s.casesId,
-        s.casesName,
-        s.entryName,
-        s.beforeCasesEntryId AS entryId,
-        count(s.beforeCasesEntryId) AS totalNum,
-        sum(s.improveleNum) AS improveleNum,
-        sum(s.handleNum) AS handleNum,
-        concat(ROUND((sum(s.handleNum)) / sum(s.beforeQcresultInfoId) * 100,2),'%') AS handleStr
-        FROM
-        (
-        SELECT
-        k.hospitalId,
-        k.deptId,
-        k.deptName,
-        k.behospitalCode,
-        k.lastQcresultInfoId,
-        k.beforeQcresultInfoId,
-        k.casesId,
-        k.beforeCasesEntryId,
-        i. NAME AS casesName,
-        o. NAME AS entryName,
-        y.cases_entry_id AS lastCasesEntryId,
-        CASE WHEN y.cases_entry_id IS NULL THEN 0 else 1 END AS improveleNum,
-        CASE WHEN y.cases_entry_id IS NULL THEN 1 else 0 END AS handleNum
-        FROM
-        (
-        SELECT
-        e.hospital_id AS hospitalId,
-        e.dept_id AS deptId,
-        e.dept_name AS deptName,
-        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.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 id="getEntryInfo" resultType="com.diagbot.dto.GetEntryInfoDTO">
         SELECT
-        q.hospital_id,
-        q.beh_dept_id AS dept_id,
-        q.beh_dept_name AS dept_name,
-        w.behospital_code,
-        max(w.qcresult_info_id) AS lastQcresultInfoId
+            a.id AS casesId,
+            a. NAME AS casesName,
+            b.id AS entryId,
+            b. NAME AS entryName
         FROM
-        med_behospital_info q,
-        med_click_info w
+            qc_cases a,
+            qc_cases_entry b
         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>
-        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>
-        GROUP BY
-        q.beh_dept_id,
-        q.beh_dept_name,
-        q.behospital_code
-        UNION
+            a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND a.id = b.cases_id
+    </select>
+
+    <select id="getEntryDefectImprove" resultMap="entryDefectImproveMap">
         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 deptId,
+        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_behospital_info q,
-        med_click_info w
+        med_qcresult_click a
         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
+        a.is_deleted = 'N'
         <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},'%')
+            and a.dept_name like CONCAT('%',#{deptName},'%')
         </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 test="startDate != null and startDate != ''">
+            <![CDATA[ AND a.gmt_create >= #{startDate}]]>
         </if>
-        <if test="entryName != null and entryName != ''">
-            and o.name like CONCAT('%',#{entryName},'%')
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[ AND a.gmt_create <= #{endDate}]]>
         </if>
-        ) s
-        GROUP BY
-        s.deptId,
-        s.deptName,
-        s.casesId,
-        s.beforeCasesEntryId
+         order by gmt_create
     </select>
 
     <select id="getEntryDefectImproveInner" resultType="com.diagbot.dto.BehospitalInfoDTO">
@@ -480,7 +333,7 @@
         (
         SELECT
         q.*,
-         max(w.qcresult_info_id) AS lastQcresultInfoId
+        max(w.qcresult_info_id) AS lastQcresultInfoId
         FROM
         med_behospital_info q,
         med_click_info w

+ 17 - 0
src/main/resources/mapper/MedQcresultClickMapper.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.MedQcresultClickMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.MedQcresultClick">
+        <result column="id" property="id" />
+        <result column="hospital_id" property="hospitalId" />
+        <result column="behospital_code" property="behospitalCode" />
+        <result column="dept_id" property="deptId" />
+        <result column="dept_name" property="deptName" />
+        <result column="qcresult_info_id" property="qcresultInfoId" />
+        <result column="cases_entry_ids" property="CasesEntryIds" />
+        <result column="gmt_create" property="gmtCreate" />
+    </resultMap>
+
+</mapper>