Browse Source

rev:wms与acs接口

master
gengby 1 year ago
parent
commit
e3980f3063
  1. 22
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java
  2. 1
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java
  3. 14
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java

22
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java

@ -34,10 +34,7 @@ import org.nl.modules.system.service.ParamService;
import org.nl.modules.system.service.impl.ParamServiceImpl; import org.nl.modules.system.service.impl.ParamServiceImpl;
import org.nl.modules.wql.util.SpringContextHolder; import org.nl.modules.wql.util.SpringContextHolder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString; import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
@ -100,9 +97,6 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
} }
if (ikey != 0) { if (ikey != 0) {
inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
// if (ObjectUtil.isEmpty(inst)) {
// inst = instructionService.findByCode(String.valueOf(ikey));
// }
} }
if (!ObjectUtil.isEmpty(link_inst)) { if (!ObjectUtil.isEmpty(link_inst)) {
link_flag = true; link_flag = true;
@ -121,14 +115,6 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
} }
//普通站点
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
//货架
StandardStorageDeviceDriver standardStorageDeviceDriver;
//
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
//自动门
StandardAutoDoorDeviceDriver standardAutoDoorDeviceDriver;
//分配 车id //分配 车id
//(不需要WCS反馈) //(不需要WCS反馈)
@ -189,7 +175,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
JSONObject resp = JSONObject.parseObject(httpResponse.body()); JSONObject resp = JSONObject.parseObject(httpResponse.body());
if (resp.getJSONObject("payload").getInteger("status") == 200) { if (resp.getInteger("status") == 200) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
log.info("指令号:{},acs请求wms取货申请成功,wms允许agv申请取货,已反馈agv允许取货", inst.getInstruction_code()); log.info("指令号:{},acs请求wms取货申请成功,wms允许agv申请取货,已反馈agv允许取货", inst.getInstruction_code());
} else { } else {
@ -254,7 +240,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
JSONObject resp = JSONObject.parseObject(httpResponse.body()); JSONObject resp = JSONObject.parseObject(httpResponse.body());
if (resp.getJSONObject("payload").getInteger("status") == 200) { if (resp.getInteger("status") == 200) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
log.info("指令号:{},acs反馈wms取货完成离开成功,wms允许agv取货完成离开,已反馈agv取货完成离开", inst.getInstruction_code()); log.info("指令号:{},acs反馈wms取货完成离开成功,wms允许agv取货完成离开,已反馈agv取货完成离开", inst.getInstruction_code());
} else { } else {
@ -316,7 +302,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
JSONObject resp = JSONObject.parseObject(httpResponse.body()); JSONObject resp = JSONObject.parseObject(httpResponse.body());
if (resp.getJSONObject("payload").getInteger("status") == 200) { if (resp.getInteger("status") == 200) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
log.info("指令号:{},acs请求wms放货申请成功,wms允许agv申请放货,已反馈agv允许放货", inst.getInstruction_code()); log.info("指令号:{},acs请求wms放货申请成功,wms允许agv申请放货,已反馈agv允许放货", inst.getInstruction_code());
} else { } else {
@ -379,7 +365,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) { if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
JSONObject resp = JSONObject.parseObject(httpResponse.body()); JSONObject resp = JSONObject.parseObject(httpResponse.body());
if (resp.getJSONObject("payload").getInteger("status") == 200) { if (resp.getInteger("status") == 200) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
log.info("指令号:{},acs请求wms放货完成申请成功,wms允许agv放货完成,已反馈agv放货完成", inst.getInstruction_code()); log.info("指令号:{},acs请求wms放货完成申请成功,wms允许agv放货完成,已反馈agv放货完成", inst.getInstruction_code());
} else { } else {

1
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java

@ -18,7 +18,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Map;
/** /**
* @author ludj * @author ludj

14
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java

@ -100,28 +100,21 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
MDC.put(log_file_type, log_type); MDC.put(log_file_type, log_type);
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
log.info("开始反馈wms任务状态,请求参数:{}", JSON.toJSONString(data)); log.info("开始反馈wms任务状态,请求参数:{}", JSON.toJSONString(data));
this.getTokenFromWms();
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue(); String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
HttpResponse result = null; HttpResponse result = null;
AddressDto addressDto = addressService.findByCode("feedbackTaskStatusToWms"); AddressDto addressDto = addressService.findByCode("feedbackTaskStatusToWms");
String methods_url = addressDto.getMethods_url(); String methods_url = addressDto.getMethods_url();
String url = wmsurl + methods_url; String url = wmsurl + methods_url;
Map<String, Object> map = new HashMap<>();
map.put("payload", JSON.toJSONString(data));
try { try {
result = HttpRequest result = HttpRequest
.post(url) .post(url)
.header("Content-Type", "application/json;charset=UTF-8") .header("Content-Type", "application/json;charset=UTF-8")
.header("Authorization", String.valueOf(redisUtils.get("wms_token"))) .body(JSON.toJSONString(data))
.body(JSON.toJSONString(map))
.timeout(3000) .timeout(3000)
.execute(); .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) { } catch (Exception e) {
log.error("反馈wms任务状态失败,请求路径:{},失败原因:{}", url, e.getMessage()); log.error("反馈wms任务状态失败,请求路径:{},失败原因:{}", url, e.getMessage());
CompletableFuture.runAsync(() -> {
retryableUtil.retryable(url, JSON.toJSONString(map));
});
} }
return result; return result;
} }
@ -559,7 +552,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
public HttpResponse feedAgvTaskStatus(JSONArray from) { public HttpResponse feedAgvTaskStatus(JSONArray from) {
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
log.info("开始反馈WMS AGV取放货状态,请求参数:{}", from); log.info("开始反馈WMS AGV取放货状态,请求参数:{}", from);
this.getTokenFromWms();
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("feedAgvTaskStatus"); AddressDto addressDto = addressService.findByCode("feedAgvTaskStatus");
String methods_url = addressDto.getMethods_url(); String methods_url = addressDto.getMethods_url();
@ -570,7 +562,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try { try {
result = HttpRequest.post(url) result = HttpRequest.post(url)
.header("Content-Type", "application/json;charset=UTF-8") .header("Content-Type", "application/json;charset=UTF-8")
.header("Authorization", String.valueOf(redisUtils.get("wms_token")))
.body(JSON.toJSONString(from)) .body(JSON.toJSONString(from))
.timeout(3000) .timeout(3000)
.execute(); .execute();
@ -585,7 +576,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Override @Override
public JSONObject test(JSONObject form) { public JSONObject test(JSONObject form) {
this.getTokenFromWms();
String url = "https://zoneda.onestep-cloud.com/lwmss/v1/41/chsv-unqualified-products/execute-inspection-ng"; String url = "https://zoneda.onestep-cloud.com/lwmss/v1/41/chsv-unqualified-products/execute-inspection-ng";
JSONObject resp = null; JSONObject resp = null;
try { try {

Loading…
Cancel
Save