From b5ef534819e9d1cbcbb138e4cf58acb6a5d7ca6c Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期三, 28 八月 2024 15:17:47 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV

---
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java |  228 ++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 171 insertions(+), 57 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java
index 9357183..1b116c0 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java
@@ -1,22 +1,9 @@
 package com.dy.pipIrrStatistics.intake;
 
 import com.dy.common.webUtil.QueryResultVo;
-import com.dy.pipIrrGlobal.daoRm.RmOnHourReportHistoryMapper;
-import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveHistoryMapper;
-import com.dy.pipIrrGlobal.daoRm.RmOnHourReportLastMapper;
-import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveLastMapper;
+import com.dy.pipIrrGlobal.daoRm.*;
 import com.dy.pipIrrGlobal.voSt.*;
 import com.dy.pipIrrStatistics.intake.qo.*;
-import com.dy.pipIrrGlobal.voSt.VoBatteryVolt;
-import com.dy.pipIrrGlobal.voSt.VoCumulativeFlow;
-import com.dy.pipIrrGlobal.voSt.VoIntake;
-import com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount;
-import com.dy.pipIrrGlobal.voSt.VoSignalIntensity;
-import com.dy.pipIrrStatistics.intake.qo.BatteryVoltQO;
-import com.dy.pipIrrStatistics.intake.qo.CumulativeFlowQO;
-import com.dy.pipIrrStatistics.intake.qo.IntakeCountValueQO;
-import com.dy.pipIrrStatistics.intake.qo.CommonQO;
-import com.dy.pipIrrStatistics.intake.qo.SignalIntensityQO;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.common.utils.PojoUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,8 +11,10 @@
 import org.springframework.stereotype.Service;
 
 import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
-import java.time.LocalDateTime;
+import java.util.Calendar;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -46,9 +35,13 @@
     private RmOpenCloseValveHistoryMapper rmOpenCloseValveHistoryMapper;
     @Autowired
     private RmOnHourReportLastMapper rmOnHourReportLastMapper;
-
     @Autowired
     private RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper;
+
+    @Autowired
+    private RmIntakeAmountDayMapper rmIntakeAmountDayMapper;
+    @Autowired
+    private RmLossDayLastMapper rmLossDayLastMapper;
 
     @Value("${rtu.batteryVolt}")
     private Double batteryVolt;
@@ -71,13 +64,16 @@
          */
         String timeStart = qo.getTimeStart();
         String timeStop = qo.getTimeStop();
-        if(timeStart != null) {
-            timeStart = timeStart + " 00:00:00";
-        }else {
-            timeStart = LocalDate.now() + " 00:00:00";
-        }
+
         if(timeStop != null) {
             timeStop = timeStop + " 23:59:59";
+            if(timeStart != null) {
+                timeStart = timeStart + " 00:00:00";
+            }else {
+                timeStart = LocalDate.now() + " 00:00:00";
+            }
+        }else {
+            timeStart = null;
         }
         qo.setTimeStart(timeStart);
         qo.setTimeStop(timeStop);
@@ -201,7 +197,7 @@
         if(timeStart != null && timeStart != "") {
             timeStart = timeStart + " 00:00:00";
         } else {
-            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+            timeStart = LocalDate.now() + " 00:00:00";
         }
         qo.setTimeStart(timeStart);
 
@@ -240,7 +236,7 @@
         if(timeStart != null && timeStart != "") {
             timeStart = timeStart + " 00:00:00";
         } else {
-            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+            timeStart = LocalDate.now() + " 00:00:00";
         }
         qo.setTimeStart(timeStart);
 
@@ -279,7 +275,7 @@
         if(timeStart != null && timeStart != "") {
             timeStart = timeStart + " 00:00:00";
         } else {
-            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+            timeStart = LocalDate.now() + " 00:00:00";
         }
         qo.setTimeStart(timeStart);
 
