|
|
@ -4,10 +4,12 @@ import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.nl.acs.device_driver.basedriver.standard_conveyor_control.StandardCoveyorControlDeviceDriver; |
|
|
|
import org.nl.acs.device_driver.sdk.PhotoelectricDetectionDeviceDriver; |
|
|
|
import org.nl.acs.log.service.DeviceExecuteLogService; |
|
|
|
import org.nl.acs.opc.Device; |
|
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
|
import org.nl.acs.task.service.TaskService; |
|
|
|
import org.nl.acs.task.service.dto.TaskDto; |
|
|
|
import org.nl.modules.common.exception.BadRequestException; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -25,6 +27,8 @@ public class AgvWaitUtil { |
|
|
|
private DeviceAppService deviceAppService; |
|
|
|
@Autowired |
|
|
|
private DeviceExecuteLogService deviceExecuteLogService; |
|
|
|
@Autowired |
|
|
|
private TaskService taskService; |
|
|
|
|
|
|
|
//取货前等待
|
|
|
|
public JSONObject waitInGet(String deviceCode) { |
|
|
@ -36,9 +40,13 @@ public class AgvWaitUtil { |
|
|
|
throw new BadRequestException("请求失败,未找到设备!"); |
|
|
|
} |
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof PhotoelectricDetectionDeviceDriver) { |
|
|
|
PhotoelectricDetectionDeviceDriver driver = (PhotoelectricDetectionDeviceDriver) device.getDeviceDriver(); |
|
|
|
if (driver.getMove() == 1) { |
|
|
|
if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { |
|
|
|
// 标准版输送线驱动
|
|
|
|
StandardCoveyorControlDeviceDriver driver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); |
|
|
|
// 通知输送线申请取货-1
|
|
|
|
driver.writing(1); |
|
|
|
// 判断是否满足条件:action = 1(允许取货) && move = 1(有货)
|
|
|
|
if (driver.getMove() == 1 && driver.getAction() == 1) { |
|
|
|
String message = "允许AGV取货。"; |
|
|
|
driver.setMessage(message); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message); |
|
|
@ -71,8 +79,11 @@ public class AgvWaitUtil { |
|
|
|
throw new BadRequestException("请求失败,未找到设备!"); |
|
|
|
} |
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof PhotoelectricDetectionDeviceDriver) { |
|
|
|
PhotoelectricDetectionDeviceDriver driver = (PhotoelectricDetectionDeviceDriver) device.getDeviceDriver(); |
|
|
|
if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { |
|
|
|
// 标准版输送线驱动
|
|
|
|
StandardCoveyorControlDeviceDriver driver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); |
|
|
|
// 通知输送线取货完成-2
|
|
|
|
driver.writing(2); |
|
|
|
if (driver.getMove() == 0) { |
|
|
|
String message = "允许AGV取货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
@ -99,7 +110,7 @@ public class AgvWaitUtil { |
|
|
|
} |
|
|
|
|
|
|
|
//放货前等待
|
|
|
|
public JSONObject waitInPut(String deviceCode) { |
|
|
|
public JSONObject waitInPut(String deviceCode,TaskDto taskDto) { |
|
|
|
log.info("仙工AGV请求放货,设备号 - {}", deviceCode); |
|
|
|
boolean flag = false; |
|
|
|
|
|
|
@ -108,17 +119,26 @@ public class AgvWaitUtil { |
|
|
|
throw new BadRequestException("请求失败,未找到设备!"); |
|
|
|
} |
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof PhotoelectricDetectionDeviceDriver) { |
|
|
|
PhotoelectricDetectionDeviceDriver driver = (PhotoelectricDetectionDeviceDriver) device.getDeviceDriver(); |
|
|
|
if (driver.getMove() == 0) { |
|
|
|
if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { |
|
|
|
// 标准版输送线驱动
|
|
|
|
StandardCoveyorControlDeviceDriver driver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); |
|
|
|
// 通知输送线申请放货-3
|
|
|
|
driver.writing(3); |
|
|
|
// 判断是否满足条件:action = 2(允许放货) && move = 0(无货)
|
|
|
|
if (driver.getMove() == 0 && driver.getAction() == 2) { |
|
|
|
String message = "允许AGV放货。"; |
|
|
|
driver.setMessage(message); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message); |
|
|
|
flag = true; |
|
|
|
|
|
|
|
if (taskDto.getIs_vehicle().equals("1")) { |
|
|
|
// 获取当前母载具号
|
|
|
|
taskDto.setVehicle_code(driver.getBarcode()); |
|
|
|
taskService.update(taskDto); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
String message = "光电信号有货,不允许放货!"; |
|
|
|
driver.setMessage(message); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", "光电信号为:" + driver.getMove()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
flag = true; |
|
|
@ -146,15 +166,20 @@ public class AgvWaitUtil { |
|
|
|
throw new BadRequestException("请求失败,未找到设备!"); |
|
|
|
} |
|
|
|
|
|
|
|
if (device.getDeviceDriver() instanceof PhotoelectricDetectionDeviceDriver) { |
|
|
|
PhotoelectricDetectionDeviceDriver driver = (PhotoelectricDetectionDeviceDriver) device.getDeviceDriver(); |
|
|
|
if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { |
|
|
|
// 标准版输送线驱动
|
|
|
|
StandardCoveyorControlDeviceDriver driver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); |
|
|
|
// 通知输送线放货完成-4
|
|
|
|
driver.writing(4); |
|
|
|
if (driver.getMove() == 1) { |
|
|
|
String message = "允许AGV放货完成离开。"; |
|
|
|
String message = "允许AGV放货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message); |
|
|
|
flag = true; |
|
|
|
} else { |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", "光电信号为:" + driver.getMove() + ",不允许AGV放货完成离开!"); |
|
|
|
String message = "光电信号有货,不允许AGV放货后离开。"; |
|
|
|
driver.setMessage(message); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message); |
|
|
|
} |
|
|
|
} else { |
|
|
|
flag = true; |
|
|
|