From d097b6d0ede9a50036f2e57e04832a2d916ec60b Mon Sep 17 00:00:00 2001
From: liriming <1343021927@qq.com>
Date: 星期四, 20 三月 2025 18:08:47 +0800
Subject: [PATCH] demo

---
 src/main/java/com/iailab/sdk/demo/HttpClientDemo.java     |   19 +++++++--
 src/test/java/com/iailab/sdk/demo/HttpClientDemoTest.java |   48 ++++++++++++++----------
 pom.xml                                                   |   19 ++++-----
 src/main/resources/application.yaml                       |   16 +++++---
 4 files changed, 62 insertions(+), 40 deletions(-)

diff --git a/pom.xml b/pom.xml
index 47154b5..dfc0ce5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,6 @@
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
         </dependency>
 
         <dependency>
@@ -31,16 +30,16 @@
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
 
-<!--        <dependency>-->
-<!--            <groupId>com.iailab</groupId>-->
-<!--            <artifactId>iailab-plat-sdk</artifactId>-->
-<!--            <version>1.0.0</version>-->
-<!--        </dependency>-->
+        <dependency>
+            <groupId>com.iailab</groupId>
+            <artifactId>iailab-plat-sdk</artifactId>
+            <version>1.0.0</version>
+        </dependency>
 
-<!--        <dependency>-->
-<!--            <groupId>junit</groupId>-->
-<!--            <artifactId>junit</artifactId>-->
-<!--        </dependency>-->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
 
 <!--        <dependency>-->
 <!--            <groupId>com.fasterxml.jackson.core</groupId>-->
diff --git a/src/main/java/com/iailab/sdk/demo/HttpClientDemo.java b/src/main/java/com/iailab/sdk/demo/HttpClientDemo.java
index ecdf09c..6ad0804 100644
--- a/src/main/java/com/iailab/sdk/demo/HttpClientDemo.java
+++ b/src/main/java/com/iailab/sdk/demo/HttpClientDemo.java
@@ -1,11 +1,12 @@
 package com.iailab.sdk.demo;
 
+import com.alibaba.fastjson.JSONObject;
 import com.iailab.sdk.auth.client.IailabClient;
 import com.iailab.sdk.auth.client.common.pojo.CommonResult;
-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 com.iailab.sdk.auth.client.common.pojo.PageResult;
+import com.iailab.sdk.auth.client.dto.StAlarmAndSuggestPageReqDTO;
+import com.iailab.sdk.auth.client.dto.StAlarmAndSuggestRespDTO;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 import java.util.Map;
@@ -22,4 +23,14 @@
     public CommonResult<Map<String, Object>> queryPointsRealValue(@RequestBody List<String> pointNos) {
         return IailabClient.getInstance().queryPointsRealValue(pointNos);
     }
+
+    @PostMapping("/alarm-suggest/page")
+    public CommonResult<PageResult<StAlarmAndSuggestRespDTO>> getAlarmAndSuggestPage(@RequestBody StAlarmAndSuggestPageReqDTO reqVO) {
+        return IailabClient.getInstance().getAlarmAndSuggestPage(reqVO);
+    }
+
+    @GetMapping("/handleHttp")
+    public CommonResult<Object> handleHttp(@RequestParam("method") String method, @RequestParam("url") String url, @RequestParam("params") Map<String, Object> params) {
+        return IailabClient.getInstance().handleHttp(method,url,params);
+    }
 }
diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml
index 62d4de5..3b0b185 100644
--- a/src/main/resources/application.yaml
+++ b/src/main/resources/application.yaml
@@ -11,10 +11,14 @@
 # 平台配置项,设置当前项目所有自定义的配置,token中的配置需要事先在平台配置好
 iailab:
   token:
