|
@@ -1,4 +1,4 @@
|
|
|
-package com.nokia.domainb.capability.service;
|
|
|
+package com.nokia.domainb.service;
|
|
|
|
|
|
import cn.chinaunicom.open.nlgxptconnection.COMPConnectionContext;
|
|
|
import com.google.gson.JsonElement;
|
|
@@ -7,13 +7,13 @@ import com.google.gson.JsonParser;
|
|
|
import com.nokia.domainb.capability.Foreignproduct;
|
|
|
import com.nokia.domainb.capability.QryRouteAll;
|
|
|
import com.nokia.domainb.capability.QryUserIsUdm;
|
|
|
-import com.nokia.domainb.capability.dto.RouteDTO;
|
|
|
-import com.nokia.domainb.capability.dto.SaAndVolteDTO;
|
|
|
-import com.nokia.domainb.capability.dto.SaDTO;
|
|
|
-import com.nokia.domainb.capability.vo.RouteVO;
|
|
|
-import com.nokia.domainb.capability.vo.SaAndVolteVO;
|
|
|
-import com.nokia.domainb.capability.vo.SaVO;
|
|
|
-import com.nokia.domainb.common.http.R;
|
|
|
+import com.nokia.domainb.dto.RouteDTO;
|
|
|
+import com.nokia.domainb.dto.SaAndVolteDTO;
|
|
|
+import com.nokia.domainb.dto.SaDTO;
|
|
|
+import com.nokia.domainb.vo.RouteVO;
|
|
|
+import com.nokia.domainb.vo.SaAndVolteVO;
|
|
|
+import com.nokia.domainb.vo.SaVO;
|
|
|
+import com.nokia.common.http.R;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -21,17 +21,22 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class DomainService {
|
|
|
public R route(RouteDTO dto) {
|
|
|
+ RouteVO vo = new RouteVO();
|
|
|
+ vo.setIsUnicomNumber(false);
|
|
|
+ vo.setPhoneNumber(dto.getPhoneNumber());
|
|
|
QryRouteAll qryRouteAll = new QryRouteAll();
|
|
|
String result = qryRouteAll.query(dto.getPhoneNumber());
|
|
|
JsonObject jsonObject = JsonParser.parseString(result).getAsJsonObject();
|
|
|
- JsonObject data = jsonObject.getAsJsonObject("UNI_BSS_BODY")
|
|
|
+ JsonObject rsp = jsonObject.getAsJsonObject("UNI_BSS_BODY")
|
|
|
.getAsJsonObject("QRYROUTEALL_RSP")
|
|
|
- .getAsJsonObject("RSP")
|
|
|
- .getAsJsonArray("DATA")
|
|
|
- .get(0)
|
|
|
- .getAsJsonObject();
|
|
|
- RouteVO vo = new RouteVO();
|
|
|
- vo.setPhoneNumber(dto.getPhoneNumber());
|
|
|
+ .getAsJsonObject("RSP");
|
|
|
+ String rspCode = rsp.get("RSP_CODE").getAsString();
|
|
|
+ if (!"0000".equals(rspCode)) {
|
|
|
+ String rspDesc = rsp.get("RSP_DESC").getAsString();
|
|
|
+ return R.error().data(vo).message(rspDesc);
|
|
|
+ }
|
|
|
+
|
|
|
+ JsonObject data = rsp.getAsJsonArray("DATA").get(0).getAsJsonObject();
|
|
|
JsonElement routeTypeElement = data.get("ROUTE_TYPE");
|
|
|
if (routeTypeElement != null) {
|
|
|
vo.setRouteType(routeTypeElement.getAsString());
|
|
@@ -51,9 +56,14 @@ public class DomainService {
|
|
|
if (eparchyCodeElement != null) {
|
|
|
vo.setEparchyCode(eparchyCodeElement.getAsString());
|
|
|
}
|
|
|
+
|
|
|
boolean isUnicomNumber = "1".equals(vo.getUserStatus()) || "2".equals(vo.getUserStatus());
|
|
|
- vo.setIsUnicomNumber(isUnicomNumber);
|
|
|
- return R.ok().data(vo);
|
|
|
+ if (isUnicomNumber) {
|
|
|
+ vo.setIsUnicomNumber(true);
|
|
|
+ return R.ok().data(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.error().data(vo).message(getUserStatusDescription(vo.getUserStatus()));
|
|
|
}
|
|
|
|
|
|
public R sa(SaDTO dto) {
|
|
@@ -64,19 +74,23 @@ public class DomainService {
|
|
|
vo.setIsHaveSa(false);
|
|
|
vo.setIsUdmUser(false);
|
|
|
if (Boolean.FALSE.equals(routeVO.getIsUnicomNumber())) {
|
|
|
- return R.ok().data(vo);
|
|
|
+ return R.error().data(vo).message(getUserStatusDescription(routeVO.getUserStatus()));
|
|
|
}
|
|
|
|
|
|
vo.setIsUnicomNumber(true);
|
|
|
QryUserIsUdm qryUserIsUdm = new QryUserIsUdm();
|
|
|
COMPConnectionContext result = qryUserIsUdm.query(dto.getPhoneNumber(), routeVO.getProvinceCode(), false);
|
|
|
JsonObject jsonObject = JsonParser.parseString(result.getResponseContext()).getAsJsonObject();
|
|
|
- JsonObject data = jsonObject.getAsJsonObject("UNI_BSS_BODY")
|
|
|
+ JsonObject rsp = jsonObject.getAsJsonObject("UNI_BSS_BODY")
|
|
|
.getAsJsonObject("QRY_USER_IS_UDM_RSP")
|
|
|
- .getAsJsonObject("RSP")
|
|
|
- .getAsJsonArray("DATA")
|
|
|
- .get(0)
|
|
|
- .getAsJsonObject();
|
|
|
+ .getAsJsonObject("RSP");
|
|
|
+ String rspCode = rsp.get("RSP_CODE").getAsString();
|
|
|
+ if (!"0000".equals(rspCode)) {
|
|
|
+ String rspDesc = rsp.get("RSP_DESC").getAsString();
|
|
|
+ return R.error().data(vo).message(rspDesc);
|
|
|
+ }
|
|
|
+
|
|
|
+ JsonObject data = rsp.getAsJsonArray("DATA").get(0).getAsJsonObject();
|
|
|
JsonElement isHaveSaElement = data.get("IS_HAVE_SA");
|
|
|
if (isHaveSaElement != null) {
|
|
|
vo.setIsHaveSa("Y".equals(isHaveSaElement.getAsString()));
|
|
@@ -99,19 +113,19 @@ public class DomainService {
|
|
|
vo.setIsHaveVolte(false);
|
|
|
|
|
|
if (Boolean.FALSE.equals(routeVO.getIsUnicomNumber())) {
|
|
|
- return R.ok().data(vo);
|
|
|
+ return R.error().data(vo).message(getUserStatusDescription(routeVO.getUserStatus()));
|
|
|
}
|
|
|
|
|
|
Foreignproduct foreignproduct = new Foreignproduct();
|
|
|
COMPConnectionContext result = foreignproduct.query(dto.getPhoneNumber(), routeVO.getProvinceCode(), false);
|
|
|
JsonObject jsonObject = JsonParser.parseString(result.getResponseContext()).getAsJsonObject();
|
|
|
- String status = jsonObject.getAsJsonObject("UNI_BSS_BODY")
|
|
|
+ JsonObject rsp = jsonObject.getAsJsonObject("UNI_BSS_BODY")
|
|
|
.getAsJsonObject("FOREIGN_PRODUCT_RSP")
|
|
|
- .get("STATUS")
|
|
|
- .getAsString();
|
|
|
-
|
|
|
- if ("8888".equals(status)) {
|
|
|
- return R.ok().data(vo);
|
|
|
+ .getAsJsonObject("RSP");
|
|
|
+ String rspCode = rsp.get("RSP_CODE").getAsString();
|
|
|
+ if (!"0000".equals(rspCode)) {
|
|
|
+ String rspDesc = rsp.get("RSP_DESC").getAsString();
|
|
|
+ return R.error().data(vo).message(rspDesc);
|
|
|
}
|
|
|
|
|
|
vo.setIsHebeiUnicomNumber(true);
|
|
@@ -126,4 +140,23 @@ public class DomainService {
|
|
|
|
|
|
return R.ok().data(vo);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 获取路由用户状态说明
|
|
|
+ */
|
|
|
+ private String getUserStatusDescription(String userStatus) {
|
|
|
+ if ("3".equals(userStatus)) {
|
|
|
+ return "非CB 号码在cBss系统没有路由记录";
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("4".equals(userStatus)) {
|
|
|
+ return "drds 号码失效状态 且为新架构号码";
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("5".equals(userStatus)) {
|
|
|
+ return "oracle 号码失效状态 且为cBss常态化号码";
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|