From 59156c0295cf0ceba9d585545360a9288d4adec7 Mon Sep 17 00:00:00 2001 From: psh Date: Fri, 22 Dec 2023 08:54:13 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=AF=B7=E6=B1=82wcs=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E5=8F=96=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/nl/acs/AcsConfig.java | 2 +- .../agv/ndcone/AgvNdcOneDeviceDriver.java | 92 +++++++++++++++++-- .../acs/ext/wms/service/AcsToWmsService.java | 7 ++ .../wms/service/impl/AcsToWmsServiceImpl.java | 47 ++++++++-- 4 files changed, 132 insertions(+), 16 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java b/acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java index 77cbff7..33ada00 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java @@ -31,7 +31,7 @@ public interface AcsConfig { //WMS系统接口地址 String WMSURL = "wmsurl"; //WCS系统接口地址 - String WCSURL = "wcsurl"; + String WCSURL = "liKu_wcs_url"; String HASOTHERSYSTEM = "hasOtherSystem"; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java index c66924d..c7aa990 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java @@ -172,8 +172,27 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if ("true".equals(device.getExtraValue().get("wait"))) { - // todo 请求wcs是否允许取货 + if ("true".equals(device.getExtraValue().get("wait")) + && !inst.getTask_code().startsWith("-") + && "1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue())) { + JSONObject form = new JSONObject(); + form.put("vehicle_code", inst.getVehicle_code()); + form.put("status", 1); + form.put("device_code", device_code); + form.put("task_code", inst.getTask_code()); + JSONObject result = acsToWmsService.feedWcsAgvTaskStatus(new JSONArray() {{ + add(form); + }}); + + if (HttpStatus.HTTP_OK == result.getIntValue("status")) { + wcsFlag = true; + } else { + String resultMessage = result.getString("message"); + this.message = resultMessage; + String message = resultMessage + "不允许AGV取货。"; + driver.setMessage(message); + logServer.deviceExecuteLog(device_code, "", "", message); + } } else { wcsFlag = true; } @@ -350,8 +369,27 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if ("true".equals(device.getExtraValue().get("wait"))) { - // todo 请求wcs是否允许取货 + if ("true".equals(device.getExtraValue().get("wait")) + && !inst.getTask_code().startsWith("-") + && "1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue())) { + JSONObject form = new JSONObject(); + form.put("vehicle_code", inst.getVehicle_code()); + form.put("status", 2); + form.put("device_code", device_code); + form.put("task_code", inst.getTask_code()); + JSONObject result = acsToWmsService.feedWcsAgvTaskStatus(new JSONArray() {{ + add(form); + }}); + + if (HttpStatus.HTTP_OK == result.getIntValue("status")) { + wcsFlag = true; + } else { + String resultMessage = result.getString("message"); + this.message = resultMessage; + String message = resultMessage + "不允许AGV取货后离开。"; + driver.setMessage(message); + logServer.deviceExecuteLog(device_code, "", "", message); + } } else { wcsFlag = true; } @@ -525,8 +563,27 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if ("true".equals(device.getExtraValue().get("wait"))) { - // todo 请求wcs是否允许取货 + if ("true".equals(device.getExtraValue().get("wait")) + && !inst.getTask_code().startsWith("-") + && "1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue())) { + JSONObject form = new JSONObject(); + form.put("vehicle_code", inst.getVehicle_code()); + form.put("status", 3); + form.put("device_code", device_code); + form.put("task_code", inst.getTask_code()); + JSONObject result = acsToWmsService.feedWcsAgvTaskStatus(new JSONArray() {{ + add(form); + }}); + + if (HttpStatus.HTTP_OK == result.getIntValue("status")) { + wcsFlag = true; + } else { + String resultMessage = result.getString("message"); + this.message = resultMessage; + String message = resultMessage + "不允许AGV放货。"; + driver.setMessage(message); + logServer.deviceExecuteLog(device_code, "", "", message); + } } else { wcsFlag = true; } @@ -692,8 +749,27 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if ("true".equals(device.getExtraValue().get("wait"))) { - // todo 请求wcs是否允许取货 + if ("true".equals(device.getExtraValue().get("wait")) + && !inst.getTask_code().startsWith("-") + && "1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue())) { + JSONObject form = new JSONObject(); + form.put("vehicle_code", inst.getVehicle_code()); + form.put("status", 4); + form.put("device_code", device_code); + form.put("task_code", inst.getTask_code()); + JSONObject result = acsToWmsService.feedWcsAgvTaskStatus(new JSONArray() {{ + add(form); + }}); + + if (HttpStatus.HTTP_OK == result.getIntValue("status")) { + wcsFlag = true; + } else { + String resultMessage = result.getString("message"); + this.message = resultMessage; + String message = resultMessage + "不允许AGV放货后离开。"; + driver.setMessage(message); + logServer.deviceExecuteLog(device_code, "", "", message); + } } else { wcsFlag = true; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index 882304f..64d73b9 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -114,6 +114,13 @@ public interface AcsToWmsService { * @return */ JSONObject feedAgvTaskStatus(JSONArray from); + /** + * 反馈WCSAGV取放货状态 + * + * @param from + * @return + */ + JSONObject feedWcsAgvTaskStatus(JSONArray from); JSONObject test(JSONObject form); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index 40dfbc9..95e644c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -107,21 +107,21 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { AddressDto addressDto = addressService.findByCode("feedbackTaskStatusToWms"); String methods_url = addressDto.getMethods_url(); String url = wmsurl + methods_url; - Map map = new HashMap<>(); - map.put("payload", JSON.toJSONString(data)); +// Map map = new HashMap<>(); +// map.put("payload", JSON.toJSONString(data)); try { result = HttpRequest .post(url) .header("Content-Type", "application/json;charset=UTF-8") .header("Authorization", String.valueOf(redisUtils.get("wms_token"))) - .body(JSON.toJSONString(map)) + .body(JSON.toJSONString(data)) .timeout(3000) .execute(); - log.info("反馈wms任务状态成功,请求路径:{},请求参数:{},响应参数:{}", url, JSON.toJSONString(map), JSON.toJSONString(result.body())); + log.info("反馈wms任务状态成功,请求路径:{},请求参数:{},响应参数:{}", url, JSON.toJSONString(data), JSON.toJSONString(result.body())); } catch (Exception e) { log.error("反馈wms任务状态失败,请求路径:{},失败原因:{}", url, e.getMessage()); CompletableFuture.runAsync(() -> { - retryableUtil.retryable(url, JSON.toJSONString(map)); + retryableUtil.retryable(url, JSON.toJSONString(data)); }); } return result; @@ -563,12 +563,45 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { AddressDto addressDto = addressService.findByCode("feedAgvTaskStatus"); String methodsUrl = addressDto.getMethods_url(); String url = wmsUrl + methodsUrl; -// log.info("feedAgvTaskStatus - 请求参数 {}", param); + log.info("feedAgvTaskStatus - 请求参数 {}", from); HttpResponse response = HttpRequest .post(url) .body(from.toString()) .execute(); -// log.info("feedAgvTaskStatus - 返回参数 {}", response.body()); + log.info("feedAgvTaskStatus - 返回参数 {}", response.body()); + return JSONObject.parseObject(response.body()); + } + } catch (Throwable ignored) { + JSONObject result = new JSONObject(); + result.put("status", HttpStatus.HTTP_CLIENT_TIMEOUT); + result.put("message", "请求超时!"); + return result; + } finally { + MDC.remove(log_file_type); + } + + JSONObject result = new JSONObject(); + result.put("status", HttpStatus.HTTP_BAD_REQUEST); + result.put("message", "请求失败,未知原因!"); + return result; + } + + @Override + public JSONObject feedWcsAgvTaskStatus(JSONArray from) { + try { + MDC.put(log_file_type, log_type); + + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + String wmsUrl = paramService.findByCode(AcsConfig.WCSURL).getValue(); + AddressDto addressDto = addressService.findByCode("feedWcsAgvTaskStatus"); + String methodsUrl = addressDto.getMethods_url(); + String url = wmsUrl + methodsUrl; + log.info("feedWcsAgvTaskStatus - 请求参数 {}", from); + HttpResponse response = HttpRequest + .post(url) + .body(from.toString()) + .execute(); + log.info("feedWcsAgvTaskStatus - 返回参数 {}", response.body()); return JSONObject.parseObject(response.body()); } } catch (Throwable ignored) {