fix: 同排移库问题,补码校验

This commit is contained in:
2024-04-22 15:16:03 +08:00
parent 6766c47ced
commit a09e15adf9
5 changed files with 152 additions and 155 deletions

View File

@@ -464,8 +464,10 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
requireSucess = true;
return true;
} else {
//查看是否存在输送线到对接为的指令
Instruction byNextDeviceCodeFromCache = instructionService.findByNextDeviceCodeFromCache(this.device_code);
//补码生成堆垛机对接位到货架的指令
if (StrUtil.isNotEmpty(hand_barcode)) {
if (StrUtil.isNotEmpty(hand_barcode) && ObjectUtil.isEmpty(byNextDeviceCodeFromCache)) {
TaskDto taskDtoHandCode = taskserver.findByVehicleCodeCodeAndReady(hand_barcode);
if (Objects.nonNull(taskDtoHandCode)) {
String taskid = taskDtoHandCode.getTask_id();
@@ -518,79 +520,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
return false;
}
}
/**
* 目前没有从标准输送线为起点的任务
*/
//判断是否有相同起点的,任务状态就绪的任务
/**
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
if (ObjectUtil.isNotNull(taskdto)) {
//判断指令的起点和当前的设备号相同
if (!taskdto.getStart_device_code().equals(device_code)) {
return false;
}
//判断当前任务号是否存在指令
String taskid = taskdto.getTask_id();
String taskcode = taskdto.getTask_code();
String priority = taskdto.getPriority();
String start_point_code = taskdto.getStart_point_code();
String start_device_code = taskdto.getStart_device_code();
String route_plan_code = taskdto.getRoute_plan_code();
String next_device_code = "";
String containerType = "";
String interactionJson = taskdto.getInteraction_json();
if (StrUtil.isNotEmpty(interactionJson)) {
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
containerType = interactionJsonDTO.getContainerType();
}
String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code());
if (StrUtil.isEmpty(this_coevice_code)) {
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.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_coevice_code;
}
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList) || shortPathsList.size() < 1) {
throw new RuntimeException("路由不通!");
}
Device startdevice = deviceAppservice.findDeviceByCode(start_device_code);
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code);
String next_point_code;
if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) {
next_point_code = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.getTo_z();
} else {
next_point_code = next_device_code;
}
Instruction instdto = new Instruction();
packageData(instdto, route_plan_code, taskdto, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code, priority, containerType);
log.error("=================================,{}", instdto.getCreate_by());
try {
instructionService.create(instdto);
} catch (Exception e) {
e.printStackTrace();
log.error("指令创建失败!,{}", e.getMessage());
return false;
}
return updateTask(taskdto, nextdevice, instdto);
}
**/
}
return false;

View File

@@ -333,6 +333,14 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
*/
Instruction findByDeviceCodeFromCache(String devicecode);
/**
* 根据终点查询指令
* @param devicecode
* @return
*/
Instruction findByNextDeviceCodeFromCache(String devicecode);
/**
* 根据设备id查询
*

View File

@@ -1520,6 +1520,29 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
return null;
}
@Override
public Instruction findByNextDeviceCodeFromCache(String devicecode) {
List<Instruction> instructionList = instructions;
ListUtil.sort(
instructionList,
new Comparator<Instruction>() {
@Override
public int compare(Instruction o1, Instruction o2) {
return o1.getCreate_time().compareTo(o2.getCreate_time());
}
});
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()) {
Instruction inst = it.next();
if (StrUtil.equals(devicecode, inst.getNext_device_code())) {
return inst;
}
}
return null;
}
@Override
public List<Instruction> findAllInstFromCache() {
return instructions;

View File

@@ -568,11 +568,14 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
// 判断起点终点设备类型
String startDeviceType = deviceAppService.findDeviceTypeByCode(dto.getStart_device_code());
String nextDeviceType = deviceAppService.findDeviceTypeByCode(dto.getNext_device_code());
if (routeLineService
.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code)
.size()
== 0) {
throw new BadRequestException(dto.getStart_point_code() + "->" + dto.getNext_point_code() + " " + LangProcess.msg("route_isNull"));
// 同一排转库任务不做路由校验
if (!(StrUtil.equals(DeviceType.storage.toString(), startDeviceType) && StrUtil.equals(DeviceType.storage.toString(), nextDeviceType) && StrUtil.equals(start_device_code, next_device_code))) {
if (routeLineService
.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code)
.size()
== 0) {
throw new BadRequestException(dto.getStart_point_code() + "->" + dto.getNext_point_code() + " " + LangProcess.msg("route_isNull"));
}
}
String createTaskCheck = paramService.findByCode(AcsConfig.CREATETASKCHECK).getValue();
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);

View File

@@ -69,49 +69,15 @@ public class CreateDDJInst {
if (CollUtil.isNotEmpty(taskDtoList)) {
taskDtoList = sortInst(taskDtoList);
for (TaskDto taskDto : taskDtoList) {
List<RouteLineDto> list =
routeLineService.getShortPathLines(
taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code());
if (ObjectUtils.isEmpty(list)) {
throw new BadRequestException("路由不通");
}
RouteLineDto routeLineDto = list.get(0);
String[] path = routeLineDto.getPath().split("->");
List<String> pathlist = Arrays.asList(path);
String deviceType = appService.findDeviceByCode(pathlist.get(1)).getDevice_type();
if (pathlist.size() < 3 || (!deviceType.equals(DeviceType.stacker.name()))) {
return;
}
Device deviceByCode = appService.findDeviceByCode(pathlist.get(1));
if (ObjectUtils.isEmpty(deviceByCode)) {
log.error("没有找到DDJ设备");
return;
}
StandardStackerDeviceDriver standardStackerDeviceDriver;
if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) {
standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver();
// if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getMove() == 1 || standardStackerDeviceDriver.getCommand() != 0) {
// log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code());
// return;
// }
}
String next_device_code = taskDto.getNext_device_code();
Device nextDevice = appService.findDeviceByCode(next_device_code);
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
// if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
// beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
// if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) {
// log.error("输送机,{}未联机或执行中", next_device_code);
// return;
// }
// }
String next_device_code = "";
Device nextDevice = null;
List<String> pathlist;
Device deviceByCode = null;
String taskid = taskDto.getTask_id();
String taskcode = taskDto.getTask_code();
String task_type = taskDto.getTask_type();
String vehiclecode = taskDto.getVehicle_code();
String storage_task_type = taskDto.getStorage_task_type();
String priority = taskDto.getPriority();
String is_send = taskDto.getIs_send();
String start_device_code = taskDto.getStart_device_code();
Device startDevice = appService.findDeviceByCode(start_device_code);
@@ -134,40 +100,102 @@ public class CreateDDJInst {
String start_height = taskDto.getStart_height();
String next_height = taskDto.getNext_height();
/**
* 开始平均分配
*/
String this_coevice_code = taskserver.queryAssignedByDeviceCode(start_device_code, next_device_code);
if (StrUtil.isEmpty(this_coevice_code)) {
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
RouteLineDto routeLineDto1 = shortPathsList.get(0);
String path1 = routeLineDto1.getPath();
String[] str = path1.split("->");
List<String> pathlist1 = Arrays.asList(str);
int index = 0;
for (int m = 0; m < pathlist1.size(); m++) {
String deviceType1 = appService.findDeviceByCode(pathlist1.get(m)).getDevice_type();
if (deviceType1.equals(DeviceType.stacker.name())) {
index = m + 1;
break;
//同排的货位移库任务
if (StrUtil.equals(taskDto.getStart_device_code(), taskDto.getNext_device_code())) {
//通过起点找路由
List<RouteLineDto> list =
routeLineService.getShortPathLinesByCode(
taskDto.getStart_device_code(), taskDto.getRoute_plan_code());
if (ObjectUtils.isEmpty(list)) {
throw new BadRequestException("路由不通");
}
RouteLineDto routeLineDto = list.get(0);
String[] path = routeLineDto.getPath().split("->");
pathlist = Arrays.asList(path);
deviceByCode = appService.findDeviceByCode(pathlist.get(1));
if (ObjectUtils.isEmpty(deviceByCode)) {
log.error("没有找到DDJ设备");
return;
}
StandardStackerDeviceDriver standardStackerDeviceDriver;
if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) {
standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver();
if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getMove() == 1 || standardStackerDeviceDriver.getCommand() != 0) {
log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code());
return;
}
}
next_device_code = start_device_code;
nextDevice = appService.findDeviceByCode(next_device_code);
} else {
List<RouteLineDto> list =
routeLineService.getShortPathLines(
taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code());
if (ObjectUtils.isEmpty(list)) {
throw new BadRequestException("路由不通");
}
RouteLineDto routeLineDto = list.get(0);
String[] path = routeLineDto.getPath().split("->");
pathlist = Arrays.asList(path);
deviceByCode = appService.findDeviceByCode(pathlist.get(1));
if (ObjectUtils.isEmpty(deviceByCode)) {
log.error("没有找到DDJ设备");
return;
}
StandardStackerDeviceDriver standardStackerDeviceDriver;
if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) {
standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver();
if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getMove() == 1 || standardStackerDeviceDriver.getCommand() != 0) {
log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code());
return;
}
}
next_device_code = taskDto.getNext_device_code();
nextDevice = appService.findDeviceByCode(next_device_code);
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) {
log.error("输送机,{}未联机或执行中", next_device_code);
return;
}
}
/**
* 开始平均分配
*/
String this_coevice_code = taskserver.queryAssignedByDeviceCode(start_device_code, next_device_code);
if (StrUtil.isEmpty(this_coevice_code)) {
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
RouteLineDto routeLineDto1 = shortPathsList.get(0);
String path1 = routeLineDto1.getPath();
String[] str = path1.split("->");
List<String> pathlist1 = Arrays.asList(str);
int index = 0;
for (int m = 0; m < pathlist1.size(); m++) {
String deviceType1 = appService.findDeviceByCode(pathlist1.get(m)).getDevice_type();
if (deviceType1.equals(DeviceType.stacker.name())) {
index = m + 1;
break;
}
/*if (pathlist1.get(m).equals(start_device_code)) {
}*/
}
next_device_code = pathlist1.get(index);
} else {
next_device_code = this_coevice_code;
}
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList) || shortPathsList.size() < 1) {
throw new RuntimeException("路由不通!");
}
next_device_code = pathlist1.get(index);
} else {
next_device_code = this_coevice_code;
}
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList) || shortPathsList.size()<1) {
throw new RuntimeException("路由不通!");
}
// 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 + "-" + taskDto.getTo_y() + "-" + taskDto.getTo_z();
} else {
@@ -268,19 +296,27 @@ public class CreateDDJInst {
}
}
int max = 0;
//非同排的路径
for (Instruction inst : insts) {
List<RouteLineDto> shortPathLines = routeLineService.getShortPathLines(inst.getStart_device_code(), inst.getNext_device_code(),
inst.getRoute_plan_code());
if (CollUtil.isEmpty(shortPathLines) || shortPathLines.size() < 1) {
log.error("没有此路由");
throw new BadRequestException("路由不通");
List<RouteLineDto> shortPathLines =new ArrayList<>();
if (!(inst.getStart_device_code().equals(inst.getNext_device_code()))) {
shortPathLines = routeLineService.getShortPathLines(inst.getStart_device_code(), inst.getNext_device_code(),
inst.getRoute_plan_code());
if (CollUtil.isEmpty(shortPathLines) || shortPathLines.size() < 1) {
log.error("没有此路由");
throw new BadRequestException("路由不通");
}
}else {
//同排路径
shortPathLines = routeLineService.getShortPathLinesByCode(inst.getStart_device_code(), inst.getRoute_plan_code());
if (CollUtil.isEmpty(shortPathLines) || shortPathLines.size() < 1) {
log.error("没有此路由");
throw new BadRequestException("路由不通");
}
}
RouteLineDto routeLineDto1 = (RouteLineDto) shortPathLines.get(0);
String[] path1 = routeLineDto1.getPath().split("->");
List<String> pathlist1 = Arrays.asList(path1);
if (pathlist1.size() < 3 || pathlist1.get(1).equals(DeviceType.stacker.name())) {
//return;
}
if (pathlist1.get(1).equals(pathlist.get(1))) {
max++;
}
@@ -371,8 +407,6 @@ public class CreateDDJInst {
continue;
}
}
}
}
}