From 9f3c4a33279f10ed420d604765487558ab0744f0 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期五, 11 四月 2025 11:42:21 +0800 Subject: [PATCH] 获取已完成灌溉计划接口增加分页功能 --- pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StConsumeByClientSv.java | 317 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 317 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StConsumeByClientSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StConsumeByClientSv.java new file mode 100644 index 0000000..894dd14 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StConsumeByClientSv.java @@ -0,0 +1,317 @@ +package com.dy.pipIrrStatistics.statistics; + +import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveHistoryMapper; +import com.dy.pipIrrGlobal.daoSt.StConsumeClientDayMapper; +import com.dy.pipIrrGlobal.daoSt.StConsumeClientMonthMapper; +import com.dy.pipIrrGlobal.daoSt.StConsumeClientYearMapper; +import com.dy.pipIrrGlobal.pojoSt.StConsumeClientDay; +import com.dy.pipIrrGlobal.pojoSt.StConsumeClientMonth; +import com.dy.pipIrrGlobal.pojoSt.StConsumeClientYear; +import com.dy.pipIrrGlobal.voSt.VoClientConsumeStatistics; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + + +/** + * @Author: liurunyu + * @Date: 2024/12/25 16:40 + * @Description + */ +@Component +public class StConsumeByClientSv { + + @Autowired + protected RmOpenCloseValveHistoryMapper rmOpenCloseValveHistoryMapper; + + @Autowired + protected StConsumeClientDayMapper stConsumeClientDayMapper; + + @Autowired + protected StConsumeClientMonthMapper stConsumeClientMonthMapper; + + @Autowired + protected StConsumeClientYearMapper stConsumeClientYearMapper; + + + /** + * 鏃ョ粺璁� + */ + @Transactional + protected void statisticsDay(Integer statisticsYear, Integer statisticsMonth, Integer statisticsDay, Date statisticsStartDt, Date statisticsEndDt){ + //浠ョ敤姘存埛涓哄崟浣嶇粺璁℃煇涓�鏃ョ殑鎵�鏈夊厖鍊艰褰� + List<VoClientConsumeStatistics> list = rmOpenCloseValveHistoryMapper.statisticsByClient(statisticsStartDt, statisticsEndDt) ; + if(list != null && list.size() > 0){ + for(VoClientConsumeStatistics vo : list){ + List<StConsumeClientDay> listOfDay = this.stConsumeClientDayMapper.selectByClientAndYearAndMonth(vo.clientId, statisticsYear, statisticsMonth) ; + StConsumeClientDay po = null ; + if(listOfDay != null && listOfDay.size() > 0){ + //绋嬪簭閫昏緫鎺у埗涓婏紝闆嗗悎涓彧鏈変竴涓璞� + po = listOfDay.get(0) ; + } + if(po == null){ + po = new StConsumeClientDay() ; + po.clientId = vo.clientId ; + po.year = statisticsYear ; + po.month = statisticsMonth ; + } + this.setValueOfDayOfMonth(statisticsDay, vo, po); + if(po.id == null) { + stConsumeClientDayMapper.insert(po); + }else{ + stConsumeClientDayMapper.updateByPrimaryKeySelective(po) ; + } + } + } + } + + /** + * 鏈堢粺璁� + */ + @Transactional + protected void statisticsMonth(Integer statisticsYear, Integer statisticsMonth){ + //浠ョ敤姘存埛涓哄崟浣嶇粺璁℃煇涓�鏈堢殑鎵�鏈夊厖鍊艰褰� + List<VoClientConsumeStatistics> list = stConsumeClientDayMapper.statisticsByClient(statisticsYear, statisticsMonth) ; + if(list != null && list.size() > 0){ + for(VoClientConsumeStatistics vo : list){ + List<StConsumeClientMonth> listOfMonth = this.stConsumeClientMonthMapper.selectByClientAndYear(vo.clientId, statisticsYear) ; + StConsumeClientMonth po = null ; + if(listOfMonth != null && listOfMonth.size() > 0){ + //绋嬪簭閫昏緫鎺у埗涓婏紝闆嗗悎涓彧鏈変竴涓璞� + po = listOfMonth.get(0) ; + } + if(po == null){ + po = new StConsumeClientMonth() ; + po.clientId = vo.clientId ; + po.year = statisticsYear ; + } + this.setValueOfMonthOfYear(statisticsMonth, vo, po); + if(po.id == null) { + stConsumeClientMonthMapper.insert(po); + }else{ + stConsumeClientMonthMapper.updateByPrimaryKeySelective(po) ; + } + } + } + } + + /** + * 骞寸粺璁� + */ + @Transactional + protected void statisticsYear(Integer statisticsYear){ + //浠ョ敤姘存埛涓哄崟浣嶇粺璁℃煇涓�骞寸殑鎵�鏈夊厖鍊艰褰� + List<VoClientConsumeStatistics> list = stConsumeClientMonthMapper.statisticsByClient(statisticsYear) ; + if(list != null && list.size() > 0){ + for(VoClientConsumeStatistics vo : list){ + List<StConsumeClientYear> listOfYear = this.stConsumeClientYearMapper.selectByClientAndYear(vo.clientId, statisticsYear) ; + StConsumeClientYear po = null ; + if(listOfYear != null && listOfYear.size() > 0){ + //绋嬪簭閫昏緫鎺у埗涓婏紝闆嗗悎涓彧鏈変竴涓璞� + po = listOfYear.get(0) ; + } + if(po == null){ + po = new StConsumeClientYear() ; + po.clientId = vo.clientId ; + po.year = statisticsYear ; + } + this.setValueOfYear(vo, po); + if(po.id == null) { + stConsumeClientYearMapper.insert(po); + }else{ + stConsumeClientYearMapper.updateByPrimaryKeySelective(po) ; + } + } + } + } + + private void setValueOfDayOfMonth(Integer statisticsDay, VoClientConsumeStatistics vo, StConsumeClientDay po){ + switch (statisticsDay) { + case 1: + po.amount1 = vo.money; + po.times1 = vo.times; + break; + case 2: + po.amount2 = vo.money; + po.times2 = vo.times; + break; + case 3: + po.amount3 = vo.money; + po.times3 = vo.times; + break; + case 4: + po.amount4 = vo.money; + po.times4 = vo.times; + break; + case 5: + po.amount5 = vo.money; + po.times5 = vo.times; + break; + case 6: + po.amount6 = vo.money; + po.times6 = vo.times; + break; + case 7: + po.amount7 = vo.money; + po.times7 = vo.times; + break; + case 8: + po.amount8 = vo.money; + po.times8 = vo.times; + break; + case 9: + po.amount9 = vo.money; + po.times9 = vo.times; + break; + case 10: + po.amount10 = vo.money; + po.times10 = vo.times; + break; + case 11: + po.amount11 = vo.money; + po.times11 = vo.times; + break; + case 12: + po.amount12 = vo.money; + po.times12 = vo.times; + break; + case 13: + po.amount13 = vo.money; + po.times13 = vo.times; + break; + case 14: + po.amount14 = vo.money; + po.times14 = vo.times; + break; + case 15: + po.amount15 = vo.money; + po.times15 = vo.times; + break; + case 16: + po.amount16 = vo.money; + po.times16 = vo.times; + break; + case 17: + po.amount17 = vo.money; + po.times17 = vo.times; + break; + case 18: + po.amount18 = vo.money; + po.times18 = vo.times; + break; + case 19: + po.amount19 = vo.money; + po.times19 = vo.times; + break; + case 20: + po.amount20 = vo.money; + po.times20 = vo.times; + break; + case 21: + po.amount21 = vo.money; + po.times21 = vo.times; + break; + case 22: + po.amount22 = vo.money; + po.times22 = vo.times; + break; + case 23: + po.amount23 = vo.money; + po.times23 = vo.times; + break; + case 24: + po.amount24 = vo.money; + po.times24 = vo.times; + break; + case 25: + po.amount25 = vo.money; + po.times25 = vo.times; + break; + case 26: + po.amount26 = vo.money; + po.times26 = vo.times; + break; + case 27: + po.amount27 = vo.money; + po.times27 = vo.times; + break; + case 28: + po.amount28 = vo.money; + po.times28 = vo.times; + break; + case 29: + po.amount29 = vo.money; + po.times29 = vo.times; + break; + case 30: + po.amount30 = vo.money; + po.times30 = vo.times; + break; + case 31: + po.amount31 = vo.money; + po.times31 = vo.times; + break; + } + } + + private void setValueOfMonthOfYear(Integer statisticsMonth, VoClientConsumeStatistics vo, StConsumeClientMonth po){ + switch (statisticsMonth) { + case 1: + po.amount1 = vo.money; + po.times1 = vo.times; + break; + case 2: + po.amount2 = vo.money; + po.times2 = vo.times; + break; + case 3: + po.amount3 = vo.money; + po.times3 = vo.times; + break; + case 4: + po.amount4 = vo.money; + po.times4 = vo.times; + break; + case 5: + po.amount5 = vo.money; + po.times5 = vo.times; + break; + case 6: + po.amount6 = vo.money; + po.times6 = vo.times; + break; + case 7: + po.amount7 = vo.money; + po.times7 = vo.times; + break; + case 8: + po.amount8 = vo.money; + po.times8 = vo.times; + break; + case 9: + po.amount9 = vo.money; + po.times9 = vo.times; + break; + case 10: + po.amount10 = vo.money; + po.times10 = vo.times; + break; + case 11: + po.amount11 = vo.money; + po.times11 = vo.times; + break; + case 12: + po.amount12 = vo.money; + po.times12 = vo.times; + break; + } + } + + private void setValueOfYear(VoClientConsumeStatistics vo, StConsumeClientYear po){ + po.amount = vo.money; + po.times = vo.times; + } +} -- Gitblit v1.8.0