From b2abd25927c39e849e592f1abdc08879d8d35245 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期三, 07 五月 2025 09:48:39 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV

---
 pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/statistics/StClientAmountMonthSv.java |  167 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 167 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/statistics/StClientAmountMonthSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/statistics/StClientAmountMonthSv.java
new file mode 100644
index 0000000..a1d5d90
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/statistics/StClientAmountMonthSv.java
@@ -0,0 +1,167 @@
+package com.dy.pipIrrTemp.statistics;
+
+import com.dy.common.util.DateTime;
+import com.dy.pipIrrGlobal.daoSt.StClientAmountDayMapper;
+import com.dy.pipIrrGlobal.daoSt.StClientAmountMonthMapper;
+import com.dy.pipIrrGlobal.pojoSt.StClientAmountMonth;
+import com.dy.pipIrrGlobal.voSt.VoClientAmountStatistics;
+import com.dy.pipIrrTemp.util.StClientAmountConstant;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/12/30 09:52
+ * @Description
+ */
+
+@Slf4j
+@Service
+public class StClientAmountMonthSv {
+
+    protected StClientAmountDayMapper stClientAmountDayDao;
+
+    protected StClientAmountMonthMapper stClientAmountMonthDao;
+
+    @Autowired
+    private void setDao(StClientAmountDayMapper dao) {
+        this.stClientAmountDayDao = dao;
+    }
+
+    @Autowired
+    private void setDao(StClientAmountMonthMapper dao) {
+        this.stClientAmountMonthDao = dao;
+    }
+
+    /**
+     * 鍒犻櫎鎵�鏈�
+     * @throws Exception
+     */
+    public void deleteAllStClientAmountMonth() throws Exception {
+        stClientAmountMonthDao.deleteAll() ;
+    }
+
+    /**
+     * 杞瓨鍐滄埛鏈堝彇姘撮噺
+     *
+     * @throws Exception
+     */
+    public void statisticsClientAmountMonth() throws Exception {
+        //缁熻鍒版槰澶╋紝浠婂ぉ鐨勭粺璁℃槑鏃ラ浂鏅ㄥ畾鏃朵换鍔$粺璁�
+        Long curYm = Long.parseLong(DateTime.yyyy_MM().replaceAll("-", ""));
+        Long atMonth ;
+        for(int[] ym : StClientAmountConstant.yearMonthGrp) {
+            atMonth = Long.parseLong(ym[0] + "" + (ym[1] < 10?("0" + ym[1]):ym[1]) ) ;
+            if(atMonth <= curYm) {
+                this.doSome(ym[0], ym[1]);
+            }
+        }
+    }
+
+
+    @Transactional
+    protected void doSome(Integer statisticsYear, Integer statisticsMonth){
+        List<VoClientAmountStatistics> list = stClientAmountDayDao.statisticsByClient(statisticsYear, statisticsMonth) ;
+        if(list != null && list.size() > 0){
+            List<StClientAmountMonth> listOfMonth = stClientAmountMonthDao.selectByYear(statisticsYear) ;
+            for(VoClientAmountStatistics vo : list){
+                StClientAmountMonth po = this.getDataOfClient(listOfMonth, vo.clientId) ;
+                if(po == null){
+                    po = new StClientAmountMonth() ;
+                    po.clientId = vo.clientId ;
+                    po.year = statisticsYear ;
+                }
+                this.setValue(statisticsMonth, vo, po);
+                if(po.id == null) {
+                    stClientAmountMonthDao.insert(po);
+                }else{
+                    stClientAmountMonthDao.updateByPrimaryKeySelective(po) ;
+                }
+            }
+        }
+    }
+
+
+    private StClientAmountMonth getDataOfClient(List<StClientAmountMonth> list, Long clientId){
+        if(list != null && list.size() > 0){
+            for(StClientAmountMonth vo : list){
+                if(vo.clientId.longValue() == clientId.longValue()){
+                    //绋嬪簭閫昏緫鎺у埗涓婏紝闆嗗悎涓彧鏈変竴涓璞�
+                    return vo ;
+                }
+            }
+        }
+        return null ;
+    }
+
+    private void setValue(Integer statisticsMonth, VoClientAmountStatistics vo, StClientAmountMonth po){
+        switch (statisticsMonth) {
+            case 1:
+                po.amount1 = vo.amount;
+                po.money1 = vo.money;
+                po.times1 = vo.times;
+                break;
+            case 2:
+                po.amount2 = vo.amount;
+                po.money2 = vo.money;
+                po.times2 = vo.times;
+                break;
+            case 3:
+                po.amount3 = vo.amount;
+                po.money3 = vo.money;
+                po.times3 = vo.times;
+                break;
+            case 4:
+                po.amount4 = vo.amount;
+                po.money4 = vo.money;
+                po.times4 = vo.times;
+                break;
+            case 5:
+                po.amount5 = vo.amount;
+                po.money5 = vo.money;
+                po.times5 = vo.times;
+                break;
+            case 6:
+                po.amount6 = vo.amount;
+                po.money6 = vo.money;
+                po.times6 = vo.times;
+                break;
+            case 7:
+                po.amount7 = vo.amount;
+                po.money7 = vo.money;
+                po.times7 = vo.times;
+                break;
+            case 8:
+                po.amount8 = vo.amount;
+                po.money8 = vo.money;
+                po.times8 = vo.times;
+                break;
+            case 9:
+                po.amount9 = vo.amount;
+                po.money9 = vo.money;
+                po.times9 = vo.times;
+                break;
+            case 10:
+                po.amount10 = vo.amount;
+                po.money10 = vo.money;
+                po.times10 = vo.times;
+                break;
+            case 11:
+                po.amount11 = vo.amount;
+                po.money11 = vo.money;
+                po.times11 = vo.times;
+                break;
+            case 12:
+                po.amount12 = vo.amount;
+                po.money12 = vo.money;
+                po.times12 = vo.times;
+                break;
+        }
+    }
+
+}
+

--
Gitblit v1.8.0