|
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
import org.nl.acs.AcsConfig; |
|
|
|
import org.nl.acs.instruction.service.InstructionService; |
|
|
|
import org.nl.acs.instruction.service.dto.Instruction; |
|
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
@ -13,6 +14,8 @@ import org.nl.acs.route.service.RouteLineService; |
|
|
|
import org.nl.acs.route.service.dto.RouteLineDto; |
|
|
|
import org.nl.acs.task.service.TaskService; |
|
|
|
import org.nl.acs.task.service.dto.TaskDto; |
|
|
|
import org.nl.modules.system.service.ParamService; |
|
|
|
import org.nl.modules.system.service.dto.ParamDto; |
|
|
|
import org.nl.modules.wql.util.SpringContextHolder; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
@ -31,128 +34,139 @@ 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); |
|
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
|
|
|
|
|
List<TaskDto> list = taskserver.queryAll("task_status = '0'"); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
TaskDto acsTask = list.get(i); |
|
|
|
if(StrUtil.equals(acsTask.getTask_type(),"7") && !StrUtil.startWith(acsTask.getTask_code(), "-") ){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
String taskid = acsTask.getTask_id(); |
|
|
|
String taskcode = acsTask.getTask_code(); |
|
|
|
String task_type = acsTask.getTask_type(); |
|
|
|
String vehiclecode = acsTask.getVehicle_code(); |
|
|
|
String storage_task_type = acsTask.getStorage_task_type(); |
|
|
|
String priority = acsTask.getPriority(); |
|
|
|
String is_send = acsTask.getIs_send(); |
|
|
|
ParamService paramService = SpringContextHolder.getBean(ParamService.class); |
|
|
|
|
|
|
|
ParamDto sendInst = paramService.findByCode(AcsConfig.SEND_INST); |
|
|
|
if ("1".equals(sendInst.getValue())) { |
|
|
|
TaskService taskserver = SpringContextHolder.getBean(TaskService.class); |
|
|
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); |
|
|
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); |
|
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
|
|
|
|
|
List<TaskDto> list = taskserver.queryAll("task_status = '0'"); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
TaskDto acsTask = list.get(i); |
|
|
|
if (StrUtil.equals(acsTask.getTask_type(), "7") && !StrUtil.startWith(acsTask.getTask_code(), "-")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
String taskid = acsTask.getTask_id(); |
|
|
|
String taskcode = acsTask.getTask_code(); |
|
|
|
String task_type = acsTask.getTask_type(); |
|
|
|
String vehiclecode = acsTask.getVehicle_code(); |
|
|
|
String storage_task_type = acsTask.getStorage_task_type(); |
|
|
|
String priority = acsTask.getPriority(); |
|
|
|
String is_send = acsTask.getIs_send(); |
|
|
|
|
|
|
|
String start_device_code = acsTask.getStart_device_code(); |
|
|
|
String start_point_code = acsTask.getStart_point_code(); |
|
|
|
String start_device_code = acsTask.getStart_device_code(); |
|
|
|
String start_point_code = acsTask.getStart_point_code(); |
|
|
|
|
|
|
|
String put_device_code = acsTask.getPut_device_code(); |
|
|
|
String put_point_code = acsTask.getPut_point_code(); |
|
|
|
String put_device_code = acsTask.getPut_device_code(); |
|
|
|
String put_point_code = acsTask.getPut_point_code(); |
|
|
|
|
|
|
|
String next_device_code = acsTask.getNext_device_code(); |
|
|
|
String next_point_code = acsTask.getNext_point_code(); |
|
|
|
String next_device_code = acsTask.getNext_device_code(); |
|
|
|
String next_point_code = acsTask.getNext_point_code(); |
|
|
|
|
|
|
|
String start_point_code2 = acsTask.getStart_point_code2(); |
|
|
|
String start_device_code2 = acsTask.getStart_device_code2(); |
|
|
|
String start_point_code2 = acsTask.getStart_point_code2(); |
|
|
|
String start_device_code2 = acsTask.getStart_device_code2(); |
|
|
|
|
|
|
|
String next_point_code2 = acsTask.getNext_point_code2(); |
|
|
|
String next_device_code2 = acsTask.getNext_device_code2(); |
|
|
|
String next_point_code2 = acsTask.getNext_point_code2(); |
|
|
|
String next_device_code2 = acsTask.getNext_device_code2(); |
|
|
|
|
|
|
|
|
|
|
|
String route_plan_code = acsTask.getRoute_plan_code(); |
|
|
|
String vehicleType = acsTask.getVehicle_type(); |
|
|
|
String agv_system_type = acsTask.getAgv_system_type(); |
|
|
|
String route_plan_code = acsTask.getRoute_plan_code(); |
|
|
|
String vehicleType = acsTask.getVehicle_type(); |
|
|
|
String agv_system_type = acsTask.getAgv_system_type(); |
|
|
|
|
|
|
|
String start_height = acsTask.getStart_height(); |
|
|
|
String next_height = acsTask.getNext_height(); |
|
|
|
|
|
|
|
if (StrUtil.equals(is_send, "0")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
//校验路由关系
|
|
|
|
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(is_send, "0")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
//校验路由关系
|
|
|
|
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); |
|
|
|
if (ObjectUtils.isEmpty(shortPathsList)) { |
|
|
|
acsTask.setRemark("路由不通无法生成指令"); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
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; |
|
|
|
if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
next_device_code = pathlist.get(index); |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
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); |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
Instruction instdto = new Instruction(); |
|
|
|
instdto.setInstruction_type(task_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); |
|
|
|
String now = DateUtil.now(); |
|
|
|
instdto.setCreate_time(now); |
|
|
|
instdto.setCreate_by("auto"); |
|
|
|
|
|
|
|
instdto.setStart_device_code(start_device_code); |
|
|
|
instdto.setStart_point_code(start_point_code); |
|
|
|
instdto.setPut_device_code(put_device_code); |
|
|
|
instdto.setPut_point_code(put_point_code); |
|
|
|
instdto.setNext_device_code(next_device_code); |
|
|
|
instdto.setNext_point_code(next_point_code); |
|
|
|
|
|
|
|
instdto.setStart_point_code2(start_point_code2); |
|
|
|
instdto.setStart_device_code2(start_device_code2); |
|
|
|
instdto.setNext_point_code2(next_point_code2); |
|
|
|
instdto.setNext_device_code2(next_device_code2); |
|
|
|
|
|
|
|
instdto.setPriority(priority); |
|
|
|
instdto.setInstruction_status("0"); |
|
|
|
instdto.setExecute_device_code(start_point_code); |
|
|
|
instdto.setVehicle_type(vehicleType); |
|
|
|
instdto.setAgv_system_type(agv_system_type); |
|
|
|
instdto.setAgv_inst_type("1"); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
instructionService.create(instdto); |
|
|
|
} catch (Exception e) { |
|
|
|
acsTask.setRemark(e.getMessage()); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} |
|
|
|
//创建指令后修改任务状态
|
|
|
|
acsTask.setTask_status("1"); |
|
|
|
taskserver.update(acsTask); |
|
|
|
|
|
|
|
Instruction instdto = new Instruction(); |
|
|
|
instdto.setInstruction_type(task_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); |
|
|
|
String now = DateUtil.now(); |
|
|
|
instdto.setCreate_time(now); |
|
|
|
instdto.setCreate_by("auto"); |
|
|
|
|
|
|
|
instdto.setStart_device_code(start_device_code); |
|
|
|
instdto.setStart_point_code(start_point_code); |
|
|
|
instdto.setPut_device_code(put_device_code); |
|
|
|
instdto.setPut_point_code(put_point_code); |
|
|
|
instdto.setNext_device_code(next_device_code); |
|
|
|
instdto.setNext_point_code(next_point_code); |
|
|
|
|
|
|
|
instdto.setStart_point_code2(start_point_code2); |
|
|
|
instdto.setStart_device_code2(start_device_code2); |
|
|
|
instdto.setNext_point_code2(next_point_code2); |
|
|
|
instdto.setNext_device_code2(next_device_code2); |
|
|
|
|
|
|
|
instdto.setPriority(priority); |
|
|
|
instdto.setInstruction_status("0"); |
|
|
|
instdto.setExecute_device_code(start_point_code); |
|
|
|
instdto.setVehicle_type(vehicleType); |
|
|
|
instdto.setAgv_system_type(agv_system_type); |
|
|
|
instdto.setAgv_inst_type("1"); |
|
|
|
|
|
|
|
|
|
|
|
instdto.setStart_height(start_height); |
|
|
|
instdto.setNext_height(next_height); |
|
|
|
|
|
|
|
try { |
|
|
|
instructionService.create(instdto); |
|
|
|
} catch (Exception e) { |
|
|
|
acsTask.setRemark(e.getMessage()); |
|
|
|
taskserver.updateByCodeFromCache(acsTask); |
|
|
|
continue; |
|
|
|
} |
|
|
|
//创建指令后修改任务状态
|
|
|
|
acsTask.setTask_status("1"); |
|
|
|
taskserver.update(acsTask); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|