|
@ -9,7 +9,6 @@ import org.nl.acs.device_driver.maGang.MaGangConveyorDeviceDriver; |
|
|
import org.nl.acs.ext.wms.service.AgvToAcsService; |
|
|
import org.nl.acs.ext.wms.service.AgvToAcsService; |
|
|
import org.nl.acs.instruction.service.InstructionService; |
|
|
import org.nl.acs.instruction.service.InstructionService; |
|
|
import org.nl.acs.instruction.service.dto.Instruction; |
|
|
import org.nl.acs.instruction.service.dto.Instruction; |
|
|
import org.nl.acs.log.service.DeviceExecuteLogService; |
|
|
|
|
|
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.modules.common.exception.BadRequestException; |
|
|
import org.nl.modules.common.exception.BadRequestException; |
|
@ -25,7 +24,6 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { |
|
|
|
|
|
|
|
|
private final DeviceAppService deviceAppService; |
|
|
private final DeviceAppService deviceAppService; |
|
|
private final InstructionService instructionService; |
|
|
private final InstructionService instructionService; |
|
|
private final DeviceExecuteLogService logService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Map<String, Object> waitpointRequest(JSONObject param) { |
|
|
public Map<String, Object> waitpointRequest(JSONObject param) { |
|
@ -33,15 +31,18 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { |
|
|
String inst_code = param.getString("task_code"); |
|
|
String inst_code = param.getString("task_code"); |
|
|
//站点
|
|
|
//站点
|
|
|
String address = param.getString("address"); |
|
|
String address = param.getString("address"); |
|
|
//车号
|
|
|
log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address); |
|
|
String vehicle_code = param.getString("device_code"); |
|
|
|
|
|
String deviceCode = RouteUtil.getDeviceCode(address); |
|
|
String deviceCode = RouteUtil.getDeviceCode(address); |
|
|
Instruction instructionDto = instructionService.findByCodeFromCache(inst_code); |
|
|
Instruction instructionDto = instructionService.findByCodeFromCache(inst_code); |
|
|
if (ObjectUtil.isEmpty(instructionDto)) { |
|
|
if (ObjectUtil.isEmpty(instructionDto)) { |
|
|
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:指令任务号不存在! 指令号:" + inst_code); |
|
|
log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "指令任务号不存在或指令已取消或者指令已完成!"); |
|
|
throw new BadRequestException("请求失败,指令任务号不存在!"); |
|
|
throw new BadRequestException("指令任务号不存在或指令已取消或者指令已完成!"); |
|
|
} |
|
|
} |
|
|
Device device = deviceAppService.findDeviceByCode(deviceCode); |
|
|
Device device = deviceAppService.findDeviceByCode(deviceCode); |
|
|
|
|
|
if (ObjectUtil.isEmpty(device)) { |
|
|
|
|
|
log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "设备号:'" + deviceCode + "'有误,请检查!"); |
|
|
|
|
|
throw new BadRequestException("设备号:'" + deviceCode + "'有误,请检查!"); |
|
|
|
|
|
} |
|
|
MaGangConveyorDeviceDriver maGangConveyorDeviceDriver = (MaGangConveyorDeviceDriver) device.getDeviceDriver(); |
|
|
MaGangConveyorDeviceDriver maGangConveyorDeviceDriver = (MaGangConveyorDeviceDriver) device.getDeviceDriver(); |
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
map.put("status", 200); |
|
|
map.put("status", 200); |
|
@ -49,55 +50,55 @@ public class AgvToAcsServiceImpl implements AgvToAcsService { |
|
|
//取货点等待
|
|
|
//取货点等待
|
|
|
if (address.contains("INGET")) { |
|
|
if (address.contains("INGET")) { |
|
|
//告诉设备请求取货
|
|
|
//告诉设备请求取货
|
|
|
maGangConveyorDeviceDriver.writing(4); |
|
|
maGangConveyorDeviceDriver.writing("to_command", "4"); |
|
|
//判断是否满足取货条件
|
|
|
//判断是否满足取货条件
|
|
|
if (maGangConveyorDeviceDriver.getMove() == 1 && maGangConveyorDeviceDriver.getAction() == 1) { |
|
|
if (maGangConveyorDeviceDriver.getMove() == 1 && maGangConveyorDeviceDriver.getAction() == 1) { |
|
|
//满足响应成功
|
|
|
//满足响应成功
|
|
|
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString()); |
|
|
log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},响应参数:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, String.valueOf(map)); |
|
|
return map; |
|
|
return map; |
|
|
} else { |
|
|
} else { |
|
|
//不满足抛异常
|
|
|
//不满足抛异常
|
|
|
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:取货前-取货点无货!"); |
|
|
log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "不满足取货条件: move = 1 && action = 1"); |
|
|
throw new BadRequestException("请求失败,取货前-取货点无货!"); |
|
|
throw new BadRequestException("请求失败,不满足取货条件: move = 1 && action = 1"); |
|
|
} |
|
|
} |
|
|
}//取货完成等待
|
|
|
}//取货完成等待
|
|
|
else if (address.contains("OUTGET")) { |
|
|
else if (address.contains("OUTGET")) { |
|
|
//取货完成以后判断取货点是否有货
|
|
|
//取货完成以后判断取货点是否有货
|
|
|
if (maGangConveyorDeviceDriver.getMove() == 0) { |
|
|
if (maGangConveyorDeviceDriver.getMove() == 0) { |
|
|
//无货告诉设备取货完成
|
|
|
//无货告诉设备取货完成
|
|
|
maGangConveyorDeviceDriver.writing(2); |
|
|
maGangConveyorDeviceDriver.writing("to_command", "2"); |
|
|
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString()); |
|
|
log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},响应参数:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, String.valueOf(map)); |
|
|
return map; |
|
|
return map; |
|
|
} else { |
|
|
} else { |
|
|
//有货抛异常
|
|
|
//有货抛异常
|
|
|
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:取货完成后-取货点有货!"); |
|
|
log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "请求失败,取货完成后: move = 1!"); |
|
|
throw new BadRequestException("请求失败,取货完成后-取货点有货!"); |
|
|
throw new BadRequestException("请求失败,取货完成后: move = 1!"); |
|
|
} |
|
|
} |
|
|
}//放货前等待
|
|
|
}//放货前等待
|
|
|
else if (address.contains("INPUT")) { |
|
|
else if (address.contains("INPUT")) { |
|
|
//告诉设备请求放货
|
|
|
//告诉设备请求放货
|
|
|
maGangConveyorDeviceDriver.writing(5); |
|
|
maGangConveyorDeviceDriver.writing("to_command", "5"); |
|
|
//判断是否满足放货信号
|
|
|
//判断是否满足放货信号
|
|
|
if (maGangConveyorDeviceDriver.getMove() == 0 && maGangConveyorDeviceDriver.getAction() == 2) { |
|
|
if (maGangConveyorDeviceDriver.getMove() == 0 && maGangConveyorDeviceDriver.getAction() == 2) { |
|
|
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString()); |
|
|
log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},响应参数:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, String.valueOf(map)); |
|
|
return map; |
|
|
return map; |
|
|
} else { |
|
|
} else { |
|
|
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:放货前-放货点有货!"); |
|
|
log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "放货前不满足放货条件: move = 0 && action = 2!"); |
|
|
throw new BadRequestException("请求失败,放货前-放货点有货!"); |
|
|
throw new BadRequestException("请求失败,放货前不满足放货条件: move = 0 && action = 2!"); |
|
|
} |
|
|
} |
|
|
}//放货完成等待
|
|
|
}//放货完成等待
|
|
|
else if (address.contains("OUTPUT")) { |
|
|
else if (address.contains("OUTPUT")) { |
|
|
//放货完成后判断放货点是否有货
|
|
|
//放货完成后判断放货点是否有货
|
|
|
if (maGangConveyorDeviceDriver.getMove() == 1) { |
|
|
if (maGangConveyorDeviceDriver.getMove() == 1) { |
|
|
maGangConveyorDeviceDriver.writing(3); |
|
|
maGangConveyorDeviceDriver.writing("to_command", "3"); |
|
|
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString()); |
|
|
log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},响应参数:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, String.valueOf(map)); |
|
|
return map; |
|
|
return map; |
|
|
} else { |
|
|
} else { |
|
|
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:放货完成后-放货点无货!"); |
|
|
log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "放货完成后: move = 0 !"); |
|
|
throw new BadRequestException("请求失败,放货完成后-放货点无货!"); |
|
|
throw new BadRequestException("请求失败,放货完成后: move = 0!"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:请求失败,地址有误! 地址:" + address); |
|
|
log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "请求失败,地址:'" + address + "'->有误!"); |
|
|
throw new BadRequestException("请求失败,地址有误!"); |
|
|
throw new BadRequestException("请求失败,地址:'" + address + "'->有误!"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|