Przeglądaj źródła

控制台-统计相关

zhaops 5 lat temu
rodzic
commit
76b075b5a3

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

@@ -13,5 +13,7 @@ import lombok.Setter;
 public class AverageStatisticsDTO {
     private String deptId;
     private String deptName;
+    private Integer num;
     private Double averageValue;
+    private Double totleValue;
 }

+ 8 - 5
src/main/java/com/diagbot/facade/ConsoleFacade.java

@@ -276,24 +276,27 @@ public class ConsoleFacade {
             retAverageList = BeanUtil.listCopyTo(averageList, AverageStatisticsDTO.class);
         } else {
             Double averageValue = 0d;
+            Double totleValue = 0d;
             Integer num = 0;
             for (AverageStatisticsDTO averageStatisticsDTO : averageList) {
                 if (retAverageList.size() < limitCount - 1) {
                     retAverageList.add(averageStatisticsDTO);
                 } else {
-                    averageValue = BigDecimal
-                            .valueOf(averageValue)
-                            .add(BigDecimal.valueOf(averageStatisticsDTO.getAverageValue()))
+                    totleValue = BigDecimal
+                            .valueOf(totleValue)
+                            .add(BigDecimal.valueOf(averageStatisticsDTO.getTotleValue()))
                             .doubleValue();
-                    num++;
+                    num += averageStatisticsDTO.getNum();
                 }
             }
-            averageValue = BigDecimal.valueOf(averageValue)
+            averageValue = BigDecimal.valueOf(totleValue)
                     .divide(BigDecimal.valueOf(num), 2)
                     .doubleValue();
             AverageStatisticsDTO retAverageStatistics = new AverageStatisticsDTO();
             retAverageStatistics.setDeptName("其他");
+            retAverageStatistics.setNum(num);
             retAverageStatistics.setAverageValue(averageValue);
+            retAverageStatistics.setTotleValue(totleValue);
             retAverageList.add(retAverageStatistics);
         }
         return retAverageList;

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

@@ -143,7 +143,9 @@
         SELECT
         a.beh_dept_id as deptId,
         a.beh_dept_name as deptName,
-        round( sum( b.behospital_day_num )/ count(*), 2 ) AS averageValue
+        count(*) AS num,
+        round( sum( b.behospital_day_num )/ count(*), 2 ) AS averageValue,
+        round( sum( b.behospital_day_num ), 2 ) AS totleValue
         FROM
         med_behospital_info a,
         med_home_page b
@@ -170,7 +172,9 @@
         SELECT
         a.beh_dept_id as deptId,
         a.beh_dept_name as deptName,
-        round( sum( b.total_fee )/ count(*), 2 ) AS averageValue
+        count(*) AS num,
+        round( sum( b.total_fee )/ count(*), 2 ) AS averageValue,
+        round( sum( b.total_fee ), 2 ) AS totleValue
         FROM
         med_behospital_info a,
         med_home_page b