소스 검색

mongodb访问方式变更

tags/v1.0.0^2
林万龙 3 년 전
부모
커밋
d877cccbc1
1개의 변경된 파일12개의 추가작업 그리고 7개의 파일을 삭제
  1. +12
    -7
      src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java

+ 12
- 7
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<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;


Loading…
취소
저장