From e17954f5a2e4337edaf76bd69bb58842daedf549 Mon Sep 17 00:00:00 2001 From: linwl <304115325@qq.com> Date: Wed, 20 Jan 2021 18:55:50 +0800 Subject: [PATCH] =?UTF-8?q?mongodb=E8=AE=BF=E9=97=AE=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup_production.sh => setup_pro.sh | 0 .../impl/DipperAstPosAsyncTaskServiceImpl.java | 18 +++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) rename setup_production.sh => setup_pro.sh (100%) diff --git a/setup_production.sh b/setup_pro.sh similarity index 100% rename from setup_production.sh rename to setup_pro.sh 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 51aa1d3..eea974f 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java @@ -11,6 +11,7 @@ import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService; import com.telpo.dipperposition.service.IProvinceInfoService; import com.telpo.dipperposition.service.IpProvinceService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.logging.log4j.util.PropertiesUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -67,13 +68,20 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS 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 :" + buffer.toString()); + String provinceBuffer = buffer.toString(); + if (StringUtils.isEmpty(provinceBuffer)) { + log.debug("IP省份获取错误,结果为空"); return null; + } else { + log.debug("IP省份获取错误,结果为:" + provinceBuffer); + JSONObject provinceJson = JSONObject.parseObject(provinceBuffer); + String province = (String)provinceJson.get("province"); + if (ObjectUtils.isEmpty(province)) { + log.debug("json is :" + buffer.toString()); + return null; + } + return province; } - return province; } else { // 意外错误 log.debug("ip address is null");