From 09fe50d59e2f1e2261d376eb49ad6c40301f25b4 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期五, 10 五月 2024 16:08:59 +0800
Subject: [PATCH] 修改IP与数据库连接

---
 springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java |   81 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java
new file mode 100644
index 0000000..54f3223
--- /dev/null
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java
@@ -0,0 +1,81 @@
+package com.example.springboot.component;
+
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Arrays;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+
+
+import org.apache.commons.io.FileUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.stereotype.Component;
+
+@Component
+public class PlcParameter extends Thread {
+
+//  private final MessageSender messageSender;
+//
+//  public PlcParameter(MessageSender messageSender) {
+//    this.messageSender = messageSender;
+//  }
+
+  @Override
+  public void run() {
+    while (this != null) {
+      try {
+//        try {
+//          RabbitMQUtils.sendMessage("Hello, world!", "module_queue");
+//        } catch (Exception e) {
+//          e.printStackTrace();
+//        }
+//        try {
+//          RabbitMQUtils.receiveMessage("module_queue");
+//        } catch (Exception e) {
+//          e.printStackTrace();
+//        }
+//        String message = "Hello, RabbitMQ!";
+//        messageSender.sendMessage(message);
+        Thread.sleep(500);
+
+      } catch (InterruptedException e) {
+        e.printStackTrace();
+      }
+
+
+      JSONObject jsonObject = new JSONObject();
+      jsonObject.put("key1", "value1");
+      jsonObject.put("key2", 123);
+      JSONArray jsonArray = new JSONArray();
+      jsonArray.add("item1");
+      jsonArray.add("item2");
+      jsonObject.put("key3", jsonArray);
+
+      try {
+        // 灏� JSON 瀵硅薄杞崲涓哄瓧绗︿覆骞跺彂閫佸埌闃熷垪//RabbitMQUtils.sendJsonMessage(jsonObject, "json_queue");
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+
+      try {
+        // 浠庨槦鍒楁帴鏀跺苟瑙f瀽 JSON 娑堟伅涓� JSONObject 瀵硅薄
+        JSONObject receivedJsonObject = RabbitMQUtils.receiveJsonMessage(JSONObject.class, "json_queue");
+        System.out.println(receivedJsonObject.toString());
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+    }
+  }
+
+
+}

--
Gitblit v1.8.0