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 d1ea3a1..98ccfd2 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java @@ -137,11 +137,20 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS } String lonAndAlt = null; - ProvinceInfoEntity entity = provinceInfoService.getProvinceInfo(centerAddress); - if (entity != null) { - lonAndAlt = entity.getProvince(); + try { + byte[] utf8 = centerAddress.getBytes("UTF-8"); + String utf8CenterAddress = new String(utf8, "UTF-8"); + log.debug("centerAddress is " + utf8CenterAddress); + + ProvinceInfoEntity entity = provinceInfoService.getProvinceInfo(utf8CenterAddress); + if (entity != null) { + lonAndAlt = entity.getProvince(); + } + } catch (Exception e) { + log.error(e.getMessage()); } + // (2) 处理返回结果 if (lonAndAlt == null) { // null处理 diff --git a/src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java b/src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java index b124ac9..6ccb38a 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/ProvinceInfoServiceImpl.java @@ -2,6 +2,7 @@ package com.telpo.dipperposition.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; +import com.telpo.dipperposition.entity.mongo.IpProvinceEntity; import com.telpo.dipperposition.entity.mongo.ProvinceInfoEntity; import com.telpo.dipperposition.mapper.ProvinceInfoMapper; import com.telpo.dipperposition.service.IProvinceInfoService; @@ -57,13 +58,14 @@ public class ProvinceInfoServiceImpl implements IProvinceInfoService { ProvinceInfoEntity query = new ProvinceInfoEntity(); query.setProvince(provicne); Example example = Example.of(query); -// PageRequest pageable = PageRequest.of(0, 1); - Optional data = provinceInfoMapper.findOne(example); -// if (CollectionUtil.isNotEmpty(data.getContent())) { -// -// List provinceInfos = BeanTools.copyList(data.getContent(), ProvinceInfoEntity.class); -// return provinceInfos.get(0); - return data.get(); + PageRequest pageable = PageRequest.of(0, 1); + Page data = provinceInfoMapper.findAll(example, pageable); + if (CollectionUtil.isNotEmpty(data.getContent())) { + List records = BeanTools.copyList(data.getContent(), ProvinceInfoEntity.class); + return records.get(0); + } else { + return null; + } } catch (Exception e) { log.error("获取省份异常:", e); return null;