| | |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Collection; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | |
| | | try { |
| | | Map<String, Object> res = wmsServerFeignClient.openAsrsQueryTask(req); |
| | | if (res == null) { |
| | | wcsStationStatusService.upsertFromRcsPoll(stationId, taskNo, null); |
| | | // wcsStationStatusService.upsertFromRcsPoll(stationId, taskNo, null); |
| | | wcsStationStatusService.clearStationSnapshot(stationId); |
| | | return; |
| | | } |
| | | Object codeObj = res.get("code"); |
| | | int code = parseCode(codeObj); |
| | | if (code != 200) { |
| | | log.debug("WMS queryTask 非成功 code={} msg={}", code, res.get("msg")); |
| | | wcsStationStatusService.upsertFromRcsPoll(stationId, taskNo, null); |
| | | // wcsStationStatusService.upsertFromRcsPoll(stationId, taskNo, null); |
| | | wcsStationStatusService.clearStationSnapshot(stationId); |
| | | return; |
| | | } |
| | | Object data = res.get("data"); |
| | | @SuppressWarnings("unchecked") |
| | | Map<String, Object> dataMap = data instanceof Map ? (Map<String, Object>) data : null; |
| | | if (dataMap == null || !hasWrkDetls(dataMap)) { |
| | | // queryTask 空数据时清空站点缓存,避免电视机显示历史物料 |
| | | wcsStationStatusService.clearStationSnapshot(stationId); |
| | | return; |
| | | } |
| | | wcsStationStatusService.upsertFromRcsPoll(stationId, taskNo, dataMap); |
| | | } catch (Exception e) { |
| | | log.warn("WMS queryTask 调用失败: {}", e.getMessage()); |
| | | wcsStationStatusService.upsertFromRcsPoll(stationId, taskNo, null); |
| | | // wcsStationStatusService.upsertFromRcsPoll(stationId, taskNo, null); |
| | | wcsStationStatusService.clearStationSnapshot(stationId); |
| | | } |
| | | } |
| | | |
| | | private static boolean hasWrkDetls(Map<String, Object> dataMap) { |
| | | if (dataMap == null) { |
| | | return false; |
| | | } |
| | | Object wrkDetls = dataMap.get("wrkDetls"); |
| | | if (wrkDetls == null) { |
| | | return false; |
| | | } |
| | | if (wrkDetls instanceof Collection) { |
| | | return !((Collection<?>) wrkDetls).isEmpty(); |
| | | } |
| | | if (wrkDetls.getClass().isArray()) { |
| | | return java.lang.reflect.Array.getLength(wrkDetls) > 0; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private static int parseCode(Object codeObj) { |
| | | if (codeObj == null) { |
| | | return 0; |