rev:驱动

This commit is contained in:
2024-05-22 10:34:36 +08:00
parent d1bad23400
commit 565a068711
9 changed files with 360 additions and 114 deletions

View File

@@ -279,27 +279,46 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
return;
}
instDto = new Instruction();
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code());
if (CollectionUtil.isEmpty(shortPathsList)) {
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 不存在该点的路由信息!"));
return;
}
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String[] str = path.split("->");
List<String> pathList = Arrays.asList(str);
String start_device_code = taskDto.getStart_device_code();
int index = 0;
for (int m = 0; m < pathList.size(); m++) {
if (pathList.get(m).equals(start_device_code)) {
index = m + 1;
break;
List<RouteLineDto> shortPathsList = null;
String start_device_code = null;
String next_device_code = null;
List<DeviceAssignedDto> assignedDtos = deviceAssignedService.queryAssignedByDevice(taskDto.getStart_device_code(), taskDto.getNext_device_code());
if (CollectionUtil.isEmpty(assignedDtos)) {
shortPathsList = routeLineService.getShortPathLines(taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code());
if (CollectionUtil.isEmpty(shortPathsList)) {
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 不存在该点的路由信息!"));
return;
}
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String[] str = path.split("->");
List<String> pathList = Arrays.asList(str);
start_device_code = taskDto.getStart_device_code();
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 {
DeviceAssignedDto assignedDto = null;
if (assignedDtos.size() > 1) {
for (DeviceAssignedDto deviceAssignedDto : assignedDtos) {
String inst_nextDevice_code = deviceAssignedDto.getInst_nextDevice_code();
Instruction inst = instructionService.findReadyInstByEnd(inst_nextDevice_code);
if (ObjectUtil.isEmpty(inst)) {
assignedDto = deviceAssignedDto;
break;
}
}
} else {
assignedDto = assignedDtos.get(0);
}
start_device_code = assignedDto.getDevice_code();
next_device_code = assignedDto.getInst_nextDevice_code();
}
String next_device_code = pathList.get(index);
// int start = 0;
// String start_device_code = pathList.get(start);
// String next_device_code = pathList.get(start + 1);
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
if (nextDevice == null) {
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 未配置指令终点驱动信息, 终点: " + instDto.getNext_device_code()));
@@ -315,8 +334,10 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskService.update(taskDto);
if (nextDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
int nextAddress = Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0);
this.writing(Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(nextAddress, instDto.getInstruction_code(), CommandEnum.COMMAND_1.getValue()));
if (StrUtil.equals(this.getDevice().getRegion(), nextDevice.getRegion())) {
int nextAddress = Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0);
this.writing(Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(nextAddress, instDto.getInstruction_code(), CommandEnum.COMMAND_1.getValue()));
}
}
} catch (Exception e) {
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage()));
@@ -327,9 +348,11 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
String next_device_code = instDto.getNext_device_code();
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
if (nextDevice != null && StrUtil.equals(nextDevice.getDevice_type(), "conveyor")) {
Integer address = Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0);
this.writing(Arrays.asList(ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(instDto.getInstruction_code(), address, CommandEnum.COMMAND_1.getValue()));
this.requireSuccess = true;
if (StrUtil.equals(this.getDevice().getRegion(), nextDevice.getRegion())) {
Integer address = Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0);
this.writing(Arrays.asList(ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(instDto.getInstruction_code(), address, CommandEnum.COMMAND_1.getValue()));
this.requireSuccess = true;
}
}
}
}
@@ -342,7 +365,13 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
} else {
LOCK.lock();
try {
TaskDto taskDto = taskService.findReadyTaskByNextDeviceCode(deviceCode);
Device cacheDevice = deviceAppService.findDeviceByCode(deviceCode);
List<String> checkoutStartDeviceCode = new ArrayList<>();
if (cacheDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) cacheDevice.getDeviceDriver();
checkoutStartDeviceCode = appearanceInspectionScannerConveyorDeviceDriver.getExtraDeviceCodes("checkoutStartDeviceCode");
}
TaskDto taskDto = taskService.findReadyTaskByNextDeviceCode(deviceCode, checkoutStartDeviceCode);
Instruction instDto = instructionService.findReadyInstByEnd(deviceCode);
if (ObjectUtil.isNotEmpty(taskDto) && ObjectUtil.isEmpty(instDto)) {
instDto = new Instruction();
@@ -351,49 +380,72 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 不存在该点的路由信息!"));
return;
}
DeviceAssignedDto assignedDto = assignedDtos.get(0);
DeviceAssignedDto assignedDto = null;
if (assignedDtos.size() > 1) {
for (DeviceAssignedDto deviceAssignedDto : assignedDtos) {
String inst_nextDevice_code = deviceAssignedDto.getInst_nextDevice_code();
Instruction inst = instructionService.findReadyInstByEnd(inst_nextDevice_code);
if (ObjectUtil.isEmpty(inst)) {
assignedDto = deviceAssignedDto;
break;
}
}
} else {
assignedDto = assignedDtos.get(0);
}
if (ObjectUtil.isEmpty(assignedDto)) {
return;
}
String start_device_code = assignedDto.getDevice_code();
String next_device_code = assignedDto.getInst_nextDevice_code();
Instruction inst = instructionService.findReadyInstByEnd(next_device_code);
if (ObjectUtil.isNotEmpty(inst)) {
Device device = deviceAppService.findDeviceByCode(next_device_code);
if (device != null) {
//判断另一个拣选位是否禁用
String pinkDeviceCode = Optional.ofNullable(device.getExtraValue().get("pinkDeviceCode")).map(Objects::toString).orElse("");
Device pinkDevice = deviceAppService.findDeviceByCode(pinkDeviceCode);
if (pinkDevice != null && pinkDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) pinkDevice.getDeviceDriver();
if (appearanceInspectionScannerConveyorDeviceDriver.getMode() == 0) {
String getLinkDeviceCode = Optional.ofNullable(device.getExtraValue().get("getLinkDeviceCode")).map(Objects::toString).orElse("");
if (StrUtil.isNotEmpty(getLinkDeviceCode)) {
next_device_code = getLinkDeviceCode;
Device device = deviceAppService.findDeviceByCode(next_device_code);
if (device != null) {
String pinkDeviceCode = Optional.ofNullable(device.getExtraValue().get("pinkDeviceCode")).map(Objects::toString).orElse("");
Device pinkDevice = deviceAppService.findDeviceByCode(pinkDeviceCode);
if (pinkDevice != null && pinkDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) pinkDevice.getDeviceDriver();
if (appearanceInspectionScannerConveyorDeviceDriver.getMode() == 0) {
return;
}
Instruction inst = instructionService.findReadyInstByEnd(next_device_code);
if (ObjectUtil.isNotEmpty(inst)) {
String pinkDeviceCode2 = Optional.ofNullable(pinkDevice.getExtraValue().get("pinkDeviceCode")).map(Object::toString).orElse("");
Device pinkDevice2 = deviceAppService.findDeviceByCode(pinkDeviceCode2);
if (pinkDevice2 != null && pinkDevice2.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver2 = (AppearanceInspectionScannerConveyorDeviceDriver) pinkDevice2.getDeviceDriver();
if (appearanceInspectionScannerConveyorDeviceDriver2.getMode() == 0) {
String getLinkDeviceCode = Optional.ofNullable(device.getExtraValue().get("getLinkDeviceCode")).map(Objects::toString).orElse("");
Instruction instruction = instructionService.findReadyInstByEnd(getLinkDeviceCode);
if (StrUtil.isNotEmpty(getLinkDeviceCode) && ObjectUtil.isEmpty(instruction)) {
next_device_code = getLinkDeviceCode;
}
}
}
}
}
String start_point_code = null;
if (StrUtil.equals(deviceAppService.findDeviceTypeByCode(start_device_code), "storage")) {
start_point_code = start_device_code + "-" + taskDto.getFrom_y() + "-" + taskDto.getFrom_z();
} else {
start_point_code = start_device_code;
}
setInstruction(instDto, taskDto, start_device_code, start_point_code, next_device_code, next_device_code);
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
if (nextDevice == null) {
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 未配置指令终点驱动信息, 终点: " + instDto.getNext_device_code()));
return;
}
try {
instructionService.create(instDto);
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskService.update(taskDto);
} catch (Exception e) {
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage()));
return;
}
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建出库指令成功,指令号:" + instDto.getInstruction_code() + " , 任务号:" + instDto.getTask_code()));
this.requireSuccess = true;
}
String start_point_code = null;
if (StrUtil.equals(deviceAppService.findDeviceTypeByCode(start_device_code), "storage")) {
start_point_code = start_device_code + "-" + taskDto.getFrom_y() + "-" + taskDto.getFrom_z();
} else {
start_point_code = start_device_code;
}
setInstruction(instDto, taskDto, start_device_code, start_point_code, next_device_code, next_device_code);
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
if (nextDevice == null) {
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 未配置指令终点驱动信息, 终点: " + instDto.getNext_device_code()));
return;
}
try {
instructionService.create(instDto);
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskService.update(taskDto);
} catch (Exception e) {
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage()));
return;
}
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建出库指令成功,指令号:" + instDto.getInstruction_code() + " , 任务号:" + instDto.getTask_code()));
this.requireSuccess = true;
}
} finally {
LOCK.unlock();
@@ -415,9 +467,11 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
String next_device_code = inst.getNext_device_code();
Device next_device = deviceAppService.findDeviceByCode(next_device_code);
if (next_device != null && next_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
Integer address = Optional.ofNullable(next_device.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0);
this.writing(Arrays.asList(ItemProtocol.TO_COMMAND.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey()), Arrays.asList(CommandEnum.COMMAND_1.getValue(), inst.getInstruction_code(), address));
this.requireSuccess = true;
if (StrUtil.equals(this.getDevice().getRegion(), next_device.getRegion())) {
Integer address = Optional.ofNullable(next_device.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0);
this.writing(Arrays.asList(ItemProtocol.TO_COMMAND.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey()), Arrays.asList(CommandEnum.COMMAND_1.getValue(), inst.getInstruction_code(), address));
this.requireSuccess = true;
}
}
}
}

