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的基本为正确数据
|
|
@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{
|
//已经修改后的数值仍然大于IntakeAmountDayFlag,说明是大日未上报数据而积累下来,可以大于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);
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|