| | |
| | | import com.zy.acs.common.domain.protocol.IMessageBody; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.common.utils.RequestSupport; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | public BaseResult<?> executeAgvActionCmd(AgvAction agvAction) { |
| | | |
| | |
| | | String serialNo = agvAction.getSerialNo(); |
| | | |
| | | AgvProtocol protocol = AgvProtocol.build(agvAction.getAgvNo()).setMessageBody(agvAction.beMesBody(serialNo)); |
| | | |
| | | // fake |
| | | if (configService.getVal("fakeSign", Boolean.class)) { |
| | | return BaseResult.ok(); |
| | | } |
| | | |
| | | return this.requestProcess(serialNo, protocol |
| | | , (RequestSupport<AGV_01_UP>) result -> result.getSerialNo().equals(serialNo)); |
| | |
| | | @SuppressWarnings("all") |
| | | private IMessageBody executeRequest(String serialNo, AgvProtocol protocol) throws TimeoutException { |
| | | |
| | | redis.push(RedisConstant.AGV_CMD_DOWN_FLAG, protocol); |
| | | redis.push(RedisConstant.AGV_PATH_DOWN_FLAG, protocol); |
| | | |
| | | IMessageBody messageBody = null; |
| | | |
| | |
| | | // 获取响应 |
| | | long startTime = System.currentTimeMillis(); |
| | | while ((System.currentTimeMillis() - startTime) < RedisConstant.CMD_TIMEOUT_LIMIT) { |
| | | if ((messageBody = redis.getObject(RedisConstant.AGV_CMD_UP_FLAG, redisKey)) != null){ |
| | | redis.deleteObject(RedisConstant.AGV_CMD_UP_FLAG, redisKey); |
| | | if ((messageBody = redis.getObject(RedisConstant.AGV_PATH_UP_FLAG, redisKey)) != null){ |
| | | redis.deleteObject(RedisConstant.AGV_PATH_UP_FLAG, redisKey); |
| | | return messageBody; |
| | | } |
| | | try{ |