-    base-url: http://172.16.8.100/admin-api #平台接口url,使用时需修改成真实的ip和端口
-    tenant-id: 172 #租户id
-    client-id: shasteel #租户OAuth2客户端id
-    client-secret: S3mYv7LkF1xJtQqWp9rZ2cVb8N6hT0D #租户OAuth2客户端密钥
-    username: shasteel
+#    base-url: http://127.0.0.1:48080/admin-api #平台接口url,使用时需修改成真实的ip和端口
+#    tenant-id: 172 #租户id
+#    client-id: shasteel #租户OAuth2客户端id
+#    client-secret: S3mYv7LkF1xJtQqWp9rZ2cVb8N6hT0D #租户OAuth2客户端密钥
+#    username: shasteel
 
-debug: true
+        base-url: http://127.0.0.1:48080/admin-api #平台接口url,使用时需修改成真实的ip和端口
+        tenant-id: 176 #租户id
+        client-id: ansteel #租户OAuth2客户端id
+        client-secret: q3vY7K9PmFjW1xLbN6rTtZz2cV4B5sD0 #租户OAuth2客户端密钥
+        username: ansteel
diff --git a/src/test/java/com/iailab/sdk/demo/HttpClientDemoTest.java b/src/test/java/com/iailab/sdk/demo/HttpClientDemoTest.java
index 7a62ee0..ee15eeb 100644
--- a/src/test/java/com/iailab/sdk/demo/HttpClientDemoTest.java
+++ b/src/test/java/com/iailab/sdk/demo/HttpClientDemoTest.java
@@ -1,12 +1,20 @@
 package com.iailab.sdk.demo;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.iailab.sdk.auth.client.common.pojo.CommonResult;
+import com.iailab.sdk.auth.client.common.pojo.PageResult;
+import com.iailab.sdk.auth.client.dto.StAlarmAndSuggestPageReqDTO;
+import com.iailab.sdk.auth.client.dto.StAlarmAndSuggestRespDTO;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 
@@ -17,33 +25,33 @@
     @Autowired
     private HttpClientDemo httpClientDemo;
 
-
     @Test
-    public void authenticate() {
-        httpClientDemo.authenticate();
+    public void testQueryPointsRealValue() {
+        List<String> pointNos = new ArrayList<>();
+        pointNos.add("F0000120076");
+        CommonResult<Map<String, Object>> commonResult = httpClientDemo.queryPointsRealValue(pointNos);
+        System.out.println(commonResult.getData());
     }
 
     @Test
-    public void refreshToken() throws Exception {
-        httpClientDemo.refreshToken();
-    }
-
-
-    @Test
-    public void testQueryPointsRealValue() throws Exception {
-        CommonResult<Map<String, Object>> mapCommonResult = httpClientDemo.queryPointsRealValue();
-        System.out.println(mapCommonResult.getData());
+    public void testGetAlarmAndSuggestPage() {
+        StAlarmAndSuggestPageReqDTO reqVO = new StAlarmAndSuggestPageReqDTO();
+        reqVO.setObj("Air");
+        CommonResult<PageResult<StAlarmAndSuggestRespDTO>> commonResult = httpClientDemo.getAlarmAndSuggestPage(reqVO);
+        System.out.println(commonResult.getData().getList());
     }
 
     @Test
-    public void testDoHttpPost() throws Exception {
-        // 准备参数
-        httpClientDemo.doHttpPost();
+    public void testHandleHttp() {
+        Map<String, Object> params = new HashMap<>();
+        params.put("chartCode","BFG_PRED01");
+        String url = "/ansteel/api/mcs/predict-data/charts";
+        CommonResult<Object> commonResult = httpClientDemo.handleHttp("POST",url,params);
+        System.out.println(commonResult.getData());
+
+//        String url = "/ansteel/api/mcs/power-run-state/list";
+//        CommonResult<Object> commonResult = httpClientDemo.handleHttp("GET",url,params);
+//        System.out.println(commonResult.getData());
     }
 
-    @Test
-    public void testDoHttpGet() throws Exception {
-        // 准备参数
-        httpClientDemo.doHttpGet();
-    }
 }

--
Gitblit v1.9.3