| | |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.StationCommand; |
| | | import com.zy.core.model.protocol.StationProtocol; |
| | | import com.zy.core.model.protocol.StationTaskBufferItem; |
| | | import com.zy.core.network.DeviceConnectPool; |
| | | import com.zy.core.network.ZyStationConnectDriver; |
| | | import com.zy.core.network.entity.ZyStationStatusEntity; |
| | |
| | | stationProtocol.setEnableIn(statusEntity.isEnableIn()); |
| | | stationProtocol.setWeight(statusEntity.getWeight()); |
| | | stationProtocol.setTaskWriteIdx(statusEntity.getTaskWriteIdx()); |
| | | stationProtocol.setTaskBufferItems(statusEntity.getTaskBufferItems()); |
| | | } |
| | | |
| | | if (!Cools.isEmpty(stationProtocol.getSystemWarning())) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public synchronized boolean clearPath(Integer taskNo) { |
| | | if (taskNo == null || taskNo <= 0) { |
| | | return false; |
| | | } |
| | | if (zyStationConnectDriver == null) { |
| | | return false; |
| | | } |
| | | List<StationProtocol> status = getStatus(); |
| | | if (status == null || status.isEmpty()) { |
| | | return false; |
| | | } |
| | | |
| | | boolean found = false; |
| | | boolean success = true; |
| | | for (StationProtocol stationProtocol : status) { |
| | | List<StationTaskBufferItem> taskBufferItems = stationProtocol == null ? null : stationProtocol.getTaskBufferItems(); |
| | | if (taskBufferItems == null || taskBufferItems.isEmpty()) { |
| | | continue; |
| | | } |
| | | Integer stationId = stationProtocol.getStationId(); |
| | | for (StationTaskBufferItem item : taskBufferItems) { |
| | | if (item == null || !Objects.equals(taskNo, item.getTaskNo())) { |
| | | continue; |
| | | } |
| | | found = true; |
| | | if (!zyStationConnectDriver.clearTaskBufferSlot(stationId, item.getSlotIdx())) { |
| | | success = false; |
| | | log.warn("输送站缓存区残留路径清理失败。stationId={}, slotIdx={}, taskNo={}", |
| | | stationId, item.getSlotIdx(), item.getTaskNo()); |
| | | continue; |
| | | } |
| | | item.setTaskNo(0); |
| | | item.setTargetStaNo(0); |
| | | } |
| | | } |
| | | return found && success; |
| | | } |
| | | |
| | | @Override |
| | | public CommandResponse sendCommand(StationCommand command) { |
| | | CommandResponse commandResponse = null; |
| | | try { |
| | |
| | | e.printStackTrace(); |
| | | } finally { |
| | | BasStationOptService optService = SpringUtils.getBean(BasStationOptService.class); |
| | | if (optService == null) { |
| | | return commandResponse; |
| | | } |
| | | List<ZyStationStatusEntity> statusListEntity = zyStationConnectDriver.getStatus(); |
| | | ZyStationStatusEntity matched = null; |
| | | if (statusListEntity != null) { |
| | |
| | | null, |
| | | JSON.toJSONString(command), |
| | | JSON.toJSONString(matched), |
| | | 1, |
| | | commandResponse != null && Boolean.TRUE.equals(commandResponse.getResult()) ? 1 : 0, |
| | | JSON.toJSONString(commandResponse) |
| | | ); |
| | | if (optService != null) { |
| | | optService.save(basStationOpt); |
| | | } |
| | | optService.save(basStationOpt); |
| | | } |
| | | return commandResponse; |
| | | } |