Bläddra i källkod

增加数据解析

tags/v1.0.0^2
林万龙 3 år sedan
förälder
incheckning
c6837861cc
3 ändrade filer med 28 tillägg och 11 borttagningar
  1. +1
    -1
      dipper_position_run.sh
  2. +21
    -9
      src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java
  3. +6
    -1
      src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java

+ 1
- 1
dipper_position_run.sh Visa fil

@@ -18,7 +18,7 @@ if [[ ${environment} == 'pro' ]]; then
mv /home/linwl/dipperposition/dipperposition.jar /home/data/dipperposition/dipperposition.jar
fi
nohup java -Xmx2048M -Xms2048M -Djava.security.egd=file:/dev/./urandom -Dio.netty.leakDetectionLevel=ADVANCED -jar dipperposition.jar --spring.profiles.active=pro &
nohup java -Xmx1024M -Xms1024M -Djava.security.egd=file:/dev/./urandom -Dio.netty.leakDetectionLevel=ADVANCED -jar dipperposition.jar --spring.profiles.active=pro &

fi
if [[ ${environment} == 'test' ]]; then


+ 21
- 9
src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java Visa fil

@@ -70,11 +70,17 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
}
//log.debug("IP省份获取错误,结果为:" + result);
JSONObject provinceJson = JSONObject.parseObject(result);
String province = (String)provinceJson.get("province");
if (ObjectUtils.isEmpty(province)) {
log.debug("json is :" + buffer.toString());
return null;
String province = null;
try {
province = (String)provinceJson.get("province");
if (ObjectUtils.isEmpty(province)) {
log.debug("json is :" + buffer.toString());
return null;
}
} catch (Exception e) {
log.error("JSONObject分析出错,provinceJson:" + provinceJson);
}

return province;
}
} else {
@@ -116,7 +122,7 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
//this.centerProvinceFilePath = positionConfig.getCenterProvinceFilePath();
// (1) 获取省会城市信息
String centerAddress = getIpPositionProvince(ipAddress);
if (ObjectUtils.isEmpty(centerAddress) || centerAddress.equals("0")) {
if (centerAddress == null || ObjectUtils.isEmpty(centerAddress) || centerAddress.equals("0")) {
log.warn("IP地址非法,无法获取辅助位置信息!");
// 返回武汉的定位数据
centerAddress = this.centerProvince;
@@ -132,10 +138,16 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
String utf8CenterAddress = new String(utf8, "UTF-8");
log.debug("centerAddress is " + utf8CenterAddress);

ProvinceInfoEntity entity = provinceInfoService.getProvinceInfo(utf8CenterAddress);
if (entity != null) {
lonValue = entity.getLon();
altValue = entity.getAlt();
if (utf8CenterAddress.endsWith("省") || utf8CenterAddress.endsWith("区") || utf8CenterAddress.endsWith("市")) {

ProvinceInfoEntity entity = provinceInfoService.getProvinceInfo(utf8CenterAddress);
if (entity != null) {
lonValue = entity.getLon();
altValue = entity.getAlt();
}
} else {
log.error("非法省份:" + utf8CenterAddress);
return null;
}
} catch (Exception e) {
log.error(e.getMessage());


+ 6
- 1
src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java Visa fil

@@ -1,5 +1,6 @@
package com.telpo.dipperposition.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.telpo.dipperposition.entity.mongo.ProvinceInfoEntity;
import com.telpo.dipperposition.mapper.ProvinceInfoMapper;
import com.telpo.dipperposition.service.IProvinceInfoService;
@@ -56,7 +57,11 @@ public class ProvinceInfoServiceImpl implements IProvinceInfoService {
ExampleMatcher matcher = ExampleMatcher.matching().withIgnorePaths("_class");
Example<ProvinceInfoEntity> example = Example.of(query, matcher);
Optional<ProvinceInfoEntity> data = provinceInfoMapper.findOne(example);
return data.get();
if (ObjectUtil.isNotEmpty(data)) {
return data.get();
} else {
return null;
}
} catch (Exception e) {
log.error("获取省份异常:", e);
return null;


Laddar…
Avbryt
Spara