Browse Source

rev:acs拆分指令优化

master
刘先源 2 months ago
parent
commit
732eed01a7
  1. 3
      acs2/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java
  2. 11
      acs2/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
  3. 32
      acs2/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java
  4. 44
      acs2/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java

3
acs2/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java

@ -14,7 +14,8 @@ public enum DriverTypeEnum {
PHOTOELECTRIC_DETECTION_DEVICE_DRIVER(3, "photoelectric_detection_station", "光电检测站点", "station"), PHOTOELECTRIC_DETECTION_DEVICE_DRIVER(3, "photoelectric_detection_station", "光电检测站点", "station"),
XIANGONG_AGV_DEVICE_DRIVER(4, "xg_agv", "仙工AGV", "agv"), XIANGONG_AGV_DEVICE_DRIVER(4, "xg_agv", "仙工AGV", "agv"),
RGV_DEVICE_DRIVER(5, "rgv_station", "RGV", "rgv"), RGV_DEVICE_DRIVER(5, "rgv_station", "RGV", "rgv"),
ELEVATOR_DRIVER(6, "standard_elevator", "电梯", "elevator"); ELEVATOR_DRIVER(6, "standard_elevator", "电梯", "elevator"),
CONVEYOR_CONTROL(7, "standard_conveyor_control", "标准版-输送线", "conveyor");
//驱动索引 //驱动索引
private int index; private int index;
//驱动编码 //驱动编码

11
acs2/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java

@ -224,14 +224,18 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override @Override
public void create(Instruction dto) throws Exception { public void create(Instruction dto) throws Exception {
// 指令表
WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
// 格式化操作
dto = format(dto); dto = format(dto);
String task_code = dto.getTask_code(); String task_code = dto.getTask_code();
TaskDto task = taskService.findByCodeFromCache(task_code); TaskDto task = taskService.findByCodeFromCache(task_code);
String excutetype = null; String excutetype = null;
WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
String currentUsername = SecurityUtils.getCurrentUsername(); String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now(); String now = DateUtil.now();
if (StrUtil.isEmpty(dto.getRoute_plan_code())) { if (StrUtil.isEmpty(dto.getRoute_plan_code())) {
dto.setRoute_plan_code(task.getRoute_plan_code()); dto.setRoute_plan_code(task.getRoute_plan_code());
} }
@ -245,10 +249,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
dto.setInstruction_id(IdUtil.simpleUUID()); dto.setInstruction_id(IdUtil.simpleUUID());
} }
dto.setInstruction_type(task.getTask_type()); dto.setInstruction_type(task.getTask_type());
// 校验路由
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code()); List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code());
if (ObjectUtils.isEmpty(shortPathsList)) { if (ObjectUtils.isEmpty(shortPathsList)) {
throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通"); throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通");
} }
// 判断是否已经存在指令
String type = shortPathsList.get(0).getType(); String type = shortPathsList.get(0).getType();
if (!StrUtil.equals(type, "0")) { if (!StrUtil.equals(type, "0")) {
JSONObject instcheckjson = instwo.query(" instruction_status <2 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0); JSONObject instcheckjson = instwo.query(" instruction_status <2 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0);
@ -271,7 +278,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
dto.setStart_parent_code(task.getStart_parent_code()); dto.setStart_parent_code(task.getStart_parent_code());
dto.setNext_parent_code(task.getNext_parent_code()); dto.setNext_parent_code(task.getNext_parent_code());
// 判断任务类型(要下发的系统)
try { try {
// != 0 为agv任务 // != 0 为agv任务
if (!StrUtil.equals(type, "0")) { if (!StrUtil.equals(type, "0")) {

32
acs2/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -250,7 +250,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
String plan_code = dto.getRoute_plan_code(); String plan_code = dto.getRoute_plan_code();
//判断起点终点设备类型 //判断起点终点设备类型
if (routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code).isEmpty()) { if (routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code).size()==0) {
throw new Exception(dto.getStart_point_code() + "->" + dto.getNext_point_code() + "路由不通!"); throw new Exception(dto.getStart_point_code() + "->" + dto.getNext_point_code() + "路由不通!");
} }
@ -357,29 +357,13 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
} }
} }
// 获取路由路线并拆分
/**
* 开始平均分解校验
*/
String this_device_code = this.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); List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code);
RouteLineDto routeLineDto = shortPathsList.get(0); RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath(); String path = routeLineDto.getPath();
String type = routeLineDto.getType(); String type = routeLineDto.getType();
String[] str = path.split("->"); String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str); List<String> pathlist = Arrays.asList(str);
if (StrUtil.equals(acsTask.getTask_type(), "2")) {
for (int j = 0; j < pathlist.size(); j++) {
if (j == 0) {
compound_task_data = pathlist.get(j).trim();
} else {
compound_task_data = compound_task_data + "->" + pathlist.get(j).trim();
}
}
next_device_code = pathlist.get(pathlist.size() - 1);
} else {
int index = 0; int index = 0;
for (int m = 0; m < pathlist.size(); m++) { for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) { if (pathlist.get(m).equals(start_device_code)) {
@ -388,13 +372,17 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
} }
} }
next_device_code = pathlist.get(index); next_device_code = pathlist.get(index);
}
if (StrUtil.equals(deviceAppService.findDeviceTypeByCode(next_device_code), "storage")) {
// next_point_code = next_device_code + CommonFinalParam.HYPHEN_ + acsTask.getTo_y() + CommonFinalParam.HYPHEN_ + acsTask.getTo_z();
} else { } else {
next_device_code = this_device_code; next_point_code = next_device_code;
} }
//校验路由关系 //校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); List<RouteLineDto> shortPathsList2= routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList)) { if (ObjectUtils.isEmpty(shortPathsList2)) {
throw new BadRequestException("路由不通无法生成指令。"); throw new BadRequestException("路由不通无法生成指令。");
} }

