From 471cf8ec2f209183fe3b98499b3d32fb19ac927e Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期五, 09 八月 2024 15:35:45 +0800
Subject: [PATCH] 2024-08-09 朱宝民 统计指定月份各农户各天用水量及消费金额、统计指定年份各农户各月用水量及消费金额

---
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java |  179 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 179 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java
index 13e5a35..3314c6b 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java
@@ -1,15 +1,24 @@
 package com.dy.pipIrrStatistics.client;
 
 import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.daoRm.RmClientAmountDayLastMapper;
 import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveHistoryMapper;
 import com.dy.pipIrrGlobal.voSt.VoClient;
+import com.dy.pipIrrGlobal.voSt.VoDayClient;
+import com.dy.pipIrrGlobal.voSt.VoMonthClient;
+import com.dy.pipIrrStatistics.client.qo.AmountSpentQO;
 import com.dy.pipIrrStatistics.client.qo.OpenCountQO;
+import com.dy.pipIrrStatistics.client.qo.WaterConsumptionQO;
+import com.dy.pipIrrStatistics.client.qo.WaterDurationQO;
+import com.dy.pipIrrStatistics.intake.qo.ClientAmountQO;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.common.utils.PojoUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.ParseException;
 import java.time.LocalDate;
+import java.util.Calendar;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -26,6 +35,9 @@
 public class ClientSv {
     @Autowired
     private RmOpenCloseValveHistoryMapper rmOpenCloseValveHistoryMapper;
+
+    @Autowired
+    private RmClientAmountDayLastMapper rmClientAmountDayLastMapper;
 
     /**
      * 鑾峰彇鎸囧畾鏃堕棿娈靛唴寮�闃�娆℃暟瓒呰繃鎸囧畾鍊肩殑鍐滄埛
@@ -102,4 +114,171 @@
         rsVo.obj = rmOpenCloseValveHistoryMapper.getSmallOpenCountClients(params);
         return rsVo ;
     }
+
+    /**
+     * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按閲忚秴杩囨寚瀹氬�肩殑鍐滄埛
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoClient>> getLargeWaterConsumptionClients(WaterConsumptionQO 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);
+
+        // 鐢熸垚鏌ヨ鍙傛暟
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
+
+        // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟
+        Long itemTotal = Optional.ofNullable(rmOpenCloseValveHistoryMapper.getLargeWaterConsumptionClientsCount(params)).orElse(0L);
+
+        QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ;
+
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmOpenCloseValveHistoryMapper.getLargeWaterConsumptionClients(params);
+        return rsVo ;
+    }
+
+    /**
+     * 鑾峰彇鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦瓒呰繃鎸囧畾鍊肩殑鍐滄埛
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoClient>> getLargeAmountSpentClients(AmountSpentQO 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);
+
+        // 鐢熸垚鏌ヨ鍙傛暟
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
+
+        // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟
+        Long itemTotal = Optional.ofNullable(rmOpenCloseValveHistoryMapper.getLargeAmountSpentClientsCount(params)).orElse(0L);
+
+        QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ;
+
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmOpenCloseValveHistoryMapper.getLargeAmountSpentClients(params);
+        return rsVo ;
+    }
+
+    /**
+     * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱瓒呰繃鎸囧畾鍊肩殑鍐滄埛
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoClient>> getLargeWaterDurationClients(WaterDurationQO 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);
+
+        // 鐢熸垚鏌ヨ鍙傛暟
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
+
+        // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟
+        Long itemTotal = Optional.ofNullable(rmOpenCloseValveHistoryMapper.getLargeWaterDurationClientsCount(params)).orElse(0L);
+
+        QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ;
+
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmOpenCloseValveHistoryMapper.getLargeWaterDurationClients(params);
+        return rsVo ;
+    }
+
+    /**
+     * 缁熻鎸囧畾鏈堜唤鍚勫啘鎴峰悇澶╃敤姘撮噺鍙婃秷璐归噾棰�
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoDayClient>> getDayAmountAndMoney(ClientAmountQO qo) throws ParseException {
+        Integer year = qo.getYearMonth().getYear();
+        Integer month = qo.getYearMonth().getMonthValue();
+        qo.setYear(year);
+        qo.setMonth(month);
+
+        // 鐢熸垚鏌ヨ鍙傛暟
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
+
+        // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟
+        Long itemTotal = Optional.ofNullable(rmClientAmountDayLastMapper.getDayAmountAndMoneyCount(params)).orElse(0L);
+
+        QueryResultVo<List<VoDayClient>> rsVo = new QueryResultVo<>() ;
+
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmClientAmountDayLastMapper.getDayAmountAndMoney(params);
+        return rsVo ;
+    }
+
+    /**
+     * 缁熻鎸囧畾骞翠唤鍚勫啘鎴峰悇鏈堢敤姘撮噺鍙婃秷璐归噾棰�
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoMonthClient>> getMonthAmountAndMoney(ClientAmountQO 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(rmClientAmountDayLastMapper.getMonthAmountAndMoneyCount(params)).orElse(0L);
+
+        QueryResultVo<List<VoMonthClient>> rsVo = new QueryResultVo<>() ;
+
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmClientAmountDayLastMapper.getMonthAmountAndMoney(params);
+        return rsVo ;
+    }
 }

--
Gitblit v1.8.0