瀏覽代碼

Merge branch 'dev/20200426_2nd' into test

zhoutg 5 年之前
父節點
當前提交
8c7af383d1
共有 26 個文件被更改,包括 1217 次插入400 次删除
  1. 28 10
      doc/002.20200426第二版/qc_init.sql
  2. 145 14
      src/main/java/com/diagbot/aggregate/AverageStatisticsAggregate.java
  3. 164 0
      src/main/java/com/diagbot/aggregate/MrStatisticsAggregate.java
  4. 170 48
      src/main/java/com/diagbot/aggregate/ResultStatisticsAggregate.java
  5. 6 2
      src/main/java/com/diagbot/dto/AverageStatisticsDTO.java
  6. 4 14
      src/main/java/com/diagbot/dto/ResultDetailDTO.java
  7. 23 0
      src/main/java/com/diagbot/dto/QcResultPercentDTO.java
  8. 0 17
      src/main/java/com/diagbot/dto/ResultStatisticsDTO.java
  9. 15 244
      src/main/java/com/diagbot/facade/ConsoleFacade.java
  10. 94 0
      src/main/java/com/diagbot/facade/FilterFacade.java
  11. 22 5
      src/main/java/com/diagbot/mapper/BehospitalInfoMapper.java
  12. 8 0
      src/main/java/com/diagbot/mapper/QcCasesMapper.java
  13. 47 1
      src/main/java/com/diagbot/mapper/QcresultInfoMapper.java
  14. 24 6
      src/main/java/com/diagbot/service/BehospitalInfoService.java
  15. 9 1
      src/main/java/com/diagbot/service/QcCasesService.java
  16. 48 1
      src/main/java/com/diagbot/service/QcresultInfoService.java
  17. 30 6
      src/main/java/com/diagbot/service/impl/BehospitalInfoServiceImpl.java
  18. 11 0
      src/main/java/com/diagbot/service/impl/QcCasesServiceImpl.java
  19. 63 1
      src/main/java/com/diagbot/service/impl/QcresultInfoServiceImpl.java
  20. 23 0
      src/main/java/com/diagbot/vo/HomePageFilterVO.java
  21. 1 1
      src/main/java/com/diagbot/web/ConsoleController.java
  22. 60 4
      src/main/resources/mapper/BehospitalInfoMapper.xml
  23. 16 10
      src/main/resources/mapper/HomePageMapper.xml
  24. 18 0
      src/main/resources/mapper/QcCasesMapper.xml
  25. 4 14
      src/main/resources/mapper/QcQuestionInfoMapper.xml
  26. 184 1
      src/main/resources/mapper/QcresultInfoMapper.xml

+ 28 - 10
doc/002.20200426第二版/qc_init.sql

@@ -1,7 +1,5 @@
 use `qc`;
 
-ALTER TABLE `med_behospital_info` MODIFY COLUMN `doctor_id` varchar(16) DEFAULT NULL COMMENT '医生ID' AFTER `diagnose`;
-
 ALTER TABLE `sys_menu` ADD  COLUMN `show_status` int(11) NOT NULL DEFAULT '0' COMMENT '是否在右侧菜单显示(0:不显示,1:显示)' AFTER `code`;
 ALTER TABLE `sys_menu` ADD  COLUMN `maintain_status` int(11) NOT NULL DEFAULT '0' COMMENT '是否可以维护(0:不可维护,1:可以维护)' AFTER `show_status`;
 
