From c19de84fa332a00c651f28e3a52292fd14f143a1 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 23 九月 2025 17:30:07 +0800
Subject: [PATCH] 陆常丽反应软件系统财务对账时而数据不准确,分析源码,找到bug原因是,财务对账统计只有用户点击后才会触发统计功能,把历史上及当天进行了统计,如果当天统计时未下班,例如是中午触发统计了,而下午又进行了充值售水,但下班后未再点击触发对账统计,那么今天的对账统计完成了但数据不对。编写自动任务,在下半夜进行对账统计。

---
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StIntakeAmountSv.java |   91 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 91 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StIntakeAmountSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StIntakeAmountSv.java
new file mode 100644
index 0000000..7be2c7e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StIntakeAmountSv.java
@@ -0,0 +1,91 @@
+package com.dy.pipIrrStatistics.statistics;
+
+import com.dy.pipIrrGlobal.daoRm.RmIntakeAmountDayMapper;
+import com.dy.pipIrrGlobal.daoSt.StIntakeAmountMonthMapper;
+import com.dy.pipIrrGlobal.daoSt.StIntakeAmountYearMapper;
+import com.dy.pipIrrGlobal.pojoSt.StIntakeAmountMonth;
+import com.dy.pipIrrGlobal.pojoSt.StIntakeAmountYear;
+import com.dy.pipIrrGlobal.voSt.VoIntakeAmountStatistics;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/7/24 16:28
+ * @Description
+ */
+@Component
+public class StIntakeAmountSv {
+
+    @Autowired
+    protected RmIntakeAmountDayMapper rmIntakeAmountDayDao;
+
+    @Autowired
+    protected StIntakeAmountMonthMapper stIntakeAmountMonthDao ;
+
+    @Autowired
+    protected StIntakeAmountYearMapper stIntakeAmountYearDao ;
+
+    /**
+     * 鏈堢粺璁�---鍙栨按鍙g敤姘撮噺
+     */
+    @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){
+                List<StIntakeAmountMonth> listOfMonth = this.stIntakeAmountMonthDao.selectByIntakeIdAndYearAndMonth(vo.intakeId, statisticsYear, statisticsMonth) ;
+                StIntakeAmountMonth po = null ;
+                if(listOfMonth != null && listOfMonth.size() > 0) {
+                    //绋嬪簭閫昏緫鎺у埗涓婏紝闆嗗悎涓彧鏈変竴涓璞�
+                    po = listOfMonth.get(0);
+                }
+                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) ;
+                }
+            }
+        }
+    }
+
+    /**
+     * 骞寸粺璁�---鍙栨按鍙g敤姘撮噺
+     */
+    @Transactional
+    protected void statisticsYear(Integer statisticsYear){
+        List<VoIntakeAmountStatistics> list = stIntakeAmountMonthDao.statisticsByIntake(statisticsYear) ;
+        if(list != null && list.size() > 0){
+            for(VoIntakeAmountStatistics vo : list){
+                List<StIntakeAmountYear> listOfYear = stIntakeAmountYearDao.selectByIntakeIdAndYear(vo.intakeId, statisticsYear) ;
+                StIntakeAmountYear po = null ;
+                if(listOfYear != null && listOfYear.size() > 0) {
+                    //绋嬪簭閫昏緫鎺у埗涓婏紝闆嗗悎涓彧鏈変竴涓璞�
+                    po = listOfYear.get(0);
+                }
+                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) ;
+                }
+            }
+        }
+    }
+
+}

--
Gitblit v1.8.0