Browse Source

rev:堆垛机驱动

master
gengby 8 months ago
parent
commit
d1bad23400
  1. 226
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java
  2. 45
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java
  3. 23
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/enums/ModeEnum.java
  4. 54
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/station/with_station/WithStationDeviceDriver.java
  5. 1
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java
  6. 25
      nladmin-ui/src/views/acs/device/driver/appearance_inspection_scanner_conveyor_device.vue

226
nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java

@ -12,8 +12,9 @@ import lombok.Setter;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device.domain.Device;
import org.nl.acs.device.device.enums.DeviceType;
import org.nl.acs.device.device.service.DeviceAppService;
import org.nl.acs.device.device.service.DeviceAssignedService;
import org.nl.acs.device.device.service.dto.DeviceAssignedDto;
import org.nl.acs.device.driver.*;
import org.nl.acs.device.driver.conveyor.appearance_inspection_scannner_conveyor.enums.CommandEnum;
import org.nl.acs.device.enums.RequestTypeEnum;
@ -26,7 +27,6 @@ import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.enums.TaskStatusEnum;
import org.nl.acs.task.enums.TaskTypeEnum;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.common.utils.CodeUtil;
@ -35,7 +35,6 @@ import org.nl.config.SpringContextHolder;
import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto;
import java.io.Serializable;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@ -58,6 +57,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
private final TaskService taskService = SpringContextHolder.getBean(TaskService.class);
private final RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
private final DeviceAssignedService deviceAssignedService = SpringContextHolder.getBean(DeviceAssignedService.class);
private static final Lock LOCK = new ReentrantLock();
@ -149,7 +149,8 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
/**
* 请求标记
*/
boolean requireSuccess = false;
private boolean requireSuccess = false;
/**
* 请求时间
@ -172,6 +173,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
*/
private boolean isError = false;
@Override
public Device getDevice() {
return this.device;
@ -193,20 +195,21 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
this.loadAssignData(currentDeviceCode, ItemProtocol.class);
}
@Override
public void executeLogic() {
private void executeLogicBefore() {
if (this.move != this.lastMove) {
this.requireSuccess = false;
}
if (!StrUtil.equals(this.barcode, this.lastBarcode)) {
if (!StrUtil.equals(this.barcode, this.lastBarcode) && this.move == 1) {
this.requireInTaskTime = System.currentTimeMillis();
}
if (this.move != 0 && this.task > 0) {
this.update_instruction_status_by_task();
}
// else if (this.move != 0 && StrUtil.isNotEmpty(this.barcode)) {
// this.update_instruction_status_by_barcode();
// }
}
@Override
public void executeLogic() {
this.executeLogicBefore();
if (!this.online) {
this.message = "设备离线";
} else if (this.mode == 0) {
@ -220,18 +223,21 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
//编写业务逻辑方法
if (this.mode == 2 && this.move > 0 && StrUtil.isNotEmpty(this.barcode) && !requireSuccess) {
//查询入库信息
this.createInInstruction2();
this.createInInstruction();
} else if (this.mode == 2 && this.move == 0 && !requireSuccess) {
//查询出库信息
String cacheDeviceCode = Optional.ofNullable(this.getExtraValue().get("cacheDeviceCode")).map(Object::toString).orElse("");
if (ObjectUtil.isNotEmpty(cacheDeviceCode)) {
this.createOutInstruction2(cacheDeviceCode);
this.createOutInstruction(cacheDeviceCode);
} else {
this.createOutInstruction2(this.currentDeviceCode);
this.createOutInstruction(this.currentDeviceCode);
}
} else if (this.mode == 6 && move > 0 && !requireSuccess) {
//向上位申请任务
this.applyInTask();
} else if (this.mode == 2 && this.move > 0 && StrUtil.isEmpty(this.barcode) && !requireSuccess) {
//下发输送线指令信息
this.distribute();
}
}
}
@ -251,11 +257,9 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
} else {
this.requireTime = currentTimeMillis;
JSONObject requestParam = new JSONObject();
requestParam.put("device_code", this.currentDeviceCode);
requestParam.put("device_code1", this.currentDeviceCode);
requestParam.put("type", RequestTypeEnum.APPLY_IN_TASK.getType());
requestParam.put("barcode", this.barcode);
requestParam.put("weight", this.weight);
requestParam.put("height", this.height);
requestParam.put("barcode1", this.barcode);
UnifiedResponse<JSONObject> response = acsToWmsService.applyTaskToWms(requestParam);
if (response.isSuccess()) {
this.requireSuccess = true;
@ -263,58 +267,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
}
}
// public void createInInstruction() {
// long currentTimeMillis = System.currentTimeMillis();
// if (!isTimeValid(currentTimeMillis)) {
// log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
// } else {
// TaskDto taskDto = taskService.findReadyByStartDeviceCode(this.currentDeviceCode);
// Instruction instDto = instructionService.findReadyInst(this.currentDeviceCode);
// if (ObjectUtil.isNotEmpty(taskDto) && ObjectUtil.isEmpty(instDto)) {
// 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);
// int start = 0;
// String start_device_code = pathList.get(start);
// String next_device_code = pathList.get(start + 1);
// setInstruction(instDto, taskDto, start_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);
// 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()));
// return;
// }
// this.requireSuccess = true;
// } else if (ObjectUtil.isEmpty(taskDto) && ObjectUtil.isNotEmpty(instDto)) {
// 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;
// }
// }
// }
// }
public void createInInstruction2() {
public void createInInstruction() {
long currentTimeMillis = System.currentTimeMillis();
if (!isTimeValid(currentTimeMillis)) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
@ -323,7 +276,6 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
Instruction instDto = instructionService.findReadyInstByVehicleCode(this.barcode);
if (ObjectUtil.isNotEmpty(taskDto) && ObjectUtil.isEmpty(instDto)) {
if (!StrUtil.equals(this.currentDeviceCode, taskDto.getStart_device_code())) {
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前载具号:" + this.barcode + ", 对应的设备号, 与查询到的任务起点: " + taskDto.getStart_device_code() + " 不一致, 无法生成指令。"));
return;
}
instDto = new Instruction();
@ -336,15 +288,28 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
String path = routeLineDto.getPath();
String[] str = path.split("->");
List<String> pathList = Arrays.asList(str);
int start = 0;
String start_device_code = pathList.get(start);
String next_device_code = pathList.get(start + 1);
setInstruction(instDto, taskDto, start_device_code, next_device_code);
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;
}
}
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()));
return;
}
if (nextDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
setInstruction(instDto, taskDto, start_device_code, next_device_code);
} else {
setInstruction(instDto, taskDto, start_device_code, taskDto.getStart_point_code(), next_device_code, taskDto.getNext_point_code());
}
try {
instructionService.create(instDto);
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
@ -367,59 +332,10 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
this.requireSuccess = true;
}
}
}
}
// 暂时不要删除
// public void createOutInstruction() {
// long currentTimeMillis = System.currentTimeMillis();
// if (!isTimeValid(currentTimeMillis)) {
// log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
// } else {
// TaskDto taskDto = taskService.findReadyTaskByNextDeviceCode(this.currentDeviceCode);
// Instruction instDto = instructionService.findReadyInstByEnd(this.currentDeviceCode);
// if (ObjectUtil.isNotEmpty(taskDto) && ObjectUtil.isEmpty(instDto)) {
// 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);
// int start = 0;
// String start_device_code = pathList.get(start);
// String next_device_code = pathList.get(start + 1);
// 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;
// }
// this.requireSuccess = true;
// }
// }
// }
public void createOutInstruction2(String deviceCode) {
public void createOutInstruction(String deviceCode) {
long currentTimeMillis = System.currentTimeMillis();
if (!isTimeValid(currentTimeMillis)) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
@ -430,18 +346,32 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
Instruction instDto = instructionService.findReadyInstByEnd(deviceCode);
if (ObjectUtil.isNotEmpty(taskDto) && ObjectUtil.isEmpty(instDto)) {
instDto = new Instruction();
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code());
if (CollectionUtil.isEmpty(shortPathsList)) {
List<DeviceAssignedDto> assignedDtos = deviceAssignedService.queryAssignedByDevice(taskDto.getStart_device_code(), taskDto.getNext_device_code());
if (CollectionUtil.isEmpty(assignedDtos)) {
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);
int start = 0;
String start_device_code = pathList.get(start);
String next_device_code = pathList.get(start + 1);
DeviceAssignedDto assignedDto = assignedDtos.get(0);
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;
}
}
}
}
}
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();
@ -471,6 +401,28 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
}
}
/**
* 下发输送线指令
*/
private void distribute() {
long currentTimeMillis = System.currentTimeMillis();
if (!isTimeValid(currentTimeMillis)) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
} else {
this.requireTime = currentTimeMillis;
Instruction inst = instructionService.findReadyInst(this.currentDeviceCode);
if (ObjectUtil.isNotEmpty(inst)) {
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;
}
}
}
}
/**
* 更新指令状态
@ -483,14 +435,6 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
}
}
@SneakyThrows
private void update_instruction_status_by_barcode() {
Instruction instruction = instructionService.findByVehicleCodeFromCache(this.barcode);
if (ObjectUtil.isNotEmpty(instruction)) {
update_inst_status(instruction);
}
}
@SneakyThrows
private void update_inst_status(Instruction instruction) {
if (InstructionStatusEnum.READY.getIndex().equals(instruction.getInstruction_status()) && this.currentDeviceCode.equals(instruction.getStart_device_code())) {

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

@ -16,6 +16,7 @@ import org.nl.acs.device.device.service.DeviceAppService;
import org.nl.acs.device.driver.*;
import org.nl.acs.device.driver.conveyor.appearance_inspection_scannner_conveyor.AppearanceInspectionScannerConveyorDeviceDriver;
import org.nl.acs.device.driver.stacker.double_stacker.enums.CommandEnum;
import org.nl.acs.device.driver.stacker.double_stacker.enums.ModeEnum;
import org.nl.acs.device.driver.stacker.double_stacker.enums.SendSignalEnum;
import org.nl.acs.device.driver.stacker.double_stacker.enums.StrategyEnum;
import org.nl.acs.device.driver.storage.standard_storage.StandardStorageDeviceDriver;
@ -390,7 +391,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
this.updateInstStatus();
if (!this.online) {
this.message = "设备离线";
} else if (this.mode != 3) {
} else if (this.mode != ModeEnum.MODE_3.getNum()) {
this.message = "设备未联机";
} else if (this.stacker_error != 0) {
this.message = "设备报警";
@ -400,7 +401,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
this.isError = false;
//编写业务逻辑方法
//待机
if (mode == 3 && this.isStandby() && !this.requireSuccess) {
if (this.mode == ModeEnum.MODE_3.getNum() && this.isStandby() && !this.requireSuccess) {
Instruction frontInst = instructionService.findByCodeFromCache(String.valueOf(this.front_task));
Instruction backInst = instructionService.findByCodeFromCache(String.valueOf(this.back_task));
if (ObjectUtil.isEmpty(frontInst) && ObjectUtil.isEmpty(backInst)) {
@ -409,16 +410,15 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
this.applyTask();
} else {
//下发放货信息给堆垛机
this.sendPutInfoToPlc(frontInst, backInst);
}
}
//取货中
else if (mode == 3 && this.isPickup() && !this.requireSuccess) {
else if (mode == ModeEnum.MODE_3.getNum() && this.isPickup() && !this.requireSuccess) {
this.clearInfoToPlc();
}
//取货完成
else if (mode == 3 && this.isPickupComplete() && !requireSuccess) {
else if (mode == ModeEnum.MODE_3.getNum() && this.isPickupComplete() && !requireSuccess) {
Instruction frontInst = instructionService.findByCodeFromCache(String.valueOf(this.front_task));
Instruction backInst = instructionService.findByCodeFromCache(String.valueOf(this.back_task));
if (this.front_command == CommandEnum.PICKUP_COMPLETE.getStatus() && this.back_command == CommandEnum.PICKUP_COMPLETE.getStatus()) {
@ -432,25 +432,24 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
if (instanceAppearance(front_start_device) && instanceStorage(front_next_device)) {
String getLinkDeviceCode = this.handExtraStringValue(front_start_device, "getLinkDeviceCode");
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY");
if (ObjectUtil.isEmpty(backInst)) {
backInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, backNoY);
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 {
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode);
if (ObjectUtil.isNotEmpty(inst)) {
return;
} else {
//下发前叉放货信息
this.sendPutInfoToPlc(frontInst, backInst);
}
} else {
this.sendPutInfoToPlc(frontInst, backInst);
}
}
//出库
else if (instanceStorage(front_start_device) && instanceAppearance(front_next_device)) {
String getLinkDeviceCode = this.handExtraStringValue(front_next_device, "getLinkDeviceCode");
String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY");
if (ObjectUtil.isEmpty(backInst)) {
backInst = instructionService.findReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, backNoY);
if (ObjectUtil.isNotEmpty(backInst)) {
this.backWrite(backInst);
@ -458,6 +457,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
//下发前叉放货信息
this.sendPutInfoToPlc(frontInst, backInst);
}
} else {
this.sendPutInfoToPlc(frontInst, backInst);
}
} else {
//下发前叉放货信息
this.sendPutInfoToPlc(frontInst, backInst);
@ -471,41 +473,41 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
if (instanceAppearance(back_start_device) && instanceStorage(back_next_device)) {
String getLinkDeviceCode = this.handExtraStringValue(back_start_device, "getLinkDeviceCode");
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY");
if (ObjectUtil.isEmpty(frontInst)) {
frontInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY);
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 {
Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode);
if (ObjectUtil.isNotEmpty(inst)) {
return;
} else {
//下发后叉放货信息
this.sendPutInfoToPlc(frontInst, backInst);
}
} else {
this.sendPutInfoToPlc(frontInst, backInst);
}
}
//出库
else if (instanceStorage(back_start_device) && instanceAppearance(back_next_device)) {
String getLinkDeviceCode = this.handExtraStringValue(back_next_device, "getLinkDeviceCode");
String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY");
if (ObjectUtil.isEmpty(frontInst)) {
frontInst = instructionService.findReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, frontNoY);
if (ObjectUtil.isNotEmpty(frontInst)) {
this.frontWrite(frontInst);
} else {
//下发后叉放货信息
this.sendPutInfoToPlc(frontInst, backInst);
}
} else {
//下发后叉放货信息
this.sendPutInfoToPlc(frontInst, backInst);
}
} else {
this.sendPutInfoToPlc(frontInst, backInst);
}
}
this.requireSuccess = true;
}
//放货中
else if (mode == 3 && this.isRelease() && !this.requireSuccess) {
else if (mode == ModeEnum.MODE_3.getNum() && this.isRelease() && !this.requireSuccess) {
if (this.lastBack_command != CommandEnum.UNLOAD.getStatus() && this.lastFront_command != CommandEnum.UNLOAD.getStatus()) {
this.clearInfoToPlc();
} else if (this.lastBack_command != CommandEnum.UNLOAD.getStatus() && this.back_command != CommandEnum.STANDY.getStatus()) {
@ -517,12 +519,12 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
//请求卸货
else if (mode == 3 && this.isUnload() && !requireSuccess) {
else if (mode == ModeEnum.MODE_3.getNum() && this.isUnload() && !requireSuccess) {
this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_THREE.getSignalNum());
this.requireSuccess = true;
}
//卸货完成
else if (mode == 3 && this.isUnloadComplete() && !requireSuccess) {
else if (mode == ModeEnum.MODE_3.getNum() && this.isUnloadComplete() && !requireSuccess) {
if (this.front_command == CommandEnum.UNLOAD_COMPLETE.getStatus() && this.back_command == CommandEnum.UNLOAD_COMPLETE.getStatus()) {
this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_ELEVEN.getSignalNum());
} else if (this.front_command == CommandEnum.UNLOAD_COMPLETE.getStatus()) {
@ -1005,6 +1007,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
Device front_device = deviceAppService.findDeviceByCode(front_next_device_code);
Device back_device = deviceAppService.findDeviceByCode(back_next_device_code);
String back_device_code = this.handExtraStringValue(front_device, "getLinkDeviceCode");
if (instanceStorage(front_device) && instanceStorage(back_device)) {
String front_to_x = frontInst.getTo_x();
String front_to_y = frontInst.getTo_y();
String front_to_z = frontInst.getTo_z();
@ -1017,6 +1021,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
boolean flagZ = StrUtil.equals(front_to_z, back_to_z);
if (flagX && flagY && flagZ) {
return true;
}
} else if (StrUtil.equals(back_next_device_code, back_device_code)) {
return true;
}

23
nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/enums/ModeEnum.java

@ -0,0 +1,23 @@
package org.nl.acs.device.driver.stacker.double_stacker.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @Description TODO
* @Author Gengby
* @Date 2024/5/17
*/
@Getter
@AllArgsConstructor
public enum ModeEnum {
MODE_0(0, "维修"),
MODE_1(1, "手动"),
MODE_2(2, "单机自动"),
MODE_3(3, "联机自动"),
MODE_4(4, "不明");
private final Integer num;
private final String desc;
}

