From 4513ef24bf9b188c2a77d6ce94f1a6b7e9ebf0e6 Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期日, 27 四月 2025 20:40:19 +0800 Subject: [PATCH] fix(irrigatePlan): 修正灌溉计划开始时间逻辑 --- pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/statistics/StClientAmountYearSv.java | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 116 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/statistics/StClientAmountYearSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/statistics/StClientAmountYearSv.java new file mode 100644 index 0000000..a94a0a6 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/statistics/StClientAmountYearSv.java @@ -0,0 +1,116 @@ +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.daoSt.StClientAmountYearMapper; +import com.dy.pipIrrGlobal.pojoSt.StClientAmountYear; +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 StClientAmountYearSv { + + protected StClientAmountDayMapper stClientAmountDayDao; + + protected StClientAmountMonthMapper stClientAmountMonthDao; + + protected StClientAmountYearMapper stClientAmountYearDao; + + @Autowired + private void setDao(StClientAmountDayMapper dao) { + this.stClientAmountDayDao = dao; + } + + @Autowired + private void setDao(StClientAmountMonthMapper dao) { + this.stClientAmountMonthDao = dao; + } + + @Autowired + private void setDao(StClientAmountYearMapper dao) { + this.stClientAmountYearDao = dao; + } + + /** + * 鍒犻櫎鎵�鏈� + * @throws Exception + */ + public void deleteAllStClientAmountYear() throws Exception { + stClientAmountYearDao.deleteAll() ; + } + + /** + * 杞瓨鍐滄埛骞村彇姘撮噺 + * + * @throws Exception + */ + public void statisticsClientAmountYear() throws Exception { + //缁熻鍒版槰澶╋紝浠婂ぉ鐨勭粺璁℃槑鏃ラ浂鏅ㄥ畾鏃朵换鍔$粺璁� + Long curY = Long.parseLong(DateTime.yyyy().replaceAll("-", "")); + Long atYear ; + for(int[] ym : StClientAmountConstant.yearMonthGrp) { + atYear = ym[0] + 0L ; + if(atYear <= curY) { + this.doSome(ym[0]); + } + } + } + + + @Transactional + protected void doSome(Integer statisticsYear){ + List<VoClientAmountStatistics> list = stClientAmountMonthDao.statisticsByClient(statisticsYear) ; + if(list != null && list.size() > 0){ + List<StClientAmountYear> listOfYear = stClientAmountYearDao.selectByYear(statisticsYear) ; + for(VoClientAmountStatistics vo : list){ + StClientAmountYear po = this.getDataOfClient(listOfYear, vo.clientId) ; + if(po == null){ + po = new StClientAmountYear() ; + po.clientId = vo.clientId ; + po.year = statisticsYear ; + } + this.setValue(vo, po); + if(po.id == null) { + stClientAmountYearDao.insert(po); + }else{ + stClientAmountYearDao.updateByPrimaryKeySelective(po) ; + } + } + } + } + + + private StClientAmountYear getDataOfClient(List<StClientAmountYear> list, Long clientId){ + if(list != null && list.size() > 0){ + for(StClientAmountYear vo : list){ + if(vo.clientId.longValue() == clientId.longValue()){ + //绋嬪簭閫昏緫鎺у埗涓婏紝闆嗗悎涓彧鏈変竴涓璞� + return vo ; + } + } + } + return null ; + } + + private void setValue(VoClientAmountStatistics vo, StClientAmountYear po){ + po.amount = vo.amount; + po.money = vo.money; + po.times = vo.times; + } + +} + -- Gitblit v1.8.0