Explorar o código

finish read meter modal

java110 %!s(int64=3) %!d(string=hai) anos
pai
achega
bf3167ab30

+ 31 - 0
service-common/src/main/java/com/java110/common/smartMeter/factory/zhongkong/WyRequestUtils.java

@@ -97,5 +97,36 @@ public class WyRequestUtils {
         return response.getBody();
     }
 
+    /**
+     * 请求充电桩 接口
+     * <p>
+     * MappingCache.getValue(DING_DING_DOMAIN, DING_DING_APP_ID),
+     * MappingCache.getValue(DING_DING_DOMAIN, DING_DING_APP_SECURE
+     *
+     * @param url
+     * @param reqMap
+     * @param httpMethod
+     * @return
+     * @throws Exception
+     */
+    public static String executeReads(String url, Map<String, String> reqMap, HttpMethod httpMethod)  {
+        RestTemplate outRestTemplate = ApplicationContextFactory.getBean("outRestTemplate", RestTemplate.class);
+        HttpHeaders httpHeaders = new HttpHeaders();
+        HttpEntity httpEntity = null;
+        if(reqMap != null) {
+            //reqMap.put("sign", getSign(reqMap));
+            httpEntity = new HttpEntity(JSONObject.toJSONString(reqMap), httpHeaders);
+        }else{
+            httpEntity = new HttpEntity("", httpHeaders);
+        }
+        ResponseEntity<String> response = null;
+        try {
+            response = outRestTemplate.exchange(url, httpMethod, httpEntity, String.class);
+        } catch (HttpStatusCodeException e) {
+            logger.error("请求异常", e.getResponseBodyAsString());
+            return e.getResponseBodyAsString();
+        }
 
+        return response.getBody();
+    }
 }

+ 1 - 2
service-common/src/main/java/com/java110/common/smartMeter/factory/zhongkong/ZhongkongDianBiaoFactoryAdaptImpl.java

@@ -128,9 +128,8 @@ public class ZhongkongDianBiaoFactoryAdaptImpl implements ISmartMeterFactoryAdap
         Map reqParams = new HashMap();
         reqParams.put("callbackUrl",UrlCache.getOwnerUrl() + NOTIFY_URL);
         reqParams.put("bhList",bhLists);
-        String request_content = JSON.toJSONString(req);
 
-        String response = WyRequestUtils.execute(READS_URL, reqParams, HttpMethod.GET);
+        String response = WyRequestUtils.executeReads(READS_URL, reqParams, HttpMethod.GET);
 
         JSONObject paramOut = JSONObject.parseObject(response);