| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.zy.asrs.domain.param.StationCommandBarcodeParam; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | 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(); |
| | | } |
| | | |
| | |
| | | return R.error("当前系统未启用仿真插件"); |
| | | } |
| | | |
| | | Config enableFakeConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake")); |
| | | Config enableFakeConfig = configService.getOne(new QueryWrapper<Config>().eq("code", "enableFake")); |
| | | if (enableFakeConfig == null || !"Y".equals(enableFakeConfig.getValue())) { |
| | | return R.error("当前非仿真运行模式,禁止修改条码"); |
| | | } |
| | |
| | | } |
| | | |
| | | Integer devpNo = finalStation.getDeviceNo(); |
| | | DeviceConfig deviceConfig = deviceConfigService.selectOne(new EntityWrapper<DeviceConfig>() |
| | | DeviceConfig deviceConfig = deviceConfigService.getOne(new QueryWrapper<DeviceConfig>() |
| | | .eq("device_no", devpNo) |
| | | .eq("device_type", String.valueOf(SlaveType.Devp))); |
| | | if (deviceConfig == null || deviceConfig.getFake() == null || deviceConfig.getFake() != 1) { |
| | |
| | | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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) { |
| | | if (Cools.isEmpty(stationId)) { |
| | | return null; |
| | | } |
| | | |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>()); |
| | | List<BasDevp> basDevps = basDevpService.list(new QueryWrapper<BasDevp>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | List<StationObjModel> list = basDevp.getStationList$(); |
| | | for (StationObjModel entity : list) { |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |