Przeglądaj źródła

iot-data-analysis接口header中增加groupCode

lixing 2 lat temu
rodzic
commit
f773e52af3

+ 3 - 6
src/main/java/com/persagy/apm/report/common/utils/HttpUtils.java

@@ -1,8 +1,5 @@
 package com.persagy.apm.report.common.utils;
 
-import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
-import com.persagy.apm.report.detail.model.vo.AttrDefineVO;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpVersion;
 import org.apache.http.client.config.RequestConfig;
@@ -15,7 +12,6 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.http.util.EntityUtils;
 
 import java.nio.charset.Charset;
-import java.util.List;
 
 public class HttpUtils {
     private final static PoolingHttpClientConnectionManager CONNECTION_MANAGER = new PoolingHttpClientConnectionManager();
@@ -38,12 +34,13 @@ public class HttpUtils {
                 .setDefaultRequestConfig(requestConfig).build();
     }
 
-    public static String postJson(String url, String json) throws Exception {
+    public static String postJson(String url, String body, String groupCode) throws Exception {
         HttpPost httpPost = new HttpPost(url);
         //使用http1.0协议
         httpPost.setProtocolVersion(HttpVersion.HTTP_1_0);
         httpPost.addHeader("Content-type", "application/json");
-        httpPost.setEntity(new StringEntity(json, Charset.forName("UTF-8")));
+        httpPost.addHeader("groupCode", groupCode);
+        httpPost.setEntity(new StringEntity(body, Charset.forName("UTF-8")));
         CloseableHttpResponse response = HTTP_CLIENT.execute(httpPost);
         int statusCode = response.getStatusLine().getStatusCode();
         if (statusCode != 200 && statusCode != 201) {

+ 28 - 28
src/main/java/com/persagy/apm/report/dependencies/centermiddleware/service/impl/ICenterMiddlewareWebServiceImp.java

@@ -51,32 +51,32 @@ public class ICenterMiddlewareWebServiceImp implements ICenterMiddlewareWebServi
     }
 
 
-    private List<String> getObjectIdList(String pjId, String groupCode, List<String> classCodeList) {
-        log.info("查询对象信息列表开始,项目:" + pjId + "groupCode:" + groupCode + "classCodeList:" + classCodeList);
-        if (StringUtils.isEmpty(pjId) || StringUtils.isEmpty(groupCode) || CollectionUtils.isEmpty(classCodeList)) {
-            log.info("查询中台对象信息时参数为空,故不进行查询");
-            return new ArrayList<>();
-        }
-        List<String> resultList = new ArrayList<>();
-        try {
-            QueryObjectInfoDTO queryObjectInfoDTO = new QueryObjectInfoDTO();
-            queryObjectInfoDTO.setProjectId(pjId);
-            queryObjectInfoDTO.setGroupCode(groupCode);
-            Criteria criteria = new Criteria();
-            criteria.setClassCode(classCodeList);
-            queryObjectInfoDTO.setCriteria(criteria);
-            PoemsFeignResponse<ObjectInfoVO> response = centerMiddlewareWebClient.getObjectInfo(queryObjectInfoDTO);
-            List<ObjectInfoVO> objectInfoVOList = response.getContent();
-            log.info("中台返回对象结果:" + objectInfoVOList);
-            if (!CollectionUtils.isEmpty(objectInfoVOList)) {
-                for (ObjectInfoVO vo : objectInfoVOList) {
-                    resultList.add(vo.getId());
-                }
-            }
-        } catch (Exception e) {
-            throw new RuntimeException("查询中台对象信息时异常", e);
-        }
-        log.info("查询对象信息列表结束");
-        return resultList;
-    }
+//    private List<String> getObjectIdList(String pjId, String groupCode, List<String> classCodeList) {
+//        log.info("查询对象信息列表开始,项目:" + pjId + "groupCode:" + groupCode + "classCodeList:" + classCodeList);
+//        if (StringUtils.isEmpty(pjId) || StringUtils.isEmpty(groupCode) || CollectionUtils.isEmpty(classCodeList)) {
+//            log.info("查询中台对象信息时参数为空,故不进行查询");
+//            return new ArrayList<>();
+//        }
+//        List<String> resultList = new ArrayList<>();
+//        try {
+//            QueryObjectInfoDTO queryObjectInfoDTO = new QueryObjectInfoDTO();
+//            queryObjectInfoDTO.setProjectId(pjId);
+//            queryObjectInfoDTO.setGroupCode(groupCode);
+//            Criteria criteria = new Criteria();
+//            criteria.setClassCode(classCodeList);
+//            queryObjectInfoDTO.setCriteria(criteria);
+//            PoemsFeignResponse<ObjectInfoVO> response = centerMiddlewareWebClient.getObjectInfo(queryObjectInfoDTO);
+//            List<ObjectInfoVO> objectInfoVOList = response.getContent();
+//            log.info("中台返回对象结果:" + objectInfoVOList);
+//            if (!CollectionUtils.isEmpty(objectInfoVOList)) {
+//                for (ObjectInfoVO vo : objectInfoVOList) {
+//                    resultList.add(vo.getId());
+//                }
+//            }
+//        } catch (Exception e) {
+//            throw new RuntimeException("查询中台对象信息时异常", e);
+//        }
+//        log.info("查询对象信息列表结束");
+//        return resultList;
+//    }
 }

+ 1 - 1
src/main/java/com/persagy/apm/report/dependencies/iotdataanalysis/service/impl/IDataAnalysisWebServiceImpl.java

@@ -42,7 +42,7 @@ public class IDataAnalysisWebServiceImpl implements IDataAnalysisWebService {
             paramObject.put("alarmStartTime", startTime);
             paramObject.put("alarmEndTime", endTime);
             String url = iotDataAnalysisUrl + "/alarm/show/view/queryList";
-            String response = HttpUtils.postJson(url, paramObject.toString());
+            String response = HttpUtils.postJson(url, paramObject.toString(), groupCode);
             JSONObject responseObject = JSONObject.parseObject(response);
             if (DataConstants.SUCCESS.equals(responseObject.getString("respMsg"))) {
                 List<Map> content = (List<Map>) responseObject.get("content");