54
nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/station/with_station/WithStationDeviceDriver.java

@ -22,6 +22,7 @@ import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.config.SpringContextHolder;
import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto;
import java.util.List;
import java.util.Optional;
@ -49,9 +50,28 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
*/
private String device_code = null;
/**
* 请求时间
*/
private long requireTime = System.currentTimeMillis();
/**
* 请求间隔时间
*/
private long requireTimeOut = 3000L;
private boolean isTimeValid(long currentTimeMillis) {
return currentTimeMillis - this.requireTime >= this.requireTimeOut;
}
@Override
public void execute() {
device_code = this.getDeviceCode();
long currentTimeMillis = System.currentTimeMillis();
if (!isTimeValid(currentTimeMillis)) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
} else {
this.requireTime = currentTimeMillis;
Long waitTime = Optional.ofNullable(this.getExtraValue().get("apply_time")).map(Object::toString).map(Long::parseLong).orElse(System.currentTimeMillis() * 1000);
List<String> linkDeviceCodeList = this.getExtraDeviceCodes("link_device_code");
for (int i = 0; i < linkDeviceCodeList.size(); i++) {
@ -64,7 +84,8 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
requireSuccess = false;
continue;
}
if (!requireSuccess && StrUtil.isNotEmpty(appearanceInspectionScannerConveyorDeviceDriver.getBarcode())) {
if (!requireSuccess && StrUtil.isNotEmpty(appearanceInspectionScannerConveyorDeviceDriver.getBarcode())
&& !appearanceInspectionScannerConveyorDeviceDriver.isRequireSuccess()) {
TaskDto taskDto = taskServer.findByContainer(appearanceInspectionScannerConveyorDeviceDriver.getBarcode());
if (ObjectUtil.isEmpty(taskDto)) {
JSONObject requestParam = new JSONObject();
@ -73,33 +94,42 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
if (StrUtil.isEmpty(getLinkDeviceCode)) {
requestParam.put("device_code1", deviceCode);
requestParam.put("barcode1", appearanceInspectionScannerConveyorDeviceDriver.getBarcode());
UnifiedResponse<JSONObject> response = acsToWmsService.applyTaskToWms(requestParam);
if (response.isSuccess()) {
logServer.deviceExecuteLog(new LuceneLogDto(this.device_code, "申请任务...." + requestParam.toString()));
// UnifiedResponse<JSONObject> response = acsToWmsService.applyTaskToWms(requestParam);
// if (response.isSuccess()) {
appearanceInspectionScannerConveyorDeviceDriver.setRequireSuccess(true);
this.requireSuccess = true;
}
// }
} else {
Device linkDevice = deviceAppservice.findDeviceByCode(getLinkDeviceCode);
if (ObjectUtil.isNotEmpty(linkDevice) && linkDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver2 = (AppearanceInspectionScannerConveyorDeviceDriver) linkDevice.getDeviceDriver();
if (appearanceInspectionScannerConveyorDeviceDriver2.getMove() == 1) {
if (appearanceInspectionScannerConveyorDeviceDriver2.getMove() == 1 && !appearanceInspectionScannerConveyorDeviceDriver2.isRequireSuccess()) {
TaskDto taskDto2 = taskServer.findByContainer(appearanceInspectionScannerConveyorDeviceDriver2.getBarcode());
if (ObjectUtil.isEmpty(taskDto2)) {
if (ObjectUtil.isEmpty(taskDto2) ) {
requestParam.put("device_code1", deviceCode);
requestParam.put("barcode1", appearanceInspectionScannerConveyorDeviceDriver.getBarcode());
requestParam.put("device_code2", getLinkDeviceCode);
requestParam.put("barcode2", appearanceInspectionScannerConveyorDeviceDriver2.getBarcode());
UnifiedResponse<JSONObject> response = acsToWmsService.applyTaskToWms(requestParam);
if (response.isSuccess()) {
logServer.deviceExecuteLog(new LuceneLogDto(this.device_code, "申请任务...." + requestParam.toString()));
//UnifiedResponse<JSONObject> response = acsToWmsService.applyTaskToWms(requestParam);
// if (response.isSuccess()) {
this.requireSuccess = true;
}
appearanceInspectionScannerConveyorDeviceDriver.setRequireSuccess(true);
appearanceInspectionScannerConveyorDeviceDriver2.setRequireSuccess(true);
// }
}
} else {
if (System.currentTimeMillis() - appearanceInspectionScannerConveyorDeviceDriver.getRequireInTaskTime() > waitTime) {
if (System.currentTimeMillis() - appearanceInspectionScannerConveyorDeviceDriver.getRequireInTaskTime() > waitTime * 1000) {
requestParam.put("device_code1", deviceCode);
requestParam.put("barcode1", appearanceInspectionScannerConveyorDeviceDriver.getBarcode());
UnifiedResponse<JSONObject> response = acsToWmsService.applyTaskToWms(requestParam);
if (response.isSuccess()) {
logServer.deviceExecuteLog(new LuceneLogDto(this.device_code, "申请任务...." + requestParam.toString()));
// UnifiedResponse<JSONObject> response = acsToWmsService.applyTaskToWms(requestParam);
//if (response.isSuccess()) {
appearanceInspectionScannerConveyorDeviceDriver.setRequireSuccess(true);
this.requireSuccess = true;
// }
}
}
}

1
nladmin-system/nlsso-server/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java

@ -619,7 +619,6 @@ public class RouteLineServiceImpl extends CommonServiceImpl<RouteLineMapper, Rou
@Override
public List<RouteLineDto> getShortPathLines(String device_code, String next_device_code, String plan_code) {
List<RouteLineDto> list = this.routeLines.get(plan_code);
List<RouteLineDto> result = new ArrayList<>();
Iterator iterator = list.iterator();

25
nladmin-ui/src/views/acs/device/driver/appearance_inspection_scanner_conveyor_device.vue

@ -100,8 +100,8 @@
</el-col>
</el-row>
<el-row>
<el-col :span="6">
<el-form-item label="缓存设备:" prop="cacheDeviceCode" label-width="105px">
<el-col :span="8">
<el-form-item label="拣选台缓存设备:" prop="cacheDeviceCode" label-width="130px">
<el-select
v-model="form.cacheDeviceCode"
filterable
@ -118,6 +118,24 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="关联拣选台设备:" prop="pinkDeviceCode" label-width="130px">
<el-select
v-model="form.pinkDeviceCode"
filterable
clearable
reserve-keyword
placeholder="拣选关联设备"
>
<el-option
v-for=" item in deviceList"
:key="item.device_id"
:label="item.device_name"
:value="item.device_code"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
@ -288,7 +306,8 @@ export default {
currentY: '',
currentZ: '',
address: '',
cacheDeviceCode: ''
cacheDeviceCode: '',
pinkDeviceCode: ''
},
rules: {}
}

Loading…
Cancel
Save