| | |
| | | import com.zy.core.model.protocol.StationProtocol; |
| | | import com.zy.core.move.StationMoveCoordinator; |
| | | import com.zy.core.trace.StationTaskTraceRegistry; |
| | | import com.zy.core.thread.impl.v5.StationV5RuntimeConfigProvider; |
| | | import com.zy.core.thread.support.StationTaskLocationRegistry; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | |
| | |
| | | private static final String CFG_STATION_COMMAND_SEGMENT_ADVANCE_RATIO = "stationCommandSegmentAdvanceRatio"; |
| | | private static final double DEFAULT_STATION_COMMAND_SEGMENT_ADVANCE_RATIO = 0.3d; |
| | | private static final long CURRENT_STATION_TIMEOUT_MS = 1000L * 60L; |
| | | private static final long TASK_LOCATION_STALE_MS = 2_000L; |
| | | |
| | | private final DeviceConfig deviceConfig; |
| | | private final RedisUtil redisUtil; |
| | |
| | | } |
| | | |
| | | private double loadSegmentAdvanceRatio() { |
| | | if (isV5ThreadImpl()) { |
| | | StationV5RuntimeConfigProvider configProvider = SpringUtils.getBean(StationV5RuntimeConfigProvider.class); |
| | | if (configProvider != null) { |
| | | return configProvider.getSegmentAdvanceRatio(); |
| | | } |
| | | return DEFAULT_STATION_COMMAND_SEGMENT_ADVANCE_RATIO; |
| | | } |
| | | try { |
| | | ConfigService configService = SpringUtils.getBean(ConfigService.class); |
| | | if (configService == null) { |
| | |
| | | } |
| | | |
| | | private StationProtocol findCurrentStationByTask(Integer taskNo) { |
| | | if (isV5ThreadImpl()) { |
| | | return findCurrentStationByTaskFromRegistry(taskNo); |
| | | } |
| | | try { |
| | | com.zy.asrs.service.DeviceConfigService deviceConfigService = SpringUtils.getBean(com.zy.asrs.service.DeviceConfigService.class); |
| | | if (deviceConfigService == null) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | private StationProtocol findCurrentStationByTaskFromRegistry(Integer taskNo) { |
| | | StationTaskLocationRegistry registry = SpringUtils.getBean(StationTaskLocationRegistry.class); |
| | | if (registry == null) { |
| | | return null; |
| | | } |
| | | StationTaskLocationRegistry.TaskLocationSnapshot snapshot = registry.findActive(taskNo, TASK_LOCATION_STALE_MS); |
| | | if (snapshot == null || !snapshot.isLoading()) { |
| | | return null; |
| | | } |
| | | StationProtocol stationProtocol = new StationProtocol(); |
| | | stationProtocol.setTaskNo(snapshot.getTaskNo()); |
| | | stationProtocol.setStationId(snapshot.getStationId()); |
| | | stationProtocol.setRunBlock(snapshot.isRunBlock()); |
| | | stationProtocol.setLoading(true); |
| | | return stationProtocol; |
| | | } |
| | | |
| | | private boolean isV5ThreadImpl() { |
| | | return deviceConfig != null && "ZyStationV5Thread".equals(deviceConfig.getThreadImpl()); |
| | | } |
| | | |
| | | private List<StationTaskTraceSegmentVo> buildTraceSegments(List<StationCommand> segmentCommands) { |
| | | List<StationTaskTraceSegmentVo> result = new ArrayList<>(); |
| | | if (segmentCommands == null) { |