Commit b89df233 authored by wanghao's avatar wanghao

1测试上电断电操作

parent ae52307a
......@@ -35,6 +35,8 @@ public interface RobotArmCommandMapper
*/
public List<RobotArmCommand> selectRobotArmCommandList(RobotArmCommand robotArmCommand);
public List<RobotArmCommand> selectTopRunningRobotArmCommands();
public List<RobotArmCommand> findByType(String type);
/**
......
package com.zehong.system.netty.handler;
import com.zehong.system.domain.RobotArmCommand;
import com.zehong.system.service.IRobotArmCommandService;
import com.zehong.system.service.websocket.RobotArmWebSocketHandler;
import com.zehong.system.udp.RobotArmMessageParser;
......@@ -19,6 +20,7 @@ import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
......@@ -43,6 +45,8 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
private static final SimpleDateFormat TIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private volatile long lastActivityTime = System.currentTimeMillis();
@Resource
private NettyUdpServerHandler nettyUdpServerHandler;
/**
* 当前正在处理的指令信息
*/
......@@ -142,6 +146,16 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
status.getX(), status.getY(), status.getZ(), status.getR());
CommandExecution execution = currentCommands.get("127.0.0.1");
// 如果指令追踪为空,则可能是 刚启动,再去 查一下有没有正在执行的任务
if(execution == null) {
List<RobotArmCommand> robotArmCommands = robotArmCommandService.selectTopRunningRobotArmCommands();
if(robotArmCommands != null && !robotArmCommands.isEmpty()) {
// 注册指令跟踪
execution = new CommandExecution();
execution.commandId = robotArmCommands.get(0).getRobotArmCommandId();
}
}
if (execution != null) {
robotArmCommandService.completeCommand(execution.commandId);
currentCommands.remove("127.0.0.1");
......
......@@ -27,6 +27,8 @@ public interface IRobotArmCommandService
*/
public List<RobotArmCommand> selectRobotArmCommandList(RobotArmCommand robotArmCommand);
public List<RobotArmCommand> selectTopRunningRobotArmCommands();
public List<RobotArmCommand> findByType(String type);
public int insertBlankingRobotArmCommand(RobotArmCommand robotArmCommand);
......
......@@ -305,6 +305,11 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
return robotArmCommandMapper.selectRobotArmCommandList(robotArmCommand);
}
@Override
public List<RobotArmCommand> selectTopRunningRobotArmCommands() {
return robotArmCommandMapper.selectTopRunningRobotArmCommands();
}
@Override
public List<RobotArmCommand> findByType(String type) {
return robotArmCommandMapper.findByType( type);
......
......@@ -46,6 +46,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null "> and f_create_time = #{createTime}</if>
</where>
</select>
<select id="selectTopRunningRobotArmCommands" resultMap="RobotArmCommandResult">
<include refid="selectRobotArmCommandVo"/>
where f_status = '2'
</select>
<select id="selectRobotArmCommandById" parameterType="Long" resultMap="RobotArmCommandResult">
<include refid="selectRobotArmCommandVo"/>
......
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