From 203223860baa19deb6860eb2ba3181910d662980 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期四, 17 四月 2025 14:22:59 +0800
Subject: [PATCH] 1. 轮灌组被终止时灌溉时长为实际数值。2. 计划历史表按照创建时间倒排序。3. 发布计划时判断是否同项目下未完成计划,是否其他项目下使用了本计划的轮灌组且计划未完成。4. 根据计划ID获取计划最新状态。

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

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StLossAmountSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StLossAmountSv.java
new file mode 100644
index 0000000..5e83be1
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StLossAmountSv.java
@@ -0,0 +1,90 @@
+package com.dy.pipIrrStatistics.statistics;
+
+import com.dy.pipIrrGlobal.daoRm.RmLossDayMapper;
+import com.dy.pipIrrGlobal.daoSt.StLossMonthMapper;
+import com.dy.pipIrrGlobal.daoSt.StLossYearMapper;
+import com.dy.pipIrrGlobal.pojoSt.StLossMonth;
+import com.dy.pipIrrGlobal.pojoSt.StLossYear;
+import com.dy.pipIrrGlobal.voSt.VoIntakeLossStatistics;
+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 11:24
+ * @Description
+ */
+@Component
+public class StLossAmountSv {
+
+    @Autowired
+    protected RmLossDayMapper rmLossDayDao;
+
+    @Autowired
+    protected StLossMonthMapper stLossMonthDao ;
+
+    @Autowired
+    protected StLossYearMapper stLossYearDao ;
+
+    /**
+     * 鏈堢粺璁�---婕忔崯
+     */
+    @Transactional
+    protected void statisticsMonth(Integer statisticsYear, Integer statisticsMonth, Long statisticsStartId, Long statisticsEndId){
+        List<VoIntakeLossStatistics> list = rmLossDayDao.statisticsByIntake(statisticsStartId, statisticsEndId) ;
+        if(list != null && list.size() > 0){
+            for(VoIntakeLossStatistics vo : list){
+                List<StLossMonth> listOfMonth = this.stLossMonthDao.selectByIntakeIdAndYearAndMonth(vo.intakeId, statisticsYear, statisticsMonth) ;
+                StLossMonth po = null ;
+                if (listOfMonth != null && listOfMonth.size() > 0){
+                    //绋嬪簭閫昏緫鎺у埗涓婏紝闆嗗悎涓彧鏈変竴涓璞�
+                    po = listOfMonth.get(0) ;
+                }
+                if(po == null){
+                    po = new StLossMonth() ;
+                }
+                po.intakeId = vo.intakeId ;
+                po.year = statisticsYear ;
+                po.month = statisticsMonth ;
+                po.amount = vo.amount;
+                if(po.id == null) {
+                    stLossMonthDao.insert(po);
+                }else{
+                    stLossMonthDao.updateByPrimaryKey(po) ;
+                }
+            }
+        }
+    }
+
+    /**
+     * 骞寸粺璁�---婕忔崯
+     */
+    @Transactional
+    protected void statisticsYear(Integer statisticsYear){
+        List<VoIntakeLossStatistics> list = stLossMonthDao.statisticsByIntake(statisticsYear) ;
+        if(list != null && list.size() > 0){
+            for(VoIntakeLossStatistics vo : list){
+                List<StLossYear> listOfYear = this.stLossYearDao.selectByIntakeIdAndYear(vo.intakeId, statisticsYear) ;
+                StLossYear po = null ;
+                if(listOfYear != null && listOfYear.size() > 0){
+                    //绋嬪簭閫昏緫鎺у埗涓婏紝闆嗗悎涓彧鏈変竴涓璞�
+                    po = listOfYear.get(0) ;
+                }
+                if(po == null) {
+                    po = new StLossYear();
+                }
+                po.intakeId = vo.intakeId ;
+                po.year = statisticsYear ;
+                po.amount = vo.amount;
+                if(po.id == null) {
+                    stLossYearDao.insert(po);
+                }else{
+                    stLossYearDao.updateByPrimaryKey(po) ;
+                }
+            }
+        }
+    }
+}

--
Gitblit v1.8.0