Quellcode durchsuchen

Merge branch 'dev/20200426_2nd' into test

gaodm vor 5 Jahren
Ursprung
Commit
b45b835360

+ 60 - 25
src/main/java/com/diagbot/aggregate/AverageStatisticsAggregate.java

@@ -22,6 +22,7 @@ import java.util.Date;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @Description:平均值相关统计
@@ -67,8 +68,12 @@ public class AverageStatisticsAggregate {
      */
     @DataProvider("getAverageDayNum")
     public List<AverageStatisticsDTO> getAverageDayNum(@InvokeParameter("filterVO") FilterVO filterVO) {
+        Integer limitCount = filterVO.getLimitCount();
         List<AverageStatisticsDTO> retAverageDayNumList = Lists.newLinkedList();
+        //本月、本年
         List<AverageStatisticsDTO> averageDayNumList = homePageFacade.getAverageDayNum(filterVO);
+        Map<String, Double> averageMap
+                = EntityUtil.makeMapWithKeyValue(averageDayNumList, "name", "averageValue");
 
         //上月、去年
         String startDate = filterFacade.getLastStartDateStr(filterVO.getType());
@@ -90,22 +95,36 @@ public class AverageStatisticsAggregate {
         }
         //按年统计,同比环比相同
         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()));
+        //获取所有出现的科室
+        List<String> nameList = Lists.newLinkedList();
+        nameList.addAll(averageMap.keySet());
+        nameList.addAll(lastMap.keySet());
+        nameList.addAll(lastYearMap.keySet());
+        nameList = nameList
+                .stream()
+                .distinct()
+                .collect(Collectors.toList());
+
+        for (String name : nameList) {
+            AverageStatisticsDTO item = new AverageStatisticsDTO();
+            item.setName(name);
+            if (averageMap.containsKey(name)) {
+                item.setAverageValue(averageMap.get(name));
             }
-            if (lastYearMap.containsKey(item.getName())) {
-                item.setLastYearAverageValue(lastYearMap.get(item.getName()));
+            if (lastMap.containsKey(name)) {
+                item.setLastAverageValue(lastMap.get(name));
             }
-        });
-        if (averageDayNumList.size() <= 10) {
-            retAverageDayNumList = averageDayNumList;
-        } else {
-            retAverageDayNumList = averageDayNumList.subList(0, 10);
+            if (lastYearMap.containsKey(name)) {
+                item.setLastYearAverageValue(lastYearMap.get(name));
+            }
+            retAverageDayNumList.add(item);
+        }
+
+        if (retAverageDayNumList.size() > limitCount) {
+            retAverageDayNumList = retAverageDayNumList.subList(0, limitCount);
         }
         return retAverageDayNumList;
     }
@@ -118,8 +137,13 @@ public class AverageStatisticsAggregate {
      */
     @DataProvider("getAverageFee")
     public List<AverageStatisticsDTO> getAverageFee(@InvokeParameter("filterVO") FilterVO filterVO) {
+        Integer limitCount = filterVO.getLimitCount();
         List<AverageStatisticsDTO> retAverageFeeList = Lists.newLinkedList();
+        //本月、本年
         List<AverageStatisticsDTO> averageFeeList = homePageFacade.getAverageFee(filterVO);
+        Map<String, Double> averageMap
+                = EntityUtil.makeMapWithKeyValue(averageFeeList, "name", "averageValue");
+
         //上月、去年
         String startDate = filterFacade.getLastStartDateStr(filterVO.getType());
         String endDate = filterFacade.getLastEndDateStr(filterVO.getType());
@@ -140,22 +164,36 @@ public class AverageStatisticsAggregate {
         }
         //按年统计,同比环比相同
         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()));
+        //获取所有出现的科室
+        List<String> nameList = Lists.newLinkedList();
+        nameList.addAll(averageMap.keySet());
+        nameList.addAll(lastMap.keySet());
+        nameList.addAll(lastYearMap.keySet());
+        nameList = nameList
+                .stream()
+                .distinct()
+                .collect(Collectors.toList());
+
+        for (String name : nameList) {
+            AverageStatisticsDTO item = new AverageStatisticsDTO();
+            item.setName(name);
+            if (averageMap.containsKey(name)) {
+                item.setAverageValue(averageMap.get(name));
             }
-            if (lastYearMap.containsKey(item.getName())) {
-                item.setLastYearAverageValue(lastYearMap.get(item.getName()));
+            if (lastMap.containsKey(name)) {
+                item.setLastAverageValue(lastMap.get(name));
             }
-        });
-        if (averageFeeList.size() <= 10) {
-            retAverageFeeList = averageFeeList;
-        } else {
-            retAverageFeeList = averageFeeList.subList(0, 10);
+            if (lastYearMap.containsKey(name)) {
+                item.setLastYearAverageValue(lastYearMap.get(name));
+            }
+            retAverageFeeList.add(item);
+        }
+
+        if (retAverageFeeList.size() > limitCount) {
+            retAverageFeeList = retAverageFeeList.subList(0, limitCount);
         }
         return retAverageFeeList;
     }