View File

@@ -460,6 +460,20 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
} else {
this.sendPutInfoToPlc(frontInst, backInst);
}
} else if (instanceAppearance(front_start_device) && instanceAppearance(front_next_device)) {
if (ObjectUtil.isEmpty(backInst)) {
List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList");
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice");
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice");
backInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getBackDeviceCodeList, specialGetDevice, specialPutDevice, front_start_device_code);
if (ObjectUtil.isNotEmpty(backInst)) {
String back_start_device_code = backInst.getStart_device_code();
Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code);
this.backWrite(back_start_device, backInst);
} else {
this.sendPutInfoToPlc(frontInst, backInst);
}
}
} else {
//下发前叉放货信息
this.sendPutInfoToPlc(frontInst, backInst);
@@ -500,6 +514,20 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
} else {
this.sendPutInfoToPlc(frontInst, backInst);
}
} else if (instanceAppearance(back_start_device) && instanceAppearance(back_next_device)) {
if (ObjectUtil.isEmpty(backInst)) {
List<String> getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList");
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice");
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice");
frontInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getFrontDeviceCodeList, specialGetDevice, specialPutDevice, back_start_device_code);
if (ObjectUtil.isNotEmpty(frontInst)) {
String front_start_device_code = frontInst.getStart_device_code();
Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code);
this.frontWrite(front_start_device, frontInst);
} else {
this.sendPutInfoToPlc(frontInst, backInst);
}
}
} else {
this.sendPutInfoToPlc(frontInst, backInst);
}
@@ -668,10 +696,64 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
private boolean applySpecialTask() {
List<String> getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList");
List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList");
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice");
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice");
List<Instruction> frontInsts = instructionService.findReadyInstBySpecialDevice(getFrontDeviceCodeList, specialGetDevice, specialPutDevice);
Device front_start_device = null;
Device back_start_device = null;
Instruction frontInst = null;
Instruction backInst = null;
if (CollectionUtil.isNotEmpty(frontInsts)) {
frontInst = frontInsts.get(0);
if (ObjectUtil.isNotEmpty(frontInst)) {
String start_device_code = frontInst.getStart_device_code();
front_start_device = deviceAppService.findDeviceByCode(start_device_code);
if (front_start_device == null) {
return false;
}
backInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getBackDeviceCodeList, specialGetDevice, specialPutDevice, start_device_code);
}
} else {
List<Instruction> backInsts = instructionService.findReadyInstBySpecialDevice(getBackDeviceCodeList, specialGetDevice, specialPutDevice);
if (CollectionUtil.isNotEmpty(backInsts)) {
backInst = backInsts.get(0);
if (ObjectUtil.isNotEmpty(backInst)) {
String back_start_device_code = backInst.getStart_device_code();
back_start_device = deviceAppService.findDeviceByCode(back_start_device_code);
if (back_start_device == null) {
return false;
}
}
}
}
if (ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) {
this.FBWrite(front_start_device, frontInst, backInst);
this.requireSuccess = true;
} else if (ObjectUtil.isNotEmpty(frontInst)) {
this.frontWrite(front_start_device, frontInst);
this.requireSuccess = true;
} else if (ObjectUtil.isNotEmpty(backInst)) {
this.backWrite(back_start_device, backInst);
this.requireSuccess = true;
}
if (ObjectUtil.isEmpty(frontInst) && ObjectUtil.isEmpty(backInst)) {
return false;
}
return true;
}
/**
* 入库
*/
private void applyInTask() {
boolean flag = this.applySpecialTask();
if (flag) {
return;
}
List<String> getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList");
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY");
List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList");
@@ -683,7 +765,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
Device back_start_device = null;
if (CollectionUtil.isNotEmpty(frontInsts)) {
frontInst = frontInsts.get(0);
if (ObjectUtil.isNotEmpty(frontInst) && stackerNum == 2) {
if (ObjectUtil.isNotEmpty(frontInst)) {
String front_start_device_code = frontInst.getStart_device_code();
front_start_device = deviceAppService.findDeviceByCode(front_start_device_code);
if (front_start_device != null) {

View File

@@ -540,4 +540,8 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
Instruction findBusyInstByNextDeviceCode(String getLinkDeviceCode);
Instruction findByVehicleCodeFromCache(String barcode);
List<Instruction> findReadyInstBySpecialDevice(List<String> getDeviceCodeList, List<String> specialGetDevice, List<String> specialPutDevice);
Instruction findReadyInstBySpecialDeviceAndStartDeviceCode(List<String> getDeviceCodeList, List<String> specialGetDevice, List<String> specialPutDevice, String front_start_device_code);
}

View File

@@ -1844,12 +1844,13 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override
public List<Instruction> findReadyInstByStartDeviceCode(List<String> start_device_code_list, String noY) {
String currentNoY = noY == null ? "" : noY;
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex()))
.filter(inst -> start_device_code_list.contains(inst.getStart_device_code()))
.filter(inst -> ObjectUtil.isNotEmpty(inst.getTo_y()) && !noY.contains(String.valueOf(Integer.parseInt(inst.getTo_y()))))
.filter(inst -> (ObjectUtil.isNotEmpty(inst.getTo_y()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getTo_y())))))
.sorted(Comparator.comparing(Instruction::getPriority)
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
.collect(Collectors.toList());
@@ -1857,12 +1858,13 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override
public List<Instruction> findReadyInstByNextDeviceCode(List<String> next_device_code_list, String noY) {
String currentNoY = noY == null ? "" : noY;
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex()))
.filter(inst -> next_device_code_list.contains(inst.getNext_device_code()))
.filter(inst -> ObjectUtil.isNotEmpty(inst.getFrom_y()) && !noY.contains(String.valueOf(Integer.parseInt(inst.getFrom_y()))))
.filter(inst -> ObjectUtil.isNotEmpty(inst.getFrom_y()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getFrom_y()))))
.sorted(Comparator.comparing(Instruction::getPriority)
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
.collect(Collectors.toList());
@@ -1870,11 +1872,12 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override
public List<Instruction> findReadyInstByDeviceCode(List<String> device_code_list, String noY) {
String currentNoY = noY == null ? "" : noY;
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex()))
.filter(inst -> (device_code_list.contains(inst.getStart_device_code()) && ObjectUtil.isNotEmpty(inst.getTo_y()) && !noY.contains(inst.getTo_y())) || (device_code_list.contains(inst.getNext_device_code()) && ObjectUtil.isNotEmpty(inst.getFrom_y()) && !noY.contains(inst.getFrom_y())))
.filter(inst -> (device_code_list.contains(inst.getStart_device_code()) && ObjectUtil.isNotEmpty(inst.getTo_y()) && !currentNoY.contains(inst.getTo_y())) || (device_code_list.contains(inst.getNext_device_code()) && ObjectUtil.isNotEmpty(inst.getFrom_y()) && !currentNoY.contains(inst.getFrom_y())))
.sorted(Comparator.comparing(Instruction::getPriority)
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
.collect(Collectors.toList());
@@ -1882,12 +1885,13 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override
public Instruction findReadyInstByStartDeviceCode(Instruction frontInst, String link_device_code, String noY) {
String currentNoY = noY == null ? "" : noY;
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex()))
.filter(inst -> inst.getStart_device_code().equals(link_device_code))
.filter(inst -> ObjectUtil.isNotEmpty(inst.getTo_y()) && !noY.contains(inst.getTo_y()))
.filter(inst -> ObjectUtil.isNotEmpty(inst.getTo_y()) && !currentNoY.contains(inst.getTo_y()))
.filter(inst -> Integer.parseInt(StringUtil.handleString(inst.getTo_x())) == Integer.parseInt(StringUtil.handleString(frontInst.getTo_x())))
.filter(inst -> (Integer.parseInt(frontInst.getTo_y()) / 4 == Integer.parseInt(inst.getTo_y()) / 4) && (((Integer.parseInt(frontInst.getTo_y()) % 4) + (Integer.parseInt(inst.getTo_y()) % 4) == 2) || (Integer.parseInt(frontInst.getTo_y()) % 4) + (Integer.parseInt(inst.getTo_y()) % 4) == 4))
.filter(inst -> Integer.parseInt(inst.getTo_z()) == Integer.parseInt(frontInst.getTo_z()))
@@ -1898,12 +1902,13 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override
public Instruction findReadyInstByLinkDeviceCodeAndStartDeviceCode(String linkDeviceCode, String noY) {
String currentNoY = noY == null ? "" : noY;
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex()))
.filter(inst -> inst.getStart_device_code().equals(linkDeviceCode))
.filter(inst -> StrUtil.isNotBlank(inst.getTo_y()) && StrUtil.isNotBlank(noY) && !noY.contains(String.valueOf(Integer.parseInt(inst.getTo_y()))))
.filter(inst -> StrUtil.isNotBlank(inst.getTo_y()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getTo_y()))))
.sorted(Comparator.comparing(Instruction::getPriority)
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
.findFirst()
@@ -1912,12 +1917,13 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override
public Instruction findReadyInstByLinkDeviceCodeAndNextDeviceCode(String linkDeviceCode, String noY) {
String currentNoY = noY == null ? "" : noY;
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex()))
.filter(inst -> inst.getNext_device_code().equals(linkDeviceCode))
.filter(inst -> StrUtil.isNotBlank(inst.getFrom_y()) && StrUtil.isNotBlank(noY) && !noY.contains(String.valueOf(Integer.parseInt(inst.getFrom_y()))))
.filter(inst -> StrUtil.isNotBlank(inst.getFrom_y()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getFrom_y()))))
.sorted(Comparator.comparing(Instruction::getPriority)
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
.findFirst()
@@ -1926,12 +1932,13 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override
public Instruction findReadyInstByNextDeviceCode(Instruction frontInst, String link_device_code, String noY) {
String currentNoY = noY == null ? "" : noY;
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex()))
.filter(inst -> inst.getNext_device_code().equals(link_device_code))
.filter(inst -> ObjectUtil.isNotEmpty(inst.getFrom_y()) && !noY.contains(inst.getFrom_y()))
.filter(inst -> ObjectUtil.isNotEmpty(inst.getFrom_y()) && !currentNoY.contains(inst.getFrom_y()))
.filter(inst -> Integer.parseInt(StringUtil.handleString(inst.getFrom_x())) == Integer.parseInt(StringUtil.handleString(frontInst.getFrom_x())))
.filter(inst -> (Integer.parseInt(frontInst.getFrom_y()) / 4 == Integer.parseInt(inst.getFrom_y()) / 4) && (((Integer.parseInt(frontInst.getFrom_y()) % 4) + (Integer.parseInt(inst.getFrom_y()) % 4) == 2) || (Integer.parseInt(frontInst.getFrom_y()) % 4) + (Integer.parseInt(inst.getFrom_y()) % 4) == 4))
.filter(inst -> Integer.parseInt(inst.getFrom_z()) == Integer.parseInt(frontInst.getFrom_z()))
@@ -1991,5 +1998,38 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
.orElse(null);
}
@Override
public List<Instruction> findReadyInstBySpecialDevice(List<String> getDeviceCodeList, List<String> specialGetDevice, List<String> specialPutDevice) {
if (getDeviceCodeList != null && specialGetDevice != null && specialPutDevice != null) {
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex()))
.filter(inst -> getDeviceCodeList.contains(inst.getStart_device_code()) && specialGetDevice.contains(inst.getStart_device_code()))
.filter(inst -> getDeviceCodeList.contains(inst.getNext_device_code()) && specialPutDevice.contains(inst.getNext_device_code()))
.sorted(Comparator.comparing(Instruction::getPriority)
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
.collect(Collectors.toList());
}
return null;
}
@Override
public Instruction findReadyInstBySpecialDeviceAndStartDeviceCode(List<String> getDeviceCodeList, List<String> specialGetDevice, List<String> specialPutDevice, String start_device_code) {
if (getDeviceCodeList != null && specialGetDevice != null && specialPutDevice != null) {
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex()))
.filter(inst -> !inst.getStart_device_code().equals(start_device_code))
.filter(inst -> getDeviceCodeList.contains(inst.getStart_device_code()) && specialGetDevice.contains(inst.getStart_device_code()))
.filter(inst -> getDeviceCodeList.contains(inst.getNext_device_code()) && specialPutDevice.contains(inst.getNext_device_code()))
.sorted(Comparator.comparing(Instruction::getPriority)
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
.findFirst().orElse(null);
}
return null;
}
}

View File

@@ -516,7 +516,7 @@ public interface TaskService extends CommonService<Task> {
*/
TaskDto findByTaskCode(String task_code);
TaskDto findReadyTaskByNextDeviceCode(String next_device_code);
TaskDto findReadyTaskByNextDeviceCode(String next_device_code,List<String> checkoutStartDeviceCode);
List<TaskDto> findReadyTaskByXDeviceCode(List<String> xDeviceCodeList, String noY);

View File

@@ -1545,12 +1545,13 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
}
@Override
public TaskDto findReadyTaskByNextDeviceCode(String next_device_code) {
public TaskDto findReadyTaskByNextDeviceCode(String next_device_code, List<String> checkoutStartDeviceCode) {
return Optional.ofNullable(this.tasks)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(taskDto -> TaskStatusEnum.READY.getIndex().equals(taskDto.getTask_status()))
.filter(taskDto -> taskDto.getNext_device_code().equals(next_device_code))
.filter(taskDto -> !checkoutStartDeviceCode.contains(taskDto.getStart_device_code()))
.sorted(Comparator.comparing(TaskDto::getPriority)
.thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
.findFirst()
@@ -1631,12 +1632,13 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
@Override
public List<TaskDto> findReadyTaskByXDeviceCode(List<String> xDeviceCodeList, String noY) {
String currentNoY = noY == null ? "" : noY;
return Optional.ofNullable(this.tasks)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(taskDto -> xDeviceCodeList.contains(taskDto.getStart_device_code()))
.filter(taskDto -> xDeviceCodeList.contains(taskDto.getNext_device_code()))
.filter(taskDto -> StrUtil.isNotEmpty(noY) && StrUtil.isNotBlank(taskDto.getFrom_y()) && StrUtil.isNotBlank(taskDto.getTo_y()) && !noY.contains(String.valueOf(Integer.parseInt(taskDto.getFrom_y()))) && !noY.contains(String.valueOf(Integer.parseInt(taskDto.getTo_y()))))
.filter(taskDto -> StrUtil.isNotBlank(taskDto.getFrom_y()) && StrUtil.isNotBlank(taskDto.getTo_y()) && !currentNoY.contains(String.valueOf(Integer.parseInt(taskDto.getFrom_y()))) && !currentNoY.contains(String.valueOf(Integer.parseInt(taskDto.getTo_y()))))
.sorted(Comparator.comparing(TaskDto::getPriority)
.thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))
.collect(Collectors.toList());
@@ -1644,12 +1646,13 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
@Override
public TaskDto findReadyTaskByFrontTask(TaskDto frontTaskDto, List<String> xDeviceCodeList, String backNoY) {
String currentBackNoY = backNoY == null ? "" : backNoY;
return Optional.ofNullable(this.tasks)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(taskDto -> xDeviceCodeList.contains(taskDto.getStart_device_code()))
.filter(taskDto -> xDeviceCodeList.contains(taskDto.getNext_device_code()))
.filter(taskDto -> StrUtil.isNotEmpty(backNoY) && !backNoY.contains(String.valueOf(Integer.parseInt(taskDto.getFrom_y()))) && !backNoY.contains(String.valueOf(Integer.parseInt(taskDto.getTo_y()))))
.filter(taskDto -> !currentBackNoY.contains(String.valueOf(Integer.parseInt(taskDto.getFrom_y()))) && !currentBackNoY.contains(String.valueOf(Integer.parseInt(taskDto.getTo_y()))))
.filter(taskDto -> Integer.parseInt(frontTaskDto.getFrom_x()) == Integer.parseInt(taskDto.getFrom_x()))
.filter(taskDto -> Integer.parseInt(frontTaskDto.getFrom_z()) == Integer.parseInt(taskDto.getFrom_z()))
.filter(taskDto -> Integer.parseInt(frontTaskDto.getTo_x()) == Integer.parseInt(taskDto.getTo_x()))
@@ -1669,13 +1672,14 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
String front_to_x = frontTask.getTo_x();
String front_to_y = frontTask.getTo_y();
String front_to_z = frontTask.getTo_z();
String currentBackNoY = backNoY == null ? "" : backNoY;
return Optional.ofNullable(this.tasks)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(taskDto -> !taskDto.getTask_code().equals(front_task_code))
.filter(taskDto -> taskDto.getFrom_x().equals(front_from_x) && taskDto.getFrom_z().equals(front_from_z))
.filter(taskDto -> taskDto.getTo_x().equals(front_to_x) && taskDto.getTo_z().equals(front_to_z))
.filter(taskDto -> StrUtil.isNotBlank(backNoY) && StrUtil.isNotBlank(taskDto.getFrom_y()) && StrUtil.isNotBlank(taskDto.getTo_y()) && !backNoY.contains(String.valueOf(Integer.parseInt(taskDto.getFrom_y()))) && !backNoY.contains(String.valueOf(Integer.parseInt(taskDto.getTo_y()))))
.filter(taskDto -> StrUtil.isNotBlank(taskDto.getFrom_y()) && StrUtil.isNotBlank(taskDto.getTo_y()) && !currentBackNoY.contains(String.valueOf(Integer.parseInt(taskDto.getFrom_y()))) && !currentBackNoY.contains(String.valueOf(Integer.parseInt(taskDto.getTo_y()))))
.filter(taskDto -> (Integer.parseInt(front_to_y) / 4 == Integer.parseInt(taskDto.getTo_y()) / 4) && (((Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(taskDto.getTo_y()) % 4) == 2) || (Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(taskDto.getTo_y()) % 4) == 4))
.filter(taskDto -> (Integer.parseInt(front_from_y) / 4 == Integer.parseInt(taskDto.getFrom_y()) / 4) && (((Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(taskDto.getFrom_y()) % 4) == 2) || (Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(taskDto.getFrom_y()) % 4) == 4))
.sorted(Comparator.comparing(TaskDto::getPriority)
@@ -1693,12 +1697,13 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
String front_to_x = frontTask.getTo_x();
String front_to_y = frontTask.getTo_y();
String front_to_z = frontTask.getTo_z();
String currentBackNoY = backNoY == null ? "" : backNoY;
return Optional.ofNullable(this.tasks)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(taskDto -> !taskDto.getTask_code().equals(front_task_code))
.filter(taskDto -> taskDto.getFrom_x().equals(front_from_x) && taskDto.getFrom_z().equals(front_from_z))
.filter(taskDto -> StrUtil.isNotBlank(backNoY) && StrUtil.isNotBlank(taskDto.getFrom_y()) && StrUtil.isNotBlank(taskDto.getTo_y()) && !backNoY.contains(String.valueOf(Integer.parseInt(taskDto.getFrom_y()))) && !backNoY.contains(String.valueOf(Integer.parseInt(taskDto.getTo_y()))))
.filter(taskDto -> StrUtil.isNotBlank(taskDto.getFrom_y()) && StrUtil.isNotBlank(taskDto.getTo_y()) && !currentBackNoY.contains(String.valueOf(Integer.parseInt(taskDto.getFrom_y()))) && !currentBackNoY.contains(String.valueOf(Integer.parseInt(taskDto.getTo_y()))))
.filter(taskDto -> (Integer.parseInt(front_from_y) / 4 == Integer.parseInt(taskDto.getFrom_y()) / 4) && (((Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(taskDto.getFrom_y()) % 4) == 2) || (Integer.parseInt(front_from_y) % 4) + (Integer.parseInt(taskDto.getFrom_y()) % 4) == 4))
.sorted(Comparator.comparing(TaskDto::getPriority)
.thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))))

View File

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.hivemq.client.mqtt.MqttClient;
import com.hivemq.client.mqtt.MqttGlobalPublishFilter;
import com.hivemq.client.mqtt.datatypes.MqttQos;
import com.hivemq.client.mqtt.lifecycle.MqttClientReconnector;
import com.hivemq.client.mqtt.mqtt3.Mqtt3AsyncClient;
import io.micrometer.core.instrument.util.NamedThreadFactory;
import lombok.extern.slf4j.Slf4j;
@@ -168,9 +169,9 @@ public class MqttService {
.addDisconnectedListener((context -> {
Throwable cause = context.getCause();
log.error("mqtt client disconnected , {}", cause.getMessage());
//MqttClientReconnector reconnect = context.getReconnector();
//reconnect.reconnect(true);
//reconnect.delay(RECONNECT_DELAY, TimeUnit.MILLISECONDS);
MqttClientReconnector reconnect = context.getReconnector();
reconnect.reconnect(true);
reconnect.delay(RECONNECT_DELAY, TimeUnit.MILLISECONDS);
}))
.automaticReconnect()
.initialDelay(RECONNECT_DELAY, TimeUnit.MILLISECONDS)