From a27ef29ee2116befc9043fb34db5d3a7fecb4094 Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期一, 02 九月 2024 16:02:26 +0800
Subject: [PATCH] 优化代码 指定时间段用水量超过指定值的农户         指定时间段用水时长超过指定值的农户         指定时间段消费金额超过指定值的农户

---
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java |  116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 111 insertions(+), 5 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java
index 84ec52e..2d43649 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java
@@ -4,11 +4,11 @@
 import com.dy.common.webUtil.BaseResponse;
 import com.dy.common.webUtil.BaseResponseUtils;
 import com.dy.common.webUtil.QueryResultVo;
-import com.dy.pipIrrGlobal.voSt.VoClient;
-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.pipIrrGlobal.voSt.*;
+import com.dy.pipIrrStatistics.card.IcCardqo.CommonQO;
+import com.dy.pipIrrStatistics.client.qo.*;
+import com.dy.pipIrrStatistics.intake.qo.ClientAmountQO;
+import com.dy.pipIrrStatistics.result.StatisticlResultCode;
 import jakarta.validation.Valid;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -17,6 +17,8 @@
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 
@@ -132,4 +134,108 @@
             return BaseResponseUtils.buildException(e.getMessage()) ;
         }
     }
+
+    /**
+     * 缁熻鎸囧畾鏈堜唤鍚勫啘鎴峰悇澶╃敤姘撮噺鍙婃秷璐归噾棰�
+     * @param qo
+     * @return
+     */
+    @GetMapping(path = "/getDayAmountAndMoney")
+    @SsoAop()
+    public BaseResponse<QueryResultVo<List<VoDayClient>>> getDayAmountAndMoney(ClientAmountQO qo) {
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        String yearMonth = qo.getYearMonth();
+        if(yearMonth == null) {
+            return BaseResponseUtils.buildErrorMsg(StatisticlResultCode.YEAR_AND_MONTH_CANNOT_BE_NULL.getMessage());
+        }else {
+            yearMonth = yearMonth + "-01";
+            try {
+                Date date = dateFormat.parse(yearMonth);
+            } catch (Exception e) {
+                return BaseResponseUtils.buildErrorMsg(StatisticlResultCode.YEAR_OR_MONTH_IS_ERROR.getMessage());
+            }
+        }
+
+        try {
+            return BaseResponseUtils.buildSuccess(clientSv.getDayAmountAndMoney(qo));
+        } catch (Exception e) {
+            log.error("鑾峰彇璁板綍寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage()) ;
+        }
+    }
+
+    /**
+     * 缁熻鎸囧畾骞翠唤鍚勫啘鎴峰悇鏈堢敤姘撮噺鍙婃秷璐归噾棰�
+     * @param qo
+     * @return
+     */
+    @GetMapping(path = "/getMonthAmountAndMoney")
+    @SsoAop()
+    public BaseResponse<QueryResultVo<List<VoMonthClient>>> getMonthAmountAndMoney(ClientAmountQO qo) {
+        if(qo.getYear() == null) {
+            return BaseResponseUtils.buildErrorMsg(StatisticlResultCode.YEAR_CANNOT_BE_NULL.getMessage());
+        }
+        try {
+            return BaseResponseUtils.buildSuccess(clientSv.getMonthAmountAndMoney(qo));
+        } catch (Exception e) {
+            log.error("鑾峰彇璁板綍寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage()) ;
+        }
+    }
+
+    /**
+     * 鎸囧畾鏃堕棿娈靛唴寮�鐗╃悊鍗″啘鎴�
+     *
+     * @param qo
+     * @return
+     */
+    @GetMapping(path = "/getOpenIcCardClients")
+    @SsoAop()
+    public BaseResponse<QueryResultVo<List<VoClientOpenCardCount>>> getOpenIcCardClients(CommonQO qo) {
+        try {
+            QueryResultVo<List<VoClientOpenCardCount>> res = clientSv.getOpenIcCardClients(qo);
+            return BaseResponseUtils.buildSuccess(res);
+        }catch (Exception e){
+            log.error("鑾峰彇璁板綍寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
+    /**
+     * 鎸囧畾鏃堕棿娈靛唴姣忎釜鍐滄埛鍏呭�煎悎璁★紙鐗╃悊鍗★級
+     *
+     * @param qo
+     * @return
+     */
+    @GetMapping(path = "/getRechargeTotalClients")
+    @SsoAop()
+    public BaseResponse<QueryResultVo<List<VoClientRechargeTotal>>> getRechargeTotalClients(CommonQO qo) {
+        try {
+            QueryResultVo<List<VoClientRechargeTotal>> res = clientSv.getRechargeTotalClients(qo);
+            return BaseResponseUtils.buildSuccess(res);
+        }catch (Exception e){
+            log.error("鑾峰彇璁板綍寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
+
+    /**
+     * 鎸囧畾鏃堕棿娈靛唴鐗╃悊鍗″厖鍊奸噾棰濊秴杩囨寚瀹氬�肩殑鍐滄埛
+     *
+     * @param qo
+     * @return
+     */
+    @GetMapping(path = "/getRechargeTotalGtValueClients")
+    @SsoAop()
+    public BaseResponse<QueryResultVo<List<VoClientRechargeTotal>>> getRechargeTotalGtValueClients(RechargeTotalGtValueQo qo) {
+        try {
+            QueryResultVo<List<VoClientRechargeTotal>> res = clientSv.getRechargeTotalGtValueClients(qo);
+            return BaseResponseUtils.buildSuccess(res);
+        }catch (Exception e){
+            log.error("鑾峰彇璁板綍寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
 }

--
Gitblit v1.8.0