|
@ -3,9 +3,9 @@ package org.nl.start.auto.run; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.http.HttpResponse; |
|
|
import cn.hutool.http.HttpResponse; |
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import net.sf.json.JSONArray; |
|
|
|
|
|
import net.sf.json.JSONObject; |
|
|
|
|
|
import org.nl.acs.agv.server.NDCAgvService; |
|
|
import org.nl.acs.agv.server.NDCAgvService; |
|
|
import org.nl.acs.agv.server.dto.AgvDto; |
|
|
import org.nl.acs.agv.server.dto.AgvDto; |
|
|
import org.nl.acs.config.AcsConfig; |
|
|
import org.nl.acs.config.AcsConfig; |
|
@ -17,6 +17,7 @@ import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; |
|
|
import org.nl.acs.device_driver.standard_conveyor_control.StandardCoveyorControlDeviceDriver; |
|
|
import org.nl.acs.device_driver.standard_conveyor_control.StandardCoveyorControlDeviceDriver; |
|
|
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; |
|
|
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; |
|
|
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; |
|
|
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; |
|
|
|
|
|
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.standard_storage.StandardStorageDeviceDriver; |
|
|
import org.nl.acs.device_driver.traffic_light.TrafficLightDeviceDriver; |
|
|
import org.nl.acs.device_driver.traffic_light.TrafficLightDeviceDriver; |
|
|
import org.nl.acs.ext.wms.service.AcsToWmsService; |
|
|
import org.nl.acs.ext.wms.service.AcsToWmsService; |
|
@ -26,10 +27,6 @@ import org.nl.acs.instruction.service.dto.Instruction; |
|
|
import org.nl.acs.instruction.service.impl.InstructionServiceImpl; |
|
|
import org.nl.acs.instruction.service.impl.InstructionServiceImpl; |
|
|
import org.nl.acs.opc.Device; |
|
|
import org.nl.acs.opc.Device; |
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
import org.nl.acs.opc.DeviceAppServiceImpl; |
|
|
|
|
|
import org.nl.acs.task.service.TaskService; |
|
|
|
|
|
import org.nl.acs.task.service.dto.TaskDto; |
|
|
|
|
|
import org.nl.acs.task.service.impl.TaskServiceImpl; |
|
|
|
|
|
import org.nl.utils.SpringContextHolder; |
|
|
import org.nl.utils.SpringContextHolder; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
@ -93,6 +90,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { |
|
|
port = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT)); |
|
|
port = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT)); |
|
|
byte[] b = new byte[1028]; |
|
|
byte[] b = new byte[1028]; |
|
|
s = new Socket(ip, port); |
|
|
s = new Socket(ip, port); |
|
|
|
|
|
System.out.println("Agv链接成功"); |
|
|
dos = new DataOutputStream(s.getOutputStream()); |
|
|
dos = new DataOutputStream(s.getOutputStream()); |
|
|
dis = new DataInputStream(s.getInputStream()); |
|
|
dis = new DataInputStream(s.getInputStream()); |
|
|
|
|
|
|
|
@ -159,18 +157,28 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { |
|
|
StandardStorageDeviceDriver standardStorageDeviceDriver; |
|
|
StandardStorageDeviceDriver standardStorageDeviceDriver; |
|
|
StandardAutodoorDeviceDriver standardAutodoorDeviceDriver; |
|
|
StandardAutodoorDeviceDriver standardAutodoorDeviceDriver; |
|
|
StandardEmptyPalletSiteDeviceDriver standardEmptyPalletSiteDeviceDriver; |
|
|
StandardEmptyPalletSiteDeviceDriver standardEmptyPalletSiteDeviceDriver; |
|
|
|
|
|
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; |
|
|
OumulongPlcDeviceDriver oumulongPlcDeviceDriver; |
|
|
OumulongPlcDeviceDriver oumulongPlcDeviceDriver; |
|
|
TrafficLightDeviceDriver trafficLightDeviceDriver; |
|
|
TrafficLightDeviceDriver trafficLightDeviceDriver; |
|
|
int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE)); |
|
|
|
|
|
|
|
|
|
|
|
if (phase == 0x01) { |
|
|
if (phase == 0x01) { |
|
|
data = AgvService.sendAgvOneModeInst(phase, index); |
|
|
//data = AgvService.sendAgvOneModeInst(phase, index);
|
|
|
if (!ObjectUtil.isEmpty(inst)) { |
|
|
if (!ObjectUtil.isEmpty(inst)) { |
|
|
inst.setInstruction_status("1"); |
|
|
inst.setInstruction_status("1"); |
|
|
inst.setAgv_jobno(String.valueOf(index)); |
|
|
inst.setAgv_jobno(String.valueOf(index)); |
|
|
inst.setSend_status("1"); |
|
|
inst.setSend_status("1"); |
|
|
instructionService.update(inst); |
|
|
instructionService.update(inst); |
|
|
data = AgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
data = AgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
|
|
// 反馈wms任务状态---执行中
|
|
|
|
|
|
JSONObject feed_jo = new JSONObject(); |
|
|
|
|
|
feed_jo.put("task_code", inst.getTask_code()); |
|
|
|
|
|
feed_jo.put("task_status", "1"); |
|
|
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
|
|
ja.add(feed_jo); |
|
|
|
|
|
|
|
|
|
|
|
acsToWmsService.feedbackTaskStatusToWms(ja); |
|
|
|
|
|
log.info("agv任务状态-执行中反馈成功,设备号{},任务号{}", device_code, inst.getTask_code()); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
flag = true; |
|
|
flag = true; |
|
|
} |
|
|
} |
|
@ -187,6 +195,29 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { |
|
|
log.info("未找到指令号{}对应的指令", ikey); |
|
|
log.info("未找到指令号{}对应的指令", ikey); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//普通站点
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
|
|
JSONObject map = new JSONObject(); |
|
|
|
|
|
map.put("task_code", inst.getTask_code()); |
|
|
|
|
|
map.put("status", "1"); |
|
|
|
|
|
map.put("device_code", device_code); |
|
|
|
|
|
map.put("vehicle_code", inst.getVehicle_code()); |
|
|
|
|
|
HttpResponse httpResponse = acsToWmsService.feedbackAgvTakePutStatus(map); |
|
|
|
|
|
String body = httpResponse.body(); |
|
|
|
|
|
JSONObject resJson = JSONObject.parseObject(body); |
|
|
|
|
|
String message = resJson.getString("message"); |
|
|
|
|
|
int status = Integer.parseInt(resJson.getString("status")); |
|
|
|
|
|
if (status == 200) { |
|
|
|
|
|
inst.setExecute_status("1"); |
|
|
|
|
|
instructionService.update(inst); |
|
|
|
|
|
data = AgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
|
|
flag = true; |
|
|
|
|
|
log.info("agv请求取货反馈成功,设备号{},任务号{}", device_code, inst.getTask_code()); |
|
|
|
|
|
} else { |
|
|
|
|
|
log.info("agv请求取货,wms系统不允许取货,设备号{},任务号{},原因{}", device_code, inst.getTask_code(), message); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
//检测站点
|
|
|
//检测站点
|
|
|
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
@ -238,6 +269,29 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//普通站点
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
|
|
JSONObject map = new JSONObject(); |
|
|
|
|
|
map.put("task_code", inst.getTask_code()); |
|
|
|
|
|
map.put("status", "2"); |
|
|
|
|
|
map.put("device_code", device_code); |
|
|
|
|
|
map.put("vehicle_code", inst.getVehicle_code()); |
|
|
|
|
|
HttpResponse httpResponse = acsToWmsService.feedbackAgvTakePutStatus(map); |
|
|
|
|
|
String body = httpResponse.body(); |
|
|
|
|
|
JSONObject resJson = JSONObject.parseObject(body); |
|
|
|
|
|
String message = resJson.getString("message"); |
|
|
|
|
|
int status = Integer.parseInt(resJson.getString("status")); |
|
|
|
|
|
if (status == 200) { |
|
|
|
|
|
inst.setExecute_status("5"); |
|
|
|
|
|
instructionService.update(inst); |
|
|
|
|
|
data = AgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
|
|
flag = true; |
|
|
|
|
|
log.info("agv取货完成反馈成功,设备号{},任务号{}", device_code, inst.getTask_code()); |
|
|
|
|
|
} else { |
|
|
|
|
|
log.info("agv请求取货完成请求离开,wms系统不允许离开,设备号{},任务号{},原因{}", device_code, inst.getTask_code(), message); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
if (standardInspectSiteDeviceDriver.getMove() == 0) { |
|
|
if (standardInspectSiteDeviceDriver.getMove() == 0) { |
|
@ -288,6 +342,30 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { |
|
|
log.info("未找到指令号{}对应的指令", ikey); |
|
|
log.info("未找到指令号{}对应的指令", ikey); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//普通站点
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
|
|
JSONObject map = new JSONObject(); |
|
|
|
|
|
map.put("task_code", inst.getTask_code()); |
|
|
|
|
|
map.put("status", "3"); |
|
|
|
|
|
map.put("device_code", device_code); |
|
|
|
|
|
map.put("vehicle_code", inst.getVehicle_code()); |
|
|
|
|
|
HttpResponse httpResponse = acsToWmsService.feedbackAgvTakePutStatus(map); |
|
|
|
|
|
String body = httpResponse.body(); |
|
|
|
|
|
JSONObject resJson = JSONObject.parseObject(body); |
|
|
|
|
|
String message = resJson.getString("message"); |
|
|
|
|
|
int status = Integer.parseInt(resJson.getString("status")); |
|
|
|
|
|
if (status == 200) { |
|
|
|
|
|
inst.setExecute_status("3"); |
|
|
|
|
|
instructionService.update(inst); |
|
|
|
|
|
data = AgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
|
|
flag = true; |
|
|
|
|
|
log.info("agv请求放货反馈成功,设备号{},任务号{}", device_code, inst.getTask_code()); |
|
|
|
|
|
} else { |
|
|
|
|
|
log.info("agv请求放货,wms系统不允许放货,设备号{},任务号{},原因{}", device_code, inst.getTask_code(), message); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
if (standardInspectSiteDeviceDriver.getMove() == 0) { |
|
|
if (standardInspectSiteDeviceDriver.getMove() == 0) { |
|
@ -325,6 +403,29 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//普通站点
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
|
|
JSONObject map = new JSONObject(); |
|
|
|
|
|
map.put("task_code", inst.getTask_code()); |
|
|
|
|
|
map.put("status", "4"); |
|
|
|
|
|
map.put("device_code", device_code); |
|
|
|
|
|
map.put("vehicle_code", inst.getVehicle_code()); |
|
|
|
|
|
HttpResponse httpResponse = acsToWmsService.feedbackAgvTakePutStatus(map); |
|
|
|
|
|
String body = httpResponse.body(); |
|
|
|
|
|
JSONObject resJson = JSONObject.parseObject(body); |
|
|
|
|
|
String message = resJson.getString("message"); |
|
|
|
|
|
int status = Integer.parseInt(resJson.getString("status")); |
|
|
|
|
|
if (status == 200) { |
|
|
|
|
|
inst.setExecute_status("6"); |
|
|
|
|
|
instructionService.update(inst); |
|
|
|
|
|
data = AgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
|
|
flag = true; |
|
|
|
|
|
log.info("agv放货完成反馈成功,设备号{},任务号{}", device_code, inst.getTask_code()); |
|
|
|
|
|
} else { |
|
|
|
|
|
log.info("agv放货完成请求离开,wms系统不允许离开,设备号{},任务号{},原因{}", device_code, inst.getTask_code(), message); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); |
|
|
if (standardInspectSiteDeviceDriver.getMove() != 0) { |
|
|
if (standardInspectSiteDeviceDriver.getMove() != 0) { |
|
@ -363,6 +464,15 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { |
|
|
if (!ObjectUtil.isEmpty(inst)) { |
|
|
if (!ObjectUtil.isEmpty(inst)) { |
|
|
inst.setInstruction_status("2"); |
|
|
inst.setInstruction_status("2"); |
|
|
instructionService.finish(inst); |
|
|
instructionService.finish(inst); |
|
|
|
|
|
|
|
|
|
|
|
//反馈wms任务状态---完成
|
|
|
|
|
|
JSONObject feed_jo = new JSONObject(); |
|
|
|
|
|
feed_jo.put("task_code", inst.getTask_code()); |
|
|
|
|
|
feed_jo.put("task_status", "2"); |
|
|
|
|
|
JSONArray ja = new JSONArray(); |
|
|
|
|
|
ja.add(feed_jo); |
|
|
|
|
|
acsToWmsService.feedbackTaskStatusToWms(ja); |
|
|
|
|
|
log.info("agv任务完成反馈成功,设备号{},任务号{}", device_code, inst.getTask_code()); |
|
|
} |
|
|
} |
|
|
data = AgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
data = AgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
} |
|
|
} |
|
@ -503,6 +613,9 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { |
|
|
dto.setName(String.valueOf(carno)); |
|
|
dto.setName(String.valueOf(carno)); |
|
|
dto.setEnergyLevel(String.valueOf(ikey)); |
|
|
dto.setEnergyLevel(String.valueOf(ikey)); |
|
|
} |
|
|
} |
|
|
|
|
|
if (!ObjectUtil.isEmpty(data)) { |
|
|
|
|
|
write(data); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
System.out.println("agv上报不是0073类型动作,不处理"); |
|
|
System.out.println("agv上报不是0073类型动作,不处理"); |
|
|