diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java index 63a65ad..8935a14 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java +++ b/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 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 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 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 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 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 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 shortPathsList = routeLineService.getShortPathLines(taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code()); - if (CollectionUtil.isEmpty(shortPathsList)) { + List 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 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())) { diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java index 10f777b..9e6e6d4 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java +++ b/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,30 +432,32 @@ 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"); - 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; + 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 { - //下发前叉放货信息 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"); - backInst = instructionService.findReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, backNoY); - if (ObjectUtil.isNotEmpty(backInst)) { - this.backWrite(backInst); + if (ObjectUtil.isEmpty(backInst)) { + backInst = instructionService.findReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, backNoY); + if (ObjectUtil.isNotEmpty(backInst)) { + this.backWrite(backInst); + } else { + //下发前叉放货信息 + this.sendPutInfoToPlc(frontInst, backInst); + } } else { - //下发前叉放货信息 this.sendPutInfoToPlc(frontInst, backInst); } } else { @@ -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"); - 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; + 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 { - //下发后叉放货信息 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"); - frontInst = instructionService.findReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, frontNoY); - if (ObjectUtil.isNotEmpty(frontInst)) { - this.frontWrite(frontInst); + 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,18 +1007,21 @@ 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"); - String front_to_x = frontInst.getTo_x(); - String front_to_y = frontInst.getTo_y(); - String front_to_z = frontInst.getTo_z(); - String back_to_x = backInst.getTo_x(); - String back_to_y = backInst.getTo_y(); - String back_to_z = backInst.getTo_z(); - boolean flagX = StrUtil.equals(front_to_x, back_to_x); - boolean flagY = (Integer.parseInt(front_to_y) / 4 == Integer.parseInt(back_to_y) / 4) && (((Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(back_to_y) % 4) == 2) || (Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(back_to_z) % 4) == 4); - boolean flagZ = StrUtil.equals(front_to_z, back_to_z); - if (flagX && flagY && flagZ) { - return true; + 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(); + + String back_to_x = backInst.getTo_x(); + String back_to_y = backInst.getTo_y(); + String back_to_z = backInst.getTo_z(); + boolean flagX = StrUtil.equals(front_to_x, back_to_x); + boolean flagY = (Integer.parseInt(front_to_y) / 4 == Integer.parseInt(back_to_y) / 4) && (((Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(back_to_y) % 4) == 2) || (Integer.parseInt(front_to_y) % 4) + (Integer.parseInt(back_to_z) % 4) == 4); + 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; } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/enums/ModeEnum.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/enums/ModeEnum.java new file mode 100644 index 0000000..8cef234 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/station/with_station/WithStationDeviceDriver.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/station/with_station/WithStationDeviceDriver.java index 0839649..0b3e7b3 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/station/with_station/WithStationDeviceDriver.java +++ b/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,57 +50,86 @@ 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 waitTime = Optional.ofNullable(this.getExtraValue().get("apply_time")).map(Object::toString).map(Long::parseLong).orElse(System.currentTimeMillis() * 1000); - List linkDeviceCodeList = this.getExtraDeviceCodes("link_device_code"); - for (int i = 0; i < linkDeviceCodeList.size(); i++) { - String deviceCode = linkDeviceCodeList.get(i); - Device device = deviceAppservice.findDeviceByCode(deviceCode); - AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver; - if (ObjectUtil.isNotEmpty(device) && device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { - appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) device.getDeviceDriver(); - if (appearanceInspectionScannerConveyorDeviceDriver.getMove() == 0) { - requireSuccess = false; - continue; - } - if (!requireSuccess && StrUtil.isNotEmpty(appearanceInspectionScannerConveyorDeviceDriver.getBarcode())) { - TaskDto taskDto = taskServer.findByContainer(appearanceInspectionScannerConveyorDeviceDriver.getBarcode()); - if (ObjectUtil.isEmpty(taskDto)) { - JSONObject requestParam = new JSONObject(); - requestParam.put("type", RequestTypeEnum.APPLY_IN_TASK.getType()); - String getLinkDeviceCode = Optional.ofNullable(device.getExtraValue().get("getLinkDeviceCode")).map(Object::toString).orElse(null); - if (StrUtil.isEmpty(getLinkDeviceCode)) { - requestParam.put("device_code1", deviceCode); - requestParam.put("barcode1", appearanceInspectionScannerConveyorDeviceDriver.getBarcode()); - UnifiedResponse response = acsToWmsService.applyTaskToWms(requestParam); - if (response.isSuccess()) { + 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 linkDeviceCodeList = this.getExtraDeviceCodes("link_device_code"); + for (int i = 0; i < linkDeviceCodeList.size(); i++) { + String deviceCode = linkDeviceCodeList.get(i); + Device device = deviceAppservice.findDeviceByCode(deviceCode); + AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver; + if (ObjectUtil.isNotEmpty(device) && device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { + appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) device.getDeviceDriver(); + if (appearanceInspectionScannerConveyorDeviceDriver.getMove() == 0) { + requireSuccess = false; + continue; + } + if (!requireSuccess && StrUtil.isNotEmpty(appearanceInspectionScannerConveyorDeviceDriver.getBarcode()) + && !appearanceInspectionScannerConveyorDeviceDriver.isRequireSuccess()) { + TaskDto taskDto = taskServer.findByContainer(appearanceInspectionScannerConveyorDeviceDriver.getBarcode()); + if (ObjectUtil.isEmpty(taskDto)) { + JSONObject requestParam = new JSONObject(); + requestParam.put("type", RequestTypeEnum.APPLY_IN_TASK.getType()); + String getLinkDeviceCode = Optional.ofNullable(device.getExtraValue().get("getLinkDeviceCode")).map(Object::toString).orElse(null); + if (StrUtil.isEmpty(getLinkDeviceCode)) { + requestParam.put("device_code1", deviceCode); + requestParam.put("barcode1", appearanceInspectionScannerConveyorDeviceDriver.getBarcode()); + logServer.deviceExecuteLog(new LuceneLogDto(this.device_code, "申请任务...." + requestParam.toString())); + // UnifiedResponse 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) { - TaskDto taskDto2 = taskServer.findByContainer(appearanceInspectionScannerConveyorDeviceDriver2.getBarcode()); - 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 response = acsToWmsService.applyTaskToWms(requestParam); - if (response.isSuccess()) { + // } + } else { + Device linkDevice = deviceAppservice.findDeviceByCode(getLinkDeviceCode); + if (ObjectUtil.isNotEmpty(linkDevice) && linkDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { + AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver2 = (AppearanceInspectionScannerConveyorDeviceDriver) linkDevice.getDeviceDriver(); + if (appearanceInspectionScannerConveyorDeviceDriver2.getMove() == 1 && !appearanceInspectionScannerConveyorDeviceDriver2.isRequireSuccess()) { + TaskDto taskDto2 = taskServer.findByContainer(appearanceInspectionScannerConveyorDeviceDriver2.getBarcode()); + if (ObjectUtil.isEmpty(taskDto2) ) { + requestParam.put("device_code1", deviceCode); + requestParam.put("barcode1", appearanceInspectionScannerConveyorDeviceDriver.getBarcode()); + requestParam.put("device_code2", getLinkDeviceCode); + requestParam.put("barcode2", appearanceInspectionScannerConveyorDeviceDriver2.getBarcode()); + logServer.deviceExecuteLog(new LuceneLogDto(this.device_code, "申请任务...." + requestParam.toString())); + //UnifiedResponse response = acsToWmsService.applyTaskToWms(requestParam); + // if (response.isSuccess()) { this.requireSuccess = true; + appearanceInspectionScannerConveyorDeviceDriver.setRequireSuccess(true); + appearanceInspectionScannerConveyorDeviceDriver2.setRequireSuccess(true); + + // } } - } - } else { - if (System.currentTimeMillis() - appearanceInspectionScannerConveyorDeviceDriver.getRequireInTaskTime() > waitTime) { - requestParam.put("device_code1", deviceCode); - requestParam.put("barcode1", appearanceInspectionScannerConveyorDeviceDriver.getBarcode()); - UnifiedResponse response = acsToWmsService.applyTaskToWms(requestParam); - if (response.isSuccess()) { + } else { + if (System.currentTimeMillis() - appearanceInspectionScannerConveyorDeviceDriver.getRequireInTaskTime() > waitTime * 1000) { + requestParam.put("device_code1", deviceCode); + requestParam.put("barcode1", appearanceInspectionScannerConveyorDeviceDriver.getBarcode()); + logServer.deviceExecuteLog(new LuceneLogDto(this.device_code, "申请任务...." + requestParam.toString())); + // UnifiedResponse response = acsToWmsService.applyTaskToWms(requestParam); + //if (response.isSuccess()) { + appearanceInspectionScannerConveyorDeviceDriver.setRequireSuccess(true); this.requireSuccess = true; + // } } } } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java index ec5635b..a9b13a9 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java @@ -619,7 +619,6 @@ public class RouteLineServiceImpl extends CommonServiceImpl getShortPathLines(String device_code, String next_device_code, String plan_code) { - List list = this.routeLines.get(plan_code); List result = new ArrayList<>(); Iterator iterator = list.iterator(); diff --git a/nladmin-ui/src/views/acs/device/driver/appearance_inspection_scanner_conveyor_device.vue b/nladmin-ui/src/views/acs/device/driver/appearance_inspection_scanner_conveyor_device.vue index a4b4c96..e820680 100644 --- a/nladmin-ui/src/views/acs/device/driver/appearance_inspection_scanner_conveyor_device.vue +++ b/nladmin-ui/src/views/acs/device/driver/appearance_inspection_scanner_conveyor_device.vue @@ -100,8 +100,8 @@ - - + + + + + + + + + @@ -288,7 +306,8 @@ export default { currentY: '', currentZ: '', address: '', - cacheDeviceCode: '' + cacheDeviceCode: '', + pinkDeviceCode: '' }, rules: {} }