44
acs2/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java

@ -32,14 +32,22 @@ public class AutoCreateInst {
* 根据任务状态创建指令生成下一条指令 * 根据任务状态创建指令生成下一条指令
*/ */
public void run() throws Exception { public void run() throws Exception {
// 任务接口
TaskService taskserver = SpringContextHolder.getBean(TaskService.class); TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
// 指令接口
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
// 路由接口
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
// 系统参数接口
ParamService acsConfigService = SpringContextHolder.getBean(ParamService.class); ParamService acsConfigService = SpringContextHolder.getBean(ParamService.class);
List<TaskDto> list = taskserver.findReadyTask(); // 设备接口
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
// 查询所有就绪的任务
List<TaskDto> list = taskserver.findReadyTask();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
TaskDto acsTask = list.get(i); TaskDto acsTask = list.get(i);
// 获取任务对应的字段参数
String taskid = acsTask.getTask_id(); String taskid = acsTask.getTask_id();
String taskcode = acsTask.getTask_code(); String taskcode = acsTask.getTask_code();
String vehiclecode = acsTask.getVehicle_code(); String vehiclecode = acsTask.getVehicle_code();
@ -69,8 +77,12 @@ public class AutoCreateInst {
taskserver.updateByCodeFromCache(acsTask); taskserver.updateByCodeFromCache(acsTask);
continue; continue;
} }
// 找指令状态 小于 完成(2)的指令
List<Instruction> instructions = instructionService.queryAll("instruction_status < 2"); List<Instruction> instructions = instructionService.queryAll("instruction_status < 2");
// 系统参数maxInstNumber(最大指令数量)
String maxInstnumber = acsConfigService.findByCode(AcsConfig.MAX_INST_NUMBER).getValue(); String maxInstnumber = acsConfigService.findByCode(AcsConfig.MAX_INST_NUMBER).getValue();
// 不允许超过最大系统指令数量
if (ObjectUtils.isNotEmpty(maxInstnumber)) { if (ObjectUtils.isNotEmpty(maxInstnumber)) {
if (instructions.size() >= Integer.parseInt(maxInstnumber)) { if (instructions.size() >= Integer.parseInt(maxInstnumber)) {
log.info("已达到系统参数配置的最大指令数 [" + maxInstnumber + "] ,无法生成指令。"); log.info("已达到系统参数配置的最大指令数 [" + maxInstnumber + "] ,无法生成指令。");
@ -80,29 +92,13 @@ 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); List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code);
RouteLineDto routeLineDto = shortPathsList.get(0); RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath(); String path = routeLineDto.getPath();
String type = routeLineDto.getType(); String type = routeLineDto.getType();
String[] str = path.split("->"); String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str); List<String> pathlist = Arrays.asList(str);
if (StrUtil.equals(acsTask.getTask_type(), "2")) {
for (int j = 0; j < pathlist.size(); j++) {
if (j == 0) {
compound_task_data = pathlist.get(j).trim();
} else {
compound_task_data = compound_task_data + "->" + pathlist.get(j).trim();
}
}
next_device_code = pathlist.get(pathlist.size() - 1);
} else {
int index = 0; int index = 0;
for (int m = 0; m < pathlist.size(); m++) { for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) { if (pathlist.get(m).equals(start_device_code)) {
@ -111,13 +107,16 @@ public class AutoCreateInst {
} }
} }
next_device_code = pathlist.get(index); next_device_code = pathlist.get(index);
}
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
// next_point_code = next_device_code + CommonFinalParam.HYPHEN_ + acsTask.getTo_y() + CommonFinalParam.HYPHEN_ + acsTask.getTo_z();
} else { } else {
next_device_code = this_device_code; next_point_code = next_device_code;
} }
//校验路由关系 //校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); List<RouteLineDto> shortPathsList2 = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList)) { if (ObjectUtils.isEmpty(shortPathsList2)) {
log.info("任务 [" + taskcode + "] 路由不通无法生成指令。"); log.info("任务 [" + taskcode + "] 路由不通无法生成指令。");
acsTask.setRemark("任务 [" + taskcode + "] 路由不通无法生成指令。"); acsTask.setRemark("任务 [" + taskcode + "] 路由不通无法生成指令。");
taskserver.updateByCodeFromCache(acsTask); taskserver.updateByCodeFromCache(acsTask);
@ -127,6 +126,7 @@ public class AutoCreateInst {
if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) { if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
continue; continue;
} }
Device startdevice = appService.findDeviceByCode(start_device_code); Device startdevice = appService.findDeviceByCode(start_device_code);
Device nextdevice = appService.findDeviceByCode(next_device_code); Device nextdevice = appService.findDeviceByCode(next_device_code);
if (ObjectUtils.isEmpty(startdevice)) { if (ObjectUtils.isEmpty(startdevice)) {

Loading…
Cancel
Save