@@ -39,7 +37,6 @@ CREATE TABLE `qc_question_info` (
   `add_line` tinyint(4) DEFAULT '0' COMMENT '换行(0:不换行,1:换行)',
   `bold` tinyint(4) DEFAULT '0' COMMENT '换行(0:不换行,1:加粗)',
   `position` tinyint(4) DEFAULT '0' COMMENT '显示位置(1:靠右显示)',
-  `cases_entry_ids` varchar(1000) NOT NULL DEFAULT '' COMMENT '质控条目id列表',
   `remark` varchar(300) DEFAULT NULL COMMENT '备注',
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='标签基础表';
@@ -64,6 +61,27 @@ CREATE TABLE `qc_question_mapping` (
   KEY `son_question` (`son_question`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='标签映射表';
 
+
+-- ----------------------------
+-- Table structure for qc_question_entry
+-- ----------------------------
+DROP TABLE IF EXISTS `qc_question_entry`;
+CREATE TABLE `qc_question_entry` (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `is_deleted` char(1) NOT NULL DEFAULT 'N' COMMENT '是否删除,N:未删除,Y:删除',
+  `gmt_create` datetime NOT NULL DEFAULT '1970-01-01 12:00:00' COMMENT '记录创建时间',
+  `gmt_modified` datetime NOT NULL DEFAULT '1970-01-01 12:00:00' COMMENT '记录修改时间,如果时间是1970年则表示纪录未修改',
+  `creator` varchar(20) NOT NULL DEFAULT '0' COMMENT '创建人,0表示无创建人值',
+  `modifier` varchar(20) NOT NULL DEFAULT '0' COMMENT '修改人,如果为0则表示纪录未修改',
+  `question_id` bigint(20) DEFAULT NULL COMMENT 'question_id',
+  `cases_entry_id` bigint(20) DEFAULT NULL COMMENT 'cases_entry_id',
+  `order_no` int(11) NOT NULL DEFAULT '0' COMMENT '排序号',
+  `remark` varchar(300) DEFAULT NULL COMMENT '备注',
+  PRIMARY KEY (`id`),
+  KEY `question_id` (`question_id`),
+  KEY `cases_entry_id` (`cases_entry_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='标签条目映射表';
+
 -- ----------------------------
 -- Table structure for qc_module_info
 -- ----------------------------
@@ -81,7 +99,7 @@ CREATE TABLE `qc_module_info` (
   `record_module_id` bigint(20) DEFAULT NULL COMMENT 'med_record_module的id',
   `remark` varchar(300) DEFAULT NULL COMMENT '备注',
   PRIMARY KEY (`id`),
-  UNIQUE KEY `INDEX_1` (`hospital_id`,`record_module_id`)
+  KEY `INDEX_1` (`hospital_id`,`record_module_id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='模型表';
 
 -- ----------------------------
@@ -235,7 +253,7 @@ CREATE TABLE `sys_permission` (
 INSERT INTO `sys_permission` VALUES ('1', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '获取用户、机构、菜单信息', 'FUNC000001', '/sys/user/getUserOrgMenu', 'ALL', '基础功能-获取用户、机构、菜单信息', null);
 INSERT INTO `sys_permission` VALUES ('2', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '修改密码', 'FUNC000002', '/sys/user/midifyPassword', 'ALL', '基础功能-修改密码', null);
 INSERT INTO `sys_permission` VALUES ('3', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '获取医院模块数据信息', 'FUNC000003', '/qc/cases/getQcCases', 'ALL', '用户-基础数据维护-获取医院模块数据信息', null);
-INSERT INTO `sys_permission` VALUES ('4', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '批量更新模块数据', 'FUNC000004', '/qc/cases/saveQcCases', 'ALL', '用户-基础数据维护-批量更新模块数据', null);
+INSERT INTO `sys_permission` VALUES ('4', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '更新医院模块数据', 'FUNC000004', '/qc/cases/saveQcCases', 'ALL', '用户-基础数据维护-批量更新模块数据', null);
 INSERT INTO `sys_permission` VALUES ('5', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '分页查询', 'FUNC000005', '/qc/behospitalInfo/page', 'ALL', '用户-质控评分-分页', null);
 INSERT INTO `sys_permission` VALUES ('6', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '分页获取医院条目数据信息', 'FUNC000006', '/qc/casesEntryHospital/getQcCasesEntryAll', 'ALL', '用户-条目数据维护-分页获取医院条目数据信息', null);
 INSERT INTO `sys_permission` VALUES ('7', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '修改医院条目数据信息', 'FUNC000007', '/qc/casesEntryHospital/updataQcCasesEntry', 'ALL', '用户-条目数据维护-修改医院条目数据信息', null);
@@ -423,11 +441,11 @@ INSERT INTO `sys_role_permission` VALUES ('54', 'N', '1970-01-01 12:00:00', '197
 INSERT INTO `sys_role_permission` VALUES ('55', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '37', '用户-质控评分(科室)-修改质控条目');
 INSERT INTO `sys_role_permission` VALUES ('56', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '38', '用户-质控评分(科室)-获取详情');
 INSERT INTO `sys_role_permission` VALUES ('57', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '39', '用户-质控评分(个人)-获取病历质控一览下用户科室下拉列表信息');
-INSERT INTO `sys_role_permission` VALUES ('58', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '40', '用户-质控评分(科室)-评分');
-INSERT INTO `sys_role_permission` VALUES ('59', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '41', '用户-质控评分(科室)-新增质控条目');
-INSERT INTO `sys_role_permission` VALUES ('60', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '42', '用户-质控评分(科室)-删除质控条目');
-INSERT INTO `sys_role_permission` VALUES ('61', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '43', '用户-质控评分(科室)-修改质控条目');
-INSERT INTO `sys_role_permission` VALUES ('62', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '44', '用户-质控评分(科室)-获取详情');
+INSERT INTO `sys_role_permission` VALUES ('58', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '40', '用户-质控评分(个人)-评分');
+INSERT INTO `sys_role_permission` VALUES ('59', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '41', '用户-质控评分(个人)-新增质控条目');
+INSERT INTO `sys_role_permission` VALUES ('60', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '42', '用户-质控评分(个人)-删除质控条目');
+INSERT INTO `sys_role_permission` VALUES ('61', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '43', '用户-质控评分(个人)-修改质控条目');
+INSERT INTO `sys_role_permission` VALUES ('62', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '-1', '44', '用户-质控评分(个人)-获取详情');
 
 
 

+ 145 - 14
src/main/java/com/diagbot/aggregate/AverageStatisticsAggregate.java

@@ -1,8 +1,12 @@
 package com.diagbot.aggregate;
 
 import com.diagbot.dto.AverageStatisticsDTO;
-import com.diagbot.facade.ConsoleFacade;
+import com.diagbot.facade.FilterFacade;
 import com.diagbot.facade.HomePageFacade;
+import com.diagbot.facade.QcresultInfoFacade;
+import com.diagbot.util.BeanUtil;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.vo.FilterVO;
 import com.google.common.collect.Lists;
@@ -12,12 +16,15 @@ import io.github.lvyahui8.spring.annotation.InvokeParameter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.Date;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
 /**
- * @Description:
+ * @Description:平均值相关统计
  * @Author:zhaops
  * @time: 2020/4/23 14:11
  */
@@ -26,20 +33,29 @@ public class AverageStatisticsAggregate {
     @Autowired
     private HomePageFacade homePageFacade;
     @Autowired
-    private ConsoleFacade consoleFacade;
+    private QcresultInfoFacade qcresultInfoFacade;
+    @Autowired
+    private FilterFacade filterFacade;
 
     @DataProvider("setAllAverage")
     public Map<String, Object> setAllResult(
             @InvokeParameter("filterVO") FilterVO filterVO,
             @DataConsumer("getAverageDayNum") List<AverageStatisticsDTO> averageDayNumList,
-            @DataConsumer("getAverageFee") List<AverageStatisticsDTO> averageFeeList) {
+            @DataConsumer("getAverageFee") List<AverageStatisticsDTO> averageFeeList,
+            @DataConsumer("getAverageScore") List<AverageStatisticsDTO> averageScoreList) {
         Map<String, Object> retMap = new LinkedHashMap<>();
+        retMap.put("平均住院日", Lists.newLinkedList());
+        retMap.put("平均住院费用", Lists.newLinkedList());
+        retMap.put("各科室质控平均分", Lists.newLinkedList());
         if (ListUtil.isNotEmpty(averageDayNumList)) {
             retMap.put("平均住院日", averageDayNumList);
         }
         if (ListUtil.isNotEmpty(averageFeeList)) {
             retMap.put("平均住院费用", averageFeeList);
         }
+        if (ListUtil.isNotEmpty(averageScoreList)) {
+            retMap.put("各科室质控平均分", averageScoreList);
+        }
         return retMap;
     }
 
@@ -53,13 +69,43 @@ public class AverageStatisticsAggregate {
     public List<AverageStatisticsDTO> getAverageDayNum(@InvokeParameter("filterVO") FilterVO filterVO) {
         List<AverageStatisticsDTO> retAverageDayNumList = Lists.newLinkedList();
         List<AverageStatisticsDTO> averageDayNumList = homePageFacade.getAverageDayNum(filterVO);
-        if (filterVO.getLimitCount() == null || filterVO.getLimitCount().equals(0)) {
-            filterVO.setLimitCount(10);
+
+        //上月、去年
+        String startDate = filterFacade.getLastStartDateStr(filterVO.getType());
+        String endDate = filterFacade.getLastEndDateStr(filterVO.getType());
+        filterVO.setStartDate(startDate);
+        filterVO.setEndDate(endDate);
+        List<AverageStatisticsDTO> lastAverageDayNumList = homePageFacade.getAverageDayNum(filterVO);
+        Map<String, Double> lastMap
+                = EntityUtil.makeMapWithKeyValue(lastAverageDayNumList, "name", "averageValue");
+
+        //去年本月
+        if (filterVO.getType().equals(1)) {
+            Date date = new Date();
+            String year = DateUtil.getYear(date);
+            startDate = filterFacade.getStartDateStr(filterVO.getType(), Integer.valueOf(year) - 1);
+            endDate = filterFacade.getEndDateStr(filterVO.getType(), Integer.valueOf(year) - 1);
+            filterVO.setStartDate(startDate);
+            filterVO.setEndDate(endDate);
         }
-        Integer limitCount = filterVO.getLimitCount();
-        //平均住院日
-        if (ListUtil.isNotEmpty(averageDayNumList)) {
-            retAverageDayNumList = consoleFacade.getLimitAverageList(averageDayNumList, limitCount);
+        //按年统计,同比环比相同
+        List<AverageStatisticsDTO> lastYearAverageDayNumList = homePageFacade.getAverageDayNum(filterVO);
+
+        Map<String, Double> lastYearMap
+                = EntityUtil.makeMapWithKeyValue(lastYearAverageDayNumList, "name", "averageValue");
+
+        averageDayNumList.forEach(item -> {
+            if (lastMap.containsKey(item.getName())) {
+                item.setLastAverageValue(lastMap.get(item.getName()));
+            }
+            if (lastYearMap.containsKey(item.getName())) {
+                item.setLastYearAverageValue(lastYearMap.get(item.getName()));
+            }
+        });
+        if (averageDayNumList.size() <= 10) {
+            retAverageDayNumList = averageDayNumList;
+        } else {
+            retAverageDayNumList = averageDayNumList.subList(0, 10);
         }
         return retAverageDayNumList;
     }
@@ -74,14 +120,99 @@ public class AverageStatisticsAggregate {
     public List<AverageStatisticsDTO> getAverageFee(@InvokeParameter("filterVO") FilterVO filterVO) {
         List<AverageStatisticsDTO> retAverageFeeList = Lists.newLinkedList();
         List<AverageStatisticsDTO> averageFeeList = homePageFacade.getAverageFee(filterVO);
+        //上月、去年
+        String startDate = filterFacade.getLastStartDateStr(filterVO.getType());
+        String endDate = filterFacade.getLastEndDateStr(filterVO.getType());
+        filterVO.setStartDate(startDate);
+        filterVO.setEndDate(endDate);
+        List<AverageStatisticsDTO> lastAverageFeeList = homePageFacade.getAverageDayNum(filterVO);
+        Map<String, Double> lastMap
+                = EntityUtil.makeMapWithKeyValue(lastAverageFeeList, "name", "averageValue");
+
+        //去年本月
+        if (filterVO.getType().equals(1)) {
+            Date date = new Date();
+            String year = DateUtil.getYear(date);
+            startDate = filterFacade.getStartDateStr(filterVO.getType(), Integer.valueOf(year) - 1);
+            endDate = filterFacade.getEndDateStr(filterVO.getType(), Integer.valueOf(year) - 1);
+            filterVO.setStartDate(startDate);
+            filterVO.setEndDate(endDate);
+        }
+        //按年统计,同比环比相同
+        List<AverageStatisticsDTO> lastYearAverageFeeList = homePageFacade.getAverageDayNum(filterVO);
+
+        Map<String, Double> lastYearMap
+                = EntityUtil.makeMapWithKeyValue(lastYearAverageFeeList, "name", "averageValue");
+
+        averageFeeList.forEach(item -> {
+            if (lastMap.containsKey(item.getName())) {
+                item.setLastAverageValue(lastMap.get(item.getName()));
+            }
+            if (lastYearMap.containsKey(item.getName())) {
+                item.setLastYearAverageValue(lastYearMap.get(item.getName()));
+            }
+        });
+        if (averageFeeList.size() <= 10) {
+            retAverageFeeList = averageFeeList;
+        } else {
+            retAverageFeeList = averageFeeList.subList(0, 10);
+        }
+        return retAverageFeeList;
+    }
+
+    /**
+     * 质控平均分按科室统计
+     *
+     * @param filterVO
+     * @return
+     */
+    @DataProvider("getAverageScore")
+    public List<AverageStatisticsDTO> getAverageScore(@InvokeParameter("filterVO") FilterVO filterVO) {
+        List<AverageStatisticsDTO> retAverageScoreList = Lists.newLinkedList();
+        List<AverageStatisticsDTO> averageScoreList = qcresultInfoFacade.getAverageScoreByDept(filterVO);
         if (filterVO.getLimitCount() == null || filterVO.getLimitCount().equals(0)) {
             filterVO.setLimitCount(10);
         }
         Integer limitCount = filterVO.getLimitCount();
-        //平均住院费用
-        if (ListUtil.isNotEmpty(averageFeeList)) {
-            retAverageFeeList = consoleFacade.getLimitAverageList(averageFeeList, limitCount);
+        //质控平均分
+        if (ListUtil.isNotEmpty(averageScoreList)) {
+            retAverageScoreList = getLimitAverageList(averageScoreList, limitCount);
         }
-        return retAverageFeeList;
+        return retAverageScoreList;
+    }
+
+    /**
+     * 根据限制数量重组统计结果
+     *
+     * @param averageList
+     * @param limitCount
+     * @return
+     */
+    public List<AverageStatisticsDTO> getLimitAverageList(List<AverageStatisticsDTO> averageList, Integer limitCount) {
+        List<AverageStatisticsDTO> retAverageList = Lists.newLinkedList();
+        if (averageList.size() <= limitCount) {
+            retAverageList = BeanUtil.listCopyTo(averageList, AverageStatisticsDTO.class);
+        } else {
+            retAverageList = averageList.subList(0, limitCount - 1);
+            List<AverageStatisticsDTO> otherList = averageList.subList(limitCount - 1, averageList.size());
+            Double totleValue = otherList
+                    .stream()
+                    .map(i -> BigDecimal.valueOf(i.getTotleValue()))
+                    .reduce(BigDecimal.ZERO, BigDecimal::add).doubleValue();
+            Integer num = otherList
+                    .stream()
+                    .map(AverageStatisticsDTO::getNum)
+                    .reduce(0, Integer::sum);
+            Double averageValue = BigDecimal.valueOf(totleValue)
+                    .divide(BigDecimal.valueOf(num), 2, RoundingMode.HALF_UP)
+                    .doubleValue();
+            AverageStatisticsDTO retAverageStatistics = new AverageStatisticsDTO();
+            retAverageStatistics.setName("其他");
+            retAverageStatistics.setNum(num);
+            retAverageStatistics.setAverageValue(averageValue);
+            retAverageStatistics.setTotleValue(totleValue);
+            retAverageList.add(retAverageStatistics);
+        }
+        return retAverageList;
     }
 }

+ 164 - 0
src/main/java/com/diagbot/aggregate/MrStatisticsAggregate.java

@@ -0,0 +1,164 @@
+package com.diagbot.aggregate;
+
+import com.diagbot.dto.NumDTO;
+import com.diagbot.dto.QcResultPercentDTO;
+import com.diagbot.facade.BehospitalInfoFacade;
+import com.diagbot.facade.QcresultInfoFacade;
+import com.diagbot.util.BeanUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.vo.FilterVO;
+import com.diagbot.vo.HomePageFilterVO;
+import com.diagbot.vo.QcresultFilterVO;
+import com.google.common.collect.Lists;
+import io.github.lvyahui8.spring.annotation.DataConsumer;
+import io.github.lvyahui8.spring.annotation.DataProvider;
+import io.github.lvyahui8.spring.annotation.InvokeParameter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.DecimalFormat;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @Description:病历相关统计
+ * @Author:zhaops
+ * @time: 2020/5/6 17:21
+ */
+@Component
+public class MrStatisticsAggregate {
+
+    @Autowired
+    private BehospitalInfoFacade behospitalInfoFacade;
+    @Autowired
+    private QcresultInfoFacade qcresultInfoFacade;
+
+    @DataProvider("setAllMr")
+    public Map<String, Object> setAllDept(
+            @InvokeParameter("filterVO") FilterVO filterVO,
+            @DataConsumer("getLevelResultDept") List<QcResultPercentDTO> levelResults,
+            @DataConsumer("leaveHosCount") Map<String, Object> leaveHosMap,
+            @DataConsumer("mrCount") List<NumDTO> mrCountList) {
+        Map<String, Object> retMap = new LinkedHashMap<>();
+        retMap.put("各科室甲级病历占比", Lists.newLinkedList());
+        retMap.put("病历数统计", Lists.newLinkedList());
+        retMap.put("出院人数统计", new LinkedHashMap<>());
+        if (ListUtil.isNotEmpty(levelResults)) {
+            retMap.put("各科室甲级病历占比", levelResults);
+        }
+        if (leaveHosMap != null) {
+            retMap.put("出院人数统计", leaveHosMap);
+        }
+        if (ListUtil.isNotEmpty(mrCountList)) {
+            retMap.put("病历数统计", mrCountList);
+        }
+        return retMap;
+    }
+
+    /**
+     * 各科室甲级病历占比
+     *
+     * @param filterVO
+     * @return
+     */
+    @DataProvider("getLevelResultDept")
+    public List<QcResultPercentDTO> getLevelResultDept(@InvokeParameter("filterVO") FilterVO filterVO) {
+        List<QcResultPercentDTO> qcResultPercentList = qcresultInfoFacade.levelPercentGroupByDept(filterVO);
+        qcResultPercentList = qcResultPercentList.stream().limit(10).collect(Collectors.toList());
+        return qcResultPercentList;
+    }
+
+    /**
+     * 出院人数统计
+     *
+     * @param filterVO
+     * @return
+     */
+    @DataProvider("leaveHosCount")
+    public Map<String, Object> leaveHosCount(@InvokeParameter("filterVO") FilterVO filterVO) {
+        Map<String, Object> retMap = new LinkedHashMap<>();
+        retMap.put("总人数", 0);
+        retMap.put("死亡人数", 0);
+        retMap.put("新生儿人数", 0);
+        retMap.put("手术病人数", 0);
+        HomePageFilterVO homePageFilterVO = new HomePageFilterVO();
+        BeanUtil.copyProperties(filterVO, homePageFilterVO);
+        Integer totleNum = behospitalInfoFacade.homePageCount(homePageFilterVO);
+        homePageFilterVO.setDeath(1);
+        Integer deathNum = behospitalInfoFacade.homePageCount(homePageFilterVO);
+        homePageFilterVO.setDeath(null);
+        homePageFilterVO.setNewBorn(1);
+        Integer newBornNum = behospitalInfoFacade.homePageCount(homePageFilterVO);
+        Integer operationNum = behospitalInfoFacade.homePageCountForOperation(filterVO);
+        retMap.put("总人数", totleNum);
+        retMap.put("死亡人数", deathNum);
+        retMap.put("新生儿人数", newBornNum);
+        retMap.put("手术病人数", operationNum);
+        return retMap;
+    }
+
+    /**
+     * 质控病历统计
+     *
+     * @return
+     */
+    @DataProvider("mrCount")
+    public List<NumDTO> mrCount(@InvokeParameter("filterVO") FilterVO filterVO) {
+        DecimalFormat df = new DecimalFormat("#0.00");
+        List<NumDTO> retList = Lists.newLinkedList();
+        QcresultFilterVO qcresultFilterVO = new QcresultFilterVO();
+        BeanUtil.copyProperties(filterVO, qcresultFilterVO);
+
+        int totleNum = qcresultInfoFacade.resultCount(qcresultFilterVO);
+        qcresultFilterVO.setLevel("甲");
+        int firstLevelNum = qcresultInfoFacade.resultCount(qcresultFilterVO);
+        qcresultFilterVO.setLevel("乙");
+        int secondLevelNum = qcresultInfoFacade.resultCount(qcresultFilterVO);
+        qcresultFilterVO.setLevel("丙");
+        int thirdLevelNum = qcresultInfoFacade.resultCount(qcresultFilterVO);
+        NumDTO totleNumDTO = new NumDTO();
+        totleNumDTO.setName("累计质控病历数");
+        totleNumDTO.setTotleNum(totleNum);
+        totleNumDTO.setNum(totleNum);
+        NumDTO firstLevelNumDTO = new NumDTO();
+        firstLevelNumDTO.setName("甲级病历");
+        firstLevelNumDTO.setNum(firstLevelNum);
+        firstLevelNumDTO.setTotleNum(totleNum);
+        Double firstPercent = BigDecimal.valueOf(firstLevelNum)
+                .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
+                .doubleValue();
+        String firstPercentStr = df.format(BigDecimal.valueOf(firstPercent).multiply(BigDecimal.valueOf(100))) + "%";
+        firstLevelNumDTO.setPercent(firstPercent);
+        firstLevelNumDTO.setPercentStr(firstPercentStr);
+        NumDTO secondLevelNumDTO = new NumDTO();
+        secondLevelNumDTO.setName("乙级病历");
+        secondLevelNumDTO.setNum(secondLevelNum);
+        secondLevelNumDTO.setTotleNum(totleNum);
+        Double secondPercent = BigDecimal.valueOf(secondLevelNum)
+                .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
+                .doubleValue();
+        String secondPercentStr = df.format(BigDecimal.valueOf(secondPercent).multiply(BigDecimal.valueOf(100))) + "%";
+        secondLevelNumDTO.setPercent(secondPercent);
+        secondLevelNumDTO.setPercentStr(secondPercentStr);
+        NumDTO thirdLevelNumDTO = new NumDTO();
+        thirdLevelNumDTO.setName("丙级病历");
+        thirdLevelNumDTO.setNum(thirdLevelNum);
+        thirdLevelNumDTO.setTotleNum(totleNum);
+        Double thirdPercent = BigDecimal.valueOf(1)
+                .subtract(BigDecimal.valueOf(firstPercent))
+                .subtract(BigDecimal.valueOf(secondPercent))
+                .doubleValue();
+        String thirdPercentStr = df.format(BigDecimal.valueOf(thirdPercent).multiply(BigDecimal.valueOf(100))) + "%";
+        thirdLevelNumDTO.setPercent(thirdPercent);
+        thirdLevelNumDTO.setPercentStr(thirdPercentStr);
+        retList.add(totleNumDTO);
+        retList.add(firstLevelNumDTO);
+        retList.add(secondLevelNumDTO);
+        retList.add(thirdLevelNumDTO);
+        return retList;
+    }
+}

+ 170 - 48
src/main/java/com/diagbot/aggregate/ResultStatisticsAggregate.java

@@ -1,10 +1,14 @@
 package com.diagbot.aggregate;
 
-import com.diagbot.dto.ResultDetailDTO;
+import com.diagbot.dto.NumDTO;
 import com.diagbot.facade.BehospitalInfoFacade;
+import com.diagbot.facade.QcCasesFacade;
+import com.diagbot.facade.QcresultInfoFacade;
 import com.diagbot.util.BeanUtil;
+import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.vo.FilterVO;
+import com.diagbot.vo.QcresultFilterVO;
 import com.google.common.collect.Lists;
 import io.github.lvyahui8.spring.annotation.DataConsumer;
 import io.github.lvyahui8.spring.annotation.DataProvider;
@@ -15,110 +19,228 @@ import org.springframework.stereotype.Component;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.DecimalFormat;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
- * @Description:
+ * @Description:缺陷相关统计
  * @author: gaodm
  * @time: 2020/4/22 18:09
  */
 @Component
 public class ResultStatisticsAggregate {
+    @Autowired
+    private QcresultInfoFacade qcresultInfoFacade;
+    @Autowired
+    private QcCasesFacade qcCasesFacade;
     @Autowired
     private BehospitalInfoFacade behospitalInfoFacade;
 
     @DataProvider("setAllResult")
     public Map<String, Object> setAllResult(
             @InvokeParameter("filterVO") FilterVO filterVO,
-            @DataConsumer("getResult") List<ResultDetailDTO> results,
-            @DataConsumer("getResultDept") List<ResultDetailDTO> results2) {
+            @DataConsumer("entryByDept") List<NumDTO> deptList,
+            @DataConsumer("entryCountGroupByEntry") List<NumDTO> entryList,
+            @DataConsumer("entryCountGroupByCase") List<NumDTO> caseList) {
         Map<String, Object> retMap = new LinkedHashMap<>();
-        if (ListUtil.isNotEmpty(results)) {
-            retMap.put("缺陷排行列表", results);
+        retMap.put("各科室缺陷占比", Lists.newLinkedList());
+        retMap.put("各模块缺陷占比排行", Lists.newLinkedList());
+        retMap.put("条目缺陷占比", Lists.newLinkedList());
+        if (ListUtil.isNotEmpty(deptList)) {
+            retMap.put("各科室缺陷占比", deptList);
         }
-        if (ListUtil.isNotEmpty(results2)) {
-            retMap.put("各科室缺陷占比", results2);
+        if (ListUtil.isNotEmpty(caseList)) {
+            retMap.put("各模块缺陷占比排行", caseList);
         }
+        if (ListUtil.isNotEmpty(entryList)) {
+            retMap.put("条目缺陷占比", entryList);
+        }
+
         return retMap;
     }
 
-    @DataProvider("getResult")
-    public List<ResultDetailDTO> getResult(@InvokeParameter("filterVO") FilterVO filterVO) {
-        List<ResultDetailDTO> results = behospitalInfoFacade.resultStatistics2(filterVO);
+    /**
+     * 各模块缺陷占比排行
+     *
+     * @param filterVO
+     * @return
+     */
+    @DataProvider("entryCountGroupByCase")
+    public List<NumDTO> entryCountGroupByCase(@InvokeParameter("filterVO") FilterVO filterVO) {
+        QcresultFilterVO qcresultFilterVO = new QcresultFilterVO();
+        BeanUtil.copyProperties(filterVO, qcresultFilterVO);
+        int mrNum = qcresultInfoFacade.resultCount(qcresultFilterVO);
+        List<NumDTO> qcEntryNumList = qcresultInfoFacade.entryCountGroupByCase(filterVO);
+        List<NumDTO> standardEntryNumList = qcCasesFacade.entryGroupByCase();
+        if (ListUtil.isEmpty(qcEntryNumList)) {
+            standardEntryNumList.forEach(entryNum -> {
+                Integer totleNum = entryNum.getNum() * mrNum;
+                entryNum.setPercent(0d);
+                entryNum.setPercentStr("0%");
+                entryNum.setTotleNum(totleNum);
+            });
+        } else {
+            Map<Long, Integer> qcEntryNumMap
+                    = EntityUtil.makeMapWithKeyValue(qcEntryNumList, "id", "num");
+            if (ListUtil.isNotEmpty(standardEntryNumList)) {
+                standardEntryNumList.forEach(entryNum -> {
+                    Integer totleNum = entryNum.getNum() * mrNum;
+                    if (qcEntryNumMap.containsKey(entryNum.getId())) {
+                        Double percent = BigDecimal.valueOf(entryNum.getNum())
+                                .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
+                                .doubleValue();
+                        DecimalFormat df = new DecimalFormat("#0.00");
+                        String percentStr
+                                = df.format(BigDecimal.valueOf(percent).multiply(BigDecimal.valueOf(100))) + "%";
+                        entryNum.setTotleNum(totleNum);
+                        entryNum.setPercent(percent);
+                        entryNum.setPercentStr(percentStr);
+                    } else {
+                        entryNum.setPercent(0d);
+                        entryNum.setPercentStr("0%");
+                        entryNum.setTotleNum(totleNum);
+                    }
+                });
+            }
+            //降序排序
+            Collections.sort(standardEntryNumList, new Comparator<NumDTO>() {
+                @Override
+                public int compare(NumDTO o1, NumDTO o2) {
+                    return o2.getPercent().compareTo(o1.getPercent());
+                }
+            });
+        }
+
+        //取top10
+        standardEntryNumList = standardEntryNumList
+                .stream()
+                .limit(10)
+                .collect(Collectors.toList());
+
+        return standardEntryNumList;
+    }
 
-        if (ListUtil.isNotEmpty(results)) {
-            int totle = results
+    /**
+     * 条目缺陷占比
+     *
+     * @param filterVO
+     * @return
+     */
+    @DataProvider("entryCountGroupByEntry")
+    public List<NumDTO> entryCountGroupByEntry(@InvokeParameter("filterVO") FilterVO filterVO) {
+        DecimalFormat df = new DecimalFormat("#0.00");
+        List<NumDTO> numDTOList = qcresultInfoFacade.entryCountGroupByEntry(filterVO);
+        if (ListUtil.isNotEmpty(numDTOList)) {
+            int totle = numDTOList
                     .stream()
-                    .map(ResultDetailDTO::getNum)
+                    .map(NumDTO::getNum)
                     .reduce(0, Integer::sum);
-            List<ResultDetailDTO> retResutls = Lists.newLinkedList();
-            results.forEach(result -> {
-                Double percent = BigDecimal.valueOf(result.getNum())
+            List<NumDTO> retList = Lists.newLinkedList();
+            numDTOList.forEach(numDTO -> {
+                Double percent = BigDecimal.valueOf(numDTO.getNum())
                         .divide(BigDecimal.valueOf(totle), 4, RoundingMode.HALF_UP)
                         .doubleValue();
-                result.setPercent(percent);
-                DecimalFormat df = new DecimalFormat("#0.00");
+                numDTO.setPercent(percent);
                 String percentStr
-                        = df.format(BigDecimal.valueOf(result.getPercent()).multiply(BigDecimal.valueOf(100))) + "%";
-                result.setPercentStr(percentStr);
-                if (retResutls.size() < 10) {
-                    retResutls.add(result);
-                }
+                        = df.format(BigDecimal.valueOf(percent).multiply(BigDecimal.valueOf(100))) + "%";
+                numDTO.setPercentStr(percentStr);
+            });
 
+            //降序排序
+            Collections.sort(numDTOList, new Comparator<NumDTO>() {
+                @Override
+                public int compare(NumDTO o1, NumDTO o2) {
+                    return o2.getPercent().compareTo(o1.getPercent());
+                }
             });
-            return retResutls;
-        }
 
+            //top9+其他
+            if (numDTOList.size() <= 10) {
+                retList.addAll(numDTOList);
+            } else {
+                int count = 0;
+                for (NumDTO numDTO : numDTOList) {
+                    if (retList.size() < 10) {
+                        retList.add(numDTO);
+                        count += numDTO.getNum();
+                    } else {
+                        NumDTO otherNumDTO = new NumDTO();
+                        int num = totle - count;
+                        otherNumDTO.setName("其他");
+                        otherNumDTO.setNum(num);
+                        otherNumDTO.setTotleNum(totle);
+                        Double percent = BigDecimal.valueOf(numDTO.getNum())
+                                .divide(BigDecimal.valueOf(totle), 4, RoundingMode.HALF_UP)
+                                .doubleValue();
+                        otherNumDTO.setPercent(percent);
+                        String percentStr
+                                = df.format(BigDecimal.valueOf(percent).multiply(BigDecimal.valueOf(100))) + "%";
+                        otherNumDTO.setPercentStr(percentStr);
+                        retList.add(otherNumDTO);
+                        break;
+                    }
+                }
+            }
+            return retList;
+        }
         return null;
     }
 
+    /**
+     * 各科室缺陷占比
+     *
+     * @param filterVO
+     * @return
+     */
     @DataProvider("getResultDept")
-    public List<ResultDetailDTO> getResultDept(@InvokeParameter("filterVO") FilterVO filterVO) {
-        List<ResultDetailDTO> results2 = behospitalInfoFacade.resultStatisticsByDept2(filterVO);
-        if (ListUtil.isNotEmpty(results2)) {
-            int totle = results2
+    public List<NumDTO> getResultDept(@InvokeParameter("filterVO") FilterVO filterVO) {
+        List<NumDTO> numDTOList = behospitalInfoFacade.resultStatisticsByDept2(filterVO);
+        if (ListUtil.isNotEmpty(numDTOList)) {
+            int totle = numDTOList
                     .stream()
-                    .map(ResultDetailDTO::getNum)
+                    .map(NumDTO::getNum)
                     .reduce(0, Integer::sum);
-            results2.forEach(result -> {
+            numDTOList.forEach(result -> {
                 Double percent = BigDecimal.valueOf(result.getNum())
                         .divide(BigDecimal.valueOf(totle), 4, RoundingMode.HALF_UP)
                         .doubleValue();
                 result.setPercent(percent);
             });
-            List<ResultDetailDTO> retResults = Lists.newLinkedList();
-            if (results2.size() <= 6) {
-                retResults = BeanUtil.listCopyTo(results2, ResultDetailDTO.class);
+            List<NumDTO> retList = Lists.newLinkedList();
+            if (numDTOList.size() <= 10) {
+                retList = BeanUtil.listCopyTo(numDTOList, NumDTO.class);
             } else {
 
                 Double rate = 0d;
                 Integer num = 0;
-                for (ResultDetailDTO result : results2) {
-                    if (retResults.size() < 5) {
+                for (NumDTO numDTO : numDTOList) {
+                    if (retList.size() < 9) {
                         rate = BigDecimal.valueOf(rate)
-                                .add(BigDecimal.valueOf(Double.valueOf(result.getPercent())))
+                                .add(BigDecimal.valueOf(Double.valueOf(numDTO.getPercent())))
                                 .doubleValue();
-                        retResults.add(result);
+                        retList.add(numDTO);
                     } else {
-                        num += result.getNum();
+                        num += numDTO.getNum();
                     }
                 }
-                ResultDetailDTO retResult = new ResultDetailDTO();
-                retResult.setName("其他");
-                retResult.setNum(num);
-                retResult.setPercent(BigDecimal.valueOf(1).subtract(BigDecimal.valueOf(rate)).doubleValue());
-                retResults.add(retResult);
+                NumDTO otherNumDTO = new NumDTO();
+                otherNumDTO.setName("其他");
+                otherNumDTO.setNum(num);
+                otherNumDTO.setPercent(BigDecimal.valueOf(1).subtract(BigDecimal.valueOf(rate)).doubleValue());
+                retList.add(otherNumDTO);
             }
-            retResults.forEach(result -> {
+            retList.forEach(result -> {
                 DecimalFormat df = new DecimalFormat("#0.00");
                 String percentStr
                         = df.format(BigDecimal.valueOf(result.getPercent()).multiply(BigDecimal.valueOf(100))) + "%";
                 result.setPercentStr(percentStr);
             });
-            return retResults;
+            return retList;
         }
         return null;
     }
-}
+}

+ 6 - 2
src/main/java/com/diagbot/dto/AverageStatisticsDTO.java

@@ -11,9 +11,13 @@ import lombok.Setter;
 @Getter
 @Setter
 public class AverageStatisticsDTO {
-    private String deptId;
-    private String deptName;
+    private String id;
+    private String name;
     private Integer num;
     private Double averageValue;
     private Double totleValue;
+    //环比平均值
+    private Double lastAverageValue;
+    //同比平均值
+    private Double lastYearAverageValue;
 }

+ 4 - 14
src/main/java/com/diagbot/dto/ResultDetailDTO.java

@@ -6,25 +6,15 @@ import lombok.Setter;
 /**
  * @Description:
  * @Author:zhaops
- * @time: 2020/4/15 16:26
+ * @time: 2020/5/6 15:55
  */
 @Getter
 @Setter
-public class ResultDetailDTO {
-    /**
-     * 缺陷名称/科室名称
-     */
+public class NumDTO {
+    private Long id;
     private String name;
-    /**
-     * 数量
-     */
+    private Integer totleNum;
     private Integer num;
-    /**
-     * 占比
-     */
     private Double percent;
-    /**
-     * 百分比
-     */
     private String percentStr;
 }

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

@@ -0,0 +1,23 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/5/6 13:20
+ */
+@Getter
+@Setter
+public class QcResultPercentDTO {
+    private String deptId;
+    private String deptName;
+    private Integer totleNum;
+    private Integer firstLevelNum;
+    //private Integer secondLevelNum;
+    //private Integer thirdLevelNum;
+    private String firstPercent;
+    //private String secondPercent;
+    //private String thirdPercent;
+}

+ 0 - 17
src/main/java/com/diagbot/dto/ResultStatisticsDTO.java

@@ -1,17 +0,0 @@
-package com.diagbot.dto;
-
-import lombok.Getter;
-import lombok.Setter;
-
-import java.util.List;
-
-/**
- * @Description:
- * @Author:zhaops
- * @time: 2020/4/15 15:59
- */
-@Getter
-@Setter
-public class ResultStatisticsDTO {
-    List<ResultDetailDTO> details;
-}

+ 15 - 244
src/main/java/com/diagbot/facade/ConsoleFacade.java

@@ -1,27 +1,16 @@
 package com.diagbot.facade;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.diagbot.dto.AverageStatisticsDTO;
-import com.diagbot.entity.BehospitalInfo;
-import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
-import com.diagbot.util.BeanUtil;
-import com.diagbot.util.DateUtil;
 import com.diagbot.util.SysUserUtils;
 import com.diagbot.vo.FilterVO;
-import com.diagbot.vo.QcresultFilterVO;
 import com.google.common.collect.Lists;
 import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -31,114 +20,32 @@ import java.util.Map;
  */
 @Component
 public class ConsoleFacade {
-
-    @Autowired
-    private QcresultInfoFacade qcresultInfoFacade;
-    @Autowired
-    private BehospitalInfoFacade behospitalInfoFacade;
     @Autowired
-    private HomePageFacade homePageFacade;
+    private FilterFacade filterFacade;
     @Autowired
     private DataBeanAggregateQueryFacade dataBeanAggregateQueryFacade;
 
-
     /**
      * 病历相关统计
      *
+     * @param filterVO
      * @return
      */
     public Map<String, Object> mrStatistics(FilterVO filterVO) {
         Map<String, Object> retMap = new LinkedHashMap<>();
         String hospitalId = SysUserUtils.getCurrentHospitalID();
-        String startDate = getStartDateStr(filterVO.getType());
+        String startDate = filterFacade.getStartDateStr(filterVO.getType(), null);
+        String endDate = filterFacade.getEndDateStr(filterVO.getType(), null);
         filterVO.setStartDate(startDate);
+        filterVO.setEndDate(endDate);
         filterVO.setHospitalId(hospitalId);
-
-        QueryWrapper<BehospitalInfo> behospitalInfoQueryWrapper = new QueryWrapper<>();
-        behospitalInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
-                .eq("hospital_id", hospitalId)
-                .ge("behospital_date", startDate);
-        int behospitalInfoCount = behospitalInfoFacade.count(behospitalInfoQueryWrapper);
-        //病历数
-        if (filterVO.getType().equals(1)) {
-            retMap.put("本月病历数", behospitalInfoCount);
-        } else if (filterVO.getType().equals(2)) {
-            retMap.put("本年病历数", behospitalInfoCount);
-        }
-
-        QcresultFilterVO qcresultFilterVO = new QcresultFilterVO();
-        BeanUtil.copyProperties(filterVO, qcresultFilterVO);
-        //本月质控数-人工
-        qcresultFilterVO.setGradeType(2);
-        qcresultFilterVO.setLevel("");
-        int qcresultByGradeType2Count = qcresultInfoFacade.getQcresultSelectively(qcresultFilterVO);
-        if (qcresultFilterVO.getType().equals(1)) {
-            retMap.put("本月质控数-人工", qcresultByGradeType2Count);
-        } else if (qcresultFilterVO.getType().equals(2)) {
-            retMap.put("本年质控数-人工", qcresultByGradeType2Count);
-        }
-        //本月质控数-机器
-        qcresultFilterVO.setGradeType(1);
-        qcresultFilterVO.setLevel("");
-        int qcresultByGradeType1Count = qcresultInfoFacade.getQcresultSelectively(qcresultFilterVO);
-        if (qcresultFilterVO.getType().equals(1)) {
-            retMap.put("本月质控数-机器", qcresultByGradeType1Count);
-        } else if (qcresultFilterVO.getType().equals(2)) {
-            retMap.put("本年质控数-机器", qcresultByGradeType1Count);
-        }
-        //本月甲级病历-人工
-        qcresultFilterVO.setGradeType(2);
-        qcresultFilterVO.setLevel("甲");
-        int qcresultByGradeType2AndLevel1Count = qcresultInfoFacade.getQcresultSelectively(qcresultFilterVO);
-        if (qcresultFilterVO.getType().equals(1)) {
-            retMap.put("本月甲级病历-人工", qcresultByGradeType2AndLevel1Count);
-        } else if (qcresultFilterVO.getType().equals(2)) {
-            retMap.put("本年甲级病历-人工", qcresultByGradeType2AndLevel1Count);
-        }
-        //本月甲级病历-机器
-        qcresultFilterVO.setGradeType(1);
-        qcresultFilterVO.setLevel("甲");
-        int qcresultByGradeType1AndLevel1Count = qcresultInfoFacade.getQcresultSelectively(qcresultFilterVO);
-        if (qcresultFilterVO.getType().equals(1)) {
-            retMap.put("本月甲级病历-机器", qcresultByGradeType1AndLevel1Count);
-        } else if (qcresultFilterVO.getType().equals(2)) {
-            retMap.put("本年甲级病历-机器", qcresultByGradeType1AndLevel1Count);
-        }
-        //本月乙级病历-人工
-        qcresultFilterVO.setGradeType(2);
-        qcresultFilterVO.setLevel("乙");
-        int qcresultByGradeType2AndLevel2Count = qcresultInfoFacade.getQcresultSelectively(qcresultFilterVO);
-        if (qcresultFilterVO.getType().equals(1)) {
-            retMap.put("本月乙级病历-人工", qcresultByGradeType2AndLevel2Count);
-        } else if (qcresultFilterVO.getType().equals(2)) {
-            retMap.put("本年乙级病历-人工", qcresultByGradeType2AndLevel2Count);
-        }
-        //本月乙级病历-机器
-        qcresultFilterVO.setGradeType(1);
-        qcresultFilterVO.setLevel("乙");
-        int qcresultByGradeType1AndLevel2Count = qcresultInfoFacade.getQcresultSelectively(qcresultFilterVO);
-        if (qcresultFilterVO.getType().equals(1)) {
-            retMap.put("本月乙级病历-机器", qcresultByGradeType1AndLevel2Count);
-        } else if (qcresultFilterVO.getType().equals(2)) {
-            retMap.put("本年乙级病历-机器", qcresultByGradeType1AndLevel2Count);
-        }
-        //本月乙级病历-人工
-        qcresultFilterVO.setGradeType(2);
-        qcresultFilterVO.setLevel("丙");
-        int qcresultByGradeType2AndLevel3Count = qcresultInfoFacade.getQcresultSelectively(qcresultFilterVO);
-        if (qcresultFilterVO.getType().equals(1)) {
-            retMap.put("本月丙级病历-人工", qcresultByGradeType2AndLevel3Count);
-        } else if (qcresultFilterVO.getType().equals(2)) {
-            retMap.put("本年丙级病历-人工", qcresultByGradeType2AndLevel3Count);
-        }
-        //本月乙级病历-机器
-        qcresultFilterVO.setGradeType(1);
-        qcresultFilterVO.setLevel("丙");
-        int qcresultByGradeType1AndLevel3Count = qcresultInfoFacade.getQcresultSelectively(qcresultFilterVO);
-        if (filterVO.getType().equals(1)) {
-            retMap.put("本月丙级病历-机器", qcresultByGradeType1AndLevel3Count);
-        } else if (filterVO.getType().equals(2)) {
-            retMap.put("本年丙级病历-机器", qcresultByGradeType1AndLevel3Count);
+        try {
+            Map<String, Object> invokeParams = new HashMap<>();
+            invokeParams.put("filterVO", filterVO);
+            retMap
+                    = dataBeanAggregateQueryFacade.get("setAllMr", invokeParams, Map.class);
+        } catch (Exception e) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
         }
         return retMap;
     }
@@ -151,59 +58,10 @@ public class ConsoleFacade {
      */
     public Map<String, Object> resultStatistics(FilterVO filterVO) {
         Map<String, Object> retMap = new LinkedHashMap<>();
-        retMap.put("缺陷排行列表", Lists.newLinkedList());
-        retMap.put("各科室缺陷占比", Lists.newLinkedList());
         String hospitalId = SysUserUtils.getCurrentHospitalID();
-        String startDate = getStartDateStr(filterVO.getType());
+        String startDate = filterFacade.getStartDateStr(filterVO.getType(), null);
         filterVO.setStartDate(startDate);
         filterVO.setHospitalId(hospitalId);
-        /*if (filterVO.getLimitCount() == null || filterVO.getLimitCount().equals(0)) {
-            filterVO.setLimitCount(10);
-        }*/
-        //        List<ResultDetailDTO> results = behospitalInfoFacade.resultStatistics(filterVO);
-        //        if (ListUtil.isNotEmpty(results)) {
-        //            results.forEach(result -> {
-        //                DecimalFormat df = new DecimalFormat("#0.00");
-        //                String percentStr
-        //                        = df.format(BigDecimal.valueOf(result.getPercent()).multiply(BigDecimal.valueOf(100))) + "%";
-        //                result.setPercentStr(percentStr);
-        //            });
-        //            retMap.put("缺陷排行列表", results);
-        //        }
-        //        List<ResultDetailDTO> results2 = behospitalInfoFacade.resultStatisticsByDept(filterVO);
-        //        if (ListUtil.isNotEmpty(results2)) {
-        //            List<ResultDetailDTO> retResults = Lists.newLinkedList();
-        //            if (results2.size() <= 6) {
-        //                retResults = BeanUtil.listCopyTo(results2, ResultDetailDTO.class);
-        //            } else {
-        //
-        //                Double rate = 0d;
-        //                Integer num = 0;
-        //                for (ResultDetailDTO result : results2) {
-        //                    if (retResults.size() < 5) {
-        //                        rate = BigDecimal.valueOf(rate)
-        //                                .add(BigDecimal.valueOf(Double.valueOf(result.getPercent())))
-        //                                .doubleValue();
-        //                        retResults.add(result);
-        //                    } else {
-        //                        num += result.getNum();
-        //                    }
-        //                }
-        //                ResultDetailDTO retResult = new ResultDetailDTO();
-        //                retResult.setName("其他");
-        //                retResult.setNum(num);
-        //                retResult.setPercent(BigDecimal.valueOf(1).subtract(BigDecimal.valueOf(rate)).doubleValue());
-        //                retResults.add(retResult);
-        //            }
-        //            retResults.forEach(result -> {
-        //                DecimalFormat df = new DecimalFormat("#0.00");
-        //                String percentStr
-        //                        = df.format(BigDecimal.valueOf(result.getPercent()).multiply(BigDecimal.valueOf(100))) + "%";
-        //                result.setPercentStr(percentStr);
-        //            });
-        //            retMap.put("各科室缺陷占比", retResults);
-        //        }
-
         try {
             Map<String, Object> invokeParams = new HashMap<>();
             invokeParams.put("filterVO", filterVO);
@@ -216,43 +74,17 @@ public class ConsoleFacade {
     }
 
     /**
-     * 医院运营相关统计
+     * 平局值相关统计
      *
      * @param filterVO
      * @return
      */
     public Map<String, Object> averageStatistics(FilterVO filterVO) {
         Map<String, Object> retMap = new LinkedHashMap<>();
-        retMap.put("平均住院日", Lists.newLinkedList());
-        retMap.put("平均住院费用", Lists.newLinkedList());
         String hospitalId = SysUserUtils.getCurrentHospitalID();
         filterVO.setHospitalId(hospitalId);
-        String startDate = getStartDateStr(filterVO.getType());
+        String startDate = filterFacade.getStartDateStr(filterVO.getType(), null);
         filterVO.setStartDate(startDate);
-
-        /*
-        List<AverageStatisticsDTO> retAverageDayNumList = Lists.newLinkedList();
-        List<AverageStatisticsDTO> retAverageFeeList = Lists.newLinkedList();
-        List<AverageStatisticsDTO> averageDayNumList = homePageFacade.getAverageDayNum(filterVO);
-        List<AverageStatisticsDTO> averageFeeList = homePageFacade.getAverageFee(filterVO);
-
-        if (filterVO.getLimitCount() == null || filterVO.getLimitCount().equals(0)) {
-            filterVO.setLimitCount(10);
-        }
-        Integer limitCount = filterVO.getLimitCount();
-
-        //平均住院日
-        if (ListUtil.isNotEmpty(averageDayNumList)) {
-            retAverageDayNumList = getLimitAverageList(averageDayNumList, limitCount);
-            retMap.put("平均住院日", retAverageDayNumList);
-        }
-
-        //平均住院费用
-        if (ListUtil.isNotEmpty(averageFeeList)) {
-            retAverageFeeList = getLimitAverageList(averageFeeList, limitCount);
-            retMap.put("平均住院费用", retAverageFeeList);
-        }*/
-
         try {
             Map<String, Object> invokeParams = new HashMap<>();
             invokeParams.put("filterVO", filterVO);
@@ -261,67 +93,6 @@ public class ConsoleFacade {
         } catch (Exception e) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
         }
-
         return retMap;
     }
-
-    /**
-     * 筛选起始时间
-     *
-     * @param type
-     * @return
-     */
-    public String getStartDateStr(Integer type) {
-        Date date = new Date();
-        String startDate = "";
-        String year = DateUtil.getYear(date);
-        int month = DateUtil.getMonth(date);
-        if (type.equals(1)) {
-            //本月统计
-            startDate = year + "-" + month + "-1";
-        } else if (type.equals(2)) {
-            //本年统计
-            startDate = year + "-1-1";
-        }
-        return startDate;
-    }
-
-    /**
-     * 根据限制数量重组统计结果
-     *
-     * @param averageList
-     * @param limitCount
-     * @return
-     */
-    public List<AverageStatisticsDTO> getLimitAverageList(List<AverageStatisticsDTO> averageList, Integer limitCount) {
-        List<AverageStatisticsDTO> retAverageList = Lists.newLinkedList();
-        if (averageList.size() < limitCount) {
-            retAverageList = BeanUtil.listCopyTo(averageList, AverageStatisticsDTO.class);
-        } else {
-            if (averageList.size() > limitCount) {
-                retAverageList = averageList.subList(0, limitCount - 1);
-                List<AverageStatisticsDTO> otherList = averageList.subList(limitCount - 1, averageList.size());
-                Double totleValue = otherList
-                        .stream()
-                        .map(i -> BigDecimal.valueOf(i.getTotleValue()))
-                        .reduce(BigDecimal.ZERO, BigDecimal::add).doubleValue();
-                Integer num = otherList
-                        .stream()
-                        .map(AverageStatisticsDTO::getNum)
-                        .reduce(0, Integer::sum);
-                Double averageValue = BigDecimal.valueOf(totleValue)
-                        .divide(BigDecimal.valueOf(num), 2, RoundingMode.HALF_UP)
-                        .doubleValue();
-                AverageStatisticsDTO retAverageStatistics = new AverageStatisticsDTO();
-                retAverageStatistics.setDeptName("其他");
-                retAverageStatistics.setNum(num);
-                retAverageStatistics.setAverageValue(averageValue);
-                retAverageStatistics.setTotleValue(totleValue);
-                retAverageList.add(retAverageStatistics);
-            } else {
-                retAverageList = averageList;
-            }
-        }
-        return retAverageList;
-    }
 }

+ 94 - 0
src/main/java/com/diagbot/facade/FilterFacade.java

@@ -0,0 +1,94 @@
+package com.diagbot.facade;
+
+import com.diagbot.util.DateUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/5/7 13:53
+ */
+@Component
+public class FilterFacade {
+    /**
+     * 筛选起始时间
+     *
+     * @param type
+     * @return
+     */
+    public String getStartDateStr(Integer type, Integer optYear) {
+        Date date = new Date();
+        String startDate = "";
+        String year = optYear == null ? DateUtil.getYear(date) : optYear.toString();
+        int month = DateUtil.getMonth(date);
+        if (type.equals(1)) {
+            //本月统计
+            startDate = year + "-" + month + "-1";
+        } else if (type.equals(2)) {
+            //本年统计
+            startDate = year + "-1-1";
+        }
+        return startDate;
+    }
+
+    /**
+     * 筛选截止时间
+     *
+     * @param type
+     * @return
+     */
+    public String getEndDateStr(Integer type, Integer optYear) {
+        Date date = new Date();
+        String endDate = "";
+        String year = optYear == null ? DateUtil.getYear(date) : optYear.toString();
+        int month = DateUtil.getMonth(date);
+        if (type.equals(1)) {
+            //本月统计
+            if (month == 12) {
+                endDate = (Integer.valueOf(year) + 1) + "-1-1";
+            } else {
+                endDate = year + "-" + (month + 1) + "-1";
+            }
+        } else if (type.equals(2)) {
+            //本年统计
+            endDate = (Integer.valueOf(year) + 1) + "-1-1";
+        }
+        return endDate;
+    }
+
+    /**
+     * 上一统计周期(上月/去年)的起始时间
+     *
+     * @param type
+     * @return
+     */
+    public String getLastStartDateStr(Integer type) {
+        Date date = new Date();
+        String dateStr = "";
+        String year = DateUtil.getYear(date);
+        int month = DateUtil.getMonth(date);
+        if (type.equals(1)) {
+            if (month == 1) {
+                dateStr = (Integer.valueOf(year) - 1) + "-12-1";
+            } else {
+                dateStr = year + "-" + (month - 1) + "-1";
+            }
+        } else if (type.equals(2)) {
+            dateStr = (Integer.valueOf(year) - 1) + "-1-1";
+        }
+        return dateStr;
+    }
+
+    /**
+     * 获取上一统计周期(上月/去年)的起始时间
+     *
+     * @param type
+     * @return
+     */
+    public String getLastEndDateStr(Integer type) {
+        //上一统计周期的截止时间等于本周期的起始时间
+        return getStartDateStr(type, null);
+    }
+}

+ 22 - 5
src/main/java/com/diagbot/mapper/BehospitalInfoMapper.java

@@ -4,11 +4,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.MsgDTO;
-import com.diagbot.dto.ResultDetailDTO;
+import com.diagbot.dto.NumDTO;
 import com.diagbot.entity.BehospitalInfo;
 import com.diagbot.vo.AnalyzeVO;
 import com.diagbot.vo.BehospitalPageVO;
 import com.diagbot.vo.FilterVO;
+import com.diagbot.vo.HomePageFilterVO;
 
 import java.util.List;
 
@@ -32,7 +33,7 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @param filterVO
      * @return
      */
-    public List<ResultDetailDTO> resultStatistics(FilterVO filterVO);
+    public List<NumDTO> resultStatistics(FilterVO filterVO);
 
     /**
      * 各科室缺陷占比
@@ -40,7 +41,7 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @param filterVO
      * @return
      */
-    public List<ResultDetailDTO> resultStatisticsByDept(FilterVO filterVO);
+    public List<NumDTO> resultStatisticsByDept(FilterVO filterVO);
 
     /**
      * 缺陷排行列表统计-百分比未计算
@@ -48,7 +49,7 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @param filterVO
      * @return
      */
-    public List<ResultDetailDTO> resultStatistics2(FilterVO filterVO);
+    public List<NumDTO> resultStatistics2(FilterVO filterVO);
 
     /**
      * 各科室缺陷占比-百分比未计算
@@ -56,7 +57,7 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @param filterVO
      * @return
      */
-    public List<ResultDetailDTO> resultStatisticsByDept2(FilterVO filterVO);
+    public List<NumDTO> resultStatisticsByDept2(FilterVO filterVO);
 
     /**
      * 缺陷总数
@@ -72,4 +73,20 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
     IPage<BehospitalInfoDTO> getPageByDept(BehospitalPageVO behospitalPageVO);
 
     IPage<BehospitalInfoDTO> getPageByPerson(BehospitalPageVO behospitalPageVO);
+
+    /**
+     * 病案首页相关病历数统计
+     *
+     * @param homePageFilterVO
+     * @return
+     */
+    public int homePageCount(HomePageFilterVO homePageFilterVO);
+
+    /**
+     * 手术病历数统计
+     *
+     * @param filterVO
+     * @return
+     */
+    public int homePageCountForOperation(FilterVO filterVO);
 }

+ 8 - 0
src/main/java/com/diagbot/mapper/QcCasesMapper.java

@@ -1,6 +1,7 @@
 package com.diagbot.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.QcCasesDTO;
 import com.diagbot.entity.QcCases;
 import com.diagbot.vo.QcCasesQueryVO;
@@ -17,4 +18,11 @@ import java.util.List;
  */
 public interface QcCasesMapper extends BaseMapper<QcCases> {
     List<QcCasesDTO> getQcCases(QcCasesQueryVO queryVO);
+
+    /**
+     * 按模块统计条目数
+     *
+     * @return
+     */
+    List<NumDTO> entryGroupByCase();
 }

+ 47 - 1
src/main/java/com/diagbot/mapper/QcresultInfoMapper.java

@@ -1,9 +1,15 @@
 package com.diagbot.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.dto.AverageStatisticsDTO;
+import com.diagbot.dto.NumDTO;
+import com.diagbot.dto.QcResultPercentDTO;
 import com.diagbot.entity.QcresultInfo;
+import com.diagbot.vo.FilterVO;
 import com.diagbot.vo.QcresultFilterVO;
 
+import java.util.List;
+
 /**
  * <p>
  * 质控评分结果信息
@@ -22,4 +28,44 @@ public interface QcresultInfoMapper extends BaseMapper<QcresultInfo> {
      * @return
      */
     public int getQcresultSelectively(QcresultFilterVO qcresultFilterVO);
-}
+
+    /**
+     * 质控病历数统计
+     *
+     * @param qcresultFilterVO
+     * @return
+     */
+    public int resultCount(QcresultFilterVO qcresultFilterVO);
+
+    /**
+     * 按科室统计各等级病历百分比
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<QcResultPercentDTO> levelPercentGroupByDept(FilterVO filterVO);
+
+    /**
+     * 按模块统计缺陷数
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<NumDTO> entryCountGroupByCase(FilterVO filterVO);
+
+    /**
+     * 条目缺陷分组统计
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<NumDTO> entryCountGroupByEntry(FilterVO filterVO);
+
+    /**
+     * 质控平均分按科室统计
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<AverageStatisticsDTO> getAverageScoreByDept(FilterVO filterVO);
+}

+ 24 - 6
src/main/java/com/diagbot/service/BehospitalInfoService.java

@@ -4,11 +4,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.MsgDTO;
-import com.diagbot.dto.ResultDetailDTO;
+import com.diagbot.dto.NumDTO;
 import com.diagbot.entity.BehospitalInfo;
 import com.diagbot.vo.AnalyzeVO;
 import com.diagbot.vo.BehospitalPageVO;
 import com.diagbot.vo.FilterVO;
+import com.diagbot.vo.HomePageFilterVO;
 
 import java.util.List;
 
@@ -32,7 +33,7 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
      * @param filterVO
      * @return
      */
-    public List<ResultDetailDTO> resultStatistics(FilterVO filterVO);
+    public List<NumDTO> resultStatistics(FilterVO filterVO);
 
     /**
      * 各科室缺陷占比
@@ -40,7 +41,7 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
      * @param filterVO
      * @return
      */
-    public List<ResultDetailDTO> resultStatisticsByDept(FilterVO filterVO);
+    public List<NumDTO> resultStatisticsByDept(FilterVO filterVO);
 
     /**
      * 缺陷排行列表统计-百分比未计算
@@ -48,7 +49,7 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
      * @param filterVO
      * @return
      */
-    public List<ResultDetailDTO> resultStatistics2(FilterVO filterVO);
+    public List<NumDTO> resultStatistics2(FilterVO filterVO);
 
     /**
      * 各科室缺陷占比-百分比未计算
@@ -56,7 +57,7 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
      * @param filterVO
      * @return
      */
-    public List<ResultDetailDTO> resultStatisticsByDept2(FilterVO filterVO);
+    public List<NumDTO> resultStatisticsByDept2(FilterVO filterVO);
 
     /**
      * 缺陷总数
@@ -70,5 +71,22 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
     public List<BehospitalInfo> getNoGrade();
 
     IPage<BehospitalInfoDTO> getPageByDept(BehospitalPageVO behospitalPageVO);
+
     IPage<BehospitalInfoDTO> getPageByPerson(BehospitalPageVO behospitalPageVO);
-}
+
+    /**
+     * 病案首页相关病历数统计
+     *
+     * @param homePageFilterVO
+     * @return
+     */
+    public int homePageCount(HomePageFilterVO homePageFilterVO);
+
+    /**
+     * 手术病历数统计
+     *
+     * @param filterVO
+     * @return
+     */
+    public int homePageCountForOperation(FilterVO filterVO);
+}

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

@@ -1,6 +1,7 @@
 package com.diagbot.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.QcCasesDTO;
 import com.diagbot.entity.QcCases;
 import com.diagbot.vo.QcCasesQueryVO;
@@ -17,4 +18,11 @@ import java.util.List;
  */
 public interface QcCasesService extends IService<QcCases> {
     List<QcCasesDTO> getQcCases(QcCasesQueryVO queryVO);
-}
+
+    /**
+     * 按模块统计条目数
+     *
+     * @return
+     */
+    List<NumDTO> entryGroupByCase();
+}

+ 48 - 1
src/main/java/com/diagbot/service/QcresultInfoService.java

@@ -1,9 +1,15 @@
 package com.diagbot.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.dto.AverageStatisticsDTO;
+import com.diagbot.dto.NumDTO;
+import com.diagbot.dto.QcResultPercentDTO;
 import com.diagbot.entity.QcresultInfo;
+import com.diagbot.vo.FilterVO;
 import com.diagbot.vo.QcresultFilterVO;
 
+import java.util.List;
+
 /**
  * <p>
  * 质控评分结果信息
@@ -22,4 +28,45 @@ public interface QcresultInfoService extends IService<QcresultInfo> {
      * @return
      */
     public int getQcresultSelectively(QcresultFilterVO qcresultFilterVO);
-}
+
+    /**
+     * 质控病历数统计
+     *
+     * @param qcresultFilterVO
+     * @return
+     */
+    public int resultCount(QcresultFilterVO qcresultFilterVO);
+
+
+    /**
+     * 按科室统计各等级病历百分比
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<QcResultPercentDTO> levelPercentGroupByDept(FilterVO filterVO);
+
+    /**
+     * 按模块统计缺陷数
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<NumDTO> entryCountGroupByCase(FilterVO filterVO);
+
+    /**
+     * 条目缺陷分组统计
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<NumDTO> entryCountGroupByEntry(FilterVO filterVO);
+
+    /**
+     * 质控平均分按科室统计
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<AverageStatisticsDTO> getAverageScoreByDept(FilterVO filterVO);
+}

+ 30 - 6
src/main/java/com/diagbot/service/impl/BehospitalInfoServiceImpl.java

@@ -4,13 +4,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.MsgDTO;
-import com.diagbot.dto.ResultDetailDTO;
+import com.diagbot.dto.NumDTO;
 import com.diagbot.entity.BehospitalInfo;
 import com.diagbot.mapper.BehospitalInfoMapper;
 import com.diagbot.service.BehospitalInfoService;
 import com.diagbot.vo.AnalyzeVO;
 import com.diagbot.vo.BehospitalPageVO;
 import com.diagbot.vo.FilterVO;
+import com.diagbot.vo.HomePageFilterVO;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -43,7 +44,7 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
      * @return
      */
     @Override
-    public List<ResultDetailDTO> resultStatistics(FilterVO filterVO) {
+    public List<NumDTO> resultStatistics(FilterVO filterVO) {
         return baseMapper.resultStatistics(filterVO);
     }
 
@@ -54,7 +55,7 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
      * @return
      */
     @Override
-    public List<ResultDetailDTO> resultStatisticsByDept(FilterVO filterVO) {
+    public List<NumDTO> resultStatisticsByDept(FilterVO filterVO) {
         return baseMapper.resultStatisticsByDept(filterVO);
     }
 
@@ -65,7 +66,7 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
      * @return
      */
     @Override
-    public List<ResultDetailDTO> resultStatistics2(FilterVO filterVO) {
+    public List<NumDTO> resultStatistics2(FilterVO filterVO) {
         return baseMapper.resultStatistics2(filterVO);
     }
 
@@ -76,7 +77,7 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
      * @return
      */
     @Override
-    public List<ResultDetailDTO> resultStatisticsByDept2(FilterVO filterVO) {
+    public List<NumDTO> resultStatisticsByDept2(FilterVO filterVO) {
         return baseMapper.resultStatisticsByDept2(filterVO);
     }
 
@@ -97,11 +98,34 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
     }
 
     @Override
-    public IPage<BehospitalInfoDTO> getPageByDept(BehospitalPageVO behospitalPageVO){
+    public IPage<BehospitalInfoDTO> getPageByDept(BehospitalPageVO behospitalPageVO) {
         return baseMapper.getPageByDept(behospitalPageVO);
     }
+
     @Override
     public IPage<BehospitalInfoDTO> getPageByPerson(BehospitalPageVO behospitalPageVO) {
         return baseMapper.getPageByPerson(behospitalPageVO);
     }
+
+    /**
+     * 病案首页相关病历数统计
+     *
+     * @param homePageFilterVO
+     * @return
+     */
+    @Override
+    public int homePageCount(HomePageFilterVO homePageFilterVO) {
+        return baseMapper.homePageCount(homePageFilterVO);
+    }
+
+    /**
+     * 手术病历数统计
+     *
+     * @param filterVO
+     * @return
+     */
+    @Override
+    public int homePageCountForOperation(FilterVO filterVO) {
+        return baseMapper.homePageCountForOperation(filterVO);
+    }
 }

+ 11 - 0
src/main/java/com/diagbot/service/impl/QcCasesServiceImpl.java

@@ -1,6 +1,7 @@
 package com.diagbot.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.QcCasesDTO;
 import com.diagbot.entity.QcCases;
 import com.diagbot.mapper.QcCasesMapper;
@@ -24,4 +25,14 @@ public class QcCasesServiceImpl extends ServiceImpl<QcCasesMapper, QcCases> impl
     public List<QcCasesDTO> getQcCases(QcCasesQueryVO queryVO) {
         return baseMapper.getQcCases(queryVO);
     }
+
+    /**
+     * 按模块统计条目数
+     *
+     * @return
+     */
+    @Override
+    public List<NumDTO> entryGroupByCase() {
+        return baseMapper.entryGroupByCase();
+    }
 }

+ 63 - 1
src/main/java/com/diagbot/service/impl/QcresultInfoServiceImpl.java

@@ -1,12 +1,18 @@
 package com.diagbot.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.dto.AverageStatisticsDTO;
+import com.diagbot.dto.NumDTO;
+import com.diagbot.dto.QcResultPercentDTO;
 import com.diagbot.entity.QcresultInfo;
 import com.diagbot.mapper.QcresultInfoMapper;
 import com.diagbot.service.QcresultInfoService;
+import com.diagbot.vo.FilterVO;
 import com.diagbot.vo.QcresultFilterVO;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 质控评分结果信息
@@ -29,4 +35,60 @@ public class QcresultInfoServiceImpl extends ServiceImpl<QcresultInfoMapper, Qcr
     public int getQcresultSelectively(QcresultFilterVO qcresultFilterVO) {
         return baseMapper.getQcresultSelectively(qcresultFilterVO);
     }
-}
+
+    /**
+     * 质控病历数统计
+     *
+     * @param qcresultFilterVO
+     * @return
+     */
+    @Override
+    public int resultCount(QcresultFilterVO qcresultFilterVO) {
+        return baseMapper.resultCount(qcresultFilterVO);
+    }
+
+
+    /**
+     * 按科室统计各等级病历百分比
+     *
+     * @param filterVO
+     * @return
+     */
+    @Override
+    public List<QcResultPercentDTO> levelPercentGroupByDept(FilterVO filterVO) {
+        return baseMapper.levelPercentGroupByDept(filterVO);
+    }
+
+    /**
+     * 按模块统计缺陷数
+     *
+     * @param filterVO
+     * @return
+     */
+    @Override
+    public List<NumDTO> entryCountGroupByCase(FilterVO filterVO) {
+        return baseMapper.entryCountGroupByCase(filterVO);
+    }
+
+    /**
+     * 条目缺陷分组统计
+     *
+     * @param filterVO
+     * @return
+     */
+    @Override
+    public List<NumDTO> entryCountGroupByEntry(FilterVO filterVO) {
+        return baseMapper.entryCountGroupByEntry(filterVO);
+    }
+
+    /**
+     * 质控平均分按科室统计
+     *
+     * @param filterVO
+     * @return
+     */
+    @Override
+    public List<AverageStatisticsDTO> getAverageScoreByDept(FilterVO filterVO) {
+        return baseMapper.getAverageScoreByDept(filterVO);
+    }
+}

+ 23 - 0
src/main/java/com/diagbot/vo/HomePageFilterVO.java

@@ -0,0 +1,23 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/5/6 11:29
+ */
+@Getter
+@Setter
+public class HomePageFilterVO extends FilterVO {
+    /**
+     * 死亡
+     */
+    private Integer death;
+
+    /**
+     * 新生儿
+     */
+    private Integer newBorn;
+}

+ 1 - 1
src/main/java/com/diagbot/web/ConsoleController.java

@@ -46,7 +46,7 @@ public class ConsoleController {
         return RespDTO.onSuc(data);
     }
 
-    @ApiOperation(value = "医院运营相关统计[by:zhaops]",
+    @ApiOperation(value = "平均值相关统计[by:zhaops]",
             notes = "type: 统计维度 1-本月,2-本年(必填)<br>")
     @PostMapping("/averageStatistics")
     @SysLogger("averageStatistics")

+ 60 - 4
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -102,7 +102,7 @@
 
 
     <!-- 缺陷排行列表 -->
-    <select id="resultStatistics"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.ResultDetailDTO">
+    <select id="resultStatistics"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
         SELECT
         t1.msg AS name,
         t1.num AS num,
@@ -165,7 +165,7 @@
     </select>
 
     <!-- 各科室缺陷占比 -->
-    <select id="resultStatisticsByDept"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.ResultDetailDTO">
+    <select id="resultStatisticsByDept"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
         SELECT
         t1.beh_dept_name AS name,
         t1.num AS num,
@@ -227,7 +227,7 @@
     </select>
 
     <!-- 缺陷排行列表 -->
-    <select id="resultStatistics2"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.ResultDetailDTO">
+    <select id="resultStatistics2"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
         SELECT
         c.msg as name,
         count(*) AS num
@@ -259,7 +259,7 @@
     </select>
 
     <!-- 各科室缺陷占比 -->
-    <select id="resultStatisticsByDept2"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.ResultDetailDTO">
+    <select id="resultStatisticsByDept2"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
         SELECT
         a.beh_dept_id,
         a.beh_dept_name as name,
@@ -461,4 +461,60 @@
 
     </select>
 
+    <!-- 病案首页病历数统计 -->
+    <select id="homePageCount" parameterType="com.diagbot.vo.HomePageFilterVO" resultType="int">
+        SELECT
+        COUNT(*)
+        FROM
+        med_behospital_info a,
+        med_home_page b
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.behospital_code = b.behospital_code
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
+        <if test="death!=null and death==1">
+            AND b.leave_hospital_type = '死亡'
+        </if>
+        <if test="newBorn!=null and newBorn==1">
+            AND ( b.age IS NULL OR b.age = '-' OR b.age = '' )
+            <![CDATA[AND ( b.newborn_month IS NOT NULL OR b.newborn_month <> '' OR b.newborn_day IS NOT NULL OR b.newborn_day <> '' )]]>
+        </if>
+    </select>
+
+    <!-- 病案首页手术病历数统计 -->
+    <select id="homePageCountForOperation" parameterType="com.diagbot.vo.FilterVO" resultType="int">
+        SELECT
+        COUNT(*)
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_home_operation_info c
+        WHERE
+        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 b.home_page_id = c.home_page_id
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
+    </select>
 </mapper>

+ 16 - 10
src/main/resources/mapper/HomePageMapper.xml

@@ -141,11 +141,11 @@
     <!-- 按科室统计平均住院天数 -->
     <select id="getAverageDayNum"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AverageStatisticsDTO">
         SELECT
-        a.beh_dept_id as deptId,
-        a.beh_dept_name as deptName,
+        a.beh_dept_id as id,
+        a.beh_dept_name as name,
         count(*) AS num,
-        round( sum( b.behospital_day_num )/ count(*), 2 ) AS averageValue,
-        round( sum( b.behospital_day_num ), 2 ) AS totleValue
+        round( sum( CAST(b.behospital_day_num AS DECIMAL ))/ count(*), 2 ) AS averageValue,
+        round( sum( CAST(b.behospital_day_num AS DECIMAL )), 2 ) AS totleValue
         FROM
         med_behospital_info a,
         med_home_page b
@@ -158,7 +158,10 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= #{startDate}]]>
+            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
         </if>
         GROUP BY
         a.beh_dept_id,
@@ -170,11 +173,11 @@
     <!-- 按科室统计平均费用 -->
     <select id="getAverageFee"  parameterType="com.diagbot.vo.FilterVO"  resultType="com.diagbot.dto.AverageStatisticsDTO">
         SELECT
-        a.beh_dept_id as deptId,
-        a.beh_dept_name as deptName,
+        a.beh_dept_id as id,
+        a.beh_dept_name as name,
         count(*) AS num,
-        round( sum( b.total_fee )/ count(*), 2 ) AS averageValue,
-        round( sum( b.total_fee ), 2 ) AS totleValue
+        round( sum( CAST(b.total_fee AS DECIMAL ))/ count(*), 2 ) AS averageValue,
+        round( sum( CAST(b.total_fee AS DECIMAL )), 2 ) AS totleValue
         FROM
         med_behospital_info a,
         med_home_page b
@@ -187,7 +190,10 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= #{startDate}]]>
+            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
         </if>
         GROUP BY
         a.beh_dept_id,

+ 18 - 0
src/main/resources/mapper/QcCasesMapper.xml

@@ -32,4 +32,22 @@
             and qch.hospital_id = #{hospitalId}
         </if>
     </select>
+
+    <!-- 按模块统计条目数 -->
+    <select id="entryGroupByCase" resultType="com.diagbot.dto.NumDTO">
+        SELECT
+        a.id,
+        a.NAME,
+        count(*) AS num
+        FROM
+        qc_cases a,
+        qc_cases_entry b
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND a.id = b.cases_id
+        GROUP BY
+        a.id,
+        a.`name`
+    </select>
 </mapper>

+ 4 - 14
src/main/resources/mapper/QcQuestionInfoMapper.xml

@@ -45,23 +45,13 @@
     </select>
 
     <select id="getByCaseEntryIds" resultType="com.diagbot.dto.QuestionEntryDTO">
-        select * from (
-        select a.id,substring_index(substring_index(a.cases_entry_ids,',',b.help_topic_id+1),',',-1) cases_entry_id
-        from
-        qc_question_info a
-        join
-        <![CDATA[
-            mysql.help_topic b
-            on b.help_topic_id < (length(a.cases_entry_ids) - length(replace(a.cases_entry_ids,',',''))+1)
-        ]]>
-        where a.is_deleted = 'N'
+        SELECT q2.question_id id, q2.cases_entry_id FROM qc_question_info q1, qc_question_entry q2
+        where q1.is_deleted = 'N' and q2.is_deleted = 'N' and q1.id = q2.question_id
         <if test="hospitalId != null">
-            AND a.hospital_id = #{hospitalId}
+            AND q1.hospital_id = #{hospitalId}
         </if>
-        order by a.ID) t
-        where t.cases_entry_id != ''
         <if test="casesEntryIds != null and casesEntryIds.size > 0">
-            and t.cases_entry_id in
+            and q2.cases_entry_id in
             <foreach  collection="casesEntryIds" item="item" open="("  separator=","  close=")">
                 #{item}
             </foreach>

+ 184 - 1
src/main/resources/mapper/QcresultInfoMapper.xml

@@ -18,7 +18,7 @@
         <result column="remark" property="remark" />
     </resultMap>
 
-    <!-- 缺陷排行列表 -->
+    <!-- 病历数统计 -->
     <select id="getQcresultSelectively"  parameterType="com.diagbot.vo.QcresultFilterVO" resultType="int">
         SELECT
         count(1)
@@ -44,4 +44,187 @@
         </if>
     </select>
 
+    <!-- 质控病历数统计 -->
+    <select id="resultCount" parameterType="com.diagbot.vo.QcresultFilterVO" resultType="int">
+        SELECT
+        COUNT(*)
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_info c
+        WHERE
+        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 a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
+        <if test="gradeType != null and gradeType != ''">
+            AND c.grade_type = #{gradeType}
+        </if>
+        <if test="level != null and level != ''">
+            AND c.level = #{level}
+        </if>
+    </select>
+
+    <!-- 按科室统计质控病历数 -->
+    <select id="levelPercentGroupByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.QcResultPercentDTO">
+        SELECT
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        count(*) AS totleNum,
+        sum( c.`level` = '甲' ) AS firstLevelNum,
+        sum( c.`level` = '乙' ) AS secondLevelNum,
+        sum( c.`level` = '丙' ) AS thirdLevelNum,
+        concat( ROUND( sum( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstPercent,
+        concat( ROUND( sum( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS sencondPercent,
+        concat( ROUND( sum( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdPercent
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_info c
+        WHERE
+        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 a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+    </select>
+
+    <!-- 按模块统计质控缺陷数 -->
+    <select id="entryCountGroupByCase" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
+        SELECT
+        d.cases_id AS id,
+        e.NAME AS name,
+        count(*) AS num
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_info c,
+        med_qcresult_detail d,
+        qc_cases e,
+        qc_cases_entry f
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.is_deleted = 'N'
+        AND e.is_deleted = 'N'
+        AND f.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.hospital_id = d.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        AND a.behospital_code = d.behospital_code
+        AND d.cases_id = e.id
+        AND d.cases_entry_id = f.id
+        AND e.id = f.cases_id
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
+        GROUP BY
+        d.cases_id,
+        e.`name`
+    </select>
+
+    <!-- 条目缺陷分组统计 -->
+    <select id="entryCountGroupByEntry" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
+        SELECT
+        d.id,
+        d.NAME,
+        count(*) AS num
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_detail c,
+        qc_cases_entry d
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.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
+        AND c.cases_id = d.cases_id
+        AND c.cases_entry_id = d.id
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
+        GROUP BY
+        d.id,
+        d.NAME
+    </select>
+
+    <!-- 质控平均分按科室统计 -->
+    <select id="getAverageScoreByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AverageStatisticsDTO">
+        SELECT
+        a.beh_dept_id AS id,
+        a.beh_dept_name AS name,
+        ROUND( sum( CAST( c.score_res AS DECIMAL )), 2 ) AS totleValue,
+        ROUND( sum( CAST( c.score_res AS DECIMAL ))/ count(*), 2 ) AS averageValue,
+        count(*) AS num
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_info c
+        WHERE
+        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 a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+    </select>
 </mapper>