From ae2d52827d289dd985014a63c08b0913d083b215 Mon Sep 17 00:00:00 2001 From: bsw215583320 <baoshiwei121@163.com> Date: 星期二, 09 四月 2024 08:48:38 +0800 Subject: [PATCH] 去掉opc相关业务 --- jeecg-module-dry/jeecg-module-dry-api/pom.xml | 10 jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/api/JeecgSystemApi.java | 18 jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/runner/OpcCustomRunner.java | 116 ++-- jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/OpcController.java | 132 ++-- jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/listener/InitListener.java | 9 jeecg-server-cloud/jeecg-cloud-nacos/src/main/resources/application.yml | 2 jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryOpcDeviceController.java | 410 +++++++------- jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/api/fallback/JeecgSystemFallback.java | 25 jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/util/HerbUtil.java | 340 +++++----- jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryRealTimeDataController.java | 82 +- jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/websocket/DrySocket1.java | 223 +++++++ jeecg-server-cloud/jeecg-cloud-gateway/src/main/resources/application.yml | 4 jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/common/OPCUA.java | 273 +++++++++ jeecg-module-dry/jeecg-module-dry-start/src/main/test/java/com/lanbao/AiTest.java | 54 14 files changed, 1,114 insertions(+), 584 deletions(-) diff --git a/jeecg-module-dry/jeecg-module-dry-api/pom.xml b/jeecg-module-dry/jeecg-module-dry-api/pom.xml index 8bce88b..fd4d4a0 100644 --- a/jeecg-module-dry/jeecg-module-dry-api/pom.xml +++ b/jeecg-module-dry/jeecg-module-dry-api/pom.xml @@ -42,11 +42,11 @@ <!-- <artifactId>bcprov-jdk15on</artifactId>--> <!-- <version>1.70</version>--> <!-- </dependency>--> - <dependency> - <groupId>com.kangaroohy</groupId> - <artifactId>milo-spring-boot-starter</artifactId> - <version>3.0.4</version> - </dependency> +<!-- <dependency>--> +<!-- <groupId>com.kangaroohy</groupId>--> +<!-- <artifactId>milo-spring-boot-starter</artifactId>--> +<!-- <version>3.0.4</version>--> +<!-- </dependency>--> <dependency> <groupId>ai.djl.pytorch</groupId> <artifactId>pytorch-engine</artifactId> diff --git a/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/api/JeecgSystemApi.java b/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/api/JeecgSystemApi.java new file mode 100644 index 0000000..73342f6 --- /dev/null +++ b/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/api/JeecgSystemApi.java @@ -0,0 +1,18 @@ +package org.jeecg.modules.dry.api; + + +import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.dry.api.fallback.JeecgSystemFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +@FeignClient(value = "ichd-system", fallbackFactory = JeecgSystemFallback.class) +@Component +public interface JeecgSystemApi { + + + @GetMapping(value = "/sys/dict/getDictText/{dictCode}/{key}") + Result<String> getDictText(@PathVariable("dictCode") String dictCode, @PathVariable("key") String key); +} diff --git a/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/api/fallback/JeecgSystemFallback.java b/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/api/fallback/JeecgSystemFallback.java new file mode 100644 index 0000000..bad011f --- /dev/null +++ b/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/api/fallback/JeecgSystemFallback.java @@ -0,0 +1,25 @@ +package org.jeecg.modules.dry.api.fallback; + +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.modules.dry.api.DryHelloApi; +import org.jeecg.modules.dry.api.JeecgSystemApi; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +/** + * @author JeecgBoot + */ +@Slf4j +@Component +public class JeecgSystemFallback implements FallbackFactory<JeecgSystemApi> { + @Setter + private Throwable cause; + + @Override + public JeecgSystemApi create(Throwable throwable) { + log.error("寰湇鍔℃帴鍙h皟鐢ㄥけ璐ワ細 {}", cause); + return null; + } + +} diff --git a/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/common/OPCUA.java b/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/common/OPCUA.java new file mode 100644 index 0000000..fbd831a --- /dev/null +++ b/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/common/OPCUA.java @@ -0,0 +1,273 @@ +//package org.jeecg.modules.dry.common; +// +//import lombok.extern.slf4j.Slf4j; +//import org.eclipse.milo.opcua.sdk.client.OpcUaClient; +//import org.eclipse.milo.opcua.sdk.client.api.identity.AnonymousProvider; +//import org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaSubscription; +//import org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaSubscriptionManager; +//import org.eclipse.milo.opcua.sdk.client.nodes.UaNode; +//import org.eclipse.milo.opcua.sdk.client.subscriptions.ManagedDataItem; +//import org.eclipse.milo.opcua.sdk.client.subscriptions.ManagedSubscription; +//import org.eclipse.milo.opcua.stack.core.AttributeId; +//import org.eclipse.milo.opcua.stack.core.Identifiers; +//import org.eclipse.milo.opcua.stack.core.UaException; +//import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy; +//import org.eclipse.milo.opcua.stack.core.types.builtin.*; +//import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; +//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 java.nio.file.Files; +//import java.nio.file.Path; +//import java.nio.file.Paths; +//import java.util.ArrayList; +//import java.util.List; +//import java.util.Objects; +//import java.util.concurrent.CountDownLatch; +//import java.util.concurrent.atomic.AtomicInteger; +// +// +//@Slf4j +//public class OPCUA { +// +// private static AtomicInteger atomic = new AtomicInteger(1); +// // 瀹氫箟鏈嶅姟绔湴鍧� +// private final static String endPointUrl = "opc.tcp://127.0.0.1:49320"; +// +// +// /** +// * 鍒涘缓OPC UA瀹㈡埛绔� +// * @return +// * @throws Exception +// */ +// public static OpcUaClient createClient() throws Exception { +// +// Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security"); +// Files.createDirectories(securityTempDir); +// if (!Files.exists(securityTempDir)) { +// throw new Exception("unable to create security dir: " + securityTempDir); +// } +// return OpcUaClient.create(endPointUrl, +// endpoints -> +// endpoints.stream() +// .filter(e -> e.getSecurityPolicyUri().equals(SecurityPolicy.None.getUri())) +// .findFirst(), +// configBuilder -> +// configBuilder +// .setApplicationName(LocalizedText.english("eclipse milo opc-ua client")) +// .setApplicationUri("urn:eclipse:milo:examples:client") +// //璁块棶鏂瑰紡 +// .setIdentityProvider(new AnonymousProvider()) +// .setRequestTimeout(UInteger.valueOf(5000)) +// .build() +// ); +// } +// +// /** +// * 閬嶅巻鏍戝舰鑺傜偣 +// * +// * @param client OPC UA瀹㈡埛绔� +// * @param uaNode 鑺傜偣 +// * @throws Exception +// */ +// public static void browseNode(OpcUaClient client, UaNode uaNode) throws Exception { +// List<? extends UaNode> nodes; +// if (uaNode == null) { +// nodes = client.getAddressSpace().browseNodes(Identifiers.ObjectsFolder); +// } else { +// nodes = client.getAddressSpace().browseNodes(uaNode); +// } +// for (UaNode nd : nodes) { +// //鎺掗櫎绯荤粺琛屾�ц妭鐐癸紝杩欎簺绯荤粺鎬ц妭鐐瑰悕绉颁竴鑸兘鏄互"_"寮�澶� +// if (Objects.requireNonNull(nd.getBrowseName().getName()).contains("_")) { +// continue; +// } +// System.out.println("Node= " + nd.getBrowseName().getName()); +// browseNode(client, nd); +// } +// } +// +// +// /** +// * 璇诲彇鑺傜偣鏁版嵁 +// * +// * @param client OPC UA瀹㈡埛绔� +// * @throws Exception +// */ +// public static void readNode(OpcUaClient client) throws Exception { +// int namespaceIndex = 2; +// String identifier = "TD-01.SB-01.AG-01"; +// //鑺傜偣 +// NodeId nodeId = new NodeId(namespaceIndex, identifier); +// //璇诲彇鑺傜偣鏁版嵁 +// DataValue value = client.readValue(0.0, TimestampsToReturn.Neither, nodeId).get(); +// +// System.out.println(identifier + ": " + String.valueOf(value.getValue().getValue())); +// } +// +// +// /** +// * 鍐欏叆鑺傜偣鏁版嵁 +// * +// * @param client +// * @throws Exception +// */ +// public static void writeNodeValue(OpcUaClient client) throws Exception { +// //鑺傜偣 +// NodeId nodeId = new NodeId(2, "TD-01.SB-01.AG-01"); +// short i = 3; +// //鍒涘缓鏁版嵁瀵硅薄,姝ゅ鐨勬暟鎹璞′竴瀹氳瀹氫箟绫诲瀷锛屼笉鐒朵細鍑虹幇绫诲瀷閿欒锛屽鑷存棤娉曞啓鍏� +// DataValue nowValue = new DataValue(new Variant(i), null, null); +// //鍐欏叆鑺傜偣鏁版嵁 +// StatusCode statusCode = client.writeValue(nodeId, nowValue).join(); +// System.out.println("缁撴灉锛�" + statusCode.isGood()); +// } +// +// +// /** +// * 璁㈤槄(鍗曚釜) +// * +// * @param client +// * @throws Exception +// */ +// public static void subscribe(OpcUaClient client) throws Exception { +// //鍒涘缓鍙戝竷闂撮殧1000ms鐨勮闃呭璞� +// client +// .getSubscriptionManager() +// .createSubscription(1000.0) +// .thenAccept(t -> { +// //鑺傜偣 +// NodeId nodeId = new NodeId(2, "TD-01.SB-01.AG-01"); +// ReadValueId readValueId = new ReadValueId(nodeId, AttributeId.Value.uid(), null, null); +// //鍒涘缓鐩戞帶鐨勫弬鏁� +// MonitoringParameters parameters = new MonitoringParameters(UInteger.valueOf(atomic.getAndIncrement()), 1000.0, null, UInteger.valueOf(10), true); +// //鍒涘缓鐩戞帶椤硅姹� +// //璇ヨ姹傛渶鍚庣敤浜庡垱寤鸿闃呫�� +// MonitoredItemCreateRequest request = new MonitoredItemCreateRequest(readValueId, MonitoringMode.Reporting, parameters); +// List<MonitoredItemCreateRequest> requests = new ArrayList<>(); +// requests.add(request); +// //鍒涘缓鐩戞帶椤癸紝骞朵笖娉ㄥ唽鍙橀噺鍊兼敼鍙樻椂鍊欑殑鍥炶皟鍑芥暟銆� +// t.createMonitoredItems( +// TimestampsToReturn.Both, +// requests, +// (item, id) -> item.setValueConsumer((it, val) -> { +// System.out.println("nodeid :" + it.getReadValueId().getNodeId()); +// System.out.println("value :" + val.getValue().getValue()); +// }) +// ); +// }).get(); +// +// //鎸佺画璁㈤槄 +// Thread.sleep(Long.MAX_VALUE); +// } +// +// +// /** +// * 鎵归噺璁㈤槄 +// * +// * @param client +// * @throws Exception +// */ +//// private static void managedSubscriptionEvent(OpcUaClient client) throws Exception { +//// final CountDownLatch eventLatch = new CountDownLatch(1); +//// +//// //澶勭悊璁㈤槄涓氬姟 +//// handlerNode(client); +//// +//// //鎸佺画鐩戝惉 +//// eventLatch.await(); +//// } +// +// /** +// * 澶勭悊璁㈤槄涓氬姟 +// * +// * @param client OPC UA瀹㈡埛绔� +// */ +// public static void handlerNode(OpcUaClient client) { +// try { +// //鍒涘缓璁㈤槄 +// ManagedSubscription subscription = ManagedSubscription.create(client); +// +// //浣犳墍闇�瑕佽闃呯殑key +// List<String> key = new ArrayList<>(); +// key.add("閫氶亾 1.璁惧 1.鏍囪 1"); +// key.add("閫氶亾 1.璁惧 1.鏍囪 2"); +// +// List<NodeId> nodeIdList = new ArrayList<>(); +// for (String s : key) { +// nodeIdList.add(new NodeId(2, s)); +// } +// +// //鐩戝惉 +// List<ManagedDataItem> dataItemList = subscription.createDataItems(nodeIdList); +// for (ManagedDataItem managedDataItem : dataItemList) { +// managedDataItem.addDataValueListener((t) -> { +// System.out.println(managedDataItem.getNodeId().getIdentifier().toString() + ":" + t.getValue().getValue().toString()); +// }); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// /** +// * 鑷畾涔夎闃呯洃鍚� +// */ +// public static class CustomSubscriptionListener implements UaSubscriptionManager.SubscriptionListener { +// +// private OpcUaClient client; +// +// CustomSubscriptionListener(OpcUaClient client) { +// this.client = client; +// } +// +// public void onKeepAlive(UaSubscription subscription, DateTime publishTime) { +// log.debug("onKeepAlive"); +// } +// +// public void onStatusChanged(UaSubscription subscription, StatusCode status) { +// log.debug("onStatusChanged"); +// } +// +// public void onPublishFailure(UaException exception) { +// log.debug("onPublishFailure"); +// } +// +// public void onNotificationDataLost(UaSubscription subscription) { +// log.debug("onNotificationDataLost"); +// } +// +// /** +// * 閲嶈繛鏃� 灏濊瘯鎭㈠涔嬪墠鐨勮闃呭け璐ユ椂 浼氳皟鐢ㄦ鏂规硶 +// * @param uaSubscription 璁㈤槄 +// * @param statusCode 鐘舵�� +// */ +// public void onSubscriptionTransferFailed(UaSubscription uaSubscription, StatusCode statusCode) { +// log.debug("鎭㈠璁㈤槄澶辫触 闇�瑕侀噸鏂拌闃�"); +// //鍦ㄥ洖璋冩柟娉曚腑閲嶆柊璁㈤槄 +// handlerNode(client); +// } +// } +// +// /** +// * 鎵归噺璁㈤槄 +// * +// * @param client +// * @throws Exception +// */ +// public static void managedSubscriptionEvent(OpcUaClient client) throws Exception { +// final CountDownLatch eventLatch = new CountDownLatch(1); +// +// //娣诲姞璁㈤槄鐩戝惉鍣紝鐢ㄤ簬澶勭悊鏂嚎閲嶈繛鍚庣殑璁㈤槄闂 +// client.getSubscriptionManager().addSubscriptionListener(new CustomSubscriptionListener(client)); +// +// //澶勭悊璁㈤槄涓氬姟 +// handlerNode(client); +// +// //鎸佺画鐩戝惉 +// eventLatch.await(); +// } +//} diff --git a/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/util/HerbUtil.java b/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/util/HerbUtil.java index 90c6db2..00fd274 100644 --- a/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/util/HerbUtil.java +++ b/jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/util/HerbUtil.java @@ -1,170 +1,170 @@ -package org.jeecg.modules.dry.util; - -import ai.djl.Device; -import ai.djl.Model; -import ai.djl.inference.Predictor; -import ai.djl.modality.Classifications; -import ai.djl.modality.cv.Image; -import ai.djl.modality.cv.ImageFactory; -import ai.djl.modality.cv.transform.*; -import ai.djl.modality.cv.translator.ImageClassificationTranslator; -import ai.djl.translate.Translator; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.io.Resource; -import org.springframework.core.io.support.PathMatchingResourcePatternResolver; -import org.springframework.core.io.support.ResourcePatternResolver; -import org.springframework.stereotype.Component; - -import javax.imageio.ImageIO; -import javax.imageio.stream.ImageOutputStream; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.*; -import java.util.ArrayList; -import java.util.List; - -@Slf4j -@Component -public class HerbUtil { - - //瑙勫畾杈撳叆灏哄 - private static final int INPUT_SIZE = 224; - - private static final int TARGET_SIZE = 256; - - //鏍囩鏂囦欢 涓�绉嶇被鍒悕瀛楀崰涓�琛� - private List<String> herbNames; - - //鐢ㄤ簬璇嗗埆 - Predictor<Image, Classifications> predictor; - - //妯″瀷 - private Model model; - - public HerbUtil() { - //鍔犺浇鏍囩鍒癶erbNames涓� - this.loadHerbNames(); - //鍒濆鍖栨ā鍨嬪伐浣� - this.init(); - - - - } - - public List<Classifications.Classification> predict(InputStream inputStream) { - List<Classifications.Classification> result = new ArrayList<>(); - Image input = this.resizeImage(inputStream); - try { - Classifications output = predictor.predict(input); - System.out.println("鎺ㄦ祴涓猴細" + output.best().getClassName() - + ", 姒傜巼锛�" + output.best().getProbability()); - System.out.println(output); - result = output.topK(); - } catch (Exception e) { - log.error("鑽潗璇嗗埆寮傚父锛侊紒"); - log.error(input.toString()); - log.error(predictor.toString()); - e.printStackTrace(); - } - return result; - } - - private void loadHerbNames() { - BufferedReader reader = null; - herbNames = new ArrayList<>(); - try { - InputStream in = HerbUtil.class.getClassLoader().getResourceAsStream("class.txt"); - reader = new BufferedReader(new InputStreamReader(in)); - String name = null; - while ((name = reader.readLine()) != null) { - herbNames.add(name); - } - System.out.println(herbNames); - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - private void init() { - Translator<Image, Classifications> translator = ImageClassificationTranslator.builder() - //涓嬮潰鐨則ransform鏍规嵁鑷繁鐨勬敼 - .addTransform(new CenterCrop(INPUT_SIZE,INPUT_SIZE)) - - .addTransform(new ToTensor()) - .addTransform(new Normalize( - new float[] {0.485f, 0.456f, 0.406f}, - new float[] {0.229f, 0.224f, 0.225f})) - - //杞藉叆鎵�鏈夋爣绛捐繘鍘� - .optSynset(herbNames) - //鏈�缁堟樉绀烘鐜囨渶楂樼殑5涓� - .optTopK(5) - .build(); - //闅忎究璧峰悕 - Model model = Model.newInstance("model", Device.cpu()); - try { -// ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); -// Resource[] resources = resolver.getResources("../pytorch/model34.pt"); - // Resource resource = resources[0]; - File f = new File("../pytorch/model34.pt"); - - InputStream inputStream = new FileInputStream(f); - // InputStream inputStream = HerbUtil.class.getClassLoader().getResourceAsStream("model34.pt"); - if (inputStream == null) { - throw new RuntimeException("鎵句笉鍒版ā鍨嬫枃浠�"); - } - model.load(inputStream); - - predictor = model.newPredictor(translator); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private Image resizeImage(InputStream inputStream) { - BufferedImage input = null; - try { - input = ImageIO.read(inputStream); - } catch (IOException e) { - e.printStackTrace(); - } - int iw = input.getWidth(), ih = input.getHeight(); - int w = 256, h = 256; - double scale = Math.max(1. * w / iw, 1. * h / ih); - int nw = (int) (iw * scale), nh = (int) (ih * scale); - java.awt.Image img; - //鍙湁澶暱鎴栧お瀹芥墠浼氫繚鐣欐í绾垫瘮锛屽~鍏呴鑹� - // boolean needResize = 1. * iw / ih > 1.4 || 1. * ih / iw > 1.4; - // if (needResize) { - img = input.getScaledInstance(nw, nh, BufferedImage.SCALE_SMOOTH); - // } else { - // img = input.getScaledInstance(INPUT_SIZE, INPUT_SIZE, BufferedImage.SCALE_SMOOTH); - // } - BufferedImage out = new BufferedImage(nw, nh, BufferedImage.TYPE_INT_RGB); - Graphics g = out.getGraphics(); - //鍏堝皢鏁翠釜224*224鍖哄煙濉厖128 128 128棰滆壊 - g.setColor(new Color(255, 255, 255)); - g.fillRect(0, 0, nw, nh); - out.getGraphics().drawImage(img, 0, 0, null); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - try { - ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(outputStream); - ImageIO.write(out, "jpg", imageOutputStream); - //鍘籇鐩樼湅鏁堟灉 - ImageIO.write(out, "jpg", new File("E:\\out.jpg")); - InputStream is = new ByteArrayInputStream(outputStream.toByteArray()); - return ImageFactory.getInstance().fromInputStream(is); - } catch (IOException e) { - e.printStackTrace(); - throw new RuntimeException("鍥剧墖杞崲澶辫触"); - } - } -} \ No newline at end of file +//package org.jeecg.modules.dry.util; +// +//import ai.djl.Device; +//import ai.djl.Model; +//import ai.djl.inference.Predictor; +//import ai.djl.modality.Classifications; +//import ai.djl.modality.cv.Image; +//import ai.djl.modality.cv.ImageFactory; +//import ai.djl.modality.cv.transform.*; +//import ai.djl.modality.cv.translator.ImageClassificationTranslator; +//import ai.djl.translate.Translator; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.core.io.Resource; +//import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +//import org.springframework.core.io.support.ResourcePatternResolver; +//import org.springframework.stereotype.Component; +// +//import javax.imageio.ImageIO; +//import javax.imageio.stream.ImageOutputStream; +//import java.awt.*; +//import java.awt.image.BufferedImage; +//import java.io.*; +//import java.util.ArrayList; +//import java.util.List; +// +//@Slf4j +//@Component +//public class HerbUtil { +// +// //瑙勫畾杈撳叆灏哄 +// private static final int INPUT_SIZE = 224; +// +// private static final int TARGET_SIZE = 256; +// +// //鏍囩鏂囦欢 涓�绉嶇被鍒悕瀛楀崰涓�琛� +// private List<String> herbNames; +// +// //鐢ㄤ簬璇嗗埆 +// Predictor<Image, Classifications> predictor; +// +// //妯″瀷 +// private Model model; +// +// public HerbUtil() { +// //鍔犺浇鏍囩鍒癶erbNames涓� +// this.loadHerbNames(); +// //鍒濆鍖栨ā鍨嬪伐浣� +// this.init(); +// +// +// +// } +// +// public List<Classifications.Classification> predict(InputStream inputStream) { +// List<Classifications.Classification> result = new ArrayList<>(); +// Image input = this.resizeImage(inputStream); +// try { +// Classifications output = predictor.predict(input); +// System.out.println("鎺ㄦ祴涓猴細" + output.best().getClassName() +// + ", 姒傜巼锛�" + output.best().getProbability()); +// System.out.println(output); +// result = output.topK(); +// } catch (Exception e) { +// log.error("鑽潗璇嗗埆寮傚父锛侊紒"); +// log.error(input.toString()); +// log.error(predictor.toString()); +// e.printStackTrace(); +// } +// return result; +// } +// +// private void loadHerbNames() { +// BufferedReader reader = null; +// herbNames = new ArrayList<>(); +// try { +// InputStream in = HerbUtil.class.getClassLoader().getResourceAsStream("class.txt"); +// reader = new BufferedReader(new InputStreamReader(in)); +// String name = null; +// while ((name = reader.readLine()) != null) { +// herbNames.add(name); +// } +// System.out.println(herbNames); +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// if (reader != null) { +// try { +// reader.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// } +// } +// +// private void init() { +// Translator<Image, Classifications> translator = ImageClassificationTranslator.builder() +// //涓嬮潰鐨則ransform鏍规嵁鑷繁鐨勬敼 +// .addTransform(new CenterCrop(INPUT_SIZE,INPUT_SIZE)) +// +// .addTransform(new ToTensor()) +// .addTransform(new Normalize( +// new float[] {0.485f, 0.456f, 0.406f}, +// new float[] {0.229f, 0.224f, 0.225f})) +// +// //杞藉叆鎵�鏈夋爣绛捐繘鍘� +// .optSynset(herbNames) +// //鏈�缁堟樉绀烘鐜囨渶楂樼殑5涓� +// .optTopK(5) +// .build(); +// //闅忎究璧峰悕 +// Model model = Model.newInstance("model", Device.cpu()); +// try { +//// ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); +//// Resource[] resources = resolver.getResources("../pytorch/model34.pt"); +// // Resource resource = resources[0]; +// File f = new File("../pytorch/model34.pt"); +// +// InputStream inputStream = new FileInputStream(f); +// // InputStream inputStream = HerbUtil.class.getClassLoader().getResourceAsStream("model34.pt"); +// if (inputStream == null) { +// throw new RuntimeException("鎵句笉鍒版ā鍨嬫枃浠�"); +// } +// model.load(inputStream); +// +// predictor = model.newPredictor(translator); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// private Image resizeImage(InputStream inputStream) { +// BufferedImage input = null; +// try { +// input = ImageIO.read(inputStream); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// int iw = input.getWidth(), ih = input.getHeight(); +// int w = 256, h = 256; +// double scale = Math.max(1. * w / iw, 1. * h / ih); +// int nw = (int) (iw * scale), nh = (int) (ih * scale); +// java.awt.Image img; +// //鍙湁澶暱鎴栧お瀹芥墠浼氫繚鐣欐í绾垫瘮锛屽~鍏呴鑹� +// // boolean needResize = 1. * iw / ih > 1.4 || 1. * ih / iw > 1.4; +// // if (needResize) { +// img = input.getScaledInstance(nw, nh, BufferedImage.SCALE_SMOOTH); +// // } else { +// // img = input.getScaledInstance(INPUT_SIZE, INPUT_SIZE, BufferedImage.SCALE_SMOOTH); +// // } +// BufferedImage out = new BufferedImage(nw, nh, BufferedImage.TYPE_INT_RGB); +// Graphics g = out.getGraphics(); +// //鍏堝皢鏁翠釜224*224鍖哄煙濉厖128 128 128棰滆壊 +// g.setColor(new Color(255, 255, 255)); +// g.fillRect(0, 0, nw, nh); +// out.getGraphics().drawImage(img, 0, 0, null); +// ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); +// try { +// ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(outputStream); +// ImageIO.write(out, "jpg", imageOutputStream); +// //鍘籇鐩樼湅鏁堟灉 +// ImageIO.write(out, "jpg", new File("E:\\out.jpg")); +// InputStream is = new ByteArrayInputStream(outputStream.toByteArray()); +// return ImageFactory.getInstance().fromInputStream(is); +// } catch (IOException e) { +// e.printStackTrace(); +// throw new RuntimeException("鍥剧墖杞崲澶辫触"); +// } +// } +//} \ No newline at end of file diff --git a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryOpcDeviceController.java b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryOpcDeviceController.java index fdb5f5a..58dbb08 100644 --- a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryOpcDeviceController.java +++ b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryOpcDeviceController.java @@ -1,205 +1,205 @@ -package org.jeecg.modules.dry.controller; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.kangaroohy.milo.model.ReadWriteEntity; -import com.kangaroohy.milo.service.MiloService; -import org.jeecg.common.api.vo.Result; -import org.jeecg.common.system.query.QueryGenerator; -import org.jeecg.common.util.oConvertUtils; -import org.jeecg.modules.dry.entity.DryOpcDevice; -import org.jeecg.modules.dry.service.IDryOpcDeviceService; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import lombok.extern.slf4j.Slf4j; - -import org.jeecgframework.poi.excel.ExcelImportUtil; -import org.jeecgframework.poi.excel.def.NormalExcelConstants; -import org.jeecgframework.poi.excel.entity.ExportParams; -import org.jeecgframework.poi.excel.entity.ImportParams; -import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; -import org.jeecg.common.system.base.controller.JeecgController; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.multipart.MultipartHttpServletRequest; -import org.springframework.web.servlet.ModelAndView; -import com.alibaba.fastjson.JSON; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.jeecg.common.aspect.annotation.AutoLog; -import org.apache.shiro.authz.annotation.RequiresPermissions; - - /** - * @Description: dry_opc_device - * @Author: jeecg-boot - * @Date: 2023-11-28 - * @Version: V1.0 - */ -@Api(tags="dry_opc_device") -@RestController -@RequestMapping("/dry/dryOpcDevice") -@Slf4j -public class DryOpcDeviceController extends JeecgController<DryOpcDevice, IDryOpcDeviceService> { - @Autowired - private IDryOpcDeviceService dryOpcDeviceService; - - - @Autowired - private MiloService miloService; - - - /** - * 鍒嗛〉鍒楄〃鏌ヨ - * - * @param dryOpcDevice - * @param pageNo - * @param pageSize - * @param req - * @return - */ - //@AutoLog(value = "dry_opc_device-鍒嗛〉鍒楄〃鏌ヨ") - @ApiOperation(value="dry_opc_device-鍒嗛〉鍒楄〃鏌ヨ", notes="dry_opc_device-鍒嗛〉鍒楄〃鏌ヨ") - @GetMapping(value = "/list") - public Result<IPage<DryOpcDevice>> queryPageList(DryOpcDevice dryOpcDevice, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - QueryWrapper<DryOpcDevice> queryWrapper = QueryGenerator.initQueryWrapper(dryOpcDevice, req.getParameterMap()); - Page<DryOpcDevice> page = new Page<DryOpcDevice>(pageNo, pageSize); - IPage<DryOpcDevice> pageList = dryOpcDeviceService.page(page, queryWrapper); - return Result.OK(pageList); - } - - @GetMapping(value = "/listAll") - public Result<List<DryOpcDevice>> queryList(DryOpcDevice dryOpcDevice, - - HttpServletRequest req) { - QueryWrapper<DryOpcDevice> queryWrapper = QueryGenerator.initQueryWrapper(dryOpcDevice, req.getParameterMap()); - queryWrapper.orderByAsc("sort_order"); - List<DryOpcDevice> list = dryOpcDeviceService.list(queryWrapper); - list.forEach(item -> { - try { - ReadWriteEntity readWriteEntity = miloService.readFromOpcUa(item.getIdentifier()); - item.setValue((Boolean) readWriteEntity.getValue()); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - return Result.OK(list); - } - - - /** - * 娣诲姞 - * - * @param dryOpcDevice - * @return - */ - @AutoLog(value = "dry_opc_device-娣诲姞") - @ApiOperation(value="dry_opc_device-娣诲姞", notes="dry_opc_device-娣诲姞") - @RequiresPermissions("dry:dry_opc_device:add") - @PostMapping(value = "/add") - public Result<String> add(@RequestBody DryOpcDevice dryOpcDevice) { - dryOpcDeviceService.save(dryOpcDevice); - return Result.OK("娣诲姞鎴愬姛锛�"); - } - - /** - * 缂栬緫 - * - * @param dryOpcDevice - * @return - */ - @AutoLog(value = "dry_opc_device-缂栬緫") - @ApiOperation(value="dry_opc_device-缂栬緫", notes="dry_opc_device-缂栬緫") - @RequiresPermissions("dry:dry_opc_device:edit") - @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) - public Result<String> edit(@RequestBody DryOpcDevice dryOpcDevice) { - dryOpcDeviceService.updateById(dryOpcDevice); - return Result.OK("缂栬緫鎴愬姛!"); - } - - /** - * 閫氳繃id鍒犻櫎 - * - * @param id - * @return - */ - @AutoLog(value = "dry_opc_device-閫氳繃id鍒犻櫎") - @ApiOperation(value="dry_opc_device-閫氳繃id鍒犻櫎", notes="dry_opc_device-閫氳繃id鍒犻櫎") - @RequiresPermissions("dry:dry_opc_device:delete") - @DeleteMapping(value = "/delete") - public Result<String> delete(@RequestParam(name="id",required=true) String id) { - dryOpcDeviceService.removeById(id); - return Result.OK("鍒犻櫎鎴愬姛!"); - } - - /** - * 鎵归噺鍒犻櫎 - * - * @param ids - * @return - */ - @AutoLog(value = "dry_opc_device-鎵归噺鍒犻櫎") - @ApiOperation(value="dry_opc_device-鎵归噺鍒犻櫎", notes="dry_opc_device-鎵归噺鍒犻櫎") - @RequiresPermissions("dry:dry_opc_device:deleteBatch") - @DeleteMapping(value = "/deleteBatch") - public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { - this.dryOpcDeviceService.removeByIds(Arrays.asList(ids.split(","))); - return Result.OK("鎵归噺鍒犻櫎鎴愬姛!"); - } - - /** - * 閫氳繃id鏌ヨ - * - * @param id - * @return - */ - //@AutoLog(value = "dry_opc_device-閫氳繃id鏌ヨ") - @ApiOperation(value="dry_opc_device-閫氳繃id鏌ヨ", notes="dry_opc_device-閫氳繃id鏌ヨ") - @GetMapping(value = "/queryById") - public Result<DryOpcDevice> queryById(@RequestParam(name="id",required=true) String id) { - DryOpcDevice dryOpcDevice = dryOpcDeviceService.getById(id); - if(dryOpcDevice==null) { - return Result.error("鏈壘鍒板搴旀暟鎹�"); - } - return Result.OK(dryOpcDevice); - } - - /** - * 瀵煎嚭excel - * - * @param request - * @param dryOpcDevice - */ - @RequiresPermissions("dry:dry_opc_device:exportXls") - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, DryOpcDevice dryOpcDevice) { - return super.exportXls(request, dryOpcDevice, DryOpcDevice.class, "dry_opc_device"); - } - - /** - * 閫氳繃excel瀵煎叆鏁版嵁 - * - * @param request - * @param response - * @return - */ - @RequiresPermissions("dry:dry_opc_device:importExcel") - @RequestMapping(value = "/importExcel", method = RequestMethod.POST) - public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { - return super.importExcel(request, response, DryOpcDevice.class); - } - -} +//package org.jeecg.modules.dry.controller; +// +//import java.util.Arrays; +//import java.util.List; +//import java.util.Map; +//import java.util.stream.Collectors; +//import java.io.IOException; +//import java.io.UnsupportedEncodingException; +//import java.net.URLDecoder; +//import javax.servlet.http.HttpServletRequest; +//import javax.servlet.http.HttpServletResponse; +// +//import com.kangaroohy.milo.model.ReadWriteEntity; +//import com.kangaroohy.milo.service.MiloService; +//import org.jeecg.common.api.vo.Result; +//import org.jeecg.common.system.query.QueryGenerator; +//import org.jeecg.common.util.oConvertUtils; +//import org.jeecg.modules.dry.entity.DryOpcDevice; +//import org.jeecg.modules.dry.service.IDryOpcDeviceService; +// +//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +//import com.baomidou.mybatisplus.core.metadata.IPage; +//import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +//import lombok.extern.slf4j.Slf4j; +// +//import org.jeecgframework.poi.excel.ExcelImportUtil; +//import org.jeecgframework.poi.excel.def.NormalExcelConstants; +//import org.jeecgframework.poi.excel.entity.ExportParams; +//import org.jeecgframework.poi.excel.entity.ImportParams; +//import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; +//import org.jeecg.common.system.base.controller.JeecgController; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.web.bind.annotation.*; +//import org.springframework.web.multipart.MultipartFile; +//import org.springframework.web.multipart.MultipartHttpServletRequest; +//import org.springframework.web.servlet.ModelAndView; +//import com.alibaba.fastjson.JSON; +//import io.swagger.annotations.Api; +//import io.swagger.annotations.ApiOperation; +//import org.jeecg.common.aspect.annotation.AutoLog; +//import org.apache.shiro.authz.annotation.RequiresPermissions; +// +// /** +// * @Description: dry_opc_device +// * @Author: jeecg-boot +// * @Date: 2023-11-28 +// * @Version: V1.0 +// */ +//@Api(tags="dry_opc_device") +//@RestController +//@RequestMapping("/dry/dryOpcDevice") +//@Slf4j +//public class DryOpcDeviceController extends JeecgController<DryOpcDevice, IDryOpcDeviceService> { +// @Autowired +// private IDryOpcDeviceService dryOpcDeviceService; +// +// +// @Autowired +// private MiloService miloService; +// +// +// /** +// * 鍒嗛〉鍒楄〃鏌ヨ +// * +// * @param dryOpcDevice +// * @param pageNo +// * @param pageSize +// * @param req +// * @return +// */ +// //@AutoLog(value = "dry_opc_device-鍒嗛〉鍒楄〃鏌ヨ") +// @ApiOperation(value="dry_opc_device-鍒嗛〉鍒楄〃鏌ヨ", notes="dry_opc_device-鍒嗛〉鍒楄〃鏌ヨ") +// @GetMapping(value = "/list") +// public Result<IPage<DryOpcDevice>> queryPageList(DryOpcDevice dryOpcDevice, +// @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, +// @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, +// HttpServletRequest req) { +// QueryWrapper<DryOpcDevice> queryWrapper = QueryGenerator.initQueryWrapper(dryOpcDevice, req.getParameterMap()); +// Page<DryOpcDevice> page = new Page<DryOpcDevice>(pageNo, pageSize); +// IPage<DryOpcDevice> pageList = dryOpcDeviceService.page(page, queryWrapper); +// return Result.OK(pageList); +// } +// +// @GetMapping(value = "/listAll") +// public Result<List<DryOpcDevice>> queryList(DryOpcDevice dryOpcDevice, +// +// HttpServletRequest req) { +// QueryWrapper<DryOpcDevice> queryWrapper = QueryGenerator.initQueryWrapper(dryOpcDevice, req.getParameterMap()); +// queryWrapper.orderByAsc("sort_order"); +// List<DryOpcDevice> list = dryOpcDeviceService.list(queryWrapper); +// list.forEach(item -> { +// try { +// ReadWriteEntity readWriteEntity = miloService.readFromOpcUa(item.getIdentifier()); +// item.setValue((Boolean) readWriteEntity.getValue()); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// }); +// return Result.OK(list); +// } +// +// +// /** +// * 娣诲姞 +// * +// * @param dryOpcDevice +// * @return +// */ +// @AutoLog(value = "dry_opc_device-娣诲姞") +// @ApiOperation(value="dry_opc_device-娣诲姞", notes="dry_opc_device-娣诲姞") +// @RequiresPermissions("dry:dry_opc_device:add") +// @PostMapping(value = "/add") +// public Result<String> add(@RequestBody DryOpcDevice dryOpcDevice) { +// dryOpcDeviceService.save(dryOpcDevice); +// return Result.OK("娣诲姞鎴愬姛锛�"); +// } +// +// /** +// * 缂栬緫 +// * +// * @param dryOpcDevice +// * @return +// */ +// @AutoLog(value = "dry_opc_device-缂栬緫") +// @ApiOperation(value="dry_opc_device-缂栬緫", notes="dry_opc_device-缂栬緫") +// @RequiresPermissions("dry:dry_opc_device:edit") +// @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) +// public Result<String> edit(@RequestBody DryOpcDevice dryOpcDevice) { +// dryOpcDeviceService.updateById(dryOpcDevice); +// return Result.OK("缂栬緫鎴愬姛!"); +// } +// +// /** +// * 閫氳繃id鍒犻櫎 +// * +// * @param id +// * @return +// */ +// @AutoLog(value = "dry_opc_device-閫氳繃id鍒犻櫎") +// @ApiOperation(value="dry_opc_device-閫氳繃id鍒犻櫎", notes="dry_opc_device-閫氳繃id鍒犻櫎") +// @RequiresPermissions("dry:dry_opc_device:delete") +// @DeleteMapping(value = "/delete") +// public Result<String> delete(@RequestParam(name="id",required=true) String id) { +// dryOpcDeviceService.removeById(id); +// return Result.OK("鍒犻櫎鎴愬姛!"); +// } +// +// /** +// * 鎵归噺鍒犻櫎 +// * +// * @param ids +// * @return +// */ +// @AutoLog(value = "dry_opc_device-鎵归噺鍒犻櫎") +// @ApiOperation(value="dry_opc_device-鎵归噺鍒犻櫎", notes="dry_opc_device-鎵归噺鍒犻櫎") +// @RequiresPermissions("dry:dry_opc_device:deleteBatch") +// @DeleteMapping(value = "/deleteBatch") +// public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { +// this.dryOpcDeviceService.removeByIds(Arrays.asList(ids.split(","))); +// return Result.OK("鎵归噺鍒犻櫎鎴愬姛!"); +// } +// +// /** +// * 閫氳繃id鏌ヨ +// * +// * @param id +// * @return +// */ +// //@AutoLog(value = "dry_opc_device-閫氳繃id鏌ヨ") +// @ApiOperation(value="dry_opc_device-閫氳繃id鏌ヨ", notes="dry_opc_device-閫氳繃id鏌ヨ") +// @GetMapping(value = "/queryById") +// public Result<DryOpcDevice> queryById(@RequestParam(name="id",required=true) String id) { +// DryOpcDevice dryOpcDevice = dryOpcDeviceService.getById(id); +// if(dryOpcDevice==null) { +// return Result.error("鏈壘鍒板搴旀暟鎹�"); +// } +// return Result.OK(dryOpcDevice); +// } +// +// /** +// * 瀵煎嚭excel +// * +// * @param request +// * @param dryOpcDevice +// */ +// @RequiresPermissions("dry:dry_opc_device:exportXls") +// @RequestMapping(value = "/exportXls") +// public ModelAndView exportXls(HttpServletRequest request, DryOpcDevice dryOpcDevice) { +// return super.exportXls(request, dryOpcDevice, DryOpcDevice.class, "dry_opc_device"); +// } +// +// /** +// * 閫氳繃excel瀵煎叆鏁版嵁 +// * +// * @param request +// * @param response +// * @return +// */ +// @RequiresPermissions("dry:dry_opc_device:importExcel") +// @RequestMapping(value = "/importExcel", method = RequestMethod.POST) +// public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { +// return super.importExcel(request, response, DryOpcDevice.class); +// } +// +//} diff --git a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryRealTimeDataController.java b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryRealTimeDataController.java index 2878189..b261d83 100644 --- a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryRealTimeDataController.java +++ b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryRealTimeDataController.java @@ -12,7 +12,7 @@ import org.jeecg.modules.dry.entity.DryHerbInfo; import org.jeecg.modules.dry.service.*; -import org.jeecg.modules.dry.util.HerbUtil; +//import org.jeecg.modules.dry.util.HerbUtil; import org.jeecg.modules.dry.vo.CommandMessageVo; import org.jeecg.modules.dry.vo.DryHerbInfoVo; import org.jeecg.modules.dry.vo.RealTimeDataVo; @@ -36,8 +36,8 @@ @Autowired private IDryRealTimeDataService dryRealTimeDataService; - @Autowired - private HerbUtil herbUtil; +// @Autowired +// private HerbUtil herbUtil; @Autowired private IDryHerbInfoService herbInfoService; @@ -85,43 +85,43 @@ return dryRealTimeDataService.sendSocketMsg(msgVo); } - - @ApiOperation(value = "鑽潗璇嗗埆") - @PostMapping("/identify") - public Result<?> identify(@RequestParam("file") MultipartFile file) throws Exception { - try { - if (file.isEmpty()) { - throw new RuntimeException("涓婁紶鏂囦欢涓嶈兘涓虹┖"); - } - InputStream inputStream = file.getInputStream(); - List<Classifications.Classification> predict = herbUtil.predict(inputStream); - - if(predict.size()>0) { - Map<String, Double> collect = predict.stream().collect(Collectors.toMap(Classifications.Classification::getClassName, Classifications.Classification::getProbability)); - - - List<DryHerbInfoVo> voList = new ArrayList<>(); - Set<String> strings = collect.keySet(); - List<DryHerbInfo> list = herbInfoService.list(new LambdaQueryWrapper<DryHerbInfo>().in(DryHerbInfo::getPinyin, strings)); - list.forEach(item -> { - DryHerbInfoVo dryHerbInfoVo = new DryHerbInfoVo(); - BeanUtil.copyProperties(item, dryHerbInfoVo); - dryHerbInfoVo.setProbabily(collect.get(item.getPinyin())); - voList.add(dryHerbInfoVo); - }); - - List<DryHerbInfoVo> collect1 = voList.stream().sorted(Comparator.comparing(DryHerbInfoVo::getProbabily, Comparator.reverseOrder())). - collect(Collectors.toList()); - - return Result.ok(collect1); - } else { - return Result.error("AI璇嗗埆鏈嶅姟寮傚父"); - } - - } catch (Exception e) { - e.printStackTrace(); - return Result.error("AI璇嗗埆鏈嶅姟寮傚父"); - } - } +// +// @ApiOperation(value = "鑽潗璇嗗埆") +// @PostMapping("/identify") +// public Result<?> identify(@RequestParam("file") MultipartFile file) throws Exception { +// try { +// if (file.isEmpty()) { +// throw new RuntimeException("涓婁紶鏂囦欢涓嶈兘涓虹┖"); +// } +// InputStream inputStream = file.getInputStream(); +// List<Classifications.Classification> predict = herbUtil.predict(inputStream); +// +// if(predict.size()>0) { +// Map<String, Double> collect = predict.stream().collect(Collectors.toMap(Classifications.Classification::getClassName, Classifications.Classification::getProbability)); +// +// +// List<DryHerbInfoVo> voList = new ArrayList<>(); +// Set<String> strings = collect.keySet(); +// List<DryHerbInfo> list = herbInfoService.list(new LambdaQueryWrapper<DryHerbInfo>().in(DryHerbInfo::getPinyin, strings)); +// list.forEach(item -> { +// DryHerbInfoVo dryHerbInfoVo = new DryHerbInfoVo(); +// BeanUtil.copyProperties(item, dryHerbInfoVo); +// dryHerbInfoVo.setProbabily(collect.get(item.getPinyin())); +// voList.add(dryHerbInfoVo); +// }); +// +// List<DryHerbInfoVo> collect1 = voList.stream().sorted(Comparator.comparing(DryHerbInfoVo::getProbabily, Comparator.reverseOrder())). +// collect(Collectors.toList()); +// +// return Result.ok(collect1); +// } else { +// return Result.error("AI璇嗗埆鏈嶅姟寮傚父"); +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// return Result.error("AI璇嗗埆鏈嶅姟寮傚父"); +// } +// } } diff --git a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/OpcController.java b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/OpcController.java index 02852d6..84e7484 100644 --- a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/OpcController.java +++ b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/OpcController.java @@ -1,66 +1,66 @@ -package org.jeecg.modules.dry.controller; - -import com.kangaroohy.milo.model.ReadWriteEntity; -import com.kangaroohy.milo.service.MiloService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.eclipse.milo.opcua.sdk.client.OpcUaClient; -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.jeecg.common.api.vo.Result; -import org.jeecg.modules.dry.entity.DryOpcDevice; -import org.jeecg.modules.dry.service.IDryOpcDeviceService; -import org.jeecg.modules.dry.vo.CommandMessageVo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; -import java.util.concurrent.ExecutionException; - -/** - * opc鎺у埗鍣紝鐢ㄤ簬鎺у埗鐜板満鎽勫儚澶寸數婧愶紝鐏殑寮�鍏� - */ - -@Api(tags="OPC鎺у埗鍣�") -@RestController -@RequestMapping("/dry/opc") -@Slf4j -public class OpcController { - - @Autowired - private MiloService miloService; - - @Autowired - private IDryOpcDeviceService opcDeviceService; - - - @ApiOperation(value="鍙戦�佹帶鍒舵寚浠�", notes="鍚戞湇鍔$鍙戦�佹帶鍒舵寚浠わ紝鐢辨湇鍔$杞彂缁欐帶鍒舵ā鍧�") - @PostMapping("/sendWriteCommand") - public Result<?> sendWriteCommand(@RequestBody CommandMessageVo msgVo) throws Exception { - - miloService.writeToOpcUa(ReadWriteEntity.builder() - .identifier(msgVo.getCode()) - //Kep涓槸Boolean绫诲瀷 - .value(Boolean.valueOf(msgVo.getMsg())) - .build()); - return Result.OK(); - } - - @ApiOperation(value="鍙戦�佹帶鍒舵寚浠�", notes="鍚戞湇鍔$鍙戦�佹帶鍒舵寚浠わ紝鐢辨湇鍔$杞彂缁欐帶鍒舵ā鍧�") - @PostMapping("/initDevice") - public Result<?> initDevice() throws Exception { - List<DryOpcDevice> list = opcDeviceService.list(); - - list.forEach(item -> { - - }); - - return Result.OK(); - } -} +//package org.jeecg.modules.dry.controller; +// +//import com.kangaroohy.milo.model.ReadWriteEntity; +//import com.kangaroohy.milo.service.MiloService; +//import io.swagger.annotations.Api; +//import io.swagger.annotations.ApiOperation; +//import lombok.extern.slf4j.Slf4j; +//import org.eclipse.milo.opcua.sdk.client.OpcUaClient; +//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.jeecg.common.api.vo.Result; +//import org.jeecg.modules.dry.entity.DryOpcDevice; +//import org.jeecg.modules.dry.service.IDryOpcDeviceService; +//import org.jeecg.modules.dry.vo.CommandMessageVo; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.RequestBody; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RestController; +// +//import java.util.List; +//import java.util.concurrent.ExecutionException; +// +///** +// * opc鎺у埗鍣紝鐢ㄤ簬鎺у埗鐜板満鎽勫儚澶寸數婧愶紝鐏殑寮�鍏� +// */ +// +//@Api(tags="OPC鎺у埗鍣�") +//@RestController +//@RequestMapping("/dry/opc") +//@Slf4j +//public class OpcController { +// +// @Autowired +// private MiloService miloService; +// +// @Autowired +// private IDryOpcDeviceService opcDeviceService; +// +// +// @ApiOperation(value="鍙戦�佹帶鍒舵寚浠�", notes="鍚戞湇鍔$鍙戦�佹帶鍒舵寚浠わ紝鐢辨湇鍔$杞彂缁欐帶鍒舵ā鍧�") +// @PostMapping("/sendWriteCommand") +// public Result<?> sendWriteCommand(@RequestBody CommandMessageVo msgVo) throws Exception { +// +// miloService.writeToOpcUa(ReadWriteEntity.builder() +// .identifier(msgVo.getCode()) +// //Kep涓槸Boolean绫诲瀷 +// .value(Boolean.valueOf(msgVo.getMsg())) +// .build()); +// return Result.OK(); +// } +// +// @ApiOperation(value="鍙戦�佹帶鍒舵寚浠�", notes="鍚戞湇鍔$鍙戦�佹帶鍒舵寚浠わ紝鐢辨湇鍔$杞彂缁欐帶鍒舵ā鍧�") +// @PostMapping("/initDevice") +// public Result<?> initDevice() throws Exception { +// List<DryOpcDevice> list = opcDeviceService.list(); +// +// list.forEach(item -> { +// +// }); +// +// return Result.OK(); +// } +//} diff --git a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/listener/InitListener.java b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/listener/InitListener.java index 1e24954..32d78da 100644 --- a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/listener/InitListener.java +++ b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/listener/InitListener.java @@ -1,21 +1,12 @@ package org.jeecg.modules.dry.listener; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.google.common.io.ByteStreams; -import org.eclipse.milo.opcua.sdk.client.OpcUaClient; -import org.jeecg.modules.dry.common.CacheConstants; import org.jeecg.modules.dry.common.CommonDict; -import org.jeecg.modules.dry.vo.DryFault; import org.springframework.boot.context.event.ApplicationStartedEvent; import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; import java.io.IOException; import java.io.InputStream; -import java.util.HashMap; -import java.util.List; import java.util.Map; //@Component diff --git a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/runner/OpcCustomRunner.java b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/runner/OpcCustomRunner.java index e9149dd..98bb58d 100644 --- a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/runner/OpcCustomRunner.java +++ b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/runner/OpcCustomRunner.java @@ -1,58 +1,58 @@ -package org.jeecg.modules.dry.runner; - -import com.alibaba.fastjson.JSON; -import com.kangaroohy.milo.service.MiloService; -import lombok.extern.slf4j.Slf4j; -import org.jeecg.modules.dry.entity.DryOpcDevice; -import org.jeecg.modules.dry.service.IDryOpcDeviceService; -import org.jeecg.modules.dry.vo.DryOpcMsgVo; -import org.jeecg.modules.dry.websocket.DrySocket; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - -@Component -@Slf4j -public class OpcCustomRunner implements ApplicationRunner { - @Autowired - private MiloService miloService; - - - @Autowired - private IDryOpcDeviceService dryOpcDeviceService; - - @Autowired - private DrySocket drySocket; - @Override - public void run(ApplicationArguments args) throws Exception { - - subscript(); - - } - - private void subscript() throws Exception { - List<String> ids = new ArrayList<>(); - List<DryOpcDevice> list = dryOpcDeviceService.list(); - list.forEach(item -> { - ids.add(item.getIdentifier()); - }); -// ids.add("閫氶亾 1.璁惧 1.鏍囪 1"); -// ids.add("閫氶亾 1.璁惧 1.鏍囪 2"); -// ids.add("channel1.device1.tag1"); -// ids.add("channel1.device1.tag2"); -// ids.add("channel1.device1.tag3"); -// ids.add("channel1.device1.tag4"); -// ids.add("channel1.device1.tag5"); -// ids.add("channel1.device1.tag6"); - miloService.subscriptionFromOpcUa(ids, (id,value)->{ - log.info("subscription 鐐逛綅锛歿} 璁㈤槄鍒版秷鎭細{}", id, value); - - DryOpcMsgVo dryOpcMsgVo = new DryOpcMsgVo(id, (Boolean) value); - drySocket.pushMessage("1003", JSON.toJSONString(dryOpcMsgVo)); - } ); - } -} +//package org.jeecg.modules.dry.runner; +// +//import com.alibaba.fastjson.JSON; +//import com.kangaroohy.milo.service.MiloService; +//import lombok.extern.slf4j.Slf4j; +//import org.jeecg.modules.dry.entity.DryOpcDevice; +//import org.jeecg.modules.dry.service.IDryOpcDeviceService; +//import org.jeecg.modules.dry.vo.DryOpcMsgVo; +//import org.jeecg.modules.dry.websocket.DrySocket; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.ApplicationArguments; +//import org.springframework.boot.ApplicationRunner; +//import org.springframework.stereotype.Component; +// +//import java.util.ArrayList; +//import java.util.List; +// +//@Component +//@Slf4j +//public class OpcCustomRunner implements ApplicationRunner { +// @Autowired +// private MiloService miloService; +// +// +// @Autowired +// private IDryOpcDeviceService dryOpcDeviceService; +// +// @Autowired +// private DrySocket drySocket; +// @Override +// public void run(ApplicationArguments args) throws Exception { +// +// subscript(); +// +// } +// +// private void subscript() throws Exception { +// List<String> ids = new ArrayList<>(); +// List<DryOpcDevice> list = dryOpcDeviceService.list(); +// list.forEach(item -> { +// ids.add(item.getIdentifier()); +// }); +//// ids.add("閫氶亾 1.璁惧 1.鏍囪 1"); +//// ids.add("閫氶亾 1.璁惧 1.鏍囪 2"); +//// ids.add("channel1.device1.tag1"); +//// ids.add("channel1.device1.tag2"); +//// ids.add("channel1.device1.tag3"); +//// ids.add("channel1.device1.tag4"); +//// ids.add("channel1.device1.tag5"); +//// ids.add("channel1.device1.tag6"); +// miloService.subscriptionFromOpcUa(ids, (id,value)->{ +// log.info("subscription 鐐逛綅锛歿} 璁㈤槄鍒版秷鎭細{}", id, value); +// +// DryOpcMsgVo dryOpcMsgVo = new DryOpcMsgVo(id, (Boolean) value); +// drySocket.pushMessage("1003", JSON.toJSONString(dryOpcMsgVo)); +// } ); +// } +//} diff --git a/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/websocket/DrySocket1.java b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/websocket/DrySocket1.java new file mode 100644 index 0000000..61edc8e --- /dev/null +++ b/jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/websocket/DrySocket1.java @@ -0,0 +1,223 @@ +//package org.jeecg.modules.dry.websocket; +// +//import cn.hutool.core.bean.BeanUtil; +//import com.alibaba.fastjson.JSON; +//import com.alibaba.fastjson.JSONObject; +//import lombok.extern.slf4j.Slf4j; +//import org.jeecg.common.constant.DrySocketConst; +//import org.jeecg.common.util.SpringContextUtils; +//import org.jeecg.modules.dry.service.IDryRealTimeDataService; +//import org.jeecg.modules.dry.vo.RealTimeDataVo; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +// +//import javax.websocket.*; +//import javax.websocket.server.PathParam; +//import javax.websocket.server.ServerEndpoint; +//import java.util.Collection; +//import java.util.HashMap; +//import java.util.Map; +// +//@Slf4j +//@Component +//@ServerEndpoint("/drySocket/{tenantId}/{machineId}") +//public class DrySocket { +// +// /** +// * 褰撳墠 session +// */ +// private Session session; +// /** +// * 褰撳墠绉熸埛id +// */ +// private String tenantId; +// /** +// * 璁惧id锛岀敤浜庢爣璇嗗悓涓�绉熸埛锛屼笉鍚岃澶囩殑鏁版嵁 +// */ +// private String machineId; +// /** +// * 褰撳墠socket鍞竴id +// */ +// private String socketId; +// +// /** +// * 绉熸埛杩炴帴姹狅紝鍖呭惈鍗曚釜绉熸埛鐨勬墍鏈塻ocket杩炴帴锛� +// * 鍥犱负涓�涓鎴峰彲鑳芥墦寮�澶氫釜璁惧锛屽涓澶囧氨浼氭湁澶氫釜杩炴帴锛� +// * key鏄痶enantId锛寁alue鏄疢ap瀵硅薄锛涘瓙Map鐨刱ey鏄痬achineId锛寁alue鏄痙rySocket瀵硅薄 +// */ +// private Map<String, Map<String, DrySocket>> tenantPool = new HashMap<>(); +// /** +// * 杩炴帴姹狅紝鍖呭惈鎵�鏈塛ebSocket杩炴帴锛� +// * key鏄痵ocketId锛寁alue鏄痙rySocket瀵硅薄 +// */ +// private Map<String, DrySocket> machinePool = new HashMap<>(); +// +// /** +// * 鑾峰彇鏌愪釜绉熸埛鎵�鏈夌殑璁惧 +// */ +// public Map<String, DrySocket> getTenantPool(String tenantId) { +// return tenantPool.computeIfAbsent(tenantId, k -> new HashMap<>(5)); +// } +// +// /** +// * 鍚戝綋鍓嶇鎴峰彂閫佹秷鎭� +// * +// * @param message 娑堟伅鍐呭 +// */ +// public void sendMessage(String message) { +// try { +// this.session.getAsyncRemote().sendText(message); +// } catch (Exception e) { +// log.error("銆恉rySocket銆戞秷鎭彂閫佸け璐ワ細" + e.getMessage()); +// } +// } +// +// /** +// * 灏佽娑堟伅json +// * +// * @param data 娑堟伅鍐呭 +// */ +// public static String packageMessage(String type, Object data) { +// JSONObject message = new JSONObject(); +// message.put(DrySocketConst.TYPE, type); +// message.put(DrySocketConst.DATA, data); +// return message.toJSONString(); +// } +// +// /** +// * 鍚戞寚瀹氱鎴风殑鎵�鏈夎澶囧彂閫佹秷鎭� +// * +// * @param tenantId 鎺ユ敹娑堟伅鐨勭鎴稩D +// * @param message 娑堟伅鍐呭 +// */ +// public void sendMessageTo(String tenantId, String message) { +// Collection<DrySocket> values = getTenantPool(tenantId).values(); +// if (values.size() > 0) { +// for (DrySocket socketItem : values) { +// socketItem.sendMessage(message); +// } +// } else { +// log.warn("銆恉rySocket銆戞秷鎭彂閫佸け璐ワ細tenantId\"" + tenantId + "\"涓嶅瓨鍦ㄦ垨鏈湪绾匡紒"); +// } +// } +// +// /** +// * 鍚戞寚瀹氱鎴风殑鎸囧畾璁惧鍙戦�佹秷鎭� +// * +// * @param tenantId 鎺ユ敹娑堟伅鐨勭鎴稩D +// * @param message 娑堟伅鍐呭 +// */ +// public void sendMessageTo(String tenantId, String machineId, String message) { +// DrySocket socketItem = getTenantPool(tenantId).get(machineId); +// if (socketItem != null) { +// socketItem.sendMessage(message); +// } else { +// log.warn("銆恉rySocket銆戞秷鎭彂閫佸け璐ワ細tenantId\"" + tenantId + "\"鐨刴achineId\"" + machineId + "\"涓嶅瓨鍦ㄦ垨鏈湪绾匡紒"); +// } +// } +// +// /** +// * 鍚戝涓鎴风殑鎵�鏈夎澶囧彂閫佹秷鎭� +// * +// * @param tenantIds 鎺ユ敹娑堟伅鐨勭鎴稩D鏁扮粍 +// * @param message 娑堟伅鍐呭 +// */ +// public void sendMessageTo(String[] tenantIds, String message) { +// for (String tenantId : tenantIds) { +// this.sendMessageTo(tenantId, message); +// } +// } +// +// /** +// * 鍚戞墍鏈夌鎴风殑鎵�鏈夎澶囧彂閫佹秷鎭� +// * +// * @param message 娑堟伅鍐呭 +// */ +// public void sendMessageToAll(String message) { +// for (DrySocket socketItem : machinePool.values()) { +// socketItem.sendMessage(message); +// } +// } +// +// /** +// * websocket 寮�鍚繛鎺� +// */ +// @OnOpen +// public void onOpen(Session session, @PathParam("tenantId") String tenantId, @PathParam("machineId") String machineId) { +// try { +// this.tenantId = tenantId; +// this.machineId = machineId; +// this.socketId = tenantId + machineId; +// this.session = session; +// +// machinePool.put(this.socketId, this); +// getTenantPool(tenantId).put(this.machineId, this); +// +// log.info("銆恉rySocket銆戞湁鏂扮殑杩炴帴锛屾�绘暟涓�:" + machinePool.size()); +// log.info("ssss"+tenantPool.size()); +// } catch (Exception ignored) { +// } +// } +// +// /** +// * websocket 鏂紑杩炴帴 +// */ +// @OnClose +// public void onClose() { +// try { +// machinePool.remove(this.socketId); +// getTenantPool(this.tenantId).remove(this.machineId); +// +// log.info("銆恉rySocket銆戣繛鎺ユ柇寮�锛屾�绘暟涓�:" + machinePool.size()); +// } catch (Exception ignored) { +// } +// } +// +// /** +// * websocket 鏀跺埌娑堟伅 +// */ +// @OnMessage +// public void onMessage(String message) { +// log.info("銆恉rySocket銆憃nMessage:" + message); +// IDryRealTimeDataService realTimeDataService = SpringContextUtils.getBean(IDryRealTimeDataService.class); +// JSONObject json; +// try { +// json = JSON.parseObject(message); +// } catch (Exception e) { +// log.warn("銆恉rySocket銆戞敹鍒颁笉鍚堟硶鐨勬秷鎭�:" + message); +// return; +// } +// String type = json.getString(DrySocketConst.TYPE); +// switch (type) { +// // 蹇冭烦妫�娴� +// case DrySocketConst.TYPE_HB: +// this.sendMessage(DrySocket.packageMessage(type, true)); +// break; +// // 瀹炴椂鏁版嵁澶勭悊 +// case DrySocketConst.TYPE_RDT: +// Object o = json.get(DrySocketConst.DATA); +// RealTimeDataVo realTimeDataVo = BeanUtil.toBean(o, RealTimeDataVo.class); +// realTimeDataService.realTimeDataHandle(realTimeDataVo); +// break; +// +// default: +// log.warn("銆恉rySocket銆戞敹鍒颁笉璇嗗埆鐨勬秷鎭被鍨�:" + type); +// break; +// } +// +// +// } +// +// /** * 閰嶇疆閿欒淇℃伅澶勭悊 * @param session * @param t */ +// @OnError +// public void onError(Session session, Throwable t) { +// +////浠�涔堥兘涓嶆兂鎵撳嵃閮藉幓鎺夊氨濂戒簡 +// log.info("銆恮ebsocket娑堟伅銆戝嚭鐜版湭鐭ラ敊璇� "); +////鎵撳嵃閿欒淇℃伅锛屽鏋滀綘涓嶆兂鎵撳嵃閿欒淇℃伅锛屽幓鎺夊氨濂戒簡 +////杩欓噷鎵撳嵃鐨勪篃鏄� java.io.EOFException: null +// t.printStackTrace(); +// } +// +// +//} diff --git a/jeecg-module-dry/jeecg-module-dry-start/src/main/test/java/com/lanbao/AiTest.java b/jeecg-module-dry/jeecg-module-dry-start/src/main/test/java/com/lanbao/AiTest.java index 4f2a6c3..0c39a55 100644 --- a/jeecg-module-dry/jeecg-module-dry-start/src/main/test/java/com/lanbao/AiTest.java +++ b/jeecg-module-dry/jeecg-module-dry-start/src/main/test/java/com/lanbao/AiTest.java @@ -1,27 +1,27 @@ -package com.lanbao; - -import ai.djl.modality.Classifications; -import org.jeecg.modules.dry.util.HerbUtil; -import org.junit.Test; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.List; - -public class AiTest { - @Test - public void test() { - try { - String img = "E:\\testImg\\szp1.jpg"; - HerbUtil herbUtil = new HerbUtil(); - File file = new File(img); - InputStream is = new FileInputStream(file); - List<Classifications.Classification> predict = herbUtil.predict(is); - System.out.println(predict); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } - } -} +//package com.lanbao; +// +//import ai.djl.modality.Classifications; +//import org.jeecg.modules.dry.util.HerbUtil; +//import org.junit.Test; +// +//import java.io.File; +//import java.io.FileInputStream; +//import java.io.FileNotFoundException; +//import java.io.InputStream; +//import java.util.List; +// +//public class AiTest { +// @Test +// public void test() { +// try { +// String img = "E:\\testImg\\szp1.jpg"; +// HerbUtil herbUtil = new HerbUtil(); +// File file = new File(img); +// InputStream is = new FileInputStream(file); +// List<Classifications.Classification> predict = herbUtil.predict(is); +// System.out.println(predict); +// } catch (FileNotFoundException e) { +// throw new RuntimeException(e); +// } +// } +//} diff --git a/jeecg-server-cloud/jeecg-cloud-gateway/src/main/resources/application.yml b/jeecg-server-cloud/jeecg-cloud-gateway/src/main/resources/application.yml index b3cc6f1..10ece95 100644 --- a/jeecg-server-cloud/jeecg-cloud-gateway/src/main/resources/application.yml +++ b/jeecg-server-cloud/jeecg-cloud-gateway/src/main/resources/application.yml @@ -27,8 +27,8 @@ allowedOriginPatterns: "*" allowedMethods: "*" allowedHeaders: "*" -# inetutils: -# preferred-networks: 192.168 + inetutils: + preferred-networks: 192.168 #Sentinel閰嶇疆 sentinel: transport: diff --git a/jeecg-server-cloud/jeecg-cloud-nacos/src/main/resources/application.yml b/jeecg-server-cloud/jeecg-cloud-nacos/src/main/resources/application.yml index 74bfc97..4e4020f 100644 --- a/jeecg-server-cloud/jeecg-cloud-nacos/src/main/resources/application.yml +++ b/jeecg-server-cloud/jeecg-cloud-nacos/src/main/resources/application.yml @@ -14,7 +14,7 @@ password: '0': ${MYSQL-PWD:123456} url: - '0': jdbc:mysql://${MYSQL-HOST:jeecg-boot-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:nacos}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true + '0': jdbc:mysql://${MYSQL-HOST:localhost}:${MYSQL-PORT:3306}/${MYSQL-DB:nacos-herb}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true user: '0': ${MYSQL-USER:root} management: -- Gitblit v1.9.3