Browse Source

fix:优化

master
耿宝印 2 months ago
parent
commit
bbdd75f3b1
  1. 139
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java
  2. 2
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java
  3. 10
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
  4. 12
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

139
nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java

@ -8,10 +8,7 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.util.concurrent.Uninterruptibles;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.SneakyThrows;
import lombok.*;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device.domain.Device;
import org.nl.acs.device.device.service.DeviceAppService;
@ -646,9 +643,22 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
if (ObjectUtil.isEmpty(frontInst)) {
frontInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList);
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);
int numericPart = Integer.parseInt(getNumericPart(frontInst.getNext_device_code()));
if (numericPart % 4 == 2 || numericPart % 4 == 3) {
TaskDto taskDto = taskService.findByNextPointCode(getDeepPoint(frontInst.getNext_point_code()));
//Instruction instruction = instructionService.findByNextPointCode(getDeepPoint(frontInst.getNext_point_code()));
if (ObjectUtil.isNotEmpty(taskDto)) {
this.sendPutInfoToPlc(null, backInst);
} else {
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 {
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);
}
@ -720,9 +730,22 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
if (ObjectUtil.isEmpty(backInst)) {
backInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, backNoY, getBackDeviceCodeList);
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);
int numericPart = Integer.parseInt(getNumericPart(backInst.getNext_device_code()));
if (numericPart % 4 == 2 || numericPart % 4 == 3) {
TaskDto taskDto = taskService.findByNextPointCode(getDeepPoint(backInst.getNext_point_code()));
//Instruction instruction = instructionService.findByNextPointCode(getDeepPoint(backInst.getNext_point_code()));
if (ObjectUtil.isNotEmpty(taskDto)) {
this.sendPutInfoToPlc(frontInst, null);
} else {
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 {
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);
}
@ -813,15 +836,19 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
if (ObjectUtil.isNotEmpty(backInst)) {
int numericPart = Integer.parseInt(getNumericPart(backInst.getNext_device_code()));
if (numericPart % 4 == 2 || numericPart % 4 == 3) {
String qPoint = getZdPoint(backInst.getNext_point_code());
TaskDto taskDto = taskService.findByNextPointCode(qPoint);
TaskDto taskDto = taskService.findByNextPointCode(getDeepPoint(backInst.getNext_point_code()));
//Instruction instruction = instructionService.findByNextPointCode(getDeepPoint(backInst.getNext_point_code()));
if (ObjectUtil.isNotEmpty(taskDto)) {
this.sendPutInfoToPlc(frontInst, backInst);
this.sendPutInfoToPlc(frontInst, null);
} else {
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 {
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);
@ -892,7 +919,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice");
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice");
String getLinkDeviceCode = Optional.ofNullable(front_start_device.getExtraValue().get("getLinkDeviceCode")).map(Object::toString).orElse(null);
if (StrUtil.isNotEmpty(getLinkDeviceCode)){
if (StrUtil.isNotEmpty(getLinkDeviceCode)) {
backInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getBackDeviceCodeList, specialGetDevice, specialPutDevice, front_start_device_code, getLinkDeviceCode);
if (ObjectUtil.isNotEmpty(backInst)) {
String back_start_device_code = backInst.getStart_device_code();
@ -921,9 +948,22 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
if (ObjectUtil.isEmpty(frontInst)) {
frontInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList);
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);
int numericPart = Integer.parseInt(getNumericPart(frontInst.getNext_device_code()));
if (numericPart % 4 == 2 || numericPart % 4 == 3) {
TaskDto taskDto = taskService.findByNextPointCode(getDeepPoint(frontInst.getNext_point_code()));
//Instruction instruction = instructionService.findByNextPointCode(getDeepPoint(frontInst.getNext_point_code()));
if (ObjectUtil.isNotEmpty(taskDto)) {
this.sendPutInfoToPlc(null, backInst);
} else {
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 {
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);
}
@ -993,7 +1033,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
List<String> specialGetDevice = this.getExtraDeviceCodes("specialGetDevice");
List<String> specialPutDevice = this.getExtraDeviceCodes("specialPutDevice");
String getLinkDeviceCode = Optional.ofNullable(back_start_device.getExtraValue().get("getLinkDeviceCode")).map(Object::toString).orElse(null);
if (StrUtil.isNotEmpty(getLinkDeviceCode)){
if (StrUtil.isNotEmpty(getLinkDeviceCode)) {
frontInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getFrontDeviceCodeList, specialGetDevice, specialPutDevice, back_start_device_code, getLinkDeviceCode);
if (ObjectUtil.isNotEmpty(frontInst)) {
String front_start_device_code = frontInst.getStart_device_code();
@ -1268,8 +1308,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
return false;
}
String getLinkDeviceCode = Optional.ofNullable(front_start_device.getExtraValue().get("getLinkDeviceCode")).map(Object::toString).orElse(null);
if (StrUtil.isNotEmpty(getLinkDeviceCode)){
backInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getBackDeviceCodeList, specialGetDevice, specialPutDevice, start_device_code,getLinkDeviceCode);
if (StrUtil.isNotEmpty(getLinkDeviceCode)) {
backInst = instructionService.findReadyInstBySpecialDeviceAndStartDeviceCode(getBackDeviceCodeList, specialGetDevice, specialPutDevice, start_device_code, getLinkDeviceCode);
}
}
} else {
@ -1624,6 +1664,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY");
List<String> getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList");
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY");
//先查询入库位是深库位的入库指令信息
List<Instruction> frontInsts = instructionService.findDeepReadyInstByStartDeviceCode(getFrontDeviceCodeList, frontNoY);
if (CollectionUtil.isNotEmpty(frontInsts)) {
frontInst = frontInsts.get(0);
@ -1634,11 +1675,24 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
if (front_start_device != null) {
String getLinkDeviceCode = this.handExtraStringValue(front_start_device, "getLinkDeviceCode");
if (StrUtil.isNotEmpty(getLinkDeviceCode)) {
//根据前叉指令信息,查询是否存在对应的后叉的深库位的入库指令信息
backInst = instructionService.findDeepReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, backNoY, getBackDeviceCodeList);
if (ObjectUtil.isEmpty(backInst)) {
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode);
if (ObjectUtil.isNotEmpty(inst)) {
return;
//如果不存在深库位的后叉信息,查询是否存在浅库位的后叉信息
backInst = instructionService.findShallowReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, backNoY, getBackDeviceCodeList);
//如果存在,就查询是否有终点是浅库位对应的深库位的指令信息
if (ObjectUtil.isNotEmpty(backInst)) {
Instruction instruction = instructionService.findByNextPointCode(getDeepPoint(backInst.getNext_point_code()));
if (ObjectUtil.isNotEmpty(instruction)) {
backInst = null;
} else {
//如果有就单取深库位的
//如果没有就双取
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode);
if (ObjectUtil.isNotEmpty(inst)) {
return;
}
}
}
}
}
@ -1657,11 +1711,24 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
String getLinkDeviceCode = this.handExtraStringValue(back_start_device, "getLinkDeviceCode");
front_start_device = deviceAppService.findDeviceByCode(getLinkDeviceCode);
if (front_start_device != null) {
//根据后叉指令信息,查询是否存在对应的前叉的深库位的入库指令信息
frontInst = instructionService.findDeepReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList);
if (ObjectUtil.isEmpty(frontInst)) {
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode);
if (ObjectUtil.isNotEmpty(inst)) {
return;
//如果不存在深库位的前叉信息,查询是否存在浅库位的前叉信息
frontInst = instructionService.findShallowReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList);
//如果存在,就查询是否有终点是浅库位对应的深库位的指令信息
if (ObjectUtil.isNotEmpty(frontInst)) {
Instruction instruction = instructionService.findByNextPointCode(getDeepPoint(frontInst.getNext_point_code()));
if (ObjectUtil.isNotEmpty(instruction)) {
frontInst = null;
} else {
//如果有就单取深库位的
//如果没有就双取
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode);
if (ObjectUtil.isNotEmpty(inst)) {
return;
}
}
}
} else {
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "第二次查询到前叉指令号:" + frontInst.getInstruction_code()));
@ -2079,7 +2146,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
String start_device_code = backInst.getStart_device_code();
Device start_device = deviceAppService.findDeviceByCode(start_device_code);
if (start_device != null && start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
this.writing(this.getBackKeys(), Arrays.asList(Integer.parseInt(StringUtil.handleString(frontInst.getFrom_x())), Integer.parseInt(frontInst.getFrom_y()), Integer.parseInt(frontInst.getFrom_z()), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
this.writing(this.getBackKeys(), Arrays.asList(Integer.parseInt(StringUtil.handleString(backInst.getFrom_x())), Integer.parseInt(backInst.getFrom_y()), Integer.parseInt(backInst.getFrom_z()), backInst.getInstruction_code(), SendSignalEnum.CHOOSE_FORK_TWO.getSignalNum(), SendSignalEnum.COMMAND_ONE.getSignalNum()));
} else if (start_device != null && start_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
Integer x = this.handExtraIntValue(start_device, "currentX");
Integer y = this.handExtraIntValue(start_device, "currentY");
@ -2470,6 +2537,24 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
return String.format("%s%02d%s", type, row, rest);
}
private String getDeepPoint(String point_code) {
if (point_code == null || point_code.chars().filter(ch -> ch == '-').count() != 2) {
return null;
}
String type = point_code.substring(0, 1);
int row = Integer.parseInt(point_code.substring(1, 3));
String rest = point_code.substring(3);
if (row == 2) {
row -= 1;
} else if (row == 3) {
row += 1;
} else {
return null;
}
return String.format("%s%02d%s", type, row, rest);
}
/**
* 封装指令
*

2
nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java

@ -587,4 +587,6 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
void cancelInstAndTaskNoSendWms(String instruction_id);
List<Instruction> findReadyInstByXDeviceCode(List<String> xDeviceCodeList, String noY);
Instruction findByNextPointCode(String nextPointCode);
}

10
nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java

@ -2396,4 +2396,14 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
.collect(Collectors.toList());
}
@Override
public Instruction findByNextPointCode(String nextPointCode) {
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getNext_point_code().equals(nextPointCode))
.findFirst()
.orElse(null);
}
}

12
nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -1437,13 +1437,13 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
.stream()
.filter(taskDto -> taskDto.getTask_status().equals(TaskStatusEnum.READY.getIndex()))
.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 -> front_from_x.equals(taskDto.getFrom_x()) && front_from_z.equals(taskDto.getFrom_z()))
.filter(taskDto -> front_to_x.equals(taskDto.getTo_x()) && front_to_z.equals(taskDto.getTo_z()))
.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) - 1) / 4 == (Integer.parseInt(taskDto.getTo_y()) - 1) / 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) - 1) / 4 == (Integer.parseInt(taskDto.getFrom_y()) - 1) / 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))
.filter(taskDto -> Integer.parseInt(taskDto.getFrom_y()) < Integer.parseInt(front_from_y))
.filter(taskDto -> Integer.parseInt(taskDto.getTo_y()) < Integer.parseInt(front_to_y))
.filter(taskDto -> StrUtil.isNotEmpty(taskDto.getFrom_y()) && Integer.parseInt(taskDto.getFrom_y()) < Integer.parseInt(front_from_y))
.filter(taskDto -> StrUtil.isNotEmpty(taskDto.getTo_y()) && Integer.parseInt(taskDto.getTo_y()) < Integer.parseInt(front_to_y))
.filter(taskDto -> {
int frontToY = Integer.parseInt(front_to_y);
int taskDtoToY = Integer.parseInt(taskDto.getTo_y());
@ -1489,10 +1489,10 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
.stream()
.filter(taskDto -> taskDto.getTask_status().equals(TaskStatusEnum.READY.getIndex()))
.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 -> front_from_x.equals(taskDto.getFrom_x()) && front_from_z.equals(taskDto.getFrom_z()))
.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) - 1) / 4 == (Integer.parseInt(taskDto.getFrom_y()) - 1) / 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))
.filter(taskDto -> Integer.parseInt(taskDto.getFrom_y()) < Integer.parseInt(front_from_y))
.filter(taskDto -> StrUtil.isNotEmpty(taskDto.getFrom_y()) && Integer.parseInt(taskDto.getFrom_y()) < Integer.parseInt(front_from_y))
.filter(taskDto -> {
int frontFromY = Integer.parseInt(front_from_y);
int taskDtoFromY = Integer.parseInt(taskDto.getFrom_y());

Loading…
Cancel
Save