From 8069b5176a358fd4c730e34a4f30a781f1241c23 Mon Sep 17 00:00:00 2001 From: hdy <1105738590@qq.com> Date: 星期一, 08 七月 2024 16:00:30 +0800 Subject: [PATCH] cvt更新 --- jcdm-ui/src/views/main/kb/cvt/index.vue | 86 ++----- jcdm-main/pom.xml | 48 +-- jcdm-admin/src/main/resources/application.yml | 12 + jcdm-ui/src/api/main/da/opcuaconfig/opcuaconfig.js | 13 jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/controller/DaPassingStationCollectionController.java | 86 ++++-- jcdm-main/src/main/java/com/jcdm/main/plcserver/callback/InitCallback.java | 167 +++++++++++++++ /dev/null | 57 ----- jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/controller/DaOpcuaConfigController.java | 55 ++-- jcdm-ui/src/api/main/da/passingStationCollection/passingStationCollection.js | 8 jcdm-main/src/main/java/com/jcdm/main/plcserver/init/CustomRunner.java | 63 +++++ jcdm-admin/src/main/resources/application-druid.yml | 2 jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java | 8 jcdm-ui/vue.config.js | 2 13 files changed, 389 insertions(+), 218 deletions(-) diff --git a/jcdm-admin/src/main/resources/application-druid.yml b/jcdm-admin/src/main/resources/application-druid.yml index 50199ca..7390f33 100644 --- a/jcdm-admin/src/main/resources/application-druid.yml +++ b/jcdm-admin/src/main/resources/application-druid.yml @@ -22,7 +22,7 @@ master: url: jdbc:sqlserver://127.0.0.1:1433;DataBaseName=Jcdm041-MesCVT username: sa - password: sam@123456 + password: 123456 # master: # url: jdbc:sqlserver://127.0.0.1:1433;DataBaseName=Jcdm041-Mes # username: dt diff --git a/jcdm-admin/src/main/resources/application.yml b/jcdm-admin/src/main/resources/application.yml index 07f8ac5..a12dab1 100644 --- a/jcdm-admin/src/main/resources/application.yml +++ b/jcdm-admin/src/main/resources/application.yml @@ -18,7 +18,7 @@ # 寮�鍙戠幆澧冮厤缃� server: # 鏈嶅姟鍣ㄧ殑HTTP绔彛锛岄粯璁や负8080 - port: 8081 + port: 8082 servlet: # 搴旂敤鐨勮闂矾寰� context-path: / @@ -130,3 +130,13 @@ excludes: /system/notice # 鍖归厤閾炬帴 urlPatterns: /system/*,/monitor/*,/tool/* + +kangaroohy: + milo: + primary: default + config: + default: + endpoint: opc.tcp://127.0.0.1:49320 + security-policy: none +websocketUrl: 'ws://10.10.14.54:8081/websocket/' + diff --git a/jcdm-main/pom.xml b/jcdm-main/pom.xml index 80cbe95..519e0ee 100644 --- a/jcdm-main/pom.xml +++ b/jcdm-main/pom.xml @@ -37,37 +37,7 @@ </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> @@ -105,6 +75,24 @@ <groupId>com.jcdm</groupId> <artifactId>jcdm-system</artifactId> </dependency> + + <dependency> + <groupId>com.kangaroohy</groupId> + <artifactId>milo-spring-boot-starter</artifactId> + <version>3.0.5</version> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-websocket</artifactId> + </dependency> + + <dependency> + <groupId>com.alibaba</groupId> + <artifactId>fastjson</artifactId> + <version>2.0.22</version> + </dependency> + </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 023100c..0000000 --- a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/MethodName.java +++ /dev/null @@ -1,225 +0,0 @@ -package com.jcdm.main.da.opcuaconfig.cert; - -import cn.hutool.core.date.StopWatch; -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 java.time.Duration; -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); - private IDaParamCollectionService daParamCollectionService = BeanUtils.getBean(IDaParamCollectionService.class); - private IDaPassingStationCollectionService daPassingStationCollectionService = BeanUtils.getBean(IDaPassingStationCollectionService.class); - public void Transit(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]+".MesRecordDataDone").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]+".MesRecordDataDone").value("11").type("short").build(); - Boolean out1=clientHandler.write(node1); - log.info("鑺傜偣:{},鍝嶅簲缁撴灉:{}", node1.getIdentifier(),out1); - break; - case "2": //璇锋眰璁板綍宸ヤ綅鏁版嵁 - NodeEntity SN_node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".SNCode").value("").type("").build(); - String SNCode=clientHandler.read(SN_node); - if(SNCode==null){ - NodeEntity node2= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("22").type("short").build(); - Boolean out2=clientHandler.write(node2); - break; - } - List<DaCollectionParamConf> b; - DaCollectionParamConf daCollectionParamConf=new DaCollectionParamConf(); - daCollectionParamConf.setGatherAddress(parts[0]+"."+parts[1]); - b=collectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf); - if(b!=null&&b.size()>0){ - 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閲囬泦鏁版嵁 -// StopWatch stopWatch = new StopWatch(); -// stopWatch.start(); - List<DaParamCollection> ParamCollectionlist = new ArrayList<>(); - for(int i=0;i<nodeId.size();i++){ - DaParamCollection ParamCollection = new DaParamCollection(); - ParamCollection.setParamCode(nodeId.get(i).getIdentifier().toString().split("[.]")[2]); - ParamCollection.setLocationCode(nodeId.get(i).getIdentifier().toString().split("[.]")[1]); - ParamCollection.setParamValue(s.get(i).getValue().getValue().toString()); - ParamCollection.setSfcCode(SNCode); - ParamCollection.setParamName(b.get(i).getGatherAddress()); - ParamCollectionlist.add(ParamCollection); - } - daParamCollectionService.saveBeachDaParamCollection(ParamCollectionlist); -// stopWatch.stop(); -// System.out.println("浣跨敤sqlSessionFactory瀹炵幇鎵归噺鎻掑叆鑰楁椂锛�" + stopWatch.getTotalTimeMillis()); - } - //璁板綍杩囩珯锛屽苟璁$畻鑺傛媿銆� - DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); - PassingStationCollection.setSfcCode(SNCode); - PassingStationCollection.setLocationCode(parts[1]); - PassingStationCollection.setInboundTime(new Date()); - PassingStationCollection.setOutboundTime(new Date()); - PassingStationCollection.setCollectionTime(new Date()); - PassingStationCollection.setBeatTime("56"); - daPassingStationCollectionService.insertDaPassingStationCollection(PassingStationCollection); - //鏇存柊PLC鑺傜偣鐘舵�� - NodeEntity node2= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("21").type("short").build(); - Boolean out2=clientHandler.write(node2); - log.info("鑺傜偣:{},鍝嶅簲缁撴灉:{}", node2.getIdentifier(),out2); - break; - default: - break; - } - } - - public void Transit2(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]+".MesRecordDataDone").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]+".MesRecordDataDone").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); - 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]+".MesRecordDataDone").value("21").type("short").build(); - Boolean out2=clientHandler.write(node2); - log.info("鑺傜偣:{},鍝嶅簲缁撴灉:{}", node2.getIdentifier(),out2); - break; - default: - break; - } - } - - public void SNRetrieval(String Node, String value) throws Exception { - String[] parts = Node.split("[.]"); - if(value=="1") { - //SN鍙锋绱� - 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); - - String a=daPassingStationCollectionService.SelectSN(SNCode); - - // 1:OK鍙敓浜� 2:NG涓嶅彲鐢熶骇 3:NG鍙繑宸� 4:PC妫�绱㈠け璐ワ紙鏃犺褰曪級5:PC妫�绱㈠け璐ワ紙杞欢锛� - NodeEntity node1= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".CodeCheckFeed").value(a).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); - } - } - public void SaveData(String Node, String value) throws Exception { - String[] parts = Node.split("[.]"); - if(value=="1") { - //閲囬泦鏁版嵁鏈�缁堜繚瀛� - 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); - 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)); - } - //璇锋眰鏈�缁堜繚瀛樺弽棣�:1 淇濆瓨瀹屾垚 2 淇濆瓨澶辫触 3 淇濆瓨澶辫触锛屾暟鎹綅瓒呴暱 - NodeEntity node1= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".SaveFeedLast").value("1").type("short").build(); - Boolean out1=clientHandler.write(node1); - } - } -} 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 fc78ab0..0000000 --- a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/client/ClientHandler.java +++ /dev/null @@ -1,304 +0,0 @@ -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("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 }); - if (value.isNull()){ - method.invoke(clazz.newInstance(),new Object[] { - new String(id.getIdentifier().toString()), new String("") }); - }else{ - 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(); - - if(null == variant.getValue()) - { - return null; - }else{ - 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/controller/DaOpcuaConfigController.java b/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/controller/DaOpcuaConfigController.java index fc65d8f..41a90a9 100644 --- a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/controller/DaOpcuaConfigController.java +++ b/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/controller/DaOpcuaConfigController.java @@ -3,7 +3,7 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; -import com.jcdm.main.da.opcuaconfig.client.ClientHandler; +//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; @@ -32,8 +32,7 @@ */ @RestController @RequestMapping("/da/opcuaconfig") -public class DaOpcuaConfigController extends BaseController -{ +public class DaOpcuaConfigController extends BaseController { @Autowired private IDaOpcuaConfigService daOpcuaConfigService; @@ -42,8 +41,7 @@ */ @PreAuthorize("@ss.hasPermi('da:opcuaconfig:list')") @GetMapping("/list") - public TableDataInfo list(DaOpcuaConfig daOpcuaConfig) - { + public TableDataInfo list(DaOpcuaConfig daOpcuaConfig) { startPage(); List<DaOpcuaConfig> list = daOpcuaConfigService.selectDaOpcuaConfigList(daOpcuaConfig); return getDataTable(list); @@ -55,8 +53,7 @@ @PreAuthorize("@ss.hasPermi('da:opcuaconfig:export')") @Log(title = "浜や簰淇″彿閰嶇疆", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, DaOpcuaConfig daOpcuaConfig) - { + 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, "浜や簰淇″彿閰嶇疆鏁版嵁"); @@ -67,8 +64,7 @@ */ @PreAuthorize("@ss.hasPermi('da:opcuaconfig:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { + public AjaxResult getInfo(@PathVariable("id") Long id) { return success(daOpcuaConfigService.selectDaOpcuaConfigById(id)); } @@ -78,8 +74,7 @@ @PreAuthorize("@ss.hasPermi('da:opcuaconfig:add')") @Log(title = "浜や簰淇″彿閰嶇疆", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody DaOpcuaConfig daOpcuaConfig) - { + public AjaxResult add(@RequestBody DaOpcuaConfig daOpcuaConfig) { return toAjax(daOpcuaConfigService.insertDaOpcuaConfig(daOpcuaConfig)); } @@ -89,8 +84,7 @@ @PreAuthorize("@ss.hasPermi('da:opcuaconfig:edit')") @Log(title = "浜や簰淇″彿閰嶇疆", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody DaOpcuaConfig daOpcuaConfig) - { + public AjaxResult edit(@RequestBody DaOpcuaConfig daOpcuaConfig) { return toAjax(daOpcuaConfigService.updateDaOpcuaConfig(daOpcuaConfig)); } @@ -99,26 +93,25 @@ */ @PreAuthorize("@ss.hasPermi('da:opcuaconfig:remove')") @Log(title = "浜や簰淇″彿閰嶇疆", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(daOpcuaConfigService.deleteDaOpcuaConfigByIds(ids)); } - +} /** * 鑾峰彇浜や簰淇″彿閰嶇疆璇︾粏淇℃伅 */ - @PreAuthorize("@ss.hasPermi('da:opcuaconfig:query')") - @GetMapping(value = "/SNCode/{SNCode}/{locationCode}") - public AjaxResult setSNCode(@PathVariable("SNCode") String SNCode,@PathVariable("locationCode") String locationCode) { - NodeEntity node= NodeEntity.builder().index(2).identifier("CFL4CVT"+"."+locationCode+".MesSNCode").value(SNCode).type("string").build(); - Boolean out= null; - try { - out = ClientHandler.write(node); - } catch (Exception e) { - throw new RuntimeException(e); - } - - return toAjax(out); - } -} +// @PreAuthorize("@ss.hasPermi('da:opcuaconfig:query')") +// @GetMapping(value = "/SNCode/{SNCode}/{locationCode}") +// public AjaxResult setSNCode(@PathVariable("SNCode") String SNCode,@PathVariable("locationCode") String locationCode) { +// NodeEntity node= NodeEntity.builder().index(2).identifier("CFL4CVT"+"."+locationCode+".MesSNCode").value(SNCode).type("string").build(); +// Boolean out= null; +// try { +// out = ClientHandler.write(node); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// +// return toAjax(out); +// } +//} diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/BeanUtils.java b/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/BeanUtils.java deleted file mode 100644 index b61e3b5..0000000 --- a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/BeanUtils.java +++ /dev/null @@ -1,30 +0,0 @@ -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); - } -} 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 c836a15..0000000 --- a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/OpcusConfigInit.java +++ /dev/null @@ -1,47 +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"); //璁剧疆鏌ヨ鏉′欢锛岃闃呯姸鎬佺殑鎵�鏈夋暟鎹�. - daOpcuaConfig.setState(Long.valueOf("0")); //璁剧疆鏌ヨ鏉′欢锛屾甯哥姸鎬�. - 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("OPCUA鍒濆鍖栨垚鍔燂紝骞跺畬鎴�"+ nodeslist.size() +"涓妭鐐硅闃�"); - } catch (Exception e) { - e.printStackTrace(); - log.info("绯荤粺鎻愮ず锛孫PCUA璁㈤槄澶辫触锛�"); - } - } -} diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/Properties.java b/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/Properties.java deleted file mode 100644 index fc06c6b..0000000 --- a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/init/Properties.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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; -} diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/controller/DaPassingStationCollectionController.java b/jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/controller/DaPassingStationCollectionController.java index 8405255..029e9f8 100644 --- a/jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/controller/DaPassingStationCollectionController.java +++ b/jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/controller/DaPassingStationCollectionController.java @@ -1,30 +1,28 @@ package com.jcdm.main.da.passingStationCollection.controller; +import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.jcdm.common.core.domain.R; import com.jcdm.common.utils.DateUtils; import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling; +import com.jcdm.main.da.paramCollection.domain.DaParamCollection; import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; import com.jcdm.main.da.passingStationCollection.vo.DaPassingStationVO; +import com.kangaroohy.milo.model.ReadWriteEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.jcdm.common.annotation.Log; import com.jcdm.common.core.controller.BaseController; import com.jcdm.common.core.domain.AjaxResult; import com.jcdm.common.enums.BusinessType; import com.jcdm.common.utils.poi.ExcelUtil; import com.jcdm.common.core.page.TableDataInfo; + +import static com.jcdm.main.plcserver.callback.InitCallback.miloService; /** * 浜у搧杩囩珯閲囬泦Controller @@ -34,8 +32,7 @@ */ @RestController @RequestMapping("/da/passingStationCollection") -public class DaPassingStationCollectionController extends BaseController -{ +public class DaPassingStationCollectionController extends BaseController { @Autowired private IDaPassingStationCollectionService daPassingStationCollectionService; @@ -44,8 +41,7 @@ */ @PreAuthorize("@ss.hasPermi('da:passingStationCollection:list')") @GetMapping("/list") - public TableDataInfo list(DaPassingStationCollection daPassingStationCollection) - { + public TableDataInfo list(DaPassingStationCollection daPassingStationCollection) { startPage(); List<DaPassingStationCollection> list = daPassingStationCollectionService.selectDaPassingStationCollectionList(daPassingStationCollection); return getDataTable(list); @@ -53,27 +49,25 @@ @PreAuthorize("@ss.hasPermi('da:passingStationCollection:list')") @GetMapping("/getTopProcess") - public TableDataInfo getTopProcess() - { + public TableDataInfo getTopProcess() { DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); List<DaPassingStationVO> list = daPassingStationCollectionService.getTopProcess(daPassingStationCollection); return getDataTable(list); } + /** * 鏌ヨ浜у搧杩囩珯閲囬泦鍒楄〃 */ @PreAuthorize("@ss.hasPermi('da:passingStationCollection:list')") @GetMapping("/noPageList") - public TableDataInfo noPageList(DaPassingStationCollection daPassingStationCollection) - { + public TableDataInfo noPageList(DaPassingStationCollection daPassingStationCollection) { List<DaPassingStationCollection> list = daPassingStationCollectionService.selectDaPassingStationCollectionList(daPassingStationCollection); return getDataTable(list); } @PreAuthorize("@ss.hasPermi('da:passingStationCollection:list')") @GetMapping("/getProduceNumToday") - public R getProduceNumToday(String fieldName) - { + public R getProduceNumToday(String fieldName) { Integer num = daPassingStationCollectionService.getProduceNumToday(fieldName); return R.ok(num); } @@ -82,8 +76,7 @@ * 鏌ヨ浜у搧杩囩珯閲囬泦鍒楄〃 */ @GetMapping("/insertRepairRecordByIds") - public AjaxResult insertRepairRecordByIds(DaPassingStationCollection daPassingStationCollection) - { + public AjaxResult insertRepairRecordByIds(DaPassingStationCollection daPassingStationCollection) { daPassingStationCollectionService.insertRepairRecordByIds(daPassingStationCollection); return AjaxResult.success(); } @@ -94,8 +87,7 @@ @PreAuthorize("@ss.hasPermi('da:passingStationCollection:export')") @Log(title = "浜у搧杩囩珯閲囬泦", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, DaPassingStationCollection daPassingStationCollection) - { + public void export(HttpServletResponse response, DaPassingStationCollection daPassingStationCollection) { List<DaPassingStationCollection> list = daPassingStationCollectionService.selectDaPassingStationCollectionList(daPassingStationCollection); ExcelUtil<DaPassingStationCollection> util = new ExcelUtil<DaPassingStationCollection>(DaPassingStationCollection.class); util.exportExcel(response, list, "浜у搧杩囩珯閲囬泦鏁版嵁"); @@ -106,8 +98,7 @@ */ @PreAuthorize("@ss.hasPermi('da:passingStationCollection:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { + public AjaxResult getInfo(@PathVariable("id") Long id) { return success(daPassingStationCollectionService.selectDaPassingStationCollectionById(id)); } @@ -117,8 +108,7 @@ @PreAuthorize("@ss.hasPermi('da:passingStationCollection:add')") @Log(title = "浜у搧杩囩珯閲囬泦", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody DaPassingStationCollection daPassingStationCollection) - { + public AjaxResult add(@RequestBody DaPassingStationCollection daPassingStationCollection) { daPassingStationCollection.setCreateBy(getUsername()); daPassingStationCollection.setCreateTime(DateUtils.getNowDate()); return toAjax(daPassingStationCollectionService.insertDaPassingStationCollection(daPassingStationCollection)); @@ -130,8 +120,7 @@ @PreAuthorize("@ss.hasPermi('da:passingStationCollection:edit')") @Log(title = "浜у搧杩囩珯閲囬泦", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody DaPassingStationCollection daPassingStationCollection) - { + public AjaxResult edit(@RequestBody DaPassingStationCollection daPassingStationCollection) { daPassingStationCollection.setUpdateBy(getUsername()); daPassingStationCollection.setUpdateTime(DateUtils.getNowDate()); return toAjax(daPassingStationCollectionService.updateDaPassingStationCollection(daPassingStationCollection)); @@ -142,9 +131,42 @@ */ @PreAuthorize("@ss.hasPermi('da:passingStationCollection:remove')") @Log(title = "浜у搧杩囩珯閲囬泦", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(daPassingStationCollectionService.deleteDaPassingStationCollectionByIds(ids)); } -} + + +// @PreAuthorize("@ss.hasPermi('da:passingStationCollection:query')") +// @Log(title = "浜у搧杩囩珯閲囬泦", businessType = BusinessType.INSERT) +// @GetMapping(value = "/addPassing") +// public R addPassing(String sfcCode,String locationCode) { +// +// DaPassingStationCollection saveData = new DaPassingStationCollection(); +// saveData.setSfcCode(sfcCode); +// saveData.setLocationCode(locationCode); +// saveData.setCollectionTime(new Date()); +// daPassingStationCollectionService.insertDaPassingStationCollection(saveData); +// +// return R.ok(); +// +// } + + + @GetMapping("/initializedData") + public AjaxResult initializedData(@RequestParam String sfcCode, @RequestParam String locationCode) { + + try { + String nodeId = "CFL4CVT." + locationCode + ".MesSNCode"; + ReadWriteEntity entity = new ReadWriteEntity(nodeId, sfcCode); + miloService.writeToOpcUa(entity); + String SaveSNCode ="CFL4CVT." + locationCode + ".SaveSNCode"; + ReadWriteEntity SaveSNCodeEntity = new ReadWriteEntity(SaveSNCode, 11); + miloService.writeToOpcUa(SaveSNCodeEntity); + return AjaxResult.success("SFC Code updated successfully"); + } catch (Exception e) { + throw new RuntimeException("Failed to update SFC Code in OPC UA", e); + } + } + +} \ No newline at end of file diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/callback/InitCallback.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/callback/InitCallback.java new file mode 100644 index 0000000..d7a6c53 --- /dev/null +++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/callback/InitCallback.java @@ -0,0 +1,167 @@ +package com.jcdm.main.plcserver.callback; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.jcdm.common.core.domain.BaseEntity; +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.service.impl.DaPassingStationCollectionServiceImpl; +import com.jcdm.main.da.tileMatchRules.service.IDaTileMatchRulesService; +import com.kangaroohy.milo.model.ReadWriteEntity; +import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; +import com.kangaroohy.milo.service.MiloService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +@Slf4j +@Component +public class InitCallback implements SubscriptionCallback { + + public static MiloService miloService; + + public IDaCollectionParamConfService collectionParamConfService; + + public IDaParamCollectionService daParamCollectionService; + + public DaPassingStationCollectionServiceImpl passingStationCollectionServiceImpl; + + public IDaTileMatchRulesService daTileMatchRulesService; + ; + + public InitCallback(MiloService miloService, + IDaCollectionParamConfService collectionParamConfService, + IDaParamCollectionService daParamCollectionService, + DaPassingStationCollectionServiceImpl passingStationCollectionServiceImpl, + IDaTileMatchRulesService daTileMatchRulesService) { + InitCallback.miloService = miloService; + this.collectionParamConfService = collectionParamConfService; + this.daParamCollectionService = daParamCollectionService; + this.passingStationCollectionServiceImpl = passingStationCollectionServiceImpl; + this.daTileMatchRulesService = daTileMatchRulesService; + + } + + + @Override + public void onSubscribe(String identifier, Object value) { + String ecpStr = "";//寮傚父璁板綍鏍囪 + try { + if (null != value) { + //BCOP40杩涚珯鏍¢獙 + if (identifier.equals("CFL4CVT.BCOP040.RecordData") && null != value && "1".equals(value.toString())) { + //寰呮坊鍔犱粠杩囩珯閲囬泦琛ㄥ彇sfc_code鍐欏叆plc鐨剆ncode鏂规硶 + ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP040.MesRecordDataDone", 11); + miloService.writeToOpcByte(entity); + } + //BCOP40鍑虹珯鏍¢獙 + else if (identifier.equals("CFL4CVT.BCOP040.RecordData") && null != value && "2".equals(value.toString())) { + SaveData("CFL4CVT.BCOP40.RecordData"); + ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP040.MesRecordDataDone", 21); + miloService.writeToOpcByte(entity); + } + //BCOP60杩涚珯鏍¢獙 + else if (identifier.equals("CFL4CVT.BCOP060.RecordData") && null != value && "1".equals(value.toString())) { + //寰呮坊鍔犱粠杩囩珯閲囬泦琛ㄥ彇sfc_code鍐欏叆plc鐨剆ncode鏂规硶 + ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP060.MesRecordDataDone", 11); + miloService.writeToOpcByte(entity); + } + //BCOP60鍑虹珯鏍¢獙 + else if (identifier.equals("CFL4CVT.BCOP060.RecordData") && null != value && "2".equals(value.toString())) { + SaveData("CFL4CVT.BCOP060.RecordData"); + ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP060.MesRecordDataDone", 21); + miloService.writeToOpcByte(entity); + } + //BCOP100杩涚珯鏍¢獙 + else if (identifier.equals("CFL4CVT.BCOP100.RecordData") && null != value && "1".equals(value.toString())) { + //寰呮坊鍔犱粠杩囩珯閲囬泦琛ㄥ彇sfc_code鍐欏叆plc鐨剆ncode鏂规硶 + ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP100.MesRecordDataDone", 11); + miloService.writeToOpcByte(entity); + } + //BCOP100鍑虹珯鏍¢獙 + else if (identifier.equals("CFL4CVT.BCOP100.RecordData") && null != value && "2".equals(value.toString())) { + SaveData("CFL4CVT.BCOP100.RecordData"); + ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP100.MesRecordDataDone", 21); + miloService.writeToOpcByte(entity); + }//BP020杩涚珯鏍¢獙 + else if (identifier.equals("CFL4CVT.BP020.RecordData") && null != value && "1".equals(value.toString())) { + //寰呮坊鍔犱粠杩囩珯閲囬泦琛ㄥ彇sfc_code鍐欏叆plc鐨剆ncode鏂规硶 + ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BP020.MesRecordDataDone", 11); + miloService.writeToOpcByte(entity); + } + //BP020鍑虹珯鏍¢獙 + else if (identifier.equals("CFL4CVT.BP020.RecordData") && null != value && "2".equals(value.toString())) { + SaveData("CFL4CVT.BP020.RecordData"); + ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BP020.MesRecordDataDone", 21); + miloService.writeToOpcByte(entity); + + } + + } + } catch (Exception e) { + + } finally { + if (!"".equals(ecpStr)) { + System.out.println(ecpStr + "\r\n"); + + } + } + } + + public void SaveData(String Node) throws Exception { + String[] parts = Node.split("[.]"); + Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code1").getValue(); + + if (null != SNCodeObject) { + String SNCode = SNCodeObject.toString(); + List<DaCollectionParamConf> list; + DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); + daCollectionParamConf.setGatherAddress(parts[0] + "." + parts[1]); + 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(parts[1]); + Object value = readWriteEntityList.get(i).getValue(); + if (ObjectUtils.isNotEmpty(value)) { + String string = value.toString(); + ParamCollection.setParamValue(string); + } + 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); + } + } + } + + + public void WriteSNCode(String Node) throws Exception { + + + } +} \ No newline at end of file diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/init/CustomRunner.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/init/CustomRunner.java new file mode 100644 index 0000000..959a992 --- /dev/null +++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/init/CustomRunner.java @@ -0,0 +1,63 @@ +package com.jcdm.main.plcserver.init; + + +import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; +import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; +import com.jcdm.main.da.passingStationCollection.service.impl.DaPassingStationCollectionServiceImpl; +import com.jcdm.main.da.tileMatchRules.service.IDaTileMatchRulesService; +import com.jcdm.main.plcserver.callback.InitCallback; +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 javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@Component +public class CustomRunner implements ApplicationRunner { + + @Autowired + public MiloService miloService; + + @Autowired + public IDaCollectionParamConfService collectionParamConfService; + + @Autowired + public IDaParamCollectionService daParamCollectionService; + + @Resource + private DaPassingStationCollectionServiceImpl passingStationCollectionServiceImpl; + + + @Resource + private IDaTileMatchRulesService daTileMatchRulesService; + + @Override + public void run(ApplicationArguments args) throws Exception { + + InitCallback InitCallback = new InitCallback(miloService, + collectionParamConfService, + daParamCollectionService, + passingStationCollectionServiceImpl, + daTileMatchRulesService); + + List<String> lists = getList(); + miloService.subscriptionFromOpcUa(lists,InitCallback); + + } + + public List<String> getList(){ + List<String> lists = new ArrayList<>(); + lists.add("CFL4CVT.BCOP010.RecordData");//璇锋眰淇濆瓨 + lists.add("CFL4CVT.BCOP040.RecordData");//璇锋眰淇濆瓨 + lists.add("CFL4CVT.BCOP060.RecordData");//璇锋眰淇濆瓨 + lists.add("CFL4CVT.BCOP100.RecordData");//璇锋眰淇濆瓨 + lists.add("CFL4CVT.BP020.RecordData");//璇锋眰淇濆瓨 + + return lists; + } +} + diff --git a/jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java b/jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java index 3064159..dfc952a 100644 --- a/jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java +++ b/jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java @@ -8,7 +8,7 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; -import com.jcdm.main.da.opcuaconfig.init.BeanUtils; + import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; import com.jcdm.main.om.workReport.service.IOmWorkReportService; @@ -32,9 +32,9 @@ import java.util.List; public class ReceivingServices { - @Autowired + // private static IOmProductionOrdeInfoService omProductionOrdeInfoService; - private static IOmProductionOrdeInfoService omProductionOrdeInfoService = BeanUtils.getBean(IOmProductionOrdeInfoService.class); + public static final String ProductionPlanInformationUrl = "http://podqapp.cfmoto.com.cn:50200/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_MES_005_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES"; @@ -122,7 +122,7 @@ ordeInfo.setCreateUser(item.getZUSER()); //ordeInfo.setCreateTime(item.getZDATE()); ordeInfo.setDemandDate(item.getGSTRP());//寮�宸ユ棩鏈� - omProductionOrdeInfoService.insertOmProductionOrdeInfo(ordeInfo); +// omProductionOrdeInfoService.insertOmProductionOrdeInfo(ordeInfo); } } diff --git a/jcdm-ui/src/api/main/da/opcuaconfig/opcuaconfig.js b/jcdm-ui/src/api/main/da/opcuaconfig/opcuaconfig.js index 548cecc..4255a33 100644 --- a/jcdm-ui/src/api/main/da/opcuaconfig/opcuaconfig.js +++ b/jcdm-ui/src/api/main/da/opcuaconfig/opcuaconfig.js @@ -18,12 +18,13 @@ } // 鏌ヨ浜や簰淇″彿閰嶇疆璇︾粏 -export function setSNCode(SNCode,locationCode) { - return request({ - url: '/da/opcuaconfig/SNCode/' + SNCode+'/'+locationCode, - method: 'get' - }) -} +// export function SNCode(param) { +// return request({ +// url: '/da/opcuaconfig/SNCode', +// method: 'get', +// params: param +// }) +// } // 鏂板浜や簰淇″彿閰嶇疆 export function addOpcuaconfig(data) { diff --git a/jcdm-ui/src/api/main/da/passingStationCollection/passingStationCollection.js b/jcdm-ui/src/api/main/da/passingStationCollection/passingStationCollection.js index 12110e3..af05118 100644 --- a/jcdm-ui/src/api/main/da/passingStationCollection/passingStationCollection.js +++ b/jcdm-ui/src/api/main/da/passingStationCollection/passingStationCollection.js @@ -75,3 +75,11 @@ method: 'delete' }) } + +export function initializedData(query) { + return request({ + url: '/da/passingStationCollection/', + method: 'get', + params: query + }) +} diff --git a/jcdm-ui/src/views/main/kb/cvt/index.vue b/jcdm-ui/src/views/main/kb/cvt/index.vue index 46f132d..25bb022 100644 --- a/jcdm-ui/src/views/main/kb/cvt/index.vue +++ b/jcdm-ui/src/views/main/kb/cvt/index.vue @@ -79,9 +79,8 @@ <script> import { listOrderScheduling, getOrderScheduling, delOrderScheduling, addOrderScheduling, updateOrderScheduling } from "@/api/main/bs/orderScheduling/orderScheduling"; -import { listPassingStationCollection, getPassingStationCollection, delPassingStationCollection, addPassingStationCollection, updatePassingStationCollection } from "@/api/main/da/passingStationCollection/passingStationCollection"; +import {listPassingStationCollection, getPassingStationCollection, delPassingStationCollection, addPassingStationCollection, updatePassingStationCollection,initializedData } from "@/api/main/da/passingStationCollection/passingStationCollection"; import {listLineInfo} from "@/api/main/bs/lineInfo/lineInfo"; -import {setSNCode} from "@/api/main/da/opcuaconfig/opcuaconfig"; import {getIp, listStationConf} from "@/api/main/sc/stationConf"; export default { @@ -95,7 +94,7 @@ engineCheckList:[], showFlag:false, buttondisabled:true, - locationCode: "鏈厤缃�", + locationCode: "鏈厤缃伐浣�", locationName: "鏈厤缃伐浣�", scannerFlag: false, @@ -160,7 +159,13 @@ this.scannerFlag = true console.log("鏉$爜锛�",this.form.engineNo) if(this.form.engineNo !== null && this.form.engineNo !== undefined) { - setSNCode(this.form.engineNo, this.locationCode) + addPassingStationCollection({sfcCode:this.form.engineNo,locationCode:this.locationCode}).then(res =>{ + console.log("rrrrr",res) + }) + if(this.locationCode === 'BCOP040'|| this.locationCode === 'BCOP060'|| this.locationCode === 'BCOP100'|| this.locationCode === 'BP020' ){ + initializedData({sfcCode:this.form.engineNo,locationCode:this.locationCode}).then(res =>{ + }) + } }else{ this.reset(); this.buttondisabled = true @@ -175,9 +180,30 @@ offset:300 }); } + } + // this.AddEngineNo(); }, + handleScannerInput111(event){ + const param = { + sfcCode: this.from.engineNo, + } + addPassingStationCollection(param).then(response => { + }); + }, + + + // AddEngineNo(){ + // const param = { + // locationCode: this.from.locationCode, + // sfcCode: this.from.engineNo, + // // locationCode:"OP110", + // // sfcCode:"666", + // + // } + // addPassingStationCollection(param).then(response =>{}); + // }, getStationConf() { getIp().then(response => { @@ -207,52 +233,7 @@ EngineNohandleChange(){ console.log('鏉$爜锛�',this.form.engineNo) if(this.form.engineNo !== null && this.form.engineNo !== undefined){ - //let OrderSchedulingParam = {engineNo: null} setSNCode(this.form.engineNo,this.locationCode) - //OrderSchedulingParam.engineNo = this.form.engineNo; - /* listOrderScheduling(OrderSchedulingParam).then(response => { - if(response.total === 1 ){ - this.form.productType = response.rows[0].model - this.form.orderNo = response.rows[0].orderNo - this.form.qualityStatus = response.rows[0].qualityStatus - this.form.currentWorkstation = response.rows[0].currentWorkstation - this.form.add= response.rows[0].currentWorkstation+ response.rows[0].qualityStatus - if(this.form.qualityStatus ==='涓嶅悎鏍�'){ - this.buttondisabled = false; - } - else{ - this.buttondisabled = true; - } - } - else{ - this.reset(); - this.buttondisabled = true - const h = this.$createElement; - this.$message({ - message: h('p',null, [ - h('span', null, '璀﹀憡 '), - h('i', { style: 'color: black' }, '杈撳叆鐨勫彂鍔ㄦ満鍙锋湁璇�'), - h()]), - type: 'error', - center: true, - offset:300 - }); - } - });*/ - /*let PassingStationCollectionParam = {sfcCode: null} - PassingStationCollectionParam.sfcCode = this.form.engineNo; - listPassingStationCollection(PassingStationCollectionParam).then(ponse =>{ - this.engineCheckList = ponse.rows.locationCode ; - if(ponse.rows.length >= 1 && this.form.engineNo !== undefined){ - this.form.engineCheckList = '' - for (let i = 0; i < ponse.rows.length; i++) { - this.form.engineCheckList += ' 宸ヤ綅:'+ ponse.rows[i].locationCode+'['+ponse.rows[i].outRsSign+']' - } - } - else{ - this.form.engineCheckList = '鏆傛棤鏁版嵁' - } - });*/ } }, @@ -282,10 +263,5 @@ justify-content: center; margin-top: 5px } -/*.my-custom-modal .el-dialog__wrapper {*/ -/* width: 400px; !* 璁剧疆瀹藉害 *!*/ -/* height: 200px; !* 璁剧疆楂樺害 *!*/ -/* top: 50px; !* 璁剧疆璺濈椤甸潰椤堕儴鐨勪綅缃� *!*/ -/* left: 50px; !* 璁剧疆璺濈椤甸潰宸︿晶鐨勪綅缃� *!*/ -/*}*/ + </style> diff --git a/jcdm-ui/vue.config.js b/jcdm-ui/vue.config.js index f0c5690..f701d8a 100644 --- a/jcdm-ui/vue.config.js +++ b/jcdm-ui/vue.config.js @@ -34,7 +34,7 @@ open: true, proxy: { [process.env.VUE_APP_BASE_API]: { - target: `http://localhost:8081`, + target: `http://localhost:8082`, changeOrigin: true, pathRewrite: { ['^' + process.env.VUE_APP_BASE_API]: '' -- Gitblit v1.9.3