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 e8928dc..6692fca 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 @@ -22,7 +22,6 @@ import org.nl.acs.device.driver.conveyor.strip_conveyor.StripConveyorDeviceDrive import org.nl.acs.device.driver.storage.standard_storage.StandardStorageDeviceDriver; import org.nl.acs.ext.UnifiedResponse; import org.nl.acs.ext.hk.service.AcsToHkService; -import org.nl.acs.ext.hk.service.data.BaseReq; import org.nl.acs.ext.hk.service.data.BoxApplyPassReq; import org.nl.acs.ext.socket.Online; import org.nl.acs.ext.wms.data.req.CommonRequest; @@ -46,8 +45,6 @@ import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.config.lucene.service.dto.LuceneLogDto; import org.nl.system.service.param.ISysParamService; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; @@ -276,7 +273,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) .map(notify -> notify.getValue()) .orElse("0"); - if (notifyValue.equals("1")){ + if (notifyValue.equals("1")) { JSONObject dataParam = new JSONObject(); dataParam.put("msg", "设备" + this.currentDeviceCode + "报警, 报警信息: " + ErrorEnum.getLabel(this.error)); CommonRequest requestParam = CommonRequest.builder() @@ -315,6 +312,19 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc .build(); UnifiedResponse response = acsToWmsService.apply(request); if (!response.isSuccess()) { + String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) + .map(notify -> notify.getValue()) + .orElse("0"); + if (notifyValue.equals("1")) { + JSONObject dataParam = new JSONObject(); + dataParam.put("msg", "反馈拣选工位启停状态失败!请求参数: " + request + "响应信息: " + response.getMessage()); + CommonRequest requestParam = CommonRequest.builder() + .service("ErrorInfo") + .type("1") + .data(dataParam) + .build(); + acsToWmsService.apply(requestParam); + } logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "反馈拣选工位启停状态失败, 原因:" + response.getMessage())); } } @@ -341,9 +351,6 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc .taskCode(this.reqTakeInstCode) .type("1") .build(); -// BaseReq req = BaseReq.builder() -// .data(bapReq) -// .build(); UnifiedResponse unifiedResponse = acsToHkService.boxApplyPass(bapReq, String.class); if (unifiedResponse.isSuccess()) { this.reqTakeRequireSuccess = false; @@ -360,9 +367,6 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc .taskCode(this.reqPutInstCode) .type("2") .build(); -// BaseReq req = BaseReq.builder() -// .data(bapReq) -// .build(); UnifiedResponse unifiedResponse = acsToHkService.boxApplyPass(bapReq, String.class); if (unifiedResponse.isSuccess()) { this.reqPutRequireSuccess = false; @@ -455,6 +459,23 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc this.writing("toHeight", type); this.writing("toCommand", this.mode); this.requireSuccess = true; + } else { + if (isErrorTimeValid(currentTimeMillis)) { + this.errorRequireTime = currentTimeMillis; + String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) + .map(notify -> notify.getValue()) + .orElse("0"); + if (notifyValue.equals("1")) { + JSONObject dataParam = new JSONObject(); + dataParam.put("msg", "申请载具类型高度失败! 请求参数: " + request + "响应信息: " + response.getMessage()); + CommonRequest requestParam = CommonRequest.builder() + .service("ErrorInfo") + .type("1") + .data(dataParam) + .build(); + acsToWmsService.apply(requestParam); + } + } } } } @@ -498,7 +519,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) .map(notify -> notify.getValue()) .orElse("0"); - if (notifyValue.equals("1")){ + if (notifyValue.equals("1")) { JSONObject dataParam = new JSONObject(); dataParam.put("msg", "申请任务失败! 请求参数: " + request + "响应信息: " + response.getMessage()); CommonRequest requestParam = CommonRequest.builder() @@ -540,7 +561,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) .map(notify -> notify.getValue()) .orElse("0"); - if (notifyValue.equals("1")){ + if (notifyValue.equals("1")) { JSONObject dataParam = new JSONObject(); dataParam.put("msg", "申请任务失败! 请求参数: " + request + "响应信息: " + response.getMessage()); CommonRequest requestParam = CommonRequest.builder() @@ -773,7 +794,6 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) cacheDevice.getDeviceDriver(); checkoutStartDeviceCode = appearanceInspectionScannerConveyorDeviceDriver.getExtraDeviceCodes("checkoutStartDeviceCode"); } - List taskDtos = taskService.findReadyTasksByNextDeviceCode(deviceCode, checkoutStartDeviceCode); TaskDto taskDto = taskService.findReadyTaskByNextDeviceCode(deviceCode, checkoutStartDeviceCode); Instruction instDto = instructionService.findReadyInstByEnd(deviceCode); if (ObjectUtil.isNotEmpty(taskDto) && ObjectUtil.isEmpty(instDto)) { @@ -789,8 +809,10 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc return; } DeviceAssignedDto assignedDto = null; + //如果有多个对路由信息 if (assignedDtos.size() > 1) { Map> tempAss = new HashMap<>(); + //遍历路由信息 for (int i = 0; i < assignedDtos.size(); i++) { DeviceAssignedDto deviceAssignedDto = assignedDtos.get(i); String inst_nextDevice_code = deviceAssignedDto.getInst_nextDevice_code(); @@ -802,64 +824,12 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc } deviceAssignedDtos.add(deviceAssignedDto); } - Integer from_y = Integer.parseInt(taskDto.getFrom_y()); - if (bindTaskCode.contains(taskDto.getTask_code())) { - for (DeviceAssignedDto dto : assignedDtos) { - String inst_nextDevice_code = dto.getInst_nextDevice_code(); - Device inst_nextDevice = deviceAppService.findDeviceByCode(inst_nextDevice_code); - if (inst_nextDevice != null) { - Boolean isFront = Optional.ofNullable(inst_nextDevice.getExtraValue().get("isFront")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); - if (from_y % 4 == 1 || from_y % 4 == 2) { - //分配后叉 - if (!isFront) { - assignedDto = dto; - break; - } - } else if (from_y % 4 == 3 || from_y % 4 == 0) { - //分配前叉 - if (isFront) { - assignedDto = dto; - break; - } - } - } - } - } else { - TaskDto bindTaskDto = this.isBind(taskDtos, taskDto, taskDto.getTask_code()); - if (bindTaskDto != null) { - bindTaskCode.add(bindTaskDto.getTask_code()); - for (DeviceAssignedDto dto : assignedDtos) { - String inst_nextDevice_code = dto.getInst_nextDevice_code(); - Device inst_nextDevice = deviceAppService.findDeviceByCode(inst_nextDevice_code); - if (inst_nextDevice != null) { - Boolean isFront = Optional.ofNullable(inst_nextDevice.getExtraValue().get("isFront")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); - if (from_y % 4 == 1 || from_y % 4 == 2) { - //分配后叉 - if (!isFront) { - assignedDto = dto; - break; - } - } else if (from_y % 4 == 3 || from_y % 4 == 0) { - //分配前叉 - if (isFront) { - assignedDto = dto; - break; - } - } - } - } - } else { - Set keys = tempAss.keySet(); - Integer minKey = Collections.min(keys); - Integer maxKey = Collections.max(keys); - List minList = tempAss.get(minKey); - List maxList = tempAss.get(maxKey); - if (minList.size() == maxList.size()) { - - } - assignedDto = minList.get(0); - } - } + Set keys = tempAss.keySet(); + Integer minKey = Collections.min(keys); + Integer maxKey = Collections.max(keys); + List minList = tempAss.get(minKey); + //List maxList = tempAss.get(maxKey); + assignedDto = minList.get(0); } else { assignedDto = assignedDtos.get(0); } @@ -975,32 +945,6 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc } } - private TaskDto isBind(List taskDtos, TaskDto link_task, String task_code) { - String from_x = link_task.getFrom_x(); - String from_y = link_task.getFrom_y(); - String from_z = link_task.getFrom_z(); - return taskDtos.stream() - .filter(taskDto -> !taskDto.getTask_code().equals(task_code)) - .filter(taskDto -> taskDto.getTask_status().equals(TaskStatusEnum.READY.getIndex())) - .filter(taskDto -> taskDto.getFrom_x().equals(from_x) && taskDto.getFrom_z().equals(from_z)) - .filter(taskDto -> { - int frontFromY = Integer.parseInt(from_y); - int taskDtoFromY = Integer.parseInt(taskDto.getFrom_y()); - int frontGroup = (frontFromY - 1) / 4; - int taskDtoGroup = (taskDtoFromY - 1) / 4; - if (frontGroup != taskDtoGroup) { - return false; - } - int frontMod = frontFromY % 4; - int taskDtoMod = taskDtoFromY % 4; - return (frontMod + taskDtoMod == 2 || frontMod + taskDtoMod == 4); - }) - .sorted(Comparator.comparing(TaskDto::getPriority) - .thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) - .findFirst() - .orElse(null); - } - /** * 下发输送线指令 */ @@ -1017,14 +961,8 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc if (next_device != null && next_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { List targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode"); if (targetDeviceCode != null && targetDeviceCode.contains(next_device_code)) { -// if (StrUtil.equals(String.valueOf(this.task), inst.getInstruction_code())) { -// this.writing(Arrays.asList(ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(CommandEnum.COMMAND_1.getValue())); -// this.requireSuccess = true; -// } else { Integer address = Optional.ofNullable(next_device.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0); this.writing(Arrays.asList(ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey()), Arrays.asList(inst.getInstruction_code(), address)); - //this.writing(Arrays.asList(ItemProtocol.TO_TARGET.getKey()), Arrays.asList(address)); -// } this.requireSuccess = true; } } 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 5513362..b710c1f 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 @@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSONObject; import com.google.common.util.concurrent.Uninterruptibles; import lombok.*; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.nl.acs.device.device.domain.Device; import org.nl.acs.device.device.service.DeviceAppService; import org.nl.acs.device.driver.*; @@ -45,9 +46,7 @@ import java.util.stream.Collectors; /** * @Description 1、适用于单/双堆垛机; - * 2、默认优先执行移库任务; - * 3、其次按照堆垛机设置的策略(入库优先(含拣选出库)策略、出库优先策略、时间顺序策略、一进一出策略)执行; - * 4、除移库任务是从任务列表中查找,其余任务都是从指令列表中查找就绪状态下的信息 + * 2、默认优先执行移库任务,其次执行换层任务,再按照堆垛机所在位置执行一进一出的出入库任务; * @Author Gengby * @Date 2024/6/26 */ @@ -360,6 +359,16 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme private List HAS_GOODS = Arrays.asList(2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31); + /** + * 任务申请失败通知时间 + */ + private long errorRequireTime = System.currentTimeMillis(); + + /** + * 任务申请失败请求间隔时间 + */ + private long errorRequireTimeOut = 60000L; + private Map>> createFloorMappingPoint() { List floorPoint = this.getExtraListValue("floorPoint"); Map>> floorMappingPoint = new HashMap<>(); @@ -506,7 +515,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) .map(notify -> notify.getValue()) .orElse("0"); - if (notifyValue.equals("1")){ + if (notifyValue.equals("1")) { JSONObject dataParam = new JSONObject(); dataParam.put("msg", "设备" + this.currentDeviceCode + "报警, 报警信息: 前叉 " + ErrorEnum.getDesc(this.front_Zerror) + ", 后叉 " + ErrorEnum.getDesc(this.back_Zerror)); CommonRequest requestParam = CommonRequest.builder() @@ -537,11 +546,13 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme if (this.back_command != this.lastBack_command || this.front_command != this.lastFront_command) { this.requireSuccess = false; } + if (this.front_Zerror != this.lastFront_Zerror || this.back_Zerror != this.lastBack_Zerror) { if (AGAIN_ERROR.contains(this.front_Zerror) || AGAIN_ERROR.contains(this.back_Zerror)) { this.againRequireSuccess = false; } } + if (this.front_Zerror == ErrorEnum.MR.getCode()) { if (!this.againRequireSuccess) { this.mR(this.front_task, ForkTypeEnum.FRONT.getCode()); @@ -551,6 +562,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme this.mR(this.back_task, ForkTypeEnum.BACK.getCode()); } } + if (this.front_Zerror == ErrorEnum.KC.getCode() && this.back_Zerror == ErrorEnum.KC.getCode()) { if (!this.againRequireSuccess) { this.kC(this.front_task); @@ -573,6 +585,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } } } + if (this.front_Zerror == ErrorEnum.ZD.getCode() && this.back_Zerror == ErrorEnum.ZD.getCode() && NO_HAS_GOODS.contains(this.front_forkCargo) && NO_HAS_GOODS.contains(this.back_forkCargo) ) { @@ -686,52 +699,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } //出库 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, getFrontDeviceCodeList); - if (ObjectUtil.isNotEmpty(frontInst)) { - String qPoint = getZdPoint(frontInst.getStart_point_code()); - TaskDto taskDto = taskService.findByStartPointCode(qPoint); - if (ObjectUtil.isNotEmpty(taskDto)) { - String task_start_device_code = taskDto.getStart_device_code(); - String task_next_device_code = taskDto.getNext_device_code(); - Device task_start_device = deviceAppService.findDeviceByCode(task_start_device_code); - Device task_next_devcice = deviceAppService.findDeviceByCode(task_next_device_code); - if (task_start_device != null && task_next_devcice != null && instanceStorage(task_start_device) && instanceStorage(task_next_devcice)) { - Instruction instruction = instructionService.findByTaskCodeFromCache(taskDto.getTask_code()); - if (ObjectUtil.isEmpty(instruction)) { - frontInst = new Instruction(); - setInstruction(frontInst, taskDto); - try { - instructionService.create(frontInst); - taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskService.update(taskDto); - } catch (Exception e) { - this.unExecutedMessage = "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage(); - logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage())); - logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); - this.sendPutInfoToPlc(null, backInst); - return; - } - this.frontWrite(frontInst); - } else { - if (StrUtil.equals(instruction.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - this.frontWrite(instruction); - } else { - this.sendPutInfoToPlc(null, backInst); - } - } - } else { - this.sendPutInfoToPlc(null, backInst); - } - } else { - this.frontWrite(frontInst); - } - } else { - this.sendPutInfoToPlc(null, backInst); - } - } + //前叉有货,后叉无货,后叉取货完成 + this.backGetFinish(back_next_device, frontInst, backInst, getFrontDeviceCodeList); this.requireSuccess = true; } else { this.sendPutInfoToPlc(frontInst, backInst); @@ -773,52 +742,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } //出库 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, getBackDeviceCodeList); - if (ObjectUtil.isNotEmpty(backInst)) { - String qPoint = getZdPoint(backInst.getStart_point_code()); - TaskDto taskDto = taskService.findByStartPointCode(qPoint); - if (ObjectUtil.isNotEmpty(taskDto)) { - String task_start_device_code = taskDto.getStart_device_code(); - String task_next_device_code = taskDto.getNext_device_code(); - Device task_start_device = deviceAppService.findDeviceByCode(task_start_device_code); - Device task_next_devcice = deviceAppService.findDeviceByCode(task_next_device_code); - if (task_start_device != null && task_next_devcice != null && instanceStorage(task_start_device) && instanceStorage(task_next_devcice)) { - Instruction instruction = instructionService.findByTaskCodeFromCache(taskDto.getTask_code()); - if (ObjectUtil.isEmpty(instruction)) { - backInst = new Instruction(); - setInstruction(backInst, taskDto); - try { - instructionService.create(backInst); - taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskService.update(taskDto); - } catch (Exception e) { - this.unExecutedMessage = "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage(); - logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage())); - logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); - this.sendPutInfoToPlc(frontInst, null); - return; - } - this.backWrite(backInst); - } else { - if (StrUtil.equals(instruction.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - this.backWrite(instruction); - } else { - this.sendPutInfoToPlc(frontInst, null); - } - } - } else { - this.sendPutInfoToPlc(frontInst, null); - } - } else { - this.backWrite(backInst); - } - } else { - this.sendPutInfoToPlc(frontInst, null); - } - } + //前叉有货,后叉无货,前叉取货完成 + this.frontGetFinish(front_next_device, frontInst, backInst, getBackDeviceCodeList); this.requireSuccess = true; } else { this.sendPutInfoToPlc(frontInst, backInst); @@ -878,60 +803,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } //出库 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.findShallowReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, backNoY, getBackDeviceCodeList); - if (ObjectUtil.isNotEmpty(backInst)) { - this.backWrite(backInst); - } else { - backInst = instructionService.findDeepReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, backNoY, getBackDeviceCodeList); - if (ObjectUtil.isNotEmpty(backInst)) { - String qPoint = getZdPoint(backInst.getStart_point_code()); - TaskDto taskDto = taskService.findByStartPointCode(qPoint); - if (ObjectUtil.isNotEmpty(taskDto)) { - String task_start_device_code = taskDto.getStart_device_code(); - String task_next_device_code = taskDto.getNext_device_code(); - Device task_start_device = deviceAppService.findDeviceByCode(task_start_device_code); - Device task_next_devcice = deviceAppService.findDeviceByCode(task_next_device_code); - if (task_start_device != null && task_next_devcice != null && instanceStorage(task_start_device) && instanceStorage(task_next_devcice)) { - Instruction instruction = instructionService.findByTaskCodeFromCache(taskDto.getTask_code()); - if (ObjectUtil.isEmpty(instruction)) { - backInst = new Instruction(); - setInstruction(backInst, taskDto); - try { - instructionService.create(backInst); - taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskService.update(taskDto); - } catch (Exception e) { - this.unExecutedMessage = "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage(); - logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage())); - logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); - this.sendPutInfoToPlc(frontInst, null); - return; - } - this.backWrite(backInst); - } else { - if (StrUtil.equals(instruction.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - this.backWrite(instruction); - } else { - this.sendPutInfoToPlc(frontInst, null); - } - } - } else { - this.sendPutInfoToPlc(frontInst, null); - } - } else { - this.backWrite(backInst); - } - } else { - //下发前叉放货信息 - this.sendPutInfoToPlc(frontInst, backInst); - } - } - } else { - this.sendPutInfoToPlc(frontInst, backInst); - } + //前叉取货完成 + this.frontGetFinish(front_next_device, frontInst, backInst, getBackDeviceCodeList); } else if (instanceAppearance(front_start_device) && instanceAppearance(front_next_device)) { if (ObjectUtil.isEmpty(backInst)) { // List getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList"); @@ -992,60 +865,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } //出库 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.findShallowReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList); - if (ObjectUtil.isNotEmpty(frontInst)) { - this.frontWrite(frontInst); - } else { - frontInst = instructionService.findDeepReadyInstByLinkDeviceCodeAndNextDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList); - if (ObjectUtil.isNotEmpty(frontInst)) { - String qPoint = getZdPoint(frontInst.getStart_point_code()); - TaskDto taskDto = taskService.findByStartPointCode(qPoint); - if (ObjectUtil.isNotEmpty(taskDto)) { - String task_start_device_code = taskDto.getStart_device_code(); - String task_next_device_code = taskDto.getNext_device_code(); - Device task_start_device = deviceAppService.findDeviceByCode(task_start_device_code); - Device task_next_devcice = deviceAppService.findDeviceByCode(task_next_device_code); - if (task_start_device != null && task_next_devcice != null && instanceStorage(task_start_device) && instanceStorage(task_next_devcice)) { - Instruction instruction = instructionService.findByTaskCodeFromCache(taskDto.getTask_code()); - if (ObjectUtil.isEmpty(instruction)) { - frontInst = new Instruction(); - setInstruction(frontInst, taskDto); - try { - instructionService.create(frontInst); - taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskService.update(taskDto); - } catch (Exception e) { - this.unExecutedMessage = "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage(); - logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage())); - logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); - this.sendPutInfoToPlc(null, backInst); - return; - } - this.frontWrite(frontInst); - } else { - if (StrUtil.equals(instruction.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - this.frontWrite(instruction); - } else { - this.sendPutInfoToPlc(null, backInst); - } - } - } else { - this.sendPutInfoToPlc(null, backInst); - } - } else { - this.frontWrite(frontInst); - } - } else { - //下发前叉放货信息 - this.sendPutInfoToPlc(frontInst, backInst); - } - } - } else { - this.sendPutInfoToPlc(frontInst, backInst); - } + //后叉取货完成 + this.backGetFinish(back_next_device, frontInst, backInst, getFrontDeviceCodeList); } else if (instanceAppearance(back_start_device) && instanceAppearance(back_next_device)) { if (ObjectUtil.isEmpty(frontInst)) { //List getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList"); @@ -1079,9 +900,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme this.clearInfoToPlc(); } else if (this.lastFront_command != CommandEnum.UNLOAD.getStatus() && this.front_command != CommandEnum.STANDY.getStatus()) { this.clearInfoToPlc(); - } else { - this.requireSuccess = true; } + this.requireSuccess = true; } //请求卸货 else if (mode == ModeEnum.MODE_3.getNum() && this.isUnload() && !requireSuccess) { @@ -1274,18 +1094,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } else { String strategyValue = Optional.ofNullable(this.getExtraValue().get("strategyValue")).map(Object::toString).orElse(""); switch (strategyValue) { - case "2": - this.applyOutTask(); - break; - case "3": - this.applyTaskByTime(); - break; case "4": this.applyTaskOneInOneOut(); break; - default: - this.applyInTask(); - break; } } } else { @@ -1304,7 +1115,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme /** - * 拣选出库 + * 堆垛机换层任务 * * @return */ @@ -1360,230 +1171,6 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme return true; } - - /** - * 入库 - */ - private void applyInTask() { - boolean flag = this.applySpecialTask(); - if (flag) { - this.unExecutedMessage = null; - return; - } - if (!prohibitInWarehouse) { - List getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList"); - String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY"); - List getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList"); - String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); - List frontInsts = instructionService.findReadyInstByStartDeviceCode(getFrontDeviceCodeList, frontNoY); - Instruction frontInst = null; - Instruction backInst = null; - Device front_start_device = null; - Device back_start_device = null; - if (CollectionUtil.isNotEmpty(frontInsts)) { - frontInst = frontInsts.get(0); - if (ObjectUtil.isNotEmpty(frontInst)) { - String front_start_device_code = frontInst.getStart_device_code(); - front_start_device = deviceAppService.findDeviceByCode(front_start_device_code); - if (front_start_device != null) { - String getLinkDeviceCode = this.handExtraStringValue(front_start_device, "getLinkDeviceCode"); - backInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, backNoY, getBackDeviceCodeList); - if (ObjectUtil.isEmpty(backInst)) { - Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode); - if (ObjectUtil.isNotEmpty(inst)) { - return; - } - } - } - } - } else { - if (this.stackerNum == 2) { - List backInsts = instructionService.findReadyInstByStartDeviceCode(getBackDeviceCodeList, backNoY); - if (CollectionUtil.isNotEmpty(backInsts)) { - backInst = backInsts.get(0); - } - if (ObjectUtil.isNotEmpty(backInst)) { - String back_start_device_code = backInst.getStart_device_code(); - back_start_device = deviceAppService.findDeviceByCode(back_start_device_code); - if (back_start_device != null) { - String getLinkDeviceCode = this.handExtraStringValue(back_start_device, "getLinkDeviceCode"); - front_start_device = deviceAppService.findDeviceByCode(getLinkDeviceCode); - if (front_start_device != null) { - frontInst = instructionService.findReadyInstByLinkDeviceCodeAndStartDeviceCode(getLinkDeviceCode, frontNoY, getFrontDeviceCodeList); - if (ObjectUtil.isEmpty(frontInst)) { - Instruction inst = instructionService.findBusyInstByNextDeviceCode(getLinkDeviceCode); - if (ObjectUtil.isNotEmpty(inst)) { - return; - } - } - } - } - } - } - } - if (ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) { - this.FBWrite(front_start_device, frontInst, backInst); - this.unExecutedMessage = null; - this.requireSuccess = true; - } else if (ObjectUtil.isNotEmpty(frontInst)) { - this.frontWrite(front_start_device, frontInst); - this.unExecutedMessage = null; - this.requireSuccess = true; - } else if (ObjectUtil.isNotEmpty(backInst)) { - this.backWrite(back_start_device, backInst); - this.unExecutedMessage = null; - this.requireSuccess = true; - } else { - String strategyValue = Optional.ofNullable(this.getExtraValue().get("strategyValue")).map(Object::toString).orElse(""); - if (ObjectUtil.equals(strategyValue, StrategyEnum.IN.getValue())) { - this.applyOutTask(); - } else if (ObjectUtil.equals(strategyValue, StrategyEnum.OUT.getValue()) && !ObjectUtil.equals(strategyValue, StrategyEnum.TIME.getValue())) { - this.unExecutedMessage = "堆垛机未查询到就绪状态下可执行的任务或指令信息"; - } - } - } else { - if (this.prohibitOutWarehouse) { - this.unExecutedMessage = "堆垛机设置为禁止出库、禁止入库"; - return; - } - this.applyOutTask(); - } - } - - /** - * 出库(含拣选) - */ - private void applyOutTask() { - if (!this.prohibitOutWarehouse) { - List getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList"); - List getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList"); - String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY"); - String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); - List frontInsts = instructionService.findReadyInstByNextDeviceCode(getFrontDeviceCodeList, frontNoY); - Instruction frontInst = null; - Instruction backInst = null; - if (CollectionUtil.isNotEmpty(frontInsts)) { - frontInst = frontInsts.get(0); - if (ObjectUtil.isNotEmpty(frontInst) && this.stackerNum == 2) { - String front_next_device_code = frontInst.getNext_device_code(); - Device front_next_device = deviceAppService.findDeviceByCode(front_next_device_code); - if (front_next_device != null) { - String getLinkDeviceCode = this.handExtraStringValue(front_next_device, "getLinkDeviceCode"); - backInst = instructionService.findReadyInstByNextDeviceCode(frontInst, getLinkDeviceCode, backNoY); - } - } - } else { - if (this.stackerNum == 2) { - List backInsts = instructionService.findReadyInstByNextDeviceCode(getBackDeviceCodeList, backNoY); - if (CollectionUtil.isNotEmpty(backInsts)) { - backInst = backInsts.get(0); - } - } - } - if (ObjectUtil.isNotEmpty(frontInst) && ObjectUtil.isNotEmpty(backInst)) { - this.FBWrite(frontInst, backInst); - this.unExecutedMessage = null; - this.requireSuccess = true; - } else if (ObjectUtil.isNotEmpty(frontInst)) { - this.frontWrite(frontInst); - this.unExecutedMessage = null; - this.requireSuccess = true; - } else if (ObjectUtil.isNotEmpty(backInst)) { - this.backWrite(backInst); - this.unExecutedMessage = null; - this.requireSuccess = true; - } else { - String strategyValue = Optional.ofNullable(this.getExtraValue().get("strategyValue")).map(Object::toString).orElse(""); - if (ObjectUtil.equals(strategyValue, StrategyEnum.OUT.getValue())) { - this.applyInTask(); - } else if (ObjectUtil.equals(strategyValue, StrategyEnum.IN.getValue()) && !ObjectUtil.equals(strategyValue, StrategyEnum.TIME.getValue())) { - this.unExecutedMessage = "堆垛机未查询到就绪状态下可执行的任务或指令信息"; - } - } - } else { - if (this.prohibitInWarehouse) { - this.unExecutedMessage = "堆垛机设置为禁止出库、禁止入库"; - return; - } - this.applyInTask(); - } - } - - /** - * 时间顺序策略 - */ - private void applyTaskByTime() { - boolean flag = this.applySpecialTask(); - if (flag) { - this.unExecutedMessage = null; - return; - } - List getFrontDeviceCodeList = this.getExtraDeviceCodes("frontDeviceCodeList"); - String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY"); - List frontInsts = instructionService.findReadyInstByDeviceCode(getFrontDeviceCodeList, frontNoY); - Instruction frontInst = null; - if (CollectionUtil.isNotEmpty(frontInsts)) { - frontInst = frontInsts.get(0); - } - if (ObjectUtil.isNotEmpty(frontInst)) { - String front_start_device_code = frontInst.getStart_device_code(); - Device front_start_device = deviceAppService.findDeviceByCode(front_start_device_code); - String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); - if (front_start_device != null && front_start_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { - String getLinkDeviceCode = this.handExtraStringValue(front_start_device, "getLinkDeviceCode"); - Instruction backInst = instructionService.findReadyInstByStartDeviceCode(frontInst, getLinkDeviceCode, backNoY); - if (ObjectUtil.isNotEmpty(getLinkDeviceCode) && deviceAppService.findDeviceByCode(getLinkDeviceCode) != null && ObjectUtil.isNotEmpty(backInst)) { - this.FBWrite(front_start_device, frontInst, backInst); - this.unExecutedMessage = null; - this.requireSuccess = true; - } else { - this.frontWrite(front_start_device, frontInst); - this.unExecutedMessage = null; - this.requireSuccess = true; - } - } else if (front_start_device != null && front_start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - String next_device_code = frontInst.getNext_device_code(); - Device next_device = deviceAppService.findDeviceByCode(next_device_code); - if (next_device != null && next_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { - String getLinkDeviceCode = Optional.ofNullable(next_device.getExtraValue().get("getLinkDeviceCode")).map(Object::toString).orElse(null); - Instruction backInst = instructionService.findReadyInstByNextDeviceCode(frontInst, getLinkDeviceCode, backNoY); - if (ObjectUtil.isNotEmpty(getLinkDeviceCode) && deviceAppService.findDeviceByCode(getLinkDeviceCode) != null && ObjectUtil.isNotEmpty(backInst)) { - this.FBWrite(frontInst, backInst); - this.unExecutedMessage = null; - this.requireSuccess = true; - } else { - this.frontWrite(frontInst); - this.unExecutedMessage = null; - this.requireSuccess = true; - } - } - } - } else { - List getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList"); - String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); - List backInsts = instructionService.findReadyInstByDeviceCode(getBackDeviceCodeList, backNoY); - Instruction backInst = null; - if (CollectionUtil.isNotEmpty(backInsts)) { - backInst = backInsts.get(0); - } - if (ObjectUtil.isNotEmpty(backInst)) { - String back_start_device_code = backInst.getStart_device_code(); - Device back_start_device = deviceAppService.findDeviceByCode(back_start_device_code); - if (back_start_device != null && back_start_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { - this.backWrite(back_start_device, backInst); - this.unExecutedMessage = null; - this.requireSuccess = true; - } else if (back_start_device != null && back_start_device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - this.backWrite(backInst); - this.unExecutedMessage = null; - this.requireSuccess = true; - } - } else { - this.unExecutedMessage = "堆垛机未查询到就绪状态下可执行的任务或指令信息"; - } - } - } - /** * 一进一出策略 * 根据楼层优先级 @@ -1884,9 +1471,34 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme List getBackDeviceCodeList = this.getExtraDeviceCodes("backDeviceCodeList"); String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY"); String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); - List frontInsts = instructionService.findShallowReadyInstByNextDeviceCode(getFrontDeviceCodeList, frontNoY); - if (CollectionUtil.isNotEmpty(frontInsts)) { - frontInst = frontInsts.get(0); + //先根据优先级和时间顺序查看指令信息 + List frontInsts = instructionService.findAllInstByPriorityCreateTime(getFrontDeviceCodeList, frontNoY); + //如果查询到的是浅货位的指令信息,则直接下发 + if (CollectionUtils.isNotEmpty(frontInsts)) { + for (Instruction inst : frontInsts) { + String start_device_code = inst.getStart_device_code(); + //判断当前库位是深库位还是浅库位 + int x = Integer.parseInt(getNumericPart(start_device_code)); + //如果是深库位 + if (x == 1 || x == 4) { + //查询对应的浅货位编码 + String shallStartPointCode = getZdPoint(inst.getStart_point_code()); + //查询对应的浅库位是否存在就绪的指令信息 + Instruction shallInst = instructionService.findReadyInstByStartPointCode(shallStartPointCode); + if (shallInst != null) { + frontInst = shallInst; + break; + } + //若不存在,则查询是否存在就绪的任务信息 + TaskDto shallTask = taskService.findReadyByStartPointCode(shallStartPointCode); + if (shallTask != null) { + continue; + } + //如果不存在就绪的指令信息和任务信息,直接结束循环 + } + frontInst = inst; + break; + } if (ObjectUtil.isNotEmpty(frontInst) && this.stackerNum == 2) { String front_next_device_code = frontInst.getNext_device_code(); Device front_next_device = deviceAppService.findDeviceByCode(front_next_device_code); @@ -1899,28 +1511,30 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } } else { if (this.stackerNum == 2) { - List backInsts = instructionService.findShallowReadyInstByNextDeviceCode(getBackDeviceCodeList, backNoY); - if (CollectionUtil.isNotEmpty(backInsts)) { - backInst = backInsts.get(0); - } else { - frontInsts = instructionService.findDeepReadyInstByNextDeviceCode(getFrontDeviceCodeList, frontNoY); - if (CollectionUtil.isNotEmpty(frontInsts)) { - frontInst = frontInsts.get(0); - if (ObjectUtil.isNotEmpty(frontInst) && this.stackerNum == 2) { - String front_next_device_code = frontInst.getNext_device_code(); - Device front_next_device = deviceAppService.findDeviceByCode(front_next_device_code); - if (front_next_device != null) { - String getLinkDeviceCode = this.handExtraStringValue(front_next_device, "getLinkDeviceCode"); - if (StrUtil.isNotEmpty(getLinkDeviceCode)) { - backInst = instructionService.findDeepReadyInstByNextDeviceCode(frontInst, getLinkDeviceCode, backNoY, getBackDeviceCodeList); - } + List backInsts = instructionService.findAllInstByPriorityCreateTime(getBackDeviceCodeList, backNoY); + if (CollectionUtils.isNotEmpty(backInsts)) { + for (Instruction inst : backInsts) { + String start_device_code = inst.getStart_device_code(); + //判断当前库位是深库位还是浅库位 + int x = Integer.parseInt(getNumericPart(start_device_code)); + //如果是深库位 + if (x == 1 || x == 4) { + //查询对应的浅货位编码 + String shallStartPointCode = getZdPoint(inst.getStart_point_code()); + //查询对应的浅库位是否存在就绪的指令信息 + Instruction shallInst = instructionService.findReadyInstByStartPointCode(shallStartPointCode); + if (shallInst != null) { + backInst = shallInst; + break; + } + //若不存在,则查询是否存在就绪的任务信息 + TaskDto shallTask = taskService.findReadyByStartPointCode(shallStartPointCode); + if (shallTask != null) { + continue; } } - } else { - backInsts = instructionService.findDeepReadyInstByNextDeviceCode(getBackDeviceCodeList, backNoY); - if (CollectionUtil.isNotEmpty(backInsts)) { - backInst = backInsts.get(0); - } + backInst = inst; + break; } } } @@ -2208,7 +1822,6 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme Device front_device = deviceAppService.findDeviceByCode(front_start_device_code); Device back_device = deviceAppService.findDeviceByCode(back_start_device_code); String back_device_code = this.handExtraStringValue(front_device, "getLinkDeviceCode"); - if (instanceStorage(front_device) && instanceStorage(back_device)) { String front_from_x = frontInst.getFrom_x(); String front_from_y = frontInst.getFrom_y(); @@ -2334,6 +1947,11 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme this.requireSuccess = true; } + + private boolean isErrorTimeValid(long errorCurrentTimeMillis) { + return errorCurrentTimeMillis - this.errorRequireTime >= this.errorRequireTimeOut; + } + /** * 满入 */ @@ -2369,6 +1987,23 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } this.againRequireSuccess = true; } + } else { + if (isErrorTimeValid(currentTimeMillis)) { + this.errorRequireTime = currentTimeMillis; + String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) + .map(notify -> notify.getValue()) + .orElse("0"); + if (notifyValue.equals("1")) { + JSONObject dataParam = new JSONObject(); + dataParam.put("msg", "堆垛机满入申请重新分配库位失败! 请求参数: " + request + "响应信息: " + response.getMessage()); + CommonRequest requestParam = CommonRequest.builder() + .service("ErrorInfo") + .type("1") + .data(dataParam) + .build(); + acsToWmsService.apply(requestParam); + } + } } } } @@ -2400,6 +2035,23 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme instructionService.cancelInstAndTask(inst.getInstruction_id()); this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_FIVE.getSignalNum()); this.againRequireSuccess = true; + } else { + if (isErrorTimeValid(currentTimeMillis)) { + this.errorRequireTime = currentTimeMillis; + String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) + .map(notify -> notify.getValue()) + .orElse("0"); + if (notifyValue.equals("1")) { + JSONObject dataParam = new JSONObject(); + dataParam.put("msg", "堆垛机空出反馈WMS失败! 请求参数: " + request + "响应信息: " + response.getMessage()); + CommonRequest requestParam = CommonRequest.builder() + .service("ErrorInfo") + .type("1") + .data(dataParam) + .build(); + acsToWmsService.apply(requestParam); + } + } } } } @@ -2441,6 +2093,23 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } this.writing(ItemProtocol.TO_COMMAND.getKey(), SendSignalEnum.COMMAND_FIVE.getSignalNum()); this.againRequireSuccess = true; + } else { + if (isErrorTimeValid(currentTimeMillis)) { + this.errorRequireTime = currentTimeMillis; + String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) + .map(notify -> notify.getValue()) + .orElse("0"); + if (notifyValue.equals("1")) { + JSONObject dataParam = new JSONObject(); + dataParam.put("msg", "堆垛机取货时浅货位有货反馈WMS失败! 请求参数: " + request + "响应信息: " + response.getMessage()); + CommonRequest requestParam = CommonRequest.builder() + .service("ErrorInfo") + .type("1") + .data(dataParam) + .build(); + acsToWmsService.apply(requestParam); + } + } } } } @@ -2497,6 +2166,23 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } } this.againRequireSuccess = true; + } else { + if (isErrorTimeValid(currentTimeMillis)) { + this.errorRequireTime = currentTimeMillis; + String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify")) + .map(notify -> notify.getValue()) + .orElse("0"); + if (notifyValue.equals("1")) { + JSONObject dataParam = new JSONObject(); + dataParam.put("msg", "堆垛机放货时浅货位有货申请重新分配库位失败! 请求参数: " + request + "响应信息: " + response.getMessage()); + CommonRequest requestParam = CommonRequest.builder() + .service("ErrorInfo") + .type("1") + .data(dataParam) + .build(); + acsToWmsService.apply(requestParam); + } + } } } } @@ -2603,4 +2289,178 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme instdto.setInstruction_type(taskDto.getTask_type()); } -} + + /** + * 出库时,后叉取货完成,下发前叉取/后叉放货信息 + * + * @param back_next_device + * @param frontInst + * @param getFrontDeviceCodeList + */ + private void backGetFinish(Device back_next_device, Instruction frontInst, Instruction backInst, List getFrontDeviceCodeList) { + List xDeviceCodeList = this.getExtraDeviceCodes("xDeviceCodeList"); + String getLinkDeviceCode = this.handExtraStringValue(back_next_device, "getLinkDeviceCode"); + String frontNoY = this.handExtraStringValue(this.getDevice(), "frontNoY"); + if (ObjectUtil.isEmpty(frontInst)) { + //前叉无货,后叉有货,前叉无指令信息,后叉有指令信息 + //根据后叉关联点位,按照优先级、创建时间去查询前叉指令信息 + List frontInsts = instructionService.findAllInstByPriorityCreateTime(getLinkDeviceCode, getFrontDeviceCodeList, frontNoY); + //遍历前叉指令信息,判断前叉指令起点是深库位还是浅库位 + if (CollectionUtils.isNotEmpty(frontInsts)) { + for (Instruction inst : frontInsts) { + String start_device_code = inst.getStart_device_code(); + //判断当前库位是深库位还是浅库位 + int x = Integer.parseInt(getNumericPart(start_device_code)); + //如果是深库位 + if (x == 1 || x == 4) { + //查询对应的浅货位编码 + String shallStartPointCode = getZdPoint(inst.getStart_point_code()); + //查询对应的浅库位是否存在就绪的指令信息 + Instruction shallInst = instructionService.findReadyInstByStartPointCode(shallStartPointCode); + if (shallInst != null) { + //判断该就绪的指令信息是否是堆垛机库内移库指令信息 + String next_device_code = shallInst.getNext_device_code(); + if (xDeviceCodeList.contains(next_device_code)) { + Set currentNoY = frontNoY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(frontNoY.split(","))); + //如果是的话,判断终点是否前叉可达的, + if (!currentNoY.contains(String.valueOf(Integer.parseInt(shallInst.getFrom_y())))) { + // 如果前叉可达,则下发前叉移库指令的取货信息 break; + this.frontWrite(shallInst); + break; + } + // 否则直接下发后叉放货信息 break + this.sendPutInfoToPlc(null, backInst); + break; + } + continue; + } + //若不存在,则查询是否存在就绪的任务信息 + TaskDto shallTask = taskService.findReadyByStartPointCode(shallStartPointCode); + if (shallTask != null) { + //判断该就绪的任务信息是否是堆垛机库内移库任务信息 + String next_device_code = shallTask.getNext_device_code(); + if (xDeviceCodeList.contains(next_device_code)) { + Set currentNoY = frontNoY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(frontNoY.split(","))); + //如果是的话,判断终点是否前叉可达的, + if (!currentNoY.contains(String.valueOf(Integer.parseInt(shallTask.getFrom_y())))) { + // 如果前叉可达,则创建移库指令,并下发前叉移库指令的取货信息 break; + frontInst = new Instruction(); + setInstruction(frontInst, shallTask); + try { + instructionService.create(frontInst); + shallTask.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskService.update(shallTask); + } catch (Exception e) { + this.unExecutedMessage = "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage(); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage())); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); + this.sendPutInfoToPlc(null, backInst); + return; + } + } + // 否则直接下发后叉放货信息 break + this.sendPutInfoToPlc(null, backInst); + break; + } + continue; + } + } + frontInst = inst; + this.frontWrite(frontInst); + //直接下发前叉取货信息 + break; + } + } else { + this.sendPutInfoToPlc(null, backInst); + } + } + } + + + /** + * 出库时,前叉取货完成,下发后叉取/前叉放货信息 + * + * @param front_next_device + * @param frontInst + * @param backInst + * @param getBackDeviceCodeList + */ + private void frontGetFinish(Device front_next_device, Instruction frontInst, Instruction backInst, List getBackDeviceCodeList) { + List xDeviceCodeList = this.getExtraDeviceCodes("xDeviceCodeList"); + String getLinkDeviceCode = this.handExtraStringValue(front_next_device, "getLinkDeviceCode"); + String backNoY = this.handExtraStringValue(this.getDevice(), "backNoY"); + if (ObjectUtil.isEmpty(backInst)) { + //根据后叉关联点位,按照优先级、创建时间去查询后叉指令信息 + List backInsts = instructionService.findAllInstByPriorityCreateTime(getLinkDeviceCode, getBackDeviceCodeList, backNoY); + //遍历后叉指令信息,判断后叉指令起点是深库位还是浅库位 + if (CollectionUtils.isNotEmpty(backInsts)) { + for (Instruction inst : backInsts) { + String start_device_code = inst.getStart_device_code(); + //判断当前库位是深库位还是浅库位 + int x = Integer.parseInt(getNumericPart(start_device_code)); + //如果是深库位 + if (x == 1 || x == 4) { + //查询对应的浅货位编码 + String shallStartPointCode = getZdPoint(inst.getStart_point_code()); + //查询对应的浅库位是否存在就绪的指令信息 + Instruction shallInst = instructionService.findReadyInstByStartPointCode(shallStartPointCode); + if (shallInst != null) { + //判断该就绪的指令信息是否是堆垛机库内移库指令信息 + String next_device_code = shallInst.getNext_device_code(); + if (xDeviceCodeList.contains(next_device_code)) { + Set currentNoY = backNoY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(backNoY.split(","))); + //如果是的话,判断终点是否后叉可达的, + if (!currentNoY.contains(String.valueOf(Integer.parseInt(shallInst.getFrom_y())))) { + // 如果后叉可达,则下发后叉移库指令的取货信息 break; + this.backWrite(shallInst); + break; + } + // 否则直接下发前叉放货信息 break + this.sendPutInfoToPlc(frontInst, null); + break; + } + continue; + } + //若不存在,则查询是否存在就绪的任务信息 + TaskDto shallTask = taskService.findReadyByStartPointCode(shallStartPointCode); + if (shallTask != null) { + //判断该就绪的任务信息是否是堆垛机库内移库任务信息 + String next_device_code = shallTask.getNext_device_code(); + if (xDeviceCodeList.contains(next_device_code)) { + Set currentNoY = backNoY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(backNoY.split(","))); + //如果是的话,判断终点是否后叉可达的, + if (!currentNoY.contains(String.valueOf(Integer.parseInt(shallTask.getFrom_y())))) { + // 如果后叉可达,则创建移库指令,并下发后叉移库指令的取货信息 break; + backInst = new Instruction(); + setInstruction(backInst, shallTask); + try { + instructionService.create(backInst); + shallTask.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskService.update(shallTask); + } catch (Exception e) { + this.unExecutedMessage = "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage(); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage())); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); + this.sendPutInfoToPlc(frontInst, null); + return; + } + } + // 否则直接下发前叉放货信息 break + this.sendPutInfoToPlc(frontInst, null); + break; + } + continue; + } + } + //直接下发后叉取货信息 + backInst = inst; + this.backWrite(backInst); + break; + } + } else { + this.sendPutInfoToPlc(frontInst, null); + } + } + } + +} \ No newline at end of file diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java index faf1c5e..8932094 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java @@ -493,32 +493,6 @@ public interface InstructionService extends CommonService { * @return */ List findReadyInstByNextDeviceCode(List next_device_code_list, String noY); - List findDeepReadyInstByNextDeviceCode(List next_device_code_list, String noY); - List findShallowReadyInstByNextDeviceCode(List next_device_code_list, String noY); - - /** - * 用于时间顺序出入库策略 - * 查询前叉或后叉可达设备的指令信息 - * - * @param device_code_list - * @param noY - * @return - */ - List findReadyInstByDeviceCode(List device_code_list, String noY); - - - /** - * 用于优先入库策略和时间顺序策略 - * 主要是根据前叉指令排列层信息及前叉指令起点关联设备 - * 一般是入库时根据指令起点查询是否可组成双叉指令 - * - * @param frontInst - * @param link_device_code - * @param noY - * @return - */ - Instruction findReadyInstByStartDeviceCode(Instruction frontInst, String link_device_code, String noY); - /** * @param linkDeviceCode @@ -541,10 +515,6 @@ public interface InstructionService extends CommonService { */ Instruction findShallowReadyInstByLinkDeviceCodeAndStartDeviceCode(String linkDeviceCode, String noY, List getDeviceCodeList); - Instruction findReadyInstByLinkDeviceCodeAndNextDeviceCode(String linkDeviceCode, String noY, List getDeviceCodeList); - Instruction findDeepReadyInstByLinkDeviceCodeAndNextDeviceCode(String linkDeviceCode, String noY,List getDeviceCodeList); - Instruction findShallowReadyInstByLinkDeviceCodeAndNextDeviceCode(String linkDeviceCode, String noY,List getDeviceCodeList); - /** * 用于优先出库策略和时间顺序策略 -出库 * 主要是根据前叉指令的排列层、前叉指令终点的关联设备,查询后叉指令信息 @@ -556,7 +526,8 @@ public interface InstructionService extends CommonService { * @return */ Instruction findReadyInstByNextDeviceCode(Instruction frontInst, String link_device_code, String noY); - Instruction findDeepReadyInstByNextDeviceCode(Instruction frontInst, String link_device_code, String noY, List getDeviceCodeList); + + Instruction findShallowReadyInstByNextDeviceCode(Instruction frontInst, String link_device_code, String noY, List getDeviceCodeList); @@ -572,6 +543,8 @@ public interface InstructionService extends CommonService { Instruction findReadyInstByEnd(String next_device_code); + Instruction findReadyInstByStartPointCode(String start_point_code); + int findReadyInstNumByEnd(String next_device_code); Instruction findReadyInstByVehicleCode(String vehicleCode); @@ -586,9 +559,26 @@ public interface InstructionService extends CommonService { void cancelInstAndTaskNoSendWms(String instruction_id); - List findReadyInstByXDeviceCode(List xDeviceCodeList, String noY); + List findReadyInstByXDeviceCode(List xDeviceCodeList, String noY); Instruction findByNextPointCode(String nextPointCode); - List findInstsByNextDeviceCode(String deviceCode); + + /** + * 根据优先级和创建时间顺序去查找前/后叉可取指令信息 + * + * @param next_device_code_list + * @param noY + * @return + */ + List findAllInstByPriorityCreateTime(List next_device_code_list, String noY); + + /** + * 根据前后叉对接位关联点位及优先级和创建时间顺序去查找前/后叉可取指令信息 + * + * @param next_device_code_list + * @param noY + * @return + */ + List findAllInstByPriorityCreateTime(String link_device_code, List next_device_code_list, String noY); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 03f07ea..36dad34 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -1954,59 +1954,6 @@ public class InstructionServiceImpl extends CommonServiceImpl findDeepReadyInstByNextDeviceCode(List next_device_code_list, String noY) { - Set 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() - .sorted(Comparator.comparingInt((Instruction inst) -> { - int startCode = Integer.parseInt(getNumericPart(inst.getStart_device_code())); - if (startCode == 1 || startCode == 4) { - return 0; - } else { - return 1; - } - }) - .thenComparing(inst -> Integer.parseInt(inst.getNext_device_code())) - .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 findShallowReadyInstByNextDeviceCode(List next_device_code_list, String noY) { - Set 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() - .sorted(Comparator.comparingInt((Instruction inst) -> { - int startCode = Integer.parseInt(getNumericPart(inst.getStart_device_code())); - if (startCode == 2 || startCode == 3) { - return 0; - } else { - return 1; - } - }) - .thenComparing(inst -> inst.getNext_device_code()) - .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+"); @@ -2017,49 +1964,6 @@ public class InstructionServiceImpl extends CommonServiceImpl findReadyInstByDeviceCode(List device_code_list, String noY) { - //String currentNoY = noY == null ? "" : noY; - Set 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 -> (device_code_list.contains(inst.getStart_device_code()) && ObjectUtil.isNotEmpty(inst.getTo_y()) && !currentNoY.contains(inst.getTo_y())) || (device_code_list.contains(inst.getNext_device_code()) && ObjectUtil.isNotEmpty(inst.getFrom_y()) && !currentNoY.contains(inst.getFrom_y()))) - .sorted(Comparator.comparing(Instruction::getPriority) - .thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) - .collect(Collectors.toList()); - } - - @Override - public Instruction findReadyInstByStartDeviceCode(Instruction frontInst, String link_device_code, String noY) { - //String currentNoY = noY == null ? "" : noY; - Set 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(link_device_code)) - .filter(inst -> ObjectUtil.isNotEmpty(inst.getTo_y()) && !currentNoY.contains(inst.getTo_y())) - .filter(inst -> Integer.parseInt(StringUtil.handleString(inst.getTo_x())) == Integer.parseInt(StringUtil.handleString(frontInst.getTo_x()))) - // .filter(inst -> ((Integer.parseInt(frontInst.getTo_y()) - 1) / 4 == (Integer.parseInt(inst.getTo_y()) - 1) / 4) && (((Integer.parseInt(frontInst.getTo_y()) % 4) + (Integer.parseInt(inst.getTo_y()) % 4) == 2) || (Integer.parseInt(frontInst.getTo_y()) % 4) + (Integer.parseInt(inst.getTo_y()) % 4) == 4)) - .filter(inst -> { - int frontToY = Integer.parseInt(frontInst.getTo_y()); - int instToY = Integer.parseInt(inst.getTo_y()); - int frontGroup = (frontToY - 1) / 4; - int instGroup = (instToY - 1) / 4; - if (frontGroup != instGroup) { - return false; - } - int frontMod = frontToY % 4; - int instMod = instToY % 4; - return (frontMod + instMod == 2 || frontMod + instMod == 4); - }) - .filter(inst -> Integer.parseInt(inst.getTo_z()) == Integer.parseInt(frontInst.getTo_z())) - .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 findReadyInstByLinkDeviceCodeAndStartDeviceCode(String linkDeviceCode, String noY, List getDeviceCodeList) { @@ -2112,64 +2016,8 @@ public class InstructionServiceImpl extends CommonServiceImpl getDeviceCodeList) { - Set 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.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 getDeviceCodeList) { - Set 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 getDeviceCodeList) { - Set 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); - } @Override public Instruction findReadyInstByNextDeviceCode(Instruction frontInst, String link_device_code, String noY) { @@ -2202,8 +2050,9 @@ public class InstructionServiceImpl extends CommonServiceImpl getDeviceCodeList) { + public Instruction findShallowReadyInstByNextDeviceCode(Instruction frontInst, String link_device_code, String noY, List getDeviceCodeList) { Set currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); return Optional.ofNullable(this.instructions) .orElse(new CopyOnWriteArrayList<>()) @@ -2227,60 +2076,39 @@ public class InstructionServiceImpl extends CommonServiceImpl Integer.parseInt(inst.getFrom_y()) < Integer.parseInt(frontInst.getFrom_y())) .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) + .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 findShallowReadyInstByNextDeviceCode(Instruction frontInst, String link_device_code, String noY, List getDeviceCodeList) { - Set currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); + public Instruction findReadyInst(String start_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(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_y()) < Integer.parseInt(frontInst.getFrom_y())) - .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")))) + .filter(inst -> inst.getStart_device_code().equals(start_device_code)) .findFirst().orElse(null); } @Override - public Instruction findReadyInst(String start_device_code) { + public Instruction findReadyInstByEnd(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.getStart_device_code().equals(start_device_code)) + .filter(inst -> inst.getNext_device_code().equals(next_device_code)) .findFirst().orElse(null); } @Override - public Instruction findReadyInstByEnd(String next_device_code) { + public Instruction findReadyInstByStartPointCode(String start_point_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)) + .filter(inst -> inst.getStart_point_code().equals(start_point_code)) .findFirst().orElse(null); } @@ -2414,13 +2242,68 @@ public class InstructionServiceImpl extends CommonServiceImpl findInstsByNextDeviceCode(String deviceCode) { + public List findAllInstByPriorityCreateTime(List next_device_code_list, String noY) { + Set currentNoY = noY == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(noY.split(","))); return Optional.ofNullable(this.instructions) .orElse(new CopyOnWriteArrayList<>()) .stream() - .filter(inst -> inst.getNext_device_code().equals(deviceCode)) + .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 + .comparingInt((Instruction inst) -> + inst.getPriority() != null && !inst.getPriority().isEmpty() ? + Integer.parseInt(inst.getPriority()) : + 1) + .reversed() + .thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))) + .thenComparing(inst -> { + String startDeviceCode = inst.getStart_device_code(); + String numericPart = getNumericPart(startDeviceCode); + int location = Integer.parseInt(numericPart); + if (location == 2 || location == 3) { + return 0; + } else { + return 1; + } + }) + .thenComparing(inst -> Integer.parseInt(inst.getNext_device_code())) + ) + .collect(Collectors.toList()); + } + + @Override + public List findAllInstByPriorityCreateTime(String link_device_code, List next_device_code_list, String noY) { + Set 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 -> 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 + .comparingInt((Instruction inst) -> + inst.getPriority() != null && !inst.getPriority().isEmpty() ? + Integer.parseInt(inst.getPriority()) : + 1) + .reversed() + .thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))) + .thenComparing(inst -> { + String startDeviceCode = inst.getStart_device_code(); + String numericPart = getNumericPart(startDeviceCode); + int location = Integer.parseInt(numericPart); + if (location == 2 || location == 3) { + return 0; + } else { + return 1; + } + }) + ) .collect(Collectors.toList()); } + } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java index ce41477..603ae70 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java @@ -294,7 +294,7 @@ public interface TaskService extends CommonService { List findTasksByNextCode(String device_code); - TaskDto findByStartPointCode(String device_code); + TaskDto findReadyByStartPointCode(String start_point_code); TaskDto findReadyByVehicleCode(String vehicleCode); @@ -331,16 +331,6 @@ public interface TaskService extends CommonService { */ String queryAssignedByDevice(String device_code, String task_nextdevice_code); - - /** - * 查询相同起终任务的数量 - * - * @param - * @return - */ - Integer querySameDeviceReadyTask(String start_device, String next_device, String status); - - /** * 条件查询任务和指令 * @@ -385,8 +375,6 @@ public interface TaskService extends CommonService { TaskDto findReadyTaskByNextDeviceCode(String next_device_code, List checkoutStartDeviceCode); - List findReadyTasksByNextDeviceCode(String next_device_code, List checkoutStartDeviceCode); - List findReadyTaskByXDeviceCode(List xDeviceCodeList, String noY); /** @@ -409,6 +397,5 @@ public interface TaskService extends CommonService { void cancelNoSendWms(String task_id); - List findInstsByNextDeviceCode(String deviceCode); } diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index e16bfaa..761cc7c 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -742,7 +742,7 @@ public class TaskServiceImpl extends CommonServiceImpl impleme instdto.setNext_point_code2(next_point_code2); instdto.setAgv_inst_type(CommonFinalParam.ONE); instdto.setAgv_system_type(agv_system_type); - if (StrUtil.equals(instdto.getNext_device_code(),"3101")){ + if (StrUtil.equals(instdto.getNext_device_code(), "3101")) { instdto.setAgv_system_type(AgvSystemTypeEnum.HK_SYSTEM_TYPE.getCode()); instdto.setInstruction_type(InstTypeEnum.CTU_OUT_TASK.getCode()); } @@ -904,13 +904,15 @@ public class TaskServiceImpl extends CommonServiceImpl impleme .collect(Collectors.toList()); } + @Override - public TaskDto findByStartPointCode(String device_code) { + public TaskDto findReadyByStartPointCode(String start_point_code) { return Optional .ofNullable(this.tasks) .orElse(new CopyOnWriteArrayList<>()) .stream() - .filter(task -> StrUtil.equals(task.getStart_point_code(), device_code)) + .filter(task -> StrUtil.equals(task.getStart_point_code(), start_point_code)) + .filter(task -> StrUtil.equals(task.getTask_status(),TaskStatusEnum.READY.getIndex())) .findFirst() .orElse(null); } @@ -1251,21 +1253,6 @@ public class TaskServiceImpl extends CommonServiceImpl impleme } - @Override - public Integer querySameDeviceReadyTask(String start_device, String next_device, String status) { - int num = 0; - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (StrUtil.equals(task.getStart_device_code(), start_device) - && StrUtil.equals(task.getNext_device_code(), next_device) - && StrUtil.equals(task.getTask_status(), status)) { - num++; - } - } - - return num; - } @Override @@ -1340,7 +1327,7 @@ public class TaskServiceImpl extends CommonServiceImpl impleme String type = shortPathsList.get(0).getType(); // != 0 为agv任务 if (!StrUtil.equals(type, "0")) { - if (StrUtil.equals(paramService.findByCode(AcsConfig.AGV_TYPE).getValue(), "3") && StrUtil.equals(taskDto.getAgv_system_type(),AgvSystemTypeEnum.XG_SYSTEM_TYPE.getCode())) { + if (StrUtil.equals(paramService.findByCode(AcsConfig.AGV_TYPE).getValue(), "3") && StrUtil.equals(taskDto.getAgv_system_type(), AgvSystemTypeEnum.XG_SYSTEM_TYPE.getCode())) { try { JSONObject reqParam = new JSONObject(); reqParam.put("id", taskDto.getTask_code()); @@ -1361,30 +1348,29 @@ public class TaskServiceImpl extends CommonServiceImpl impleme .filter(taskDto -> TaskStatusEnum.READY.getIndex().equals(taskDto.getTask_status())) .filter(taskDto -> taskDto.getNext_device_code().equals(next_device_code)) .filter(taskDto -> !checkoutStartDeviceCode.contains(taskDto.getStart_device_code())) - .sorted(Comparator.comparingInt((TaskDto taskDto) -> Integer.parseInt(getNumericPart(taskDto.getStart_device_code())) % 4).reversed() - .thenComparing(taskDto -> Integer.parseInt(ObjectUtil.isEmpty(taskDto.getFrom_y()) ? "0" : taskDto.getFrom_y())) - .thenComparing(TaskDto::getPriority) - .thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) + .sorted( + Comparator + .comparingInt((TaskDto taskDto) -> + taskDto.getPriority() != null && !taskDto.getPriority().isEmpty() ? + Integer.parseInt(taskDto.getPriority()) : + 1) + .reversed() + .thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))) + .thenComparing(taskDto -> { + String startDeviceCode = taskDto.getStart_device_code(); + String numericPart = getNumericPart(startDeviceCode); + int location = Integer.parseInt(numericPart); + if (location == 2 || location == 3) { + return 0; + } else { + return 1; + } + }) + ) .findFirst() .orElse(null); } - @Override - public List findReadyTasksByNextDeviceCode(String next_device_code, List checkoutStartDeviceCode) { - return Optional.ofNullable(this.tasks) - .orElse(new CopyOnWriteArrayList<>()) - .stream() - .filter(taskDto -> TaskStatusEnum.READY.getIndex().equals(taskDto.getTask_status())) - .filter(taskDto -> taskDto.getNext_device_code().equals(next_device_code)) - .filter(taskDto -> !checkoutStartDeviceCode.contains(taskDto.getStart_device_code())) - .sorted(Comparator.comparingInt((TaskDto taskDto) -> Integer.parseInt(getNumericPart(taskDto.getStart_device_code())) % 4).reversed() - .thenComparing(taskDto -> Integer.parseInt(ObjectUtil.isEmpty(taskDto.getFrom_z()) ? "0" : taskDto.getFrom_z())) - .thenComparing(taskDto -> Integer.parseInt(ObjectUtil.isEmpty(taskDto.getFrom_y()) ? "0" : taskDto.getFrom_y())) - .thenComparing(TaskDto::getPriority) - .thenComparing(taskDto -> LocalDateTime.parse(taskDto.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); diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/config/JobRunner.java b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/config/JobRunner.java index 2504f2f..a1334e8 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/config/JobRunner.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/config/JobRunner.java @@ -17,7 +17,7 @@ import java.util.List; @Component @RequiredArgsConstructor @Order(100) -@ConditionalOnProperty(value = "spring.profiles.active",havingValue = "dev") +@ConditionalOnProperty(value = "spring.profiles.active",havingValue = "prod") public class JobRunner implements ApplicationRunner { private static final Logger log = LoggerFactory.getLogger(JobRunner.class); private final ISysQuartzJobService quartzJobService; diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateYkInst.java b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateYkInst.java index 3377167..b1d4a81 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateYkInst.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateYkInst.java @@ -91,10 +91,6 @@ public class AutoCreateYkInst { continue; } - if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE) && !StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.TWO)) { - continue; - } - RouteLineDto routeLineDto = shortPathsList.get(0); String path = routeLineDto.getPath(); String type = routeLineDto.getType(); diff --git a/nladmin-ui/src/i18n/langs/instruction/en.js b/nladmin-ui/src/i18n/langs/instruction/en.js index 5706ec2..99ab345 100644 --- a/nladmin-ui/src/i18n/langs/instruction/en.js +++ b/nladmin-ui/src/i18n/langs/instruction/en.js @@ -5,6 +5,7 @@ export default { 'instruction_type': 'Instruction Type', 'task_code': 'Task Code', 'vehicle_code': 'Vehicle Code', + 'priority': 'priority', 'instruction_status': 'Instruction Status', 'send_status': 'Send Status', 'start_point_code': 'Start Device Code', diff --git a/nladmin-ui/src/i18n/langs/instruction/in.js b/nladmin-ui/src/i18n/langs/instruction/in.js index 4daf4da..501f487 100644 --- a/nladmin-ui/src/i18n/langs/instruction/in.js +++ b/nladmin-ui/src/i18n/langs/instruction/in.js @@ -5,6 +5,7 @@ export default { 'instruction_type': 'Jenis Instruksi', 'task_code': 'Nomor Tugas', 'vehicle_code': 'Nomor Kendaraan', + 'priority': 'Prioritas', 'instruction_status': 'Status Perintah', 'send_status': 'Status Pengiriman', 'start_point_code': 'Titik Penjemputan', diff --git a/nladmin-ui/src/i18n/langs/instruction/zh.js b/nladmin-ui/src/i18n/langs/instruction/zh.js index 2d7f9fd..8244968 100644 --- a/nladmin-ui/src/i18n/langs/instruction/zh.js +++ b/nladmin-ui/src/i18n/langs/instruction/zh.js @@ -5,10 +5,11 @@ export default { 'instruction_type': '指令类型', 'task_code': '任务号', 'vehicle_code': '载具号', + 'priority': '优先级', 'instruction_status': '指令状态', 'send_status': '下发状态', - 'start_point_code': '取货点', - 'next_point_code': '放货点', + 'start_point_code': '指令起点', + 'next_point_code': '指令终点', 'start_point_code2': '取货点2', 'next_point_code2': '放货点2', 'put_point_code': '倒料点', diff --git a/nladmin-ui/src/i18n/langs/task/zh.js b/nladmin-ui/src/i18n/langs/task/zh.js index 339bae5..0045730 100644 --- a/nladmin-ui/src/i18n/langs/task/zh.js +++ b/nladmin-ui/src/i18n/langs/task/zh.js @@ -35,8 +35,8 @@ export default { 'Ready': '就绪', 'In_progress': '执行中', 'Completed': '完成', - 'Pickup_point': '取货点', - 'Delivery_point': '放货点', + 'Pickup_point': '任务起点', + 'Delivery_point': '任务终点', 'Remark': '备注', 'Creator': '创建者', 'Create_time': '创建时间', diff --git a/nladmin-ui/src/views/acs/instruction/index.vue b/nladmin-ui/src/views/acs/instruction/index.vue index 852ca75..6aafe69 100644 --- a/nladmin-ui/src/views/acs/instruction/index.vue +++ b/nladmin-ui/src/views/acs/instruction/index.vue @@ -32,27 +32,27 @@ @keyup.enter.native="crud.toQuery" /> - - - - - - + + + + + + + + + + + + + + + - + - + - +