fix:修复多线程导致无法锁定同排站点

This commit is contained in:
2026-05-01 17:00:37 +08:00
parent a0834a4ee7
commit 8a7cd4332c
8 changed files with 459 additions and 324 deletions

View File

@@ -3,16 +3,14 @@ package org.nl.system.service.quartz.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.common.base.CommonFinalParam;
import org.apache.commons.collections4.CollectionUtils;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.enums.InstructionStatusEnum;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.enums.TaskStatusEnum;
import org.nl.acs.task.enums.TaskTypeEnum;
import org.nl.acs.task.service.TaskService;
@@ -22,11 +20,15 @@ import org.nl.config.SpringContextHolder;
import org.nl.system.service.lucene.LuceneExecuteLogService;
import org.nl.system.service.lucene.dto.LuceneLogDto;
import org.nl.system.service.lucene.impl.LuceneExecuteLogServiceImpl;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@@ -34,252 +36,392 @@ import java.util.stream.Collectors;
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class AutoCreateInst {
private final RedissonClient redissonClient;
/**
* 根据任务状态创建指令、生成下一条指令
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
*/
public void run() throws Exception {
log.info("自动生成指令" + DateUtil.now());
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogServiceImpl.class);
List<TaskDto> list = taskserver.queryAllByStatus("0");
for (int i = 0; i < list.size(); i++) {
TaskDto acsTask = list.get(i);
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.AGV_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
continue;
}
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.Truss_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
continue;
}
Boolean flag=false;
String taskid = acsTask.getTask_id();
String taskcode = acsTask.getTask_code();
String task_type = acsTask.getTask_type();
String vehiclecode = acsTask.getVehicle_code();
String priority = acsTask.getPriority();
String is_send = acsTask.getIs_send();
String start_device_code = acsTask.getStart_device_code();
String start_point=null;
if(start_device_code.contains("BCPRK")){
String[] parts = start_device_code.split("-", 2);
start_point=parts[0];
}else if(start_device_code.contains("CPRK")){
String[] parts = start_device_code.split("-", 2);
start_point=parts[0];
}
if(start_point != null) {
if (start_point.equals("CPRK1")) {
List<TaskDto> list1 = taskserver.queryAllByStatus("1");
for (int j = 0; j < list1.size(); j++) {
String start_device_code1 = list1.get(j).getStart_device_code();
String[] parts = start_device_code1.split("-", 2);
start_point = parts[0];
if (start_point.equals("CPRK1")) {
flag = true;
}
}
} else if (start_point.equals("CPRK2")) {
List<TaskDto> list1 = taskserver.queryAllByStatus("1");
for (int j = 0; j < list1.size(); j++) {
String start_device_code1 = list1.get(j).getStart_device_code();
String[] parts = start_device_code1.split("-", 2);
start_point = parts[0];
if (start_point.equals("CPRK2")) {
flag = true;
}
}
} else if (start_point.equals("CPRK3")) {
List<TaskDto> list1 = taskserver.queryAllByStatus("1");
for (int j = 0; j < list1.size(); j++) {
String start_device_code1 = list1.get(j).getStart_device_code();
String[] parts = start_device_code1.split("-", 2);
start_point = parts[0];
if (start_point.equals("CPRK3")) {
flag = true;
}
}
} else if (start_point.equals("CPRK4")) {
List<TaskDto> list1 = taskserver.queryAllByStatus("1");
for (int j = 0; j < list1.size(); j++) {
String start_device_code1 = list1.get(j).getStart_device_code();
String[] parts = start_device_code1.split("-", 2);
start_point = parts[0];
if (start_point.equals("CPRK4")) {
flag = true;
}
}
} else if (start_point.equals("CPRK5")) {
List<TaskDto> list1 = taskserver.queryAllByStatus("1");
for (int j = 0; j < list1.size(); j++) {
String start_device_code1 = list1.get(j).getStart_device_code();
String[] parts = start_device_code1.split("-", 2);
start_point = parts[0];
if (start_point.equals("CPRK5")) {
flag = true;
}
}
}else if (start_point.equals("BCPRK1")) {
List<TaskDto> list1 = taskserver.queryAllByStatus("1");
for (int j = 0; j < list1.size(); j++) {
String start_device_code1 = list1.get(j).getStart_device_code();
String[] parts = start_device_code1.split("-", 2);
start_point = parts[0];
if (start_point.equals("BCPRK1")) {
flag = true;
}
}
} else if (start_point.equals("BCPRK2")) {
List<TaskDto> list1 = taskserver.queryAllByStatus("1");
for (int j = 0; j < list1.size(); j++) {
String start_device_code1 = list1.get(j).getStart_device_code();
String[] parts = start_device_code1.split("-", 2);
start_point = parts[0];
if (start_point.equals("BCPRK2")) {
flag = true;
}
}
} else if (start_point.equals("BCPRK3")) {
List<TaskDto> list1 = taskserver.queryAllByStatus("1");
for (int j = 0; j < list1.size(); j++) {
String start_device_code1 = list1.get(j).getStart_device_code();
String[] parts = start_device_code1.split("-", 2);
start_point = parts[0];
if (start_point.equals("BCPRK3")) {
flag = true;
}
}
} else if (start_point.equals("BCPRK4")) {
List<TaskDto> list1 = taskserver.queryAllByStatus("1");
for (int j = 0; j < list1.size(); j++) {
String start_device_code1 = list1.get(j).getStart_device_code();
String[] parts = start_device_code1.split("-", 2);
start_point = parts[0];
if (start_point.equals("BCPRK4")) {
flag = true;
}
}
} else if (start_point.equals("BCPRK5")) {
List<TaskDto> list1 = taskserver.queryAllByStatus("1");
for (int j = 0; j < list1.size(); j++) {
String start_device_code1 = list1.get(j).getStart_device_code();
String[] parts = start_device_code1.split("-", 2);
start_point = parts[0];
if (start_point.equals("BCPRK5")) {
flag = true;
}
}
}
}
if (flag){
continue;
}
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 next_device_code = acsTask.getNext_device_code();
String next_point_code = acsTask.getNext_point_code();
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();
String car_type=acsTask.getCar_type();
String car_width=acsTask.getCar_width();
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);
// public void run() throws Exception {
// log.info("自动生成指令" + DateUtil.now());
// TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
// InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
// RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
// DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
// LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogServiceImpl.class);
// List<TaskDto> list = taskserver.queryAllByStatus("0");
// for (int i = 0; i < list.size(); i++) {
// TaskDto acsTask = list.get(i);
// if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.AGV_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
// continue;
// }
// if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.Truss_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
// continue;
// }
// Boolean flag=false;
// String taskid = acsTask.getTask_id();
// String taskcode = acsTask.getTask_code();
// String task_type = acsTask.getTask_type();
// String vehiclecode = acsTask.getVehicle_code();
// String priority = acsTask.getPriority();
// String is_send = acsTask.getIs_send();
//
// String start_device_code = acsTask.getStart_device_code();
// String start_point=null;
// if(start_device_code.contains("BCPRK")){
// String[] parts = start_device_code.split("-", 2);
// start_point=parts[0];
// }else if(start_device_code.contains("CPRK")){
// String[] parts = start_device_code.split("-", 2);
// start_point=parts[0];
// }
// if(start_point != null) {
// if (start_point.equals("CPRK1")) {
// List<TaskDto> list1 = taskserver.queryAllByStatus("1");
// for (int j = 0; j < list1.size(); j++) {
// String start_device_code1 = list1.get(j).getStart_device_code();
// String[] parts = start_device_code1.split("-", 2);
// start_point = parts[0];
// if (start_point.equals("CPRK1")) {
// flag = true;
// }
// }
// } else if (start_point.equals("CPRK2")) {
// List<TaskDto> list1 = taskserver.queryAllByStatus("1");
// for (int j = 0; j < list1.size(); j++) {
// String start_device_code1 = list1.get(j).getStart_device_code();
// String[] parts = start_device_code1.split("-", 2);
// start_point = parts[0];
// if (start_point.equals("CPRK2")) {
// flag = true;
// }
// }
// } else if (start_point.equals("CPRK3")) {
// List<TaskDto> list1 = taskserver.queryAllByStatus("1");
// for (int j = 0; j < list1.size(); j++) {
// String start_device_code1 = list1.get(j).getStart_device_code();
// String[] parts = start_device_code1.split("-", 2);
// start_point = parts[0];
// if (start_point.equals("CPRK3")) {
// flag = true;
// }
// }
// } else if (start_point.equals("CPRK4")) {
// List<TaskDto> list1 = taskserver.queryAllByStatus("1");
// for (int j = 0; j < list1.size(); j++) {
// String start_device_code1 = list1.get(j).getStart_device_code();
// String[] parts = start_device_code1.split("-", 2);
// start_point = parts[0];
// if (start_point.equals("CPRK4")) {
// flag = true;
// }
// }
// } else if (start_point.equals("CPRK5")) {
// List<TaskDto> list1 = taskserver.queryAllByStatus("1");
// for (int j = 0; j < list1.size(); j++) {
// String start_device_code1 = list1.get(j).getStart_device_code();
// String[] parts = start_device_code1.split("-", 2);
// start_point = parts[0];
// if (start_point.equals("CPRK5")) {
// flag = true;
// }
// }
// }else if (start_point.equals("BCPRK1")) {
// List<TaskDto> list1 = taskserver.queryAllByStatus("1");
// for (int j = 0; j < list1.size(); j++) {
// String start_device_code1 = list1.get(j).getStart_device_code();
// String[] parts = start_device_code1.split("-", 2);
// start_point = parts[0];
// if (start_point.equals("BCPRK1")) {
// flag = true;
// }
// }
// } else if (start_point.equals("BCPRK2")) {
// List<TaskDto> list1 = taskserver.queryAllByStatus("1");
// for (int j = 0; j < list1.size(); j++) {
// String start_device_code1 = list1.get(j).getStart_device_code();
// String[] parts = start_device_code1.split("-", 2);
// start_point = parts[0];
// if (start_point.equals("BCPRK2")) {
// flag = true;
// }
// }
// } else if (start_point.equals("BCPRK3")) {
// List<TaskDto> list1 = taskserver.queryAllByStatus("1");
// for (int j = 0; j < list1.size(); j++) {
// String start_device_code1 = list1.get(j).getStart_device_code();
// String[] parts = start_device_code1.split("-", 2);
// start_point = parts[0];
// if (start_point.equals("BCPRK3")) {
// flag = true;
// }
// }
// } else if (start_point.equals("BCPRK4")) {
// List<TaskDto> list1 = taskserver.queryAllByStatus("1");
// for (int j = 0; j < list1.size(); j++) {
// String start_device_code1 = list1.get(j).getStart_device_code();
// String[] parts = start_device_code1.split("-", 2);
// start_point = parts[0];
// if (start_point.equals("BCPRK4")) {
// flag = true;
// }
// }
// } else if (start_point.equals("BCPRK5")) {
// List<TaskDto> list1 = taskserver.queryAllByStatus("1");
// for (int j = 0; j < list1.size(); j++) {
// String start_device_code1 = list1.get(j).getStart_device_code();
// String[] parts = start_device_code1.split("-", 2);
// start_point = parts[0];
// if (start_point.equals("BCPRK5")) {
// flag = true;
// }
// }
// }
// }
// if (flag){
// continue;
// }
// 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 next_device_code = acsTask.getNext_device_code();
// String next_point_code = acsTask.getNext_point_code();
//
// 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();
// String car_type=acsTask.getCar_type();
// String car_width=acsTask.getCar_width();
//
//
// if (StrUtil.equals(is_send, "0")) {
// continue;
// }
//
// if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
//// //校验路由关系
//// 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(), CommonFinalParam.ONE)) {
//// 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;
//// }
//// }
//// 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(SecurityUtils.getCurrentNickName());
//
// instdto.setStart_device_code(start_point_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.setCar_type(car_type);
// instdto.setCar_width(car_width);
// instdto.setPriority(priority);
// instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
// instdto.setExecute_device_code(start_point_code);
// instdto.setVehicle_type(vehicleType);
// instdto.setAgv_system_type(agv_system_type);
// instdto.setStart_height(start_height);
// instdto.setNext_height(next_height);
//
// try {
// instructionService.create(instdto);
// } catch (Exception e) {
// acsTask.setRemark(e.getMessage());
// taskserver.updateByCodeFromCache(acsTask);
// LuceneLogDto logDto = LuceneLogDto.builder()
// .device_code("定时创建指令失败")
// .content(e.getMessage())
// .build();
// logDto.setLog_level(2);
// luceneExecuteLogService.deviceExecuteLog(logDto);
// 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;
// }
// }
// next_device_code = pathlist.get(index);
// //创建指令后修改任务状态
// acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
// acsTask.setUpdate_time(DateUtil.now());
// taskserver.update(acsTask);
//
// }
// }
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;
/**
* 根据任务状态创建指令、生成下一条指令
*/
public void run() throws Exception {
log.info("自动生成指令开始: {}", DateUtil.now());
RLock lock = redissonClient.getLock("autoGenInstructionLock");
boolean locked = false;
try {
locked = lock.tryLock(0, 5, TimeUnit.SECONDS); // 不等待锁持有5秒自动释放
if (!locked) {
log.debug("未获取到分布式锁,跳过本次执行");
return;
}
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(SecurityUtils.getCurrentNickName());
instdto.setStart_device_code(start_point_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.setCar_type(car_type);
instdto.setCar_width(car_width);
instdto.setPriority(priority);
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
instdto.setExecute_device_code(start_point_code);
instdto.setVehicle_type(vehicleType);
instdto.setAgv_system_type(agv_system_type);
instdto.setStart_height(start_height);
instdto.setNext_height(next_height);
try {
instructionService.create(instdto);
} catch (Exception e) {
acsTask.setRemark(e.getMessage());
taskserver.updateByCodeFromCache(acsTask);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("定时创建指令失败")
.content(e.getMessage())
.build();
logDto.setLog_level(2);
luceneExecuteLogService.deviceExecuteLog(logDto);
continue;
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogServiceImpl.class);
//按优先级降序task_code升序
List<TaskDto> list = taskserver.queryAllByStatus("0");
if (CollectionUtils.isEmpty(list)) {
return;
}
Set<String> busyStartPoints = taskserver.queryAllByStatus("1").stream()
.map(t -> extractStartPoint(t.getStart_device_code()))
.filter(Objects::nonNull)
.collect(Collectors.toSet());
for (TaskDto acsTask : list) {
if (isNonBlockingTaskType(acsTask)) {
continue; // AGV/Truss且不以"-"开头,跳过,继续看下一个
}
if (StrUtil.equals(acsTask.getIs_send(), "0")) {
break;
}
//起始点冲突(同一起点已有执行中任务)
String startPoint = extractStartPoint(acsTask.getStart_device_code());
if (startPoint != null && busyStartPoints.contains(startPoint)) {
break;
}
try {
createInstruction(acsTask, appService, instructionService, taskserver);
} catch (Exception e) {
acsTask.setRemark(e.getMessage());
taskserver.updateByCodeFromCache(acsTask);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("定时创建指令失败")
.content(e.getMessage())
.build();
logDto.setLog_level(2);
luceneExecuteLogService.deviceExecuteLog(logDto);
break;
}
break;
}
} catch (Exception e) {
log.error("自动生成指令异常", e);
} finally {
if (locked && lock.isHeldByCurrentThread()) {
try {
lock.unlock();
} catch (Exception e) {
log.error("释放分布式锁异常", e);
}
}
//创建指令后修改任务状态
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
acsTask.setUpdate_time(DateUtil.now());
taskserver.update(acsTask);
}
}
/**
* 判断是否属于无需生成指令的任务类型
*/
private boolean isNonBlockingTaskType(TaskDto acsTask) {
String taskType = acsTask.getTask_type();
String taskCode = acsTask.getTask_code();
boolean isAgv = StrUtil.equals(taskType, TaskTypeEnum.AGV_Task.getIndex())
&& !StrUtil.startWith(taskCode, "-");
boolean isTruss = StrUtil.equals(taskType, TaskTypeEnum.Truss_Task.getIndex())
&& !StrUtil.startWith(taskCode, "-");
return isAgv || isTruss;
}
/**
* 从设备编码中提取起点区域CPRK1, BCPRK2
*/
private String extractStartPoint(String startDeviceCode) {
if (startDeviceCode == null) {
return null;
}
if (startDeviceCode.contains("BCPRK") || startDeviceCode.contains("CPRK")) {
return startDeviceCode.split("-")[0];
}
return null;
}
/**
* 封装指令创建与任务状态更新
*/
private void createInstruction(TaskDto acsTask, DeviceAppService appService,
InstructionService instructionService, TaskService taskserver) throws Exception {
String next_device_code = acsTask.getNext_device_code();
String next_point_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;
}
Instruction instdto = new Instruction();
instdto.setInstruction_type(acsTask.getTask_type());
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(acsTask.getRoute_plan_code());
instdto.setRemark(acsTask.getRemark());
instdto.setMaterial(acsTask.getMaterial());
instdto.setQuantity(acsTask.getQuantity());
instdto.setTask_id(acsTask.getTask_id());
instdto.setTask_code(acsTask.getTask_code());
instdto.setVehicle_code(acsTask.getVehicle_code());
instdto.setCreate_time(DateUtil.now());
instdto.setCreate_by(SecurityUtils.getCurrentNickName());
instdto.setStart_device_code(acsTask.getStart_point_code());
instdto.setStart_point_code(acsTask.getStart_point_code());
instdto.setPut_device_code(acsTask.getPut_device_code());
instdto.setPut_point_code(acsTask.getPut_point_code());
instdto.setNext_device_code(next_device_code);
instdto.setNext_point_code(next_point_code);
instdto.setCar_type(acsTask.getCar_type());
instdto.setCar_width(acsTask.getCar_width());
instdto.setPriority(acsTask.getPriority());
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
instdto.setExecute_device_code(acsTask.getStart_point_code());
instdto.setVehicle_type(acsTask.getVehicle_type());
instdto.setAgv_system_type(acsTask.getAgv_system_type());
instdto.setStart_height(acsTask.getStart_height());
instdto.setNext_height(acsTask.getNext_height());
instructionService.create(instdto);
// 更新任务状态为执行中
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
acsTask.setUpdate_time(DateUtil.now());
taskserver.update(acsTask);
}
}

View File

@@ -6,7 +6,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: dev
active: prod
# active: prod
jackson:
time-zone: GMT+8