Junjie
23 小时以前 ef776e9fd5e4f64e4ad09a3faa12fb7bb646c79c
src/main/java/com/zy/asrs/controller/StationController.java
@@ -7,6 +7,8 @@
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.DeviceConfigService;
import com.zy.common.utils.RedisUtil;
import com.zy.core.dispatch.StationCommandDispatchResult;
import com.zy.core.dispatch.StationCommandDispatcher;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.enums.StationCommandType;
import com.zy.core.model.StationObjModel;
@@ -22,10 +24,8 @@
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.domain.param.StationCommandMoveParam;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.Task;
import com.zy.core.model.command.StationCommand;
import com.zy.core.thread.StationThread;
@@ -45,6 +45,8 @@
    private ConfigService configService;
    @Autowired
    private DeviceConfigService deviceConfigService;
    @Autowired
    private StationCommandDispatcher stationCommandDispatcher;
    @PostMapping("/command/move")
    public R commandMove(@RequestBody StationCommandMoveParam param) {
@@ -70,7 +72,14 @@
        }
        StationCommand command = stationThread.getCommand(StationCommandType.MOVE, taskNo, stationId, targetStationId, 0);
        MessageQueue.offer(SlaveType.Devp, devpNo, new Task(2, command));
        if (command == null) {
            return R.error("生成输送命令失败,路径为空或不可达");
        }
        StationCommandDispatchResult dispatchResult = stationCommandDispatcher
                .dispatch(devpNo, command, "station-controller", "manual-move");
        if (!dispatchResult.isAccepted()) {
            return R.error("输送命令下发失败:" + dispatchResult.getReason());
        }
        return R.ok();
    }
@@ -115,7 +124,11 @@
        StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO, 9997, stationId, stationId, 0);
        command.setBarcode(barcode.trim());
        MessageQueue.offer(SlaveType.Devp, devpNo, new Task(2, command));
        StationCommandDispatchResult dispatchResult = stationCommandDispatcher
                .dispatch(devpNo, command, "station-controller", "manual-barcode");
        if (!dispatchResult.isAccepted()) {
            return R.error("条码命令下发失败:" + dispatchResult.getReason());
        }
        return R.ok();
    }
@@ -128,6 +141,29 @@
        Integer taskNo = param.getTaskNo();
        redisUtil.set(RedisKeyType.DEVICE_STATION_MOVE_RESET.key + taskNo, "cancel", 3);
        return R.ok();
    }
    @PostMapping("/command/clearPath")
    public R commandClearPath(@RequestBody StationCommandMoveParam param) {
        if (Cools.isEmpty(param) || Cools.isEmpty(param.getStationId()) || Cools.isEmpty(param.getTaskNo())) {
            return R.error("缺少参数");
        }
        StationObjModel finalStation = findStation(param.getStationId());
        if (finalStation == null) {
            return R.error("站点不存在");
        }
        StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, finalStation.getDeviceNo());
        if (stationThread == null) {
            return R.error("线程不存在");
        }
        boolean cleared = stationThread.clearPath(param.getTaskNo());
        if (!cleared) {
            return R.error("未匹配到可清理路径或清理失败");
        }
        return R.ok("清理路径成功");
    }
    private StationObjModel findStation(Integer stationId) {
@@ -146,5 +182,4 @@
        }
        return null;
    }
}