From c01f28021b6bd1af354c2756da605a2323d47558 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期六, 14 十二月 2024 10:55:28 +0800 Subject: [PATCH] pipIrr-web-temp模块中实现功能:修改一些取水口日取水量统计---因RTU一天内整点报中累计流量间歇出现0值,两次上报累计流量差值会产生大值 --- pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeIntakeAmountSv.java | 98 ++++++++++++++++++++++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoTmp/ChangeMapper.java | 40 ++++++++++ pipIrr-platform/pipIrr-global/src/main/resources/mapper/Temp4ChangeMapper.xml | 31 +++++++ pipIrr-platform/pipIrr-web/pipIrr-web-temp/说明.txt | 13 +++ pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeCtrl.java | 40 ++++++++++ pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java | 6 + 6 files changed, 227 insertions(+), 1 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java index 76f4ac2..9b32044 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java @@ -484,6 +484,12 @@ /** * 涓や釜鏃ユ湡鐩稿樊澶╂暟 */ + public static long daysBetweenyyyy_MM_dd(Date yyyy_MM_dd_1 , Date yyyy_MM_dd_2)throws Exception{ + return ((((yyyy_MM_dd_1.getTime() - yyyy_MM_dd_2.getTime())/1000)/60)/60)/24 ; + } + /** + * 涓や釜鏃ユ湡鐩稿樊澶╂暟 + */ public static long daysBetweenyyyyMMdd(String yyyyMMdd_1 , String yyyyMMdd_2)throws Exception{ return ((((dateFrom_yyyy_MM_dd(yyyyMMdd_1).getTime()-dateFrom_yyyy_MM_dd(yyyyMMdd_2).getTime())/1000)/60)/60)/24 ; } diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoTmp/ChangeMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoTmp/ChangeMapper.java new file mode 100644 index 0000000..5245577 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoTmp/ChangeMapper.java @@ -0,0 +1,40 @@ +package com.dy.pipIrrGlobal.daoTmp; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dy.pipIrrGlobal.pojoRm.RmIntakeAmountDay; +import com.dy.pipIrrGlobal.voSt.VoIntake; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author: liurunyu + * @Date: 2024/12/14 09:27 + * @Description + */ +@Mapper +public interface ChangeMapper extends BaseMapper<Object> { + + /** + * 鏌ヨ鍏ㄩ儴鍙栨按鍙� + * + * @return 瀹炰綋闆嗗悎 + */ + List<VoIntake> selectAllPrIntakes(); + + /** + * 鏌ヨ涓�涓彇姘村彛鐨勬棩鐢ㄦ按閲忕粺璁¤褰� + * + * @return 瀹炰綋闆嗗悎 + */ + List<RmIntakeAmountDay> selectOneIntakeAllAmountDay(@Param("intakeId")Long intakeId); + + /** + * 鏇存柊涓�涓彇姘村彛鐨勬棩鐢ㄦ按閲忕粺璁� + * + * @return 褰卞搷瀹炰綋鏁� + */ + int updateOneIntakeAmountDay(@Param("id")Long id, @Param("amount")Double amount); + +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/Temp4ChangeMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/Temp4ChangeMapper.xml new file mode 100644 index 0000000..2c0bfcd --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/Temp4ChangeMapper.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.dy.pipIrrGlobal.daoTmp.ChangeMapper"> + + <!-- 鏌ヨ鍑烘墍鏈夊彇姘村彛 --> + <select id="selectAllPrIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntake"> + select id as intakeId, + name as intakeNum + from pr_intake + order by id ASC + </select> + + <!-- 鍙栨按鍙e彇姘撮噺鏃ョ粺璁$浉鍏�, 姝QL涓殑 鈥漮rder by id ASC 鈥滀笉鍙慨鏀� --> + <select id="selectOneIntakeAllAmountDay" resultType="com.dy.pipIrrGlobal.pojoRm.RmIntakeAmountDay"> + select id as id, + intake_id as intakeId , + dt as dt, + amount as amount, + total_amount_last as totalAmountLast + from rm_intake_amount_day + where intake_id = #{intakeId} + order by id ASC + </select> + + <!-- 淇敼鍙栨按鍙e彇姘撮噺鏃ョ粺璁� --> + <update id="updateOneIntakeAmountDay" > + update rm_intake_amount_day + set amount = #{amount, jdbcType=FLOAT} + where id = #{id, jdbcType=BIGINT} + </update> +</mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeCtrl.java new file mode 100644 index 0000000..666a62c --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeCtrl.java @@ -0,0 +1,40 @@ +package com.dy.pipIrrTemp.changeSome; + +import com.dy.common.aop.SsoAop; +import com.dy.common.webUtil.BaseResponse; +import com.dy.common.webUtil.BaseResponseUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author: liurunyu + * @Date: 2024/12/14 9:22 + * @Description + */ +@Slf4j +@RestController +@RequestMapping(path = "chSome") +@SuppressWarnings("unchecked")//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked") +public class ChSomeCtrl { + + private ChSomeIntakeAmountSv intakeAmountSv; + + @Autowired + private void setSv(ChSomeIntakeAmountSv sv) { + this.intakeAmountSv = sv; + } + + /** + * 淇敼涓�浜涘彇姘村彛鍙栨按閲忔棩缁熻 + * @return + */ + @GetMapping(path = "changeSomeIntakeDayAmount") + @SsoAop() + public BaseResponse<Boolean> changeSomeIntakeDayAmount() throws Exception{ + this.intakeAmountSv.chIntakeAmountDay(); + return BaseResponseUtils.buildSuccess(true); + } +} 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 new file mode 100644 index 0000000..fa7191c --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/src/main/java/com/dy/pipIrrTemp/changeSome/ChSomeIntakeAmountSv.java @@ -0,0 +1,98 @@ +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.voSt.VoIntake; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Author: liurunyu + * @Date: 2024/12/14 9:25 + * @Description + */ + + +@Slf4j +@Service +public class ChSomeIntakeAmountSv { + + private ChangeMapper dao; + + private static final int IntakeAmountDayFlag = 800 ;//2024-12-14缁熻鍏冭皨鏁版嵁搴撳疄鏃舵暟鎹紝鍙戠幇澶т簬800鐨勬纭殑鏁版嵁涓嶅瓨鍦紝鑰屽皬浜�800鐨勫熀鏈负姝g‘鏁版嵁 + + @Autowired + private void setDao(ChangeMapper dao){ + this.dao = dao; + } + + public void chIntakeAmountDay() throws Exception{ + RmIntakeAmountDay lastAd = null ; + List<VoIntake> list = dao.selectAllPrIntakes() ; + if(list != null && list.size() > 0){ + for(VoIntake vo : list){ + lastAd = null ; + List<RmIntakeAmountDay> adList = dao.selectOneIntakeAllAmountDay(vo.getIntakeId()) ; + if(adList != null && adList.size() > 0){ + //adList涓暟鎹互id鍗囧簭鎺掑垪 + for(RmIntakeAmountDay ad : adList){ + if(lastAd == null){ + lastAd = ad ; + if(lastAd.amount != null && lastAd.amount > IntakeAmountDayFlag){ + dao.updateOneIntakeAmountDay(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){//瀛樿繖绉嶆儏鍐� + ad.amount = 0.0 ; + } + if(ad.amount > IntakeAmountDayFlag){ + log.info("鍑虹幇璋冩暣鍚庣殑鏃ュ彇姘撮噺浠嶅ぇ浜�" + + IntakeAmountDayFlag + + "鐨勬儏鍐碉紝鏁版嵁id=" + ad.id + + "锛屽彇姘村彛id=" + ad.intakeId + + "锛屾棩鏈�=" + ad.dt + + ad.amount + ); + 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 + ); + }else{ + //宸茬粡淇敼鍚庣殑鏁板�间粛鐒跺ぇ浜嶪ntakeAmountDayFlag锛岃鏄庢槸澶ф棩鏈笂鎶ユ暟鎹�岀Н绱笅鏉�,鍙互澶т簬IntakeAmountDayFlag + //ad.amount = ad.amount ; + log.info("鍑虹幇鐩稿樊澶氬ぉ鏃ュ彇姘撮噺澶т簬" + + IntakeAmountDayFlag + + "鐨勬儏鍐碉紝鏁版嵁id=" + ad.id + + "锛屽彇姘村彛id=" + ad.intakeId + + "锛屾棩鏈�=" + ad.dt + + "锛屾按閲�=" + ad.amount + ); + } + } + } + }else{ + ad.amount = 0.0 ; + } + dao.updateOneIntakeAmountDay(ad.id, 0.0); + } + } + } + } + } + } + } +} diff --git "a/pipIrr-platform/pipIrr-web/pipIrr-web-temp/\350\257\264\346\230\216.txt" "b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/\350\257\264\346\230\216.txt" index 36fdbeb..a64244a 100644 --- "a/pipIrr-platform/pipIrr-web/pipIrr-web-temp/\350\257\264\346\230\216.txt" +++ "b/pipIrr-platform/pipIrr-web/pipIrr-web-temp/\350\257\264\346\230\216.txt" @@ -1,2 +1,13 @@ 杩欎釜temp妯″潡鎵ц涓存椂浠诲姟锛屼緥濡傚垹闄ゆ暟鎹簱涓竴浜涢敊璇暟鎹瓑 -绯荤粺姝e紡杩愯涓嶉渶瑕佽繖涓ā鍧� \ No newline at end of file +绯荤粺姝e紡杩愯涓嶉渶瑕佽繖涓ā鍧� + +鎵ц鍔熻兘锛� +1銆佸垹闄や竴浜涙紡鎹熺粺璁�---閲嶅鏁版嵁 +/temp/delSome/deleteSomeStatisticLossAmount +2銆佸垹闄や竴浜涘彇姘村彛缁熻---閲嶅鏁版嵁 +/temp/delSome/deleteSomeStatisticIntakeAmount +3銆佸垹闄や竴浜涘啘鎴风粺璁�---閲嶅鏁版嵁 +/temp/delSome/deleteSomeStatisticClientAmount + +4銆佷慨鏀逛竴浜涘彇姘村彛鏃ュ彇姘撮噺缁熻---鍥燫TU涓�澶╁唴鏁寸偣鎶ヤ腑绱娴侀噺闂存瓏鍑虹幇0鍊硷紝涓ゆ涓婃姤绱娴侀噺宸�间細浜х敓澶у�� +/temp/chSome/changeSomeIntakeDayAmount \ No newline at end of file -- Gitblit v1.8.0