|  |  | 
 |  |  | package com.dy.rtuMw.server.rtuData.dbSv; | 
 |  |  |  | 
 |  |  | import com.dy.pipIrrGlobal.daoPr.PrControllerMapper; | 
 |  |  | import com.dy.pipIrrGlobal.daoPr.PrControllerTrampMapper; | 
 |  |  | import com.dy.common.util.NumUtil; | 
 |  |  | import com.dy.pipIrrGlobal.daoPr.*; | 
 |  |  | import com.dy.pipIrrGlobal.daoRm.*; | 
 |  |  | import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper; | 
 |  |  | import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper; | 
 |  |  | import com.dy.pipIrrGlobal.pojoPr.PrController; | 
 |  |  | import com.dy.pipIrrGlobal.pojoPr.PrControllerTramp; | 
 |  |  | import com.dy.pipIrrGlobal.pojoPr.*; | 
 |  |  | import com.dy.pipIrrGlobal.pojoRm.*; | 
 |  |  | import com.dy.pipIrrGlobal.pojoSe.SeClient; | 
 |  |  | import com.dy.pipIrrGlobal.voSe.VoCardInfo1; | 
 |  |  | 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; | 
 |  |  | import java.util.Map; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * @Author liurunyu | 
 |  |  | 
 |  |  |  */ | 
 |  |  | @Service() | 
 |  |  | public class DbSv { | 
 |  |  |     @Autowired | 
 |  |  |     private SeClientCardMapper seClientCardDao;//农户水卡DAO | 
 |  |  |     @Autowired | 
 |  |  |     private SeVirtualCardMapper seVirtualCardDao ;//虚拟卡相关DAO | 
 |  |  |     @Autowired | 
 |  |  |     private PrControllerTrampMapper prControllerTrampMapperDao;//流浪控制器DAO | 
 |  |  |     @Autowired | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private RmWorkReportHistoryMapper rmWorkReportHistoryMapperDao ;//控制器历史工作报数据DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmLossLastMapper rmLossLastMapperDao ;//控制器漏损水量统计最新数据DAO | 
 |  |  |     private RmIntakeAmountDayLastMapper rmIntakeAmountDayLastMapperDao ;//取水口取水统计最新数据DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmLossHistoryMapper rmLossHistoryMapperDao ;//控制器漏损水量统计历史数据DAO | 
 |  |  |     private RmIntakeAmountDayMapper rmIntakeAmountDayMapperDao ;//取水口取水和漏损统计DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmClientAmountDayLastMapper rmClientAmountDayLastMapperDao ;//农户日用水量统计最新数据DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmClientAmountDayMapper rmClientAmountDayMapperDao ;//农户日用水量统计数据DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmLossDayLastMapper rmLossLastMapperDao ;//控制器漏损水量统计最新数据DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmLossDayMapper rmLossHistoryMapperDao ;//控制器漏损水量统计历史数据DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmCommandHistoryMapper rmCommandHistoryDao ;//远程命令日志相关 | 
 |  |  |     @Autowired | 
 |  |  |     private SeVirtualCardMapper seVirtualCardDao ;//虚拟卡相关 | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private RmTimingReportHistoryMapper rmTimingReportHistoryDao; // 定点上报历史数据DAO | 
 |  |  | 
 |  |  |     private RmTimingReportLastMapper rmTimingReportLastDao; // 定点上报最新数据DAO | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private RmOnHourReportHistoryMapper rmOnHourReportHistoryDao; // 整点上报历史数据DAO | 
 |  |  |     private RmOnHourReportHistoryMapper rmOnHourReportHistoryDao; // 定点上报历史数据DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmOnHourReportLastMapper rmOnHourReportLastDao; // 整点上报最新数据DAO | 
 |  |  |     private RmOnHourReportLastMapper rmOnHourReportLastDao; // 定点上报最新数据DAO | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private RmOpenCloseHistoryMapper rmOpenCloseHistoryDao; | 
 |  |  |     private PrStManureMapper prStManureDao; //水肥机DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmOpenCloseLastMapper rmOpenCloseLastDao; | 
 |  |  |     private PrStSoilMapper prStSoilDao; //墒情站DAO | 
 |  |  |     @Autowired | 
 |  |  |     private PrStWeatherMapper prStWeatherDao; //气象站DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmManureLastMapper rmManureLastDao; //水肥DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmManureHistoryMapper rmManureHistoryDao; //水肥DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmSoilLastMapper rmSoilLastDao; //墒情DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmSoilHistoryMapper rmSoilHistoryDao; //墒情DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmSoilDayMapper rmSoilDayDao; //墒情DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmWeatherLastMapper rmWeatherLastDao; //气象DAO | 
 |  |  |     @Autowired | 
 |  |  |     private RmWeatherHistoryMapper rmWeatherHistoryDao; //气象DAO | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     //@Autowired | 
 |  |  |     //@Lazy | 
 |  |  | 
 |  |  |     // 基础功能 | 
 |  |  |     // | 
 |  |  |     //////////////////////////////////////////////// | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 通过物理IC地址及卡号得到农户id和姓名 | 
 |  |  |      * @param icCardAddr | 
 |  |  |      * @param icCardNo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public SeClient getClientIdAndNameByCardAddrAndCardNo(String icCardAddr, String icCardNo){ | 
 |  |  |         SeClient vo = null ; | 
 |  |  |         if(NumUtil.isPlusIntNumber(icCardNo)){ | 
 |  |  |             Long icCardNoLong = Long.parseLong(icCardNo) ; | 
 |  |  |             Map<String, Object> map = seClientCardDao.getClientIdAndNameByCardAddrAndCardNo(icCardAddr, icCardNoLong) ; | 
 |  |  |             if(map != null && map.size() > 0) { | 
 |  |  |                 vo = new SeClient() ; | 
 |  |  |                 vo.setId(Long.parseLong(map.get("clientId").toString())); | 
 |  |  |                 vo.setName(map.get("clientName").toString()); | 
 |  |  |                 vo.setAddress(map.get("clientAddress").toString()); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return vo ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 通过虚拟IC卡号得到农户id和姓名 | 
 |  |  |      * @param icCardNo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public SeClient getClientIdAndNameByVsCardNo(String icCardNo){ | 
 |  |  |         SeClient vo = null ; | 
 |  |  |         if(NumUtil.isPlusIntNumber(icCardNo)){ | 
 |  |  |             Long icCardNoLong = Long.parseLong(icCardNo) ; | 
 |  |  |             Map<String, Object> map = seVirtualCardDao.getClientIdAndNameByVsCardNo(icCardNoLong) ; | 
 |  |  |             if(map != null && map.size() > 0) { | 
 |  |  |                 vo = new SeClient() ; | 
 |  |  |                 vo.setId(Long.parseLong(map.get("clientId").toString())); | 
 |  |  |                 vo.setName(map.get("clientName").toString()); | 
 |  |  |                 vo.setAddress(map.get("clientAddress").toString()); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return vo ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 通过控制器地址从数据库表中查询控制器 | 
 |  |  |      * @param rtuAddr 控制器地址 | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void savePrConctrollerTramp(PrControllerTramp po){ | 
 |  |  |         if(po.getOrgTag().trim().length() > 2) { | 
 |  |  |             po.setOrgTag("DY"); | 
 |  |  |         } | 
 |  |  |         this.prControllerTrampMapperDao.insert(po) ; | 
 |  |  |     } | 
 |  |  |    /** | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updatePrConctrollerTramp(PrControllerTramp po){ | 
 |  |  |         this.prControllerTrampMapperDao.updateByPrimaryKeySelective(po) ; | 
 |  |  |         this.prControllerTrampMapperDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |     //////////////////////////////////////////////// | 
 |  |  |     /** | 
 |  |  |      * 得到控制器报警与状态最新记录 | 
 |  |  |      * @param rtuAddr | 
 |  |  |      * @param intakeId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmAlarmStateLast getRmAlarmStateLast(String rtuAddr){ | 
 |  |  |         List<RmAlarmStateLast> list = rmAlarmStateLastMapperDao.selectByRtuAddr(rtuAddr) ; | 
 |  |  |     public RmAlarmStateLast getRmAlarmStateLast(Long intakeId){ | 
 |  |  |         List<RmAlarmStateLast> list = rmAlarmStateLastMapperDao.selectByIntakeId(intakeId) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmAlarmStateLast(RmAlarmStateLast po){ | 
 |  |  |         this.rmAlarmStateLastMapperDao.updateByPrimaryKeySelective(po) ; | 
 |  |  |         this.rmAlarmStateLastMapperDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 保存控制器报警与状态历史记录 | 
 |  |  | 
 |  |  |      * @param intakeId | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateVirCardNoUseState(Long intakeId){ | 
 |  |  |         this.seVirtualCardDao.updateVcCardNoUseStateByIntakeId(intakeId); ; | 
 |  |  |     public void updateVirCardNoUseState(Long intakeId, Date now){ | 
 |  |  |         this.seVirtualCardDao.updateVcCardNoUseStateByIntakeId(intakeId, now) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据阀控器地址获取定点上报最新数据 | 
 |  |  |      * @param rtuAddr | 
 |  |  |      * @param intakeId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public RmTimingReportLast getRmTimingReportLast(String rtuAddr) { | 
 |  |  |         List<RmTimingReportLast> list = this.rmTimingReportLastDao.getRmTimingReportLast(rtuAddr) ; | 
 |  |  |     public RmTimingReportLast getRmTimingReportLast(Long intakeId) { | 
 |  |  |         List<RmTimingReportLast> list = this.rmTimingReportLastDao.getRmTimingReportLast(intakeId) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmTimingReportLast(RmTimingReportLast po) { | 
 |  |  |         this.rmTimingReportLastDao.updateByPrimaryKeySelective(po); | 
 |  |  |         this.rmTimingReportLastDao.updateByPrimaryKey(po); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     ///////////////////////////////////////////////// | 
 |  |  |     // | 
 |  |  |     // 整点上报实时数据功能(只在靳总的协议有此数据) | 
 |  |  |     // 定点上报实时数据功能(只在靳总的协议有此数据) | 
 |  |  |     // | 
 |  |  |     //////////////////////////////////////////////// | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 保存控制器整点上报历史数据 | 
 |  |  |      * 保存控制器定点上报历史数据 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据阀控器地址获取整点上报最新数据 | 
 |  |  |      * @param rtuAddr | 
 |  |  |      * 根据阀控器地址获取定点上报最新数据 | 
 |  |  |      * @param intakeId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public RmOnHourReportLast getRmOnHourReportLast(String rtuAddr) { | 
 |  |  |         List<RmOnHourReportLast> list = this.rmOnHourReportLastDao.getRmOnHourReportLast(rtuAddr) ; | 
 |  |  |     public RmOnHourReportLast getRmOnHourReportLast(Long intakeId) { | 
 |  |  |         List<RmOnHourReportLast> list = this.rmOnHourReportLastDao.getRmOnHourReportLast(intakeId) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 保存控制器整点上报最新数据 | 
 |  |  |      * 保存控制器定点上报最新数据 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 保存控制器整点上报罪行数据 | 
 |  |  |      * 保存控制器定点上报罪行数据 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmOnHourReportLast(RmOnHourReportLast po) { | 
 |  |  |         this.rmOnHourReportLastDao.updateByPrimaryKeySelective(po); | 
 |  |  |         this.rmOnHourReportLastDao.updateByPrimaryKey(po); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     ///////////////////////////////////////////////// | 
 |  |  | 
 |  |  |     //////////////////////////////////////////////// | 
 |  |  |     /** | 
 |  |  |      * 得到控制器开关阀上报数据最新记录 | 
 |  |  |      * @param rtuAddr | 
 |  |  |      * @param intakeId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmOpenCloseValveLast getRmOpenCloseValveLast(String rtuAddr){ | 
 |  |  |         List<RmOpenCloseValveLast> list = rmOpenCloseValveLastMapperDao.selectByRtuAddr(rtuAddr) ; | 
 |  |  |     public RmOpenCloseValveLast getRmOpenCloseValveLast(Long intakeId){ | 
 |  |  |         List<RmOpenCloseValveLast> list = rmOpenCloseValveLastMapperDao.selectByIntakeId(intakeId) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmOpenCloseValveLast(RmOpenCloseValveLast po){ | 
 |  |  |         this.rmOpenCloseValveLastMapperDao.updateByPrimaryKeySelective(po) ; | 
 |  |  |         this.rmOpenCloseValveLastMapperDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 得到控制器开关阀上报数据历史数据中的最新记录 | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmOpenCloseValveHistory(RmOpenCloseValveHistory po){ | 
 |  |  |         this.rmOpenCloseValveHistoryMapperDao.updateByPrimaryKeySelective(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 保存控制器开关阀上报数据最新记录(202404) | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmOpenCloseLast(RmOpenCloseLast po){ | 
 |  |  |         this.rmOpenCloseLastDao.insert(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 保存控制器开关阀上报数据历史记录(202404) | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmOpenCloseHistory(RmOpenCloseHistory po){ | 
 |  |  |         this.rmOpenCloseHistoryDao.insert(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 得到控制器开关阀上报数据最新记录(202404) | 
 |  |  |      * @param rtuAddr | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmOpenCloseLast getRmOpenCloseLast(String rtuAddr){ | 
 |  |  |         List<RmOpenCloseLast> list = rmOpenCloseLastDao.getRmOpenCloseReportLast(rtuAddr); | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 保存控制器开关阀上报数据最新记录(202404) | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmOpenCloseLast(RmOpenCloseLast po){ | 
 |  |  |         this.rmOpenCloseLastDao.updateByPrimaryKeySelective(po); | 
 |  |  |         this.rmOpenCloseValveHistoryMapperDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     ///////////////////////////////////////////////// | 
 |  |  | 
 |  |  |     //////////////////////////////////////////////// | 
 |  |  |     /** | 
 |  |  |      * 得到控制器上报数据最新记录 | 
 |  |  |      * @param rtuAddr | 
 |  |  |      * @param intakeId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmWorkReportLast getRmWorkReportLast(String rtuAddr){ | 
 |  |  |         List<RmWorkReportLast> list = rmWorkReportLastMapperDao.selectByRtuAddr(rtuAddr) ; | 
 |  |  |     public RmWorkReportLast getRmWorkReportLast(Long intakeId){ | 
 |  |  |         List<RmWorkReportLast> list = rmWorkReportLastMapperDao.selectByIntakeId(intakeId) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmWorkReportLast(RmWorkReportLast po){ | 
 |  |  |         this.rmWorkReportLastMapperDao.updateByPrimaryKeySelective(po) ; | 
 |  |  |         this.rmWorkReportLastMapperDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 保存控制器上报数据历史记录 | 
 |  |  | 
 |  |  |         this.rmWorkReportHistoryMapperDao.insert(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     ///////////////////////////////////////////////// | 
 |  |  |     // | 
 |  |  |     // 取水口日取水量统计功能 | 
 |  |  |     // | 
 |  |  |     //////////////////////////////////////////////// | 
 |  |  |     /** | 
 |  |  |      * 得到最新记录 | 
 |  |  |      * @param intakeId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmIntakeAmountDayLast getRmIntakeAmountLast(Long intakeId){ | 
 |  |  |         List<RmIntakeAmountDayLast> list = rmIntakeAmountDayLastMapperDao.selectByIntakeId(intakeId) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 保存最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmIntakeAmountLast(RmIntakeAmountDayLast po){ | 
 |  |  |         this.rmIntakeAmountDayLastMapperDao.insert(po) ; | 
 |  |  |     } | 
 |  |  |   /** | 
 |  |  |      * 保存记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmIntakeAmountDay(RmIntakeAmountDay po){ | 
 |  |  |         this.rmIntakeAmountDayMapperDao.insert(po) ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 保存最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmIntakeAmountLast(RmIntakeAmountDayLast po){ | 
 |  |  |         this.rmIntakeAmountDayLastMapperDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 保存历史记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmIntakeAmountDay(RmIntakeAmountDay po){ | 
 |  |  |         this.rmIntakeAmountDayMapperDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 得到符合条件的历史记录 | 
 |  |  |      * @param id | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmIntakeAmountDay getRmIntakeAmountDay(Long id){ | 
 |  |  |         return rmIntakeAmountDayMapperDao.selectByPrimaryKey(id) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     ///////////////////////////////////////////////// | 
 |  |  |     // | 
 |  |  |     // 农户日用水量及花费统计功能 | 
 |  |  |     // | 
 |  |  |     //////////////////////////////////////////////// | 
 |  |  |     /** | 
 |  |  |      * 得到最新记录 | 
 |  |  |      * @param clientId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmClientAmountDayLast getRmClientAmountLast(Long clientId){ | 
 |  |  |         List<RmClientAmountDayLast> list = rmClientAmountDayLastMapperDao.selectByClientId(clientId) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 保存最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmClientAmountLast(RmClientAmountDayLast po){ | 
 |  |  |         this.rmClientAmountDayLastMapperDao.insert(po) ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 保存记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmClientAmountDay(RmClientAmountDay po){ | 
 |  |  |         this.rmClientAmountDayMapperDao.insert(po) ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 更新最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmClientAmountLast(RmClientAmountDayLast po){ | 
 |  |  |         this.rmClientAmountDayLastMapperDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 更新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmClientAmountDay(RmClientAmountDay po){ | 
 |  |  |         this.rmClientAmountDayMapperDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 得到符合条件的历史记录 | 
 |  |  |      * @param id | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmClientAmountDay getRmClientAmountDay(Long id){ | 
 |  |  |         return rmClientAmountDayMapperDao.selectByPrimaryKey(id) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 得到符合条件的历史记录 | 
 |  |  |      * @param clientId | 
 |  |  |      * @param dt | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmClientAmountDay getRmClientAmountByClientAndDate(Long clientId, Date dt){ | 
 |  |  |         List<RmClientAmountDay> list = rmClientAmountDayMapperDao.selectByClientAndDate(clientId, dt) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     ///////////////////////////////////////////////// | 
 |  |  |     // | 
 |  |  | 
 |  |  |     //////////////////////////////////////////////// | 
 |  |  |     /** | 
 |  |  |      * 得到控制器漏损水量统计最新记录 | 
 |  |  |      * @param rtuAddr | 
 |  |  |      * @param intakeId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmLossLast getRmLossLast(String rtuAddr){ | 
 |  |  |         List<RmLossLast> list = rmLossLastMapperDao.selectByRtuAddr(rtuAddr) ; | 
 |  |  |     public RmLossDayLast getRmLossLast(Long intakeId){ | 
 |  |  |         List<RmLossDayLast> list = rmLossLastMapperDao.selectByIntakeId(intakeId) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmLossLast(RmLossLast po){ | 
 |  |  |     public void saveRmLossLast(RmLossDayLast po){ | 
 |  |  |         this.rmLossLastMapperDao.insert(po) ; | 
 |  |  |     } | 
 |  |  |   /** | 
 |  |  | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmLossHistory(RmLossHistory po){ | 
 |  |  |     public void saveRmLossHistory(RmLossDay po){ | 
 |  |  |         this.rmLossHistoryMapperDao.insert(po) ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmLossLast(RmLossLast po){ | 
 |  |  |         this.rmLossLastMapperDao.updateByPrimaryKeySelective(po) ; | 
 |  |  |     public void updateRmLossLast(RmLossDayLast po){ | 
 |  |  |         this.rmLossLastMapperDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 保存控制器漏损水量统计最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmLossHistory(RmLossHistory po){ | 
 |  |  |         this.rmLossHistoryMapperDao.updateByPrimaryKeySelective(po) ; | 
 |  |  |     public void updateRmLossHistory(RmLossDay po){ | 
 |  |  |         this.rmLossHistoryMapperDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |      * @param id | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmLossHistory getRmLossHistory(Long id){ | 
 |  |  |     public RmLossDay getRmLossHistory(Long id){ | 
 |  |  |         return rmLossHistoryMapperDao.selectByPrimaryKey(id) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * @param dt | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmLossLast getRmLossLastByDate(Date dt){ | 
 |  |  |         List<RmLossLast> list = rmLossLastMapperDao.selectByDate(dt) ; | 
 |  |  |     public RmLossDayLast getRmLossLastByDate(Date dt){ | 
 |  |  |         List<RmLossDayLast> list = rmLossLastMapperDao.selectByDate(dt) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  | 
 |  |  |      * @param dt | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmLossHistory getRmLossHistoryByDate(Date dt){ | 
 |  |  |         List<RmLossHistory> list = rmLossHistoryMapperDao.selectByDate(dt) ; | 
 |  |  |     public RmLossDay getRmLossHistoryByDate(Date dt){ | 
 |  |  |         List<RmLossDay> list = rmLossHistoryMapperDao.selectByDate(dt) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     ////////////////////////////////////////////////////// | 
 |  |  |     // | 
 |  |  |     // IC卡相关 | 
 |  |  |     // | 
 |  |  |     ////////////////////////////////////////////////////// | 
 |  |  |     /** | 
 |  |  |      * 得到农户卡 | 
 |  |  |      * @param cardAddr | 
 |  |  |      * @param cardNo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public VoCardInfo1 getIcCard(String cardAddr, String cardNo){ | 
 |  |  |         if(NumUtil.isPlusIntNumber(cardNo)){ | 
 |  |  |             Long icCardNoLong = Long.parseLong(cardNo) ; | 
 |  |  |             List<VoCardInfo1> list = seClientCardDao.getCardsByAddrAndNum(cardAddr, icCardNoLong) ; | 
 |  |  |             if(list != null && list.size() > 0){ | 
 |  |  |                 return list.get(0) ; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 得到农户虚拟卡 | 
 |  |  |      * @param cardNo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public VoCardInfo1 getVirIcCard(String cardNo){ | 
 |  |  |         if(NumUtil.isPlusIntNumber(cardNo)){ | 
 |  |  |             Long icCardNoLong = Long.parseLong(cardNo) ; | 
 |  |  |             List<VoCardInfo1> list = seVirtualCardDao.getCardsByNum(icCardNoLong) ; | 
 |  |  |             if(list != null && list.size() > 0){ | 
 |  |  |                 return list.get(0) ; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 更新实体卡剩余金额 | 
 |  |  |      * @param id | 
 |  |  |      * @param remainMoney | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateIcCardRemainMoney(Long id , Double remainMoney){ | 
 |  |  |         seClientCardDao.updateMoney(id,remainMoney); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 更新虚拟卡剩余金额 | 
 |  |  |      * @param id | 
 |  |  |      * @param remainMoney | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateVirIcCardRemainMoney(Long id , Double remainMoney){ | 
 |  |  |         seVirtualCardDao.updateMoney(id,remainMoney); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     ////////////////////////////////////////////////////// | 
 |  |  |     // | 
 |  |  |     // 水肥数据相关 | 
 |  |  |     // | 
 |  |  |     ////////////////////////////////////////////////////// | 
 |  |  |     /** | 
 |  |  |      * 通过FBox序列号得到水肥机实体 | 
 |  |  |      * @param fboxId FBox序列号 | 
 |  |  |      * @param no 编号 | 
 |  |  |      * @return 水肥机实体 | 
 |  |  |      */ | 
 |  |  |     public PrStManure getStManureByFBoxIdAndNo(String fboxId, Integer no){ | 
 |  |  |         List<PrStManure> list = this.prStManureDao.selectStPoByFBoxIdAndNo(fboxId, no) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 查询上报最新数据 | 
 |  |  |      * @param stManureId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmManureLast getRmManureLast(Long stManureId) { | 
 |  |  |         List<RmManureLast> list = this.rmManureLastDao.selectRmManureLast(stManureId) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 保存最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmManureHistory(RmManureHistory po) { | 
 |  |  |         this.rmManureHistoryDao.insert(po); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 保存最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmManureLast(RmManureLast po) { | 
 |  |  |         this.rmManureLastDao.insert(po); | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 更新最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmManureLast(RmManureLast po){ | 
 |  |  |         this.rmManureLastDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     ////////////////////////////////////////////////////// | 
 |  |  |     // | 
 |  |  |     // 墒情数据相关 | 
 |  |  |     // | 
 |  |  |     ////////////////////////////////////////////////////// | 
 |  |  |     /** | 
 |  |  |      * 通过FBox序列号得到墒情站实体 | 
 |  |  |      * @param fboxId FBox序列号 | 
 |  |  |      * @param no 编号 | 
 |  |  |      * @return 水肥机实体 | 
 |  |  |      */ | 
 |  |  |     public PrStSoil getStSoilByFBoxIdAndNo(String fboxId, Integer no){ | 
 |  |  |         List<PrStSoil> list = this.prStSoilDao.selectStPoByFBoxIdAndNo(fboxId, no) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 查询上报最新数据 | 
 |  |  |      * @param stSoilId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmSoilLast getRmSoilLast(Long stSoilId) { | 
 |  |  |         List<RmSoilLast> list = this.rmSoilLastDao.selectRmSoilLast(stSoilId) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 保存最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmSoilHistory(RmSoilHistory po) { | 
 |  |  |         this.rmSoilHistoryDao.insert(po); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 保存最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmSoilLast(RmSoilLast po) { | 
 |  |  |         this.rmSoilLastDao.insert(po); | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 更新最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmSoilLast(RmSoilLast po){ | 
 |  |  |         this.rmSoilLastDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 查询上报日数据 | 
 |  |  |      * @param stSoilId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public RmSoilDay getRmSoilDay(Long stSoilId, Integer nowYmd) { | 
 |  |  |         List<RmSoilDay> list = this.rmSoilDayDao.selectRmSoilDay(stSoilId, nowYmd) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 保存日记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmSoilDay(RmSoilDay po) { | 
 |  |  |         this.rmSoilDayDao.insert(po); | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 更新日记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmSoilDay(RmSoilDay po){ | 
 |  |  |         this.rmSoilDayDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     ////////////////////////////////////////////////////// | 
 |  |  |     // | 
 |  |  |     // 气象数据相关 | 
 |  |  |     // | 
 |  |  |     ////////////////////////////////////////////////////// | 
 |  |  |     /** | 
 |  |  |      * 通过FBox序列号得到气象站实体 | 
 |  |  |      * @param fboxId FBox序列号 | 
 |  |  |      * @param no 编号 | 
 |  |  |      * @return 水肥机实体 | 
 |  |  |      */ | 
 |  |  |     public PrStWeather getStWeatherByFBoxIdAndNo(String fboxId, Integer no){ | 
 |  |  |         List<PrStWeather> list = this.prStWeatherDao.selectStPoByFBoxIdAndNo(fboxId, no) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 查询上报最新数据 | 
 |  |  |      * @param stWeatherId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public RmWeatherLast getRmWeatherLast(Long stWeatherId) { | 
 |  |  |         List<RmWeatherLast> list = this.rmWeatherLastDao.selectRmWeatherLast(stWeatherId) ; | 
 |  |  |         if(list != null && list.size() > 0){ | 
 |  |  |             return list.get(0) ; | 
 |  |  |         } | 
 |  |  |         return null ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 保存最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmWeatherHistory(RmWeatherHistory po) { | 
 |  |  |         this.rmWeatherHistoryDao.insert(po); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 保存最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void saveRmWeatherLast(RmWeatherLast po) { | 
 |  |  |         this.rmWeatherLastDao.insert(po); | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 更新最新记录 | 
 |  |  |      * @param po | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateRmWeatherLast(RmWeatherLast po){ | 
 |  |  |         this.rmWeatherLastDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     ////////////////////////////////////////////////////// | 
 |  |  | 
 |  |  |     public RmCommandHistory getCommandLog(String commandId){ | 
 |  |  |         return rmCommandHistoryDao.selectByPrimaryKey(Long.parseLong(commandId)) ; | 
 |  |  |     } | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public void updateCommandLog(RmCommandHistory po){ | 
 |  |  |         rmCommandHistoryDao.updateByPrimaryKeySelective(po) ; | 
 |  |  |         rmCommandHistoryDao.updateByPrimaryKey(po) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  |