优化机器人/无人机逻辑
This commit is contained in:
parent
7b0eda3fb8
commit
d8002fae52
@ -446,8 +446,8 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
|
||||
SubstationPatroldevice substationPatroldevice = list.get(0);
|
||||
// 发送任务到机器人
|
||||
JSONArray jsonArray = JSONUtil.parseArray(items);
|
||||
stationRobotService.sendCommand(substationPatroldevice.getIpaddr(),
|
||||
httpServerConfig.getPatrolServerid(), substationPatroldevice.getCustom3(), Type, Command,
|
||||
stationRobotService.sendCommand(substationPatroldevice.getInternationalId(),
|
||||
httpServerConfig.getPatrolServerid(), substationPatroldevice.getInternationalId(), Type, Command,
|
||||
Code, jsonArray.toString());
|
||||
}
|
||||
}
|
||||
@ -846,7 +846,7 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
|
||||
// 机器人系统编码
|
||||
String internationalId = substationPatroldevice.getInternationalId();
|
||||
// 机器人任务
|
||||
stationRobotService.sendCommand(substationPatroldevice.getIpaddr(),
|
||||
stationRobotService.sendCommand(substationPatroldevice.getInternationalId(),
|
||||
httpServerConfig.getPatrolServerid(), internationalId, Type, Command, Code, null);
|
||||
// 创建事件并注册
|
||||
Event event = new Event(taskTodo.getTaskTodoId(), response -> {
|
||||
@ -914,7 +914,7 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
|
||||
// 机器人系统编码
|
||||
String internationalId = substationPatroldevice.getInternationalId();
|
||||
// 机器人任务
|
||||
stationRobotService.sendCommand(substationPatroldevice.getIpaddr(),
|
||||
stationRobotService.sendCommand(substationPatroldevice.getInternationalId(),
|
||||
httpServerConfig.getPatrolServerid(), internationalId, Type, Command, Code, null);
|
||||
// 创建事件并注册
|
||||
Event event = new Event(taskTodo.getTaskTodoId(), response -> {
|
||||
@ -991,7 +991,7 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
|
||||
// 机器人系统编码
|
||||
String internationalId = substationPatroldevice.getInternationalId();
|
||||
// 机器人任务
|
||||
stationRobotService.sendCommand(substationPatroldevice.getIpaddr(),
|
||||
stationRobotService.sendCommand(substationPatroldevice.getInternationalId(),
|
||||
httpServerConfig.getPatrolServerid(), internationalId, Type, Command, Code, null);
|
||||
// 创建事件并注册
|
||||
Event event = new Event(task.getTaskCode(), response -> {
|
||||
@ -1063,7 +1063,7 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
|
||||
// 机器人系统编码
|
||||
String internationalId = substationPatroldevice.getInternationalId();
|
||||
// 机器人任务
|
||||
stationRobotService.sendCommand(substationPatroldevice.getIpaddr(),
|
||||
stationRobotService.sendCommand(substationPatroldevice.getInternationalId(),
|
||||
httpServerConfig.getPatrolServerid(), internationalId, Type, Command, Code, null);
|
||||
// 创建事件并注册
|
||||
Event event = new Event(taskTodo.getTaskTodoId(), response -> {
|
||||
|
@ -187,7 +187,7 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
|
||||
jsonArray.add(jsonObject);
|
||||
WebSocketServer.sendInfo("robot_status_data", jsonArray.toString());
|
||||
}
|
||||
ChannelMap.getChannelMap().put(stationNodeIP, ctx.channel());
|
||||
// ChannelMap.getChannelMap().put(stationNodeIP, ctx.channel());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,6 +224,7 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
|
||||
Map<String, Object> map = MyXmlUtil.xmlToMap(xml);
|
||||
String Type = map.get("Type").toString();
|
||||
String Command = map.get("Command").toString();
|
||||
String SendCode = map.get("SendCode").toString();
|
||||
String Code = "";
|
||||
if (ObjectUtil.isNotEmpty(map.get("Code"))) {
|
||||
Code = map.get("Code").toString();
|
||||
@ -250,6 +251,7 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
|
||||
SystemCode.SUCCESS_STATUS_CODE.getCode(), jsonObject.toString());
|
||||
log.info("响应信息" + reponsexml);
|
||||
sendResponseData(ctx, msg, reponsexml);
|
||||
ChannelMap.getChannelMap().put(SendCode, ctx.channel());
|
||||
log.info("机器人/无人机注册成功!{}", map.get("SendCode").toString());
|
||||
}
|
||||
if (SystemCode.TYPE_SYSTEM_MESSAGE_CODE.getCode().equals(Type) && SystemCode.COMMAND_HEARTBEAT_CODE.getCode().equals(Command)) {
|
||||
|
@ -357,7 +357,7 @@ public class LinkageSignalController {
|
||||
List<SubstationPatroldevice> list = substationPatroldeviceService.list(new LambdaQueryWrapper<SubstationPatroldevice>().eq(SubstationPatroldevice::getPatroldeviceCode, robotCode));
|
||||
if (list.size() > 0) {
|
||||
SubstationPatroldevice substationPatroldevice = list.get(0);
|
||||
stationRobotService.sendCommand(substationPatroldevice.getIpaddr(), httpServerConfig.getPatrolServerid(), substationPatroldevice.getCustom3(),
|
||||
stationRobotService.sendCommand(substationPatroldevice.getInternationalId(), httpServerConfig.getPatrolServerid(), substationPatroldevice.getInternationalId(),
|
||||
SystemCode.TYPE_LINKAGE_TASK_ISSUED_CODE.getCode(), SystemCode.COMMAND_TASK_CONFIG_CODE.getCode(), code, jsonObject.toString());
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class ExaminePlanController {
|
||||
List<SubstationPatroldevice> list = substationPatroldeviceService.list(new LambdaQueryWrapper<SubstationPatroldevice>().eq(SubstationPatroldevice::getPatroldeviceCode, robotCode));
|
||||
if (list.size() > 0) {
|
||||
SubstationPatroldevice substationPatroldevice = list.get(0);
|
||||
stationRobotService.sendCommand(substationPatroldevice.getIpaddr(), httpServerConfig.getPatrolServerid(), substationPatroldevice.getCustom3(),
|
||||
stationRobotService.sendCommand(substationPatroldevice.getInternationalId(), httpServerConfig.getPatrolServerid(), substationPatroldevice.getInternationalId(),
|
||||
SystemCode.TYPE_EXAMINE_ISSUED_CODE.getCode(), SystemCode.COMMAND_EXAMINE_CONFIG_CODE.getCode(), examinePlan.getStationCode(), jsonObject.toString());
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ public class TaskController {
|
||||
taskService.createTodoTaskList(task);
|
||||
}
|
||||
} else {
|
||||
stationRobotService.sendCommand(substationPatroldevice.getIpaddr(), httpServerConfig.getPatrolServerid(), substationPatroldevice.getCustom3(), SystemCode.TYPE_TASK_CONTROL_CODE.getCode(), SystemCode.COMMAND_TASK_START_CODE.getCode(), task.getTaskCode(), null);
|
||||
stationRobotService.sendCommand(substationPatroldevice.getInternationalId(), httpServerConfig.getPatrolServerid(), substationPatroldevice.getInternationalId(), SystemCode.TYPE_TASK_CONTROL_CODE.getCode(), SystemCode.COMMAND_TASK_START_CODE.getCode(), task.getTaskCode(), null);
|
||||
}
|
||||
|
||||
}
|
||||
@ -346,7 +346,7 @@ public class TaskController {
|
||||
List<SubstationPatroldevice> list = substationPatroldeviceService.list(new LambdaQueryWrapper<SubstationPatroldevice>().eq(SubstationPatroldevice::getPatroldeviceCode, task.getRobotCode()));
|
||||
if (list.size() > 0) {
|
||||
SubstationPatroldevice substationPatroldevice = list.get(0);
|
||||
stationRobotService.sendCommand(substationPatroldevice.getIpaddr(), httpServerConfig.getPatrolServerid(), substationPatroldevice.getCustom3(),
|
||||
stationRobotService.sendCommand(substationPatroldevice.getInternationalId(), httpServerConfig.getPatrolServerid(), substationPatroldevice.getInternationalId(),
|
||||
SystemCode.TYPE_TASK_ISSUED_CODE.getCode(), SystemCode.COMMAND_TASK_CONFIG_CODE.getCode(), task.getStationCode(), jsonObject.toString());
|
||||
}
|
||||
if ("1".equals(task.getTaskTodoType())) {
|
||||
|
@ -186,7 +186,7 @@ public class TaskTodoController {
|
||||
List<SubstationPatroldevice> list = substationPatroldeviceService.list(new LambdaQueryWrapper<SubstationPatroldevice>().eq(SubstationPatroldevice::getPatroldeviceCode, robotCode));
|
||||
if (list.size() > 0) {
|
||||
SubstationPatroldevice substationPatroldevice = list.get(0);
|
||||
stationRobotService.sendCommand(substationPatroldevice.getIpaddr(), httpServerConfig.getPatrolServerid(), substationPatroldevice.getCustom3(), SystemCode.TYPE_TASK_CONTROL_CODE.getCode(),
|
||||
stationRobotService.sendCommand(substationPatroldevice.getInternationalId(), httpServerConfig.getPatrolServerid(), substationPatroldevice.getInternationalId(), SystemCode.TYPE_TASK_CONTROL_CODE.getCode(),
|
||||
Command, Code, null);
|
||||
}
|
||||
LambdaUpdateWrapper<TaskTodo> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
|
@ -115,10 +115,10 @@ public class StationRobotServiceImpl extends ServiceImpl<SubstationMapper, Subst
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCommand(String targetIp, String sendcode, String receivecode, String type, String command,
|
||||
public void sendCommand(String targetId, String sendcode, String receivecode, String type, String command,
|
||||
String code, String items) {
|
||||
log.info("进入sendCommand方法");
|
||||
if (StrUtil.isBlank(targetIp)) {
|
||||
if (StrUtil.isBlank(targetId)) {
|
||||
log.info("判断机器人");
|
||||
// 机器人编码
|
||||
List<SubstationPatroldevice> list =
|
||||
@ -126,10 +126,10 @@ public class StationRobotServiceImpl extends ServiceImpl<SubstationMapper, Subst
|
||||
// 发送机器人控制指令
|
||||
if (list.size() > 0) {
|
||||
SubstationPatroldevice substationPatroldevice = list.get(0);
|
||||
sendMsgtoRobot(substationPatroldevice.getIpaddr(), sendcode, substationPatroldevice.getCustom3(), type, command, code, items);
|
||||
sendMsgtoRobot(substationPatroldevice.getInternationalId(), sendcode, substationPatroldevice.getInternationalId(), type, command, code, items);
|
||||
}
|
||||
} else {
|
||||
sendMsgtoRobot(targetIp, sendcode, receivecode, type, command, code, items);
|
||||
sendMsgtoRobot(targetId, sendcode, receivecode, type, command, code, items);
|
||||
}
|
||||
|
||||
|
||||
@ -209,7 +209,7 @@ public class StationRobotServiceImpl extends ServiceImpl<SubstationMapper, Subst
|
||||
/**
|
||||
* 机器人发送消息
|
||||
*
|
||||
* @param targetip 变电站IP
|
||||
* @param targetIp 目标id
|
||||
* sendcode 发送方GBId
|
||||
* receivecode 接收方BGId
|
||||
* type 巡视系统规范中定义
|
||||
@ -217,9 +217,9 @@ public class StationRobotServiceImpl extends ServiceImpl<SubstationMapper, Subst
|
||||
* code 发送的编码
|
||||
* items 发送的内容数据信息封装成jsonstr
|
||||
*/
|
||||
private void sendMsgtoRobot(String targetip, String sendcode, String receivecode, String type, String command,
|
||||
private void sendMsgtoRobot(String targetIp, String sendcode, String receivecode, String type, String command,
|
||||
String code, String items) {
|
||||
log.info("接收控制值targetip" + targetip + "接收控制值sendcode" + sendcode + "接收控制值receivecode" + receivecode + "接收控制值items" + items);
|
||||
log.info("接收控制值targetip" + targetIp + "接收控制值sendcode" + sendcode + "接收控制值receivecode" + receivecode + "接收控制值items" + items);
|
||||
String reponsexml = MyXmlUtil.getXml(sendcode, receivecode, type, command, code, items);
|
||||
log.info("主动发送控制命令" + reponsexml);
|
||||
MyMessageProtocol messageProtocol = new MyMessageProtocol();
|
||||
@ -231,7 +231,7 @@ public class StationRobotServiceImpl extends ServiceImpl<SubstationMapper, Subst
|
||||
messageProtocol.setSessionflag(0);
|
||||
messageProtocol.setXmllen(reponsexml.getBytes(CharsetUtil.UTF_8).length);
|
||||
messageProtocol.setXmlcontent(reponsexml.getBytes(CharsetUtil.UTF_8));
|
||||
Channel channel = ChannelMap.getChannel(targetip);
|
||||
Channel channel = ChannelMap.getChannel(targetIp);
|
||||
if (null == channel) {
|
||||
throw new RuntimeException("客户端已离线");
|
||||
}
|
||||
@ -643,7 +643,7 @@ public class StationRobotServiceImpl extends ServiceImpl<SubstationMapper, Subst
|
||||
public void sendRobotModel(String robotId) {
|
||||
SubstationPatroldevice substationPatroldevice = substationPatroldeviceMapper.selectById(robotId);
|
||||
if (substationPatroldevice != null) {
|
||||
sendMsgtoRobot(substationPatroldevice.getIpaddr(), serverConfig.getPatrolServerid(), substationPatroldevice.getCustom3(), SystemCode.TYPE_MODEL_SYNC_CODE.getCode(), SystemCode.COMMAND_MODEL_HOST_CODE.getCode(), substationPatroldevice.getStationCode(), "");
|
||||
sendMsgtoRobot(substationPatroldevice.getInternationalId(), serverConfig.getPatrolServerid(), substationPatroldevice.getInternationalId(), SystemCode.TYPE_MODEL_SYNC_CODE.getCode(), SystemCode.COMMAND_MODEL_HOST_CODE.getCode(), substationPatroldevice.getStationCode(), "");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user