Kaynağa Gözat

项目设备列表

JCM 4 yıl önce
ebeveyn
işleme
a331e9481b

+ 4 - 0
src/main/java/com/ebei/screen/common/constants/EbaSystemConstants.java

@@ -28,4 +28,8 @@ public interface EbaSystemConstants {
      * 02、获取当前用户名下项目列表
      */
     String projectGetList = baseUrl + "project/getList";
+    /**
+     * 03、获取当前项目id
+     */
+    String deviceGetDevice = baseUrl + "mobject/getList";
 }

+ 35 - 3
src/main/java/com/ebei/screen/common/util/EbaUtils.java

@@ -8,6 +8,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.stereotype.Component;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * EBA大屏工具类
  *
@@ -22,6 +26,8 @@ public class EbaUtils {
 
     private static MongoTemplate mongoTemplate;
 
+    private static Levi PARAMS = Levi.by("clientId", EbaSystemConstants.cliendId).set("clientSecret", EbaSystemConstants.clientSecret);
+
     @Autowired
     public void setMongoTemplate(MongoTemplate mongoTemplate) {
         EbaUtils.mongoTemplate = mongoTemplate;
@@ -43,12 +49,38 @@ public class EbaUtils {
      * @return
      */
     public static String getToken() {
-        Levi params = Levi.by("clientId", EbaSystemConstants.cliendId).set("clientSecret", EbaSystemConstants.clientSecret);
         String result = HttpRequest.post(EbaSystemConstants.tokenGetInfo)
                 .header("content-type", "application/json")
-                .body(JSON.toJSONString(params))
+                .body(JSON.toJSONString(PARAMS))
                 .execute().body();
-        log.info("#########> 获取token:{} 参数:{}", result, JSON.toJSONString(params));
+        log.info("#########> 获取token:{} 参数:{}", result, JSON.toJSONString(PARAMS));
         return LeviUtils.getJsonFieldOne(result, "data.token", String.class);
     }
+
+    /**
+     * 当前用户下项目列表
+     * @return
+     */
+    public static List<Map> getProjectList(){
+        String result = HttpRequest.post(EbaSystemConstants.projectGetList)
+                .header("token", getToken())
+                .body(JSON.toJSONString(PARAMS))
+                .execute().body();
+        log.info("#########> 获取token:{} 参数:{}", result, JSON.toJSONString(PARAMS));
+        return LeviUtils.getJsonFieldMany(result, "data.projectList",Map.class);
+    }
+
+    /**
+     * 项目下所有设备列表
+     * @return
+     */
+    public static List<Map> getDeviceList(){
+        String result = HttpRequest.post(EbaSystemConstants.deviceGetDevice)
+                .body("{\n\t\"projectId\":1250\n}")
+                .header("token", getToken())
+                .body(JSON.toJSONString(PARAMS))
+                .execute().body();
+        log.info("#########> 获取token:{} 参数:{}", result, JSON.toJSONString(PARAMS));
+        return LeviUtils.getJsonFieldMany(result, "data.projectList",Map.class);
+    }
 }

+ 7 - 0
src/main/java/com/ebei/screen/controller/eba/EbaSystemController.java

@@ -1,6 +1,7 @@
 package com.ebei.screen.controller.eba;
 
 import com.ebei.screen.common.response.ResponseBean;
+import com.ebei.screen.common.response.ResponseBuilder;
 import com.ebei.screen.modules.po.Test;
 import com.ebei.screen.service.EbaSystemService;
 import io.swagger.annotations.Api;
@@ -29,5 +30,11 @@ public class EbaSystemController {
     public ResponseBean<List<Test>> test() {
         return ebaSystemService.test();
     }
+    @ApiOperation("冀朝明的测试")
+    @PostMapping("/testJCM")
+    public ResponseBean<String> testJCM() {
+        ebaSystemService.getProjectList();
+        return ResponseBuilder.ok("可以的");
+    }
 
 }

+ 2 - 0
src/main/java/com/ebei/screen/service/EbaSystemService.java

@@ -14,4 +14,6 @@ import java.util.List;
 public interface EbaSystemService {
 
     ResponseBean<List<Test>> test();
+
+    void getProjectList();
 }

+ 10 - 0
src/main/java/com/ebei/screen/service/impl/EbaSystemServiceImpl.java

@@ -2,6 +2,7 @@ package com.ebei.screen.service.impl;
 
 import com.ebei.screen.common.response.ResponseBean;
 import com.ebei.screen.common.response.ResponseBuilder;
+import com.ebei.screen.common.util.EbaUtils;
 import com.ebei.screen.modules.po.Test;
 import com.ebei.screen.service.EbaSystemService;
 import lombok.extern.slf4j.Slf4j;
@@ -10,7 +11,9 @@ import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * EBA系统大屏
@@ -31,4 +34,11 @@ public class EbaSystemServiceImpl implements EbaSystemService {
         List<Test> all = mongoTemplate.findAll(Test.class);
         return ResponseBuilder.ok(all);
     }
+
+    @Override
+    public void getProjectList() {
+        List<Map> projectList = EbaUtils.getProjectList();
+        //mongoTemplate.dropCollection("test");
+        mongoTemplate.insert(projectList,"test");
+    }
 }