| | |
| | | package com.dy.rtuMw.server.rtuData.p206V1_0_0; |
| | | |
| | | import com.dy.pipIrrGlobal.pojoRm.RmLossHistory; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmLossLast; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmLossDay; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmLossDayLast; |
| | | import com.dy.rtuMw.server.rtuData.TaskSurpport; |
| | | import com.dy.rtuMw.server.rtuData.dbSv.DbSv; |
| | | import com.dy.common.mw.protocol.Data; |
| | |
| | | import com.dy.pipIrrGlobal.pojoPr.PrController; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | |
| | | * @param dataCdC0Vo 开阀上报数据对象 |
| | | */ |
| | | private void doDeal(DbSv sv, PrController controller, String rtuAddr, DataV1_0_1 dV1_0_1, DataCdC0Vo dataCdC0Vo) throws Exception { |
| | | RmLossLast poLast = sv.getRmLossLast(controller.getIntakeId()); |
| | | Date findDt = controller.getFindDt() ;//发现此控制器的日期与时间 |
| | | if(findDt != null){ |
| | | String findDtStr = DateTime.yyyy_MM_dd(findDt) ; |
| | | if(findDtStr.equals(DateTime.yyyy_MM_dd())){ |
| | | //当天发现控制器,控制器计算的漏损量一定不正确,强制设置成0 |
| | | dataCdC0Vo.lossAmount = 0.0 ; |
| | | } |
| | | } |
| | | |
| | | RmLossDayLast poLast = sv.getRmLossLast(controller.getIntakeId()); |
| | | if (poLast == null) { |
| | | //数据库中不存在该取水口的漏损数据 |
| | | //首先生成最新数据及历史数据,并先保存 |
| | |
| | | if(DateTime.dateFrom_yyyy_MM_dd_HH_mm_ss(dataCdC0Vo.rtuDt).equals(poLast.dtRtu)){ |
| | | //时间一致,重复上报数据,不进行任何处理 |
| | | }else{ |
| | | RmLossHistory poHistory = null ; |
| | | RmLossDay poHistory = null ; |
| | | if(poLast.lastHistoryId != null){ |
| | | poHistory = sv.getRmLossHistory(poLast.lastHistoryId) ; |
| | | } |
| | |
| | | //这种情况不存在(RTU时钟早于本地记录中的RTU时钟(RTU穿越回过去了,可能时钟重置了),此种情况不处理) |
| | | } |
| | | } |
| | | sv.updateRmLossLast(poLast); |
| | | } |
| | | } |
| | | |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | private RmLossLast newRmLossLast(PrController controller, String rtuAddr, DataV1_0_1 dV1_0_1, DataCdC0Vo cdData)throws Exception { |
| | | RmLossLast po = new RmLossLast() ; |
| | | private RmLossDayLast newRmLossLast(PrController controller, String rtuAddr, DataV1_0_1 dV1_0_1, DataCdC0Vo cdData)throws Exception { |
| | | RmLossDayLast po = new RmLossDayLast() ; |
| | | po.controllerId = controller==null?null:controller.getId(); |
| | | po.intakeId = controller==null?null:controller.getIntakeId(); |
| | | po.rtuAddr = rtuAddr; |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | private RmLossHistory newRmLossHistory(PrController controller, String rtuAddr, DataV1_0_1 dV1_0_1, DataCdC0Vo cdData)throws Exception { |
| | | RmLossHistory po = new RmLossHistory() ; |
| | | private RmLossDay newRmLossHistory(PrController controller, String rtuAddr, DataV1_0_1 dV1_0_1, DataCdC0Vo cdData)throws Exception { |
| | | RmLossDay po = new RmLossDay() ; |
| | | po.controllerId = controller==null?null:controller.getId(); |
| | | po.intakeId = controller==null?null:controller.getIntakeId(); |
| | | po.rtuAddr = rtuAddr; |
| | |
| | | * @throws Exception |
| | | * @return RmLossHistory |
| | | */ |
| | | private RmLossHistory newAndSaveHistoryDataDeal(DbSv sv, PrController controller, String rtuAddr, DataV1_0_1 dV1_0_1, DataCdC0Vo dataCdC0Vo, RmLossLast poLast)throws Exception { |
| | | RmLossHistory poHistory = this.newRmLossHistory(controller, rtuAddr, dV1_0_1, dataCdC0Vo) ; |
| | | private RmLossDay newAndSaveHistoryDataDeal(DbSv sv, PrController controller, String rtuAddr, DataV1_0_1 dV1_0_1, DataCdC0Vo dataCdC0Vo, RmLossDayLast poLast)throws Exception { |
| | | RmLossDay poHistory = this.newRmLossHistory(controller, rtuAddr, dV1_0_1, dataCdC0Vo) ; |
| | | sv.saveRmLossHistory(poHistory); |
| | | //由最新数据持有历史数据中的最新记录ID,以方便快速查询 |
| | | poLast.lastHistoryId = poHistory == null ? null: poHistory.id ; |