| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.pipIrrTemp.changeSome; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.util.DateTime; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.daoTmp.ChangeMapper; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoRm.RmIntakeAmountDay; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoRm.RmLossDay; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoSt.StIntakeAmountMonth; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoSt.StIntakeAmountYear; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoSt.StLossMonth; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoSt.StLossYear; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voSt.VoIntake; | 
|---|
|  |  |  | 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.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2024/12/24 8:47 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | public class ChSomeIntakeLossSv { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private ChangeMapper dao; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private void setDao(ChangeMapper dao){ | 
|---|
|  |  |  | this.dao = dao; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //////////////////////////////////////// | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // 有关日统计 | 
|---|
|  |  |  | // | 
|---|
|  |  |  | /////////////////////////////////////// | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 调整取水口日漏损量统计 | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void chIntakeLossDay() throws Exception{ | 
|---|
|  |  |  | List<VoIntake> list = dao.selectAllPrIntakes() ; | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | for(VoIntake vo : list){ | 
|---|
|  |  |  | List<RmLossDay> adList = dao.selectOneIntakeAllLossDay(vo.getIntakeId()) ; | 
|---|
|  |  |  | if(adList != null && adList.size() > 0){ | 
|---|
|  |  |  | //adList中数据以id升序排列 | 
|---|
|  |  |  | for(RmLossDay ad : adList){ | 
|---|
|  |  |  | if(ad.lossAmount != null && ad.lossAmount > StClientAmountConstant.IntakeLossDayFlag){ | 
|---|
|  |  |  | this.doUpdateOneIntakeLossDay(ad.id, 0.0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | protected int doUpdateOneIntakeLossDay(Long id, Double loss){ | 
|---|
|  |  |  | return dao.updateOneIntakeLossDay(id, loss); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //////////////////////////////////////// | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // 有关月统计 | 
|---|
|  |  |  | // | 
|---|
|  |  |  | /////////////////////////////////////// | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static final int DealStartYear = 2024 ; | 
|---|
|  |  |  | private static final int DealStartMonth = 8 ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static final String endDayOfMonth(int year, int month){ | 
|---|
|  |  |  | if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){ | 
|---|
|  |  |  | return "31" ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(month == 2){ | 
|---|
|  |  |  | if(DateTime.isLeapYear(year)){ | 
|---|
|  |  |  | return "29" ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return "28" ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return "30" ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 删除所有取水口月漏损量统计 | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void deleteAllIntakeLossMonth(){ | 
|---|
|  |  |  | dao.deleteAllIntakeLossMonth(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 统计取水口月漏损量 | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void statisticsIntakeLossMonth() throws Exception{ | 
|---|
|  |  |  | int nowYear = Integer.parseInt(DateTime.yyyy()) ; | 
|---|
|  |  |  | int nowMonth = Integer.parseInt(DateTime.MM()) ; | 
|---|
|  |  |  | Date startDt ; | 
|---|
|  |  |  | Date endDt ; | 
|---|
|  |  |  | List<StLossMonth> list ; | 
|---|
|  |  |  | for(int year = DealStartYear; year <= nowYear; year ++){ | 
|---|
|  |  |  | list = null ; | 
|---|
|  |  |  | if(year < nowYear){ | 
|---|
|  |  |  | for(int month = 1 ; month <= 12 ; month ++){ | 
|---|
|  |  |  | startDt = DateTime.dateFrom_yyyy_MM_dd(year + "-" + month + "-01") ; | 
|---|
|  |  |  | endDt = DateTime.dateFrom_yyyy_MM_dd(year + "-" + month + "-" + endDayOfMonth(year, month)) ; | 
|---|
|  |  |  | list = dao.statisticAllIntakeLossMonthFromLossDay(startDt, endDt) ; | 
|---|
|  |  |  | this.doStatisticsIntakeLossMonth(year, month, list) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | for(int month = 1 ; month <= nowMonth ; month ++){ | 
|---|
|  |  |  | startDt = DateTime.dateFrom_yyyy_MM_dd(year + "-" + month + "-01") ; | 
|---|
|  |  |  | endDt = DateTime.dateFrom_yyyy_MM_dd(year + "-" + month + "-" + endDayOfMonth(year, month)) ; | 
|---|
|  |  |  | list = dao.statisticAllIntakeLossMonthFromLossDay(startDt, endDt) ; | 
|---|
|  |  |  | this.doStatisticsIntakeLossMonth(year, month, list) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | protected void doStatisticsIntakeLossMonth(int year, int month, List<StLossMonth> list) throws Exception{ | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | for(StLossMonth po : list){ | 
|---|
|  |  |  | po.year = year ; | 
|---|
|  |  |  | po.month = month ; | 
|---|
|  |  |  | dao.saveOneIntakeLossMonth(po) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //////////////////////////////////////// | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // 有关年统计 | 
|---|
|  |  |  | // | 
|---|
|  |  |  | /////////////////////////////////////// | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 删除所有取水口年漏损量统计 | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void deleteAllIntakeLossYear(){ | 
|---|
|  |  |  | dao.deleteAllIntakeLossYear(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 统计取水口月漏损量 | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void statisticsIntakeLossYear() throws Exception{ | 
|---|
|  |  |  | int nowYear = Integer.parseInt(DateTime.yyyy()) ; | 
|---|
|  |  |  | Date startDt ; | 
|---|
|  |  |  | Date endDt ; | 
|---|
|  |  |  | List<StLossYear> list ; | 
|---|
|  |  |  | for(int year = DealStartYear; year <= nowYear; year ++){ | 
|---|
|  |  |  | list = null ; | 
|---|
|  |  |  | startDt = DateTime.dateFrom_yyyy_MM_dd(year + "-01-01") ; | 
|---|
|  |  |  | endDt = DateTime.dateFrom_yyyy_MM_dd(year + "-12-31") ; | 
|---|
|  |  |  | list = dao.statisticAllIntakeLossYearFromLossDay(startDt, endDt) ; | 
|---|
|  |  |  | this.doStatisticsIntakeLossYear(year, list) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | protected void doStatisticsIntakeLossYear(int year, List<StLossYear> list) throws Exception{ | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | for(StLossYear po : list){ | 
|---|
|  |  |  | po.year = year ; | 
|---|
|  |  |  | dao.saveOneIntakeLossYear(po) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|