|
|
@ -42,6 +42,8 @@ public class AutoCreateInst { |
|
|
|
protected BusinessLogger execute_log; |
|
|
|
protected NoRepeatBusinessLogger device_log; |
|
|
|
|
|
|
|
private volatile boolean lock = false; |
|
|
|
|
|
|
|
public AutoCreateInst() { |
|
|
|
this.execute_log = new BusinessLoggerImpl(BusinessDomain.device_execute.name()); |
|
|
|
this.device_log = BusinessLoggerFactory.getNoRepeatBusinessLogger(BusinessDomain.device_execute.name()); |
|
|
@ -53,48 +55,51 @@ public class AutoCreateInst { |
|
|
|
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货 |
|
|
|
*/ |
|
|
|
public void run() throws Exception { |
|
|
|
TaskService taskserver = SpringContextHolder.getBean(TaskService.class); |
|
|
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); |
|
|
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); |
|
|
|
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); |
|
|
|
List<TaskDto> list = taskserver.queryByStauts("0"); |
|
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
if (!lock) { |
|
|
|
lock = true; |
|
|
|
try { |
|
|
|
TaskService taskserver = SpringContextHolder.getBean(TaskService.class); |
|
|
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); |
|
|
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); |
|
|
|
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); |
|
|
|
List<TaskDto> list = taskserver.queryByStauts("0"); |
|
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
|
|
|
|
TaskDto acsTask = list.get(i); |
|
|
|
String taskid = acsTask.getTask_id(); |
|
|
|
String taskcode = acsTask.getTask_code(); |
|
|
|
String vehiclecode = acsTask.getVehicle_code(); |
|
|
|
String priority = acsTask.getPriority(); |
|
|
|
String start_point_code = acsTask.getStart_point_code(); |
|
|
|
String start_device_code = acsTask.getStart_device_code(); |
|
|
|
String route_plan_code = acsTask.getRoute_plan_code(); |
|
|
|
String vehicleType = acsTask.getVehicle_type(); |
|
|
|
TaskDto acsTask = list.get(i); |
|
|
|
String taskid = acsTask.getTask_id(); |
|
|
|
String taskcode = acsTask.getTask_code(); |
|
|
|
String vehiclecode = acsTask.getVehicle_code(); |
|
|
|
String priority = acsTask.getPriority(); |
|
|
|
String start_point_code = acsTask.getStart_point_code(); |
|
|
|
String start_device_code = acsTask.getStart_device_code(); |
|
|
|
String route_plan_code = acsTask.getRoute_plan_code(); |
|
|
|
String vehicleType = acsTask.getVehicle_type(); |
|
|
|
|
|
|
|
//是否复合任务 =0非复合任务
|
|
|
|
String compound_task = acsTask.getCompound_task(); |
|
|
|
String next_point_code = acsTask.getNext_point_code(); |
|
|
|
String next_device_code = acsTask.getNext_device_code(); |
|
|
|
if (StrUtil.isEmpty(start_device_code)) { |
|
|
|
acsTask.setRemark("起始设备不能为空"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(next_device_code)) { |
|
|
|
acsTask.setRemark("目标设备不能为空"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} |
|
|
|
String maxInstnumber = acsConfigService.findConfigFromCache().get(AcsConfig.MAXINSTNUMBER); |
|
|
|
if (ObjectUtils.isNotEmpty(maxInstnumber)) { |
|
|
|
if (i >= Integer.parseInt(maxInstnumber)) { |
|
|
|
acsTask.setRemark("系统参数配置最大指令数为:" + maxInstnumber + "无法生成指令"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
//是否复合任务 =0非复合任务
|
|
|
|
String compound_task = acsTask.getCompound_task(); |
|
|
|
String next_point_code = acsTask.getNext_point_code(); |
|
|
|
String next_device_code = acsTask.getNext_device_code(); |
|
|
|
if (StrUtil.isEmpty(start_device_code)) { |
|
|
|
acsTask.setRemark("起始设备不能为空"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(next_device_code)) { |
|
|
|
acsTask.setRemark("目标设备不能为空"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} |
|
|
|
String maxInstnumber = acsConfigService.findConfigFromCache().get(AcsConfig.MAXINSTNUMBER); |
|
|
|
if (ObjectUtils.isNotEmpty(maxInstnumber)) { |
|
|
|
if (i >= Integer.parseInt(maxInstnumber)) { |
|
|
|
acsTask.setRemark("系统参数配置最大指令数为:" + maxInstnumber + "无法生成指令"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//特殊任务 起点终点处理
|
|
|
|
//特殊任务 起点终点处理
|
|
|
|
// if (StrUtil.equals("2", acsTask.getTask_type())) {
|
|
|
|
// next_device_code = acsTask.getNext_device_code();
|
|
|
|
// if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
|
|
|
@ -110,299 +115,305 @@ public class AutoCreateInst { |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
/** |
|
|
|
* 开始平均分解校验 |
|
|
|
*/ |
|
|
|
String this_device_code = taskserver.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code()); |
|
|
|
if (StrUtil.isEmpty(this_device_code)) { |
|
|
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code); |
|
|
|
RouteLineDto routeLineDto = shortPathsList.get(0); |
|
|
|
String path = routeLineDto.getPath(); |
|
|
|
String type = routeLineDto.getType(); |
|
|
|
String[] str = path.split("->"); |
|
|
|
List<String> pathlist = Arrays.asList(str); |
|
|
|
int index = 0; |
|
|
|
for (int m = 0; m < pathlist.size(); m++) { |
|
|
|
if (pathlist.get(m).equals(start_device_code)) { |
|
|
|
index = m + 1; |
|
|
|
break; |
|
|
|
/** |
|
|
|
* 开始平均分解校验 |
|
|
|
*/ |
|
|
|
String this_device_code = taskserver.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code()); |
|
|
|
if (StrUtil.isEmpty(this_device_code)) { |
|
|
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code); |
|
|
|
RouteLineDto routeLineDto = shortPathsList.get(0); |
|
|
|
String path = routeLineDto.getPath(); |
|
|
|
String type = routeLineDto.getType(); |
|
|
|
String[] str = path.split("->"); |
|
|
|
List<String> pathlist = Arrays.asList(str); |
|
|
|
int index = 0; |
|
|
|
for (int m = 0; m < pathlist.size(); m++) { |
|
|
|
if (pathlist.get(m).equals(start_device_code)) { |
|
|
|
index = m + 1; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
next_device_code = pathlist.get(index); |
|
|
|
} else { |
|
|
|
next_device_code = this_device_code; |
|
|
|
} |
|
|
|
} |
|
|
|
next_device_code = pathlist.get(index); |
|
|
|
} else { |
|
|
|
next_device_code = this_device_code; |
|
|
|
} |
|
|
|
//校验路由关系
|
|
|
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); |
|
|
|
if (ObjectUtils.isEmpty(shortPathsList)) { |
|
|
|
acsTask.setRemark("路由不通无法生成指令"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
Device startdevice = appService.findDeviceByCode(start_device_code); |
|
|
|
Device nextdevice = appService.findDeviceByCode(next_device_code); |
|
|
|
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { |
|
|
|
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); |
|
|
|
} else { |
|
|
|
next_point_code = next_device_code; |
|
|
|
} |
|
|
|
if (ObjectUtils.isEmpty(appService)) { |
|
|
|
log.info("地址对应设备未找到"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (ObjectUtils.isEmpty(startdevice)) { |
|
|
|
log.info("地址对应设备未找到"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
//普通站点
|
|
|
|
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; |
|
|
|
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; |
|
|
|
StandardEmptyPalletSiteDeviceDriver standardEmptsyPalletSiteDeviceDriver; |
|
|
|
StandardManipulatorInspectSiteDeviceDriver standardManipulatorInspectSiteDeviceDriver; |
|
|
|
LampThreecolorDeviceDriver lampThreecolorDeviceDriver; |
|
|
|
|
|
|
|
String createTaskCheck = acsConfigService.findConfigFromCache().get(AcsConfig.CREATETASKCHECK); |
|
|
|
|
|
|
|
if (StrUtil.equals(createTaskCheck, "1")) { |
|
|
|
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); |
|
|
|
if (standardInspectSiteDeviceDriver.getMode() != 2) { |
|
|
|
log.info("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
//校验路由关系
|
|
|
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); |
|
|
|
if (ObjectUtils.isEmpty(shortPathsList)) { |
|
|
|
acsTask.setRemark("路由不通无法生成指令"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(startdevice.getDevice_code(), startdevice.getDevice_code()); |
|
|
|
this.execute_log.log("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (standardInspectSiteDeviceDriver.getMove() == 0) { |
|
|
|
log.info("目标设备:" + startdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + startdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(startdevice.getDevice_code(), startdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + startdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
|
|
|
|
if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (startdevice.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) { |
|
|
|
standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) startdevice.getDeviceDriver(); |
|
|
|
if (standardManipulatorInspectSiteDeviceDriver.getMode() != 2) { |
|
|
|
log.info("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(startdevice.getDevice_code(), startdevice.getDevice_code()); |
|
|
|
this.execute_log.log("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
Device startdevice = appService.findDeviceByCode(start_device_code); |
|
|
|
Device nextdevice = appService.findDeviceByCode(next_device_code); |
|
|
|
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { |
|
|
|
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); |
|
|
|
} else { |
|
|
|
next_point_code = next_device_code; |
|
|
|
} |
|
|
|
if (standardManipulatorInspectSiteDeviceDriver.getMove() == 0) { |
|
|
|
log.info("目标设备:" + startdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + startdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(startdevice.getDevice_code(), startdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + startdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
if (ObjectUtils.isEmpty(appService)) { |
|
|
|
log.info("地址对应设备未找到"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (startdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { |
|
|
|
standardEmptsyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) startdevice.getDeviceDriver(); |
|
|
|
if (standardEmptsyPalletSiteDeviceDriver.getMode() != 2) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
if (ObjectUtils.isEmpty(startdevice)) { |
|
|
|
log.info("地址对应设备未找到"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
//普通站点
|
|
|
|
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; |
|
|
|
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; |
|
|
|
StandardEmptyPalletSiteDeviceDriver standardEmptsyPalletSiteDeviceDriver; |
|
|
|
StandardManipulatorInspectSiteDeviceDriver standardManipulatorInspectSiteDeviceDriver; |
|
|
|
LampThreecolorDeviceDriver lampThreecolorDeviceDriver; |
|
|
|
|
|
|
|
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.APPLY_EMPTY.getCode())) { |
|
|
|
int nowNumber = standardEmptsyPalletSiteDeviceDriver.getNumber(); |
|
|
|
start_point_code = start_point_code + "." + nowNumber; |
|
|
|
} |
|
|
|
} |
|
|
|
String createTaskCheck = acsConfigService.findConfigFromCache().get(AcsConfig.CREATETASKCHECK); |
|
|
|
|
|
|
|
//目的点校验
|
|
|
|
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); |
|
|
|
if (standardInspectSiteDeviceDriver.getMode() != 2) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
if (StrUtil.equals(createTaskCheck, "1")) { |
|
|
|
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); |
|
|
|
if (standardInspectSiteDeviceDriver.getMode() != 2) { |
|
|
|
log.info("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(startdevice.getDevice_code(), startdevice.getDevice_code()); |
|
|
|
this.execute_log.log("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (standardInspectSiteDeviceDriver.getMove() == 0) { |
|
|
|
log.info("目标设备:" + startdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + startdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(startdevice.getDevice_code(), startdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + startdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (startdevice.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) { |
|
|
|
standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) startdevice.getDeviceDriver(); |
|
|
|
if (standardManipulatorInspectSiteDeviceDriver.getMode() != 2) { |
|
|
|
log.info("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(startdevice.getDevice_code(), startdevice.getDevice_code()); |
|
|
|
this.execute_log.log("起点设备:" + startdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (standardManipulatorInspectSiteDeviceDriver.getMove() == 0) { |
|
|
|
log.info("目标设备:" + startdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + startdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(startdevice.getDevice_code(), startdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + startdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (startdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { |
|
|
|
standardEmptsyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) startdevice.getDeviceDriver(); |
|
|
|
if (standardEmptsyPalletSiteDeviceDriver.getMode() != 2) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.APPLY_EMPTY.getCode())) { |
|
|
|
int nowNumber = standardEmptsyPalletSiteDeviceDriver.getNumber(); |
|
|
|
start_point_code = start_point_code + "." + nowNumber; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//目的点校验
|
|
|
|
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); |
|
|
|
if (standardInspectSiteDeviceDriver.getMode() != 2) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (standardInspectSiteDeviceDriver.getMove() != 0) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (startdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { |
|
|
|
standardEmptsyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) startdevice.getDeviceDriver(); |
|
|
|
if (next_device_code.equals("Q1") || next_device_code.equals("P1")) { |
|
|
|
int number = standardEmptsyPalletSiteDeviceDriver.getNumber(); |
|
|
|
start_device_code = start_device_code + "." + number; |
|
|
|
start_point_code = start_point_code + "." + number; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (nextdevice.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) { |
|
|
|
standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); |
|
|
|
if (standardManipulatorInspectSiteDeviceDriver.getMode() != 2) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (standardManipulatorInspectSiteDeviceDriver.getMove() != 0) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (nextdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver(); |
|
|
|
if (standardOrdinarySiteDeviceDriver.getHasGoods() != 0) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "有货,无法生成任务,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "有货,无法生成任务,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "有货,无法生成任务,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//校验 是否同任务是否存在相同终点、未完成的指令
|
|
|
|
int sameqty = instructionService.querySameDestinationInst(next_point_code); |
|
|
|
if (sameqty > 0) { |
|
|
|
log.info("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (standardInspectSiteDeviceDriver.getMove() != 0) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
|
|
|
|
//空盘位生成指令需要另外逻辑
|
|
|
|
if (nextdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { |
|
|
|
standardEmptsyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) nextdevice.getDeviceDriver(); |
|
|
|
if (standardEmptsyPalletSiteDeviceDriver.getMode() != 2) { |
|
|
|
log.info(("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode)); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
int max_emptypalletnum = Integer.parseInt(nextdevice.getExtraValue().get("max_emptypalletnum").toString()); |
|
|
|
int nowNumber = standardEmptsyPalletSiteDeviceDriver.getNumber(); |
|
|
|
if (nowNumber == max_emptypalletnum) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "空盘位已满等待入库,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "空盘位已满等待入库,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "空盘位已满等待入库,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 查看是否有相同终点的指令
|
|
|
|
int sameqty = instructionService.querySameDestinationInst(next_point_code); |
|
|
|
if (sameqty > 0) { |
|
|
|
log.info("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
next_point_code = next_point_code + "." + (nowNumber + sameqty + 1); |
|
|
|
} |
|
|
|
if (startdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver){ |
|
|
|
if (startdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { |
|
|
|
standardEmptsyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) startdevice.getDeviceDriver(); |
|
|
|
if (next_device_code.equals("Q1") || next_device_code.equals("P1")){ |
|
|
|
int number = standardEmptsyPalletSiteDeviceDriver.getNumber(); |
|
|
|
start_device_code = start_device_code + "." + number; |
|
|
|
start_point_code = start_point_code + "." + number; |
|
|
|
|
|
|
|
int sameqty = instructionService.querySameOriginInst(start_point_code); |
|
|
|
if (sameqty > 0) { |
|
|
|
log.info("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (nextdevice.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) { |
|
|
|
standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); |
|
|
|
if (standardManipulatorInspectSiteDeviceDriver.getMode() != 2) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (standardManipulatorInspectSiteDeviceDriver.getMove() != 0) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
if (!StrUtil.equals(acsTask.getEmptypallet_num(), "0")) { |
|
|
|
Integer.parseInt(acsTask.getEmptypallet_num()); |
|
|
|
int num = standardEmptsyPalletSiteDeviceDriver.getNumber() - Integer.parseInt(acsTask.getEmptypallet_num()) + 1 - sameqty; |
|
|
|
if (num <= 0) { |
|
|
|
acsTask.setRemark("叠盘位可用空盘数量不足无法生成"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
start_point_code = start_point_code + "." + num; |
|
|
|
} |
|
|
|
} else { |
|
|
|
//目的点校验
|
|
|
|
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); |
|
|
|
if (next_device_code.equals("Q1") || next_device_code.equals("P1")) { |
|
|
|
int number = standardEmptsyPalletSiteDeviceDriver.getNumber(); |
|
|
|
start_device_code = start_device_code + "." + number; |
|
|
|
start_point_code = start_point_code + "." + number; |
|
|
|
} |
|
|
|
} else { |
|
|
|
start_point_code = start_point_code + "." + 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Instruction instdto = new Instruction(); |
|
|
|
instdto.setInstruction_type(acsTask.getTask_type()); |
|
|
|
instdto.setInstruction_id(IdUtil.simpleUUID()); |
|
|
|
instdto.setRoute_plan_code(route_plan_code); |
|
|
|
instdto.setRemark(acsTask.getRemark()); |
|
|
|
instdto.setMaterial(acsTask.getMaterial()); |
|
|
|
instdto.setQuantity(acsTask.getQuantity()); |
|
|
|
instdto.setTask_id(taskid); |
|
|
|
instdto.setTask_code(taskcode); |
|
|
|
instdto.setVehicle_code(vehiclecode); |
|
|
|
instdto.setRoute_plan_code(route_plan_code); |
|
|
|
String now = DateUtil.now(); |
|
|
|
instdto.setCreate_time(now); |
|
|
|
instdto.setCreate_by("auto"); |
|
|
|
instdto.setStart_device_code(start_device_code); |
|
|
|
instdto.setNext_device_code(next_device_code); |
|
|
|
instdto.setStart_point_code(start_point_code); |
|
|
|
instdto.setNext_point_code(next_point_code); |
|
|
|
instdto.setPriority(priority); |
|
|
|
instdto.setInstruction_status("0"); |
|
|
|
instdto.setExecute_device_code(start_point_code); |
|
|
|
instdto.setVehicle_type(vehicleType); |
|
|
|
instdto.setMaterial(acsTask.getMaterial()); |
|
|
|
|
|
|
|
if (nextdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|
|
|
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver(); |
|
|
|
if (standardOrdinarySiteDeviceDriver.getHasGoods() != 0) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "有货,无法生成任务,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "有货,无法生成任务,任务号:" + taskcode); |
|
|
|
try { |
|
|
|
instructionService.create(instdto); |
|
|
|
} catch (Exception e) { |
|
|
|
acsTask.setRemark(e.getMessage()); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "有货,无法生成任务,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//校验 是否同任务是否存在相同终点、未完成的指令
|
|
|
|
int sameqty = instructionService.querySameDestinationInst(next_point_code); |
|
|
|
if (sameqty > 0) { |
|
|
|
log.info("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
//创建指令后修改任务状态
|
|
|
|
acsTask.setTask_status("1"); |
|
|
|
taskserver.update(acsTask); |
|
|
|
|
|
|
|
//空盘位生成指令需要另外逻辑
|
|
|
|
if (nextdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { |
|
|
|
standardEmptsyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) nextdevice.getDeviceDriver(); |
|
|
|
if (standardEmptsyPalletSiteDeviceDriver.getMode() != 2) { |
|
|
|
log.info(("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode)); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
int max_emptypalletnum = Integer.parseInt(nextdevice.getExtraValue().get("max_emptypalletnum").toString()); |
|
|
|
int nowNumber = standardEmptsyPalletSiteDeviceDriver.getNumber(); |
|
|
|
if (nowNumber == max_emptypalletnum) { |
|
|
|
log.info("目标设备:" + nextdevice.getDevice_code() + "空盘位已满等待入库,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "空盘位已满等待入库,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "空盘位已满等待入库,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 查看是否有相同终点的指令
|
|
|
|
int sameqty = instructionService.querySameDestinationInst(next_point_code); |
|
|
|
if (sameqty > 0) { |
|
|
|
log.info("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} finally { |
|
|
|
if (lock) { |
|
|
|
lock = false; |
|
|
|
} |
|
|
|
next_point_code = next_point_code + "." + (nowNumber + sameqty + 1); |
|
|
|
} |
|
|
|
if (startdevice.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { |
|
|
|
standardEmptsyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) startdevice.getDeviceDriver(); |
|
|
|
|
|
|
|
int sameqty = instructionService.querySameOriginInst(start_point_code); |
|
|
|
if (sameqty > 0) { |
|
|
|
log.info("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
acsTask.setRemark("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); |
|
|
|
this.execute_log.log("存在相同终点的指令,任务号:" + taskcode); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (!StrUtil.equals(acsTask.getEmptypallet_num(), "0")) { |
|
|
|
Integer.parseInt(acsTask.getEmptypallet_num()); |
|
|
|
int num = standardEmptsyPalletSiteDeviceDriver.getNumber() - Integer.parseInt(acsTask.getEmptypallet_num()) + 1 - sameqty; |
|
|
|
if (num <= 0) { |
|
|
|
acsTask.setRemark("叠盘位可用空盘数量不足无法生成"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
start_point_code = start_point_code + "." + num; |
|
|
|
} |
|
|
|
} else { |
|
|
|
//目的点校验
|
|
|
|
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { |
|
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); |
|
|
|
if (next_device_code.equals("Q1") || next_device_code.equals("P1")){ |
|
|
|
int number = standardEmptsyPalletSiteDeviceDriver.getNumber(); |
|
|
|
start_device_code = start_device_code + "." + number; |
|
|
|
start_point_code = start_point_code + "." + number; |
|
|
|
} |
|
|
|
} else { |
|
|
|
start_point_code = start_point_code + "." + 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Instruction instdto = new Instruction(); |
|
|
|
instdto.setInstruction_type(acsTask.getTask_type()); |
|
|
|
instdto.setInstruction_id(IdUtil.simpleUUID()); |
|
|
|
instdto.setRoute_plan_code(route_plan_code); |
|
|
|
instdto.setRemark(acsTask.getRemark()); |
|
|
|
instdto.setMaterial(acsTask.getMaterial()); |
|
|
|
instdto.setQuantity(acsTask.getQuantity()); |
|
|
|
instdto.setTask_id(taskid); |
|
|
|
instdto.setTask_code(taskcode); |
|
|
|
instdto.setVehicle_code(vehiclecode); |
|
|
|
instdto.setRoute_plan_code(route_plan_code); |
|
|
|
String now = DateUtil.now(); |
|
|
|
instdto.setCreate_time(now); |
|
|
|
instdto.setCreate_by("auto"); |
|
|
|
instdto.setStart_device_code(start_device_code); |
|
|
|
instdto.setNext_device_code(next_device_code); |
|
|
|
instdto.setStart_point_code(start_point_code); |
|
|
|
instdto.setNext_point_code(next_point_code); |
|
|
|
instdto.setPriority(priority); |
|
|
|
instdto.setInstruction_status("0"); |
|
|
|
instdto.setExecute_device_code(start_point_code); |
|
|
|
instdto.setVehicle_type(vehicleType); |
|
|
|
instdto.setMaterial(acsTask.getMaterial()); |
|
|
|
|
|
|
|
try { |
|
|
|
instructionService.create(instdto); |
|
|
|
} catch (Exception e) { |
|
|
|
acsTask.setRemark(e.getMessage()); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
//创建指令后修改任务状态
|
|
|
|
acsTask.setTask_status("1"); |
|
|
|
taskserver.update(acsTask); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|