From a5b351156c343e707cf977b9e76ac2cfc9e64259 Mon Sep 17 00:00:00 2001
From: cl <418351270@qq.com>
Date: 星期四, 07 三月 2024 16:14:43 +0800
Subject: [PATCH] 更新OPC

---
 jcdm-main/src/main/java/com/jcdm/main/plcserver/conf/OPCElement.java       |   25 +++
 /dev/null                                                                  |   48 ------
 jcdm-main/pom.xml                                                          |   40 +----
 jcdm-main/src/main/java/com/jcdm/main/plcserver/CustomRunner.java          |   58 ++++++++
 jcdm-admin/src/main/resources/application.yml                              |    8 +
 jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java |  190 +++++++++++++++++++++++++++
 6 files changed, 289 insertions(+), 80 deletions(-)

diff --git a/jcdm-admin/src/main/resources/application.yml b/jcdm-admin/src/main/resources/application.yml
index f470bcc..551cd0a 100644
--- a/jcdm-admin/src/main/resources/application.yml
+++ b/jcdm-admin/src/main/resources/application.yml
@@ -130,3 +130,11 @@
   excludes: /system/notice
   # 鍖归厤閾炬帴
   urlPatterns: /system/*,/monitor/*,/tool/*
+
+kangaroohy:
+  milo:
+    primary: default
+    config:
+      default:
+        endpoint: opc.tcp://127.0.0.1:49320
+        security-policy: none
\ No newline at end of file
diff --git a/jcdm-main/pom.xml b/jcdm-main/pom.xml
index 4518cee..94a7bfc 100644
--- a/jcdm-main/pom.xml
+++ b/jcdm-main/pom.xml
@@ -59,43 +59,19 @@
             <version>2.10.1</version>
         </dependency>
 
-        <!--Server SDK渚濊禆-->
-        <dependency>
-            <groupId>org.eclipse.milo</groupId>
-            <artifactId>sdk-server</artifactId>
-            <version>0.3.6</version>
-        </dependency>
-
-        <!--Client SDK渚濊禆-->
-        <dependency>
-            <groupId>org.eclipse.milo</groupId>
-            <artifactId>sdk-client</artifactId>
-            <version>0.3.6</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.eclipse.milo</groupId>
-            <artifactId>stack-client</artifactId>
-            <version>0.3.6</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.eclipse.milo</groupId>
-            <artifactId>stack-client</artifactId>
-            <version>0.3.6</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.eclipse.milo</groupId>
-            <artifactId>stack-server</artifactId>
-            <version>0.3.6</version>
-        </dependency>
-
         <!-- 绯荤粺妯″潡-->
         <dependency>
             <groupId>com.jcdm</groupId>
             <artifactId>jcdm-framework</artifactId>
         </dependency>
+
+        <!-- opc start-->
+        <dependency>
+            <groupId>com.kangaroohy</groupId>
+            <artifactId>milo-spring-boot-starter</artifactId>
+            <version>3.0.5</version>
+        </dependency>
+        <!-- opc end-->
     </dependencies>
 
 </project>
\ No newline at end of file
diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/KeyStoreLoader.java b/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/KeyStoreLoader.java
deleted file mode 100644
index 9b6a4e0..0000000
--- a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/KeyStoreLoader.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package com.jcdm.main.da.opcuaconfig.cert;
-
-import org.eclipse.milo.opcua.sdk.server.util.HostnameUtil;
-import org.eclipse.milo.opcua.stack.core.util.SelfSignedCertificateBuilder;
-import org.eclipse.milo.opcua.stack.core.util.SelfSignedCertificateGenerator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.security.*;
-import java.security.cert.X509Certificate;
-import java.util.regex.Pattern;
-
-/**
- * @ClassName: KeyStoreLoader
- * @Description: KeyStoreLoader
- * @author yyt
- * @date 2023骞�10鏈�13鏃�
- */
-@Component
-public class KeyStoreLoader {
-
-	private static final Pattern IP_ADDR_PATTERN = Pattern
-			.compile("^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
-
-	// 璇佷功鍒悕
-	private static final String CLIENT_ALIAS = "jlclient-ai";
-	// 鑾峰彇绉侀挜鐨勫瘑鐮�
-	private static final char[] PASSWORD = "yyt@8888888888".toCharArray();
-
-	private final Logger logger = LoggerFactory.getLogger(getClass());
-
-	// 璇佷功瀵硅薄
-	private X509Certificate clientCertificate;
-	// 瀵嗛挜瀵瑰璞�
-	private KeyPair clientKeyPair;
-
-	/**
-	 * @MethodName: load
-	 * @Description: load
-	 * @param baseDir
-	 * @return
-	 * @throws Exception
-	 * @CreateTime 2023骞�10鏈�13鏃�
-	 */
-	public KeyStoreLoader load(Path baseDir) throws Exception {
-		// 鍒涘缓涓�涓娇鐢╜PKCS12`鍔犲瘑鏍囧噯鐨凨eyStore銆侹eyStore鍦ㄥ悗闈㈠皢浣滀负璇诲彇鍜岀敓鎴愯瘉涔︾殑瀵硅薄銆�
-		KeyStore keyStore = KeyStore.getInstance("PKCS12");
-
-		// PKCS12鐨勫姞瀵嗘爣鍑嗙殑鏂囦欢鍚庣紑鏄�.pfx锛屽叾涓寘鍚簡鍏挜鍜岀閽ャ��
-		// 鑰屽叾浠栧.der绛夌殑鏍煎紡鍙寘鍚叕閽ワ紝绉侀挜鍦ㄥ彟澶栫殑鏂囦欢涓��
-		Path serverKeyStore = baseDir.resolve("OPCUA-client.pfx");
-
-		logger.info("Loading KeyStore at {}", serverKeyStore);
-
-		// 濡傛灉鏂囦欢涓嶅瓨鍦ㄥ垯鍒涘缓.pfx璇佷功鏂囦欢銆�
-		if (!Files.exists(serverKeyStore)) {
-			keyStore.load(null, PASSWORD);
-
-			// 鐢�2048浣嶇殑RAS绠楁硶銆俙SelfSignedCertificateGenerator`涓篗ilo搴撶殑瀵硅薄銆�
-			KeyPair keyPair = SelfSignedCertificateGenerator.generateRsaKeyPair(2048);
-
-			// `SelfSignedCertificateBuilder`涔熸槸Milo搴撶殑瀵硅薄锛岀敤鏉ョ敓鎴愯瘉涔︺��
-			// 涓棿鎵�璁剧疆鐨勮瘉涔﹀睘鎬у彲浠ヨ嚜琛屼慨鏀广��
-			SelfSignedCertificateBuilder builder = new SelfSignedCertificateBuilder(keyPair)
-					.setCommonName("UaClient@Jellyleo")
-					.setOrganization("JL")
-					.setOrganizationalUnit("per")
-					.setLocalityName("jl")
-					.setStateName("JiangSu")
-					.setCountryCode("CN")
-					.setApplicationUri("urn:Yyt_PC:UnifiedAutomation:UaExpert")
-					.addDnsName("Yyt_PC")
-					.addIpAddress("127.0.0.1");
-
-			// Get as many hostnames and IP addresses as we can listed in the certificate.
-			for (String hostname : HostnameUtil.getHostnames("0.0.0.0")) {
-				if (IP_ADDR_PATTERN.matcher(hostname).matches()) {
-					builder.addIpAddress(hostname);
-				} else {
-					builder.addDnsName(hostname);
-				}
-			}
-			// 鍒涘缓璇佷功
-			X509Certificate certificate = builder.build();
-
-			// 璁剧疆瀵瑰簲绉侀挜鐨勫埆鍚嶏紝瀵嗙爜锛岃瘉涔﹂摼
-			keyStore.setKeyEntry(CLIENT_ALIAS, keyPair.getPrivate(), PASSWORD, new X509Certificate[] { certificate });
-			try (OutputStream out = Files.newOutputStream(serverKeyStore)) {
-				// 淇濆瓨璇佷功鍒拌緭鍑烘祦
-				keyStore.store(out, PASSWORD);
-			}
-		} else {
-			try (InputStream in = Files.newInputStream(serverKeyStore)) {
-				// 濡傛灉鏂囦欢瀛樺湪鍒欒鍙�
-				keyStore.load(in, PASSWORD);
-			}
-		}
-
-		// 鐢ㄥ瘑鐮佽幏鍙栧搴斿埆鍚嶇殑绉侀挜銆�
-		Key serverPrivateKey = keyStore.getKey(CLIENT_ALIAS, PASSWORD);
-		if (serverPrivateKey instanceof PrivateKey) {
-			// 鑾峰彇瀵瑰簲鍒悕鐨勮瘉涔﹀璞°��
-			clientCertificate = (X509Certificate) keyStore.getCertificate(CLIENT_ALIAS);
-			// 鑾峰彇鍏挜
-			PublicKey serverPublicKey = clientCertificate.getPublicKey();
-			// 鍒涘缓Keypair瀵硅薄銆�
-			clientKeyPair = new KeyPair(serverPublicKey, (PrivateKey) serverPrivateKey);
-		}
-
-		return this;
-	}
-
-	// 杩斿洖璇佷功
-	public X509Certificate getClientCertificate() {
-		return clientCertificate;
-	}
-
-	// 杩斿洖瀵嗛挜瀵�
-	public KeyPair getClientKeyPair() {
-		return clientKeyPair;
-	}
-}
diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/MethodName.java b/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/MethodName.java
deleted file mode 100644
index 9f2a5fe..0000000
--- a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/MethodName.java
+++ /dev/null
@@ -1,197 +0,0 @@
-package com.jcdm.main.da.opcuaconfig.cert;
-
-import com.jcdm.framework.websocket.WebSocketServer;
-import com.jcdm.framework.websocket.WebSocketUsers;
-import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo;
-import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService;
-import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf;
-import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService;
-import com.jcdm.main.da.opcuaconfig.client.ClientHandler;
-import com.jcdm.main.da.opcuaconfig.domain.NodeEntity;
-import com.jcdm.main.da.opcuaconfig.init.BeanUtils;
-import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
-import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
-import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
-import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
-import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
-
-import javax.websocket.Session;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import static com.jcdm.main.da.opcuaconfig.client.ClientHandler.readValues;
-
-@Slf4j
-public class MethodName {
-    Map<String, Session> map = WebSocketUsers.getUsers();
-    private IDaCollectionParamConfService collectionParamConfService = BeanUtils.getBean(IDaCollectionParamConfService.class);
-    private IDaParamCollectionService daParamCollectionService = BeanUtils.getBean(IDaParamCollectionService.class);
-    private IDaPassingStationCollectionService daPassingStationCollectionService = BeanUtils.getBean(IDaPassingStationCollectionService.class);
-    private IBsFormulaChildInfoService bsFormulaChildInfoService = BeanUtils.getBean(IBsFormulaChildInfoService.class);
-    private List<DataValue> s=null;
-    public void Transit(String Node, String value) throws Exception {
-        log.info(Node+":"+value);
-        String[] parts = Node.split("[.]");
-        ClientHandler clientHandler=new ClientHandler();
-        NodeEntity SN_node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".SNCode").value("").type("").build();
-        String SNCode=clientHandler.read(SN_node);
-        log.info("璇诲彇鑺傜偣:{},缁撴灉:{}", SN_node.getIdentifier(),SNCode);
-        switch (value) {
-            case "0":   //鍒濆
-                NodeEntity node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordDataDone").value("0").type("short").build();
-                Boolean out=clientHandler.write(node);
-                log.info("鑺傜偣:{},鍝嶅簲缁撴灉:{}", node.getIdentifier(),out);
-                WebSocketUsers.sendMessageToUserByText(map.get(parts[1]), "IN0");
-
-                break;
-            case "1":   //璇锋眰涓嬪彂杩涚珯鐘舵��
-                NodeEntity node1= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordDataDone").value("11").type("short").build();
-                Boolean out1=clientHandler.write(node1);
-                DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection();
-                PassingStationCollection.setSfcCode(SNCode);
-                PassingStationCollection.setLocationCode(parts[1]);
-                PassingStationCollection.setInboundTime(new Date());
-                daPassingStationCollectionService.insertDaPassingStationCollection(PassingStationCollection);
-                log.info("鑺傜偣:{},鍝嶅簲缁撴灉:{}", node1.getIdentifier(),out1);
-                WebSocketUsers.sendMessageToUserByText(map.get(parts[1]), "IN");
-                break;
-            case "2":   //璇锋眰璁板綍宸ヤ綅鏁版嵁
-                List<DaCollectionParamConf> b;
-                DaCollectionParamConf daCollectionParamConf=new DaCollectionParamConf();
-                daCollectionParamConf.setGatherAddress(parts[0]+"."+parts[1]);
-                b=collectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf);
-
-                List<NodeId> nodeId = b.stream().map(info -> {
-                    NodeId nodeid = new NodeId(2,info.getGatherAddress());
-                    return nodeid;
-                }).collect(Collectors.toList());
-                List<DataValue> s=readValues(nodeId);
-                //淇濆瓨PLC閲囬泦鏁版嵁
-//                for(int i=0;i<nodeId.size();i++)
-//                {
-//                    DaParamCollection Config=new DaParamCollection();
-//                    Config.setParamCode(nodeId.get(i).getIdentifier().toString().split("[.]")[2]);
-//                    Config.setLocationCode(nodeId.get(i).getIdentifier().toString().split("[.]")[1]);
-//                    Config.setParamValue(s.get(i).getValue().getValue().toString());
-//                    Config.setSfcCode(SNCode);
-//                    Config.setParamName(b.get(i).getGatherAddress());
-//                    daParamCollectionService.insertDaParamCollection(Config);
-//                }
-                //鏇存柊鍑虹珯鏃堕棿锛岃绠楄妭鎷嶃��
-                DaPassingStationCollection PSC=new DaPassingStationCollection();
-                PSC.setSfcCode(SNCode);
-                List<DaPassingStationCollection> LPSC=daPassingStationCollectionService.selectDaPassingStationCollectionList(PSC);
-                if(LPSC != null && LPSC.size() > 0){
-                    LPSC.get(0).setOutboundTime(new Date());
-                    LPSC.get(0).setCollectionTime(new Date());
-                    LPSC.get(0).setBeatTime(Long.toString(Math.abs(new Date().getTime() - LPSC.get(0).getInboundTime().getTime())));
-                    daPassingStationCollectionService.updateDaPassingStationCollection(LPSC.get(0));
-                }
-                //鏇存柊PLC鑺傜偣鐘舵��
-                NodeEntity node2= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordDataDone").value("21").type("short").build();
-                Boolean out2=clientHandler.write(node2);
-                WebSocketUsers.sendMessageToUserByText(map.get(parts[1]), "OUT");
-                log.info("鑺傜偣:{},鍝嶅簲缁撴灉:{}", node2.getIdentifier(),out2);
-                break;
-            default:
-                break;
-        }
-    }
-
-    public void tighten(String Node, String value) throws Exception {
-        String[] parts = Node.split("[.]");
-        ClientHandler clientHandler=new ClientHandler();
-        System.out.println("Node:"+Node+"value:"+value);
-        switch (value){
-            case "1":
-                //璇绘壄鐭�
-                NodeEntity SN_node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordSN").value("").type("").build();
-                String SNCode=clientHandler.read(SN_node);
-
-                //璇昏搴�
-                NodeEntity SNDone= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordSNDone").value("").type("").build();
-                String RecordSNDone = clientHandler.read(SNDone);
-
-                //璇荤粨鏋�
-                NodeEntity SNDone1= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".WorkID").value("").type("").build();
-                String WorkID = clientHandler.read(SNDone1);
-
-                //淇濆瓨鍙傛暟閲囬泦琛�
-                DaParamCollection paramCollection = new DaParamCollection();
-                paramCollection.setLocationCode(parts[1]);
-                paramCollection.setParamCode("RecordSN");
-                paramCollection.setParamValue(SNCode);
-                paramCollection.setParamName(parts[0]+"."+parts[1]+".RecordSN");
-                daParamCollectionService.insertDaParamCollection(paramCollection);
-
-
-                DaParamCollection paramCollection1 = new DaParamCollection();
-                paramCollection1.setLocationCode(parts[1]);
-                paramCollection1.setParamCode("RecordSNDone");
-                paramCollection1.setParamValue(RecordSNDone);
-                paramCollection1.setParamName(parts[0]+"."+parts[1]+".RecordSNDone");
-                daParamCollectionService.insertDaParamCollection(paramCollection1);
-
-
-
-                DaParamCollection paramCollection2 = new DaParamCollection();
-                paramCollection2.setLocationCode(parts[1]);
-                paramCollection2.setParamCode("WorkID");
-                paramCollection2.setParamValue(WorkID);
-                paramCollection2.setParamName(parts[0]+"."+parts[1]+".WorkID");
-                daParamCollectionService.insertDaParamCollection(paramCollection2);
-
-                //淇濆瓨鐘舵�佹洿鏂板墠绔〃鍗�
-                BsFormulaChildInfo test = bsFormulaChildInfoService.selectBsFormulaChildInfoByTypeTopOne("1", "test", parts[1]);
-                test.setResults(WorkID);
-                bsFormulaChildInfoService.updateBsFormulaChildInfo(test);
-                WebSocketUsers.sendMessageToUserByText(map.get(parts[1]), "TIGHTEN");
-
-
-
-                System.out.println("SNCode:"+SNCode);
-                System.out.println("Node:"+Node+"value:"+value);
-                NodeEntity node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".StationStatus").value("0").type("short").build();
-                Boolean out=clientHandler.write(node);
-                NodeEntity RecordSN= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordSN").value("0").type("short").build();
-                Boolean out1=clientHandler.write(RecordSN);
-                NodeEntity riteRecordSNDone= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordSNDone").value("0").type("short").build();
-                Boolean out2=clientHandler.write(riteRecordSNDone);
-                log.info("鑺傜偣:{},鍝嶅簲缁撴灉:{}", node.getIdentifier(),out);
-            default:
-                break;
-        }
-    }
-
-    //宸ヤ欢鍒颁綅
-    public void inPlace(String Node, String value) throws Exception {
-        String[] parts = Node.split("[.]");
-        ClientHandler clientHandler=new ClientHandler();
-        System.out.println("Node:"+Node+"value:"+value);
-        switch (value){
-            case "1":
-
-            default:
-                break;
-        }
-    }
-
-    //鏀捐
-    public void release(String Node, String value) throws Exception {
-        String[] parts = Node.split("[.]");
-        ClientHandler clientHandler=new ClientHandler();
-        System.out.println("Node:"+Node+"value:"+value);
-        switch (value){
-            case "1":
-
-            default:
-                break;
-        }
-    }
-
-
-}
diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/client/ClientHandler.java b/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/client/ClientHandler.java
deleted file mode 100644
index a6e01b5..0000000
--- a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/client/ClientHandler.java
+++ /dev/null
@@ -1,295 +0,0 @@
-package com.jcdm.main.da.opcuaconfig.client;
-
-import com.google.common.collect.ImmutableList;
-import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig;
-import com.jcdm.main.da.opcuaconfig.domain.NodeEntity;
-import com.jcdm.main.da.opcuaconfig.service.IDaOpcuaConfigService;
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
-import org.eclipse.milo.opcua.sdk.client.api.nodes.VariableNode;
-import org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaSubscription;
-import org.eclipse.milo.opcua.stack.core.AttributeId;
-import org.eclipse.milo.opcua.stack.core.BuiltinDataType;
-import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
-import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
-import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode;
-import org.eclipse.milo.opcua.stack.core.types.builtin.Variant;
-import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned;
-import org.eclipse.milo.opcua.stack.core.types.enumerated.MonitoringMode;
-import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn;
-import org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemCreateRequest;
-import org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters;
-import org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-
-/**
- * @ClassName: ClientHandler
- * @Description: 瀹㈡埛绔鐞�
- * @author Jellyleo
- * @date 2019骞�12鏈�12鏃�
- */
-@Slf4j
-@Service
-public class ClientHandler {
-
-	// 瀹㈡埛绔疄渚�
-	public static OpcUaClient client = null;
-
-	public List<DaOpcuaConfig> b = null;
-
-	@Autowired
-	private ClientRunner clientRunner;
-
-	@Autowired
-	private IDaOpcuaConfigService daOpcuaConfigService;
-
-
-	/**
-	 * 
-	 * @MethodName: connect
-	 * @Description: connect
-	 * @throws Exception
-	 * @CreateTime 2019骞�12鏈�18鏃� 涓婂崍10:41:09
-	 */
-	public String connect() throws Exception {
-
-		if (client != null) {
-			return "瀹㈡埛绔凡鍒涘缓";
-		}
-
-		client = clientRunner.run();
-
-		if (client == null) {
-			return "瀹㈡埛绔厤缃疄渚嬪寲澶辫触";
-		}
-
-		// 鍒涘缓杩炴帴
-		client.connect().get();
-		return "鍒涘缓杩炴帴鎴愬姛";
-	}
-
-	/**
-	 * @MethodName: disconnect
-	 * @Description: 鏂紑杩炴帴
-	 * @return
-	 * @throws Exception
-	 * @CreateTime 2019骞�12鏈�18鏃� 涓婂崍10:45:21
-	 */
-	public String disconnect() throws Exception {
-
-		if (client == null) {
-			return "杩炴帴宸叉柇寮�";
-		}
-
-		// 鏂紑杩炴帴
-		clientRunner.getFuture().complete(client);
-		client = null;
-		return "鏂紑杩炴帴鎴愬姛";
-	}
-
-	/**
-	 * @MethodName: subscribe
-	 * @Description: 璁㈤槄鑺傜偣鍙橀噺
-	 * @throws Exception
-	 * @CreateTime 2019骞�12鏈�18鏃� 涓婂崍10:38:11
-	 */
-	public String subscribe(List<NodeEntity> nodes) throws Exception {
-
-		if (client == null) {
-			return "鎵句笉鍒板鎴风锛屾搷浣滃け璐�";
-		}
-
-		// 鏌ヨ璁㈤槄瀵硅薄锛屾病鏈夊垯鍒涘缓
-		UaSubscription subscription = null;
-		ImmutableList<UaSubscription> subscriptionList = client.getSubscriptionManager().getSubscriptions();
-		if (CollectionUtils.isEmpty(subscriptionList)) {
-			subscription = client.getSubscriptionManager().createSubscription(1000.0).get();
-		} else {
-			subscription = subscriptionList.get(0);
-		}
-
-		// 鐩戞帶椤硅姹傚垪琛�
-		List<MonitoredItemCreateRequest> requests = new ArrayList<>();
-
-		if (!CollectionUtils.isEmpty(nodes)) {
-			for (NodeEntity node : nodes) {
-				// 鍒涘缓鐩戞帶鐨勫弬鏁�
-				MonitoringParameters parameters = new MonitoringParameters(subscription.nextClientHandle(), 1000.0, // sampling
-						// interval
-						null, // filter, null means use default
-						Unsigned.uint(10), // queue size
-						true // discard oldest
-				);
-				// 鍒涘缓璁㈤槄鐨勫彉閲忥紝 鍒涘缓鐩戞帶椤硅 姹�
-				MonitoredItemCreateRequest request = new MonitoredItemCreateRequest(
-						new ReadValueId(new NodeId(node.getIndex(), node.getIdentifier()), AttributeId.Value.uid(),
-								null, null),
-						MonitoringMode.Reporting, parameters);
-				requests.add(request);
-			}
-		}
-
-		// 鍒涘缓鐩戞帶椤癸紝骞朵笖娉ㄥ唽鍙橀噺鍊兼敼鍙樻椂鍊欑殑鍥炶皟鍑芥暟
-		subscription.createMonitoredItems(TimestampsToReturn.Both, requests, (item, id) -> {
-			item.setValueConsumer((i, v) -> {
-				handle(i.getReadValueId().getNodeId(), v.getValue());
-			});
-		}).get();
-
-		return "璁㈤槄鎴愬姛";
-	}
-
-	/**
-	 * * @MethodName: write
-	 * @Description: 鍥炶皟鍑芥暟
-	 * @CreateTime 2023骞�10鏈�13鏃�
-	 */
-	public void handle(NodeId id, Variant value){
-		if (b == null || 0 > b.size()) {
-			DaOpcuaConfig opcuaConfParam=new DaOpcuaConfig();
-		    opcuaConfParam.setSubscribe("Y");
-		    b=daOpcuaConfigService.selectDaOpcuaConfigList(opcuaConfParam);
-		}
-		//浣跨敤Stream API鍦↙ist<T>涓煡鎵惧厓绱�
-		DaOpcuaConfig daOpcuaConfig = b.stream()
-				.filter(customer ->id.getIdentifier().toString().equals(customer.getNode()))
-				.findAny()
-				.orElse(null);
-		try {
-			Class<?> clazz = Class.forName("com.jcdm.main.da.opcuaconfig.cert.MethodName");
-			Method method = clazz.getMethod(daOpcuaConfig.getrFunction(), new Class[] { String.class, String.class });
-			method.invoke(clazz.newInstance(),new Object[] {
-					new String(id.getIdentifier().toString()), new String(value.getValue().toString()) });
-		} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException |
-				 InvocationTargetException e) {
-			e.printStackTrace();
-		}
-	}
-
-
-	/**
-	 * @MethodName: write
-	 * @Description: 鍙樿妭鐐归噺鍐欏叆
-	 * @param node
-	 * @throws Exception
-	 * @CreateTime 2019骞�12鏈�18鏃� 涓婂崍9:51:40
-	 */
-	public static Boolean write(NodeEntity node) throws Exception {
-
-		if (client == null) {
-			log.info("鎵句笉鍒板鎴风锛屾搷浣滃け璐�");
-			return false;
-		}
-
-		NodeId nodeId = new NodeId(node.getIndex(), node.getIdentifier());
-		Variant value = null;
-		switch (node.getType()) {
-		case "int":
-			value = new Variant(Integer.parseInt(node.getValue().toString()));
-			break;
-		case "boolean":
-			value = new Variant(Boolean.parseBoolean(node.getValue().toString()));
-			break;
-		case "short":
-			value = new Variant(Short.parseShort(node.getValue().toString()));
-			break;
-		case "long":
-			value = new Variant(Long.parseLong(node.getValue().toString()));
-			break;
-		case "string":
-			value = new Variant(node.getValue().toString());
-			break;
-		case "char":
-			value = new Variant(node.getValue().toString().charAt(0));
-			break;
-		}
-		DataValue dataValue = new DataValue(value, null, null);
-
-		StatusCode statusCode = client.writeValue(nodeId, dataValue).get();
-
-		return statusCode.isGood();
-	}
-
-	/**
-	 * 鏂规硶鎻忚堪: 璇诲彇澶氫釜鐐逛綅鐨勫��
-	 *
-	 * @param nodeIdList 鐐逛綅闆嗗悎
-	 * @return {@link List<DataValue>}
-	 * @throws
-	 */
-	public static List<DataValue> readValues(List<NodeId> nodeIdList){
-		try {
-			List<DataValue> dataValues=client.readValues(0.0, TimestampsToReturn.Both,nodeIdList).get();
-			return dataValues;
-		} catch (InterruptedException | ExecutionException e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	/**
-	 * @MethodName: read
-	 * @Description: 璇诲彇
-	 * @param node
-	 * @return
-	 * @throws Exception
-	 * @CreateTime 2019骞�12鏈�19鏃� 涓嬪崍2:40:34
-	 */
-	public String read(NodeEntity node) throws Exception {
-
-		if (client == null) {
-			return "鎵句笉鍒板鎴风锛屾搷浣滃け璐�";
-		}
-
-		NodeId nodeId = new NodeId(node.getIndex(), node.getIdentifier());
-		VariableNode vnode = client.getAddressSpace().createVariableNode(nodeId);
-		DataValue value = vnode.readValue().get();
-		log.info("Value={}", value);
-
-		Variant variant = value.getValue();
-		log.info("Variant={}", variant.getValue());
-
-		log.info("BackingClass={}", BuiltinDataType.getBackingClass(variant.getDataType().get()));
-
-		return variant.getValue().toString();
-	}
-
-
-	/**
-	 * 鏂规硶鎻忚堪:  鍐欏叆澶氫釜鑺傜偣鐨勫��
-	 *
-	 * @param keys  鑺傜偣闆嗗悎
-	 * @param values  鍊奸泦鍚�
-	 * @param client  瀹㈡埛绔�
-	 * @return {@link Object}
-	 * @throws
-	 */
-	public static Object writeValues(Set<String> keys, List<Object> values, OpcUaClient client){
-		List<NodeId> nodeIs=new ArrayList<>(keys.size());
-		keys.forEach(e->{
-			NodeId nodeId = new NodeId(2, e);
-			nodeIs.add(nodeId);
-		});
-		List<DataValue> dataValues=new ArrayList<>(values.size());
-		values.forEach(e->{
-			Variant value=new Variant(Double.parseDouble(e.toString()));
-			DataValue dataValue=new DataValue(value);
-			dataValues.add(dataValue);
-		});
-		try {
-			client.writeValues(nodeIs,dataValues).get();
-		} catch (InterruptedException | ExecutionException e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-}
diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/client/ClientRunner.java b/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/client/ClientRunner.java
deleted file mode 100644
index 513a6dd..0000000
--- a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/client/ClientRunner.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package com.jcdm.main.da.opcuaconfig.client;
-
-import com.jcdm.main.da.opcuaconfig.cert.KeyStoreLoader;
-import com.jcdm.main.da.opcuaconfig.init.Properties;
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
-import org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfig;
-import org.eclipse.milo.opcua.sdk.client.api.identity.AnonymousProvider;
-import org.eclipse.milo.opcua.stack.client.DiscoveryClient;
-import org.eclipse.milo.opcua.stack.core.Stack;
-import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy;
-import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText;
-import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned;
-import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.function.Predicate;
-
-/**
- * @ClassName: ClientRunner
- * @Description: 瀹㈡埛绔惎鍔ㄧ被
- * @author yyt
- * @date 2023骞�10鏈�13鏃�
- */
-@Slf4j
-@Component
-public class ClientRunner {
-
-	private final CompletableFuture<OpcUaClient> future = new CompletableFuture<>();
-
-	@Autowired
-	private Properties properties;
-
-	@Autowired
-	private KeyStoreLoader keyStoreLoader;
-
-	/**
-	 * @MethodName: run
-	 * @Description: 鍚姩
-	 * @return
-	 * @throws Exception
-	 * @CreateTime 2023骞�10鏈�13鏃�
-	 */
-	public OpcUaClient run() throws Exception {
-
-		OpcUaClient client = createClient();
-
-		future.whenCompleteAsync((c, ex) -> {
-			if (ex != null) {
-				log.error("Error running example: {}", ex.getMessage(), ex);
-			}
-
-			try {
-				c.disconnect().get();
-				Stack.releaseSharedResources();
-			} catch (InterruptedException | ExecutionException e) {
-				log.error("Error disconnecting:", e.getMessage(), e);
-			}
-		});
-
-		return client;
-	}
-
-	/**
-	 * @MethodName: createClient
-	 * @Description: 鍒涘缓瀹㈡埛绔�
-	 * @return
-	 * @throws Exception
-	 * @CreateTime 2023骞�10鏈�13鏃�
-	 */
-	private OpcUaClient createClient() throws Exception {
-
-		Path securityTempDir = Paths.get(properties.getCertPath(), "security");
-		Files.createDirectories(securityTempDir);
-		if (!Files.exists(securityTempDir)) {
-			log.error("unable to create security dir: " + securityTempDir);
-			return null;
-		}
-
-		KeyStoreLoader loader = keyStoreLoader.load(securityTempDir);
-
-		// 鎼滅储OPC鑺傜偣
-		List<EndpointDescription> endpoints = null;
-		try {
-			//鑾峰彇瀹夊叏绛栫暐
-			endpoints = DiscoveryClient.getEndpoints(properties.getEndpointUrl()).get();
-		} catch (Throwable e) {
-			// try the explicit discovery endpoint as well
-			String discoveryUrl = properties.getEndpointUrl();
-
-			if (!discoveryUrl.endsWith("/")) {
-				discoveryUrl += "/";
-			}
-			discoveryUrl += "discovery";
-
-			log.info("Trying explicit discovery URL: {}", discoveryUrl);
-			endpoints = DiscoveryClient.getEndpoints(discoveryUrl).get();
-		}
-
-		EndpointDescription endpoint = endpoints.stream()
-				.filter(e -> e.getSecurityPolicyUri().equals(SecurityPolicy.None.getUri())).filter(endpointFilter())
-				.findFirst().orElseThrow(() -> new Exception("no desired endpoints returned"));
-
-		OpcUaClientConfig config = OpcUaClientConfig.builder()
-				// opc ua鑷畾涔夌殑鍚嶇О
-				.setApplicationName(LocalizedText.english("plc"))
-				// 鍦板潃
-				.setApplicationUri(properties.getEndpointUrl())
-				.setCertificate(loader.getClientCertificate()).setKeyPair(loader.getClientKeyPair())
-				// 瀹夊叏绛栫暐绛夐厤缃�
-				//.setEndpoint(endpoint).setIdentityProvider(new UsernameProvider("OPCUA", "yyt@8888888888"))
-				.setEndpoint(endpoint)
-				// 鍖垮悕楠岃瘉
-				.setIdentityProvider(new AnonymousProvider())
-				//绛夊緟鏃堕棿
-				.setRequestTimeout(Unsigned.uint(5000)).build();
-
-		return OpcUaClient.create(config);
-
-	}
-
-	/**
-	 * @MethodName: endpointFilter
-	 * @Description: endpointFilter
-	 * @return
-	 * @CreateTime 2023骞�10鏈�13鏃�
-	 */
-	private Predicate<EndpointDescription> endpointFilter() {
-		return e -> true;
-	}
-
-	/**
-	 * @return the future
-	 */
-	public CompletableFuture<OpcUaClient> getFuture() {
-		return future;
-	}
-
-}
diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/OpcusConfigInit.java b/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/OpcusConfigInit.java
deleted file mode 100644
index 2404567..0000000
--- a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/OpcusConfigInit.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.jcdm.main.da.opcuaconfig.init;
-
-import com.google.common.collect.Lists;
-import com.jcdm.main.da.opcuaconfig.client.ClientHandler;
-import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig;
-import com.jcdm.main.da.opcuaconfig.domain.NodeEntity;
-import com.jcdm.main.da.opcuaconfig.service.IDaOpcuaConfigService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-@Component
-@Slf4j
-public class OpcusConfigInit implements CommandLineRunner {
-
-    @Autowired
-    private ClientHandler clientHandler;
-
-    @Autowired
-    private IDaOpcuaConfigService daOpcuaConfigService;
-
-    @Override
-    public void run(String... args) throws Exception {
-        try {
-            DaOpcuaConfig daOpcuaConfig=new DaOpcuaConfig();
-            daOpcuaConfig.setSubscribe("Y"); //璁剧疆鏌ヨ鏉′欢锛屾槸鍚﹁闃呯姸鎬佷负Y鐨勬墍鏈夋暟鎹�.
-            List<DaOpcuaConfig> nodeslist=daOpcuaConfigService.selectDaOpcuaConfigList(daOpcuaConfig);
-            clientHandler.connect();
-            if (nodeslist != null && nodeslist.size() > 0) {
-                List<NodeEntity> NodeList = Lists.transform(nodeslist, (DaOpcuaConfig) -> {
-                    NodeEntity nodeEntity = new NodeEntity();
-                    nodeEntity.setIndex(2);
-                    nodeEntity.setIdentifier(DaOpcuaConfig.getNode());
-                    return nodeEntity;
-                });
-                clientHandler.subscribe(NodeList);
-                log.info("鍒濆鍖朞PC璁㈤槄" + nodeslist.size() + "鏉★紒");
-            }
-            log.info("绯荤粺鎻愮ず锛孫PCUA璁㈤槄鎴愬姛锛�");
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.info("绯荤粺鎻愮ず锛孫PCUA璁㈤槄澶辫触锛�");
-        }
-    }
-}
diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/CustomRunner.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/CustomRunner.java
new file mode 100644
index 0000000..3897220
--- /dev/null
+++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/CustomRunner.java
@@ -0,0 +1,58 @@
+package com.jcdm.main.plcserver;
+
+
+import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService;
+import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
+import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
+import com.jcdm.main.plcserver.conf.OPCElement;
+import com.jcdm.main.plcserver.sub.OPCUaSubscription;
+import com.kangaroohy.milo.service.MiloService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Component
+public class CustomRunner implements ApplicationRunner {
+
+    @Autowired
+    private MiloService miloService;
+
+    @Autowired
+    private IDaPassingStationCollectionService daPassingStationCollectionService;
+
+    @Autowired
+    private IDaCollectionParamConfService collectionParamConfService;
+
+    @Autowired
+    private IDaParamCollectionService daParamCollectionService;
+
+    @Override
+    public void run(ApplicationArguments args) throws Exception {
+
+        OPCUaSubscription opcUaSubscription = new OPCUaSubscription(
+                miloService,
+                daPassingStationCollectionService,
+                collectionParamConfService,
+                daParamCollectionService);
+
+        List<String> lists = getSubList();
+        miloService.subscriptionFromOpcUa(lists,opcUaSubscription);
+
+    }
+
+    /**
+     * 璁㈤槄鍐呭
+     */
+    public List<String> getSubList(){
+        List<String> lists = new ArrayList<>();
+        lists.add(OPCElement.OP_OP010_RecordSN);//璇锋眰涓嬪彂SN鍙�
+        lists.add(OPCElement.OP_OP010_RecordData);//璇锋眰璁板綍鏁版嵁
+        lists.add(OPCElement.OP_OP020_RecordData);//璇锋眰璁板綍鏁版嵁
+        return lists;
+    }
+}
+
diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/conf/OPCElement.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/conf/OPCElement.java
new file mode 100644
index 0000000..9324948
--- /dev/null
+++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/conf/OPCElement.java
@@ -0,0 +1,25 @@
+package com.jcdm.main.plcserver.conf;
+
+/**
+ * @ClassName: OPCElement
+ * @Description: PC鍜孭LC閫氫俊浣跨敤鐨凮PCserver涓婄殑鏍囪鍚嶇О鍒楄〃
+ */
+public class OPCElement {
+
+
+    /**
+     * OP010
+     */
+    public static final String OP_OP010_RecordSN = "OP.OP010.RecordSN";//璇锋眰涓嬪彂SN鍙�
+    public static final String OP_OP010_RecordData = "OP.OP010.RecordData";//璇锋眰璁板綍鏁版嵁
+
+    /**
+     * OP020
+     */
+    public static final String OP_OP020_RecordData = "OP.OP020.RecordData";//璇锋眰璁板綍鏁版嵁
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
new file mode 100644
index 0000000..f841abe
--- /dev/null
+++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
@@ -0,0 +1,190 @@
+package com.jcdm.main.plcserver.sub;
+
+
+import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf;
+import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService;
+import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
+import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
+import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
+import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
+import com.jcdm.main.plcserver.conf.OPCElement;
+import com.kangaroohy.milo.model.ReadWriteEntity;
+import com.kangaroohy.milo.runner.subscription.SubscriptionCallback;
+import com.kangaroohy.milo.service.MiloService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+
+@Component
+public class OPCUaSubscription implements SubscriptionCallback {
+
+    public static MiloService miloService;
+
+    public IDaPassingStationCollectionService daPassingStationCollectionService;
+
+    public IDaCollectionParamConfService collectionParamConfService;
+
+    public IDaParamCollectionService daParamCollectionService;
+
+    public OPCUaSubscription(MiloService miloService,
+                             IDaPassingStationCollectionService daPassingStationCollectionService,
+                             IDaCollectionParamConfService collectionParamConfService,
+                             IDaParamCollectionService daParamCollectionService) {
+        OPCUaSubscription.miloService = miloService;
+        this.daPassingStationCollectionService = daPassingStationCollectionService;
+        this.collectionParamConfService = collectionParamConfService;
+        this.daParamCollectionService = daParamCollectionService;
+
+    }
+
+
+    @Override
+    public void onSubscribe(String identifier, Object value) {
+
+        try {
+            if(null != value) {
+                String[] nodes = identifier.split("[.]");
+                String thoroughfare = nodes[0];//閫氶亾
+                String device = nodes[1];//璁惧
+                String tab = nodes[2];//鏍囪
+                String tabVlaue = value.toString();//鍦板潃鍊�
+
+                //璇锋眰涓嬪彂SN鍙�
+                if (("RecordSN").equals(tab) && "1".equals(tabVlaue)) {
+                    //鑾峰彇SN鍙锋柟娉�
+                    String SNCode = getSNCode();
+
+                    //涓嬪彂SN
+                    String SNCodeAddress = thoroughfare + "." + device + ".SNCode";
+                    miloService.writeToOpcChar(ReadWriteEntity.builder().identifier(SNCodeAddress).value(SNCode).build());
+                    //涓嬪彂SN瀹屾垚
+                    String recordSNDoneAddress = thoroughfare + "." + device + ".RecordSNDone";
+                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(recordSNDoneAddress).value(1).build());
+                }
+                //璇锋眰璁板綍鏁版嵁
+                else if (("RecordData").equals(tab)) {
+                    String recordDataDoneValue = "";
+
+                    if("1".equals(tabVlaue)){
+                        recordDataDoneValue = "11";
+
+                        //杩涚珯淇濆瓨鏁版嵁
+                        //inSaveDate(thoroughfare,device)
+                        //璁板綍鏁版嵁瀹屾垚
+                        String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
+                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(recordDataDoneValue).build());
+                    }else if("2".equals(tabVlaue)){
+
+                        //鍑虹珯淇濆瓨鏁版嵁
+                        recordDataDoneValue = outSaveDate(thoroughfare,device);
+                        //璁板綍鏁版嵁瀹屾垚
+                        String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
+                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(recordDataDoneValue).build());
+                    }else{
+                        System.out.println("^");
+                    }
+
+
+
+
+                }
+            }
+        } catch (Exception e) {
+
+        }
+    }
+
+
+
+    /**
+     * 鑾峰彇SNCode
+     */
+    public String getSNCode(){
+        String SNCode = "";
+        return SNCode;
+    }
+
+
+    /**
+     * 鍑虹珯淇濆瓨鏁版嵁
+     */
+    public String outSaveDate(String thoroughfare,String device) {
+        String result = "";
+        try {
+            //璇诲彇SNCode
+            String SNCodeAddress = thoroughfare + "." + device + ".SNCode";
+            Object SNCodeObject = miloService.readFromOpcUa(SNCodeAddress).getValue();
+            if(null == SNCodeObject || "".equals(SNCodeObject)){
+               result = "22";
+            }else{
+                String SNCode = SNCodeObject.toString();
+                //1銆佹洿鏂板伐鍗曚俊鎭�
+                //updateOrderInfo();
+                //2銆佷繚瀛樿繃绔欓噰闆嗘暟鎹�
+                saveStationInfo(SNCode,thoroughfare,device);
+                //3銆佷繚瀛樺弬鏁伴噰闆嗘暟鎹�
+                SaveParamData(SNCode,thoroughfare,device);
+
+                result = "21";
+
+            }
+
+        }catch (Exception e) {
+
+        }
+        return result;
+    }
+
+    /**
+     * 淇濆瓨杩囩珯閲囬泦
+     */
+    public void saveStationInfo(String SNCode,String thoroughfare,String device){
+        DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection();
+        daPassingStationCollection.setSfcCode(SNCode);
+        //daPassingStationCollection.setInboundTime();//鍏ョ珯鏃堕棿
+        daPassingStationCollection.setOutboundTime(new Date());//鍑虹珯鏃堕棿
+        //daPassingStationCollection.setOutRsSign();//鍑虹珯鏄惁鍚堟牸
+        daPassingStationCollectionService.insertDaPassingStationCollection(daPassingStationCollection);
+    }
+
+    public void SaveParamData(String SNCode,String thoroughfare,String device) throws Exception {
+        List<DaCollectionParamConf> list;
+        DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf();
+        daCollectionParamConf.setGatherAddress(thoroughfare+ "." + device);
+        list = collectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf);
+
+        List<String> nodeIdList = list.stream().map(info -> {
+            String nodeid = info.getGatherAddress();
+            return nodeid;
+        }).collect(Collectors.toList());
+
+        if(!nodeIdList.isEmpty()){
+            List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(nodeIdList);
+            List<DaParamCollection> daParamCollectionlist = new ArrayList<>();
+            for(int i=0;i<nodeIdList.size();i++){
+                DaParamCollection ParamCollection = new DaParamCollection();
+                if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){
+                    ParamCollection.setParamCode(readWriteEntityList.get(i).getIdentifier().toString().split("[.]")[2]);
+                    ParamCollection.setLocationCode(device);
+                    ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString());
+                    ParamCollection.setSfcCode(SNCode);
+                    ParamCollection.setParamName(list.get(i).getCollectParameterName());
+                    ParamCollection.setParamUpper(list.get(i).getParamUpper());
+                    ParamCollection.setParamLower(list.get(i).getParamLower());
+                    ParamCollection.setUnit(list.get(i).getCollectParameterUnit());
+                    //ParamCollection.setState("鍚堟牸");
+                    ParamCollection.setType(list.get(i).getCollectParameterType());
+                    ParamCollection.setCollectionTime(new Date());
+                    daParamCollectionlist.add(ParamCollection);
+                }
+            }
+            //daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist);
+        }
+
+    }
+}

--
Gitblit v1.9.3