| | |
| | | import java.io.Serializable; |
| | | |
| | | import com.alibaba.fastjson2.JSON ; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | |
| | | public class Command implements Serializable{ |
| | | |
| | |
| | | public String id; |
| | | |
| | | /** |
| | | * 水表协议名称,这个可以为空,因为水表上行数据解析出协议名称,然后系统把协议名称保存在水表数据记录中,从此协议名称就不再空了 |
| | | * RTU协议名称,这个可以为空,因为RTU上行数据解析出协议名称,然后系统把协议名称保存在RTU数据记录中,从此协议名称就不再空了 |
| | | */ |
| | | public String protocol; |
| | | |
| | |
| | | * RTU 地址 |
| | | */ |
| | | public String rtuAddr ; |
| | | |
| | | /** |
| | | * 水表号 |
| | | * 应用电信平台时有效 |
| | | */ |
| | | public String meterNo ; |
| | | |
| | | /** |
| | | * 电信平台上的产品ID,当不在电信平台上运行时,为null |
| | | * 应用电信平台时有效 |
| | | */ |
| | | public Integer productId ; |
| | | |
| | | /** |
| | | * 电信平台上的设备ID,当不在电信平台上运行时,为null |
| | | * 应用电信平台时有效 |
| | | */ |
| | | public String deviceId ; |
| | | |
| | | |
| | | /** |
| | | * 命令类型:Rtu命令、针对监控中间件的命令 |
| | | * 由com.dy.common.mw.protocol.CommandType类定义 |
| | |
| | | public Boolean noRtMwDealRes ; |
| | | |
| | | /** |
| | | * rtu返回命令结果 发向目的地web URL |
| | | */ |
| | | public String rtuResultSendWebUrl ; |
| | | |
| | | /** |
| | | * 具体参数数据 |
| | | */ |
| | | public Object param ; |
| | |
| | | public String toString(){ |
| | | String s = "命令id=" + id + "\n" ; |
| | | s += (protocol == null ? "" : ("协议=" + protocol + "\n")); |
| | | s += (rtuAddr == null ? "" : ("IMEI号=" + rtuAddr + "\n")); |
| | | s += (meterNo == null ? "" : ("水表号=" + meterNo + "\n")); |
| | | if(productId != null){ |
| | | s += "电信平台产品ID=" + productId + "\n" ; |
| | | } |
| | | if(deviceId != null && !deviceId.trim().equals("")){ |
| | | s += "电信平台设备ID=" + deviceId + "\n" ; |
| | | } |
| | | s += "命令类型=" + (type.equals(CommandType.innerCommand)?"内部命令":"终端命令") + "\n" ; |
| | | s += (rtuAddr == null ? "" : ("Rtu地址=" + rtuAddr + "\n")); |
| | | s += "命令类型=" + (type.equals(CommandType.innerCommand)?"内部命令":"RTU命令") + "\n" ; |
| | | s += (code == null ? "" : ("功能码=" + code + "\n")) ; |
| | | s += "返回中间件对命令处理结果=" + (noRtMwDealRes == null?"返回":(noRtMwDealRes?"不返回":"返回") + "\n") ; |
| | | s += "是否返回中间件对命令处理结果=" + (noRtMwDealRes == null?"是":(noRtMwDealRes?"是":"否") + "\n") ; |
| | | if(param != null){ |
| | | s += "参数:" + param ; |
| | | } |
| | |
| | | @SuppressWarnings("unused") |
| | | public String toJson()throws Exception{ |
| | | try{ |
| | | return JSON.toJSONString(this) ; |
| | | String json = JSON.toJSONString(this) ; |
| | | return json ; |
| | | }catch(Exception e){ |
| | | throw new Exception(e.getMessage() , e ) ; |
| | | } |
| | |
| | | @SuppressWarnings("unused") |
| | | public static Command jsonToObject(String json)throws Exception{ |
| | | try{ |
| | | return JSON.parseObject(json, Command.class) ; |
| | | JSONObject jsonObject = JSON.parseObject(json); |
| | | Command command = jsonObject.to(Command.class) ; |
| | | //command.param = jsonObject.getObject("param", class); |
| | | return command ; |
| | | }catch(Exception e){ |
| | | throw new Exception(e.getMessage() , e ) ; |
| | | } |
| | |
| | | this.rtuAddr = rtuAddr; |
| | | return this ; |
| | | } |
| | | |
| | | |
| | | public String getRtuResultSendWebUrl() { |
| | | return rtuResultSendWebUrl; |
| | | } |
| | | |
| | | public void setRtuResultSendWebUrl(String rtuResultSendWebUrl) { |
| | | this.rtuResultSendWebUrl = rtuResultSendWebUrl; |
| | | } |
| | | |
| | | public String getProtocol() { |
| | | return protocol; |
| | | } |
| | | public void setProtocol(String protocol) { |
| | | this.protocol = protocol; |
| | | } |
| | | public String getMeterNo() { |
| | | return meterNo; |
| | | } |
| | | public void setMeterNo(String meterNo) { |
| | | this.meterNo = meterNo; |
| | | } |
| | | public Integer getProductId() { |
| | | return productId; |
| | | } |
| | | public void setProductId(Integer productId) { |
| | | this.productId = productId; |
| | | } |
| | | public String getDeviceId() { |
| | | return deviceId; |
| | | } |
| | | public void setDeviceId(String deviceId) { |
| | | this.deviceId = deviceId; |
| | | } |
| | | public String getType() { |
| | | return type; |