|
@@ -0,0 +1,81 @@
|
|
|
|
+package com.nokia.domainb.capability;
|
|
|
|
+
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+
|
|
|
|
+import cn.chinaunicom.open.common.Const;
|
|
|
|
+import cn.chinaunicom.open.nlgxptconnection.COMPConnection;
|
|
|
|
+import cn.chinaunicom.open.nlgxptconnection.COMPConnectionContext;
|
|
|
|
+import cn.chinaunicom.open.nlgxptconnection.impl.COMPJsonConnection;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 路由查询
|
|
|
|
+ */
|
|
|
|
+public class QryRouteAll extends AbstractQuery {
|
|
|
|
+ // 测试环境url
|
|
|
|
+ private static final String urlTest = "http://10.124.150.230:8000/api/microservice/routes/qryrouteall/v1";
|
|
|
|
+ // 生产环境url
|
|
|
|
+ private static final String url = "http://10.245.34.209:8000/api/microservice/routes/qryrouteall/v1";
|
|
|
|
+
|
|
|
|
+ public String query(String phoneNumber) {
|
|
|
|
+ return query(phoneNumber, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 使用RestTemplate查询
|
|
|
|
+ public String query(String phoneNumber, boolean test) {
|
|
|
|
+ // 整体包装
|
|
|
|
+ JSONObject compParamObject = new JSONObject();
|
|
|
|
+ // UNI_BSS_HEAD
|
|
|
|
+ compParamObject.put("UNI_BSS_HEAD", getUniBSSHead(test));
|
|
|
|
+ // UNI_BSS_BODY
|
|
|
|
+ JSONObject uniBSSBody = new JSONObject();
|
|
|
|
+ // QRYROUTEALL_REQ
|
|
|
|
+ JSONObject qryRouteAllReq = new JSONObject();
|
|
|
|
+ // REQ
|
|
|
|
+ JSONObject req = new JSONObject();
|
|
|
|
+ // 查询号码
|
|
|
|
+ req.put("ROUTE_VALUE", phoneNumber);
|
|
|
|
+ // 网别 支持 30固话 40宽带 50移网
|
|
|
|
+ req.put("NET_TYPE_CODE", 50);
|
|
|
|
+ qryRouteAllReq.put("REQ", req);
|
|
|
|
+ uniBSSBody.put("QRYROUTEALL_REQ", qryRouteAllReq);
|
|
|
|
+ compParamObject.put("UNI_BSS_BODY", uniBSSBody);
|
|
|
|
+
|
|
|
|
+ String realUrl = test ? urlTest : url;
|
|
|
|
+
|
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
|
+ ResponseEntity<String> response = restTemplate.postForEntity(realUrl,
|
|
|
|
+ new HttpEntity<>(compParamObject, getHeaders()), String.class);
|
|
|
|
+ return response.getBody();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public COMPConnectionContext queryWithSdk(String phoneNumber) {
|
|
|
|
+ return queryWithSdk(phoneNumber, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 使用能力商店SDK查询
|
|
|
|
+ public COMPConnectionContext queryWithSdk(String phoneNumber, boolean test) {
|
|
|
|
+ String realAppSecret = test ? appSecretTest : appSecret;
|
|
|
|
+ String realUrl = test ? urlTest : url;
|
|
|
|
+ COMPConnection compConnection = new COMPJsonConnection(appId, realAppSecret);
|
|
|
|
+ // REQ
|
|
|
|
+ Map<String, Object> req = new HashMap<>();
|
|
|
|
+ // 查询号码
|
|
|
|
+ req.put("ROUTE_VALUE", phoneNumber);
|
|
|
|
+ // 网别 支持 30固话 40宽带 50移网
|
|
|
|
+ req.put("NET_TYPE_CODE", "50");
|
|
|
|
+ // QRYROUTEALL_REQ
|
|
|
|
+ Map<String, Object> qryRouteAllReq = new HashMap<>();
|
|
|
|
+ qryRouteAllReq.put("REQ", req);
|
|
|
|
+ Map<String, Object> uniBssBody = new HashMap<>();
|
|
|
|
+ uniBssBody.put("QRYROUTEALL_REQ", qryRouteAllReq);
|
|
|
|
+ return compConnection.excute(Const.HttpMethodType.POST, realUrl, uniBssBody, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|