From cdc35c146d7054d58e273aec3035387f324d6ac3 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期日, 27 四月 2025 14:12:26 +0800
Subject: [PATCH] MyBatis拦截器测试修改

---
 pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeIntakeAmountSv.java |  120 ++++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 81 insertions(+), 39 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeIntakeAmountSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeIntakeAmountSv.java
index fcebfd9..f7c8286 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeIntakeAmountSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeIntakeAmountSv.java
@@ -6,6 +6,8 @@
 import com.dy.pipIrrGlobal.pojoSt.StIntakeAmountMonth;
 import com.dy.pipIrrGlobal.pojoSt.StIntakeAmountYear;
 import com.dy.pipIrrGlobal.voSt.VoIntake;
+import com.dy.pipIrrGlobal.voTmp.VoRmIntakeAmountDay;
+import com.dy.pipIrrTemp.util.StClientAmountConstant;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -26,8 +28,6 @@
 public class ChSomeIntakeAmountSv {
 
     private ChangeMapper dao;
-
-    private static final int IntakeAmountDayFlag = 800 ;//2024-12-14缁熻鍏冭皨鏁版嵁搴撳疄鏃舵暟鎹紝鍙戠幇澶т簬800鐨勬纭殑鏁版嵁涓嶅瓨鍦紝鑰屽皬浜�800鐨勫熀鏈负姝g‘鏁版嵁
 
     @Autowired
     private void setDao(ChangeMapper dao){
@@ -57,11 +57,11 @@
                     for(RmIntakeAmountDay ad : adList){
                         if(lastAd == null){
                             lastAd = ad ;
-                            if(lastAd.amount != null && lastAd.amount > IntakeAmountDayFlag){
+                            if(lastAd.amount != null && lastAd.amount > StClientAmountConstant.IntakeAmountDayFlag){
                                 this.doUpdateOneIntakeAmountDay(lastAd.id, 0.0);
                             }
                         }else{
-                            if(ad.amount != null && ad.amount > IntakeAmountDayFlag){
+                            if(ad.amount != null && ad.amount > StClientAmountConstant.IntakeAmountDayFlag){
                                 if(ad.totalAmountLast != null && lastAd.totalAmountLast != null){
                                     //閲嶆柊璁$畻鏃ュ彇姘撮噺
                                     ad.amount = ad.totalAmountLast - lastAd.totalAmountLast;
@@ -74,10 +74,10 @@
                                         );
                                         ad.amount = 0.0 ;
                                     }
-                                    if(ad.amount > IntakeAmountDayFlag){
+                                    if(ad.amount > StClientAmountConstant.IntakeAmountDayFlag){
                                         //璁$畻鏃ュ彇姘撮噺鍚庯紝浠嶅ぇ浜嶪ntakeAmountDayFlag
                                         log.info("鍑虹幇璋冩暣鍚庣殑鏃ュ彇姘撮噺浠嶅ぇ浜�"
-                                                + IntakeAmountDayFlag
+                                                + StClientAmountConstant.IntakeAmountDayFlag
                                                 + "鐨勬儏鍐碉紝鏁版嵁id=" + ad.id
                                                 + "锛屽彇姘村彛id=" + ad.intakeId
                                                 + "锛屾棩鏈�=" + ad.dt
@@ -87,7 +87,7 @@
                                             if(DateTime.daysBetweenyyyy_MM_dd(ad.dt, lastAd.dt) == 1){
                                                 //鍙浉宸竴澶�
                                                 log.info("鍑虹幇鐩稿樊涓�澶╀絾鏃ュ彇姘撮噺澶т簬"
-                                                        + IntakeAmountDayFlag
+                                                        + StClientAmountConstant.IntakeAmountDayFlag
                                                         + "鐨勬儏鍐碉紝鏁版嵁id=" + ad.id
                                                         + "锛屽彇姘村彛id=" + ad.intakeId
                                                         + "锛屾棩鏈�=" + ad.dt
@@ -99,7 +99,7 @@
                                                 //宸茬粡淇敼鍚庣殑鏁板�间粛鐒跺ぇ浜嶪ntakeAmountDayFlag锛岃鏄庢槸澶ф棩鏈笂鎶ユ暟鎹�岀Н绱笅鏉�,鍙互澶т簬IntakeAmountDayFlag
                                                 //ad.amount = ad.amount ;
                                                 log.info("鍑虹幇鐩稿樊澶氬ぉ鏃ュ彇姘撮噺澶т簬"
-                                                        + IntakeAmountDayFlag
+                                                        + StClientAmountConstant.IntakeAmountDayFlag
                                                         + "鐨勬儏鍐碉紝鏁版嵁id=" + ad.id
                                                         + "锛屽彇姘村彛id=" + ad.intakeId
                                                         + "锛屾棩鏈�=" + ad.dt
@@ -110,7 +110,7 @@
                                     }
                                 }else{
                                     log.info("鍑虹幇鐩稿樊澶氬ぉ鏃ュ彇姘撮噺澶т簬"
-                                            + IntakeAmountDayFlag
+                                            + StClientAmountConstant.IntakeAmountDayFlag
                                             + "骞朵笖灞炴�otalAmountLast涓簄ull鐨勬儏鍐碉紝鏁版嵁id=" + ad.id
                                             + "锛屽彇姘村彛id=" + ad.intakeId
                                             + "锛屾棩鏈�=" + ad.dt
@@ -130,10 +130,66 @@
     }
 
     @Transactional
-    int doUpdateOneIntakeAmountDay(Long id, Double amount){
+    protected int doUpdateOneIntakeAmountDay(Long id, Double amount){
         return dao.updateOneIntakeAmountDay(id, amount);
     }
 
+    /**
+     * 鍒犻櫎鎵�鏈夊彇姘村彛鏃ュ彇姘撮噺缁熻
+     * @throws Exception
+     */
+    //@Transactional
+    //public void deleteAllIntakeAmountDay(){
+    //    dao.deleteAllIntakeAmountDay();
+    //}
+    /**
+     * 鍒犻櫎涓�浜涘彇姘村彛鏃ュ彇姘撮噺缁熻
+     * @throws Exception
+     */
+    @Transactional
+    public void deleteSomeIntakeAmountDay(){
+        dao.deleteSomeIntakeAmountDay();
+    }
+
+
+    /**
+     * 缁熻鍙栨按鍙f棩鍙栨按閲�
+     * @throws Exception
+     */
+    public void statisticsIntakeAmountDay() throws Exception{
+        int nowYear = Integer.parseInt(DateTime.yyyy()) ;
+        int nowMonth = Integer.parseInt(DateTime.MM()) ;
+        int nowDay = Integer.parseInt(DateTime.dd()) ;
+        Date startDt ;
+        Date endDt ;
+        List<VoRmIntakeAmountDay> list ;
+        boolean stop = false ;
+        for(int[] ym : StClientAmountConstant.yearMonthGrp) {
+            int[] dates = DateTime.dayGrpInMonth(ym[0], ym[1]);
+            for(int day: dates){
+                if(ym[0] == nowYear && ym[1] == nowMonth && day > nowDay){
+                    stop = true ;
+                }
+                if(!stop){
+                    startDt = DateTime.dateFrom_yyyy_MM_dd_HH_mm_ss(ym[0] + "-" + ym[1] + "-" + day + " 00:00:00") ;
+                    endDt = DateTime.dateFrom_yyyy_MM_dd_HH_mm_ss(ym[0] + "-" + ym[1] + "-" + day + " 23:59:59") ;
+                    list = dao.statisticAllIntakeAmountDayFromOpenCloseValveHistory(startDt, endDt) ;
+                    this.doStatisticsIntakeAmountDay(ym[0], ym[1], day, list) ;
+                }else{
+                    break ;
+                }
+            }
+        }
+    }
+    @Transactional
+    protected void doStatisticsIntakeAmountDay(int year, int month, int day, List<VoRmIntakeAmountDay> list) throws Exception{
+        if(list != null && list.size() > 0){
+            Date date = DateTime.dateFrom_yyyy_MM_dd(year + "-" + month + "-" + day) ;
+            for(VoRmIntakeAmountDay vo : list){
+                dao.updateOneIntakeAmountDay1(vo.intakeId, date, vo.amount, vo.money, vo.times);
+            }
+        }
+    }
 
 
     ////////////////////////////////////////
@@ -142,28 +198,11 @@
     //
     ///////////////////////////////////////
 
-    private static final int DealStartYear = 2024 ;
-    private static final int DealStartMonth = 8 ;
-
-    private static final String endDayOfMonth(int year, int month){
-        if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){
-            return "31" ;
-        }else{
-            if(month == 2){
-                if(DateTime.isLeapYear(year)){
-                    return "29" ;
-                }else{
-                    return "28" ;
-                }
-            }else{
-                return "30" ;
-            }
-        }
-    }
     /**
      * 鍒犻櫎鎵�鏈夊彇姘村彛鏈堝彇姘撮噺缁熻
      * @throws Exception
      */
+    @Transactional
     public void deleteAllIntakeAmountMonth(){
         dao.deleteAllIntakeAmountMonth();
     }
@@ -174,30 +213,31 @@
      */
     public void statisticsIntakeAmountMonth() throws Exception{
         int nowYear = Integer.parseInt(DateTime.yyyy()) ;
-        int nowMonth = Integer.parseInt(DateTime.mm()) ;
+        int nowMonth = Integer.parseInt(DateTime.MM()) ;
         Date startDt ;
         Date endDt ;
         List<StIntakeAmountMonth> list ;
-        for(int year = DealStartYear; year <= nowYear; year ++){
+        for(int year = StClientAmountConstant.DealStartYear; year <= nowYear; year ++){
             list = null ;
             if(year < nowYear){
                 for(int month = 1 ; month <= 12 ; month ++){
-                    startDt = DateTime.dateFrom_MM_dd(year + "-" + month + "-01") ;
-                    endDt = DateTime.dateFrom_MM_dd(year + "-" + month + endDayOfMonth(year, month)) ;
+                    startDt = DateTime.dateFrom_yyyy_MM_dd(year + "-" + month + "-01") ;
+                    endDt = DateTime.dateFrom_yyyy_MM_dd(year + "-" + month + "-" + DateTime.endDayOfMonth(year, month)) ;
                     list = dao.statisticAllIntakeAmountMonthFromAmountDay(startDt, endDt) ;
                     this.doStatisticsIntakeAmountMonth(year, month, list) ;
                 }
             }else{
                 for(int month = 1 ; month <= nowMonth ; month ++){
-                    startDt = DateTime.dateFrom_MM_dd(year + "-" + month + "-01") ;
-                    endDt = DateTime.dateFrom_MM_dd(year + "-" + month + endDayOfMonth(year, month)) ;
+                    startDt = DateTime.dateFrom_yyyy_MM_dd(year + "-" + month + "-01") ;
+                    endDt = DateTime.dateFrom_yyyy_MM_dd(year + "-" + month + "-" + DateTime.endDayOfMonth(year, month)) ;
                     list = dao.statisticAllIntakeAmountMonthFromAmountDay(startDt, endDt) ;
                     this.doStatisticsIntakeAmountMonth(year, month, list) ;
                 }
             }
         }
     }
-    private void doStatisticsIntakeAmountMonth(int year, int month, List<StIntakeAmountMonth> list) throws Exception{
+    @Transactional
+    protected void doStatisticsIntakeAmountMonth(int year, int month, List<StIntakeAmountMonth> list) throws Exception{
         if(list != null && list.size() > 0){
             for(StIntakeAmountMonth po : list){
                 po.year = year ;
@@ -217,6 +257,7 @@
      * 鍒犻櫎鎵�鏈夊彇姘村彛骞村彇姘撮噺缁熻
      * @throws Exception
      */
+    @Transactional
     public void deleteAllIntakeAmountYear(){
         dao.deleteAllIntakeAmountYear();
     }
@@ -230,15 +271,16 @@
         Date startDt ;
         Date endDt ;
         List<StIntakeAmountYear> list ;
-        for(int year = DealStartYear; year <= nowYear; year ++){
+        for(int year = StClientAmountConstant.DealStartYear; year <= nowYear; year ++){
             list = null ;
-            startDt = DateTime.dateFrom_MM_dd(year + "-01-01") ;
-            endDt = DateTime.dateFrom_MM_dd(year + "-12-31") ;
+            startDt = DateTime.dateFrom_yyyy_MM_dd(year + "-01-01") ;
+            endDt = DateTime.dateFrom_yyyy_MM_dd(year + "-12-31") ;
             list = dao.statisticAllIntakeAmountYearFromAmountDay(startDt, endDt) ;
             this.doStatisticsIntakeAmountYear(year, list) ;
         }
     }
-    private void doStatisticsIntakeAmountYear(int year, List<StIntakeAmountYear> list) throws Exception{
+    @Transactional
+    protected void doStatisticsIntakeAmountYear(int year, List<StIntakeAmountYear> list) throws Exception{
         if(list != null && list.size() > 0){
             for(StIntakeAmountYear po : list){
                 po.year = year ;

--
Gitblit v1.8.0