|  |  |  | 
|---|
|  |  |  | package com.dy.pipIrrRemote.monitor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cn.hutool.core.date.DateUtil; | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSONArray; | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSONObject; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.Command; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.CommandBackParam; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.rtuState.RtuStatus; | 
|---|
|  |  |  | import com.dy.common.util.DateTime; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponse; | 
|---|
|  |  |  | import com.dy.common.webUtil.QueryResultVo; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.web.client.RestTemplate; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.text.DateFormat; | 
|---|
|  |  |  | import java.time.format.DateTimeFormatter; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 查询RTU在通信中间件中的支行状态 | 
|---|
|  |  |  | * 查询RTU在通信中间件中的在线状态 | 
|---|
|  |  |  | * @param rtuAddr | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public RtuStatus rtuStatus(String rtuAddr){ | 
|---|
|  |  |  | public RtuStatus rtuStatus(String rtuAddr) throws Exception{ | 
|---|
|  |  |  | //向通信中间件发关命令,查询部分RTU在线情况 | 
|---|
|  |  |  | RtuStatus rtuStatus = null ; | 
|---|
|  |  |  | Command com = this.createInnerCommand(CodeLocal.oneRtuStates); | 
|---|
|  |  |  | 
|---|
|  |  |  | if(bakParam != null){ | 
|---|
|  |  |  | if(bakParam.getSuccess().booleanValue()){ | 
|---|
|  |  |  | //通信中间件成功返回命令结果 | 
|---|
|  |  |  | rtuStatus = JSON.parseObject(JSON.toJSONString(reCom.getAttachment()), RtuStatus.class); | 
|---|
|  |  |  | if(reCom.getAttachment() != null){ | 
|---|
|  |  |  | rtuStatus = JSON.parseObject(JSON.toJSONString(reCom.getAttachment()), RtuStatus.class); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | throw new Exception("通信中间件未掌握该RTU的状态,可能该RTU未上线") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | log.error("通信中间件返回内部命令结果中不包含CommandBackParam类型参数"); | 
|---|
|  |  |  | throw new Exception("通信中间件执行命令出错") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | log.error("通信中间件返回内部命令执行失败" + (res.getMsg() == null? "" : ("," + res.getMsg()))) ; | 
|---|
|  |  |  | throw new Exception("通信中间件执行命令出错" + (res.getMsg() == null? "" : ("," + res.getMsg()))) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | log.error("通信中间件返回内部命令结果为null"); | 
|---|
|  |  |  | throw new Exception("通信中间件执行命令出错,返回内部命令结果为null") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return rtuStatus ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | rsVo.obj = records ; | 
|---|
|  |  |  | for(VoOnLineIntake rVo : records){ | 
|---|
|  |  |  | if(rVo.getAlarm() != null && !rVo.getAlarm().trim().equals("") && rVo.getAlarm().endsWith(",")){ | 
|---|
|  |  |  | rVo.setAlarm(rVo.getAlarm().substring(0, rVo.getAlarm().length() - 1)) ; | 
|---|
|  |  |  | if(rVo.getAlarmDt() != null){ | 
|---|
|  |  |  | rVo.setAlarm(rVo.getAlarm().substring(0, rVo.getAlarm().length() - 1) + "\n" + DateTime.yyyy_MM_dd_HH_mm_ss(rVo.getAlarmDt()) ) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | rVo.setAlarm(rVo.getAlarm().substring(0, rVo.getAlarm().length() - 1)) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return rsVo ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|