From 68497454e8a209ab381ea1c4d3673ffe91c3d44e Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Thu, 15 Jun 2023 09:07:17 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BB=BB=E5=8A=A1=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SiemensConveyorDeviceDriver.java | 2 +- ...CoveyorControlWithScannerDeviceDriver.java | 61 +++++++++++++++++++ .../service/impl/InstructionServiceImpl.java | 53 +++++++++++++--- .../nl/acs/opc/DeviceOpcProtocolRunable.java | 6 +- .../task/service/impl/TaskServiceImpl.java | 38 ++++++++++-- 5 files changed, 142 insertions(+), 18 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java index decaec13d..00cf54db9 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java @@ -1113,7 +1113,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme instructionService.update(inst); logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code()); } - if (StrUtil.equals(inst.getInstruction_status(), "1")) { + if (StrUtil.equals(inst.getInstruction_status(), "1") || StrUtil.equals(inst.getInstruction_status(), "0") ) { if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { vehicle_code = inst.getVehicle_code(); inst.setExecute_device_code(this.device_code); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java index 62f636378..e80392e3c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java @@ -530,6 +530,22 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe message = "下发电气任务号成功"; requireSucess = true; applySucess = true; + while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() + , instdto.getInstruction_code())) { + this.writing(list); + logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号"); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if(ObjectUtil.isEmpty(instdto.getInstruction_code())){ + requireSucess = false; + applySucess = false; + return false; + } + } + } else { message = "任务号:" + task.getTask_code() + "未找到指令"; } @@ -602,6 +618,21 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe + "已存在对应任务,下发电气信号"); requireSucess = true; applySucess = true; + while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() + , instdto.getInstruction_code())) { + this.writing(list); + logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号"); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if(ObjectUtil.isEmpty(instdto.getInstruction_code())){ + requireSucess = false; + applySucess = false; + return false; + } + } } else { message = "任务号:" + taskdto.getTask_code() + "未找到指令"; } @@ -647,6 +678,21 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe message = "下发电气任务号成功"; requireSucess = true; applySucess = true; + while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() + , instdto.getInstruction_code())) { + this.writing(list); + logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号"); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if(ObjectUtil.isEmpty(instdto.getInstruction_code())){ + requireSucess = false; + applySucess = false; + return false; + } + } return true; } else { logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号" + container_code @@ -776,6 +822,21 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe // } requireSucess = true; applySucess = true; + while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() + , instdto.getInstruction_code())) { + this.writing(list); + logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号"); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if(ObjectUtil.isEmpty(instdto.getInstruction_code())){ + requireSucess = false; + applySucess = false; + return false; + } + } } else { if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { message = "申请任务中..."; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index eecf4d54f..3b7ce544c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -414,9 +414,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu WQLObject wo = WQLObject.getWQLObject("acs_instruction"); JSONObject json = (JSONObject) JSONObject.toJSON(dto); - wo.insert(json); - instructions.add(dto); + + try{ + instructions.add(dto); + log.warn("指令添加到指令列表:"+dto.toString()); + } catch (Exception e){ + log.warn("指令添加到指令列表异常:" + dto.toString() +e.getMessage()); + } } @Override @@ -530,7 +535,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu JSONObject json = (JSONObject) JSONObject.toJSON(dto); wo.insert(json); - instructions.add(dto); + try{ + instructions.add(dto); + log.warn("指令添加到指令列表:"+dto.toString()); + } catch (Exception e){ + log.warn("指令添加到指令列表异常:"+e.getMessage()); + } } @@ -645,7 +655,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu JSONObject json = (JSONObject) JSONObject.toJSON(dto); wo.insert(json); - instructions.add(dto); + try{ + instructions.add(dto); + log.warn("指令添加到指令列表:"+dto.toString()); + } catch (Exception e){ + log.warn("指令添加到指令列表异常:" + dto.toString() +e.getMessage()); + } } @@ -732,7 +747,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu // agvService.addOrderSequences(dto); // } // } - instructions.add(dto); + try{ + instructions.add(dto); + log.warn("指令添加到指令列表:"+dto.toString()); + } catch (Exception e){ + log.warn("指令添加到指令列表异常:" + dto.toString() +e.getMessage()); + } } @Override @@ -747,7 +767,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu wo.update(json); removeByCodeFromCache(dto.getInstruction_code()); - instructions.add(dto); + try{ + instructions.add(dto); + log.warn("指令添加到指令列表:"+dto.toString()); + } catch (Exception e){ + log.warn("指令添加到指令列表异常:" + dto.toString() +e.getMessage()); + } + // this.reload(); } @@ -1580,9 +1606,18 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public boolean removeByCodeFromCache(String code) { CopyOnWriteArrayList instructions = (CopyOnWriteArrayList) this.instructions; - instructions.removeIf((inst) -> { - return inst.getInstruction_code().equals(code); - }); + + try{ + instructions.removeIf((inst) -> { + if(StrUtil.equals(inst.getInstruction_code(),code)){ + log.warn("指令移除指令列表:"+inst.toString()); + } + return inst.getInstruction_code().equals(code); + }); + } catch (Exception e){ + log.warn("指令移除指令列表列表异常:" + e.getMessage()); + } + // while (iterator.hasNext()) { // Instruction instruction = iterator.next(); // if (instruction.getInstruction_code().equals(code)) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java index d0b770e86..b1ad40336 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java @@ -1,6 +1,7 @@ package org.nl.acs.opc; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import lombok.extern.slf4j.Slf4j; import org.nl.acs.udw.UnifiedDataAccessor; @@ -191,8 +192,9 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC if (true) { this.logItemChanged(itemId, accessor_value, value, itemDto); } - - accessor_value.setValue(itemId, value); + if(!ObjectUtil.isEmpty(value)){ + accessor_value.setValue(itemId, value); + } } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 63921aec5..ab4cabfed 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -520,8 +520,15 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { JSONObject json = (JSONObject) JSONObject.toJSON(dto); wo.insert(json); - synchronized (TaskServiceImpl.class) { +// synchronized (TaskServiceImpl.class) { +// tasks.add(dto); +// } + + try{ tasks.add(dto); + log.warn("任务添加到任务列表:"+dto.toString()); + } catch (Exception e){ + log.warn("任务添加到任务列表异常:"+ dto.toString() +e.getMessage()); } } @@ -673,7 +680,12 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { removeByCodeFromCache(entity.getTask_code()); if (StrUtil.equals(dto.getTask_status(), "0") || StrUtil.equals(dto.getTask_status(), "1")) { - tasks.add(dto); + try{ + tasks.add(dto); + log.warn("任务添加到任务列表:"+dto.toString()); + } catch (Exception e){ + log.warn("任务添加到任务列表异常:"+ dto.toString() +e.getMessage()); + } } // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); @@ -1296,9 +1308,18 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { @Override public boolean removeByCodeFromCache(String code) { CopyOnWriteArrayList taskDtos = (CopyOnWriteArrayList) this.tasks; - taskDtos.removeIf((task) -> { - return task.getTask_code().equals(code); - }); + try{ + + taskDtos.removeIf((task) -> { + if(StrUtil.equals(task.getTask_code(),code)){ + log.warn("任务移除任务列表成功:"+task.toString()); + } + return task.getTask_code().equals(code); + }); + } catch (Exception e){ + log.warn("指令移除任务列表异常:"+e.getMessage()); + } + return true; } @@ -1525,7 +1546,12 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { @Override public void updateByCodeFromCache(TaskDto dto) { removeByCodeFromCache(dto.getTask_code()); - tasks.add(dto); + try{ + tasks.add(dto); + log.warn("任务添加到任务列表:"+dto.toString()); + } catch (Exception e){ + log.warn("任务添加到任务列表异常:"+ dto.toString() +e.getMessage()); + } } @Override