| | |
| | | boolean initialized = false; |
| | | // 上一步执行时间(用于堵塞检测) |
| | | long stepExecuteTime = System.currentTimeMillis(); |
| | | // 避免在到达目标后重复执行到位逻辑 |
| | | // 仅在每次到达目标时执行一次到位处理,避免重复生成条码 |
| | | boolean arrivalHandled = false; |
| | | |
| | | while (true) { |
| | |
| | | // 路径队列为空,等待新的分段命令 |
| | | if (currentStationId != null && finalTargetStationId != null |
| | | && currentStationId.equals(finalTargetStationId)) { |
| | | // 已到达目标,先执行一次到位逻辑,然后继续等待下一条移动命令 |
| | | // 已到达当前目标后继续等待下一条分段命令,避免排序/绕圈场景吞掉后续命令 |
| | | if (!arrivalHandled) { |
| | | if (generateBarcode) { |
| | | Integer targetDeviceNo = getDeviceNoByStationId(finalTargetStationId); |
| | |
| | | } |
| | | |
| | | if (command.getCommandType() == StationCommandType.WRITE_INFO) { |
| | | if (command.getBarcode() != null) { |
| | | updateStationBarcode(deviceNo, stationId, command.getBarcode()); |
| | | return; |
| | | } |
| | | if (taskNo == 9998 && targetStationId == 0) { |
| | | // 生成出库站点仿真数据 |
| | | generateFakeOutStationData(deviceNo, stationId); |
| | |
| | | } |
| | | } |
| | | |
| | | private void updateStationBarcode(Integer deviceNo, Integer stationId, String barcode) { |
| | | List<ZyStationStatusEntity> statusList = deviceStatusMap.get(deviceNo); |
| | | if (statusList == null) { |
| | | return; |
| | | } |
| | | |
| | | ZyStationStatusEntity status = statusList.stream() |
| | | .filter(item -> item.getStationId().equals(stationId)).findFirst().orElse(null); |
| | | if (status == null) { |
| | | return; |
| | | } |
| | | |
| | | synchronized (status) { |
| | | status.setBarcode(barcode); |
| | | } |
| | | } |
| | | |
| | | // segmentedPathCommand 方法已删除,功能已整合到 runTaskLoop |
| | | |
| | | private Integer getDeviceNoByStationId(Integer stationId) { |