|
|
@@ -1,5 +1,6 @@ |
|
|
|
package com.telpo.dipperposition.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.telpo.dipperposition.common.*; |
|
|
|
import com.telpo.dipperposition.config.NettyServerConfig; |
|
|
@@ -20,7 +21,9 @@ import org.springframework.util.ResourceUtils; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* @program: DipperAstPosAsyncTaskServiceImpl |
|
|
@@ -58,14 +61,16 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS |
|
|
|
IpProvinceEntity ipProvinceEntity = ipProvinceService.getIpProvince(ipAddress); |
|
|
|
if (ipProvinceEntity == null) { |
|
|
|
// 匹配不到,再请求高德IP定位服务。 |
|
|
|
JSONObject userObj = new JSONObject(); |
|
|
|
userObj.put("ip", ipAddress); |
|
|
|
userObj.put("key", ipPositionRequestKey); |
|
|
|
JSONObject json = okHttpUtil.postRequestWithJson(ipPositionRequestPath, null, userObj); |
|
|
|
if (ObjectUtils.isNotEmpty(json)) { |
|
|
|
String province = (String) json.get("province"); |
|
|
|
//JSONObject userObj = new JSONObject(); |
|
|
|
Map<String, String> dataMap = new HashMap<String, String>(); |
|
|
|
dataMap.put("ip", ipAddress); |
|
|
|
dataMap.put("key", ipPositionRequestKey); |
|
|
|
StringBuffer buffer = okHttpUtil.getQueryString(ipPositionRequestPath, dataMap); |
|
|
|
if (ObjectUtils.isNotEmpty(buffer)) { |
|
|
|
JSONObject provinceJson = JSONObject.parseObject(buffer.toString()); |
|
|
|
String province = (String)provinceJson.get("province"); |
|
|
|
if (ObjectUtils.isEmpty(province)) { |
|
|
|
log.debug("json is :" + json.toString()); |
|
|
|
log.debug("json is :" + buffer.toString()); |
|
|
|
return null; |
|
|
|
} |
|
|
|
return province; |
|
|
|