Przeglądaj źródła

根据组织id获取点位

丁治程 9 miesięcy temu
rodzic
commit
3987eb3781

+ 6 - 4
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeCollectData/controller/IotedgeCollectDataController.java

@@ -177,16 +177,18 @@ public class IotedgeCollectDataController extends JeecgController<IotedgeCollect
 	 @AutoLog(value = "采集数据-获取点位")
 	 @ApiOperation(value="采集数据-获取点位", notes="采集数据-获取点位")
 	 @PostMapping(value = "/getTagInfo")
-	 public Result<List<IoTEdgeDevices>> getTagInfo(HttpServletRequest request) {
-		 return  Result.OK(iotedgeCollectDataService.getDevicesInfoById(request));
+	 public Result<List<IoTEdgeDevices>> getTagInfo(@RequestBody String groupId,HttpServletRequest request) {
+		 JSONObject jsonObject = JSONObject.parseObject(groupId);
+		 String groupId1 = (String) jsonObject.get("groupId");
+		 return  Result.OK(iotedgeCollectDataService.getDevicesInfoById(groupId1,request));
 	 }
 
 
 	 @AutoLog(value = "采集数据-调用接口测试")
 	 @ApiOperation(value="采集数据-调用接口测试", notes="采集数据-调用接口测试")
 	 @PostMapping(value = "/test")
-	 public Result<List<IoTEdgeDevices>> test(HttpServletRequest request) {
-		 return  Result.OK(iotedgeCollectDataService.getDevicesInfoById(request));
+	 public JSONObject test(@RequestParam(name = "groupId") String groupId,@RequestParam(name = "elToken") String elToken) {
+		 return  restClientService.getGroupDevicesInfo(groupId,elToken);
 	 }
 
 	 @AutoLog(value = "IoTEdge-发送邮件测试")

+ 1 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeCollectData/service/IIotedgeCollectDataService.java

@@ -21,7 +21,7 @@ import java.util.Map;
  */
 public interface IIotedgeCollectDataService extends IService<IotedgeCollectData> {
 
-    List<IoTEdgeDevices> getDevicesInfoById(HttpServletRequest request);
+    List<IoTEdgeDevices> getDevicesInfoById(String groupId,HttpServletRequest request);
 
     IotedgeCollectData getOneInfo(String deviceId, String moduleName, String tagName, String beginDate);
 

+ 21 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeCollectData/service/RestClientService.java

@@ -65,11 +65,31 @@ public class RestClientService {
     /**
     *   author: dzc
     *   version: 1.0
+    *   des: 根据组织id 获取设备信息
+    *   date: 2024/8/9
+    */
+
+    public JSONObject getGroupDevicesInfo(String groupId,String elToken){
+        //String url = "http://127.0.0.1:8082/v1/devices?deviceType=&groupID="+groupId+"&projectID=all&productID=all";
+        String url = configService.getConfigValue(ConfigInfo.IOTEDGE_GETINFOBYGROUPID)+groupId+"&projectID=all&productID=all";
+        //String accessToken = getAccessToken();
+        HttpHeaders headers = new HttpHeaders();
+        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
+        headers.setContentType(type);
+        headers.add("Authorization", "Bearer " + elToken);
+        HttpEntity<String> httpEntity = new HttpEntity<String>(null, headers);
+        ResponseEntity<JSONObject> response = restTemplate.exchange(url, HttpMethod.GET,httpEntity, JSONObject.class);
+        return response.getBody();
+    }
+
+    /**
+    *   author: dzc
+    *   version: 1.0
     *   des: 调用IoTEdge接口 获取所有设备信息
     *   date: 2024/5/29
     */
     public JSONObject getAllDevicesInfo(String elToken){
-        //String url = "http://127.0.0.1:8082/v1/devices?deviceType=&projectID=all&productID=all";
+        //String url = "http://127.0.0.1:8082/v1/devices?deviceType=&groupID="+groupId+"&projectID=all&productID=all";
         String url = configService.getConfigValue(ConfigInfo.GETALLDEVICESINFO);
         //String accessToken = getAccessToken();
         HttpHeaders headers = new HttpHeaders();

+ 2 - 2
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeCollectData/service/impl/IotedgeCollectDataServiceImpl.java

@@ -66,7 +66,7 @@ public class IotedgeCollectDataServiceImpl extends ServiceImpl<IotedgeCollectDat
     private static final String ERROR_CODE_TWO = "500";
 
     @Override
-    public List<IoTEdgeDevices> getDevicesInfoById(HttpServletRequest request) {
+    public List<IoTEdgeDevices> getDevicesInfoById(String groupId,HttpServletRequest request) {
 
         String elToken = "";
         Cookie[] cookies = request.getCookies();
@@ -80,7 +80,7 @@ public class IotedgeCollectDataServiceImpl extends ServiceImpl<IotedgeCollectDat
 
 
         Map<String, String> devicesMap = new HashMap<>();
-        JSONObject message1 = restClientService.getAllDevicesInfo(elToken);
+        JSONObject message1 = restClientService.getGroupDevicesInfo(groupId,elToken);
         ArrayList<Map<String,Object>> maps = (ArrayList<Map<String, Object>>) message1.get("items");
         for (Map<String,Object> device : maps) {
             devicesMap.put(device.get("deviceName").toString(),device.get("deviceId").toString());

+ 3 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeConfig/util/ConfigInfo.java

@@ -84,4 +84,7 @@ public class ConfigInfo {
 
     /** IoTEdge-分配用户角色(新增/修改/删除) */
     public static String IOTEDGE_SETUSERROLE = "IoTEdge.SetUserRloe";
+
+    /** IoTEdge-根据组织id查询设备信息 */
+    public static String IOTEDGE_GETINFOBYGROUPID = "IoTEdge.getInfoByGroupID";
 }