Commit db162d2b authored by wanghao's avatar wanghao

1 指令追踪调整

parent 904fe89d
...@@ -128,8 +128,8 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -128,8 +128,8 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
/** /**
* 仅处理已完成的指令 * 仅处理已完成的指令
*/ */
public void onlyCompleted() { public void onlyCompleted(String commandId) {
CommandExecution execution = currentCommands.get("127.0.0.1"); CommandExecution execution = currentCommands.get(commandId);
// 如果指令追踪为空,则可能是 刚启动,再去 查一下有没有正在执行的任务 // 如果指令追踪为空,则可能是 刚启动,再去 查一下有没有正在执行的任务
if(execution == null) { if(execution == null) {
List<RobotArmCommand> robotArmCommands = robotArmCommandService.selectTopRunningRobotArmCommands(); List<RobotArmCommand> robotArmCommands = robotArmCommandService.selectTopRunningRobotArmCommands();
...@@ -142,7 +142,7 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -142,7 +142,7 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
if (execution != null) { if (execution != null) {
robotArmCommandService.completeCommand(execution.commandId); robotArmCommandService.completeCommand(execution.commandId);
currentCommands.remove("127.0.0.1"); currentCommands.remove(commandId);
log.info("指令完成: {}", execution.commandId); log.info("指令完成: {}", execution.commandId);
} }
} }
...@@ -164,9 +164,9 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -164,9 +164,9 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
status.getCode(), status.getText(), status.getCode(), status.getText(),
status.getX(), status.getY(), status.getZ(), status.getR()); status.getX(), status.getY(), status.getZ(), status.getR());
CommandExecution execution = currentCommands.get("127.0.0.1"); CommandExecution execution = null;
// 如果指令追踪为空,则可能是 刚启动,再去 查一下有没有正在执行的任务 // 如果指令追踪为空,则可能是 刚启动,再去 查一下有没有正在执行的任务
if(execution == null) { if(currentCommands.size() == 0) {
List<RobotArmCommand> robotArmCommands = robotArmCommandService.selectTopRunningRobotArmCommands(); List<RobotArmCommand> robotArmCommands = robotArmCommandService.selectTopRunningRobotArmCommands();
if(robotArmCommands != null && !robotArmCommands.isEmpty()) { if(robotArmCommands != null && !robotArmCommands.isEmpty()) {
// 注册指令跟踪 // 注册指令跟踪
...@@ -177,7 +177,7 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -177,7 +177,7 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
if (execution != null) { if (execution != null) {
robotArmCommandService.completeCommand(execution.commandId); robotArmCommandService.completeCommand(execution.commandId);
currentCommands.remove("127.0.0.1"); currentCommands.remove(execution.commandId + "");
log.info("指令完成: {}", execution.commandId); log.info("指令完成: {}", execution.commandId);
} }
} else { } else {
...@@ -188,12 +188,12 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -188,12 +188,12 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
/** /**
* 记录当前执行的指令 * 记录当前执行的指令
*/ */
public void registerCommandExecution(String address, Long commandId) { public void registerCommandExecution(Long commandId) {
CommandExecution execution = new CommandExecution(); CommandExecution execution = new CommandExecution();
execution.commandId = commandId; execution.commandId = commandId;
execution.startTime = System.currentTimeMillis(); execution.startTime = System.currentTimeMillis();
currentCommands.put(address, execution); currentCommands.put(commandId + "", execution);
log.info("注册指令跟踪: {} -> {}", address, commandId); log.info("注册指令跟踪: {}", commandId);
} }
......
...@@ -160,7 +160,7 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -160,7 +160,7 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
); );
// 注册指令跟踪 // 注册指令跟踪
nettyUdpServerHandler.registerCommandExecution("127.0.0.1", command.getRobotArmCommandId()); nettyUdpServerHandler.registerCommandExecution(command.getRobotArmCommandId());
} }
/** /**
...@@ -400,7 +400,7 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -400,7 +400,7 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
return AjaxResult.error("只有待执行状态的指令才能确认完成"); return AjaxResult.error("只有待执行状态的指令才能确认完成");
} }
try { try {
nettyUdpServerHandler.onlyCompleted(); nettyUdpServerHandler.onlyCompleted(commandId +"");
} catch (Exception e) { } catch (Exception e) {
return AjaxResult.error("执行确认完成指令时发生异常: " + e.getMessage()); return AjaxResult.error("执行确认完成指令时发生异常: " + e.getMessage());
} }
......
...@@ -182,6 +182,8 @@ public class DeviceCommunicationJob implements Job { ...@@ -182,6 +182,8 @@ public class DeviceCommunicationJob implements Job {
writeCurrentTimeToDevice(master, deviceId, binding); writeCurrentTimeToDevice(master, deviceId, binding);
} }
binding.setWriteTimeStatus("1");
// 5. 更新数据库 // 5. 更新数据库
palletDeviceBindingMapper.updatePalletDeviceBinding(binding); palletDeviceBindingMapper.updatePalletDeviceBinding(binding);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment