|
|
@ -2,20 +2,26 @@ package org.nl.acs.device_driver.basedriver.agv.ndcone; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.http.HttpStatus; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.EqualsAndHashCode; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.nl.acs.AcsConfig; |
|
|
|
import org.nl.acs.agv.server.NDCAgvService; |
|
|
|
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun; |
|
|
|
import org.nl.acs.device.service.DeviceService; |
|
|
|
import org.nl.acs.device_driver.DeviceDriver; |
|
|
|
import org.nl.acs.device_driver.basedriver.agv.utils.ErrorUtil; |
|
|
|
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutoDoorDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.driver.AbstractDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.fold_disc_site.FoldDiscSiteDeviceDriver; |
|
|
|
import org.nl.acs.ext.wms.service.AcsToWmsService; |
|
|
|
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; |
|
|
|
import org.nl.acs.instruction.service.InstructionService; |
|
|
@ -73,6 +79,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
|
|
|
|
String error_code = "0"; |
|
|
|
String error_message = ""; |
|
|
|
String device_status = "UNKNOWN"; |
|
|
|
String message = ""; |
|
|
|
|
|
|
|
public synchronized void processSocket(int[] arr) { |
|
|
|
device_code = this.getDeviceCode(); |
|
|
@ -89,6 +97,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
Instruction link_inst = null; |
|
|
|
List<Instruction> insts = null; |
|
|
|
Instruction inst = null; |
|
|
|
boolean flag = false; |
|
|
|
boolean wcsFlag = false; |
|
|
|
boolean wmsFlag = false; |
|
|
|
boolean link_flag = false; |
|
|
|
if (ikey != 0) { |
|
|
|
inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); |
|
|
@ -111,6 +122,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
inst.setCarno(String.valueOf(carno)); |
|
|
|
instructionService.update(inst); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + "反馈:" + data); |
|
|
|
this.device_status = "EXECUTING"; |
|
|
|
|
|
|
|
//到达取货点
|
|
|
|
//(需要WCS反馈)
|
|
|
@ -149,6 +161,148 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
|
|
if ("true".equals(device.getExtraValue().get("wait"))) { |
|
|
|
// todo 请求wcs是否允许取货
|
|
|
|
} else { |
|
|
|
wcsFlag = true; |
|
|
|
} |
|
|
|
|
|
|
|
if ("true".equals(device.getExtraValue().get("reqWms")) |
|
|
|
&& !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.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
|
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
wmsFlag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "不允许AGV取货。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
wmsFlag = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (wcsFlag && wmsFlag) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许AGV取货。"); |
|
|
|
} |
|
|
|
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
StandardInspectSiteDeviceDriver driver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
|
|
if (driver.getMode() != 0 |
|
|
|
&& driver.getMove() != 0) { |
|
|
|
if (!inst.getTask_code().startsWith("-") |
|
|
|
&& "1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue()) |
|
|
|
&& "true".equals(device.getExtraValue().get("reqWms"))) { |
|
|
|
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.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
|
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
flag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "不允许AGV取货。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
String message = ""; |
|
|
|
if (driver.getMode() == 0) { |
|
|
|
message += "站点未联机,"; |
|
|
|
} else { |
|
|
|
if (driver.getMove() == 0) { |
|
|
|
message += "站点无货,"; |
|
|
|
} |
|
|
|
} |
|
|
|
message += "不允许AGV取货。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
|
|
|
|
if (flag) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许AGV取货。"); |
|
|
|
} |
|
|
|
} else if (device.getDeviceDriver() instanceof FoldDiscSiteDeviceDriver) { |
|
|
|
FoldDiscSiteDeviceDriver driver = (FoldDiscSiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
if (driver.getMode() != 0 |
|
|
|
&& driver.getMove() != 0 |
|
|
|
&& driver.getNumber() != 0) { |
|
|
|
if (!inst.getTask_code().startsWith("-") |
|
|
|
&& "1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue()) |
|
|
|
&& "true".equals(device.getExtraValue().get("reqWms"))) { |
|
|
|
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.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
flag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "不允许AGV取货。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
String message = ""; |
|
|
|
if (driver.getMode() == 0) { |
|
|
|
message += "站点未联机,"; |
|
|
|
} else { |
|
|
|
if (driver.getMove() == 0) { |
|
|
|
message += "站点无货,"; |
|
|
|
} |
|
|
|
if (driver.getNumber() == 0) { |
|
|
|
message += "站点无托盘,"; |
|
|
|
} |
|
|
|
} |
|
|
|
message += "不允许AGV取货。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
|
|
|
|
if (flag) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许AGV取货。"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//取货完毕
|
|
|
|
//(需要WCS反馈)
|
|
|
|
} else if (phase == 0x05) { |
|
|
@ -185,6 +339,148 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
|
|
if ("true".equals(device.getExtraValue().get("wait"))) { |
|
|
|
// todo 请求wcs是否允许取货
|
|
|
|
} else { |
|
|
|
wcsFlag = true; |
|
|
|
} |
|
|
|
|
|
|
|
if ("true".equals(device.getExtraValue().get("reqWms")) |
|
|
|
&& !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.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
|
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
wmsFlag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "不允许AGV取货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
wmsFlag = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (wcsFlag && wmsFlag) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许AGV取货后离开。"); |
|
|
|
} |
|
|
|
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
StandardInspectSiteDeviceDriver driver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
|
|
if (driver.getMode() != 0 |
|
|
|
&& driver.getMove() == 0) { |
|
|
|
if (!inst.getTask_code().startsWith("-") |
|
|
|
&& "1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue()) |
|
|
|
&& "true".equals(device.getExtraValue().get("reqWms"))) { |
|
|
|
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.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
|
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
flag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "不允许AGV取货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
String message = ""; |
|
|
|
if (driver.getMode() == 0) { |
|
|
|
message += "站点未联机,"; |
|
|
|
} else { |
|
|
|
if (driver.getMove() != 0) { |
|
|
|
message += "站点有货,"; |
|
|
|
} |
|
|
|
} |
|
|
|
message += "不允许AGV取货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
|
|
|
|
if (flag) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许AGV取货后离开。"); |
|
|
|
} |
|
|
|
} else if (device.getDeviceDriver() instanceof FoldDiscSiteDeviceDriver) { |
|
|
|
FoldDiscSiteDeviceDriver driver = (FoldDiscSiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
if (driver.getMode() != 0 |
|
|
|
&& driver.getMove() == 0 |
|
|
|
&& driver.getNumber() == 0) { |
|
|
|
if (!inst.getTask_code().startsWith("-") |
|
|
|
&& "1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue()) |
|
|
|
&& "true".equals(device.getExtraValue().get("reqWms"))) { |
|
|
|
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.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
flag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "不允许AGV取货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
String message = ""; |
|
|
|
if (driver.getMode() == 0) { |
|
|
|
message += "站点未联机,"; |
|
|
|
} else { |
|
|
|
if (driver.getMove() != 0) { |
|
|
|
message += "站点有货,"; |
|
|
|
} |
|
|
|
if (driver.getNumber() != 0) { |
|
|
|
message += "站点有托盘,"; |
|
|
|
} |
|
|
|
} |
|
|
|
message += "不允许AGV取货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
|
|
|
|
if (flag) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许AGV取货后离开。"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//到达放货点
|
|
|
|
//(需要WCS反馈)
|
|
|
|
} else if (phase == 0x07) { |
|
|
@ -218,6 +514,139 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
|
|
if ("true".equals(device.getExtraValue().get("wait"))) { |
|
|
|
// todo 请求wcs是否允许取货
|
|
|
|
} else { |
|
|
|
wcsFlag = true; |
|
|
|
} |
|
|
|
|
|
|
|
if ("true".equals(device.getExtraValue().get("reqWms")) |
|
|
|
&& !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.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
|
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
wmsFlag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "不允许AGV放货。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
wmsFlag = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (wcsFlag && wmsFlag) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许AGV放货。"); |
|
|
|
} |
|
|
|
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
StandardInspectSiteDeviceDriver driver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
|
|
if (driver.getMode() != 0 |
|
|
|
&& driver.getMove() == 0) { |
|
|
|
if (!inst.getTask_code().startsWith("-") |
|
|
|
&& "1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue()) |
|
|
|
&& "true".equals(device.getExtraValue().get("reqWms"))) { |
|
|
|
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.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
|
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
flag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "不允许AGV放货。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
String message = ""; |
|
|
|
if (driver.getMode() == 0) { |
|
|
|
message += "站点未联机,"; |
|
|
|
} else { |
|
|
|
if (driver.getMove() != 0) { |
|
|
|
message += "站点有货,"; |
|
|
|
} |
|
|
|
} |
|
|
|
message += "不允许AGV放货。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
|
|
|
|
if (flag) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许AGV放货。"); |
|
|
|
} |
|
|
|
} else if (device.getDeviceDriver() instanceof FoldDiscSiteDeviceDriver) { |
|
|
|
FoldDiscSiteDeviceDriver driver = (FoldDiscSiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
if (driver.getMode() != 0) { |
|
|
|
if (!inst.getTask_code().startsWith("-") |
|
|
|
&& "1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue()) |
|
|
|
&& "true".equals(device.getExtraValue().get("reqWms"))) { |
|
|
|
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.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
flag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "不允许AGV放货。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
String message = ""; |
|
|
|
if (driver.getMode() == 0) { |
|
|
|
message += "站点未联机,"; |
|
|
|
} |
|
|
|
message += "不允许AGV放货。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
|
|
|
|
if (flag) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许AGV放货。"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//放货完毕
|
|
|
|
//(需要WCS反馈)
|
|
|
|
} else if (phase == 0x09) { |
|
|
@ -252,6 +681,151 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
StandardOrdinarySiteDeviceDriver driver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
|
|
if ("true".equals(device.getExtraValue().get("wait"))) { |
|
|
|
// todo 请求wcs是否允许取货
|
|
|
|
} else { |
|
|
|
wcsFlag = true; |
|
|
|
} |
|
|
|
|
|
|
|
if ("true".equals(device.getExtraValue().get("reqWms")) |
|
|
|
&& !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.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
|
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
wmsFlag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "不允许AGV放货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
wmsFlag = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (wcsFlag && wmsFlag) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许AGV放货后离开。"); |
|
|
|
} |
|
|
|
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
StandardInspectSiteDeviceDriver driver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
|
|
if (driver.getMode() != 0 |
|
|
|
&& driver.getMove() != 0) { |
|
|
|
if (!inst.getTask_code().startsWith("-") |
|
|
|
&& "1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue()) |
|
|
|
&& "true".equals(device.getExtraValue().get("reqWms"))) { |
|
|
|
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.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
|
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
flag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "不允许AGV放货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
String message = ""; |
|
|
|
if (driver.getMode() == 0) { |
|
|
|
message += "站点未联机,"; |
|
|
|
} else { |
|
|
|
if (driver.getMove() == 0) { |
|
|
|
message += "站点无货,"; |
|
|
|
} |
|
|
|
} |
|
|
|
message += "不允许AGV放货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
|
|
|
|
if (flag) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许AGV放货后离开。"); |
|
|
|
} |
|
|
|
} else if (device.getDeviceDriver() instanceof FoldDiscSiteDeviceDriver) { |
|
|
|
FoldDiscSiteDeviceDriver driver = (FoldDiscSiteDeviceDriver) device.getDeviceDriver(); |
|
|
|
if (driver.getMode() != 0 |
|
|
|
&& driver.getMove() != 0 |
|
|
|
&& driver.getNumber() != 0) { |
|
|
|
if (!inst.getTask_code().startsWith("-") |
|
|
|
&& "1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue()) |
|
|
|
&& "true".equals(device.getExtraValue().get("reqWms"))) { |
|
|
|
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.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
flag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "不允许AGV放货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
String message = ""; |
|
|
|
if (driver.getMode() == 0) { |
|
|
|
message += "站点未联机,"; |
|
|
|
} else { |
|
|
|
if (driver.getMove() == 0) { |
|
|
|
message += "站点无货,"; |
|
|
|
} |
|
|
|
if (driver.getNumber() == 0) { |
|
|
|
message += "站点无托盘,"; |
|
|
|
} |
|
|
|
} |
|
|
|
message += "不允许AGV放货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
|
|
|
|
if (flag) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许AGV放货后离开。"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (flag) { |
|
|
|
this.device_status = "IDLE"; |
|
|
|
} |
|
|
|
} |
|
|
|
//到达位置点
|
|
|
|
//(需要WCS反馈)
|
|
|
@ -262,19 +836,155 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); |
|
|
|
} else if (phase == 0x50) {//进入区域
|
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); |
|
|
|
if (agvaddr == 0) { |
|
|
|
agvaddr = agvaddr_copy; |
|
|
|
} |
|
|
|
if (agvaddr < 1) { |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (agvaddr != 0) { |
|
|
|
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); |
|
|
|
if (StrUtil.contains(old_device_code, "-")) { |
|
|
|
String[] point = old_device_code.split("-"); |
|
|
|
device_code = point[0]; |
|
|
|
} else if (StrUtil.contains(old_device_code, ".")) { |
|
|
|
String[] point = old_device_code.split("\\."); |
|
|
|
device_code = point[0]; |
|
|
|
} else { |
|
|
|
device_code = old_device_code; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
device = deviceAppService.findDeviceByCode(device_code); |
|
|
|
if (ObjectUtil.isEmpty(device_code)) { |
|
|
|
log.info(agvaddr + "对应设备号为空!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardAutoDoorDeviceDriver) { |
|
|
|
StandardAutoDoorDeviceDriver driver = (StandardAutoDoorDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
|
|
if (driver.getMode() != 0) { |
|
|
|
if ("1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue()) |
|
|
|
&& "true".equals(device.getExtraValue().get("reqWms"))) { |
|
|
|
JSONObject form = new JSONObject(); |
|
|
|
form.put("vehicle_code", inst.getVehicle_code()); |
|
|
|
form.put("status", 5); |
|
|
|
form.put("device_code", device_code); |
|
|
|
form.put("task_code", inst.getTask_code()); |
|
|
|
JSONObject result = acsToWmsService.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
flag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "无法开门。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
String message = "自动门未联机,无法开门。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
|
|
|
|
if (flag) { |
|
|
|
driver.writing(1); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许开门。"); |
|
|
|
} |
|
|
|
|
|
|
|
if (driver.getAction() == 1) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (phase == 0x51) {//离开区域
|
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); |
|
|
|
if (agvaddr == 0) { |
|
|
|
agvaddr = agvaddr_copy; |
|
|
|
} |
|
|
|
if (agvaddr < 1) { |
|
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (agvaddr != 0) { |
|
|
|
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); |
|
|
|
if (StrUtil.contains(old_device_code, "-")) { |
|
|
|
String[] point = old_device_code.split("-"); |
|
|
|
device_code = point[0]; |
|
|
|
} else if (StrUtil.contains(old_device_code, ".")) { |
|
|
|
String[] point = old_device_code.split("\\."); |
|
|
|
device_code = point[0]; |
|
|
|
} else { |
|
|
|
device_code = old_device_code; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
device = deviceAppService.findDeviceByCode(device_code); |
|
|
|
if (ObjectUtil.isEmpty(device_code)) { |
|
|
|
log.info(agvaddr + "对应设备号为空!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardAutoDoorDeviceDriver) { |
|
|
|
StandardAutoDoorDeviceDriver driver = (StandardAutoDoorDeviceDriver) device.getDeviceDriver(); |
|
|
|
|
|
|
|
if (driver.getMode() != 0) { |
|
|
|
if ("1".equals(paramService.findByCode(AcsConfig.HASWMS).getValue()) |
|
|
|
&& "true".equals(device.getExtraValue().get("reqWms"))) { |
|
|
|
JSONObject form = new JSONObject(); |
|
|
|
form.put("vehicle_code", inst.getVehicle_code()); |
|
|
|
form.put("status", 6); |
|
|
|
form.put("device_code", device_code); |
|
|
|
form.put("task_code", inst.getTask_code()); |
|
|
|
JSONObject result = acsToWmsService.feedAgvTaskStatus(new JSONArray() {{ |
|
|
|
add(form); |
|
|
|
}}); |
|
|
|
if (HttpStatus.HTTP_OK == result.getIntValue("status")) { |
|
|
|
flag = true; |
|
|
|
} else { |
|
|
|
String resultMessage = result.getString("message"); |
|
|
|
this.message = resultMessage; |
|
|
|
String message = resultMessage + "无法关门。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
String message = "自动门未联机,无法关门。"; |
|
|
|
driver.setMessage(message); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", message); |
|
|
|
} |
|
|
|
|
|
|
|
if (flag) { |
|
|
|
driver.writing(2); |
|
|
|
this.message = ""; |
|
|
|
driver.setMessage(""); |
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "允许关门。"); |
|
|
|
} |
|
|
|
|
|
|
|
if (driver.getAction() == 2) { |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (phase == 0x67) {//agv异常
|
|
|
|
if (ikey == 0) { |
|
|
|
this.setErrorInfo(ikey, "0", "正常"); |
|
|
|
this.device_status = "IDLE"; |
|
|
|
} else { |
|
|
|
Map<String, String> error = ErrorUtil.getAgvErrorMsg(ikey); |
|
|
|
String code = error.get("code"); |
|
|
|
String info = error.get("info"); |
|
|
|
this.setErrorInfo(ikey, code, info); |
|
|
|
this.device_status = "ERROR"; |
|
|
|
} |
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
last_error = error; |
|
|
|