From c1233a21b1f29d2050fbf342ce5dbd752a7b8197 Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Thu, 6 Jul 2023 09:30:01 +0800 Subject: [PATCH] =?UTF-8?q?rev:=E5=8F=8D=E9=A6=88wms=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agv/ndcone/AgvNdcOneDeviceDriver.java | 8 +++---- .../acs/ext/wms/rest/AcsToWmsController.java | 6 +++--- .../wms/service/impl/AcsToWmsServiceImpl.java | 21 ++++++++++++------- 3 files changed, 21 insertions(+), 14 deletions(-) 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 21ce6f2..6ece9c1 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 @@ -184,7 +184,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { JSONObject resp = JSONObject.parseObject(httpResponse.body()); - if (resp.getInteger("status") == 200) { + if (resp.getJSONObject("payload").getInteger("status") == 200) { data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); log.info("指令号:{},acs请求wms取货申请成功,wms允许agv申请取货,已反馈agv允许取货", inst.getInstruction_code()); } else { @@ -249,7 +249,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { JSONObject resp = JSONObject.parseObject(httpResponse.body()); - if (resp.getInteger("status") == 200) { + if (resp.getJSONObject("payload").getInteger("status") == 200) { data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); log.info("指令号:{},acs反馈wms取货完成离开成功,wms允许agv取货完成离开,已反馈agv取货完成离开", inst.getInstruction_code()); } else { @@ -311,7 +311,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { JSONObject resp = JSONObject.parseObject(httpResponse.body()); - if (resp.getInteger("status") == 200) { + if (resp.getJSONObject("payload").getInteger("status") == 200) { data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); log.info("指令号:{},acs请求wms放货申请成功,wms允许agv申请放货,已反馈agv允许放货", inst.getInstruction_code()); } else { @@ -374,7 +374,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { JSONObject resp = JSONObject.parseObject(httpResponse.body()); - if (resp.getInteger("status") == 200) { + if (resp.getJSONObject("payload").getInteger("status") == 200) { data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); log.info("指令号:{},acs请求wms放货完成申请成功,wms允许agv放货完成,已反馈agv放货完成", inst.getInstruction_code()); } else { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java index e65af14..213c1f3 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java @@ -42,9 +42,9 @@ public class AcsToWmsController { @PostMapping("/taskStatusFeedback") @Log(value = "ACS向WMS反馈任务状态", isInterfaceLog = true, interfaceLogType = InterfaceLogType.ACS_TO_LMS) @ApiOperation("ACS向WMS反馈任务状态") - public ResponseEntity feedbackTaskStatusToWms(@RequestBody Map whereJson) { - JSONArray data = JSONArray.parseArray(String.valueOf(whereJson)); - return new ResponseEntity<>(acstowmsService.feedbackTaskStatusToWms(data), HttpStatus.OK); + @SaIgnore + public ResponseEntity feedbackTaskStatusToWms(@RequestBody JSONArray form) { + return new ResponseEntity<>(acstowmsService.feedbackTaskStatusToWms(form), HttpStatus.OK); } @PostMapping("/feedbackAgvStatus") 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 b7545d5..a1639d0 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 @@ -16,15 +16,14 @@ import org.nl.acs.device.address.service.dto.AddressDto; import org.nl.acs.device.service.DeviceService; import org.nl.acs.ext.wms.data.*; import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.log.service.DeviceExecuteLogService; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; import org.nl.modules.common.utils.RedisUtils; import org.nl.modules.system.service.ParamService; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.TimeUnit; @Service @@ -92,23 +91,25 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { @Override public HttpResponse feedbackTaskStatusToWms(JSONArray data) { - try { MDC.put(log_file_type, log_type); if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { log.info("开始反馈wms任务状态,请求参数:{}", JSON.toJSONString(data)); - if (!redisUtils.hasKey("wms_token")) { + if (redisUtils.getExpire("wms_token") == -1) { this.getTokenFromWms(); } String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue(); HttpResponse result = null; AddressDto addressDto = addressService.findByCode("feedbackTaskStatusToWms"); String methods_url = addressDto.getMethods_url(); + Map map = new HashMap<>(); + map.put("payload", JSON.toJSONString(data)); try { result = HttpRequest .post(wmsurl + methods_url) + .header("Content-Type", "application/json;charset=UTF-8") .header("Authorization", String.valueOf(redisUtils.get("wms_token"))) - .body(JSON.toJSONString(data)) + .body(JSON.toJSONString(map)) .execute(); log.info("反馈wms任务状态成功,请求路径:{},请求参数:{}", wmsurl + methods_url, JSON.toJSONString(data)); } catch (Exception e) { @@ -548,13 +549,19 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { public HttpResponse feedAgvTaskStatus(JSONArray from) { if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { log.info("开始反馈WMS AGV取放货状态,请求参数:{}", from); + if (redisUtils.getExpire("wms_token") == -1) { + this.getTokenFromWms(); + } String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); AddressDto addressDto = addressService.findByCode("feedAgvTaskStatus"); String methods_url = addressDto.getMethods_url(); String url = wmsUrl + methods_url; HttpResponse result = null; + Map map = new HashMap<>(); + map.put("payload", JSON.toJSONString(from)); try { result = HttpRequest.post(url) + .header("Content-Type", "application/json;charset=UTF-8") .header("Authorization", String.valueOf(redisUtils.get("wms_token"))) .body(JSON.toJSONString(from)) .execute(); @@ -569,7 +576,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { @Override public HttpResponse test(JSONObject form) { - if (!redisUtils.hasKey("wms_token")) { + if (redisUtils.getExpire("wms_token") == -1) { this.getTokenFromWms(); } String url = "https://zoneda.onestep-cloud.com/lwmss/v1/41/chsv-unqualified-products/execute-inspection-ng";