From d5426047a2173c69c32eb70166ce5c61b54ff228 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 26 十二月 2024 15:46:34 +0800
Subject: [PATCH] 1、实现农户IC卡充值日、月、年自动化统计; 2、实现农户充值日、月、年自动化统计; 3、部分实现农户IC卡充值日、月、年自动化统计; 4、部分实现农户充值日、月、年自动化统计。

---
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StChargeByClientSv.java |  362 +++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 320 insertions(+), 42 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StChargeByClientSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StChargeByClientSv.java
index c732e8c..86036d6 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StChargeByClientSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StChargeByClientSv.java
@@ -1,8 +1,14 @@
 package com.dy.pipIrrStatistics.statistics;
 
-import com.dy.pipIrrGlobal.pojoSt.StIntakeAmountMonth;
-import com.dy.pipIrrGlobal.pojoSt.StIntakeAmountYear;
-import com.dy.pipIrrGlobal.voSt.VoIntakeAmountStatistics;
+import com.dy.pipIrrGlobal.daoSe.SeRechargeHistoryMapper;
+import com.dy.pipIrrGlobal.daoSt.StRechargeClientDayMapper;
+import com.dy.pipIrrGlobal.daoSt.StRechargeClientMonthMapper;
+import com.dy.pipIrrGlobal.daoSt.StRechargeClientYearMapper;
+import com.dy.pipIrrGlobal.pojoSt.StRechargeClientDay;
+import com.dy.pipIrrGlobal.pojoSt.StRechargeClientMonth;
+import com.dy.pipIrrGlobal.pojoSt.StRechargeClientYear;
+import com.dy.pipIrrGlobal.voSt.VoClientRechargeStatistics;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -10,57 +16,329 @@
 
 /**
  * @Author: liurunyu
- * @Date: 2024/12/23 14:54
+ * @Date: 2024/12/23 14:53
  * @Description
  */
 @Component
 public class StChargeByClientSv {
+
+    @Autowired
+    protected SeRechargeHistoryMapper seRechargeHistoryMapper;
+
+    @Autowired
+    protected StRechargeClientDayMapper stRechargeClientDayMapper;
+
+    @Autowired
+    protected StRechargeClientMonthMapper stRechargeClientMonthMapper;
+
+    @Autowired
+    protected StRechargeClientYearMapper stRechargeClientYearMapper;
+
+
     /**
-     * 鏈堢粺璁�---婕忔崯
+     * 鏃ョ粺璁�
      */
     @Transactional
-    protected void statisticsMonth(Integer statisticsYear, Integer statisticsMonth, Long statisticsStartId, Long statisticsEndId){
-//        List<VoIntakeAmountStatistics> list = rmIntakeAmountDayDao.statisticsByIntake(statisticsStartId, statisticsEndId) ;
-//        if(list != null && list.size() > 0){
-//            for(VoIntakeAmountStatistics vo : list){
-//                StIntakeAmountMonth po = this.stIntakeAmountMonthDao.selectByIntakeIdAndYearAndMonth(vo.intakeId, statisticsYear, statisticsMonth) ;
-//                if(po == null){
-//                    po = new StIntakeAmountMonth() ;
-//                }
-//                po.intakeId = vo.intakeId ;
-//                po.year = statisticsYear ;
-//                po.month = statisticsMonth ;
-//                po.amount = vo.amount;
-//                if(po.id == null) {
-//                    stIntakeAmountMonthDao.insert(po);
-//                }else{
-//                    stIntakeAmountMonthDao.updateByPrimaryKey(po) ;
-//                }
-//            }
-//        }
+    protected void statisticsDay(Integer statisticsYear, Integer statisticsMonth, Integer statisticsDay, Long statisticsStartId, Long statisticsEndId){
+        //浠ョ敤姘存埛涓哄崟浣嶇粺璁℃煇涓�鏃ョ殑鎵�鏈夊厖鍊艰褰�
+        List<VoClientRechargeStatistics> list = seRechargeHistoryMapper.statisticsByClient(statisticsStartId, statisticsEndId) ;
+        if(list != null && list.size() > 0){
+            for(VoClientRechargeStatistics vo : list){
+                StRechargeClientDay po = this.stRechargeClientDayMapper.selectByClientAndYearAndMonth(vo.clientId, statisticsYear, statisticsMonth) ;
+                if(po == null){
+                    po = new StRechargeClientDay() ;
+                    po.clientId = vo.clientId ;
+                    po.year = statisticsYear ;
+                    po.month = statisticsMonth ;
+                }
+                this.setValueOfDayOfMonth(statisticsDay, vo, po);
+                if(po.id == null) {
+                    stRechargeClientDayMapper.insert(po);
+                }else{
+                    stRechargeClientDayMapper.updateByPrimaryKeySelective(po) ;
+                }
+            }
+        }
     }
 
     /**
-     * 骞寸粺璁�---婕忔崯
+     * 鏈堢粺璁�
+     */
+    @Transactional
+    protected void statisticsMonth(Integer statisticsYear, Integer statisticsMonth){
+        //浠ョ敤姘存埛涓哄崟浣嶇粺璁℃煇涓�鏈堢殑鎵�鏈夊厖鍊艰褰�
+        List<VoClientRechargeStatistics> list = stRechargeClientDayMapper.statisticsByClient(statisticsYear, statisticsMonth) ;
+        if(list != null && list.size() > 0){
+            for(VoClientRechargeStatistics vo : list){
+                StRechargeClientMonth po = this.stRechargeClientMonthMapper.selectByClientAndYear(vo.clientId, statisticsYear) ;
+                if(po == null){
+                    po = new StRechargeClientMonth() ;
+                    po.clientId = vo.clientId ;
+                    po.year = statisticsYear ;
+                }
+                this.setValueOfMonthOfYear(statisticsMonth, vo, po);
+                if(po.id == null) {
+                    stRechargeClientMonthMapper.insert(po);
+                }else{
+                    stRechargeClientMonthMapper.updateByPrimaryKeySelective(po) ;
+                }
+            }
+        }
+    }
+
+    /**
+     * 骞寸粺璁�
      */
     @Transactional
     protected void statisticsYear(Integer statisticsYear){
-//        List<VoIntakeAmountStatistics> list = stIntakeAmountMonthDao.statisticsByIntake(statisticsYear) ;
-//        if(list != null && list.size() > 0){
-//            for(VoIntakeAmountStatistics vo : list){
-//                StIntakeAmountYear po = stIntakeAmountYearDao.selectByIntakeIdAndYear(vo.intakeId, statisticsYear) ;
-//                if(po == null){
-//                    po = new StIntakeAmountYear() ;
-//                }
-//                po.intakeId = vo.intakeId ;
-//                po.year = statisticsYear ;
-//                po.amount = vo.amount;
-//                if(po.id == null){
-//                    stIntakeAmountYearDao.insert(po) ;
-//                }else{
-//                    stIntakeAmountYearDao.updateByPrimaryKey(po) ;
-//                }
-//            }
-//        }
+        //浠ョ敤姘存埛涓哄崟浣嶇粺璁℃煇涓�骞寸殑鎵�鏈夊厖鍊艰褰�
+        List<VoClientRechargeStatistics> list = stRechargeClientMonthMapper.statisticsByClient(statisticsYear) ;
+        if(list != null && list.size() > 0){
+            for(VoClientRechargeStatistics vo : list){
+                StRechargeClientYear po = this.stRechargeClientYearMapper.selectByClientAndYear(vo.clientId, statisticsYear) ;
+                if(po == null){
+                    po = new StRechargeClientYear() ;
+                    po.clientId = vo.clientId ;
+                    po.year = statisticsYear ;
+                }
+                this.setValueOfYear(vo, po);
+                if(po.id == null) {
+                    stRechargeClientYearMapper.insert(po);
+                }else{
+                    stRechargeClientYearMapper.updateByPrimaryKeySelective(po) ;
+                }
+            }
+        }
+    }
+
+    private void setValueOfDayOfMonth(Integer statisticsDay, VoClientRechargeStatistics vo, StRechargeClientDay po){
+        switch (statisticsDay) {
+            case 1:
+                po.amount1 = vo.amount;
+                po.gift1 = vo.gift;
+                po.times1 = vo.times;
+                break;
+            case 2:
+                po.amount2 = vo.amount;
+                po.gift2 = vo.gift;
+                po.times2 = vo.times;
+                break;
+            case 3:
+                po.amount3 = vo.amount;
+                po.gift3 = vo.gift;
+                po.times3 = vo.times;
+                break;
+            case 4:
+                po.amount4 = vo.amount;
+                po.gift4 = vo.gift;
+                po.times4 = vo.times;
+                break;
+            case 5:
+                po.amount5 = vo.amount;
+                po.gift5 = vo.gift;
+                po.times5 = vo.times;
+                break;
+            case 6:
+                po.amount6 = vo.amount;
+                po.gift6 = vo.gift;
+                po.times6 = vo.times;
+                break;
+            case 7:
+                po.amount7 = vo.amount;
+                po.gift7 = vo.gift;
+                po.times7 = vo.times;
+                break;
+            case 8:
+                po.amount8 = vo.amount;
+                po.gift8 = vo.gift;
+                po.times8 = vo.times;
+                break;
+            case 9:
+                po.amount9 = vo.amount;
+                po.gift9 = vo.gift;
+                po.times9 = vo.times;
+                break;
+            case 10:
+                po.amount10 = vo.amount;
+                po.gift10 = vo.gift;
+                po.times10 = vo.times;
+                break;
+            case 11:
+                po.amount11 = vo.amount;
+                po.gift11 = vo.gift;
+                po.times11 = vo.times;
+                break;
+            case 12:
+                po.amount12 = vo.amount;
+                po.gift12 = vo.gift;
+                po.times12 = vo.times;
+                break;
+            case 13:
+                po.amount13 = vo.amount;
+                po.gift13 = vo.gift;
+                po.times13 = vo.times;
+                break;
+            case 14:
+                po.amount14 = vo.amount;
+                po.gift14 = vo.gift;
+                po.times14 = vo.times;
+                break;
+            case 15:
+                po.amount15 = vo.amount;
+                po.gift15 = vo.gift;
+                po.times15 = vo.times;
+                break;
+            case 16:
+                po.amount16 = vo.amount;
+                po.gift16 = vo.gift;
+                po.times16 = vo.times;
+                break;
+            case 17:
+                po.amount17 = vo.amount;
+                po.gift17 = vo.gift;
+                po.times17 = vo.times;
+                break;
+            case 18:
+                po.amount18 = vo.amount;
+                po.gift18 = vo.gift;
+                po.times18 = vo.times;
+                break;
+            case 19:
+                po.amount19 = vo.amount;
+                po.gift19 = vo.gift;
+                po.times19 = vo.times;
+                break;
+            case 20:
+                po.amount20 = vo.amount;
+                po.gift20 = vo.gift;
+                po.times20 = vo.times;
+                break;
+            case 21:
+                po.amount21 = vo.amount;
+                po.gift21 = vo.gift;
+                po.times21 = vo.times;
+                break;
+            case 22:
+                po.amount22 = vo.amount;
+                po.gift22 = vo.gift;
+                po.times22 = vo.times;
+                break;
+            case 23:
+                po.amount23 = vo.amount;
+                po.gift23 = vo.gift;
+                po.times23 = vo.times;
+                break;
+            case 24:
+                po.amount24 = vo.amount;
+                po.gift24 = vo.gift;
+                po.times24 = vo.times;
+                break;
+            case 25:
+                po.amount25 = vo.amount;
+                po.gift25 = vo.gift;
+                po.times25 = vo.times;
+                break;
+            case 26:
+                po.amount26 = vo.amount;
+                po.gift26 = vo.gift;
+                po.times26 = vo.times;
+                break;
+            case 27:
+                po.amount27 = vo.amount;
+                po.gift27 = vo.gift;
+                po.times27 = vo.times;
+                break;
+            case 28:
+                po.amount28 = vo.amount;
+                po.gift28 = vo.gift;
+                po.times28 = vo.times;
+                break;
+            case 29:
+                po.amount29 = vo.amount;
+                po.gift29 = vo.gift;
+                po.times29 = vo.times;
+                break;
+            case 30:
+                po.amount30 = vo.amount;
+                po.gift30 = vo.gift;
+                po.times30 = vo.times;
+                break;
+            case 31:
+                po.amount31 = vo.amount;
+                po.gift31 = vo.gift;
+                po.times31 = vo.times;
+                break;
+        }
+    }
+
+    private void setValueOfMonthOfYear(Integer statisticsMonth, VoClientRechargeStatistics vo, StRechargeClientMonth po){
+        switch (statisticsMonth) {
+            case 1:
+                po.amount1 = vo.amount;
+                po.gift1 = vo.gift;
+                po.times1 = vo.times;
+                break;
+            case 2:
+                po.amount2 = vo.amount;
+                po.gift2 = vo.gift;
+                po.times2 = vo.times;
+                break;
+            case 3:
+                po.amount3 = vo.amount;
+                po.gift3 = vo.gift;
+                po.times3 = vo.times;
+                break;
+            case 4:
+                po.amount4 = vo.amount;
+                po.gift4 = vo.gift;
+                po.times4 = vo.times;
+                break;
+            case 5:
+                po.amount5 = vo.amount;
+                po.gift5 = vo.gift;
+                po.times5 = vo.times;
+                break;
+            case 6:
+                po.amount6 = vo.amount;
+                po.gift6 = vo.gift;
+                po.times6 = vo.times;
+                break;
+            case 7:
+                po.amount7 = vo.amount;
+                po.gift7 = vo.gift;
+                po.times7 = vo.times;
+                break;
+            case 8:
+                po.amount8 = vo.amount;
+                po.gift8 = vo.gift;
+                po.times8 = vo.times;
+                break;
+            case 9:
+                po.amount9 = vo.amount;
+                po.gift9 = vo.gift;
+                po.times9 = vo.times;
+                break;
+            case 10:
+                po.amount10 = vo.amount;
+                po.gift10 = vo.gift;
+                po.times10 = vo.times;
+                break;
+            case 11:
+                po.amount11 = vo.amount;
+                po.gift11 = vo.gift;
+                po.times11 = vo.times;
+                break;
+            case 12:
+                po.amount12 = vo.amount;
+                po.gift12 = vo.gift;
+                po.times12 = vo.times;
+                break;
+        }
+    }
+
+    private void setValueOfYear(VoClientRechargeStatistics vo, StRechargeClientYear po){
+        po.amount = vo.amount;
+        po.gift = vo.gift;
+        po.times = vo.times;
     }
 }

--
Gitblit v1.8.0