From 59979105fddeaf2e4464684620843d1b5fb565c7 Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期一, 16 十二月 2024 17:20:18 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeIntakeAmountSv.java | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 162 insertions(+), 6 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeIntakeAmountSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeIntakeAmountSv.java index fa7191c..a23eb3d 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeIntakeAmountSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeIntakeAmountSv.java @@ -3,11 +3,15 @@ import com.dy.common.util.DateTime; import com.dy.pipIrrGlobal.daoTmp.ChangeMapper; import com.dy.pipIrrGlobal.pojoRm.RmIntakeAmountDay; +import com.dy.pipIrrGlobal.pojoSt.StIntakeAmountMonth; +import com.dy.pipIrrGlobal.pojoSt.StIntakeAmountYear; import com.dy.pipIrrGlobal.voSt.VoIntake; 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; /** @@ -30,6 +34,17 @@ this.dao = dao; } + + //////////////////////////////////////// + // + // 鏈夊叧鏃ョ粺璁� + // + /////////////////////////////////////// + + /** + * 璋冩暣鍙栨按鍙f棩鍙栨按閲忕粺璁� + * @throws Exception + */ public void chIntakeAmountDay() throws Exception{ RmIntakeAmountDay lastAd = null ; List<VoIntake> list = dao.selectAllPrIntakes() ; @@ -43,16 +58,24 @@ if(lastAd == null){ lastAd = ad ; if(lastAd.amount != null && lastAd.amount > IntakeAmountDayFlag){ - dao.updateOneIntakeAmountDay(lastAd.id, 0.0); + this.doUpdateOneIntakeAmountDay(lastAd.id, 0.0); } }else{ if(ad.amount != null && ad.amount > IntakeAmountDayFlag){ if(ad.totalAmountLast != null && lastAd.totalAmountLast != null){ + //閲嶆柊璁$畻鏃ュ彇姘撮噺 ad.amount = ad.totalAmountLast - lastAd.totalAmountLast; - if(ad.amount < 0){//瀛樿繖绉嶆儏鍐� + if(ad.amount < 0){//璁$畻鏃ュ彇姘撮噺鍚庯紝鍙兘浼氭湁杩欑鎯呭喌鍙戠敓锛堣礋鍊硷級 + log.info("鍑虹幇璋冩暣鍚庣殑鏃ュ彇姘撮噺鍑虹幇璐熷��" + ad.amount + + "鎯呭喌锛屾暟鎹甶d=" + ad.id + + "锛屽彇姘村彛id=" + ad.intakeId + + "锛屾棩鏈�=" + ad.dt + + "锛岃缃按閲�=0.0" + ); ad.amount = 0.0 ; } if(ad.amount > IntakeAmountDayFlag){ + //璁$畻鏃ュ彇姘撮噺鍚庯紝浠嶅ぇ浜嶪ntakeAmountDayFlag log.info("鍑虹幇璋冩暣鍚庣殑鏃ュ彇姘撮噺浠嶅ぇ浜�" + IntakeAmountDayFlag + "鐨勬儏鍐碉紝鏁版嵁id=" + ad.id @@ -63,14 +86,15 @@ if(ad.dt != null && lastAd.dt != null){ if(DateTime.daysBetweenyyyy_MM_dd(ad.dt, lastAd.dt) == 1){ //鍙浉宸竴澶� - ad.amount = 0.0 ; log.info("鍑虹幇鐩稿樊涓�澶╀絾鏃ュ彇姘撮噺澶т簬" + IntakeAmountDayFlag + "鐨勬儏鍐碉紝鏁版嵁id=" + ad.id + "锛屽彇姘村彛id=" + ad.intakeId + "锛屾棩鏈�=" + ad.dt - + "锛屾按閲�=" + ad.amount + + "锛岃缃按閲�=0.0" + + "锛岃缃墠姘撮噺= " + ad.amount ); + ad.amount = 0.0 ; }else{ //宸茬粡淇敼鍚庣殑鏁板�间粛鐒跺ぇ浜嶪ntakeAmountDayFlag锛岃鏄庢槸澶ф棩鏈笂鎶ユ暟鎹�岀Н绱笅鏉�,鍙互澶т簬IntakeAmountDayFlag //ad.amount = ad.amount ; @@ -79,20 +103,152 @@ + "鐨勬儏鍐碉紝鏁版嵁id=" + ad.id + "锛屽彇姘村彛id=" + ad.intakeId + "锛屾棩鏈�=" + ad.dt - + "锛屾按閲�=" + ad.amount + + "锛屾按閲忎繚鎸佷笉鍙�=" + ad.amount ); } } } }else{ + log.info("鍑虹幇鐩稿樊澶氬ぉ鏃ュ彇姘撮噺澶т簬" + + IntakeAmountDayFlag + + "骞朵笖灞炴�otalAmountLast涓簄ull鐨勬儏鍐碉紝鏁版嵁id=" + ad.id + + "锛屽彇姘村彛id=" + ad.intakeId + + "锛屾棩鏈�=" + ad.dt + + "锛岃缃按閲�=0.0" + + "锛岃缃墠姘撮噺= " + ad.amount + ); ad.amount = 0.0 ; } - dao.updateOneIntakeAmountDay(ad.id, 0.0); + this.doUpdateOneIntakeAmountDay(ad.id, ad.amount); } } + lastAd = ad ; } } } } } + + @Transactional + protected int doUpdateOneIntakeAmountDay(Long id, Double amount){ + return dao.updateOneIntakeAmountDay(id, amount); + } + + + + //////////////////////////////////////// + // + // 鏈夊叧鏈堢粺璁� + // + /////////////////////////////////////// + + 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 deleteAllIntakeAmountMonth(){ + dao.deleteAllIntakeAmountMonth(); + } + + /** + * 缁熻鍙栨按鍙f湀鍙栨按閲� + * @throws Exception + */ + public void statisticsIntakeAmountMonth() throws Exception{ + int nowYear = Integer.parseInt(DateTime.yyyy()) ; + int nowMonth = Integer.parseInt(DateTime.mm()) ; + Date startDt ; + Date endDt ; + List<StIntakeAmountMonth> 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.statisticAllIntakeAmountMonthFromAmountDay(startDt, endDt) ; + this.doStatisticsIntakeAmountMonth(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.statisticAllIntakeAmountMonthFromAmountDay(startDt, endDt) ; + this.doStatisticsIntakeAmountMonth(year, month, list) ; + } + } + } + } + @Transactional + protected void doStatisticsIntakeAmountMonth(int year, int month, List<StIntakeAmountMonth> list) throws Exception{ + if(list != null && list.size() > 0){ + for(StIntakeAmountMonth po : list){ + po.year = year ; + po.month = month ; + dao.saveOneIntakeAmountMonth(po) ; + } + } + } + + + //////////////////////////////////////// + // + // 鏈夊叧骞寸粺璁� + // + /////////////////////////////////////// + /** + * 鍒犻櫎鎵�鏈夊彇姘村彛骞村彇姘撮噺缁熻 + * @throws Exception + */ + @Transactional + public void deleteAllIntakeAmountYear(){ + dao.deleteAllIntakeAmountYear(); + } + + /** + * 缁熻鍙栨按鍙f湀鍙栨按閲� + * @throws Exception + */ + public void statisticsIntakeAmountYear() throws Exception{ + int nowYear = Integer.parseInt(DateTime.yyyy()) ; + Date startDt ; + Date endDt ; + List<StIntakeAmountYear> 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.statisticAllIntakeAmountYearFromAmountDay(startDt, endDt) ; + this.doStatisticsIntakeAmountYear(year, list) ; + } + } + @Transactional + protected void doStatisticsIntakeAmountYear(int year, List<StIntakeAmountYear> list) throws Exception{ + if(list != null && list.size() > 0){ + for(StIntakeAmountYear po : list){ + po.year = year ; + dao.saveOneIntakeAmountYear(po) ; + } + } + } + } -- Gitblit v1.8.0