jcdm-main/pom.xml
@@ -37,6 +37,38 @@ </exclusions> </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>org.projectlombok</groupId> <artifactId>lombok</artifactId> jcdm-main/src/main/java/com/jcdm/main/bs/beatSetting/controller/BsBeatSettingController.java
@@ -22,7 +22,7 @@ import com.jcdm.common.core.page.TableDataInfo; /** * èæ设置Controller * èæ设置Controller1 * * @author Yi * @date 2024-01-05 jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/KeyStoreLoader.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,127 @@ 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`å å¯æ åçKeyStoreãKeyStoreå¨åé¢å°ä½ä¸ºè¯»ååçæè¯ä¹¦ç对象ã 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`为Miloåºç对象ã 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; } } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/MethodName.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,69 @@ package com.jcdm.main.da.opcuaconfig.cert; 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 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 java.util.*; import java.util.stream.Collectors; import static com.jcdm.main.da.opcuaconfig.client.ClientHandler.readValues; @Slf4j public class MethodName { private IDaCollectionParamConfService collectionParamConfService = BeanUtils.getBean(IDaCollectionParamConfService.class); public void getSn(String Node, String value) throws Exception { log.info(Node+":"+value); String[] parts = Node.split("[.]"); ClientHandler clientHandler=new ClientHandler(); 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); 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); log.info("èç¹:{},ååºç»æ:{}", node1.getIdentifier(),out1); break; case "2": //请æ±è®°å½å·¥ä½æ°æ® List<DaCollectionParamConf> b; DaCollectionParamConf daCollectionParamConf=new DaCollectionParamConf(); daCollectionParamConf.setCollectParameterId(parts[0]+"."+parts[1]); b=collectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf); List<String> ids = b.stream().map(e -> e.getCollectParameterId()).collect(Collectors.toList()); Set<String> de=ListToSet(ids); List<DataValue> s=readValues(de); // s.forEach(element->{ // DaParamCollection Config=new DaParamCollection(); // String[] q = element.getIdentifier().split("[.]"); // Config.setParamCode(q[2]); // Config.setLocationCode(q[1]); // Config.setParamValue(element.getValue().toString()); // daParamCollectionService.insertDaParamCollection(Config); // }); NodeEntity node2= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordDataDone").value("21").type("short").build(); Boolean out2=clientHandler.write(node2); log.info("èç¹:{},ååºç»æ:{}", node2.getIdentifier(),out2); break; default: break; } } public Set<String> ListToSet(List<String> list) { Object[] objects = list.toArray();// è¿åObjectæ°ç» String[] strings1 = new String[list.size()]; list.toArray(strings1);// å°è½¬ååçæ°ç»æ¾å ¥å·²ç»å建好çå¯¹è±¡ä¸ String[] strings2 = list.toArray(new String[0]);// å°è½¬ååçæ°ç»èµç»æ°å¯¹è±¡ Set<String> set = new HashSet<String>(Arrays.asList(strings2)); return set; } } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/client/ClientHandler.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,301 @@ package com.jcdm.main.da.opcuaconfig.client; import com.google.common.collect.ImmutableList; import com.jcdm.main.da.opcuaconfig.controller.DaOpcuaConfigController; 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(1L); b=daOpcuaConfigService.selectDaOpcuaConfigList(opcuaConfParam); } //使ç¨Stream APIå¨List<T>ä¸æ¥æ¾å ç´ DaOpcuaConfig daOpcuaConfig = b.stream() .filter(customer ->id.getIdentifier().toString().equals(customer.getNode())) .findAny() .orElse(null); try { Class<?> clazz = Class.forName(daOpcuaConfig.getrModule()); 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 keys ç¹ä½éå * @return {@link List<DataValue>} * @throws */ public static List<DataValue> readValues(Set<String> keys){ List<NodeId> nodeIdList=new ArrayList<>(500); keys.forEach(e->{ NodeId nodeId = new NodeId(2, e); nodeIdList.add(nodeId); }); 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; } } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/client/ClientRunner.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,146 @@ 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; } } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/controller/DaOpcuaConfigController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,109 @@ package com.jcdm.main.da.opcuaconfig.controller; import com.jcdm.common.annotation.Log; import com.jcdm.common.core.controller.BaseController; import com.jcdm.common.core.domain.AjaxResult; import com.jcdm.common.core.page.TableDataInfo; import com.jcdm.common.enums.BusinessType; import com.jcdm.common.utils.poi.ExcelUtil; import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig; import com.jcdm.main.da.opcuaconfig.service.IDaOpcuaConfigService; import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.List; /** * OPCUAåæ°è®¾ç½®Controller * * @author yyt * @date 2023-12-22 */ @RestController @RequestMapping("/da/opcuaconfig") public class DaOpcuaConfigController extends BaseController { @Autowired private IDaOpcuaConfigService daOpcuaConfigService; @Autowired private IDaParamCollectionService daParamCollectionService; /** * æ¥è¯¢OPCUAåæ°è®¾ç½®å表 */ @PreAuthorize("@ss.hasPermi('da:opcuaconfig:list')") @GetMapping("/list") public TableDataInfo list(DaOpcuaConfig daOpcuaConfig) { startPage(); List<DaOpcuaConfig> list = daOpcuaConfigService.selectDaOpcuaConfigList(daOpcuaConfig); return getDataTable(list); } @PreAuthorize("@ss.hasPermi('da:opcuaconfig:getconfig')") @GetMapping("/getconfig") public List<DaOpcuaConfig> getconfig(DaOpcuaConfig daOpcuaConfig) { return daOpcuaConfigService.selectDaOpcuaConfigList(daOpcuaConfig); } /** * 导åºOPCUAåæ°è®¾ç½®å表 */ @PreAuthorize("@ss.hasPermi('da:opcuaconfig:export')") @Log(title = "OPCUAåæ°è®¾ç½®", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, DaOpcuaConfig daOpcuaConfig) { List<DaOpcuaConfig> list = daOpcuaConfigService.selectDaOpcuaConfigList(daOpcuaConfig); ExcelUtil<DaOpcuaConfig> util = new ExcelUtil<DaOpcuaConfig>(DaOpcuaConfig.class); util.exportExcel(response, list, "OPCUAåæ°è®¾ç½®æ°æ®"); } /** * è·åOPCUAåæ°è®¾ç½®è¯¦ç»ä¿¡æ¯ */ @PreAuthorize("@ss.hasPermi('da:opcuaconfig:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(daOpcuaConfigService.selectDaOpcuaConfigById(id)); } /** * æ°å¢OPCUAåæ°è®¾ç½® */ @PreAuthorize("@ss.hasPermi('da:opcuaconfig:add')") @Log(title = "OPCUAåæ°è®¾ç½®", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody DaOpcuaConfig daOpcuaConfig) { return toAjax(daOpcuaConfigService.insertDaOpcuaConfig(daOpcuaConfig)); } /** * ä¿®æ¹OPCUAåæ°è®¾ç½® */ @PreAuthorize("@ss.hasPermi('da:opcuaconfig:edit')") @Log(title = "OPCUAåæ°è®¾ç½®", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody DaOpcuaConfig daOpcuaConfig) { return toAjax(daOpcuaConfigService.updateDaOpcuaConfig(daOpcuaConfig)); } /** * å é¤OPCUAåæ°è®¾ç½® */ @PreAuthorize("@ss.hasPermi('da:opcuaconfig:remove')") @Log(title = "OPCUAåæ°è®¾ç½®", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(daOpcuaConfigService.deleteDaOpcuaConfigByIds(ids)); } } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/domain/DaOpcuaConfig.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,163 @@ package com.jcdm.main.da.opcuaconfig.domain; import com.jcdm.common.annotation.Excel; import com.jcdm.common.core.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; /** * OPCUAåæ°è®¾ç½®å¯¹è±¡ da_opcua_config * * @author yyt * @date 2023-12-22 */ public class DaOpcuaConfig extends BaseEntity { private static final long serialVersionUID = 1L; /** ID */ private Long id; /** æå±æ¨¡å */ @Excel(name = "æå±æ¨¡å") private String module; /** èç¹ */ @Excel(name = "èç¹") private String node; /** é¿åº¦ */ @Excel(name = "é¿åº¦") private Long length; /** ç±»å */ @Excel(name = "ç±»å") private String sysTypes; /** åè½è¯´æ */ @Excel(name = "åè½è¯´æ") private String functionality; /** æ¯å¦è®¢é */ @Excel(name = "æ¯å¦è®¢é ") private Long subscribe; /** 订é ååºæ¨¡å */ @Excel(name = "订é ååºæ¨¡å") private String rModule; /** 订é ååºå½æ° */ @Excel(name = "订é ååºå½æ°") private String rFunction; /** å¤æ³¨ */ @Excel(name = "å¤æ³¨") private String remarks; public void setId(Long id) { this.id = id; } public Long getId() { return id; } public void setModule(String module) { this.module = module; } public String getModule() { return module; } public void setNode(String node) { this.node = node; } public String getNode() { return node; } public void setLength(Long length) { this.length = length; } public Long getLength() { return length; } public void setSysTypes(String sysTypes) { this.sysTypes = sysTypes; } public String getSysTypes() { return sysTypes; } public void setFunctionality(String functionality) { this.functionality = functionality; } public String getFunctionality() { return functionality; } public void setSubscribe(Long subscribe) { this.subscribe = subscribe; } public Long getSubscribe() { return subscribe; } public void setrModule(String rModule) { this.rModule = rModule; } public String getrModule() { return rModule; } public void setrFunction(String rFunction) { this.rFunction = rFunction; } public String getrFunction() { return rFunction; } public void setRemarks(String remarks) { this.remarks = remarks; } public String getRemarks() { return remarks; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) .append("module", getModule()) .append("node", getNode()) .append("length", getLength()) .append("sysTypes", getSysTypes()) .append("functionality", getFunctionality()) .append("subscribe", getSubscribe()) .append("rModule", getrModule()) .append("rFunction", getrFunction()) .append("remarks", getRemarks()) .toString(); } } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/domain/NodeEntity.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,19 @@ package com.jcdm.main.da.opcuaconfig.domain; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; @Data @Builder(toBuilder = true) @AllArgsConstructor @NoArgsConstructor public class NodeEntity { private Integer index; private String identifier; private Object value; private String type; private Integer clientHandle; } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/domain/OpcuaConf.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,177 @@ package com.jcdm.main.da.opcuaconfig.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; /** * <p> * * </p> * * @author yyt * @since 2023-10-17 */ @TableName("sys_opcua_conf") public class OpcuaConf implements Serializable { private static final long serialVersionUID=1L; /** * ID */ @TableId(value = "id", type = IdType.ID_WORKER) private Long id; /** * æå±æ¨¡å */ @TableField("module") private String module; /** * èç¹ */ @TableField("node") private String node; /** * é¿åº¦ */ @TableField("length") private Integer length; /** * ç±»å */ @TableField("sys_types") private String sysTypes; /** * åè½è¯´æ */ @TableField("functionality") private String functionality; /** * æ¯å¦è®¢é */ @TableField("subscribe") private Integer subscribe; /** * 订é ååºæ¨¡å */ @TableField("r_module") private String rModule; /** * 订é ååºå½æ° */ @TableField("r_function") private String rFunction; /** * å¤æ³¨ */ @TableField("remarks") private String remarks; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getModule() { return module; } public void setModule(String module) { this.module = module; } public String getNode() { return node; } public void setNode(String node) { this.node = node; } public Integer getLength() { return length; } public void setLength(Integer length) { this.length = length; } public String getSysTypes() { return sysTypes; } public void setSysTypes(String sysTypes) { this.sysTypes = sysTypes; } public String getFunctionality() { return functionality; } public void setFunctionality(String functionality) { this.functionality = functionality; } public Integer getSubscribe() { return subscribe; } public void setSubscribe(Integer subscribe) { this.subscribe = subscribe; } public String getrModule() { return rModule; } public void setrModule(String rModule) { this.rModule = rModule; } public String getrFunction() { return rFunction; } public void setrFunction(String rFunction) { this.rFunction = rFunction; } public String getRemarks() { return remarks; } public void setRemarks(String remarks) { this.remarks = remarks; } @Override public String toString() { return "OpcuaConf{" + "id=" + id + ", module=" + module + ", node=" + node + ", length=" + length + ", sysTypes=" + sysTypes + ", " + "functionality=" + functionality + ", subscribe=" + subscribe + ", rModule=" + rModule + ", rFunction=" + rFunction + ", remarks=" + remarks + "}"; } } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/BeanUtils.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,30 @@ package com.jcdm.main.da.opcuaconfig.init; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; @Component public class BeanUtils implements ApplicationContextAware { protected static ApplicationContext applicationContext ; @Override public void setApplicationContext(ApplicationContext arg0) throws BeansException { if (applicationContext == null) { applicationContext = arg0; } } public static Object getBean(String name) { //nameè¡¨ç¤ºå ¶ä»è¦æ³¨å ¥ç注解nameå return applicationContext.getBean(name); } /** * æ¿å°ApplicationContext对象å®ä¾åå°±å¯ä»¥æå¨è·åBeançæ³¨å ¥å®ä¾å¯¹è±¡ */ public static <T> T getBean(Class<T> clazz) { return applicationContext.getBean(clazz); } } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/OpcusConfigInit.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,51 @@ 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.controller.DaOpcuaConfigController; 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; import java.util.stream.Collectors; import java.util.stream.Stream; @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(1L); //设置æ¥è¯¢æ¡ä»¶ï¼æ¯å¦è®¢é ç¶æ为1çæææ°æ®. 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("åå§åOPC订é " + nodeslist.size() + "æ¡ï¼"); } log.info("ç³»ç»æ示ï¼OPCUA订é æåï¼"); } catch (Exception e) { e.printStackTrace(); log.info("ç³»ç»æ示ï¼OPCUA订é 失败ï¼"); } } } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/Properties.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,57 @@ /** * Created by Jellyleo on 2019å¹´12æ19æ¥ * Copyright © 2019 jellyleo.com * All rights reserved. */ package com.jcdm.main.da.opcuaconfig.init; import lombok.Getter; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; /** * @ClassName: Properties * @Description: OpcUaåæ° * @author yyt * @date 2023å¹´10æ13æ¥ */ @Getter @Configuration @PropertySource("classpath:opcua.properties") public class Properties { @Value("${opcua.server.endpoint.url}") private String endpointUrl; @Value("${opcua.server.idp.username}") private String idpUsername; @Value("${opcua.server.idp.password}") private String idpPassword; @Value("${opcua.client.app.name}") private String appName; @Value("${opcua.client.app.uri}") private String appUri; @Value("${opcua.client.cert.path}") private String certPath; @Value("${opcua.client.cert.file}") private String certFile; @Value("${opcua.client.cert.alias}") private String certAlias; @Value("${opcua.client.cert.common.name}") private String commonName; @Value("${opcua.client.cert.organization}") private String organization; @Value("${opcua.client.cert.organization.unit}") private String orgUnit; @Value("${opcua.client.cert.locality.name}") private String localityName; @Value("${opcua.client.cert.state.name}") private String stateName; @Value("${opcua.client.cert.country.code}") private String countryCode; @Value("${opcua.client.cert.dns.name}") private String dnsName; @Value("${opcua.client.cert.ip.address}") private String ipAddress; @Value("${opcua.client.cert.keystore.password}") private String keyPassword; } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/mapper/DaOpcuaConfigMapper.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,62 @@ package com.jcdm.main.da.opcuaconfig.mapper; import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig; import java.util.List; /** * OPCUAåæ°è®¾ç½®Mapperæ¥å£ * * @author yyt * @date 2023-12-22 */ public interface DaOpcuaConfigMapper { /** * æ¥è¯¢OPCUAåæ°è®¾ç½® * * @param id OPCUAåæ°è®¾ç½®ä¸»é® * @return OPCUAåæ°è®¾ç½® */ public DaOpcuaConfig selectDaOpcuaConfigById(Long id); /** * æ¥è¯¢OPCUAåæ°è®¾ç½®å表 * * @param daOpcuaConfig OPCUAåæ°è®¾ç½®1 * @return OPCUAåæ°è®¾ç½®éå */ public List<DaOpcuaConfig> selectDaOpcuaConfigList(DaOpcuaConfig daOpcuaConfig); /** * æ°å¢OPCUAåæ°è®¾ç½®99 * * @param daOpcuaConfig OPCUAåæ°è®¾ç½® * @return ç»æ */ public int insertDaOpcuaConfig(DaOpcuaConfig daOpcuaConfig); /** * ä¿®æ¹OPCUAåæ°è®¾ç½® * * @param daOpcuaConfig OPCUAåæ°è®¾ç½® * @return ç»æ */ public int updateDaOpcuaConfig(DaOpcuaConfig daOpcuaConfig); /** * å é¤OPCUAåæ°è®¾ç½® * * @param id OPCUAåæ°è®¾ç½®ä¸»é® * @return ç»æ */ public int deleteDaOpcuaConfigById(Long id); /** * æ¹éå é¤OPCUAåæ°è®¾ç½® * * @param ids éè¦å é¤çæ°æ®ä¸»é®éå * @return ç»æ */ public int deleteDaOpcuaConfigByIds(Long[] ids); } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/service/IDaOpcuaConfigService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,62 @@ package com.jcdm.main.da.opcuaconfig.service; import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig; import java.util.List; /** * OPCUAåæ°è®¾ç½®Serviceæ¥å£ * * @author yyt * @date 2023-12-22 */ public interface IDaOpcuaConfigService { /** * æ¥è¯¢OPCUAåæ°è®¾ç½® * * @param id OPCUAåæ°è®¾ç½®ä¸»é® * @return OPCUAåæ°è®¾ç½® */ public DaOpcuaConfig selectDaOpcuaConfigById(Long id); /** * æ¥è¯¢OPCUAåæ°è®¾ç½®å表 * * @param daOpcuaConfig OPCUAåæ°è®¾ç½® * @return OPCUAåæ°è®¾ç½®éå */ public List<DaOpcuaConfig> selectDaOpcuaConfigList(DaOpcuaConfig daOpcuaConfig); /** * æ°å¢OPCUAåæ°è®¾ç½® * * @param daOpcuaConfig OPCUAåæ°è®¾ç½® * @return ç»æ */ public int insertDaOpcuaConfig(DaOpcuaConfig daOpcuaConfig); /** * ä¿®æ¹OPCUAåæ°è®¾ç½® * * @param daOpcuaConfig OPCUAåæ°è®¾ç½® * @return ç»æ */ public int updateDaOpcuaConfig(DaOpcuaConfig daOpcuaConfig); /** * æ¹éå é¤OPCUAåæ°è®¾ç½® * * @param ids éè¦å é¤çOPCUAåæ°è®¾ç½®ä¸»é®éå * @return ç»æ */ public int deleteDaOpcuaConfigByIds(Long[] ids); /** * å é¤OPCUAåæ°è®¾ç½®ä¿¡æ¯ * * @param id OPCUAåæ°è®¾ç½®ä¸»é® * @return ç»æ */ public int deleteDaOpcuaConfigById(Long id); } jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/service/impl/DaOpcuaConfigServiceImpl.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,94 @@ package com.jcdm.main.da.opcuaconfig.service.impl; import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig; import com.jcdm.main.da.opcuaconfig.mapper.DaOpcuaConfigMapper; import com.jcdm.main.da.opcuaconfig.service.IDaOpcuaConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; /** * OPCUAåæ°è®¾ç½®Serviceä¸å¡å±å¤ç * * @author yyt * @date 2023-12-22 */ @Service public class DaOpcuaConfigServiceImpl implements IDaOpcuaConfigService { @Autowired private DaOpcuaConfigMapper daOpcuaConfigMapper; /** * æ¥è¯¢OPCUAåæ°è®¾ç½® * * @param id OPCUAåæ°è®¾ç½®ä¸»é® * @return OPCUAåæ°è®¾ç½® */ @Override public DaOpcuaConfig selectDaOpcuaConfigById(Long id) { return daOpcuaConfigMapper.selectDaOpcuaConfigById(id); } /** * æ¥è¯¢OPCUAåæ°è®¾ç½®å表 * * @param daOpcuaConfig OPCUAåæ°è®¾ç½® * @return OPCUAåæ°è®¾ç½® */ @Override public List<DaOpcuaConfig> selectDaOpcuaConfigList(DaOpcuaConfig daOpcuaConfig) { return daOpcuaConfigMapper.selectDaOpcuaConfigList(daOpcuaConfig); } /** * æ°å¢OPCUAåæ°è®¾ç½® * * @param daOpcuaConfig OPCUAåæ°è®¾ç½® * @return ç»æ */ @Override public int insertDaOpcuaConfig(DaOpcuaConfig daOpcuaConfig) { return daOpcuaConfigMapper.insertDaOpcuaConfig(daOpcuaConfig); } /** * ä¿®æ¹OPCUAåæ°è®¾ç½® * * @param daOpcuaConfig OPCUAåæ°è®¾ç½® * @return ç»æ */ @Override public int updateDaOpcuaConfig(DaOpcuaConfig daOpcuaConfig) { return daOpcuaConfigMapper.updateDaOpcuaConfig(daOpcuaConfig); } /** * æ¹éå é¤OPCUAåæ°è®¾ç½® * * @param ids éè¦å é¤çOPCUAåæ°è®¾ç½®ä¸»é® * @return ç»æ */ @Override public int deleteDaOpcuaConfigByIds(Long[] ids) { return daOpcuaConfigMapper.deleteDaOpcuaConfigByIds(ids); } /** * å é¤OPCUAåæ°è®¾ç½®ä¿¡æ¯ * * @param id OPCUAåæ°è®¾ç½®ä¸»é® * @return ç»æ */ @Override public int deleteDaOpcuaConfigById(Long id) { return daOpcuaConfigMapper.deleteDaOpcuaConfigById(id); } } jcdm-main/src/main/resources/mapper/da/opcuaconfig/DaOpcuaConfigMapper.xml
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,97 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.jcdm.main.da.opcuaconfig.mapper.DaOpcuaConfigMapper"> <resultMap type="DaOpcuaConfig" id="DaOpcuaConfigResult"> <result property="id" column="id" /> <result property="module" column="module" /> <result property="node" column="node" /> <result property="length" column="length" /> <result property="sysTypes" column="sys_types" /> <result property="functionality" column="functionality" /> <result property="subscribe" column="subscribe" /> <result property="rModule" column="r_module" /> <result property="rFunction" column="r_function" /> <result property="remarks" column="remarks" /> </resultMap> <sql id="selectDaOpcuaConfigVo"> select id, module, node, length, sys_types, functionality, subscribe, r_module, r_function, remarks from da_opcua_config </sql> <select id="selectDaOpcuaConfigList" parameterType="DaOpcuaConfig" resultMap="DaOpcuaConfigResult"> <include refid="selectDaOpcuaConfigVo"/> <where> <if test="module != null and module != ''"> and module like concat('%', #{module}, '%')</if> <if test="node != null and node != ''"> and node like concat('%', #{node}, '%')</if> <if test="length != null "> and length = #{length}</if> <if test="sysTypes != null and sysTypes != ''"> and sys_types = #{sysTypes}</if> <if test="functionality != null and functionality != ''"> and functionality like concat('%', #{functionality}, '%')</if> <if test="subscribe != null "> and subscribe = #{subscribe}</if> <if test="rModule != null and rModule != ''"> and r_module like concat('%', #{rModule}, '%')</if> <if test="rFunction != null and rFunction != ''"> and r_function like concat('%', #{rFunction}, '%')</if> </where> </select> <select id="selectDaOpcuaConfigById" parameterType="Long" resultMap="DaOpcuaConfigResult"> <include refid="selectDaOpcuaConfigVo"/> where id = #{id} </select> <insert id="insertDaOpcuaConfig" parameterType="DaOpcuaConfig"> insert into da_opcua_config <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null">id,</if> <if test="module != null">module,</if> <if test="node != null">node,</if> <if test="length != null">length,</if> <if test="sysTypes != null">sys_types,</if> <if test="functionality != null">functionality,</if> <if test="subscribe != null">subscribe,</if> <if test="rModule != null">r_module,</if> <if test="rFunction != null">r_function,</if> <if test="remarks != null">remarks,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if> <if test="module != null">#{module},</if> <if test="node != null">#{node},</if> <if test="length != null">#{length},</if> <if test="sysTypes != null">#{sysTypes},</if> <if test="functionality != null">#{functionality},</if> <if test="subscribe != null">#{subscribe},</if> <if test="rModule != null">#{rModule},</if> <if test="rFunction != null">#{rFunction},</if> <if test="remarks != null">#{remarks},</if> </trim> </insert> <update id="updateDaOpcuaConfig" parameterType="DaOpcuaConfig"> update da_opcua_config <trim prefix="SET" suffixOverrides=","> <if test="module != null">module = #{module},</if> <if test="node != null">node = #{node},</if> <if test="length != null">length = #{length},</if> <if test="sysTypes != null">sys_types = #{sysTypes},</if> <if test="functionality != null">functionality = #{functionality},</if> <if test="subscribe != null">subscribe = #{subscribe},</if> <if test="rModule != null">r_module = #{rModule},</if> <if test="rFunction != null">r_function = #{rFunction},</if> <if test="remarks != null">remarks = #{remarks},</if> </trim> where id = #{id} </update> <delete id="deleteDaOpcuaConfigById" parameterType="Long"> delete from da_opcua_config where id = #{id} </delete> <delete id="deleteDaOpcuaConfigByIds" parameterType="String"> delete from da_opcua_config where id in <foreach item="id" collection="array" open="(" separator="," close=")"> #{id} </foreach> </delete> </mapper> jcdm-main/src/main/resources/opcua.properties
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,20 @@ #opcua server opcua.server.endpoint.url=opc.tcp://127.0.0.1:49320 opcua.server.idp.username= opcua.server.idp.password= #opcua client opcua.client.app.name=plc opcua.client.app.uri=urn:Yyt_PC:UnifiedAutomation:UaExpert opcua.client.cert.path=C:/mes/ opcua.client.cert.file=Yyt_PC-client.pfx opcua.client.cert.alias=jlclient-ai opcua.client.cert.common.name=UaClient@Jellyleo opcua.client.cert.organization=JL opcua.client.cert.organization.unit=per opcua.client.cert.locality.name=jl opcua.client.cert.state.name=JiangSu opcua.client.cert.country.code=CN opcua.client.cert.dns.name=Jellyleo opcua.client.cert.ip.address=administrator opcua.client.cert.keystore.password=yyt@8888888888