zhang
2025-05-20 1313906bb1eb983d3beece810035e7fc28d6a92f
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AgvCmdService.java
@@ -12,6 +12,7 @@
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;
@@ -29,11 +30,13 @@
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;
    @Autowired
    private ConfigService configService;
    public BaseResult<?> executeAgvActionCmd(AgvAction agvAction) {
        // todo 1: 记录日志 2:发送任务  3:同步响应
        log.info(JSON.toJSONString(agvAction));
//        log.info(JSON.toJSONString(agvAction));
        String serialNo = agvAction.getSerialNo();
@@ -66,7 +69,8 @@
            } else {
                return BaseResult.error();
            }
        } catch (TimeoutException ex){
        } catch (TimeoutException e){
            log.error("AgvCmdService.requestProcess", e);
            return BaseResult.error();
        }
    }
@@ -74,7 +78,7 @@
    @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;
@@ -82,12 +86,12 @@
        // 获取响应
        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{
                Thread.sleep(100);
                Thread.sleep(10);
            }catch(Exception ex){
                ex.printStackTrace();
            }