@@ -170,9 +208,6 @@ public class AverageStatisticsAggregate {
     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(averageScoreList)) {

+ 5 - 1
src/main/java/com/diagbot/aggregate/MrStatisticsAggregate.java

@@ -68,7 +68,11 @@ public class MrStatisticsAggregate {
     @DataProvider("getLevelResultDept")
     public List<QcResultPercentDTO> getLevelResultDept(@InvokeParameter("filterVO") FilterVO filterVO) {
         List<QcResultPercentDTO> qcResultPercentList = qcresultInfoFacade.levelPercentGroupByDept(filterVO);
-        qcResultPercentList = qcResultPercentList.stream().limit(10).collect(Collectors.toList());
+        Integer limitCount = filterVO.getLimitCount();
+        qcResultPercentList = qcResultPercentList
+                .stream()
+                .limit(limitCount)
+                .collect(Collectors.toList());
         return qcResultPercentList;
     }
 

+ 10 - 7
src/main/java/com/diagbot/aggregate/ResultStatisticsAggregate.java

@@ -71,6 +71,7 @@ public class ResultStatisticsAggregate {
      */
     @DataProvider("entryCountGroupByCase")
     public List<NumDTO> entryCountGroupByCase(@InvokeParameter("filterVO") FilterVO filterVO) {
+        Integer limitCount = filterVO.getLimitCount();
         QcresultFilterVO qcresultFilterVO = new QcresultFilterVO();
         BeanUtil.copyProperties(filterVO, qcresultFilterVO);
         int mrNum = qcresultInfoFacade.resultCount(qcresultFilterVO);
@@ -118,7 +119,7 @@ public class ResultStatisticsAggregate {
         //取top10
         standardEntryNumList = standardEntryNumList
                 .stream()
-                .limit(10)
+                .limit(limitCount)
                 .collect(Collectors.toList());
 
         return standardEntryNumList;
@@ -133,6 +134,7 @@ public class ResultStatisticsAggregate {
     @DataProvider("entryCountGroupByEntry")
     public List<NumDTO> entryCountGroupByEntry(@InvokeParameter("filterVO") FilterVO filterVO) {
         DecimalFormat df = new DecimalFormat("#0.00");
+        Integer limitCount = filterVO.getLimitCount();
         List<NumDTO> numDTOList = qcresultInfoFacade.entryCountGroupByEntry(filterVO);
         if (ListUtil.isNotEmpty(numDTOList)) {
             int totle = numDTOList
@@ -159,12 +161,12 @@ public class ResultStatisticsAggregate {
             });
 
             //top9+其他
-            if (numDTOList.size() <= 10) {
+            if (numDTOList.size() <= limitCount) {
                 retList.addAll(numDTOList);
             } else {
                 int count = 0;
                 for (NumDTO numDTO : numDTOList) {
-                    if (retList.size() < 10) {
+                    if (retList.size() < limitCount - 1) {
                         retList.add(numDTO);
                         count += numDTO.getNum();
                     } else {
@@ -196,8 +198,9 @@ public class ResultStatisticsAggregate {
      * @param filterVO
      * @return
      */
-    @DataProvider("getResultDept")
-    public List<NumDTO> getResultDept(@InvokeParameter("filterVO") FilterVO filterVO) {
+    @DataProvider("entryByDept")
+    public List<NumDTO> entryByDept(@InvokeParameter("filterVO") FilterVO filterVO) {
+        Integer limitCount = filterVO.getLimitCount();
         List<NumDTO> numDTOList = behospitalInfoFacade.resultStatisticsByDept2(filterVO);
         if (ListUtil.isNotEmpty(numDTOList)) {
             int totle = numDTOList
@@ -211,14 +214,14 @@ public class ResultStatisticsAggregate {
                 result.setPercent(percent);
             });
             List<NumDTO> retList = Lists.newLinkedList();
-            if (numDTOList.size() <= 10) {
+            if (numDTOList.size() <= limitCount) {
                 retList = BeanUtil.listCopyTo(numDTOList, NumDTO.class);
             } else {
 
                 Double rate = 0d;
                 Integer num = 0;
                 for (NumDTO numDTO : numDTOList) {
-                    if (retList.size() < 9) {
+                    if (retList.size() < limitCount - 1) {
                         rate = BigDecimal.valueOf(rate)
                                 .add(BigDecimal.valueOf(Double.valueOf(numDTO.getPercent())))
                                 .doubleValue();

+ 6 - 2
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -675,14 +675,18 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
 
         BehosDTO behosDTO = new BehosDTO();
         if (behospitalInfo == null) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该病历已删除!");
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                    "该病历不存在!【hospitalId=" + hospitalId + "】【behospitalCode="
+                            + getDetailVO.getBehospitalCode() + "】");
         }
         BeanUtil.copyProperties(behospitalInfo, behosDTO);
 
         // 获取结果主表信息
         QcResultDTO qcResultDTO = qcresultInfoFacade.getByBehospitalCode(getDetailVO);
         if (qcResultDTO == null) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该病历未评分!");
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                    "该病历未评分!【hospitalId=" + hospitalId + "】【behospitalCode="
+                    + getDetailVO.getBehospitalCode() + "】");
         }
         QcResultApiDTO qcResultApiDTO = new QcResultApiDTO();
         BeanUtil.copyProperties(qcResultDTO, qcResultApiDTO);

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

@@ -4,7 +4,6 @@ import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.util.SysUserUtils;
 import com.diagbot.vo.FilterVO;
-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;
@@ -39,6 +38,9 @@ public class ConsoleFacade {
         filterVO.setStartDate(startDate);
         filterVO.setEndDate(endDate);
         filterVO.setHospitalId(hospitalId);
+        if (filterVO.getLimitCount() == null || filterVO.getLimitCount().equals(0)) {
+            filterVO.setLimitCount(10);
+        }
         try {
             Map<String, Object> invokeParams = new HashMap<>();
             invokeParams.put("filterVO", filterVO);
@@ -60,8 +62,13 @@ public class ConsoleFacade {
         Map<String, Object> retMap = new LinkedHashMap<>();
         String hospitalId = SysUserUtils.getCurrentHospitalID();
         String startDate = filterFacade.getStartDateStr(filterVO.getType(), null);
-        filterVO.setStartDate(startDate);
+        String endDate = filterFacade.getEndDateStr(filterVO.getType(), null);
         filterVO.setHospitalId(hospitalId);
+        filterVO.setStartDate(startDate);
+        filterVO.setEndDate(endDate);
+        if (filterVO.getLimitCount() == null || filterVO.getLimitCount().equals(0)) {
+            filterVO.setLimitCount(10);
+        }
         try {
             Map<String, Object> invokeParams = new HashMap<>();
             invokeParams.put("filterVO", filterVO);
@@ -82,9 +89,14 @@ public class ConsoleFacade {
     public Map<String, Object> averageStatistics(FilterVO filterVO) {
         Map<String, Object> retMap = new LinkedHashMap<>();
         String hospitalId = SysUserUtils.getCurrentHospitalID();
-        filterVO.setHospitalId(hospitalId);
         String startDate = filterFacade.getStartDateStr(filterVO.getType(), null);
+        String endDate = filterFacade.getEndDateStr(filterVO.getType(), null);
+        filterVO.setHospitalId(hospitalId);
         filterVO.setStartDate(startDate);
+        filterVO.setEndDate(endDate);
+        if (filterVO.getLimitCount() == null || filterVO.getLimitCount().equals(0)) {
+            filterVO.setLimitCount(10);
+        }
         try {
             Map<String, Object> invokeParams = new HashMap<>();
             invokeParams.put("filterVO", filterVO);

+ 30 - 9
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -129,7 +129,10 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= #{startDate}]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
         </if>
         GROUP BY
         c.msg
@@ -155,7 +158,10 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= #{startDate}]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
         </if>
         ) t2
         )
@@ -193,7 +199,10 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= #{startDate}]]>
+            <![CDATA[ and a.leave_hospital_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,
@@ -220,7 +229,10 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= #{startDate}]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
         </if>
         ) t2
         )
@@ -247,7 +259,10 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= #{startDate}]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
         </if>
         GROUP BY
         c.msg
@@ -280,7 +295,10 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= #{startDate}]]>
+            <![CDATA[ and a.leave_hospital_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,
@@ -309,7 +327,10 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= #{startDate}]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
         </if>
     </select>
 
@@ -477,7 +498,7 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
         </if>
         <if test="endDate != null and endDate != ''">
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
@@ -511,7 +532,7 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
         </if>
         <if test="endDate != null and endDate != ''">
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>

+ 2 - 6
src/main/resources/mapper/HomePageMapper.xml

@@ -158,7 +158,7 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
         </if>
         <if test="endDate != null and endDate != ''">
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
@@ -166,8 +166,6 @@
         GROUP BY
         a.beh_dept_id,
         a.beh_dept_name
-        ORDER BY
-        sum( b.behospital_day_num )/ count(*) DESC
     </select>
 
     <!-- 按科室统计平均费用 -->
@@ -190,7 +188,7 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
         </if>
         <if test="endDate != null and endDate != ''">
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
@@ -198,8 +196,6 @@
         GROUP BY
         a.beh_dept_id,
         a.beh_dept_name
-        ORDER BY
-        sum( b.total_fee )/ count(*) DESC
     </select>
 
 </mapper>

+ 9 - 6
src/main/resources/mapper/QcresultInfoMapper.xml

@@ -34,7 +34,10 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= #{startDate}]]>
+            <![CDATA[ and a.leave_hospital_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 b.grade_type = #{gradeType}
@@ -64,7 +67,7 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
         </if>
         <if test="endDate != null and endDate != ''">
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
@@ -105,7 +108,7 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
         </if>
         <if test="endDate != null and endDate != ''">
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
@@ -148,7 +151,7 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
         </if>
         <if test="endDate != null and endDate != ''">
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
@@ -184,7 +187,7 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
         </if>
         <if test="endDate != null and endDate != ''">
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
@@ -218,7 +221,7 @@
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.behospital_date >= DATE(#{startDate})]]>
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
         </if>
         <if test="endDate != null and endDate != ''">
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>