|
@@ -1,6 +1,7 @@
|
|
|
package com.benyun.core.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.benyun.core.constant.RedisContant;
|
|
|
import com.benyun.core.dao.AddrCategoryDao;
|
|
|
import com.benyun.core.dao.AttentionPoolDao;
|
|
|
import com.benyun.core.dao.WdInfoDao;
|
|
@@ -12,19 +13,23 @@ import com.benyun.core.entity.bo.WdCount;
|
|
|
import com.benyun.core.entity.bo.WdCountBody;
|
|
|
import com.benyun.core.entity.WdInfo;
|
|
|
import com.benyun.core.entity.bo.WdTopologicalInfoBo;
|
|
|
+import com.benyun.core.entity.vo.ChannelMapAceeptVo;
|
|
|
+import com.benyun.core.entity.vo.WdInfoVo;
|
|
|
import com.benyun.core.service.ChannelMapService;
|
|
|
+import com.benyun.core.utils.WdRedisStoreage;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.ruoyi.common.core.domain.R;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.data.geo.*;
|
|
|
+import org.springframework.data.redis.connection.RedisGeoCommands;
|
|
|
+import org.springframework.data.redis.core.BoundGeoOperations;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -53,23 +58,35 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
@Autowired
|
|
|
WdInfoDao wdInfoDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("cityTierListMap")
|
|
|
+ HashMap<String,List<String>> cityTierListMap;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ RedisTemplate redisTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ WdRedisStoreage wdRedisStoreage;
|
|
|
+
|
|
|
@Override
|
|
|
- public WdCount area(List<String> channel, String rankType, String searchText, String[] addrCode) {
|
|
|
+ public WdCount area(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
+ //1.根据不同级别得到 需要封装的 地区码
|
|
|
List<String> addrCodeList = new ArrayList<>();
|
|
|
-
|
|
|
- //1.根据不同级别得到地区码
|
|
|
- if ("province".equals(rankType)) {
|
|
|
+ if ("province".equals(channelMapAceeptVo.getRankType())) {
|
|
|
//省码
|
|
|
- Collections.addAll(addrCodeList, addrCode);
|
|
|
- } else if ("city".equals(rankType)) {
|
|
|
+ for (String s : channelMapAceeptVo.getAddrCode()) {
|
|
|
+ String substring = s.substring(0, 2);
|
|
|
+ addrCodeList.add(substring);
|
|
|
+ }
|
|
|
+ } else if ("city".equals(channelMapAceeptVo.getRankType())) {
|
|
|
//省的所有市
|
|
|
- for (String s : addrCode) {
|
|
|
+ for (String s : channelMapAceeptVo.getAddrCode()) {
|
|
|
String substring = s.substring(0, 2);
|
|
|
addrCodeList.add(substring);
|
|
|
}
|
|
|
- } else if ("zone".equals(rankType)) {
|
|
|
+ } else if ("zone".equals(channelMapAceeptVo.getRankType())) {
|
|
|
//市的所有区
|
|
|
- for (String s : addrCode) {
|
|
|
+ for (String s : channelMapAceeptVo.getAddrCode()) {
|
|
|
String substring = s.substring(0, 4);
|
|
|
addrCodeList.add(substring);
|
|
|
}
|
|
@@ -77,15 +94,16 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- //2.找到相关地区信息
|
|
|
+
|
|
|
+ //2.找到所有需要封装的 地区信息
|
|
|
QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
|
|
|
- if ("province".equals(rankType)) {
|
|
|
+ if ("province".equals(channelMapAceeptVo.getRankType())) {
|
|
|
queryWrapper.eq("city", "");
|
|
|
- } else if ("city".equals(rankType)) {
|
|
|
+ } else if ("city".equals(channelMapAceeptVo.getRankType())) {
|
|
|
queryWrapper.eq("district", "").and(addrCategoryQueryWrapper -> {
|
|
|
addrCategoryQueryWrapper.ne("city", "");
|
|
|
});
|
|
|
- } else if ("zone".equals(rankType)) {
|
|
|
+ } else if ("zone".equals(channelMapAceeptVo.getRankType())) {
|
|
|
queryWrapper.ne("district", "");
|
|
|
}
|
|
|
queryWrapper.and(addrCategoryQueryWrapper -> {
|
|
@@ -95,15 +113,12 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
- //TODO 前置分类删选还没做
|
|
|
-
|
|
|
-
|
|
|
List<AddrCategory> addrCategories = addrCategoryDao.selectList(queryWrapper);
|
|
|
|
|
|
|
|
|
//3.组装地区信息
|
|
|
List<WdCountBody> result = new ArrayList<>();
|
|
|
+ HashMap<String,Integer> statistics = new HashMap<>(); //统计信息
|
|
|
for (AddrCategory addrCategory : addrCategories) {
|
|
|
WdCountBody wdCountBody = new WdCountBody();
|
|
|
|
|
@@ -111,43 +126,82 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
wdCountBody.setLat(addrCategory.getLatGd());
|
|
|
wdCountBody.setLng(addrCategory.getLngGd());
|
|
|
wdCountBody.setAddrCode(addrCategory.getAddrCode());
|
|
|
- if ("province".equals(rankType)) {
|
|
|
+ if ("province".equals(channelMapAceeptVo.getRankType())) {
|
|
|
wdCountBody.setName(addrCategory.getProvince());
|
|
|
- } else if ("city".equals(rankType)) {
|
|
|
+ statistics.put(addrCategory.getAddrCode().substring(0,2),0);
|
|
|
+ } else if ("city".equals(channelMapAceeptVo.getRankType())) {
|
|
|
wdCountBody.setName(addrCategory.getCity());
|
|
|
- } else if ("zone".equals(rankType)) {
|
|
|
+ statistics.put(addrCategory.getAddrCode().substring(0,4),0);
|
|
|
+ } else if ("zone".equals(channelMapAceeptVo.getRankType())) {
|
|
|
wdCountBody.setName(addrCategory.getDistrict());
|
|
|
+ statistics.put(addrCategory.getAddrCode().substring(0,6),0);
|
|
|
}
|
|
|
result.add(wdCountBody);
|
|
|
}
|
|
|
|
|
|
- //4.统计地区网点信息
|
|
|
- Long total = 0L;
|
|
|
- for (WdCountBody wdCountBody : result) {
|
|
|
- QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
|
|
|
- String code = wdCountBody.getAddrCode();
|
|
|
|
|
|
- //根据地区前缀,使用模糊查询
|
|
|
- if ("province".equals(rankType))
|
|
|
- code = code.substring(0, 2);
|
|
|
- else if ("city".equals(rankType))
|
|
|
- code = code.substring(0, 4);
|
|
|
+ //4.组装条件构造器找到网点信息网点
|
|
|
+ //2.1 渠道、地区分类
|
|
|
+ QueryWrapper<WdInfo> queryWrapper2 = new QueryWrapper<>();
|
|
|
+ queryWrapper2.in("wd_type_code", channelMapAceeptVo.getChannel()).and(originWdInfoQueryWrapper -> {
|
|
|
+ for (String s : addrCodeList) {
|
|
|
+ originWdInfoQueryWrapper.likeRight("addr_code", s).or();
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- queryWrapper1.likeRight("addr_code", code).and(originWdInfoQueryWrapper -> {
|
|
|
- originWdInfoQueryWrapper.in("wd_type_code", channel);
|
|
|
+ //搜索字段
|
|
|
+ if (channelMapAceeptVo.getSearchText() != null && !channelMapAceeptVo.getSearchText() .trim().equals("")) {
|
|
|
+ queryWrapper2.and(originWdInfoQueryWrapper -> {
|
|
|
+ originWdInfoQueryWrapper.like("wd_name", channelMapAceeptVo.getSearchText() );
|
|
|
});
|
|
|
- if (searchText != null && !searchText.trim().equals("")) {
|
|
|
- queryWrapper1.and(originWdInfoQueryWrapper -> {
|
|
|
- originWdInfoQueryWrapper.like("wd_name", searchText);
|
|
|
- });
|
|
|
+ }
|
|
|
+
|
|
|
+ //城市等级分类
|
|
|
+ if(channelMapAceeptVo.getCityTier() != null && channelMapAceeptVo.getCityTier().length > 0){
|
|
|
+ List<String> tierCode = new ArrayList<>();
|
|
|
+ for (String s : channelMapAceeptVo.getCityTier()) {
|
|
|
+ List<String> list = cityTierListMap.get(s);
|
|
|
+ if (list != null){
|
|
|
+ tierCode.addAll(list);
|
|
|
+ }
|
|
|
}
|
|
|
- Long aLong = originWdInfoDao.selectCount(queryWrapper1);
|
|
|
- wdCountBody.setCount(aLong);
|
|
|
- total += aLong;
|
|
|
+ queryWrapper2.and(wdInfoQueryWrapper -> {
|
|
|
+ wdInfoQueryWrapper.in("addr_code",tierCode);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+ //5.统计
|
|
|
+ int total = 0;
|
|
|
+ List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper2);
|
|
|
+ for (WdInfo wdInfo : wdInfos) {
|
|
|
+ if("province".equals(channelMapAceeptVo.getRankType())){
|
|
|
+ statistics.put(wdInfo.getAddrCode().substring(0,2),statistics.get(wdInfo.getAddrCode().substring(0,2))+1);
|
|
|
+ } else if ("city".equals(channelMapAceeptVo.getRankType())) {
|
|
|
+ statistics.put(wdInfo.getAddrCode().substring(0,4),statistics.get(wdInfo.getAddrCode().substring(0,4))+1);
|
|
|
+ } else if ("zone".equals(channelMapAceeptVo.getRankType())) {
|
|
|
+ statistics.put(wdInfo.getAddrCode().substring(0,6),statistics.get(wdInfo.getAddrCode().substring(0,6))+1);
|
|
|
+ }
|
|
|
+ total++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//5.计算radio
|
|
|
for (WdCountBody wdCountBody : result) {
|
|
|
+ String code = null;
|
|
|
+ if("province".equals(channelMapAceeptVo.getRankType())){
|
|
|
+ code = wdCountBody.getAddrCode().substring(0,2);
|
|
|
+ }else if("city".equals(channelMapAceeptVo.getRankType())){
|
|
|
+ code = wdCountBody.getAddrCode().substring(0,4);
|
|
|
+ }else if("zone".equals(channelMapAceeptVo.getRankType())){
|
|
|
+ code = wdCountBody.getAddrCode().substring(0,4);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(statistics.get(code) != null){
|
|
|
+ wdCountBody.setCount(statistics.get(code));
|
|
|
+ }else {
|
|
|
+ wdCountBody.setCount(0);
|
|
|
+ }
|
|
|
+
|
|
|
if (total != 0){
|
|
|
BigDecimal bigDecimal = new BigDecimal((float) wdCountBody.getCount() / total);
|
|
|
float v = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
|
|
@@ -162,205 +216,192 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
return wdCount;
|
|
|
}
|
|
|
|
|
|
- //TODO 需要优化
|
|
|
-// @Override
|
|
|
-// public HashMap list(String[] channel, String rankType, String searchText, String orderby, String[] addrCode, int pageNum, int pageSize) {
|
|
|
-// //1.根据不同级别得到地区码
|
|
|
-// List<String> addrCodeList = new ArrayList<>();
|
|
|
-// if ("province".equals(rankType)) {
|
|
|
-// //省码
|
|
|
-// for (String s : addrCode) {
|
|
|
-// String substring = s.substring(0, 2);
|
|
|
-// addrCodeList.add(substring);
|
|
|
-// }
|
|
|
-// } else if ("city".equals(rankType)) {
|
|
|
-// //省的所有市
|
|
|
-// for (String s : addrCode) {
|
|
|
-// String substring = s.substring(0, 4);
|
|
|
-// addrCodeList.add(substring);
|
|
|
-// }
|
|
|
-// } else if ("zone".equals(rankType)) {
|
|
|
-// //区
|
|
|
-// for (String s : addrCode) {
|
|
|
-// String substring = s.substring(0, 6);
|
|
|
-// addrCodeList.add(substring);
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// //2.根据地区前缀找到所有的网点
|
|
|
-// QueryWrapper<WdTopologicalInfo> queryWrapper = new QueryWrapper<>();
|
|
|
-// queryWrapper.in("center_wd_type_code", channel).and(originWdInfoQueryWrapper -> {
|
|
|
-// for (String s : addrCodeList) {
|
|
|
-// originWdInfoQueryWrapper.likeRight("addr_code", s).or();
|
|
|
-// }
|
|
|
-// });
|
|
|
-//
|
|
|
-// if (searchText != null && !searchText.trim().equals("")) {
|
|
|
-// queryWrapper.and(originWdInfoQueryWrapper -> {
|
|
|
-// originWdInfoQueryWrapper.like("center_wd_name", searchText);
|
|
|
-// });
|
|
|
-// }
|
|
|
-//
|
|
|
-// queryWrapper.and(wdTopologicalInfoQueryWrapper -> {
|
|
|
-// wdTopologicalInfoQueryWrapper.eq("radius",1000); //1km内算附近
|
|
|
-// });
|
|
|
-//
|
|
|
-// if (orderby != null && !orderby.trim().equals("")) {
|
|
|
-// queryWrapper.orderByDesc(orderby);
|
|
|
-// }
|
|
|
-//
|
|
|
-// //获取数据
|
|
|
-// PageHelper.startPage(pageNum, pageSize);
|
|
|
-// List<WdTopologicalInfo> originWdInfos = wdTopologicalInfoDao.selectList(queryWrapper);
|
|
|
-// PageInfo<WdTopologicalInfo> PageInfo = new PageInfo<>(originWdInfos);
|
|
|
-//
|
|
|
-//
|
|
|
-// //组装
|
|
|
-// List<WdTopologicalInfoBo> collect = PageInfo.getList().stream().map(wdTopologicalInfo -> {
|
|
|
-// wdTopologicalInfo.setAddrCodeInfo(addrCodeMap.get(wdTopologicalInfo.getAddrCode()));
|
|
|
-//
|
|
|
-// List<String> list = new ArrayList<>();
|
|
|
-// String tag = wdTopologicalInfo.getTag();
|
|
|
-// for (String s : tag.split(";")) {
|
|
|
-// String[] split = s.split(":");
|
|
|
-// if (split != null && split.length == 2) {
|
|
|
-// if(typeByMap.get(split[0]) == null)
|
|
|
-// continue;
|
|
|
-// String[] split1 = typeByMap.get(split[0]).split(":");
|
|
|
-// String t = "";
|
|
|
-// if (split1.length == 3)
|
|
|
-// t = split1[2];
|
|
|
-// else if (split1.length == 2)
|
|
|
-// t = split1[1];
|
|
|
-// else if (split1.length == 1)
|
|
|
-// t = split1[0];
|
|
|
-// list.add(t);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// WdTopologicalInfoBo wdTopologicalInfoBo = new WdTopologicalInfoBo(wdTopologicalInfo);
|
|
|
-// wdTopologicalInfoBo.setTag(list);
|
|
|
-// return wdTopologicalInfoBo;
|
|
|
-// }).collect(Collectors.toList());
|
|
|
-//
|
|
|
-//
|
|
|
-// PageInfo.setList(null);
|
|
|
-// HashMap result = new HashMap();
|
|
|
-// result.put("data",collect);
|
|
|
-// result.put("page",PageInfo);
|
|
|
-//
|
|
|
-// return result;
|
|
|
-// }
|
|
|
|
|
|
+ //TODO 待测试(redis版本)
|
|
|
@Override
|
|
|
- public HashMap list(String[] channel, String rankType, String searchText, String orderby, String[] addrCode, int pageNum, int pageSize) {
|
|
|
- //1.根据不同级别得到地区码
|
|
|
+ public HashMap list(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
+ //1.根据条件获取网点
|
|
|
+ PageInfo<WdInfo> PageInfo = getQueryPageWd(channelMapAceeptVo);
|
|
|
+
|
|
|
+ //2.获取标签并组装
|
|
|
+ List<WdTopologicalInfoBo> result = new ArrayList<>(); //返回的封装网点数据集
|
|
|
+ for (WdInfo wdInfo : PageInfo.getList()) {
|
|
|
+ WdTopologicalInfoBo wdTopologicalInfoBo = new WdTopologicalInfoBo(wdInfo);
|
|
|
+ wdTopologicalInfoBo.setAddrCodeInfo(addrCodeMap.get(wdInfo.getAddrCode()));
|
|
|
+ List<String> tags = wdRedisStoreage.getWdTag(wdInfo);
|
|
|
+ wdTopologicalInfoBo.setTag(tags);
|
|
|
+ result.add(wdTopologicalInfoBo);
|
|
|
+ }
|
|
|
+
|
|
|
+ //返回结果集
|
|
|
+ PageInfo.setList(null);
|
|
|
+ HashMap data = new HashMap();
|
|
|
+ data.put("data",result);
|
|
|
+ data.put("page",PageInfo);
|
|
|
+
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<WdInfo> point(String[] channel, String searchText, String[] addrCode, int pageNum, int pageSize) {
|
|
|
+ QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.in("wd_type_code", channel);
|
|
|
+ for (String s : addrCode) {
|
|
|
+ queryWrapper.and(originWdInfoQueryWrapper -> {
|
|
|
+ originWdInfoQueryWrapper.eq("addr_code",s);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (searchText != null && !searchText.trim().equals("")) {
|
|
|
+ queryWrapper.and(originWdInfoQueryWrapper -> {
|
|
|
+ originWdInfoQueryWrapper.like("wd_name", searchText);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ List<WdInfo> originWdInfos = originWdInfoDao.selectList(queryWrapper);
|
|
|
+ PageInfo<WdInfo> PageInfo = new PageInfo<>(originWdInfos);
|
|
|
+ return PageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据条件获取网点(分页)
|
|
|
+ * */
|
|
|
+ public PageInfo<WdInfo> getQueryPageWd(ChannelMapAceeptVo channelMapAceeptVo){
|
|
|
+ //1.根据不同级别得到需要查询的 地区码
|
|
|
List<String> addrCodeList = new ArrayList<>();
|
|
|
- if ("province".equals(rankType)) {
|
|
|
+ if ("province".equals(channelMapAceeptVo.getRankType())) {
|
|
|
//省码
|
|
|
- for (String s : addrCode) {
|
|
|
+ for (String s : channelMapAceeptVo.getAddrCode()) {
|
|
|
String substring = s.substring(0, 2);
|
|
|
addrCodeList.add(substring);
|
|
|
}
|
|
|
- } else if ("city".equals(rankType)) {
|
|
|
+ } else if ("city".equals(channelMapAceeptVo.getRankType())) {
|
|
|
//省的所有市
|
|
|
- for (String s : addrCode) {
|
|
|
+ for (String s : channelMapAceeptVo.getAddrCode()) {
|
|
|
+ String substring = s.substring(0, 2);
|
|
|
+ addrCodeList.add(substring);
|
|
|
+ }
|
|
|
+ } else if ("zone".equals(channelMapAceeptVo.getRankType())) {
|
|
|
+ //市的所有区
|
|
|
+ for (String s : channelMapAceeptVo.getAddrCode()) {
|
|
|
String substring = s.substring(0, 4);
|
|
|
addrCodeList.add(substring);
|
|
|
}
|
|
|
- } else if ("zone".equals(rankType)) {
|
|
|
- //区
|
|
|
- for (String s : addrCode) {
|
|
|
+ } else if ("district".equals(channelMapAceeptVo.getRankType())){
|
|
|
+ //区的所有街道
|
|
|
+ for (String s : channelMapAceeptVo.getAddrCode()) {
|
|
|
String substring = s.substring(0, 6);
|
|
|
addrCodeList.add(substring);
|
|
|
}
|
|
|
- } else {
|
|
|
+ }else
|
|
|
return null;
|
|
|
- }
|
|
|
|
|
|
|
|
|
- //2.根据地区前缀找到所有的网点
|
|
|
+ //2.组装条件构造器找到网点信息网点
|
|
|
+ //2.1 渠道、地区分类
|
|
|
QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.in("wd_type_code", channel).and(originWdInfoQueryWrapper -> {
|
|
|
+ queryWrapper.in("wd_type_code", channelMapAceeptVo.getChannel()).and(originWdInfoQueryWrapper -> {
|
|
|
for (String s : addrCodeList) {
|
|
|
originWdInfoQueryWrapper.likeRight("addr_code", s).or();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- if (searchText != null && !searchText.trim().equals("")) {
|
|
|
+ //搜索字段
|
|
|
+ if (channelMapAceeptVo.getSearchText() != null && !channelMapAceeptVo.getSearchText() .trim().equals("")) {
|
|
|
queryWrapper.and(originWdInfoQueryWrapper -> {
|
|
|
- originWdInfoQueryWrapper.like("wd_name", searchText);
|
|
|
+ originWdInfoQueryWrapper.like("wd_name", channelMapAceeptVo.getSearchText() );
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- if (orderby != null && !orderby.trim().equals("")) {
|
|
|
- queryWrapper.orderByDesc(orderby);
|
|
|
+ //城市等级分类
|
|
|
+ if(channelMapAceeptVo.getCityTier() != null && channelMapAceeptVo.getCityTier().length > 0){
|
|
|
+ List<String> tierCode = new ArrayList<>();
|
|
|
+ for (String s : channelMapAceeptVo.getCityTier()) {
|
|
|
+ List<String> list = cityTierListMap.get(s);
|
|
|
+ if (list != null){
|
|
|
+ tierCode.addAll(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ queryWrapper.and(wdInfoQueryWrapper -> {
|
|
|
+ wdInfoQueryWrapper.in("addr_code",tierCode);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- //获取数据
|
|
|
- PageHelper.startPage(pageNum, pageSize);
|
|
|
+ //排序字段查询
|
|
|
+ if (channelMapAceeptVo.getOrderby() != null && !channelMapAceeptVo.getOrderby().trim().equals("")) {
|
|
|
+ PageHelper.orderBy(channelMapAceeptVo.getOrderby());
|
|
|
+ }
|
|
|
+ PageHelper.startPage(channelMapAceeptVo.getPageNum(), channelMapAceeptVo.getPageSize());
|
|
|
List<WdInfo> originWdInfos = wdInfoDao.selectList(queryWrapper);
|
|
|
PageInfo<WdInfo> PageInfo = new PageInfo<>(originWdInfos);
|
|
|
+ return PageInfo;
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- //组装
|
|
|
- List<WdTopologicalInfoBo> collect = PageInfo.getList().stream().map(wdInfo -> {
|
|
|
-
|
|
|
- List<String> list = new ArrayList<>();
|
|
|
- String tag = wdInfo.getTypeNameBy();
|
|
|
- if(tag != null){
|
|
|
- String[] split = tag.split(":");
|
|
|
- for (String s : split) {
|
|
|
- list.add(s);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 根据条件获取网点
|
|
|
+ * */
|
|
|
+ public List<WdInfo> getQueryWd(ChannelMapAceeptVo channelMapAceeptVo){
|
|
|
+ //1.根据不同级别得到需要查询的 地区码
|
|
|
+ List<String> addrCodeList = new ArrayList<>();
|
|
|
+ if ("province".equals(channelMapAceeptVo.getRankType())) {
|
|
|
+ //省码
|
|
|
+ for (String s : channelMapAceeptVo.getAddrCode()) {
|
|
|
+ String substring = s.substring(0, 2);
|
|
|
+ addrCodeList.add(substring);
|
|
|
}
|
|
|
+ } else if ("city".equals(channelMapAceeptVo.getRankType())) {
|
|
|
+ //省的所有市
|
|
|
+ for (String s : channelMapAceeptVo.getAddrCode()) {
|
|
|
+ String substring = s.substring(0, 2);
|
|
|
+ addrCodeList.add(substring);
|
|
|
+ }
|
|
|
+ } else if ("zone".equals(channelMapAceeptVo.getRankType())) {
|
|
|
+ //市的所有区
|
|
|
+ for (String s : channelMapAceeptVo.getAddrCode()) {
|
|
|
+ String substring = s.substring(0, 4);
|
|
|
+ addrCodeList.add(substring);
|
|
|
+ }
|
|
|
+ } else if ("district".equals(channelMapAceeptVo.getRankType())){
|
|
|
+ //区的所有街道
|
|
|
+ for (String s : channelMapAceeptVo.getAddrCode()) {
|
|
|
+ String substring = s.substring(0, 6);
|
|
|
+ addrCodeList.add(substring);
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ return null;
|
|
|
|
|
|
|
|
|
- WdTopologicalInfoBo wdTopologicalInfoBo = new WdTopologicalInfoBo();
|
|
|
- wdTopologicalInfoBo.setCenterWdId(wdInfo.getWdId());
|
|
|
- wdTopologicalInfoBo.setCenterWdName(wdInfo.getWdName());
|
|
|
- wdTopologicalInfoBo.setCenterWdTypeCode(wdInfo.getWdTypeCode());
|
|
|
- wdTopologicalInfoBo.setAddrCode(wdInfo.getAddrCode());
|
|
|
- wdTopologicalInfoBo.setAddrCodeInfo(addrCodeMap.get(wdInfo.getAddrCode()));
|
|
|
- wdTopologicalInfoBo.setAddrInfo(wdInfo.getAddrInfo());
|
|
|
- wdTopologicalInfoBo.setGeoHash(wdInfo.getGeoHash());
|
|
|
- wdTopologicalInfoBo.setLat(wdInfo.getLat());
|
|
|
- wdTopologicalInfoBo.setLng(wdInfo.getLng());
|
|
|
-
|
|
|
- wdTopologicalInfoBo.setTag(list);
|
|
|
- return wdTopologicalInfoBo;
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
-
|
|
|
- PageInfo.setList(null);
|
|
|
- HashMap result = new HashMap();
|
|
|
- result.put("data",collect);
|
|
|
- result.put("page",PageInfo);
|
|
|
-
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public PageInfo<WdInfo> point(String[] channel, String searchText, String[] addrCode, int pageNum, int pageSize) {
|
|
|
+ //2.组装条件构造器找到网点信息网点
|
|
|
+ //2.1 渠道、地区分类
|
|
|
QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.in("wd_type_code", channel);
|
|
|
- for (String s : addrCode) {
|
|
|
+ queryWrapper.in("wd_type_code", channelMapAceeptVo.getChannel()).and(originWdInfoQueryWrapper -> {
|
|
|
+ for (String s : addrCodeList) {
|
|
|
+ originWdInfoQueryWrapper.likeRight("addr_code", s).or();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //搜索字段
|
|
|
+ if (channelMapAceeptVo.getSearchText() != null && !channelMapAceeptVo.getSearchText() .trim().equals("")) {
|
|
|
queryWrapper.and(originWdInfoQueryWrapper -> {
|
|
|
- originWdInfoQueryWrapper.eq("addr_code",s);
|
|
|
+ originWdInfoQueryWrapper.like("wd_name", channelMapAceeptVo.getSearchText() );
|
|
|
});
|
|
|
}
|
|
|
- if (searchText != null && !searchText.trim().equals("")) {
|
|
|
- queryWrapper.and(originWdInfoQueryWrapper -> {
|
|
|
- originWdInfoQueryWrapper.like("wd_name", searchText);
|
|
|
+
|
|
|
+ //城市等级分类
|
|
|
+ if(channelMapAceeptVo.getCityTier() != null && channelMapAceeptVo.getCityTier().length > 0){
|
|
|
+ List<String> tierCode = new ArrayList<>();
|
|
|
+ for (String s : channelMapAceeptVo.getCityTier()) {
|
|
|
+ List<String> list = cityTierListMap.get(s);
|
|
|
+ if (list != null){
|
|
|
+ tierCode.addAll(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ queryWrapper.and(wdInfoQueryWrapper -> {
|
|
|
+ wdInfoQueryWrapper.in("addr_code",tierCode);
|
|
|
});
|
|
|
}
|
|
|
- PageHelper.startPage(pageNum, pageSize);
|
|
|
- List<WdInfo> originWdInfos = originWdInfoDao.selectList(queryWrapper);
|
|
|
- PageInfo<WdInfo> PageInfo = new PageInfo<>(originWdInfos);
|
|
|
- return PageInfo;
|
|
|
+
|
|
|
+
|
|
|
+ List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
|
|
|
+ return wdInfos;
|
|
|
}
|
|
|
}
|