fix 请求wcs是否允许取货
This commit is contained in:
@@ -31,7 +31,7 @@ public interface AcsConfig {
|
|||||||
//WMS系统接口地址
|
//WMS系统接口地址
|
||||||
String WMSURL = "wmsurl";
|
String WMSURL = "wmsurl";
|
||||||
//WCS系统接口地址
|
//WCS系统接口地址
|
||||||
String WCSURL = "wcsurl";
|
String WCSURL = "liKu_wcs_url";
|
||||||
|
|
||||||
String HASOTHERSYSTEM = "hasOtherSystem";
|
String HASOTHERSYSTEM = "hasOtherSystem";
|
||||||
|
|
||||||
|
|||||||
@@ -172,8 +172,27 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
|||||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||||
StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||||
|
|
||||||
if ("true".equals(device.getExtraValue().get("wait"))) {
|
if ("true".equals(device.getExtraValue().get("wait"))
|
||||||
// todo 请求wcs是否允许取货
|
&& !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 {
|
} else {
|
||||||
wcsFlag = true;
|
wcsFlag = true;
|
||||||
}
|
}
|
||||||
@@ -350,8 +369,27 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
|||||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||||
StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||||
|
|
||||||
if ("true".equals(device.getExtraValue().get("wait"))) {
|
if ("true".equals(device.getExtraValue().get("wait"))
|
||||||
// todo 请求wcs是否允许取货
|
&& !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 {
|
} else {
|
||||||
wcsFlag = true;
|
wcsFlag = true;
|
||||||
}
|
}
|
||||||
@@ -525,8 +563,27 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
|||||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||||
StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||||
|
|
||||||
if ("true".equals(device.getExtraValue().get("wait"))) {
|
if ("true".equals(device.getExtraValue().get("wait"))
|
||||||
// todo 请求wcs是否允许取货
|
&& !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 {
|
} else {
|
||||||
wcsFlag = true;
|
wcsFlag = true;
|
||||||
}
|
}
|
||||||
@@ -692,8 +749,27 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
|||||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||||
StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||||
|
|
||||||
if ("true".equals(device.getExtraValue().get("wait"))) {
|
if ("true".equals(device.getExtraValue().get("wait"))
|
||||||
// todo 请求wcs是否允许取货
|
&& !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 {
|
} else {
|
||||||
wcsFlag = true;
|
wcsFlag = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,6 +114,13 @@ public interface AcsToWmsService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
JSONObject feedAgvTaskStatus(JSONArray from);
|
JSONObject feedAgvTaskStatus(JSONArray from);
|
||||||
|
/**
|
||||||
|
* 反馈WCSAGV取放货状态
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
JSONObject feedWcsAgvTaskStatus(JSONArray from);
|
||||||
|
|
||||||
JSONObject test(JSONObject form);
|
JSONObject test(JSONObject form);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,21 +107,21 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
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<String, Object> map = new HashMap<>();
|
||||||
map.put("payload", JSON.toJSONString(data));
|
// 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")))
|
.header("Authorization", String.valueOf(redisUtils.get("wms_token")))
|
||||||
.body(JSON.toJSONString(map))
|
.body(JSON.toJSONString(data))
|
||||||
.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(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
retryableUtil.retryable(url, JSON.toJSONString(map));
|
retryableUtil.retryable(url, JSON.toJSONString(data));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -563,12 +563,45 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
AddressDto addressDto = addressService.findByCode("feedAgvTaskStatus");
|
AddressDto addressDto = addressService.findByCode("feedAgvTaskStatus");
|
||||||
String methodsUrl = addressDto.getMethods_url();
|
String methodsUrl = addressDto.getMethods_url();
|
||||||
String url = wmsUrl + methodsUrl;
|
String url = wmsUrl + methodsUrl;
|
||||||
// log.info("feedAgvTaskStatus - 请求参数 {}", param);
|
log.info("feedAgvTaskStatus - 请求参数 {}", from);
|
||||||
HttpResponse response = HttpRequest
|
HttpResponse response = HttpRequest
|
||||||
.post(url)
|
.post(url)
|
||||||
.body(from.toString())
|
.body(from.toString())
|
||||||
.execute();
|
.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());
|
return JSONObject.parseObject(response.body());
|
||||||
}
|
}
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
|
|||||||
Reference in New Issue
Block a user