@@ -313,39 +309,47 @@
      */
     public VoCountOfOpenType getCountByOpenType(OpenTypeQO qo) {
         /**
-         * 琛ラ綈璧锋鏃堕棿锛屽鏋滃紑濮嬫椂闂翠负绌猴紝鍒欓粯璁や负褰撳墠鏃ユ湡
+         * 琛ラ綈璧锋鏃堕棿锛屽鏋滃紑濮嬫椂闂翠负绌猴紝鍒欓粯璁や负褰撳墠鏃ユ湡锛屽鏋滅粨鏉熸椂闂翠负绌猴紝鍒欐煡璇㈡椂闂翠负绌�
          */
         String timeStart = qo.getTimeStart();
         String timeStop = qo.getTimeStop();
-        if(timeStart != null) {
-            timeStart = timeStart + " 00:00:00";
-        }else {
-            timeStart = LocalDate.now() + " 00:00:00";
-        }
         if(timeStop != null) {
             timeStop = timeStop + " 23:59:59";
+            if(timeStart != null) {
+                timeStart = timeStart + " 00:00:00";
+            }else {
+                timeStart = LocalDate.now() + " 00:00:00";
+            }
+        }else {
+            timeStart = null;
         }
         qo.setTimeStart(timeStart);
         qo.setTimeStop(timeStop);
 
         Integer openType = qo.getOpenType();
         String openTypeName = "";
-        switch (openType) {
-            case 1:
-                openTypeName = "鍒峰崱寮�闃�";
-                break;
-            case 3:
-                openTypeName = "涓績绔欏紑闃�";
-                break;
-            case 8:
-                openTypeName = "鐢ㄦ埛杩滅▼寮�闃�";
-                break;
-            case 11:
-                openTypeName = "寮�鍏抽榾鍗″紑闃�";
-                break;
-            case 13:
-                openTypeName = "寮�鍏抽榾鍗″紑闃�";
-                break;
+        if (openType == null){
+            openTypeName = "鏈煡";
+        }else {
+            switch (openType) {
+                case 1:
+                    openTypeName = "鍒峰崱寮�闃�";
+                    break;
+                case 3:
+                    openTypeName = "涓績绔欏紑闃�";
+                    break;
+                case 8:
+                    openTypeName = "鐢ㄦ埛杩滅▼寮�闃�";
+                    break;
+                case 11:
+                    openTypeName = "寮�鍏抽榾鍗″紑闃�";
+                    break;
+                case 13:
+                    openTypeName = "寮�鍏抽榾鍗″紑闃�";
+                    break;
+                default:
+                    openTypeName = "鏈煡";
+            }
         }
 
         // 鐢熸垚鏌ヨ鍙傛暟
@@ -437,7 +441,7 @@
         if(timeStart != null && timeStart != "") {
             timeStart = timeStart + " 00:00:00";
         } else {
-            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+            timeStart = LocalDate.now() + " 00:00:00";
         }
         qo.setTimeStart(timeStart);
 
@@ -465,7 +469,6 @@
         return rsVo ;
     }
 
-
     /**
      * 鎸囧畾鏃堕棿娈靛唴鐢ㄦ按閲忚秴杩囨寚瀹氬�肩殑鍙栨按鍙�
      * @param qo
@@ -477,7 +480,7 @@
         if(timeStart != null && timeStart != "") {
             timeStart = timeStart + " 00:00:00";
         } else {
-            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+            timeStart = LocalDate.now() + " 00:00:00";
         }
         qo.setTimeStart(timeStart);
 
@@ -492,7 +495,6 @@
             qo.setValue(0.0);
         }
 
-
         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo);
         Long itemTotal = rmOpenCloseValveHistoryMapper.getUseWaterGtValueIntakesCount(params);
 
@@ -505,8 +507,6 @@
         return rsVo ;
     }
 
-
-
     /**
      * 鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦瓒呰繃鎸囧畾鍊肩殑鍙栨按鍙�
      * @param qo
@@ -518,7 +518,7 @@
         if(timeStart != null && timeStart != "") {
             timeStart = timeStart + " 00:00:00";
         } else {
-            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+            timeStart = LocalDate.now() + " 00:00:00";
         }
         qo.setTimeStart(timeStart);
 
@@ -545,7 +545,6 @@
         return rsVo ;
     }
 
-
     /**
      * 鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱瓒呰繃鎸囧畾鍊肩殑鍙栨按鍙�
      * @param qo
@@ -557,7 +556,7 @@
         if(timeStart != null && timeStart != "") {
             timeStart = timeStart + " 00:00:00";
         } else {
-            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+            timeStart = LocalDate.now() + " 00:00:00";
         }
         qo.setTimeStart(timeStart);
 
@@ -592,7 +591,7 @@
         if(timeStart != null && timeStart != "") {
             timeStart = timeStart + " 00:00:00";
         } else {
-            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+            timeStart = LocalDate.now() + " 00:00:00";
         }
         qo.setTimeStart(timeStart);
 
@@ -627,7 +626,7 @@
         if(timeStart != null && timeStart != "") {
             timeStart = timeStart + " 00:00:00";
         } else {
-            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+            timeStart = LocalDate.now() + " 00:00:00";
         }
         qo.setTimeStart(timeStart);
 
@@ -650,4 +649,119 @@
         rsVo.obj = rmOpenCloseValveHistoryMapper.getNoOpenHaveCloseIntakes(params);
         return rsVo ;
     }
+
+    /**
+     * 缁熻鎸囧畾鏈堜唤鍚勫ぉ鐢ㄦ按閲�
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoDayIntakeAmount>> getDayIntakeAmount(IntakeAmountQO qo) throws ParseException {
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        String yearMonth = qo.getYearMonth();
+        yearMonth = yearMonth + "-01";
+        yearMonth = dateFormat.format(dateFormat.parse(yearMonth));
+
+        Integer year = Integer.parseInt(yearMonth.substring(0,4));
+        Integer month = Integer.parseInt(yearMonth.substring(5,7));
+        qo.setYear(year);
+        qo.setMonth(month);
+
+        // 鐢熸垚鏌ヨ鍙傛暟
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
+
+        // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟
+        Long itemTotal = Optional.ofNullable(rmIntakeAmountDayMapper.getDayIntakeAmountCount(params)).orElse(0L);
+
+        QueryResultVo<List<VoDayIntakeAmount>> rsVo = new QueryResultVo<>() ;
+
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmIntakeAmountDayMapper.getDayIntakeAmount(params);
+        return rsVo ;
+    }
+
+    /**
+     * 缁熻鎸囧畾骞翠唤鍚勬湀鐢ㄦ按閲�
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoMonthAmount>> getMonthIntakeAmount(IntakeAmountQO qo) {
+        Calendar calendar = Calendar.getInstance();
+        Integer year = Optional.ofNullable(qo.getYear()).orElse(calendar.get(Calendar.YEAR));
+        qo.setYear(year);
+
+        // 鐢熸垚鏌ヨ鍙傛暟
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
+
+        // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟
+        Long itemTotal = Optional.ofNullable(rmIntakeAmountDayMapper.getMonthIntakeAmountCount(params)).orElse(0L);
+
+        QueryResultVo<List<VoMonthAmount>> rsVo = new QueryResultVo<>() ;
+
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmIntakeAmountDayMapper.getMonthIntakeAmount(params);
+        return rsVo ;
+    }
+
+    /**
+     * 缁熻鎸囧畾鏈堜唤鍚勫ぉ婕忔崯閲�
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoDayLoss>> getDayLossAmount(IntakeAmountQO qo) throws ParseException {
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        String yearMonth = qo.getYearMonth();
+        yearMonth = yearMonth + "-01";
+        yearMonth = dateFormat.format(dateFormat.parse(yearMonth));
+        Integer year = Integer.parseInt(yearMonth.substring(0,4));
+        Integer month = Integer.parseInt(yearMonth.substring(5,7));
+        qo.setYear(year);
+        qo.setMonth(month);
+
+        // 鐢熸垚鏌ヨ鍙傛暟
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
+
+        // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟
+        Long itemTotal = Optional.ofNullable(rmLossDayLastMapper.getDayLossAmountCount(params)).orElse(0L);
+
+        QueryResultVo<List<VoDayLoss>> rsVo = new QueryResultVo<>() ;
+
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmLossDayLastMapper.getDayLossAmount(params);
+        return rsVo ;
+    }
+
+    /**
+     * 缁熻鎸囧畾骞翠唤鍚勬湀婕忔崯閲�
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoMonthAmount>> getMonthLossAmount(IntakeAmountQO qo) {
+        Calendar calendar = Calendar.getInstance();
+        Integer year = Optional.ofNullable(qo.getYear()).orElse(calendar.get(Calendar.YEAR));
+        qo.setYear(year);
+
+        // 鐢熸垚鏌ヨ鍙傛暟
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
+
+        // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟
+        Long itemTotal = Optional.ofNullable(rmLossDayLastMapper.getMonthLossAmountCount(params)).orElse(0L);
+
+        QueryResultVo<List<VoMonthAmount>> rsVo = new QueryResultVo<>() ;
+
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmLossDayLastMapper.getMonthLossAmount(params);
+        return rsVo ;
+    }
 }

--
Gitblit v1.8.0