From 77097cbda3ecb7f05e5848953a8d18fde70b61a2 Mon Sep 17 00:00:00 2001 From: liuxy Date: Thu, 14 Aug 2025 17:08:54 +0800 Subject: [PATCH] =?UTF-8?q?rev=EF=BC=9A=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../run/OneNDCSocketConnectionAutoRun.java | 4 +- .../StandardAutodoorDeviceDriver.java | 67 ++++++++++++++++--- 2 files changed, 61 insertions(+), 10 deletions(-) diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java index 0385f7c..b530d63 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -233,7 +233,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { log.error("agv车号为"+carno+",进入自动门区域:"+"自动门:"+device_code+"未联机,无法开门。"); } if (flag) { - driver.writing(ItemProtocol.item_to_command,1); + driver.writing(ItemProtocol.item_to_command,"1"); driver.setMessage(""); log.info("agv车号为"+carno+",进入自动门区域"+"自动门:"+device_code+"已联机,允许开门。"); logServer.deviceExecuteLog(device_code, "", "", "允许开门。"); @@ -277,7 +277,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } log.info("自动门:"+device_code+"关门的action的值此时为:"+driver.getAction()+"该值应为0"); if (flag) { - driver.writing(ItemProtocol.item_to_command,2); + driver.writing(ItemProtocol.item_to_command,"2"); driver.setMessage(""); log.info("自动门:"+device_code+"工作模式正常,"+"agv车号为"+carno+",写入关门信号2,准备离开自动门。"); logServer.deviceExecuteLog(device_code, "", "", "允许关门。"); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java index 576acb7..e43c3fb 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.autodoor.standard_autodoor; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; @@ -13,14 +14,18 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.ext.wms.data.one.feedBackTaskStatus.FeedBackTaskStatusRequest; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.task.service.TaskService; import org.nl.acs.utils.ReadUtil; import org.nl.config.SpringContextHolder; +import org.nl.system.service.lucene.LuceneExecuteLogService; +import org.nl.system.service.lucene.dto.LuceneLogDto; import org.openscada.opc.lib.da.Server; import java.util.Date; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; /** @@ -34,6 +39,8 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + LuceneExecuteLogService lucene = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); @@ -129,26 +136,70 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem } - public void writing(String param, int command) { - String to_command = String.format("%s.%s.%s.%s", this.getDevice().getOpc_server_code(), this.getDevice().getOpc_plc_code(), this.getDevice().getDevice_code(), param); + /** + * 多个信号一起下发电气 + * + * @param map + */ + + public void writing(Map map) { + LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map itemMap = new LinkedHashMap<>(); + map.forEach((key, value) -> { + if (ObjectUtil.isNotEmpty(value)) { + itemMap.put(getToParam() + key, value); + } + }); + if (ObjectUtil.isNotEmpty(itemMap)) { + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try{ + this.checkcontrol(itemMap); + } catch (Exception e1){ + e1.printStackTrace(); + } + } + logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); + lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap)); + } + } + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getToParam() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + public void writing(String param, String value) { + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + param; String opcservcerid = this.getDevice().getOpc_server_id(); Server server = ReadUtil.getServer(opcservcerid); Map itemMap = new HashMap(); - itemMap.put(to_command, command); + if (value instanceof String) { + itemMap.put(to_param, value); + } else { + itemMap.put(to_param, value); + } ReadUtil.write(itemMap, server); - log.info("下发PLC信号:{},{}", to_command, command); - System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); - + server.disconnect(); + log.info("下发PLC信号:{},{}", this.devicecode, "to_command:" + value); + lucene.deviceExecuteLog(new LuceneLogDto(this.devicecode, message + param + " 写入 " + value)); } public synchronized void OpenOrClose(String type) { //开门 if (CommonFinalParam.ONE.equals(type)) { - writing(ItemProtocol.item_to_command, 1); + writing(ItemProtocol.item_to_command, "1"); } else { - writing(ItemProtocol.item_to_command, 2); + writing(ItemProtocol.item_to_command, "2"); } }