| | |
| | | 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.List; |
| | | |
| | |
| | | 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 |
| | | + "情况,数据id=" + ad.id |
| | | + ",取水口id=" + ad.intakeId |
| | | + ",日期=" + ad.dt |
| | | + ",设置水量=0.0" |
| | | ); |
| | | ad.amount = 0.0 ; |
| | | } |
| | | if(ad.amount > IntakeAmountDayFlag){ |
| | | //计算日取水量后,仍大于IntakeAmountDayFlag |
| | | log.info("出现调整后的日取水量仍大于" |
| | | + IntakeAmountDayFlag |
| | | + "的情况,数据id=" + ad.id |
| | |
| | | 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{ |
| | | //已经修改后的数值仍然大于IntakeAmountDayFlag,说明是大日未上报数据而积累下来,可以大于IntakeAmountDayFlag |
| | | //ad.amount = ad.amount ; |
| | |
| | | + "的情况,数据id=" + ad.id |
| | | + ",取水口id=" + ad.intakeId |
| | | + ",日期=" + ad.dt |
| | | + ",水量=" + ad.amount |
| | | + ",水量保持不变=" + ad.amount |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | log.info("出现相差多天日取水量大于" |
| | | + IntakeAmountDayFlag |
| | | + "并且属性totalAmountLast为null的情况,数据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, 0.0); |
| | | } |
| | | } |
| | | lastAd = ad ; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Transactional |
| | | int doUpdateOneIntakeAmountDay(Long id, Double amount){ |
| | | return dao.updateOneIntakeAmountDay(id, amount); |
| | | } |
| | | } |