| | |
| | | private static final int RUN_BLOCK_DIRECT_REASSIGN_NEAREST_CACHE_SECONDS = 60 * 60 * 24; |
| | | private static final long CHECK_STATION_OUT_ORDER_SLOW_THRESHOLD_MS = 200L; |
| | | private static final long EXECUTE_REROUTE_PLAN_SLOW_THRESHOLD_MS = 200L; |
| | | private static final String RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING_PREFIX = "堵塞重分配请求WMS失败"; |
| | | private static final String RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING = |
| | | RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING_PREFIX + ",请检查WMS重新分配库位接口"; |
| | | |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | |
| | | } |
| | | String response = wmsOperateUtils.applyReassignTaskLocNo(wrkMast.getWrkNo(), stationProtocol.getStationId()); |
| | | if (Cools.isEmpty(response)) { |
| | | appendStationSystemWarning(stationProtocol, RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING); |
| | | News.taskError(wrkMast.getWrkNo(), "请求WMS重新分配库位接口失败,接口未响应!!!response:{}", response); |
| | | return; |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (!jsonObject.getInteger("code").equals(200)) { |
| | | News.error("请求WMS接口失败!!!response:{}", response); |
| | | JSONObject jsonObject; |
| | | try { |
| | | jsonObject = JSON.parseObject(response); |
| | | } catch (Exception e) { |
| | | appendStationSystemWarning(stationProtocol, RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING); |
| | | News.taskError(wrkMast.getWrkNo(), "请求WMS重新分配库位接口响应解析异常!!!response:{}", response, e); |
| | | return; |
| | | } |
| | | if (jsonObject == null || !Integer.valueOf(200).equals(jsonObject.getInteger("code"))) { |
| | | appendStationSystemWarning(stationProtocol, RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING); |
| | | News.taskError(wrkMast.getWrkNo(), "请求WMS接口失败!!!response:{}", response); |
| | | return; |
| | | } |
| | | |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | if (dto == null || Cools.isEmpty(dto.getLocNo())) { |
| | | appendStationSystemWarning(stationProtocol, RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING); |
| | | News.taskError(wrkMast.getWrkNo(), "请求WMS重新分配库位接口失败,WMS未返回目标库位!!!response:{}", response); |
| | | return; |
| | | } |
| | | clearStationSystemWarningByPrefix(stationProtocol, RUN_BLOCK_DIRECT_REASSIGN_WMS_WARNING_PREFIX); |
| | | String sourceLocNo = wrkMast.getLocNo(); |
| | | String locNo = dto.getLocNo(); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private void appendStationSystemWarning(StationProtocol stationProtocol, String warning) { |
| | | if (stationProtocol == null || Cools.isEmpty(warning)) { |
| | | return; |
| | | } |
| | | String currentWarning = stationProtocol.getSystemWarning(); |
| | | if (Cools.isEmpty(currentWarning)) { |
| | | stationProtocol.setSystemWarning(warning); |
| | | return; |
| | | } |
| | | if (currentWarning.contains(warning)) { |
| | | return; |
| | | } |
| | | stationProtocol.setSystemWarning(currentWarning + ";" + warning); |
| | | } |
| | | |
| | | private void clearStationSystemWarningByPrefix(StationProtocol stationProtocol, String warningPrefix) { |
| | | if (stationProtocol == null || Cools.isEmpty(warningPrefix) || Cools.isEmpty(stationProtocol.getSystemWarning())) { |
| | | return; |
| | | } |
| | | String[] warningParts = stationProtocol.getSystemWarning().split(";"); |
| | | List<String> keepWarningList = new ArrayList<>(); |
| | | for (String warningPart : warningParts) { |
| | | if (Cools.isEmpty(warningPart) || warningPart.startsWith(warningPrefix)) { |
| | | continue; |
| | | } |
| | | keepWarningList.add(warningPart); |
| | | } |
| | | stationProtocol.setSystemWarning(String.join(";", keepWarningList)); |
| | | } |
| | | |
| | | private int countCurrentTaskBufferCommands(List<StationTaskBufferItem> taskBufferItems, Integer currentTaskNo) { |
| | | if (taskBufferItems == null || taskBufferItems.isEmpty() || currentTaskNo == null || currentTaskNo <= 0) { |
| | | return 0; |