| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private DeviceConfigService deviceConfigService; |
| | | @Autowired |
| | | private StationCommandDispatcher stationCommandDispatcher; |
| | | |
| | | @PostMapping("/command/move") |
| | | public R commandMove(@RequestBody StationCommandMoveParam param) { |
| | |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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) { |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |