|
|
@ -76,6 +76,7 @@ import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.CopyOnWriteArrayList; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -381,7 +382,8 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper, |
|
|
|
.eq(InstructionMybatis::getTask_code, dto.getTask_code())); |
|
|
|
if (CollUtil.isNotEmpty(instructionMybatis) && instructionMybatis.stream().anyMatch(inst -> inst.getStart_device_code() |
|
|
|
.equals(start_device_code))) { |
|
|
|
return; |
|
|
|
// throw new BadRequestException("已经存在相同任务号的起点!");
|
|
|
|
//return;
|
|
|
|
} |
|
|
|
} |
|
|
|
String currentUsername = SecurityUtils.getCurrentNickName(); |
|
|
@ -505,7 +507,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper, |
|
|
|
} catch (Exception e) { |
|
|
|
dto.setSend_status("2"); |
|
|
|
e.printStackTrace(); |
|
|
|
log.error(""); |
|
|
|
log.error("创建指令出错, {}", e.getMessage()); |
|
|
|
} |
|
|
|
InstructionMybatis entity = ConvertUtil.convert(dto, InstructionMybatis.class); |
|
|
|
instructionMapper.insert(entity); |
|
|
@ -1755,7 +1757,49 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper, |
|
|
|
.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()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getTo_y()))))) |
|
|
|
.sorted(Comparator.comparing(Instruction::getPriority) |
|
|
|
//.sorted(Comparator.comparing(Instruction::getPriority)
|
|
|
|
.sorted(Comparator.comparingInt((Instruction inst) -> Integer.parseInt(getNumericPart(inst.getNext_device_code())) % 4) |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getTo_z()) ? "0" : inst.getTo_z())) |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getTo_y()) ? "0" : inst.getTo_y())) |
|
|
|
.thenComparing(Comparator.comparing(Instruction::getPriority)) |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Instruction> findDeepReadyInstByStartDeviceCode(List<String> start_device_code_list, String noY) { |
|
|
|
// String currentNoY = noY == null ? "" : noY;
|
|
|
|
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); |
|
|
|
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()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getTo_y()))))) |
|
|
|
.filter(inst -> Integer.parseInt(getNumericPart(inst.getNext_device_code())) % 4 == 1 || Integer.parseInt(getNumericPart(inst.getNext_device_code())) % 4 == 0) |
|
|
|
//.sorted(Comparator.comparing(Instruction::getPriority)
|
|
|
|
.sorted(Comparator.comparingInt((Instruction inst) -> Integer.parseInt(getNumericPart(inst.getNext_device_code())) % 4) |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getTo_z()) ? "0" : inst.getTo_z())) |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getTo_y()) ? "0" : inst.getTo_y())) |
|
|
|
.thenComparing(Comparator.comparing(Instruction::getPriority)).reversed() |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Instruction> findShallowReadyInstByStartDeviceCode(List<String> start_device_code_list, String noY) { |
|
|
|
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); |
|
|
|
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()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getTo_y()))))) |
|
|
|
.filter(inst -> Integer.parseInt(getNumericPart(inst.getNext_device_code())) % 4 == 2 || Integer.parseInt(getNumericPart(inst.getNext_device_code())) % 4 == 3) |
|
|
|
.sorted(Comparator.comparingInt((Instruction inst) -> Integer.parseInt(getNumericPart(inst.getNext_device_code())) % 4) |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getTo_z()) ? "0" : inst.getTo_z())) |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getTo_y()) ? "0" : inst.getTo_y())) |
|
|
|
.thenComparing(Comparator.comparing(Instruction::getPriority)).reversed() |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
@ -1770,11 +1814,60 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper, |
|
|
|
.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()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getFrom_y())))) |
|
|
|
.sorted(Comparator.comparing(Instruction::getPriority) |
|
|
|
// .sorted(Comparator.comparing(Instruction::getPriority)
|
|
|
|
.sorted(Comparator.comparingInt((Instruction inst) -> Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4).reversed() |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getFrom_z()) ? "0" : inst.getFrom_z())) |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getFrom_y()) ? "0" : inst.getFrom_y())) |
|
|
|
.thenComparing(Comparator.comparing(Instruction::getPriority)) |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Instruction> findDeepReadyInstByNextDeviceCode(List<String> next_device_code_list, String noY) { |
|
|
|
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); |
|
|
|
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()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getFrom_y())))) |
|
|
|
.filter(inst -> Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4 == 1 || Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4 == 0) |
|
|
|
.sorted(Comparator.comparingInt((Instruction inst) -> Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4).reversed() |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getFrom_z()) ? "0" : inst.getFrom_z())) |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getFrom_y()) ? "0" : inst.getFrom_y())) |
|
|
|
.thenComparing(Comparator.comparing(Instruction::getPriority)).reversed() |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Instruction> findShallowReadyInstByNextDeviceCode(List<String> next_device_code_list, String noY) { |
|
|
|
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); |
|
|
|
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()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getFrom_y())))) |
|
|
|
.filter(inst -> Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4 == 2 || Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 3 == 0) |
|
|
|
.sorted(Comparator.comparingInt((Instruction inst) -> Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4).reversed() |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getFrom_z()) ? "0" : inst.getFrom_z())) |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getFrom_y()) ? "0" : inst.getFrom_y())) |
|
|
|
.thenComparing(Comparator.comparing(Instruction::getPriority)) |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
private String getNumericPart(String device_c0de) { |
|
|
|
Pattern pattern = Pattern.compile("\\d+"); |
|
|
|
Matcher matcher = pattern.matcher(device_c0de); |
|
|
|
if (matcher.find()) { |
|
|
|
return matcher.group(); |
|
|
|
} |
|
|
|
return "0"; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Instruction> findReadyInstByDeviceCode(List<String> device_code_list, String noY) { |
|
|
|
//String currentNoY = noY == null ? "" : noY;
|
|
|
@ -1820,7 +1913,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper, |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Instruction findReadyInstByLinkDeviceCodeAndStartDeviceCode(String linkDeviceCode, String noY) { |
|
|
|
public Instruction findReadyInstByLinkDeviceCodeAndStartDeviceCode(String linkDeviceCode, String noY, List<String> getDeviceCodeList) { |
|
|
|
// String currentNoY = noY == null ? "" : noY;
|
|
|
|
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); |
|
|
|
return Optional.ofNullable(this.instructions) |
|
|
@ -1828,6 +1921,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper, |
|
|
|
.stream() |
|
|
|
.filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex())) |
|
|
|
.filter(inst -> inst.getStart_device_code().equals(linkDeviceCode)) |
|
|
|
.filter(inst -> getDeviceCodeList.contains(inst.getStart_device_code())) |
|
|
|
.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")))) |
|
|
@ -1836,16 +1930,93 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper, |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Instruction findReadyInstByLinkDeviceCodeAndNextDeviceCode(String linkDeviceCode, String noY) { |
|
|
|
//String currentNoY = noY == null ? "" : noY;
|
|
|
|
public Instruction findDeepReadyInstByLinkDeviceCodeAndStartDeviceCode(String linkDeviceCode, String noY, List<String> getDeviceCodeList) { |
|
|
|
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); |
|
|
|
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 -> getDeviceCodeList.contains(inst.getStart_device_code())) |
|
|
|
.filter(inst -> StrUtil.isNotBlank(inst.getTo_y()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getTo_y())))) |
|
|
|
.filter(inst -> Integer.parseInt(getNumericPart(inst.getNext_device_code())) % 4 == 1 || Integer.parseInt(getNumericPart(inst.getNext_device_code())) % 4 == 0) |
|
|
|
.sorted(Comparator.comparing(Instruction::getPriority) |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.findFirst() |
|
|
|
.orElse(null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Instruction findShallowReadyInstByLinkDeviceCodeAndStartDeviceCode(String linkDeviceCode, String noY, List<String> getDeviceCodeList) { |
|
|
|
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); |
|
|
|
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 -> getDeviceCodeList.contains(inst.getStart_device_code())) |
|
|
|
.filter(inst -> StrUtil.isNotBlank(inst.getTo_y()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getTo_y())))) |
|
|
|
.filter(inst -> Integer.parseInt(getNumericPart(inst.getNext_device_code())) % 4 == 2 || Integer.parseInt(getNumericPart(inst.getNext_device_code())) % 4 == 3) |
|
|
|
.sorted(Comparator.comparing(Instruction::getPriority).reversed() |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.findFirst() |
|
|
|
.orElse(null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Instruction findReadyInstByLinkDeviceCodeAndNextDeviceCode(String linkDeviceCode, String noY, List<String> getDeviceCodeList) { |
|
|
|
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); |
|
|
|
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 -> getDeviceCodeList.contains(inst.getNext_device_code())) |
|
|
|
.filter(inst -> StrUtil.isNotBlank(inst.getFrom_y()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getFrom_y())))) |
|
|
|
.sorted(Comparator.comparing(Instruction::getPriority) |
|
|
|
.sorted(Comparator.comparingInt((Instruction inst) -> Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4).reversed() |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getFrom_z()) ? "0" : inst.getFrom_z())) |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getFrom_y()) ? "0" : inst.getFrom_y())) |
|
|
|
.thenComparing(Comparator.comparing(Instruction::getPriority)) |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.findFirst() |
|
|
|
.orElse(null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Instruction findDeepReadyInstByLinkDeviceCodeAndNextDeviceCode(String linkDeviceCode, String noY, List<String> getDeviceCodeList) { |
|
|
|
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); |
|
|
|
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 -> getDeviceCodeList.contains(inst.getNext_device_code())) |
|
|
|
.filter(inst -> StrUtil.isNotBlank(inst.getFrom_y()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getFrom_y())))) |
|
|
|
.filter(inst -> Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4 == 1 || Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4 == 0) |
|
|
|
.sorted(Comparator.comparingInt((Instruction inst) -> Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4).reversed() |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getFrom_z()) ? "0" : inst.getFrom_z())) |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getFrom_y()) ? "0" : inst.getFrom_y())) |
|
|
|
.thenComparing(Comparator.comparing(Instruction::getPriority)) |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.findFirst() |
|
|
|
.orElse(null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Instruction findShallowReadyInstByLinkDeviceCodeAndNextDeviceCode(String linkDeviceCode, String noY, List<String> getDeviceCodeList) { |
|
|
|
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); |
|
|
|
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 -> getDeviceCodeList.contains(inst.getNext_device_code())) |
|
|
|
.filter(inst -> StrUtil.isNotBlank(inst.getFrom_y()) && !currentNoY.contains(String.valueOf(Integer.parseInt(inst.getFrom_y())))) |
|
|
|
.filter(inst -> Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4 == 2 || Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4 == 3) |
|
|
|
.sorted(Comparator.comparingInt((Instruction inst) -> Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4).reversed() |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getFrom_z()) ? "0" : inst.getFrom_z())) |
|
|
|
.thenComparing(inst -> Integer.parseInt(ObjectUtil.isEmpty(inst.getFrom_y()) ? "0" : inst.getFrom_y())) |
|
|
|
.thenComparing(Comparator.comparing(Instruction::getPriority)) |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.findFirst() |
|
|
|
.orElse(null); |
|
|
@ -1882,6 +2053,66 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper, |
|
|
|
.findFirst().orElse(null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Instruction findDeepReadyInstByNextDeviceCode(Instruction frontInst, String link_device_code, String noY, List<String> getDeviceCodeList) { |
|
|
|
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); |
|
|
|
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()) && !currentNoY.contains(inst.getFrom_y())) |
|
|
|
.filter(inst -> Integer.parseInt(StringUtil.handleString(inst.getFrom_x())) == Integer.parseInt(StringUtil.handleString(frontInst.getFrom_x()))) |
|
|
|
.filter(inst -> getDeviceCodeList.contains(inst.getNext_device_code())) |
|
|
|
.filter(inst -> { |
|
|
|
int frontY = Integer.parseInt(frontInst.getFrom_y()); |
|
|
|
int instY = Integer.parseInt(inst.getFrom_y()); |
|
|
|
int frontGroup = (frontY - 1) / 4; |
|
|
|
int instGroup = (instY - 1) / 4; |
|
|
|
if (frontGroup != instGroup) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
int frontMod = frontY % 4; |
|
|
|
int instMod = instY % 4; |
|
|
|
return (frontMod + instMod == 2 || frontMod + instMod == 4); |
|
|
|
}) |
|
|
|
.filter(inst -> Integer.parseInt(inst.getFrom_z()) == Integer.parseInt(frontInst.getFrom_z())) |
|
|
|
.filter(inst -> Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4 == 0 || Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4 == 1) |
|
|
|
.sorted(Comparator.comparing(Instruction::getPriority).reversed() |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.findFirst().orElse(null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Instruction findShallowReadyInstByNextDeviceCode(Instruction frontInst, String link_device_code, String noY, List<String> getDeviceCodeList) { |
|
|
|
Set<String> currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); |
|
|
|
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()) && !currentNoY.contains(inst.getFrom_y())) |
|
|
|
.filter(inst -> Integer.parseInt(StringUtil.handleString(inst.getFrom_x())) == Integer.parseInt(StringUtil.handleString(frontInst.getFrom_x()))) |
|
|
|
.filter(inst -> getDeviceCodeList.contains(inst.getNext_device_code())) |
|
|
|
.filter(inst -> { |
|
|
|
int frontY = Integer.parseInt(frontInst.getFrom_y()); |
|
|
|
int instY = Integer.parseInt(inst.getFrom_y()); |
|
|
|
int frontGroup = (frontY - 1) / 4; |
|
|
|
int instGroup = (instY - 1) / 4; |
|
|
|
if (frontGroup != instGroup) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
int frontMod = frontY % 4; |
|
|
|
int instMod = instY % 4; |
|
|
|
return (frontMod + instMod == 2 || frontMod + instMod == 4); |
|
|
|
}) |
|
|
|
.filter(inst -> Integer.parseInt(inst.getFrom_z()) == Integer.parseInt(frontInst.getFrom_z())) |
|
|
|
.filter(inst -> Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4 == 2 || Integer.parseInt(getNumericPart(inst.getStart_device_code())) % 4 == 3) |
|
|
|
.sorted(Comparator.comparing(Instruction::getPriority).reversed() |
|
|
|
.thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
|
|
|
.findFirst().orElse(null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Instruction findReadyInst(String start_device_code) { |
|
|
|
return Optional.ofNullable(this.instructions) |
|
|
@ -1902,6 +2133,17 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper, |
|
|
|
.findFirst().orElse(null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public int findReadyInstNumByEnd(String next_device_code) { |
|
|
|
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(next_device_code)) |
|
|
|
.collect(Collectors.toList()) |
|
|
|
.size(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Instruction findReadyInstByVehicleCode(String vehicleCode) { |
|
|
|
return Optional.ofNullable(this.instructions) |
|
|
|