|
@@ -0,0 +1,169 @@
|
|
|
+package com.hhwy.qbeqsjy.kafka.service;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.hhwy.qbeqsjy.common.HttpClient;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.http.NameValuePair;
|
|
|
+import org.apache.http.message.BasicNameValuePair;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 同行类数据查询业务逻辑
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class SameTravelService {
|
|
|
+
|
|
|
+ @Value("${fwkfpt.token.url}")
|
|
|
+ private String fwkfptTokenUrl;
|
|
|
+ @Value("${fwkfpt.uniQuery.url}")
|
|
|
+ private String fwkfptUniQueryUrl;
|
|
|
+
|
|
|
+ public void callService_3(){
|
|
|
+ Map<String, Object> tokenHeaderParamsMap = new HashMap<>();
|
|
|
+ tokenHeaderParamsMap.put("Content-Type", "application/x-www-form-urlencoded");
|
|
|
+ Map<String, Object> userTokenMap = new HashMap<>();
|
|
|
+ userTokenMap.put("type", "user");
|
|
|
+ userTokenMap.put("policeNo", "000000");
|
|
|
+ userTokenMap.put("userId", "-1");
|
|
|
+ Map<String, Object> appTokenMap = new HashMap<>();
|
|
|
+ appTokenMap.put("appId", "A-17865251449995264");
|
|
|
+ appTokenMap.put("userToken", JSON.toJSONString(userTokenMap));
|
|
|
+ List<NameValuePair> nameValuePairs = new ArrayList<>();
|
|
|
+ nameValuePairs.add(new BasicNameValuePair("userToken", JSON.toJSONString(userTokenMap)));
|
|
|
+ nameValuePairs.add(new BasicNameValuePair("appToken", JSON.toJSONString(appTokenMap)));
|
|
|
+ nameValuePairs.add(new BasicNameValuePair("serviceid", "7251188999258112"));
|
|
|
+ HttpClient httpClient = new HttpClient();
|
|
|
+ String content = httpClient.postResourceFWKFPT(fwkfptTokenUrl, nameValuePairs, tokenHeaderParamsMap);
|
|
|
+ JSONObject resultJSONobj = JSON.parseObject(content);
|
|
|
+ String appTokenId = "";
|
|
|
+ String userTokenId = "";
|
|
|
+ if(resultJSONobj != null){
|
|
|
+ String appTokenJSONStr = resultJSONobj.getString("appTokenId");
|
|
|
+ String userTokenJSONStr = resultJSONobj.getString("userTokenId");
|
|
|
+ if(StringUtils.isBlank(appTokenJSONStr) && StringUtils.isBlank(userTokenJSONStr)){
|
|
|
+ String message = resultJSONobj.getString("message");
|
|
|
+ log.error("获取【服务开放平台 # 权限认证令牌】 令牌创建失败,异常信息:{}", message);
|
|
|
+ }
|
|
|
+ appTokenId = JSON.parseObject(appTokenJSONStr).getString("appToken");
|
|
|
+ userTokenId = JSON.parseObject(userTokenJSONStr).getString("userToken");
|
|
|
+ log.info("获取【服务开放平台 # 权限认证令牌】 令牌创建成功,响应消息:{}", content);
|
|
|
+ }
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
+ Map<String, Object> headerParamsMap = new HashMap<>();
|
|
|
+ headerParamsMap.put("Content-Type", "application/json");
|
|
|
+ headerParamsMap.put("apptoken", appTokenId);
|
|
|
+ headerParamsMap.put("usertoken", userTokenId);
|
|
|
+ headerParamsMap.put("userid", "-1");
|
|
|
+ headerParamsMap.put("subid", "A-17865251449995264");
|
|
|
+ headerParamsMap.put("serviceid", "7251188999258112");
|
|
|
+ headerParamsMap.put("police-no", "000000");
|
|
|
+ headerParamsMap.put("app-id", "1");
|
|
|
+ headerParamsMap.put("role-id", "1");
|
|
|
+ httpClient.sendGetRequst(fwkfptUniQueryUrl, headerParamsMap);
|
|
|
+ log.info("调用【服务开放平台 # 天津市手机号最后一次位置查询接口】 服务调用成功,耗时:{}ms", System.currentTimeMillis() - start);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void callService_14(){
|
|
|
+ Map<String, Object> tokenHeaderParamsMap = new HashMap<>();
|
|
|
+ tokenHeaderParamsMap.put("Content-Type", "application/x-www-form-urlencoded");
|
|
|
+ Map<String, Object> userTokenMap = new HashMap<>();
|
|
|
+ userTokenMap.put("type", "user");
|
|
|
+ userTokenMap.put("policeNo", "000000");
|
|
|
+ userTokenMap.put("userId", "-1");
|
|
|
+ Map<String, Object> appTokenMap = new HashMap<>();
|
|
|
+ appTokenMap.put("appId", "A-17865251449995264");
|
|
|
+ appTokenMap.put("userToken", JSON.toJSONString(userTokenMap));
|
|
|
+ List<NameValuePair> nameValuePairs = new ArrayList<>();
|
|
|
+ nameValuePairs.add(new BasicNameValuePair("userToken", JSON.toJSONString(userTokenMap)));
|
|
|
+ nameValuePairs.add(new BasicNameValuePair("appToken", JSON.toJSONString(appTokenMap)));
|
|
|
+ nameValuePairs.add(new BasicNameValuePair("serviceid", "10579974096420864"));
|
|
|
+ HttpClient httpClient = new HttpClient();
|
|
|
+ String content = httpClient.postResourceFWKFPT(fwkfptTokenUrl, nameValuePairs, tokenHeaderParamsMap);
|
|
|
+ JSONObject resultJSONobj = JSON.parseObject(content);
|
|
|
+ String appTokenId = "";
|
|
|
+ String userTokenId = "";
|
|
|
+ if(resultJSONobj != null){
|
|
|
+ String appTokenJSONStr = resultJSONobj.getString("appTokenId");
|
|
|
+ String userTokenJSONStr = resultJSONobj.getString("userTokenId");
|
|
|
+ if(StringUtils.isBlank(appTokenJSONStr) && StringUtils.isBlank(userTokenJSONStr)){
|
|
|
+ String message = resultJSONobj.getString("message");
|
|
|
+ log.error("获取【服务开放平台 # 权限认证令牌】 令牌创建失败,异常信息:{}", message);
|
|
|
+ }
|
|
|
+ appTokenId = JSON.parseObject(appTokenJSONStr).getString("appToken");
|
|
|
+ userTokenId = JSON.parseObject(userTokenJSONStr).getString("userToken");
|
|
|
+ log.info("获取【服务开放平台 # 权限认证令牌】 令牌创建成功,响应消息:{}", content);
|
|
|
+ }
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
+ Map<String, Object> headerParamsMap = new HashMap<>();
|
|
|
+ headerParamsMap.put("Content-Type", "application/json");
|
|
|
+ headerParamsMap.put("apptoken", appTokenId);
|
|
|
+ headerParamsMap.put("usertoken", userTokenId);
|
|
|
+ headerParamsMap.put("userid", "-1");
|
|
|
+ headerParamsMap.put("subid", "A-17865251449995264");
|
|
|
+ headerParamsMap.put("serviceid", "10579974096420864");
|
|
|
+ headerParamsMap.put("police-no", "000000");
|
|
|
+ headerParamsMap.put("app-id", "1");
|
|
|
+ headerParamsMap.put("role-id", "1");
|
|
|
+ String reqBody = "{ \"From\":\"320100\", \"To\":\"320100\", \"MessageSequence\":\"2020030314141200001\", \"RequestParam\":{ \"Condition\":\"VEH_PLATE_NUM='津RVG959'\", \"OtherCondition\":{ \"AsyncBoolean\":\"0\", \"AsyncIdentity\":\"0\", \"AsyncOnceReturnNum\":\"100\", \"AsyncQuery\":\"\", \"CallbackID\":\"\", \"CodeMode\":\"0\", \"MaxReturnNum\":\"10\", \"SortResults\":\"ILLE_TIME+\" }, \"ResourceInfos\":[ { \"DataItems\":[ { \"Name\":\"VEH_PLATE_NUM\", \"Fmt\": \"\" }, { \"Name\":\"ILLE_TIME\", \"Fmt\": \"\" } ], \"ResourceName\":\"R-120000000001-00000170\" } ] } }";
|
|
|
+ httpClient.postResource(fwkfptUniQueryUrl, reqBody, headerParamsMap);
|
|
|
+ log.info("调用【服务开放平台 # 天津市通查服务查询接口】 服务调用成功,耗时:{}ms", System.currentTimeMillis() - start);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void callService_15(){
|
|
|
+ Map<String, Object> tokenHeaderParamsMap = new HashMap<>();
|
|
|
+ tokenHeaderParamsMap.put("Content-Type", "application/x-www-form-urlencoded");
|
|
|
+ Map<String, Object> userTokenMap = new HashMap<>();
|
|
|
+ userTokenMap.put("type", "user");
|
|
|
+ userTokenMap.put("policeNo", "000000");
|
|
|
+ userTokenMap.put("userId", "-1");
|
|
|
+ Map<String, Object> appTokenMap = new HashMap<>();
|
|
|
+ appTokenMap.put("appId", "A-17865251449995264");
|
|
|
+ appTokenMap.put("userToken", JSON.toJSONString(userTokenMap));
|
|
|
+ List<NameValuePair> nameValuePairs = new ArrayList<>();
|
|
|
+ nameValuePairs.add(new BasicNameValuePair("userToken", JSON.toJSONString(userTokenMap)));
|
|
|
+ nameValuePairs.add(new BasicNameValuePair("appToken", JSON.toJSONString(appTokenMap)));
|
|
|
+ nameValuePairs.add(new BasicNameValuePair("serviceid", "32655244525568"));
|
|
|
+ HttpClient httpClient = new HttpClient();
|
|
|
+ String content = httpClient.postResourceFWKFPT(fwkfptTokenUrl, nameValuePairs, tokenHeaderParamsMap);
|
|
|
+ JSONObject resultJSONobj = JSON.parseObject(content);
|
|
|
+ String appTokenId = "";
|
|
|
+ String userTokenId = "";
|
|
|
+ if(resultJSONobj != null){
|
|
|
+ String appTokenJSONStr = resultJSONobj.getString("appTokenId");
|
|
|
+ String userTokenJSONStr = resultJSONobj.getString("userTokenId");
|
|
|
+ if(StringUtils.isBlank(appTokenJSONStr) && StringUtils.isBlank(userTokenJSONStr)){
|
|
|
+ String message = resultJSONobj.getString("message");
|
|
|
+ log.error("获取【服务开放平台 # 权限认证令牌】 令牌创建失败,异常信息:{}", message);
|
|
|
+ }
|
|
|
+ appTokenId = JSON.parseObject(appTokenJSONStr).getString("appToken");
|
|
|
+ userTokenId = JSON.parseObject(userTokenJSONStr).getString("userToken");
|
|
|
+ log.info("获取【服务开放平台 # 权限认证令牌】 令牌创建成功,响应消息:{}", content);
|
|
|
+ }
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
+ Map<String, Object> headerParamsMap = new HashMap<>();
|
|
|
+ headerParamsMap.put("Content-Type", "application/json");
|
|
|
+ headerParamsMap.put("apptoken", appTokenId);
|
|
|
+ headerParamsMap.put("usertoken", userTokenId);
|
|
|
+ headerParamsMap.put("userid", "-1");
|
|
|
+ headerParamsMap.put("subid", "A-17865251449995264");
|
|
|
+ headerParamsMap.put("serviceid", "32655244525568");
|
|
|
+ headerParamsMap.put("police-no", "000000");
|
|
|
+ headerParamsMap.put("app-id", "1");
|
|
|
+ headerParamsMap.put("role-id", "1");
|
|
|
+ String reqBody = "{ \"From\":\"120000\", \"To\":\"120000\", \"MessageSequence\":\"2020030314141200001\", \"RequestParam\":{ \"Condition\":\"DE00000618='370881198904288273'\", \"ResourceInfos\":[ { \"DataItems\":[ { \"Name\": \"HBH\", \"Fmt\": \"\" }, { \"Name\": \"LKZWXM\", \"Fmt\": \"\" }, { \"Name\": \"ZJHM\", \"Fmt\": \"\" }, { \"Name\": \"ZJLX\", \"Fmt\": \"\" } , { \"Name\": \"HBRQ\", \"Fmt\": \"\" } ], \"ResourceName\":\"R-120000000000-00002228\" }], \"OtherCondition\":{ \"AsyncBoolean\":\"1\", \"AsyncIdentity\":\"1\", \"AsyncOnceReturnNum\":\"100\", \"AsyncQuery\":\"1\", \"CallbackID\":\"1\", \"CodeMode\":\"0\", \"MaxReturnNum\":\"2\", \"SortResults\":\"\" } } }";
|
|
|
+ httpClient.postResource(fwkfptUniQueryUrl, reqBody, headerParamsMap);
|
|
|
+ log.info("调用【服务开放平台 # 天津市通用拓展查询服务查询接口】 服务调用成功,耗时:{}ms", System.currentTimeMillis() - start);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|