|
@@ -1,6 +1,7 @@
|
|
|
package com.ruoyi.demo.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
@@ -11,6 +12,7 @@ import com.ruoyi.demo.mapper.*;
|
|
|
import com.ruoyi.demo.service.ChannelMapService;
|
|
|
import com.ruoyi.demo.utils.InitMapUtil;
|
|
|
import com.ruoyi.demo.utils.WdRedisStoreage;
|
|
|
+import io.netty.util.concurrent.CompleteFuture;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
@@ -19,8 +21,11 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
@@ -30,9 +35,6 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
@Autowired
|
|
|
private AddrCategoryDao addrCategoryDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private WdInfoDao originWdInfoDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
InitMapUtil initMapUtil;
|
|
|
|
|
@@ -66,8 +68,12 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
EnterpriseWdDao enterpriseWdDao;
|
|
|
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
+ /**
|
|
|
+ * 地图模式:查看所有地区的网点数量(v1.0)
|
|
|
+ * @param channelMapAceeptVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+/* @Override
|
|
|
public WdCount area(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
//1.根据不同级别得到 需要封装的 地区码
|
|
|
List<String> addrCodeList = new ArrayList<>();
|
|
@@ -217,23 +223,419 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
wdCount.setWdCountBodyList(result);
|
|
|
wdCount.setTotal(total);
|
|
|
return wdCount;
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 地图模式:查看所有地区的网点数量(v2.0)
|
|
|
+ * @param channelMapAceeptVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public WdCount area(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
+ //1.根据不同级别得到 需要查询的 网点地区码
|
|
|
+ CompletableFuture<List<String>> completableFuture1 = CompletableFuture.supplyAsync(() -> {
|
|
|
+ return findWdAddrCode(channelMapAceeptVo.getRankType(),channelMapAceeptVo.getAddrCode());
|
|
|
+ });
|
|
|
+
|
|
|
+ //2.找到所有需要封装的 地区信息
|
|
|
+ CompletableFuture<List<AddrCategory>> completableFuture2 = CompletableFuture.supplyAsync(() -> {
|
|
|
+ return findCenterAddrCode(channelMapAceeptVo.getRankType(),channelMapAceeptVo.getAddrCode());
|
|
|
+ });
|
|
|
+
|
|
|
+ List<AddrCategory> addrCategories = completableFuture2.join();
|
|
|
+
|
|
|
+ //3.组装地区信息
|
|
|
+ List<WdCountBody> result = new ArrayList<>();
|
|
|
+ HashMap<String,Integer> statistics = new HashMap<>(); //初始化统计信息
|
|
|
+ for (AddrCategory addrCategory : addrCategories) {
|
|
|
+ WdCountBody wdCountBody = new WdCountBody();
|
|
|
+
|
|
|
+ //组装
|
|
|
+ wdCountBody.setLat(addrCategory.getLatGd());
|
|
|
+ wdCountBody.setLng(addrCategory.getLngGd());
|
|
|
+ wdCountBody.setAddrCode(addrCategory.getAddrCode());
|
|
|
+ if ("province".equals(channelMapAceeptVo.getRankType())) {
|
|
|
+ wdCountBody.setName(addrCategory.getProvince());
|
|
|
+ statistics.put(addrCategory.getAddrCode().substring(0,2),0);
|
|
|
+ } else if ("city".equals(channelMapAceeptVo.getRankType())) {
|
|
|
+ wdCountBody.setName(addrCategory.getCity());
|
|
|
+ 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.组装条件构造器找到网点信息网点
|
|
|
+ //2.1 渠道、地区分类
|
|
|
+ List<String> wdAddrCodes = completableFuture1.join();
|
|
|
+ QueryWrapper<WdInfo> queryWrapper2 = new QueryWrapper<>();
|
|
|
+ queryWrapper2.select("addr_code","count(*) as audit");
|
|
|
+ queryWrapper2.in("wd_type_code", channelMapAceeptVo.getChannel()).and(originWdInfoQueryWrapper -> {
|
|
|
+ originWdInfoQueryWrapper.in("addr_code",wdAddrCodes);
|
|
|
+ });
|
|
|
+
|
|
|
+ //搜索字段
|
|
|
+ if (channelMapAceeptVo.getSearchText() != null && !channelMapAceeptVo.getSearchText().trim().equals("")) {
|
|
|
+ queryWrapper2.and(originWdInfoQueryWrapper -> {
|
|
|
+ originWdInfoQueryWrapper.like("wd_name", channelMapAceeptVo.getSearchText() );
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //城市等级分类
|
|
|
+ if(channelMapAceeptVo.getCityTier() != null && channelMapAceeptVo.getCityTier().length > 0){
|
|
|
+ List<String> tierCode = new ArrayList<>();
|
|
|
+ for (String s : channelMapAceeptVo.getCityTier()) {
|
|
|
+ List<String> list = initMapUtil.getInitCityTierListMap(s);
|
|
|
+ if (list != null){
|
|
|
+ tierCode.addAll(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ queryWrapper2.and(wdInfoQueryWrapper -> {
|
|
|
+ wdInfoQueryWrapper.in("addr_code",tierCode);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ queryWrapper2.groupBy("addr_code");
|
|
|
+
|
|
|
+ //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))+wdInfo.getAudit());
|
|
|
+ } else if ("city".equals(channelMapAceeptVo.getRankType())) {
|
|
|
+ statistics.put(wdInfo.getAddrCode().substring(0,4),statistics.get(wdInfo.getAddrCode().substring(0,4))+wdInfo.getAudit());
|
|
|
+ } else if ("zone".equals(channelMapAceeptVo.getRankType())) {
|
|
|
+ statistics.put(wdInfo.getAddrCode().substring(0,6),statistics.get(wdInfo.getAddrCode().substring(0,6))+wdInfo.getAudit());
|
|
|
+ }
|
|
|
+ total+=+wdInfo.getAudit();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //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,6);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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();
|
|
|
+ wdCountBody.setRadio(v);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ wdCountBody.setRadio(0.0f);
|
|
|
+ }
|
|
|
+
|
|
|
+ //5.封装结果
|
|
|
+ WdCount wdCount = new WdCount();
|
|
|
+ wdCount.setWdCountBodyList(result);
|
|
|
+ wdCount.setTotal(total);
|
|
|
+ return wdCount;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 地图模式:查看省级地区的网点数量(v2.0)
|
|
|
+ * @param channelMapAceeptVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public WdCount areaProvince(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
+ //1.找到所有需要封装的 地区信息
|
|
|
+ List<AddrCategory> addrCategories = findCenterAddrCode(channelMapAceeptVo.getRankType(),channelMapAceeptVo.getAddrCode());
|
|
|
+
|
|
|
+ //2.组装地区信息
|
|
|
+ List<WdCountBody> result = new ArrayList<>();
|
|
|
+ HashMap<String,Integer> statistics = new HashMap<>(); //初始化统计信息
|
|
|
+ for (AddrCategory addrCategory : addrCategories) {
|
|
|
+ WdCountBody wdCountBody = new WdCountBody();
|
|
|
+
|
|
|
+ //组装
|
|
|
+ wdCountBody.setLat(addrCategory.getLatGd());
|
|
|
+ wdCountBody.setLng(addrCategory.getLngGd());
|
|
|
+ wdCountBody.setAddrCode(addrCategory.getAddrCode());
|
|
|
+ wdCountBody.setName(addrCategory.getProvince());
|
|
|
+ statistics.put(addrCategory.getAddrCode().substring(0,2),0);
|
|
|
+ result.add(wdCountBody);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //3.找到符合条件的网点信息
|
|
|
+ QueryWrapper<WdInfo> queryWrapper2 = new QueryWrapper<>();
|
|
|
+ queryWrapper2.select("addr_code","count(*) as audit");
|
|
|
+ assembleQueryWrapper(queryWrapper2,channelMapAceeptVo);
|
|
|
+ queryWrapper2.groupBy("addr_code");
|
|
|
+
|
|
|
+
|
|
|
+ //4.统计各个地区网点数量
|
|
|
+ int total = 0;
|
|
|
+ List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper2);
|
|
|
+ for (WdInfo wdInfo : wdInfos) {
|
|
|
+ statistics.put(wdInfo.getAddrCode().substring(0,2),statistics.get(wdInfo.getAddrCode().substring(0,2))+wdInfo.getAudit());
|
|
|
+ total+=+wdInfo.getAudit();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //5.计算radio
|
|
|
+ for (WdCountBody wdCountBody : result) {
|
|
|
+ String code = null;
|
|
|
+ code = wdCountBody.getAddrCode().substring(0,2);
|
|
|
+ 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();
|
|
|
+ wdCountBody.setRadio(v);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ wdCountBody.setRadio(0.0f);
|
|
|
+ }
|
|
|
+
|
|
|
+ //5.封装结果
|
|
|
+ WdCount wdCount = new WdCount();
|
|
|
+ wdCount.setWdCountBodyList(result);
|
|
|
+ wdCount.setTotal(total);
|
|
|
+ return wdCount;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 地图模式:查看市级地区的网点数量(v2.0)
|
|
|
+ * @param channelMapAceeptVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public WdCount areaCity(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
+ //1.根据不同级别得到 需要查询的 网点地区码
|
|
|
+ CompletableFuture<List<String>> completableFuture1 = CompletableFuture.supplyAsync(() -> {
|
|
|
+ return findWdAddrCode(channelMapAceeptVo.getRankType(),channelMapAceeptVo.getAddrCode());
|
|
|
+ });
|
|
|
+
|
|
|
+ //2.找到所有需要封装的 地区信息
|
|
|
+ CompletableFuture<List<AddrCategory>> completableFuture2 = CompletableFuture.supplyAsync(() -> {
|
|
|
+ return findCenterAddrCode(channelMapAceeptVo.getRankType(),channelMapAceeptVo.getAddrCode());
|
|
|
+ });
|
|
|
+
|
|
|
+ List<AddrCategory> addrCategories = completableFuture2.join();
|
|
|
+
|
|
|
+ //3.组装地区信息
|
|
|
+ List<WdCountBody> result = new ArrayList<>();
|
|
|
+ HashMap<String,Integer> statistics = new HashMap<>(); //初始化统计信息
|
|
|
+ for (AddrCategory addrCategory : addrCategories) {
|
|
|
+ WdCountBody wdCountBody = new WdCountBody();
|
|
|
+
|
|
|
+ //组装
|
|
|
+ wdCountBody.setLat(addrCategory.getLatGd());
|
|
|
+ wdCountBody.setLng(addrCategory.getLngGd());
|
|
|
+ wdCountBody.setAddrCode(addrCategory.getAddrCode());
|
|
|
+ wdCountBody.setName(addrCategory.getCity());
|
|
|
+ statistics.put(addrCategory.getAddrCode().substring(0,4),0);
|
|
|
+ result.add(wdCountBody);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //4.组装条件构造器找到网点信息网点
|
|
|
+ //2.1 渠道、地区分类
|
|
|
+ List<String> wdAddrCodes = completableFuture1.join();
|
|
|
+ QueryWrapper<WdInfo> queryWrapper2 = new QueryWrapper<>();
|
|
|
+ queryWrapper2.select("addr_code","count(*) as audit");
|
|
|
+ queryWrapper2.in("wd_type_code", channelMapAceeptVo.getChannel()).and(originWdInfoQueryWrapper -> {
|
|
|
+ originWdInfoQueryWrapper.in("addr_code",wdAddrCodes);
|
|
|
+ });
|
|
|
+
|
|
|
+ //搜索字段
|
|
|
+ if (channelMapAceeptVo.getSearchText() != null && !channelMapAceeptVo.getSearchText().trim().equals("")) {
|
|
|
+ queryWrapper2.and(originWdInfoQueryWrapper -> {
|
|
|
+ originWdInfoQueryWrapper.like("wd_name", channelMapAceeptVo.getSearchText() );
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //城市等级分类
|
|
|
+ if(channelMapAceeptVo.getCityTier() != null && channelMapAceeptVo.getCityTier().length > 0){
|
|
|
+ List<String> tierCode = new ArrayList<>();
|
|
|
+ for (String s : channelMapAceeptVo.getCityTier()) {
|
|
|
+ List<String> list = initMapUtil.getInitCityTierListMap(s);
|
|
|
+ if (list != null){
|
|
|
+ tierCode.addAll(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ queryWrapper2.and(wdInfoQueryWrapper -> {
|
|
|
+ wdInfoQueryWrapper.in("addr_code",tierCode);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ queryWrapper2.groupBy("addr_code");
|
|
|
+
|
|
|
+ //5.统计
|
|
|
+ int total = 0;
|
|
|
+ List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper2);
|
|
|
+ for (WdInfo wdInfo : wdInfos) {
|
|
|
+ statistics.put(wdInfo.getAddrCode().substring(0,4),statistics.get(wdInfo.getAddrCode().substring(0,4))+wdInfo.getAudit());
|
|
|
+ total+=+wdInfo.getAudit();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //5.计算radio
|
|
|
+ for (WdCountBody wdCountBody : result) {
|
|
|
+ String code = null;
|
|
|
+ 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();
|
|
|
+ wdCountBody.setRadio(v);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ wdCountBody.setRadio(0.0f);
|
|
|
+ }
|
|
|
+
|
|
|
+ //5.封装结果
|
|
|
+ WdCount wdCount = new WdCount();
|
|
|
+ wdCount.setWdCountBodyList(result);
|
|
|
+ wdCount.setTotal(total);
|
|
|
+ return wdCount;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 地图模式:查看区级地区的网点数量(v2.0)
|
|
|
+ * @param channelMapAceeptVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public WdCount areaZone(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
+ //1.根据不同级别得到 需要查询的 网点地区码
|
|
|
+ CompletableFuture<List<String>> completableFuture1 = CompletableFuture.supplyAsync(() -> {
|
|
|
+ return findWdAddrCode(channelMapAceeptVo.getRankType(),channelMapAceeptVo.getAddrCode());
|
|
|
+ });
|
|
|
+
|
|
|
+ //2.找到所有需要封装的 地区信息
|
|
|
+ CompletableFuture<List<AddrCategory>> completableFuture2 = CompletableFuture.supplyAsync(() -> {
|
|
|
+ return findCenterAddrCode(channelMapAceeptVo.getRankType(),channelMapAceeptVo.getAddrCode());
|
|
|
+ });
|
|
|
+
|
|
|
+ List<AddrCategory> addrCategories = completableFuture2.join();
|
|
|
+
|
|
|
+ //3.组装地区信息
|
|
|
+ List<WdCountBody> result = new ArrayList<>();
|
|
|
+ HashMap<String,Integer> statistics = new HashMap<>(); //初始化统计信息
|
|
|
+ for (AddrCategory addrCategory : addrCategories) {
|
|
|
+ WdCountBody wdCountBody = new WdCountBody();
|
|
|
+
|
|
|
+ //组装
|
|
|
+ wdCountBody.setLat(addrCategory.getLatGd());
|
|
|
+ wdCountBody.setLng(addrCategory.getLngGd());
|
|
|
+ wdCountBody.setAddrCode(addrCategory.getAddrCode());
|
|
|
+ wdCountBody.setName(addrCategory.getDistrict());
|
|
|
+ statistics.put(addrCategory.getAddrCode().substring(0,6),0);
|
|
|
+ result.add(wdCountBody);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //4.组装条件构造器找到网点信息网点
|
|
|
+ //2.1 渠道、地区分类
|
|
|
+ List<String> wdAddrCodes = completableFuture1.join();
|
|
|
+ QueryWrapper<WdInfo> queryWrapper2 = new QueryWrapper<>();
|
|
|
+ queryWrapper2.select("addr_code","count(*) as audit");
|
|
|
+ queryWrapper2.in("wd_type_code", channelMapAceeptVo.getChannel()).and(originWdInfoQueryWrapper -> {
|
|
|
+ originWdInfoQueryWrapper.in("addr_code",wdAddrCodes);
|
|
|
+ });
|
|
|
+
|
|
|
+ //搜索字段
|
|
|
+ if (channelMapAceeptVo.getSearchText() != null && !channelMapAceeptVo.getSearchText().trim().equals("")) {
|
|
|
+ queryWrapper2.and(originWdInfoQueryWrapper -> {
|
|
|
+ originWdInfoQueryWrapper.like("wd_name", channelMapAceeptVo.getSearchText() );
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //城市等级分类
|
|
|
+ if(channelMapAceeptVo.getCityTier() != null && channelMapAceeptVo.getCityTier().length > 0){
|
|
|
+ List<String> tierCode = new ArrayList<>();
|
|
|
+ for (String s : channelMapAceeptVo.getCityTier()) {
|
|
|
+ List<String> list = initMapUtil.getInitCityTierListMap(s);
|
|
|
+ if (list != null){
|
|
|
+ tierCode.addAll(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ queryWrapper2.and(wdInfoQueryWrapper -> {
|
|
|
+ wdInfoQueryWrapper.in("addr_code",tierCode);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ queryWrapper2.groupBy("addr_code");
|
|
|
+
|
|
|
+ //5.统计
|
|
|
+ int total = 0;
|
|
|
+ List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper2);
|
|
|
+ for (WdInfo wdInfo : wdInfos) {
|
|
|
+ statistics.put(wdInfo.getAddrCode().substring(0,6),statistics.get(wdInfo.getAddrCode().substring(0,6))+wdInfo.getAudit());
|
|
|
+ total+=+wdInfo.getAudit();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //5.计算radio
|
|
|
+ for (WdCountBody wdCountBody : result) {
|
|
|
+ String code = null;
|
|
|
+ code = wdCountBody.getAddrCode().substring(0,6);
|
|
|
+
|
|
|
+ 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();
|
|
|
+ wdCountBody.setRadio(v);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ wdCountBody.setRadio(0.0f);
|
|
|
+ }
|
|
|
+
|
|
|
+ //5.封装结果
|
|
|
+ WdCount wdCount = new WdCount();
|
|
|
+ wdCount.setWdCountBodyList(result);
|
|
|
+ wdCount.setTotal(total);
|
|
|
+ return wdCount;
|
|
|
+ }
|
|
|
|
|
|
- //TODO 待测试(redis版本)
|
|
|
+ /**
|
|
|
+ * 获取网点列表
|
|
|
+ * @param channelMapAceeptVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
public HashMap list(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
//1.根据条件获取网点
|
|
|
QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
|
|
|
-
|
|
|
- PageHelper.startPage(channelMapAceeptVo.getPageNum(), channelMapAceeptVo.getPageSize());
|
|
|
- List<WdInfo> originWdInfos = wdInfoDao.selectList(queryWrapper);
|
|
|
- PageInfo<WdInfo> PageInfo = new PageInfo<>(originWdInfos);
|
|
|
+ Page<WdInfo> page = new Page<>(channelMapAceeptVo.getPageNum(), channelMapAceeptVo.getPageSize());
|
|
|
+ Page<WdInfo> page1 = wdInfoDao.selectPage(page, queryWrapper);
|
|
|
|
|
|
//2.获取标签并组装
|
|
|
List<WdTopologicalInfoBo> result = new ArrayList<>(); //返回的封装网点数据集
|
|
|
- for (WdInfo wdInfo : PageInfo.getList()) {
|
|
|
+ for (WdInfo wdInfo : page1.getRecords()) {
|
|
|
WdTopologicalInfoBo wdTopologicalInfoBo = new WdTopologicalInfoBo(wdInfo);
|
|
|
wdTopologicalInfoBo.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(wdInfo.getAddrCode()));
|
|
|
List<String> tags = wdRedisStoreage.getWdTag(wdInfo);
|
|
@@ -241,35 +643,45 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
result.add(wdTopologicalInfoBo);
|
|
|
}
|
|
|
|
|
|
- //返回结果集
|
|
|
- PageInfo.setList(null);
|
|
|
+ //3.返回结果集
|
|
|
+ page1.setRecords(null);
|
|
|
HashMap data = new HashMap();
|
|
|
data.put("data",result);
|
|
|
- data.put("page",PageInfo);
|
|
|
+ data.put("page",page1);
|
|
|
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取区下的具体网点信息
|
|
|
+ * @param channelMapAceeptVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
- public PageInfo<WdInfo> point(String[] channel, String searchText, String[] addrCode, int pageNum, int pageSize) {
|
|
|
+ public Page<WdInfo> point(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
+ //1.查找符合条件的网点
|
|
|
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.eq("addr_code",channelMapAceeptVo.getAddrCode()[0])
|
|
|
+ .and(wdInfoQueryWrapper -> {
|
|
|
+ wdInfoQueryWrapper.in("wd_type_code", channelMapAceeptVo.getChannel());
|
|
|
+ });
|
|
|
+
|
|
|
+ if (channelMapAceeptVo.getSearchText() != null && !channelMapAceeptVo.getSearchText().trim().equals("")) {
|
|
|
queryWrapper.and(originWdInfoQueryWrapper -> {
|
|
|
- originWdInfoQueryWrapper.like("wd_name", searchText);
|
|
|
+ originWdInfoQueryWrapper.like("wd_name", channelMapAceeptVo.getSearchText());
|
|
|
});
|
|
|
}
|
|
|
- PageHelper.startPage(pageNum, pageSize);
|
|
|
- List<WdInfo> originWdInfos = originWdInfoDao.selectList(queryWrapper);
|
|
|
- PageInfo<WdInfo> PageInfo = new PageInfo<>(originWdInfos);
|
|
|
- return PageInfo;
|
|
|
+
|
|
|
+ Page<WdInfo> page = new Page<>(channelMapAceeptVo.getPageNum(), channelMapAceeptVo.getPageSize());
|
|
|
+ Page<WdInfo> page1 = wdInfoDao.selectPage(page, queryWrapper);
|
|
|
+ return page1;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取网点详细信息
|
|
|
+ * @param wdId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
public WdInfo getWdInfo(String wdId) {
|
|
|
QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
@@ -280,6 +692,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
return wdInfo;
|
|
|
|
|
|
if("1".equals(wdInfo.getWdTypeCode())){
|
|
|
+ //门店网点
|
|
|
QueryWrapper<StoreWd> queryWrapper1 = new QueryWrapper<>();
|
|
|
queryWrapper1.eq("wd_id",wdId);
|
|
|
StoreWd storeWd = storeWdDao.selectOne(queryWrapper1);
|
|
@@ -289,6 +702,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
storeWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(storeWdInfoBo.getAddrCode()));
|
|
|
return storeWdInfoBo;
|
|
|
}else if("2".equals(wdInfo.getWdTypeCode())){
|
|
|
+ //小区网点
|
|
|
QueryWrapper<HouseWd> queryWrapper1 = new QueryWrapper<>();
|
|
|
queryWrapper1.eq("wd_id",wdId);
|
|
|
HouseWd houseWd = houseWdDao.selectOne(queryWrapper1);
|
|
@@ -298,6 +712,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
houseWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(houseWdInfoBo.getAddrCode()));
|
|
|
return houseWdInfoBo;
|
|
|
}else if("3".equals(wdInfo.getWdTypeCode())){
|
|
|
+ //楼宇网点
|
|
|
QueryWrapper<BuildWd> queryWrapper1 = new QueryWrapper<>();
|
|
|
queryWrapper1.eq("wd_id",wdId);
|
|
|
BuildWd buildWd = buildWdDao.selectOne(queryWrapper1);
|
|
@@ -307,6 +722,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
buildWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(buildWdInfoBo.getAddrCode()));
|
|
|
return buildWdInfoBo;
|
|
|
}else if("4".equals(wdInfo.getWdTypeCode())){
|
|
|
+ //交通设施网点
|
|
|
QueryWrapper<TrafficWd> queryWrapper1 = new QueryWrapper<>();
|
|
|
queryWrapper1.eq("wd_id",wdId);
|
|
|
TrafficWd trafficWd = trafficWdDao.selectOne(queryWrapper1);
|
|
@@ -316,6 +732,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
trafficWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(trafficWdInfoBo.getAddrCode()));
|
|
|
return trafficWdInfoBo;
|
|
|
}else if("5".equals(wdInfo.getWdTypeCode())){
|
|
|
+ //企业网点
|
|
|
QueryWrapper<EnterpriseWd> queryWrapper1 = new QueryWrapper<>();
|
|
|
queryWrapper1.eq("wd_id",wdId);
|
|
|
EnterpriseWd enterpriseWd = enterpriseWdDao.selectOne(queryWrapper1);
|
|
@@ -329,45 +746,33 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
return wdInfo;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 封装网点过滤条件(v2.0)
|
|
|
+ * @param queryWrapper
|
|
|
+ * @param channelMapAceeptVo
|
|
|
+ */
|
|
|
public void assembleQueryWrapper(QueryWrapper<WdInfo> queryWrapper,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);
|
|
|
- }
|
|
|
+ List<String> wdAddrCode = findWdAddrCode(channelMapAceeptVo.getRankType(), channelMapAceeptVo.getAddrCode());
|
|
|
+
|
|
|
+ //店龄
|
|
|
+ if(channelMapAceeptVo.getStoreAge() != null && !channelMapAceeptVo.getStoreAge().equals("")){
|
|
|
+ queryWrapper.and(wdInfoQueryWrapper -> {
|
|
|
+ wdInfoQueryWrapper.eq("store_age",channelMapAceeptVo.getStoreAge());
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- queryWrapper.in("wd_type_code", channelMapAceeptVo.getChannel()).and(originWdInfoQueryWrapper -> {
|
|
|
- for (String s : addrCodeList) {
|
|
|
- originWdInfoQueryWrapper.likeRight("addr_code", s).or();
|
|
|
- }
|
|
|
+ //地区过滤
|
|
|
+ queryWrapper.and(wdInfoQueryWrapper -> {
|
|
|
+ wdInfoQueryWrapper.in("addr_code", wdAddrCode);
|
|
|
});
|
|
|
|
|
|
- //搜索字段
|
|
|
- if (channelMapAceeptVo.getSearchText() != null && !channelMapAceeptVo.getSearchText() .trim().equals("")) {
|
|
|
- queryWrapper.and(originWdInfoQueryWrapper -> {
|
|
|
- originWdInfoQueryWrapper.like("wd_name", channelMapAceeptVo.getSearchText() );
|
|
|
+
|
|
|
+ //渠道过滤
|
|
|
+ if(channelMapAceeptVo.getChannel() != null && channelMapAceeptVo.getChannel().length != 6){
|
|
|
+ queryWrapper.and(wdInfoQueryWrapper -> {
|
|
|
+ wdInfoQueryWrapper.in("wd_type_code", channelMapAceeptVo.getChannel());
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -381,9 +786,29 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
}
|
|
|
}
|
|
|
queryWrapper.and(wdInfoQueryWrapper -> {
|
|
|
- for (String s : tierCode) {
|
|
|
- wdInfoQueryWrapper.likeRight("addr_code", s).or();
|
|
|
- }
|
|
|
+ wdInfoQueryWrapper.in("addr_code",tierCode);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //是否关联品牌
|
|
|
+ if(channelMapAceeptVo.getIsBrand() != null && !channelMapAceeptVo.getIsBrand().equals("")){
|
|
|
+ queryWrapper.and(wdInfoQueryWrapper -> {
|
|
|
+ wdInfoQueryWrapper.isNotNull("brand_name");
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否有联系方式
|
|
|
+ if(channelMapAceeptVo.getIsTelephone() != null && !channelMapAceeptVo.getIsTelephone().equals("")){
|
|
|
+ queryWrapper.and(wdInfoQueryWrapper -> {
|
|
|
+ wdInfoQueryWrapper.isNotNull("teletphone");
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //搜索字段
|
|
|
+ if (channelMapAceeptVo.getSearchText() != null && !channelMapAceeptVo.getSearchText() .trim().equals("")) {
|
|
|
+ queryWrapper.and(originWdInfoQueryWrapper -> {
|
|
|
+ originWdInfoQueryWrapper.like("wd_name", channelMapAceeptVo.getSearchText() );
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -395,4 +820,89 @@ public class ChannelMapServiceImpl implements ChannelMapService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 找到所有满足条件的网点addrCode
|
|
|
+ * @param rankType
|
|
|
+ * @param addrCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<String> findWdAddrCode(String rankType,String[] addrCode){
|
|
|
+ //1.根据不同级别得到 找到所有 完整的 区码
|
|
|
+ List<String> addrCodeList = new ArrayList<>();
|
|
|
+ if ("province".equals(rankType)) {
|
|
|
+ //addrCode:省码
|
|
|
+ for (String string:addrCode)
|
|
|
+ addrCodeList.add(string.substring(0, 2));
|
|
|
+ } else if ("city".equals(rankType)) {
|
|
|
+ //addrCode:省码(只允许有一个)
|
|
|
+ String substring = addrCode[0].substring(0, 2); //根据该省码找到旗下的所有的区
|
|
|
+ addrCodeList.add(substring);
|
|
|
+ } else if ("zone".equals(rankType)) {
|
|
|
+ //addrCode:市码(只允许有一个)
|
|
|
+ String substring = addrCode[0].substring(0, 4); //根据该市码找到旗下的所有的区
|
|
|
+ addrCodeList.add(substring);
|
|
|
+ } else {
|
|
|
+ for (String string:addrCode)
|
|
|
+ addrCodeList.add(string.substring(0, 2));
|
|
|
+ }
|
|
|
+
|
|
|
+ //2.找到所有完整的区码
|
|
|
+ QueryWrapper<AddrCategory> queryWrapper1 = new QueryWrapper<>();
|
|
|
+ queryWrapper1.ne("district", "");
|
|
|
+ queryWrapper1.and(addrCategoryQueryWrapper -> {
|
|
|
+ for (String s : addrCodeList) {
|
|
|
+ addrCategoryQueryWrapper.likeRight("addr_code", s).or();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<AddrCategory> addrCategories1 = addrCategoryDao.selectList(queryWrapper1);
|
|
|
+ List<String> collect = addrCategories1.stream().map(item -> {
|
|
|
+ return item.getAddrCode();
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ return collect;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 找到需要展示的中心addrCode
|
|
|
+ * @param rankType
|
|
|
+ * @param addrCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<AddrCategory> findCenterAddrCode(String rankType,String[] addrCode){
|
|
|
+ //1.根据不同级别得到 找到所有 完整的 区码
|
|
|
+ List<String> addrCodeList = new ArrayList<>();
|
|
|
+ if ("province".equals(rankType)) {
|
|
|
+ //addrCode:省码
|
|
|
+ addrCodeList.addAll(Arrays.asList(addrCode));
|
|
|
+ } else if ("city".equals(rankType)) {
|
|
|
+ //addrCode:省码(只允许有一个)
|
|
|
+ String substring = addrCode[0].substring(0, 2); //根据该省码找到旗下的所有的区
|
|
|
+ addrCodeList.add(substring);
|
|
|
+ } else if ("zone".equals(rankType)) {
|
|
|
+ //addrCode:市码(只允许有一个)
|
|
|
+ String substring = addrCode[0].substring(0, 4); //根据该市码找到旗下的所有的区
|
|
|
+ addrCodeList.add(substring);
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //2.找到所有需要封装的 地区信息
|
|
|
+ QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
|
|
|
+ if ("province".equals(rankType)) {
|
|
|
+ queryWrapper.eq("city", "");
|
|
|
+ } else if ("city".equals(rankType)) {
|
|
|
+ queryWrapper.eq("district", "").and(addrCategoryQueryWrapper -> {
|
|
|
+ addrCategoryQueryWrapper.ne("city", "");
|
|
|
+ });
|
|
|
+ } else if ("zone".equals(rankType)) {
|
|
|
+ queryWrapper.ne("district", "");
|
|
|
+ }
|
|
|
+ queryWrapper.and(addrCategoryQueryWrapper -> {
|
|
|
+ for (String s : addrCodeList) {
|
|
|
+ addrCategoryQueryWrapper.likeRight("addr_code", s).or();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<AddrCategory> addrCategories = addrCategoryDao.selectList(queryWrapper);
|
|
|
+ return addrCategories;
|
|
|
+ }
|
|
|
}
|