|
@ -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); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|