|
|
@@ -70,6 +70,12 @@ public class PBXServiceImpl implements IPBXService {
|
|
|
@Value("${pbx.active}")
|
|
|
private String pbxActive;
|
|
|
|
|
|
+ @Value("${pbx.api.url}")
|
|
|
+ private String regionPhoneAPIUrl;
|
|
|
+
|
|
|
+ @Value("${pbx.api.appcode}")
|
|
|
+ private String regionPhoneAppCode;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
|
|
|
|
@@ -78,6 +84,8 @@ public class PBXServiceImpl implements IPBXService {
|
|
|
|
|
|
private static final String SUCCESS = "0";
|
|
|
|
|
|
+ private static final String API_SUCCESS = "200";
|
|
|
+
|
|
|
@Autowired
|
|
|
private ElevatorWorkOrderMapper elevatorWorkOrderMapper;
|
|
|
|
|
|
@@ -854,6 +862,10 @@ public class PBXServiceImpl implements IPBXService {
|
|
|
if (StringUtils.isEmpty(toPhone) || toPhone.length() == 4) {
|
|
|
continue;
|
|
|
}
|
|
|
+ // 如果手机号开头是0 去除掉0
|
|
|
+ if (toPhone.startsWith("0")) {
|
|
|
+ toPhone = toPhone.substring(1,12);
|
|
|
+ }
|
|
|
String callId = redisCache.getCacheObject(PBXConstant.PBX_TRANSFER_CODE_KEY + toPhone);
|
|
|
if (StringUtils.isEmpty(callId)) {
|
|
|
log.info("no cache transferToValue,key : {}",PBXConstant.PBX_TRANSFER_CODE_KEY + toPhone);
|
|
|
@@ -869,8 +881,6 @@ public class PBXServiceImpl implements IPBXService {
|
|
|
startRecordVoice(channelId);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void startRecordVoice(String channelId) {
|
|
|
@@ -1081,13 +1091,16 @@ public class PBXServiceImpl implements IPBXService {
|
|
|
* @param phoneNum 手机号
|
|
|
* @return 归属地
|
|
|
*/
|
|
|
- public static String getRegionInfoByPhoneAPI(String phoneNum){
|
|
|
+ public String getRegionInfoByPhoneAPI(String phoneNum){
|
|
|
// 360提供的一个接口 能返回省份和城市
|
|
|
try {
|
|
|
- String url = "https://cx.shouji.360.cn/phonearea.php?number=" + phoneNum;
|
|
|
- String responseBody = HttpUtil.createGet(url).execute().body();
|
|
|
+ String url = regionPhoneAPIUrl + phoneNum;
|
|
|
+ log.info("getRegionInfoByPhoneAPI url : {}",url);
|
|
|
+ String responseBody = HttpUtil.createGet(url).header("Authorization",regionPhoneAppCode)
|
|
|
+ .execute().body();
|
|
|
+ log.info("getRegionInfoByPhoneAPI response body {}", responseBody);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(responseBody);
|
|
|
- if (!SUCCESS.equals(jsonObject.getInteger("code").toString())) {
|
|
|
+ if (!API_SUCCESS.equals(jsonObject.getInteger("ret").toString())) {
|
|
|
return "";
|
|
|
}
|
|
|
String city = jsonObject.getJSONObject("data").getString("city");
|
|
|
@@ -1130,11 +1143,4 @@ public class PBXServiceImpl implements IPBXService {
|
|
|
phoneNumber.setNationalNumber(Long.parseLong(phone));
|
|
|
return phoneNumber;
|
|
|
}
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
-
|
|
|
- String phoneNum = "19909918878";
|
|
|
- System.out.println(getRegionInfoByPhoneAPI(phoneNum));
|
|
|
-
|
|
|
- }
|
|
|
}
|