Ver Fonte

fan zha 0802

sunyize há 2 anos atrás
pai
commit
dd127d6cb8

+ 32 - 17
tnc-sms/src/main/java/org/jeecg/modules/smscheck/controller/BusinessReminderCardController.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -27,6 +28,8 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.stream.Stream;
 
 /**
@@ -42,7 +45,7 @@ public class BusinessReminderCardController {
     @Autowired
     private PhonePurposeService phonePurposeService;
 
-    private static final String PHONE_PLACE_API_URL="http://virtual.paipai.com/extinfo/GetMobileProductInfo";
+    private static final String PHONE_PLACE_API_URL="https://cx.shouji.360.cn/phonearea.php";
 
 
     @ApiOperation(value = "入网信息业务-分页列表查询", notes = "入网信息业务-分页列表查询")
@@ -314,8 +317,8 @@ public class BusinessReminderCardController {
      * @throws
 
      */
-
-    public String getMobilePlace(String mobile){
+    @GetMapping(value = "/queryByMobile")
+    public String getMobilePlace(String mobile) throws Exception{
 
         HttpClientUtil util = new HttpClientUtil();
 
@@ -325,27 +328,20 @@ public class BusinessReminderCardController {
 
             //访问拍拍的查询接口
 
-            String mobileMessage = util.getWebcontent(PHONE_PLACE_API_URL+"?mobile="+mobile+"&amount=10000", "GB2312");
-
-            strings = mobileMessage.split(";");
-
-            //(页面获取到的消息,除了这些,还有一些html语句)
+            String mobileMessage = util.getWebcontent(PHONE_PLACE_API_URL+"?number="+mobile, "GB2312");
 
-            //            string[0]="({mobile:'15850781443',province:'江苏',isp:'中国移动',stock:'1',amount:'10000',maxprice:'0',minprice:'0',cityname:'南京'})";
-
-            mobileMessage = strings[0];
-
-            JSONObject jsonObject = JSONObject.parseObject(mobileMessage.substring(1, mobileMessage.length()-1));
+            //{"code":0,"data":{"province":"\u6cb3\u5317","city":"\u77f3\u5bb6\u5e84","sp":"\u79fb\u52a8"}}
+            JSONObject jsonObject = JSONObject.parseObject(mobileMessage);
 
             //解析出省份和city和运营商
 
-            String province = jsonObject.getString("province");
+            String province = JSONObject.parseObject(jsonObject.get("data").toString()).get("province").toString();
 
-            String cityname = jsonObject.getString("cityname");
+            String cityname = JSONObject.parseObject(jsonObject.get("data").toString()).get("city").toString();
 
-            String isp = jsonObject.getString("isp");
+            String isp = JSONObject.parseObject(jsonObject.get("data").toString()).get("sp").toString();
 
-            return isp+"&nbsp"+province+cityname;
+            return  province+cityname;
 
         } catch (Exception e) {
 
@@ -359,4 +355,23 @@ public class BusinessReminderCardController {
 
     }
 
+
+    /**
+     * @param string
+     * @return 转换之后的内容
+     * @Title: unicodeDecode
+     * @Description: unicode解码 将Unicode的编码转换为中文
+     */
+    public String unicodeDecode(String string) {
+        Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
+        Matcher matcher = pattern.matcher(string);
+        char ch;
+        while (matcher.find()) {
+            ch = (char) Integer.parseInt(matcher.group(2), 16);
+            string = string.replace(matcher.group(1), ch + "");
+        }
+        return string;
+    }
+
+
 }

+ 2 - 13
tnc-sms/src/main/java/org/jeecg/modules/smscheck/util/HttpClientUtil.java

@@ -79,29 +79,18 @@ public class HttpClientUtil {
             response = conn.getResponseCode();
 
             if (response == 200) {
-
                 InputStream im = null;
-
                 try {
-
                     im = conn.getInputStream();
-
-                    return readInputStream(im, charest);
-
+                    String s = readInputStream(im, charest);
+                    return s;
                 } finally {
-
                     IOUtils.closeQuietly(im);
-
                 }
-
             }
-
             return null;
-
         } catch (Exception e) {
-
             logger.error(String.format("下载到文件出错[url=%s][%s][responsecode=%d]", webUrl, e.getMessage(), response));
-
             return null;
 
         } finally {