rev
This commit is contained in:
@@ -11,14 +11,12 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zhangjiangwei
|
* @author zhangjiangwei
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/agv/xg")
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Api(tags = "仙工AGV")
|
@Api(tags = "仙工AGV")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.sf.json.JSONObject;
|
|||||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsZDServiceImpl;
|
import org.nl.acs.ext.wms.service.impl.AcsToWmsZDServiceImpl;
|
||||||
import org.nl.acs.instruction.service.InstructionService;
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
|
import org.nl.acs.instruction.service.dto.Instruction;
|
||||||
import org.nl.acs.log.service.LogServer;
|
import org.nl.acs.log.service.LogServer;
|
||||||
import org.nl.acs.opc.DeviceAppService;
|
import org.nl.acs.opc.DeviceAppService;
|
||||||
import org.nl.exception.BadRequestException;
|
import org.nl.exception.BadRequestException;
|
||||||
@@ -30,12 +31,10 @@ public class AgvWaitUtil {
|
|||||||
LogServer logServer;
|
LogServer logServer;
|
||||||
|
|
||||||
//取货前等待
|
//取货前等待
|
||||||
public JSONObject waitInGet(String startDeviceCode) {
|
public JSONObject waitInGet(String startDeviceCode, Instruction inst) {
|
||||||
log.info("仙工AGV请求取货,设备号 - {}", startDeviceCode);
|
log.info("仙工AGV请求取货,设备号 - {}", startDeviceCode);
|
||||||
|
|
||||||
JSONObject requestWMSParam = new JSONObject();
|
JSONObject responseBody = acsToWmsService.gccQueryStationState(inst);
|
||||||
requestWMSParam.put("StartStationCode", startDeviceCode);
|
|
||||||
JSONObject responseBody = acsToWmsService.gccQueryStationState(requestWMSParam);
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
||||||
JSONArray data = responseBody.optJSONArray("data");
|
JSONArray data = responseBody.optJSONArray("data");
|
||||||
@@ -56,12 +55,10 @@ public class AgvWaitUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//取货完成等待
|
//取货完成等待
|
||||||
public JSONObject waitOutGet(String startDeviceCode) {
|
public JSONObject waitOutGet(String startDeviceCode, Instruction inst) {
|
||||||
log.info("仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
log.info("仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
||||||
|
|
||||||
JSONObject requestWMSParam = new JSONObject();
|
JSONObject responseBody = acsToWmsService.gccQueryStationState(inst);
|
||||||
requestWMSParam.put("StartStationCode", startDeviceCode);
|
|
||||||
JSONObject responseBody = acsToWmsService.gccQueryStationState(requestWMSParam);
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
||||||
JSONArray data = responseBody.optJSONArray("data");
|
JSONArray data = responseBody.optJSONArray("data");
|
||||||
@@ -82,12 +79,10 @@ public class AgvWaitUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//放货前等待
|
//放货前等待
|
||||||
public JSONObject waitInPut(String endDeviceCode) {
|
public JSONObject waitInPut(String endDeviceCode, Instruction inst) {
|
||||||
log.info("仙工AGV请求放货,设备号 - {}", endDeviceCode);
|
log.info("仙工AGV请求放货,设备号 - {}", endDeviceCode);
|
||||||
|
|
||||||
JSONObject requestWMSParam = new JSONObject();
|
JSONObject responseBody = acsToWmsService.gccQueryStationState(inst);
|
||||||
requestWMSParam.put("EndStationCode", endDeviceCode);
|
|
||||||
JSONObject responseBody = acsToWmsService.gccQueryStationState(requestWMSParam);
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
||||||
JSONArray data = responseBody.optJSONArray("data");
|
JSONArray data = responseBody.optJSONArray("data");
|
||||||
@@ -109,12 +104,10 @@ public class AgvWaitUtil {
|
|||||||
|
|
||||||
|
|
||||||
//放货完成等待
|
//放货完成等待
|
||||||
public JSONObject waitOutPut(String endDeviceCode) {
|
public JSONObject waitOutPut(String endDeviceCode, Instruction inst) {
|
||||||
log.info("仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
|
log.info("仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
|
||||||
|
|
||||||
JSONObject requestWMSParam = new JSONObject();
|
JSONObject responseBody = acsToWmsService.gccQueryStationState(inst);
|
||||||
requestWMSParam.put("EndStationCode", endDeviceCode);
|
|
||||||
JSONObject responseBody = acsToWmsService.gccQueryStationState(requestWMSParam);
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) {
|
||||||
JSONArray data = responseBody.optJSONArray("data");
|
JSONArray data = responseBody.optJSONArray("data");
|
||||||
|
|||||||
@@ -2020,9 +2020,15 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject xgAGVControlDoorSwitch(JSONObject requestParam) {
|
public JSONObject xgAGVControlDoorSwitch(JSONObject requestParam) {
|
||||||
|
log.info("仙工AGV控制门开关,请求参数 - {}", requestParam);
|
||||||
try {
|
try {
|
||||||
|
String doorName = requestParam.optString("doorName");
|
||||||
|
if (doorName.startsWith("D")) {
|
||||||
|
doorName = doorName.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
JSONObject requestWMSParam = new JSONObject();
|
JSONObject requestWMSParam = new JSONObject();
|
||||||
requestWMSParam.put("device_code", requestParam.optString("doorName"));
|
requestWMSParam.put("device_code", doorName);
|
||||||
requestWMSParam.put("device_status", "1".equals(requestParam.optString("state")) ? "open" : "close");
|
requestWMSParam.put("device_status", "1".equals(requestParam.optString("state")) ? "open" : "close");
|
||||||
JSONObject wmsResult = acsToWmsService.gccControlDoorSwitch(requestWMSParam);
|
JSONObject wmsResult = acsToWmsService.gccControlDoorSwitch(requestWMSParam);
|
||||||
|
|
||||||
@@ -2034,8 +2040,10 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
result.put("result", -1);
|
result.put("result", -1);
|
||||||
result.put("message", wmsResult.optString("message"));
|
result.put("message", wmsResult.optString("message"));
|
||||||
}
|
}
|
||||||
|
log.info("仙工AGV控制门开关,响应参数 - {}", result);
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error("仙工AGV控制门开关错误!", e);
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("result", -1);
|
result.put("result", -1);
|
||||||
result.put("message", e.getMessage());
|
result.put("message", e.getMessage());
|
||||||
@@ -2045,6 +2053,7 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject xgAGVQueryDoorStatus(JSONObject requestParam) {
|
public JSONObject xgAGVQueryDoorStatus(JSONObject requestParam) {
|
||||||
|
log.info("仙工AGV查询门状态,请求参数 - {}", requestParam);
|
||||||
String[] doorNameList = requestParam.optJSONArray("doorNameList").optString(0).split(",");
|
String[] doorNameList = requestParam.optJSONArray("doorNameList").optString(0).split(",");
|
||||||
|
|
||||||
if (doorNameList.length == 1 && StrUtil.isBlank(doorNameList[0])) {
|
if (doorNameList.length == 1 && StrUtil.isBlank(doorNameList[0])) {
|
||||||
@@ -2055,49 +2064,36 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
com.alibaba.fastjson.JSONArray wmsResult = acsToWmsService.gccQueryDoorStatus();
|
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(wmsResult)) {
|
|
||||||
JSONObject result = new JSONObject();
|
|
||||||
result.put("result", 0);
|
|
||||||
result.put("message", "操作成功");
|
|
||||||
result.put("data", Arrays.stream(doorNameList)
|
|
||||||
.map(doorName -> {
|
|
||||||
JSONObject door = new JSONObject();
|
|
||||||
door.put("doorName", doorName);
|
|
||||||
door.put("state", -1);
|
|
||||||
door.put("timestamp", System.currentTimeMillis());
|
|
||||||
return door;
|
|
||||||
}).collect(Collectors.toList()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<JSONObject> data = Arrays.stream(doorNameList).map(doorName -> {
|
|
||||||
JSONObject door = new JSONObject();
|
|
||||||
door.put("doorName", doorName);
|
|
||||||
List<Object> list = wmsResult.stream().filter(o -> doorName.equals(((com.alibaba.fastjson.JSONObject) o).getString("device_code"))).collect(Collectors.toList());
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
door.put("state", -1);
|
|
||||||
} else {
|
|
||||||
com.alibaba.fastjson.JSONObject row = (com.alibaba.fastjson.JSONObject) list.get(0);
|
|
||||||
int state = 1;
|
|
||||||
if ("close".equals(row.getString("device_status"))) {
|
|
||||||
state = 0;
|
|
||||||
} else if ("open".equals(row.getString("device_status"))) {
|
|
||||||
state = 2;
|
|
||||||
}
|
|
||||||
door.put("state", state);
|
|
||||||
}
|
|
||||||
door.put("timestamp", System.currentTimeMillis());
|
|
||||||
return door;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
|
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("result", 0);
|
result.put("result", 0);
|
||||||
result.put("message", "操作成功");
|
result.put("message", "操作成功");
|
||||||
|
|
||||||
|
JSONArray data = new JSONArray();
|
||||||
|
JSONObject datum = new JSONObject();
|
||||||
|
for (String doorName : doorNameList) {
|
||||||
|
String requestWMSDeviceCode = doorName;
|
||||||
|
if (doorName.startsWith("D")) {
|
||||||
|
requestWMSDeviceCode = doorName.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject responseBody = acsToWmsService.gccQueryDoorStatus(requestWMSDeviceCode);
|
||||||
|
datum.put("doorName", doorName);
|
||||||
|
String deviceStatus = responseBody.optString("device_status");
|
||||||
|
if ("open".equals(deviceStatus)) {
|
||||||
|
datum.put("state", 2);
|
||||||
|
} else if ("close".equals(deviceStatus)) {
|
||||||
|
datum.put("state", 0);
|
||||||
|
} else {
|
||||||
|
datum.put("state", -1);
|
||||||
|
}
|
||||||
|
data.add(datum);
|
||||||
|
}
|
||||||
result.put("data", data);
|
result.put("data", data);
|
||||||
|
|
||||||
|
log.info("仙工AGV查询门状态,响应参数 - {}", result);
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error("仙工AGV查询们状态错误!", e);
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("result", 0);
|
result.put("result", 0);
|
||||||
result.put("message", e.getMessage());
|
result.put("message", e.getMessage());
|
||||||
@@ -2230,9 +2226,9 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (address.contains("GET")) {
|
if (address.contains("GET")) {
|
||||||
return agvWaitUtil.waitInGet(deviceCodeNow);
|
return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
|
||||||
} else if (address.contains("PUT")) {
|
} else if (address.contains("PUT")) {
|
||||||
return agvWaitUtil.waitInPut(deviceCodeNow);
|
return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (address.contains("OUT")) {
|
if (address.contains("OUT")) {
|
||||||
@@ -2242,9 +2238,9 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (address.contains("GET")) {
|
if (address.contains("GET")) {
|
||||||
return agvWaitUtil.waitOutGet(deviceCodeNow);
|
return agvWaitUtil.waitOutGet(deviceCodeNow, instructionDto);
|
||||||
} else if (address.contains("PUT")) {
|
} else if (address.contains("PUT")) {
|
||||||
return agvWaitUtil.waitOutPut(deviceCodeNow);
|
return agvWaitUtil.waitOutPut(deviceCodeNow, instructionDto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.nl.acs.ext.wms.service;
|
|||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
import net.sf.json.JSONArray;
|
import net.sf.json.JSONArray;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
|
import org.nl.acs.instruction.service.dto.Instruction;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -127,6 +128,7 @@ public interface AcsToWmsService {
|
|||||||
/**
|
/**
|
||||||
* 六维广钞厂查询自动门状态
|
* 六维广钞厂查询自动门状态
|
||||||
*
|
*
|
||||||
|
* @param deviceCode 自动门编码(不带首字母D)
|
||||||
* @return 示例:[
|
* @return 示例:[
|
||||||
* {
|
* {
|
||||||
* "device_code":"AD1",
|
* "device_code":"AD1",
|
||||||
@@ -138,14 +140,11 @@ public interface AcsToWmsService {
|
|||||||
* }
|
* }
|
||||||
* ]
|
* ]
|
||||||
*/
|
*/
|
||||||
com.alibaba.fastjson.JSONArray gccQueryDoorStatus();
|
JSONObject gccQueryDoorStatus(String deviceCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 六维广钞厂查询站点有无货状态
|
* 六维广钞厂查询站点有无货状态
|
||||||
* @param requestWMSParam 示例:{
|
* @param inst 指令对象
|
||||||
* "StartStationCode":"111",
|
|
||||||
* "EndStationCode":"222"
|
|
||||||
* }
|
|
||||||
* @return 示例:{
|
* @return 示例:{
|
||||||
* "errArr":null,
|
* "errArr":null,
|
||||||
* "data":[{"Station_Code":"1170","IsHasGoods":true},{"Station_Code":"1030","IsHasGoods":true}],
|
* "data":[{"Station_Code":"1170","IsHasGoods":true},{"Station_Code":"1030","IsHasGoods":true}],
|
||||||
@@ -153,5 +152,5 @@ public interface AcsToWmsService {
|
|||||||
* "message":"获取站点相关信息成功"
|
* "message":"获取站点相关信息成功"
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
JSONObject gccQueryStationState(JSONObject requestWMSParam);
|
JSONObject gccQueryStationState(Instruction inst);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.json.JSONArray;
|
import net.sf.json.JSONArray;
|
||||||
@@ -14,6 +15,7 @@ import org.nl.acs.device.address.service.AddressService;
|
|||||||
import org.nl.acs.device.address.service.dto.AddressDto;
|
import org.nl.acs.device.address.service.dto.AddressDto;
|
||||||
import org.nl.acs.device.service.DeviceService;
|
import org.nl.acs.device.service.DeviceService;
|
||||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||||
|
import org.nl.acs.instruction.service.dto.Instruction;
|
||||||
import org.nl.acs.log.service.LogServer;
|
import org.nl.acs.log.service.LogServer;
|
||||||
import org.nl.acs.task.service.TaskService;
|
import org.nl.acs.task.service.TaskService;
|
||||||
import org.nl.acs.task.service.dto.TaskDto;
|
import org.nl.acs.task.service.dto.TaskDto;
|
||||||
@@ -25,6 +27,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -542,34 +545,35 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public com.alibaba.fastjson.JSONArray gccQueryDoorStatus() {
|
public JSONObject gccQueryDoorStatus(String deviceCode) {
|
||||||
try {
|
try {
|
||||||
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
|
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
|
||||||
AddressDto addressDto = addressService.findByCode("gccQueryDoorStatus");
|
AddressDto addressDto = addressService.findByCode("gccQueryDoorStatus");
|
||||||
|
String uri = wmsurl + addressDto.getMethods_url() + "?deviceCode=" + deviceCode;
|
||||||
|
|
||||||
log.info("gccQueryDoorStatus - 请求");
|
log.info("gccQueryDoorStatus - 请求路径{}", uri);
|
||||||
String responseBody = HttpRequest
|
String responseBody = HttpRequest
|
||||||
.get(wmsurl + addressDto.getMethods_url())
|
.get(uri)
|
||||||
.execute()
|
.execute()
|
||||||
.body();
|
.body();
|
||||||
log.info("gccControlDoorSwitch - 响应参数{}", responseBody);
|
log.info("gccQueryDoorStatus - 响应参数{}", responseBody);
|
||||||
|
|
||||||
return com.alibaba.fastjson.JSONArray.parseArray(responseBody);
|
return JSONObject.fromObject(responseBody);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return new com.alibaba.fastjson.JSONArray();
|
return new JSONObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject gccQueryStationState(JSONObject requestWMSParam) {
|
public JSONObject gccQueryStationState(Instruction inst) {
|
||||||
try {
|
try {
|
||||||
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
|
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
|
||||||
AddressDto addressDto = addressService.findByCode("gccQueryStationState");
|
AddressDto addressDto = addressService.findByCode("gccQueryStationState");
|
||||||
|
String uri = wmsurl + addressDto.getMethods_url() + "?StartStationCode=" + inst.getStart_point_code() + "&EndStationCode=" + inst.getNext_point_code();
|
||||||
|
|
||||||
log.info("gccQueryStationState - 请求参数{}", requestWMSParam);
|
log.info("gccQueryStationState - 请求路径{}", uri);
|
||||||
String responseBody = HttpRequest
|
String responseBody = HttpRequest
|
||||||
.post(wmsurl + addressDto.getMethods_url())
|
.get(uri)
|
||||||
.body(requestWMSParam.toString())
|
|
||||||
.execute()
|
.execute()
|
||||||
.body();
|
.body();
|
||||||
log.info("gccQueryStationState - 响应参数{}", responseBody);
|
log.info("gccQueryStationState - 响应参数{}", responseBody);
|
||||||
|
|||||||
Reference in New Issue
Block a user