From 8579b568049621bf4b91984c5a147a0e81120c66 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 12 十二月 2024 16:06:18 +0800
Subject: [PATCH] 漏损月统计重新实现

---
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StClientSv.java |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StClientSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StClientSv.java
index e453ab8..000b497 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StClientSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StClientSv.java
@@ -37,12 +37,19 @@
         List<VoClientAmountStatistics> list = rmClientAmountDayDao.statisticsByClient(statisticsStartId, statisticsEndId) ;
         if(list != null && list.size() > 0){
             for(VoClientAmountStatistics vo : list){
-                StClientAmountMonth po = new StClientAmountMonth() ;
+                StClientAmountMonth po = stClientAmountMonthDao.selectByClientIdAndYearAndMonth(vo.clientId, statisticsYear, statisticsMonth) ;
+                if(po == null) {
+                    po = new StClientAmountMonth();
+                }
                 po.clientId = vo.clientId ;
                 po.year = statisticsYear ;
                 po.month = statisticsMonth ;
                 po.amount = vo.amount;
-                stClientAmountMonthDao.insert(po) ;
+                if(po.id == null) {
+                    stClientAmountMonthDao.insert(po);
+                }else{
+                    stClientAmountMonthDao.updateByPrimaryKey(po) ;
+                }
             }
         }
     }
@@ -55,11 +62,18 @@
         List<VoClientAmountStatistics> list = stClientAmountMonthDao.statisticsByClient(statisticsYear) ;
         if(list != null && list.size() > 0){
             for(VoClientAmountStatistics vo : list){
-                StClientAmountYear po = new StClientAmountYear() ;
+                StClientAmountYear po = stClientAmountYearDao.selectByClientIdAndYear(vo.clientId, statisticsYear) ;
+                if(po == null) {
+                    po = new StClientAmountYear();
+                }
                 po.clientId = vo.clientId ;
                 po.year = statisticsYear ;
                 po.amount = vo.amount;
-                stClientAmountYearDao.insert(po) ;
+                if(po.id == null) {
+                    stClientAmountYearDao.insert(po);
+                }else{
+                    stClientAmountYearDao.updateByPrimaryKey(po) ;
+                }
             }
         }
     }

--
Gitblit v1.8.0