diff --git a/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java b/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java index febe80a..5def78f 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java @@ -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 dataMap = new HashMap(); + 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;