|  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.protocol.Command; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.CommandBackParam; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponse; | 
|---|
|  |  |  | import com.dy.common.webUtil.QueryResultVo; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.VoAllRound.VoArIntakeRemote; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voAllRound.VoArIntakeRemote; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.daoAllRound.Ar4BaseMapper; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.daoAllRound.Ar4RemoteMapper; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.rtuMw.CodeLocal; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voPr.VoOnLineIntake; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.core.env.Environment; | 
|---|
|  |  |  | 
|---|
|  |  |  | private Ar4BaseMapper baseDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private Ar4RemoteMapper remoteDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private Environment env; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | * 取水口基本信息 | 
|---|
|  |  |  | * @return 取水口基本信息 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public QueryResultVo<VoArIntakeRemote> intakeInfo(Long intakeId){ | 
|---|
|  |  |  | public VoArIntakeRemote intakeInfo(Long intakeId){ | 
|---|
|  |  |  | VoArIntakeRemote rVo = new VoArIntakeRemote() ; | 
|---|
|  |  |  | rVo.intakeId = intakeId ; | 
|---|
|  |  |  | String rtuAddr = this.getRtuAddr(intakeId); | 
|---|
|  |  |  | this.getRtuOnLine(rtuAddr, rVo); | 
|---|
|  |  |  | this.getAlarmLastInfo(intakeId, rVo); | 
|---|
|  |  |  | this.getOpenCloseValveLastInfo(intakeId, rVo); | 
|---|
|  |  |  | this.getLossAmountLastInfo(intakeId, rVo); | 
|---|
|  |  |  | return rVo ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String rtuAddr = null ; | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取取水口对应的RTU地址 | 
|---|
|  |  |  | * @param intakeId 取水口ID | 
|---|
|  |  |  | * @return RTU地址 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String getRtuAddr(Long intakeId){ | 
|---|
|  |  |  | List<String> rtuAddrs = baseDao.intakeRtuAddr(intakeId) ; | 
|---|
|  |  |  | if(rtuAddrs != null && rtuAddrs.size() > 0){ | 
|---|
|  |  |  | rtuAddr = rtuAddrs.get(0) ; | 
|---|
|  |  |  | return rtuAddrs.get(0) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 得到取水RTU在线情况 | 
|---|
|  |  |  | * @param rtuAddr | 
|---|
|  |  |  | * @param rVo | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void getRtuOnLine(String rtuAddr, VoArIntakeRemote rVo){ | 
|---|
|  |  |  | if(rtuAddr != null){ | 
|---|
|  |  |  | //向通信中间件发关命令,查询部分RTU在线情况 | 
|---|
|  |  |  | Command com = this.createInnerCommand(CodeLocal.onLinePart); | 
|---|
|  |  |  | 
|---|
|  |  |  | log.error("通信中间件返回内部命令结果为null"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return null ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 得到取水口最新报警信息 | 
|---|
|  |  |  | * @param intakeId | 
|---|
|  |  |  | * @param rVo | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void getAlarmLastInfo(Long intakeId, VoArIntakeRemote rVo){ | 
|---|
|  |  |  | List<VoArIntakeRemote> list = remoteDao.alarmLastInfo(intakeId); | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | VoArIntakeRemote vo = list.get(0) ; | 
|---|
|  |  |  | rVo.alarm = vo.alarm ; | 
|---|
|  |  |  | if(rVo.alarm == null || rVo.alarm.trim().equals("")){ | 
|---|
|  |  |  | rVo.alarm = "无报警" ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | rVo.alarmDt = vo.alarmDt ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 得到取水口最新开关阀信息 | 
|---|
|  |  |  | * @param intakeId | 
|---|
|  |  |  | * @param rVo | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void getOpenCloseValveLastInfo(Long intakeId, VoArIntakeRemote rVo){ | 
|---|
|  |  |  | List<VoArIntakeRemote> list = remoteDao.openCloseValveLastInfo(intakeId); | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | VoArIntakeRemote vo = list.get(0) ; | 
|---|
|  |  |  | rVo.lastOpenDt = vo.lastOpenDt ; | 
|---|
|  |  |  | rVo.lastCloseDt = vo.lastCloseDt ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 得到取水口最新漏损信息 | 
|---|
|  |  |  | * @param intakeId | 
|---|
|  |  |  | * @param rVo | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void getLossAmountLastInfo(Long intakeId, VoArIntakeRemote rVo){ | 
|---|
|  |  |  | List<VoArIntakeRemote> list = remoteDao.lossLastInfo(intakeId); | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | VoArIntakeRemote vo = list.get(0) ; | 
|---|
|  |  |  | rVo.lossDt = vo.lossDt ; | 
|---|
|  |  |  | rVo.lossAmount = vo.lossAmount ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|