|
|
@ -22,6 +22,7 @@ import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceD |
|
|
|
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.standard_manipulator_inspect_site.StandardManipulatorInspectSiteDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.standard_manipulator_stacking_site.StandardManipulatorStackingSiteDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.standard_storage.StandardStorageDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.weighing_site.WeighingSiteDeviceDriver; |
|
|
@ -36,6 +37,7 @@ import org.nl.acs.opc.DeviceAppService; |
|
|
|
import org.nl.acs.opc.DeviceAppServiceImpl; |
|
|
|
import org.nl.acs.opc.DeviceType; |
|
|
|
import org.nl.acs.task.service.TaskService; |
|
|
|
import org.nl.acs.task.service.dto.TaskDto; |
|
|
|
import org.nl.exception.BadRequestException; |
|
|
|
import org.nl.logger.BusinessLogger; |
|
|
|
import org.nl.start.auto.run.NDCSocketConnectionAutoRun; |
|
|
@ -769,193 +771,118 @@ public class AgvServiceImpl implements AgvService { |
|
|
|
|
|
|
|
//1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
|
|
|
@Override |
|
|
|
public synchronized String process(String jobno, String type, String address, String action, String processingVehicle) { |
|
|
|
log.info("查询到AGV请求参数,jobno:{},address:{}", jobno + ",address:" + address + ",type:" + type + ",action:" + action); |
|
|
|
boolean is_feedback = false; |
|
|
|
String str = ""; |
|
|
|
String backaddress = address; |
|
|
|
if (address.indexOf(".") > 0) { |
|
|
|
str = address.substring(address.indexOf("."), address.length()); |
|
|
|
address = address.substring(0, address.indexOf(".")); |
|
|
|
} else if (address.indexOf("-") > 0) { |
|
|
|
address = address.substring(0, address.indexOf("-")); |
|
|
|
} |
|
|
|
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); |
|
|
|
Instruction inst = instructionService.findByCodeFromCache(jobno); |
|
|
|
public synchronized String process(String jobno, String type, String address, String action, String processingVehicle) |
|
|
|
{ |
|
|
|
{ |
|
|
|
log.info("查询到AGV请求参数,jobno:{},address:{}", jobno + ",address:" + address + ",type:" + type + ",action:" + action); |
|
|
|
//释放AGV资源,继续后续动作
|
|
|
|
boolean is_feedback = false; |
|
|
|
String str = ""; |
|
|
|
String backaddress = address; |
|
|
|
if (address.indexOf(".") > 0) { |
|
|
|
str = address.substring(address.indexOf(".") + 1, address.length()); |
|
|
|
address = address.substring(0, address.indexOf(".")); |
|
|
|
} else if (address.indexOf("-") > 0) { |
|
|
|
address = address.substring(0, address.indexOf("-")); |
|
|
|
} |
|
|
|
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); |
|
|
|
TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); |
|
|
|
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); |
|
|
|
|
|
|
|
Instruction inst = instructionService.findByCodeFromCache(jobno); |
|
|
|
TaskDto task = taskService.findByCode(inst.getTask_code()); |
|
|
|
|
|
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
|
Device addressdevice = appService.findDeviceByCode(address); |
|
|
|
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; |
|
|
|
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; |
|
|
|
SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver; |
|
|
|
//请求进入
|
|
|
|
if ("onEntry".equals(type)) { |
|
|
|
|
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver(); |
|
|
|
//请求取货
|
|
|
|
if ("Load".equals(action)) { |
|
|
|
if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() > 0) { |
|
|
|
inst.setExecute_status("1"); |
|
|
|
is_feedback = true; |
|
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
|
Device addressdevice = appService.findDeviceByCode(address); |
|
|
|
|
|
|
|
StandardManipulatorStackingSiteDeviceDriver standardManipulatorStackingSiteDeviceDriver; |
|
|
|
//取货的进入前等待和离开等待
|
|
|
|
if (action.equals("taking")) { |
|
|
|
if ("EntryRequired".equals(type)) { |
|
|
|
//
|
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { |
|
|
|
standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) addressdevice.getDeviceDriver(); |
|
|
|
if(standardManipulatorStackingSiteDeviceDriver.getMove()==1){ |
|
|
|
is_feedback = true; |
|
|
|
} else { |
|
|
|
log.info("设备{} 请求取货,光电信号:{}",addressdevice,standardManipulatorStackingSiteDeviceDriver.getMove()); |
|
|
|
} |
|
|
|
} |
|
|
|
//请求放货
|
|
|
|
} else if ("Unload".equals(action)) { |
|
|
|
if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() == 0) { |
|
|
|
inst.setExecute_status("3"); |
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|
|
|
is_feedback = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (addressdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { |
|
|
|
specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); |
|
|
|
//请求取货
|
|
|
|
if ("Load".equals(action)) { |
|
|
|
if (addressdevice.getHas_goods() > 0) { |
|
|
|
inst.setExecute_status("1"); |
|
|
|
is_feedback = true; |
|
|
|
if ("PauseOnStation".equals(type)) { |
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { |
|
|
|
standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) addressdevice.getDeviceDriver(); |
|
|
|
if(standardManipulatorStackingSiteDeviceDriver.getMove()==0){ |
|
|
|
is_feedback = true; |
|
|
|
} else { |
|
|
|
log.info("设备{} 请求离开,光电信号:{}",addressdevice,standardManipulatorStackingSiteDeviceDriver.getMove()); |
|
|
|
} |
|
|
|
} |
|
|
|
//请求放货
|
|
|
|
} else if ("Unload".equals(action)) { |
|
|
|
if (addressdevice.getHas_goods() == 0) { |
|
|
|
inst.setExecute_status("3"); |
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|
|
|
is_feedback = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); |
|
|
|
//请求取货
|
|
|
|
if ("Load".equals(action)) { |
|
|
|
if (addressdevice.getHas_goods() > 0) { |
|
|
|
inst.setExecute_status("1"); |
|
|
|
is_feedback = true; |
|
|
|
|
|
|
|
//放货的进入前等待和离开等待
|
|
|
|
if (action.equals("puting")) { |
|
|
|
if ("EntryRequired".equals(type)) { |
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { |
|
|
|
standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) addressdevice.getDeviceDriver(); |
|
|
|
if(standardManipulatorStackingSiteDeviceDriver.getMove()==0){ |
|
|
|
is_feedback = true; |
|
|
|
} else { |
|
|
|
log.info("设备{} 请求放货,光电信号:{}",addressdevice,standardManipulatorStackingSiteDeviceDriver.getMove()); |
|
|
|
} |
|
|
|
} |
|
|
|
//请求放货
|
|
|
|
} else if ("Unload".equals(action)) { |
|
|
|
if (addressdevice.getHas_goods() == 0) { |
|
|
|
inst.setExecute_status("3"); |
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|
|
|
is_feedback = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|
|
|
//请求取货
|
|
|
|
if ("Load".equals(action)) { |
|
|
|
inst.setExecute_status("1"); |
|
|
|
is_feedback = true; |
|
|
|
//请求放货
|
|
|
|
} else if ("Unload".equals(action)) { |
|
|
|
inst.setExecute_status("3"); |
|
|
|
is_feedback = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//取放货完成
|
|
|
|
} else if ("onStation".equals(type)) { |
|
|
|
|
|
|
|
System.out.println("取放货完成"); |
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver(); |
|
|
|
//取货完成
|
|
|
|
if ("Load".equals(action)) { |
|
|
|
if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() == 0) { |
|
|
|
inst.setExecute_device_code(processingVehicle); |
|
|
|
inst.setExecute_status("2"); |
|
|
|
is_feedback = true; |
|
|
|
if ("PauseOnStation".equals(type)) { |
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { |
|
|
|
standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) addressdevice.getDeviceDriver(); |
|
|
|
if(standardManipulatorStackingSiteDeviceDriver.getMove()==1){ |
|
|
|
is_feedback = true; |
|
|
|
} else { |
|
|
|
log.info("设备{} 请求离开,光电信号:{}",addressdevice,standardManipulatorStackingSiteDeviceDriver.getMove()); |
|
|
|
} |
|
|
|
} |
|
|
|
//放货完成
|
|
|
|
} else if ("Unload".equals(action)) { |
|
|
|
if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() > 0) { |
|
|
|
inst.setExecute_device_code(address); |
|
|
|
inst.setExecute_status("4"); |
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|
|
|
is_feedback = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); |
|
|
|
//取货完成
|
|
|
|
if ("Load".equals(action)) { |
|
|
|
inst.setExecute_device_code(processingVehicle); |
|
|
|
inst.setExecute_status("2"); |
|
|
|
is_feedback = true; |
|
|
|
//放货完成
|
|
|
|
} else if ("Unload".equals(action)) { |
|
|
|
inst.setExecute_device_code(address); |
|
|
|
inst.setExecute_status("4"); |
|
|
|
is_feedback = true; |
|
|
|
com.alibaba.fastjson.JSONObject requestjo = new com.alibaba.fastjson.JSONObject(); |
|
|
|
if (is_feedback) { |
|
|
|
requestjo.put("task_code", jobno); |
|
|
|
requestjo.put("operation", action); |
|
|
|
if (type.equals("entryRequired") || type.equals("EntryRequired")) { |
|
|
|
requestjo.put("entryRequired", "true"); |
|
|
|
} else { |
|
|
|
requestjo.put("pauseOnStation", "true"); |
|
|
|
} |
|
|
|
log.info("反馈AGV请求数据:{}", requestjo); |
|
|
|
System.out.println("back agv:" + requestjo); |
|
|
|
|
|
|
|
} |
|
|
|
if (addressdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { |
|
|
|
specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); |
|
|
|
//取货完成
|
|
|
|
if ("Load".equals(action)) { |
|
|
|
inst.setExecute_device_code(processingVehicle); |
|
|
|
inst.setExecute_status("2"); |
|
|
|
is_feedback = true; |
|
|
|
//放货完成
|
|
|
|
} else if ("Unload".equals(action)) { |
|
|
|
inst.setExecute_device_code(processingVehicle); |
|
|
|
inst.setExecute_status("4"); |
|
|
|
is_feedback = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|
|
|
//取货完成
|
|
|
|
if ("Load".equals(action)) { |
|
|
|
inst.setExecute_device_code(processingVehicle); |
|
|
|
inst.setExecute_status("2"); |
|
|
|
is_feedback = true; |
|
|
|
//放货完成
|
|
|
|
} else if ("Unload".equals(action)) { |
|
|
|
inst.setExecute_device_code(processingVehicle); |
|
|
|
inst.setExecute_status("4"); |
|
|
|
is_feedback = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
JSONObject requestjo = new JSONObject(); |
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
if (is_feedback) { |
|
|
|
String param = ""; |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
if (str.length() > 0) { |
|
|
|
backaddress = backaddress + str; |
|
|
|
} |
|
|
|
if ("onEntry".equals(type)) { |
|
|
|
param = "EntryPermitted-" + backaddress + action; |
|
|
|
} else if ("onStation".equals(type)) { |
|
|
|
param = "ContinueOnStation-" + backaddress + action; |
|
|
|
} |
|
|
|
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); |
|
|
|
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); |
|
|
|
|
|
|
|
jo.put("key", param); |
|
|
|
jo.put("value", "False"); |
|
|
|
ja.add(jo); |
|
|
|
requestjo.put("properties", ja); |
|
|
|
log.info("反馈AGV请求数据:{}", requestjo); |
|
|
|
System.out.println("back agv:" + requestjo); |
|
|
|
agvurl = agvurl + ":" + agvport + "/api/route/transportOrders/" + jobno + "/interact"; |
|
|
|
|
|
|
|
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); |
|
|
|
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); |
|
|
|
|
|
|
|
agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + jobno + "/interact"; |
|
|
|
HttpResponse result = HttpRequest.post(agvurl) |
|
|
|
.body(String.valueOf(requestjo)) |
|
|
|
.timeout(20000)//超时,毫秒
|
|
|
|
.execute(); |
|
|
|
} |
|
|
|
return requestjo.toString(); |
|
|
|
|
|
|
|
HttpResponse result = HttpRequest.post(agvurl) |
|
|
|
.body(String.valueOf(requestjo)) |
|
|
|
.timeout(20000)//超时,毫秒
|
|
|
|
.execute(); |
|
|
|
} |
|
|
|
is_feedback = false; |
|
|
|
|
|
|
|
return requestjo.toString(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|