|
|
|
@ -121,7 +121,7 @@ public class NettyServer { |
|
|
|
//绑定端口,开始接收进来的连接 |
|
|
|
try { |
|
|
|
ChannelFuture future = bootstrap.bind(serverPort).sync(); |
|
|
|
logger.info("################ TCP服务器启动 ################"); |
|
|
|
logger.info("###### TCP服务器启动 ######"); |
|
|
|
future.channel().closeFuture().sync(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
@ -140,11 +140,16 @@ public class NettyServer { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String compact(String xml) { |
|
|
|
String compactXml = xml |
|
|
|
.replaceAll(">\\s+<", "><") // 处理标签间的空白 |
|
|
|
.replaceAll("\\s+", " "); // 压缩连续空格(可选) |
|
|
|
return compactXml; |
|
|
|
} |
|
|
|
|
|
|
|
//发送消息 |
|
|
|
public void flushMsgToDevice(String uuid, String clientKey, boolean request, String xml) { |
|
|
|
logger.info("clientKey: " + clientKey + ", tcpClientMap.size(): " + tcpClientMap.size() + ", tcpClientMap: " + tcpClientMap); |
|
|
|
|
|
|
|
if (tcpClientMap.containsKey(clientKey) && !StringUtil.isNullOrEmpty(xml)) { |
|
|
|
if (tcpClientMap.containsKey(clientKey)) { |
|
|
|
ByteBuf byteBuf = Unpooled.copiedBuffer(xml, CharsetUtil.UTF_8); |
|
|
|
int length = byteBuf.readableBytes(); |
|
|
|
ByteBuf allBuf = Unpooled.buffer(length + ConfigType.dataLength); |
|
|
|
@ -158,17 +163,16 @@ public class NettyServer { |
|
|
|
allBuf.writeByte(0xEB); |
|
|
|
allBuf.writeByte(0x90); |
|
|
|
redisTemplate.opsForValue().set(String.valueOf(sendIndex), allBuf.toString(CharsetUtil.US_ASCII), 60L, TimeUnit.SECONDS); |
|
|
|
logger.info(Color.MAGENTA + "######## => 会话:{}, 客户:{}, 向设备回送序列:{}, 接收端序列:{}, 消息########\n{}" + Color.END, uuid, tcpClientMap.get(clientKey), sendIndex, receiveIndex, xml); |
|
|
|
logger.info(Color.MAGENTA + "###### 会话:{}, 客户:[{}/{}], 向设备回送序列:{}, 接收端序列:{}, 消息: ######\n{}" + Color.END, uuid, clientKey, tcpClientMap.get(clientKey), sendIndex, receiveIndex, compact(xml)); |
|
|
|
nettyServerHandler.sendMsg(uuid, clientKey, tcpClientMap.get(clientKey), allBuf); |
|
|
|
sendIndex++; |
|
|
|
} else { |
|
|
|
logger.warn(Color.RED + "######## 会话: {}, 客户: [{}/{}] 离线!!! ########" + Color.END, uuid, tcpClientMap.get(clientKey), clientKey); |
|
|
|
logger.warn(Color.RED + "###### 会话:{}, 客户:[{}/{}] 离线!!! ######" + Color.END, uuid, clientKey, tcpClientMap.get(clientKey)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void flushMsgToDeviceBroadcast(String uuid, String clientKey, boolean request, String xml) { |
|
|
|
for (Map.Entry<String, String> entry : tcpClientMap.entrySet()) { |
|
|
|
logger.info("######## flushMsgToDeviceBroadcast key: {}, value: {} ########", entry.getKey(), entry.getValue()); |
|
|
|
ByteBuf byteBuf = Unpooled.copiedBuffer(xml, CharsetUtil.UTF_8); |
|
|
|
int length = byteBuf.readableBytes(); |
|
|
|
ByteBuf allBuf = Unpooled.buffer(length + ConfigType.dataLength); |
|
|
|
@ -182,7 +186,7 @@ public class NettyServer { |
|
|
|
allBuf.writeByte(0xEB); |
|
|
|
allBuf.writeByte(0x90); |
|
|
|
redisTemplate.opsForValue().set(String.valueOf(sendIndex), allBuf.toString(CharsetUtil.US_ASCII), 60L, TimeUnit.SECONDS); |
|
|
|
logger.info(Color.MAGENTA + "######## => 会话:{}, 客户:{}, 向设备回送序列:{}, 接收端序列:{}, 消息########\n{}" + Color.END, uuid, tcpClientMap.get(clientKey), sendIndex, receiveIndex, xml); |
|
|
|
logger.info(Color.MAGENTA + "###### 会话:{}, 客户:[{}/{}], 向设备回送序列:{}, 接收端序列:{}, 消息: ######\n{}" + Color.END, uuid, clientKey, tcpClientMap.get(clientKey), sendIndex, receiveIndex, compact(xml)); |
|
|
|
nettyServerHandler.sendMsg(uuid, entry.getKey(), tcpClientMap.get(entry.getKey()), allBuf); |
|
|
|
sendIndex++; |
|
|
|
try { |
|
|
|
@ -231,7 +235,8 @@ public class NettyServer { |
|
|
|
command = Integer.parseInt(root.element("Command").getText()); |
|
|
|
} |
|
|
|
|
|
|
|
logger.info(Color.MAGENTA + "######## <= 会话: {}, 客户: [{}/{}], 消息类型: {}, 命令:{}, 消息体: ########\n{}" + Color.END, binaryModel.uuid, sendCode, binaryModel.id, type, command, xml); |
|
|
|
String compactXml = compact(xml); |
|
|
|
logger.info(Color.YELLOW + "###### 会话:{}, 客户:[{}/{}], 消息类型:{}, 命令:{}, 消息体: ######\n{}" + Color.END, binaryModel.uuid, sendCode, binaryModel.id, type, command, compactXml); |
|
|
|
//判断是否重发 |
|
|
|
if (type == SystemType.system) { |
|
|
|
if (command == SystemType.has_response || command == SystemType.no_response) { |
|
|
|
@ -241,12 +246,15 @@ public class NettyServer { |
|
|
|
resetSendMsg(binaryModel.receiveIndex, sendCode); |
|
|
|
return; |
|
|
|
} else if (code.equals(ResponseType.succeed)) { |
|
|
|
logger.info("######## 响应结果为成功, 客户: {}, 命令: {}, 消息体 ########\n{}", sendCode, command, xml); |
|
|
|
logger.info(Color.YELLOW + "###### 响应结果为成功 ######" + Color.END); |
|
|
|
if(command == SystemType.no_response) { |
|
|
|
return; |
|
|
|
} |
|
|
|
} else if (code.equals(ResponseType.fault)) { |
|
|
|
logger.warn("######## 响应结果为失败, 客户: {}, 命令: {}, 消息体 ########\n{}", sendCode, command, xml); |
|
|
|
logger.warn(Color.RED + "###### 响应结果为失败 ######" + Color.END); |
|
|
|
return; |
|
|
|
} else if (code.equals(ResponseType.reject)) { |
|
|
|
logger.warn("######## 响应结果为拒绝, 客户: {}, 命令: {}, 消息体 ########\n{}", sendCode, command, xml); |
|
|
|
logger.warn(Color.RED + "###### 响应结果为拒绝 ######" + Color.END); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -258,13 +266,13 @@ public class NettyServer { |
|
|
|
switch (command) { |
|
|
|
case SystemType.register_request: |
|
|
|
// 收到接入侧注册信息 |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 客户端注册信息 ########", binaryModel.uuid, sendCode); |
|
|
|
dealRegister(binaryModel.uuid, xml); |
|
|
|
logger.info(Color.YELLOW + "###### 客户端[{}/{}]注册 ######" + Color.END, sendCode, binaryModel.id); |
|
|
|
dealRegister(binaryModel.uuid, compactXml); |
|
|
|
break; |
|
|
|
case SystemType.heart_request: |
|
|
|
// 处理心跳请求响应 |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 客户端心跳 ########", binaryModel.uuid, sendCode); |
|
|
|
sendHeartBeat(binaryModel.uuid, xml); |
|
|
|
logger.info(Color.YELLOW + "###### 客户端[{}/{}]心跳 ######" + Color.END, sendCode, binaryModel.id); |
|
|
|
sendHeartBeat(binaryModel.uuid, compactXml); |
|
|
|
break; |
|
|
|
case SystemType.has_response: |
|
|
|
// 处理有返回值的消息响应 |
|
|
|
@ -272,9 +280,9 @@ public class NettyServer { |
|
|
|
// 处理设备上报的模型同步响应 |
|
|
|
if (null != root.element("Items").element("Item").attribute("device_file_path")) { |
|
|
|
// 收到接入侧模型同步数据 |
|
|
|
logger.info(Color.YELLOW + "######## 会话: {}, 客户: {}, 客户端模型同步数据 ########" + Color.END, binaryModel.uuid, sendCode); |
|
|
|
logger.info(Color.YELLOW + "###### 模型同步响应数据 ######" + Color.END); |
|
|
|
// json = downXml2Json.ModelControlXml2Json(xml); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, xml, ModelControl.class); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, compactXml, ModelControl.class); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(json); |
|
|
|
jsonObject.put("uuid", binaryModel.uuid); |
|
|
|
jsonObject.put("Type", Constant.MODEL_UP_TYPE); |
|
|
|
@ -283,81 +291,81 @@ public class NettyServer { |
|
|
|
// 任务控制响应任务执行ID |
|
|
|
if (null != root.element("Items").element("Item").attribute("task_patrolled_id")) { |
|
|
|
// 收到接入侧任务下发或控制回复数据 |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 设备端任务下发或控制回复数据 ########", binaryModel.uuid, sendCode); |
|
|
|
logger.info(Color.YELLOW + "###### 任务下发响应数据 ######" + Color.END); |
|
|
|
// json = downXml2Json.ModelControlXml2Json(xml); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, xml, ModelControl.class); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, compactXml, ModelControl.class); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(json); |
|
|
|
jsonObject.put("SendCode", ""); |
|
|
|
clientController.sendMsg(binaryModel.uuid, jsonObject.toJSONString()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 接收到的系统类信息报文中,root:{},中不包含items或items中没有item,不予处理 |
|
|
|
logger.warn("[NETTY] IN RECEIVING MESSAGE, no items or item , OMIT IT, ROOT: {}", root); |
|
|
|
logger.warn(Color.RED + "###### 响应数据没有items ######" + Color.END); |
|
|
|
} |
|
|
|
break; |
|
|
|
default: |
|
|
|
// 接收到的系统类信息报文中,command:{},不在处理范围内,不予处理 |
|
|
|
logger.warn("######## 非法的消息不予处理, 客户: {}, 命令: {}, 消息体 ########\n{}", sendCode, command, xml); |
|
|
|
logger.warn(Color.RED + "###### 非法的消息不予处理 ######" + Color.END); |
|
|
|
} |
|
|
|
break; |
|
|
|
case PushType.patrolDeviceState:// insert into basedata_mont_patdevstadata |
|
|
|
// json = downXml2Json.PatrolDeviceStateControlXml2Json(xml); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, xml, PatrolDeviceStateControl.class); |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 客户端设备状态数据 ########", binaryModel.uuid, sendCode); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, compactXml, PatrolDeviceStateControl.class); |
|
|
|
logger.info(Color.YELLOW + "###### 客户端[{}/{}]设备状态数据 ######" + Color.END, sendCode, binaryModel.id); |
|
|
|
break; |
|
|
|
case PushType.patrolDeviceRunning:// insert into basedata_mont_patdevrundata |
|
|
|
// json = downXml2Json.PatrolDeviceRunningControlXml2Json(xml); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, xml, PatrolDeviceRunningControl.class); |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 客户端设备运行数据 ########", binaryModel.uuid, sendCode); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, compactXml, PatrolDeviceRunningControl.class); |
|
|
|
logger.info(Color.YELLOW + "###### 客户端[{}/{}]设备运行数据 ######" + Color.END, sendCode, binaryModel.id); |
|
|
|
break; |
|
|
|
case PushType.nestState:// insert into basedata_mont_neststadata |
|
|
|
// json = downXml2Json.NestStateControlXml2Json(xml); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, xml, NestStateControl.class); |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 客户端机巢状态数据 ########", binaryModel.uuid, sendCode); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, compactXml, NestStateControl.class); |
|
|
|
logger.info(Color.YELLOW + "###### 客户端[{}/{}]机巢状态数据 ######" + Color.END, sendCode, binaryModel.id); |
|
|
|
break; |
|
|
|
case PushType.nestRunning:// insert into basedata_mont_nestrundata |
|
|
|
// json = downXml2Json.NestRunningControlXml2Json(xml); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, xml, NestRunningControl.class); |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 客户端机巢运行数据 ########", binaryModel.uuid, sendCode); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, compactXml, NestRunningControl.class); |
|
|
|
logger.info(Color.YELLOW + "###### 客户端[{}/{}]机巢运行数据 ######" + Color.END, sendCode, binaryModel.id); |
|
|
|
break; |
|
|
|
case PushType.location:// insert into basedata_mont_patdevcoord |
|
|
|
// json = downXml2Json.LocationControlXml2Json(xml); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, xml, LocationControl.class); |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 客户端设备坐标 ########", binaryModel.uuid, sendCode); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, compactXml, LocationControl.class); |
|
|
|
logger.info(Color.YELLOW + "###### 客户端[{}/{}]设备坐标 ######" + Color.END, sendCode, binaryModel.id); |
|
|
|
break; |
|
|
|
case PushType.route:// insert into basedata_mont_patdevpatroute |
|
|
|
// json = downXml2Json.RouteControlXml2Json(xml); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, xml, RouteControl.class); |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 客户端设备路线 ########", binaryModel.uuid, sendCode); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, compactXml, RouteControl.class); |
|
|
|
logger.info(Color.YELLOW + "###### 客户端[{}/{}]设备路线 ######" + Color.END, sendCode, binaryModel.id); |
|
|
|
break; |
|
|
|
case PushType.alarm:// insert into basedata_mont_patdevalmabn |
|
|
|
// json = down.AlarmControlXml2Json(xml); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, xml, AlarmControl.class); |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 客户端设备异常告警 ########", binaryModel.uuid, sendCode); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, compactXml, AlarmControl.class); |
|
|
|
logger.info(Color.YELLOW + "###### 客户端[{}/{}]设备异常告警 ######" + Color.END, sendCode, binaryModel.id); |
|
|
|
break; |
|
|
|
case PushType.environment:// insert into basedata_mont_evndata |
|
|
|
// json = downXml2Json.EnvironmentControlXml2Json(xml); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, xml, EnvironmentControl.class); |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 客户端设备上报环境数据 ########", binaryModel.uuid, sendCode); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, compactXml, EnvironmentControl.class); |
|
|
|
logger.info(Color.YELLOW + "###### 客户端[{}/{}]设备上报环境数据 ######" + Color.END, sendCode, binaryModel.id); |
|
|
|
break; |
|
|
|
case PushType.taskState:// insert into basedata_mont_taskstadata and patrol_task_status |
|
|
|
// json = downXml2Json.TaskStateControlXml2Json(xml); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, xml, TaskStateControl.class); |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 客户端设备任务状态 ########", binaryModel.uuid, sendCode); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, compactXml, TaskStateControl.class); |
|
|
|
logger.info(Color.YELLOW + "###### 客户端{}/{}]设备任务状态 ######" + Color.END, sendCode, binaryModel.id); |
|
|
|
break; |
|
|
|
case PushType.result:// insert into basedata_mont_taskresult and patrol_task_result_main |
|
|
|
// json = downXml2Json.TaskResultControlXml2Json(xml); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, xml, TaskResultControl.class); |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 客户端巡视结果 ########", binaryModel.uuid, sendCode); |
|
|
|
json = downXml2Json.DownStreamJson2Xml(binaryModel.uuid, binaryModel.id, compactXml, TaskResultControl.class); |
|
|
|
logger.info(Color.YELLOW + "###### 客户端{}/{}]巡视结果 ######" + Color.END, sendCode, binaryModel.id); |
|
|
|
break; |
|
|
|
default: |
|
|
|
// server-handle-接收到的type:{},不在处理范围内,不予处理 |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 非法的消息不予处理, 类型{}, 消息体 ########\n{}", binaryModel.uuid, sendCode, type, xml); |
|
|
|
logger.info(Color.RED + "###### 非法的消息不予处理 ######" + Color.END); |
|
|
|
} |
|
|
|
if (type != SystemType.system && !StringUtil.isNullOrEmpty(json)) { |
|
|
|
if ((type == NestCtlType.courseReversal && command == 3)) { // 处理用SSCOM模拟的数据, 向无人机发送控制指令 |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 向设备透传200001控制指令", binaryModel.uuid, sendCode); |
|
|
|
flushMsgToDeviceBroadcast(binaryModel.uuid, receiveCode, false, xml); |
|
|
|
logger.info("###### 客户:{}, 向设备透传200001控制指令 ######", sendCode); |
|
|
|
flushMsgToDeviceBroadcast(binaryModel.uuid, receiveCode, false, compactXml); |
|
|
|
} else { |
|
|
|
//rabbitmq推送到消息队列中基于springboot_xggd |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(json); |
|
|
|
@ -366,7 +374,6 @@ public class NettyServer { |
|
|
|
// send to BasedataMontDataMqAcceptHandle |
|
|
|
rabbitTemplate.convertAndSend(Constant.EX_CHANGE_NAME, Constant.ROUTING_KEY_NAME, json); |
|
|
|
boolean isHost = json.contains(aliasHost); |
|
|
|
logger.info("######## 会话: {}, 客户: {}, isHost: {}", binaryModel.uuid, sendCode, isHost); |
|
|
|
sendResponseToDevice(binaryModel.uuid, receiveCode, sendCode, isHost); |
|
|
|
} |
|
|
|
} else { |
|
|
|
@ -374,11 +381,10 @@ public class NettyServer { |
|
|
|
|| (type == NestCtlType.ptzPitch && command == 6) |
|
|
|
|| (type == NestCtlType.picModelSet && command == 1) |
|
|
|
|| (type == NestCtlType.nestSuddenStop && command == 2)) {// 处理用SSCOM模拟的数据, 向无人机发送控制指令 |
|
|
|
logger.info("######## 会话: {}, 客户: {}, 向设备透传200002~20005控制指令", binaryModel.uuid, sendCode); |
|
|
|
flushMsgToDeviceBroadcast(binaryModel.uuid, receiveCode, false, xml); |
|
|
|
logger.info("###### 客户:{}, 向设备透传200002~20005控制指令 ######", sendCode); |
|
|
|
flushMsgToDeviceBroadcast(binaryModel.uuid, receiveCode, false, compactXml); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void sendResponseToDevice(String uuid, String sendCode, String receiveCode, boolean isHost) { |
|
|
|
@ -408,7 +414,6 @@ public class NettyServer { |
|
|
|
xStream.addPermission(AnyTypePermission.ANY); |
|
|
|
obj = (BaseControl) xStream.fromXML(xml); |
|
|
|
} catch (com.thoughtworks.xstream.XStreamException e) { |
|
|
|
logger.error("######## 注册异常堆栈[PatrolHost] 会话: {}, {} ########", uuid, e.getMessage()); |
|
|
|
try { |
|
|
|
XStream xStreamEx = getXmlStreamInstance(); |
|
|
|
xStreamEx.alias(aliasDevice, BaseControl.class); |
|
|
|
@ -417,7 +422,7 @@ public class NettyServer { |
|
|
|
xStreamEx.addPermission(AnyTypePermission.ANY); |
|
|
|
obj = (BaseControl) xStreamEx.fromXML(xml); |
|
|
|
} catch (com.thoughtworks.xstream.XStreamException e2) { |
|
|
|
logger.error("######## 解析失败[PatrolDevice] {} ########", e2.getMessage()); |
|
|
|
logger.error(Color.RED + "###### dealRegister解析失败:{} ######" + Color.END, e2.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -501,21 +506,19 @@ public class NettyServer { |
|
|
|
xStream.autodetectAnnotations(true); |
|
|
|
xml = xStream.toXML(responseControl); |
|
|
|
} catch (com.thoughtworks.xstream.XStreamException e) { |
|
|
|
logger.error("######## DOWN REGISTER 解析失败, 异常堆栈 [PatrolHost]: {} ########", e.getMessage()); |
|
|
|
try { |
|
|
|
XStream xStream = new XStream(new Xpp3Driver(new NoNameCoder())); |
|
|
|
xStream.alias(aliasDevice, RegisterResponseControl.class); |
|
|
|
xStream.autodetectAnnotations(true); |
|
|
|
xml = xStream.toXML(responseControl); |
|
|
|
} catch (com.thoughtworks.xstream.XStreamException e2) { |
|
|
|
logger.error("################ DOWN REGISTER 解析失败[PatrolDevice] {} ################", e2.getMessage()); |
|
|
|
logger.error(Color.RED + "###### sendRegisterResponse解析失败:{} ######" + Color.END, e2.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
flushMsgToDevice(uuid, sendCode, false, xml); |
|
|
|
} |
|
|
|
|
|
|
|
public void sendHeartBeat(final String uuid, String xml) { |
|
|
|
logger.info("################ 设备端机器人系统心跳消息 ################\n{}", xml); |
|
|
|
boolean isHost = true; |
|
|
|
BaseControl obj = new BaseControl(); |
|
|
|
try { |
|
|
|
@ -526,7 +529,6 @@ public class NettyServer { |
|
|
|
xStream.addPermission(AnyTypePermission.ANY); |
|
|
|
obj = (BaseControl) xStream.fromXML(xml); |
|
|
|
} catch (com.thoughtworks.xstream.XStreamException e) { |
|
|
|
logger.error("######## HEARTBEAT TO MQ 解析失败, 异常堆栈[PatrolHost]: {} ########", e.getMessage()); |
|
|
|
try { |
|
|
|
XStream xStream = new XStream(new Xpp3Driver(new NoNameCoder())); |
|
|
|
xStream.alias(aliasDevice, BaseControl.class); |
|
|
|
@ -536,7 +538,7 @@ public class NettyServer { |
|
|
|
obj = (BaseControl) xStream.fromXML(xml); |
|
|
|
isHost = false; |
|
|
|
} catch (com.thoughtworks.xstream.XStreamException e2) { |
|
|
|
logger.error("######## HEARTBEAT TO MQ 解析失败[PatrolDevice] {} ########", e2.getMessage()); |
|
|
|
logger.error(Color.RED + "###### sendHeartBeat解析失败:{} ######" + Color.END, e2.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -605,11 +607,11 @@ public class NettyServer { |
|
|
|
xml = upJson2Xml.UpStreamJson2Xml(json, LinkageTaskControl.class); |
|
|
|
break; |
|
|
|
default: |
|
|
|
logger.warn("################ 向设备端下发命令, 类型:{}错误, 不予处理 ################", type); |
|
|
|
logger.warn(Color.RED + "###### 向设备端下发命令, 类型:{}错误, 不予处理 ######" + Color.END, type); |
|
|
|
|
|
|
|
} |
|
|
|
if (!StringUtils.isEmpty(xml)) { |
|
|
|
//logger.info("################ 向设备端下发命令 ################\n{}", xml); |
|
|
|
//logger.info("###### 向设备端下发命令 ######\n{}", xml); |
|
|
|
flushMsgToDevice("", receiveCode, true, xml); |
|
|
|
} |
|
|
|
} |
|
|
|
|