#
vincentlu
4 天以前 067ea036e9044d8e57d0d1abaddd66f13f745e6a
zy-acs-manager/src/main/java/com/zy/acs/manager/core/HandlerController.java
@@ -3,12 +3,13 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.acs.common.constant.RedisConstant;
import com.zy.acs.common.utils.Base62;
import com.zy.acs.common.utils.RedisSupport;
import com.zy.acs.common.utils.Utils;
import com.zy.acs.framework.common.Cools;
import com.zy.acs.framework.common.R;
import com.zy.acs.framework.common.SnowflakeIdWorker;
import com.zy.acs.manager.common.annotation.OperationLog;
import com.zy.acs.manager.common.config.UplinkProperties;
import com.zy.acs.manager.common.domain.param.HandlerPublishParam;
import com.zy.acs.manager.common.exception.BusinessException;
import com.zy.acs.manager.core.service.*;
@@ -64,7 +65,7 @@
    @Autowired
    private StaService staService;
    @Autowired
    private TrafficService trafficService;
    private UplinkProperties uplinkProperties;
    @Autowired
    private ThreadPoolRegulator threadPoolRegulator;
    @Autowired
@@ -75,6 +76,8 @@
    private PatrolService patrolService;
    @Autowired
    private StaReserveService staReserveService;
    @Autowired
    private AgvAreaDispatcher agvAreaDispatcher;
    @PreAuthorize("hasAuthority('manager:agv:update')")
    @OperationLog("Locate All Agv")
@@ -162,12 +165,13 @@
        Task task = new Task();
        task.setAgvId(agv.getId());
        task.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
        List<Task> lastTasks = taskService.list(new LambdaQueryWrapper<Task>().orderByDesc(Task::getId));
        task.setSeqNum(Utils.generateSeqNum(Cools.isEmpty(lastTasks)?null:lastTasks.get(0).getSeqNum()));
//        List<Task> lastTasks = taskService.list(new LambdaQueryWrapper<Task>().orderByDesc(Task::getId));
//        task.setSeqNum(Utils.generateSeqNum(Cools.isEmpty(lastTasks)?null:lastTasks.get(0).getSeqNum()));
        task.setSeqNum(Base62.encode(snowflakeIdWorker.nextId()));
        task.setTaskType(param.getTaskMode().val());
        task.setTaskSts(TaskStsType.WAITING.val());
        task.setUplinkSts(uplinkProperties.getEnabled() ? TaskUplinkStateType.PENDING.toString() : TaskUplinkStateType.SKIPPED.toString());
        task.setPriority(999);
        task.setIoTime(now);
        task.setStartTime(now);
@@ -192,6 +196,9 @@
                }
                if (null == endCode) {
                    return R.error();
                }
                if (!agvAreaDispatcher.match(agv.getId(), endCode.getId())) {
                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + endCode.getData());
                }
                if (!taskService.removeById(task.getId())) {
                    throw new BusinessException("failed to remove task");
@@ -222,6 +229,10 @@
                if (null == oriLoc) {
                    return R.error();
                }
                if (!agvAreaDispatcher.match(agv.getId(), oriLoc.getCode())) {
//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriLoc.getCode$());
                    throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达起始库位【" + oriLoc.getLocNo() + "】");
                }
                if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
                    throw new BusinessException("oriLoc:" + oriLoc.getLocNo() + " 不是在库状态");
                }
@@ -240,6 +251,10 @@
                }
                if (null == destLoc) {
                    return R.error();
                }
                if (!agvAreaDispatcher.match(agv.getId(), destLoc.getCode())) {
//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destLoc.getCode$());
                    throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达目标库位【" + destLoc.getLocNo() + "】");
                }
                if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
                    throw new BusinessException("destLoc:" + destLoc.getLocNo() + " 不是空闲状态");
@@ -267,6 +282,10 @@
                if (null == oriLoc) {
                    return R.error();
                }
                if (!agvAreaDispatcher.match(agv.getId(), oriLoc.getCode())) {
//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriLoc.getCode$());
                    throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达起始库位【" + oriLoc.getLocNo() + "】");
                }
                if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
                    throw new BusinessException("oriLoc:" + oriLoc.getLocNo() + " 不是在库状态");
                }
@@ -285,6 +304,10 @@
                }
                if (null == destSta) {
                    return R.error();
                }
                if (!agvAreaDispatcher.match(agv.getId(), destSta.getCode())) {
//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destSta.getCode$());
                    throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达目标站点【" + destSta.getStaNo() + "】");
                }
                if (null == staReserveService.reserveStaIn(destSta, task, 1)) {
                    throw new BusinessException("destSta:" + destSta.getStaNo() + " 预约失败");
@@ -308,6 +331,10 @@
                if (null == oriSta) {
                    return R.error();
                }
                if (!agvAreaDispatcher.match(agv.getId(), oriSta.getCode())) {
//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriSta.getCode$());
                    throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达起始站点【" + oriSta.getStaNo() + "】");
                }
                if (null == staReserveService.reserveStaOut(oriSta, task, 1)) {
                    throw new BusinessException("oriSta:" + oriSta.getStaNo() + " 预约失败");
                }
@@ -321,6 +348,10 @@
                }
                if (null == destLoc) {
                    return R.error();
                }
                if (!agvAreaDispatcher.match(agv.getId(), destLoc.getCode())) {
//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destLoc.getCode$());
                    throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达目标库位【" + destLoc.getLocNo() + "】");
                }
                if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
                    throw new BusinessException("destLoc:" + destLoc.getLocNo() + " 不是空闲状态");
@@ -350,6 +381,10 @@
                if (null == oriSta) {
                    return R.error();
                }
                if (!agvAreaDispatcher.match(agv.getId(), oriSta.getCode())) {
//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriSta.getCode$());
                    throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达起始站点【" + oriSta.getStaNo() + "】");
                }
                if (null == staReserveService.reserveStaOut(oriSta, task, 1)) {
                    throw new BusinessException("oriSta:" + oriSta.getStaNo() + " 预约失败");
                }
@@ -365,6 +400,10 @@
                if (null == destSta) {
                    return R.error();
                }
                if (!agvAreaDispatcher.match(agv.getId(), destSta.getCode())) {
//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destSta.getCode$());
                    throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达目标站点【" + destSta.getStaNo() + "】");
                }
                if (null == staReserveService.reserveStaIn(destSta, task, 1)) {
                    throw new BusinessException("destSta:" + destSta.getStaNo() + " 预约失败");
                }