From 7797c3b20a9b41a831ec5f396e5cc916cf813edc Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 08 八月 2024 09:35:36 +0800
Subject: [PATCH] 1、通信中间件实现上行数据任务:更新物理卡和虚拟卡的剩余金额; 2、完善代码。

---
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java |  293 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 287 insertions(+), 6 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 caa045a..f2ea363 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
@@ -4,6 +4,9 @@
 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.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;
@@ -11,8 +14,8 @@
 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.IntakeQO;
-import com.dy.pipIrrStatistics.intake.qo.IntakeValueQO;
+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;
@@ -22,6 +25,7 @@
 
 import java.text.DecimalFormat;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -43,6 +47,9 @@
     @Autowired
     private RmOnHourReportLastMapper rmOnHourReportLastMapper;
 
+    @Autowired
+    private RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper;
+
     @Value("${rtu.batteryVolt}")
     private Double batteryVolt;
 
@@ -57,7 +64,7 @@
      * @param qo
      * @return
      */
-    public QueryResultVo<List<VoIntake>> getNotOnlineIntakes(IntakeQO qo) {
+    public QueryResultVo<List<VoIntake>> getNotOnlineIntakes(CommonQO qo) {
         DecimalFormat df = new DecimalFormat("0.00");
         /**
          * 琛ラ綈璧锋鏃堕棿锛屽鏋滃紑濮嬫椂闂翠负绌猴紝鍒欓粯璁や负褰撳墠鏃ユ湡
@@ -187,7 +194,7 @@
      * 鑾峰彇浠庢湭寮�杩囬榾鐨勫彇姘村彛
      * @return
      */
-    public QueryResultVo<List<VoIntake>> getNeverOpenValveIntakes(IntakeQO qo) {
+    public QueryResultVo<List<VoIntake>> getNeverOpenValveIntakes(CommonQO qo) {
 
         String timeStart = qo.getTimeStart();
         String timeStop = qo.getTimeStop();
@@ -225,7 +232,7 @@
      * @param qo
      * @return
      */
-    public QueryResultVo<List<VoIntakeOpenCount>> getOpenValveGtIntakes(IntakeValueQO qo) {
+    public QueryResultVo<List<VoIntakeOpenCount>> getOpenValveGtIntakes(IntakeCountValueQO qo) {
 
         String timeStart = qo.getTimeStart();
         String timeStop = qo.getTimeStop();
@@ -263,7 +270,7 @@
      * @param qo
      * @return
      */
-    public QueryResultVo<List<VoIntakeOpenCount>> getOpenValveLtIntakes(IntakeValueQO qo) {
+    public QueryResultVo<List<VoIntakeOpenCount>> getOpenValveLtIntakes(IntakeCountValueQO qo) {
 
         String timeStart = qo.getTimeStart();
         String timeStop = qo.getTimeStop();
@@ -296,4 +303,278 @@
         return rsVo ;
     }
 
+    /**
+     * 鏍规嵁寮�闃�绫诲瀷鑾峰彇鎿嶄綔娆℃暟
+     * @param qo
+     * @return
+     */
+    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";
+        }
+        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;
+        }
+
+        // 鐢熸垚鏌ヨ鍙傛暟
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
+
+        Integer openTypeCount = Optional.ofNullable(rmOpenCloseValveLastMapper.getCountByOpenType(params)).orElse(0);
+
+        VoCountOfOpenType vo = new VoCountOfOpenType();
+        vo.setOpenTypeName(openTypeName);
+        vo.setOpenTypeCount(openTypeCount);
+        return vo;
+    }
+
+    /**
+     * 鏍规嵁鍏抽榾绫诲瀷鑾峰彇鎿嶄綔娆℃暟
+     * @param qo
+     * @return
+     */
+    public VoCountOfCloseType getCountByCloseType(CloseTypeQo 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";
+        }
+        qo.setTimeStart(timeStart);
+        qo.setTimeStop(timeStop);
+
+        Integer closeType = qo.getCloseType();
+        String closeTypeName = "";
+        switch (closeType) {
+            case 2:
+                closeTypeName = "鍒峰崱鍏抽榾";
+                break;
+            case 4:
+                closeTypeName = "涓績绔欏叧闃�";
+                break;
+            case 5:
+                closeTypeName = "娆犺垂鍏抽榾";
+                break;
+            case 6:
+                closeTypeName = "娴侀噺璁℃晠闅滃叧闃�";
+                break;
+            case 7:
+                closeTypeName = "绱ф�ュ叧闃�";
+                break;
+            case 9:
+                closeTypeName = "鐢ㄦ埛杩滅▼鍏抽榾";
+                break;
+            case 10:
+                closeTypeName = "寮�鍏抽榾鍗″叧闃�";
+                break;
+            case 12:
+                closeTypeName = "榛戝悕鍗曞懡浠ゅ叧闃�";
+                break;
+            case 13:
+                closeTypeName = "杩滅▼瀹氭椂鍏抽榾";
+                break;
+            case 14:
+                closeTypeName = "杩滅▼瀹氶噺鍏抽榾";
+                break;
+        }
+
+        // 鐢熸垚鏌ヨ鍙傛暟
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
+        Integer closeTypeCount = Optional.ofNullable(rmOpenCloseValveLastMapper.getCountByCloseType(params)).orElse(0);
+
+        VoCountOfCloseType vo = new VoCountOfCloseType();
+        vo.setCloseTypeName(closeTypeName);
+        vo.setCloseTypeCount(closeTypeCount);
+        return vo;
+    }
+
+    /**
+     * 鎸囧畾鏃堕棿娈靛唴绱Н娴侀噺瓒呰繃鎸囧畾鍊肩殑鍙栨按鍙�
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoIntakeAccumulateAmount>> getTotalFlowGtValueIntakes(IntakeAmountValueQO qo) {
+        String timeStart = qo.getTimeStart();
+        String timeStop = qo.getTimeStop();
+        if(timeStart != null && timeStart != "") {
+            timeStart = timeStart + " 00:00:00";
+        } else {
+            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+        }
+        qo.setTimeStart(timeStart);
+
+        if(timeStop != null && timeStop != "") {
+            timeStop = timeStop + " 23:59:59";
+        }else {
+            timeStop = LocalDate.now() + " 23:59:59";
+        }
+        qo.setTimeStop(timeStop);
+
+        if (qo.getValue() == null){
+            qo.setValue(0.0);
+        }
+
+
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo);
+        Long itemTotal = rmOnHourReportHistoryMapper.getTotalFlowGtValueIntakesCount(params);
+
+        QueryResultVo<List<VoIntakeAccumulateAmount>> rsVo = new QueryResultVo<>() ;
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmOnHourReportHistoryMapper.getTotalFlowGtValueIntakes(params);
+        return rsVo ;
+    }
+
+
+    /**
+     * 鎸囧畾鏃堕棿娈靛唴鐢ㄦ按閲忚秴杩囨寚瀹氬�肩殑鍙栨按鍙�
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoIntakeAccumulateAmount>> getUseWaterGtValueIntakes(IntakeAmountValueQO qo) {
+        String timeStart = qo.getTimeStart();
+        String timeStop = qo.getTimeStop();
+        if(timeStart != null && timeStart != "") {
+            timeStart = timeStart + " 00:00:00";
+        } else {
+            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+        }
+        qo.setTimeStart(timeStart);
+
+        if(timeStop != null && timeStop != "") {
+            timeStop = timeStop + " 23:59:59";
+        }else {
+            timeStop = LocalDate.now() + " 23:59:59";
+        }
+        qo.setTimeStop(timeStop);
+
+        if (qo.getValue() == null){
+            qo.setValue(0.0);
+        }
+
+
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo);
+        Long itemTotal = rmOpenCloseValveHistoryMapper.getUseWaterGtValueIntakesCount(params);
+
+        QueryResultVo<List<VoIntakeAccumulateAmount>> rsVo = new QueryResultVo<>() ;
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmOpenCloseValveHistoryMapper.getUseWaterGtValueIntakes(params);
+        return rsVo ;
+    }
+
+
+
+    /**
+     * 鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦瓒呰繃鎸囧畾鍊肩殑鍙栨按鍙�
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoIntakeAccumulateAmount>> getExpenseGtValueIntakes(IntakeAmountValueQO qo) {
+        String timeStart = qo.getTimeStart();
+        String timeStop = qo.getTimeStop();
+        if(timeStart != null && timeStart != "") {
+            timeStart = timeStart + " 00:00:00";
+        } else {
+            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+        }
+        qo.setTimeStart(timeStart);
+
+        if(timeStop != null && timeStop != "") {
+            timeStop = timeStop + " 23:59:59";
+        }else {
+            timeStop = LocalDate.now() + " 23:59:59";
+        }
+        qo.setTimeStop(timeStop);
+
+        if (qo.getValue() == null){
+            qo.setValue(0.0);
+        }
+
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo);
+        Long itemTotal = rmOpenCloseValveHistoryMapper.getExpenseGtValueIntakesCount(params);
+
+        QueryResultVo<List<VoIntakeAccumulateAmount>> rsVo = new QueryResultVo<>() ;
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmOpenCloseValveHistoryMapper.getExpenseGtValueIntakes(params);
+        return rsVo ;
+    }
+
+
+    /**
+     * 鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱瓒呰繃鎸囧畾鍊肩殑鍙栨按鍙�
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoIntakeOpenCount>> getUseWaterDurationGtValueIntakes(IntakeCountValueQO qo) {
+        String timeStart = qo.getTimeStart();
+        String timeStop = qo.getTimeStop();
+        if(timeStart != null && timeStart != "") {
+            timeStart = timeStart + " 00:00:00";
+        } else {
+            timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString();
+        }
+        qo.setTimeStart(timeStart);
+
+        if(timeStop != null && timeStop != "") {
+            timeStop = timeStop + " 23:59:59";
+        }else {
+            timeStop = LocalDate.now() + " 23:59:59";
+        }
+        qo.setTimeStop(timeStop);
+
+
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo);
+        Long itemTotal = rmOpenCloseValveHistoryMapper.getUseWaterDurationGtValueIntakesCount(params);
+
+        QueryResultVo<List<VoIntakeOpenCount>> rsVo = new QueryResultVo<>() ;
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmOpenCloseValveHistoryMapper.getUseWaterDurationGtValueIntakes(params);
+        return rsVo ;
+    }
 }

--
Gitblit v1.8.0