Explorar o código

Merge branch 'master' into lcy

云殇忆 hai 1 ano
pai
achega
eb838ecb7b
Modificáronse 33 ficheiros con 1617 adicións e 779 borrados
  1. 77 30
      ruoyi-demo/src/main/java/com/ruoyi/demo/controller/ChannelAnalyseController.java
  2. 127 15
      ruoyi-demo/src/main/java/com/ruoyi/demo/controller/ChannelMapController.java
  3. 3 2
      ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TopologicalBuildWdController.java
  4. 3 2
      ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TopologicalCommonController.java
  5. 3 2
      ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TopologicalEnterpriseWdController.java
  6. 3 2
      ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TopologicalHouseWdController.java
  7. 14 4
      ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TopologicalStoreWdController.java
  8. 6 11
      ruoyi-demo/src/main/java/com/ruoyi/demo/entity/TopologicalBuildingWd.java
  9. 5 0
      ruoyi-demo/src/main/java/com/ruoyi/demo/entity/TopologicalEnterpriseWd.java
  10. 6 12
      ruoyi-demo/src/main/java/com/ruoyi/demo/entity/TopologicalHouseWd.java
  11. 4 18
      ruoyi-demo/src/main/java/com/ruoyi/demo/entity/TopologicalStoreWd.java
  12. 3 1
      ruoyi-demo/src/main/java/com/ruoyi/demo/entity/bo/Histogram.java
  13. 0 1
      ruoyi-demo/src/main/java/com/ruoyi/demo/entity/bo/StoreWdCategoryCount.java
  14. 5 0
      ruoyi-demo/src/main/java/com/ruoyi/demo/entity/vo/ChannelMapAceeptVo.java
  15. 27 23
      ruoyi-demo/src/main/java/com/ruoyi/demo/entity/vo/TopologicalWdAceeptVo.java
  16. 1 2
      ruoyi-demo/src/main/java/com/ruoyi/demo/init/BenyunCoreInit.java
  17. 2 1
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/ChannelAnalyseService.java
  18. 8 1
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/ChannelMapService.java
  19. 2 1
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/TopologicalBuildWdSerevice.java
  20. 1 2
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/TopologicalCommonService.java
  21. 2 1
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/TopologicalEnterpriseWdService.java
  22. 2 1
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/TopologicalHouseWdService.java
  23. 2 1
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/TopologicalStoreWdService.java
  24. 330 213
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/ChannelAnalyseServiceImpl.java
  25. 573 63
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/ChannelMapServiceImpl.java
  26. 84 82
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalBuildWdSereviceImpl.java
  27. 51 60
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalCommonServiceImpl.java
  28. 61 39
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalEnterpriseWdServiceImpl.java
  29. 77 62
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalHouseServiceWdImpl.java
  30. 132 122
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalStoreWdServiceImpl.java
  31. 1 1
      ruoyi-demo/src/main/java/com/ruoyi/demo/utils/InitMapUtil.java
  32. 0 2
      ruoyi-demo/src/main/java/com/ruoyi/demo/utils/WdRedisStoreage.java
  33. 2 2
      ruoyi-demo/src/main/resources/mapper/demo/StoreWdDaoMapper.xml

+ 77 - 30
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/ChannelAnalyseController.java

@@ -1,5 +1,6 @@
 package com.ruoyi.demo.controller;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageInfo;
 
 import com.ruoyi.common.core.domain.R;
@@ -11,8 +12,10 @@ import com.ruoyi.demo.entity.vo.ChannelAnalyseAceeptVo;
 import com.ruoyi.demo.entity.vo.ChannelMapAceeptVo;
 import com.ruoyi.demo.entity.vo.TagAnalyse;
 import com.ruoyi.demo.service.ChannelAnalyseService;
+import com.ruoyi.demo.valida.ChannelAreaGroup;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -23,70 +26,90 @@ import java.util.Hashtable;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
+/**
+ * 渠道地图模块:渠道分析
+ */
 @RestController
 @RequestMapping("/channelAnalyse")
 public class ChannelAnalyseController {
-
     @Autowired
     ChannelAnalyseService channelAnalyseService;
+
     @Autowired
     RedisTemplate redisTemplate;
 
+    /**
+     * 获取 网点城市等级分布统计
+     * @param channelMapAceeptVo 渠道地图过滤请求接收体
+     * @return
+     */
     @GetMapping("/cityTier")
-    public R cityTier(ChannelMapAceeptVo channelMapAceeptVo){
+    public R cityTier(@Validated(value = ChannelAreaGroup.class) ChannelMapAceeptVo channelMapAceeptVo){
+        //看redis中是否存在有缓存
         String md5 = channelMapAceeptVo.getHash();
-
-        //2.查看redis中是否存在有缓存
         HashMap wdCount = (HashMap) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_CITYTIER).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
 
+        //查询
         HashMap hashMap = channelAnalyseService.cityTier(channelMapAceeptVo);
 
-        //4.保存到redis中
+        //保存到redis中
         redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_CITYTIER).put(md5,hashMap);
-        redisTemplate.expire(RedisContant.CHANNEL_ANALYSE_CITYTIER,RedisContant.CHANNEL_ANALYSE_CITYTIER_TIME, TimeUnit.MINUTES); //30分钟
+        redisTemplate.expire(RedisContant.CHANNEL_ANALYSE_CITYTIER,RedisContant.CHANNEL_ANALYSE_CITYTIER_TIME, TimeUnit.MINUTES);
         return R.ok(hashMap);
     }
 
+    /**
+     * 获取 品牌列表
+     * @param channelAnalyseAceeptVo 渠道地图过滤请求接收体
+     * @return
+     */
     @GetMapping("/brandList")
     public R brandList(ChannelAnalyseAceeptVo channelAnalyseAceeptVo){
+        //查看redis中是否存在有缓存
         String md5 = channelAnalyseAceeptVo.getHash();
-
-        //2.查看redis中是否存在有缓存
-        PageInfo<Brand> wdCount = (PageInfo<Brand>) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_BRANDLIST).get(md5);
+        Page<Brand> wdCount = (Page<Brand>) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_BRANDLIST).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
 
-        PageInfo<Brand> brandPageInfo = channelAnalyseService.brandList(channelAnalyseAceeptVo);
+        //查询
+        Page<Brand> brandPageInfo = channelAnalyseService.brandList(channelAnalyseAceeptVo);
 
-        //4.保存到redis中
+        //保存到redis中
         redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_BRANDLIST).put(md5,brandPageInfo);
-        redisTemplate.expire(RedisContant.CHANNEL_ANALYSE_BRANDLIST,RedisContant.CHANNEL_ANALYSE_BRANDLIST_TIME, TimeUnit.MINUTES); //30分钟
+        redisTemplate.expire(RedisContant.CHANNEL_ANALYSE_BRANDLIST,RedisContant.CHANNEL_ANALYSE_BRANDLIST_TIME, TimeUnit.MINUTES);
         return R.ok(brandPageInfo);
     }
 
+    /**
+     * 获取 网点分类统计
+     * @param channelMapAceeptVo 渠道地图过滤请求接收体
+     * @return
+     */
     @GetMapping("/category")
-    public R category(ChannelMapAceeptVo channelMapAceeptVo){
+    public R category(@Validated(value = ChannelAreaGroup.class) ChannelMapAceeptVo channelMapAceeptVo){
+        //查看redis中是否存在有缓存
         String md5 = channelMapAceeptVo.getHash();
-
-        //2.查看redis中是否存在有缓存
         List<StoreWdCategoryCount> wdCount = (List<StoreWdCategoryCount>) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_CATEGORY).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
 
-
+        //查询
         List<StoreWdCategoryCount> category = channelAnalyseService.category(channelMapAceeptVo);
+
+        //存入redis
         redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_CATEGORY).put(md5,category);
         redisTemplate.expire(RedisContant.CHANNEL_ANALYSE_CATEGORY,RedisContant.CHANNEL_ANALYSE_CATEGORY_TIME, TimeUnit.MINUTES); //30分钟
         return R.ok(category);
     }
 
+    //TODO 待优化
     @GetMapping("/tagAnalyse")
-    public R tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo){
+    public R tagAnalyse(@Validated(value = ChannelAreaGroup.class) ChannelMapAceeptVo channelMapAceeptVo){
         Integer page = channelMapAceeptVo.getPageNum() == null ? 1:channelMapAceeptVo.getPageNum();
         channelMapAceeptVo.setPageNum(0);
         String md5 = channelMapAceeptVo.getHash();
@@ -112,26 +135,38 @@ public class ChannelAnalyseController {
         return R.ok(result);
     }
 
+    /**
+     * 获取 网点营业状态统计
+     * @param channelMapAceeptVo 渠道地图过滤请求接收体
+     * @return
+     */
     @GetMapping("/businessStatusAnalyse")
-    public R businessStatusAnalyse(ChannelMapAceeptVo channelMapAceeptVo){
+    public R businessStatusAnalyse(@Validated(value = ChannelAreaGroup.class) ChannelMapAceeptVo channelMapAceeptVo){
+        //查看redis中是否存在有缓存
         String md5 = channelMapAceeptVo.getHash();
-
-        //2.查看redis中是否存在有缓存
         HashMap<String,Integer> wdCount = (HashMap<String,Integer>) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_BUSINESS_STATUS_ANALYSE).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
+
+        //查询
         HashMap<String,Integer> hashMap = channelAnalyseService.businessStatusAnalyse(channelMapAceeptVo);
 
-        //4.保存到redis中
+        //保存到redis中
         redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_BUSINESS_STATUS_ANALYSE).put(md5,hashMap);
         redisTemplate.expire(RedisContant.CHANNEL_ANALYSE_BUSINESS_STATUS_ANALYSE,RedisContant.CHANNEL_ANALYSE_BUSINESS_STATUS_ANALYSE_TIME, TimeUnit.MINUTES); //30分钟
 
         return R.ok(hashMap);
     }
 
+
+    /**
+     * 获取 楼宇类型数量统计
+     * @param channelMapAceeptVo
+     * @return
+     */
     @GetMapping("/aroundBuildAnalyse")
-    public R aroundBuildAnalyse(ChannelMapAceeptVo channelMapAceeptVo){
+    public R aroundBuildAnalyse(@Validated(value = ChannelAreaGroup.class) ChannelMapAceeptVo channelMapAceeptVo){
         String md5 = channelMapAceeptVo.getHash();
 
         //2.查看redis中是否存在有缓存
@@ -148,36 +183,48 @@ public class ChannelAnalyseController {
         return R.ok(hashtable);
     }
 
+    /**
+     * 获取 人均消费统计
+     * @param channelMapAceeptVo
+     * @return
+     */
     @GetMapping("/perCapitaConsumpAnalyse")
-    public R perCapitaConsumpAnalyse(ChannelMapAceeptVo channelMapAceeptVo){
+    public R perCapitaConsumpAnalyse(@Validated(value = ChannelAreaGroup.class) ChannelMapAceeptVo channelMapAceeptVo){
+        //查看redis中是否存在有缓存
         String md5 = channelMapAceeptVo.getHash();
-
-        //2.查看redis中是否存在有缓存
         ArrayList<Histogram> wdCount = (ArrayList<Histogram>) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_PER_CAPITA_CONSUMP_ANALYSE).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
+
+        //查询
         ArrayList<Histogram> hashtable = channelAnalyseService.perCapitaConsumpAnalyse(channelMapAceeptVo);
 
-        //4.保存到redis中
+        //保存到redis中
         redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_PER_CAPITA_CONSUMP_ANALYSE).put(md5,hashtable);
         redisTemplate.expire(RedisContant.CHANNEL_ANALYSE_PER_CAPITA_CONSUMP_ANALYSE,RedisContant.CHANNEL_ANALYSE_PER_CAPITA_CONSUMP_ANALYSE_TIME, TimeUnit.MINUTES); //30分钟
 
         return R.ok(hashtable);
     }
 
+    /**
+     * 获取 店龄/经营时长统计
+     * @param channelMapAceeptVo
+     * @return
+     */
     @GetMapping("/operateTimeAnalyse")
-    public R operateTimeAnalyse(ChannelMapAceeptVo channelMapAceeptVo){
+    public R operateTimeAnalyse(@Validated(value = ChannelAreaGroup.class) ChannelMapAceeptVo channelMapAceeptVo){
+        //查看redis中是否存在有缓存
         String md5 = channelMapAceeptVo.getHash();
-
-        //2.查看redis中是否存在有缓存
         ArrayList<Histogram> wdCount = (ArrayList<Histogram>) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_OPERATE_TIME_ANALYSE).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
+
+        //查询
         ArrayList<Histogram> hashtable = channelAnalyseService.operateTimeAnalyse(channelMapAceeptVo);
 
-        //4.保存到redis中
+        //保存到redis中
         redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_OPERATE_TIME_ANALYSE).put(md5,hashtable);
         redisTemplate.expire(RedisContant.CHANNEL_ANALYSE_OPERATE_TIME_ANALYSE,RedisContant.CHANNEL_ANALYSE_OPERATE_TIME_ANALYSE_TIME, TimeUnit.MINUTES); //30分钟
 

+ 127 - 15
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/ChannelMapController.java

@@ -2,8 +2,10 @@ package com.ruoyi.demo.controller;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageInfo;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.helper.LoginHelper;
 import com.ruoyi.demo.constant.RedisContant;
 import com.ruoyi.demo.entity.AttentionPool;
 import com.ruoyi.demo.entity.WdInfo;
@@ -26,7 +28,9 @@ import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
-
+/**
+ * 渠道地图模块:渠道地图
+ */
 @RestController
 @RequestMapping("/channelMap")
 
@@ -40,46 +44,134 @@ public class ChannelMapController {
     @Autowired
     AttentionPoolDao attentionPoolDao;
 
+    /**
+     * 地图模式:查看省级别的网点数量
+     * @param channel
+     * @return
+     */
+    @RequestMapping("/getAreaProvince")
+    public R areaProvince(ChannelMapAceeptVo channel) {
+        //1.查看redis中是否存在有缓存
+        channel.setRankType("province");
+        String md5 = channel.getHash();
+//        WdCount wdCount = (WdCount) redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_AREA).get(md5);
+//        if (wdCount != null) {
+//            return R.ok(wdCount);
+//        }
+
+        //2.查询结果
+        WdCount area = channelMapService.areaProvince(channel);
+        if(area == null)
+            return R.fail("请求参数错误");
+
+        //3.保存到redis中
+        redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_AREA).put(md5,area);
+        redisTemplate.expire(RedisContant.CHANNEL_MAP_AREA,RedisContant.CHANNEL_MAP_AREA_TIME, TimeUnit.MINUTES); //30分钟
+        return R.ok(area);
+    }
+
+    /**
+     * 地图模式:查看市级别的网点数量
+     * @param channel
+     * @return
+     */
+    @RequestMapping("/getAreaCity")
+    public R areaCity( ChannelMapAceeptVo channel) {
+        //1.查看redis中是否存在有缓存
+        channel.setRankType("city");
+        String md5 = channel.getHash();
+        WdCount wdCount = (WdCount) redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_AREA).get(md5);
+        if (wdCount != null) {
+            return R.ok(wdCount);
+        }
 
+        //2.查询结果
+        WdCount area = channelMapService.areaCity(channel);
+        if(area == null)
+            return R.fail("请求参数错误");
+
+        //3.保存到redis中
+        redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_AREA).put(md5,area);
+        redisTemplate.expire(RedisContant.CHANNEL_MAP_AREA,RedisContant.CHANNEL_MAP_AREA_TIME, TimeUnit.MINUTES); //30分钟
+        return R.ok(area);
+    }
+
+    /**
+     * 地图模式:查看区级别的网点数量
+     * @param channel
+     * @return
+     */
+    @RequestMapping("/getAreaZone")
+    public R areaZone( ChannelMapAceeptVo channel) {
+        //1.查看redis中是否存在有缓存
+        channel.setRankType("zone");
+        String md5 = channel.getHash();
+        WdCount wdCount = (WdCount) redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_AREA).get(md5);
+        if (wdCount != null) {
+            return R.ok(wdCount);
+        }
+
+        //2.查询结果
+        WdCount area = channelMapService.areaZone(channel);
+        if(area == null)
+            return R.fail("请求参数错误");
+
+        //3.保存到redis中
+        redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_AREA).put(md5,area);
+        redisTemplate.expire(RedisContant.CHANNEL_MAP_AREA,RedisContant.CHANNEL_MAP_AREA_TIME, TimeUnit.MINUTES); //30分钟
+        return R.ok(area);
+    }
+
+
+    /**
+     * 地图模式:查看所有地区的网点数量
+     * @param channel
+     * @return
+     */
     @RequestMapping("/getArea")
     public R area(@Validated(value={ChannelAreaGroup.class}) ChannelMapAceeptVo channel) {
+        //1.查看redis中是否存在有缓存
         String md5 = channel.getHash();
-
-        //2.查看redis中是否存在有缓存
         WdCount wdCount = (WdCount) redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_AREA).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
 
-        //3.redis中没有,直接请求
+        //2.查询结果
         WdCount area = channelMapService.area(channel);
         if(area == null)
             return R.fail("请求参数错误");
 
-        //4.保存到redis中
+        //3.保存到redis中
         redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_AREA).put(md5,area);
         redisTemplate.expire(RedisContant.CHANNEL_MAP_AREA,RedisContant.CHANNEL_MAP_AREA_TIME, TimeUnit.MINUTES); //30分钟
         return R.ok(area);
     }
 
 
+    /**
+     * 获取网点列表
+     * @param channel
+     * @return
+     */
     @RequestMapping("/list")
     public R list(@Validated(value={ChannelListGroup.class}) ChannelMapAceeptVo channel){
-
+        //1.查看redis中是否存在缓存
         String md5 = channel.getHash();
         HashMap pageInfo = (HashMap) redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_LIST).get(md5);
         if(pageInfo != null){
             List<WdTopologicalInfoBo> data = (List<WdTopologicalInfoBo>) pageInfo.get("data");
-            attention(data);
+            attention(data); //是否添加关注
             pageInfo.put("data",data);
             return R.ok(pageInfo);
         }
 
+        //2.查询结果
         HashMap hashMap = channelMapService.list(channel);
         if(hashMap == null)
             return R.fail("请求参数错误");
 
-        //4.保存到redis中
+        //3.保存到redis中
         List<WdTopologicalInfoBo> data = (List<WdTopologicalInfoBo>) hashMap.get("data");
         attention(data);
         hashMap.put("data",data);
@@ -89,41 +181,56 @@ public class ChannelMapController {
     }
 
 
-
+    /**
+     * 获取区下的具体网点信息
+     * @param channel
+     * @return
+     */
     @RequestMapping("/point")
     public R point(@Validated(value={ChannelPointGroup.class}) ChannelMapAceeptVo channel){
+        //1.查看redis中是否存在缓存
         String md5 = channel.getHash();
-        PageInfo<WdInfo> pageInfo = (PageInfo<WdInfo>) redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_POINT).get(md5);
+        Page<WdInfo> pageInfo = (Page<WdInfo>) redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_POINT).get(md5);
         if(pageInfo != null){
             return R.ok(pageInfo);
         }
 
-        PageInfo<WdInfo> point = channelMapService.point(channel.getChannel(), channel.getSearchText(), channel.getAddrCode(), channel.getPageNum(), channel.getPageSize());
+        //2.查询结果
+        Page<WdInfo> point = channelMapService.point(channel);
         if(point == null)
             return R.fail("请求参数错误");
 
-        //4.保存到redis中
+        //3.保存到redis中
         redisTemplate.boundHashOps(RedisContant.CHANNEL_MAP_POINT).put(md5,point);
         redisTemplate.expire(RedisContant.CHANNEL_MAP_POINT,RedisContant.CHANNEL_MAP_POINT_TIME, TimeUnit.MINUTES); //30分钟
         return R.ok(point);
     }
 
-    //Todo 标记网点关注
+    /**
+     * 标记网点关注列表
+     * @param wdTopologicalInfoBos
+     */
     public void attention(List<WdTopologicalInfoBo> wdTopologicalInfoBos){
+        //需要标志关注的网点Id
         List<String> collect = wdTopologicalInfoBos.stream().map(wdTopologicalInfoBo -> {
             return wdTopologicalInfoBo.getWdId();
         }).collect(Collectors.toList());
 
-        //标志是否关注
+        //查询登录用户是否关注
         QueryWrapper<AttentionPool> queryWrapper1 = new QueryWrapper<>();
         queryWrapper1.select("wd_id");
-        queryWrapper1.in("wd_id",collect);
+        queryWrapper1.eq("user_id", LoginHelper.getUserId());
+        queryWrapper1.and(attentionPoolQueryWrapper -> {
+            attentionPoolQueryWrapper.in("wd_id",collect);
+        });
+
         if(collect.size() > 0){
             List<AttentionPool> attentionPools = attentionPoolDao.selectList(queryWrapper1);
             List<String> collect1 = attentionPools.stream().map(attentionPool -> {
                 return attentionPool.getWdId();
             }).collect(Collectors.toList());
 
+            //标记
             for (WdTopologicalInfoBo wdTopologicalInfoBo : wdTopologicalInfoBos) {
                 boolean contains = collect1.contains(wdTopologicalInfoBo.getWdId());
                 if (contains)
@@ -134,6 +241,11 @@ public class ChannelMapController {
         }
     }
 
+    /**
+     * 获取网点详细信息
+     * @param wdId
+     * @return
+     */
     @GetMapping("/getWdInfo")
     public R getWdInfo(String wdId){
         WdInfo wdInfo = channelMapService.getWdInfo(wdId);

+ 3 - 2
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TopologicalBuildWdController.java

@@ -15,6 +15,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
@@ -48,12 +49,12 @@ public class TopologicalBuildWdController {
     public R list(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
         String md5 = topologicalWdAceeptVo.getHash();
         //2.查看redis中是否存在有缓存
-        List<TopologicalBuildingWd> wdCount = (List<TopologicalBuildingWd>)redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_BUILD_WD_LIST).get(md5);
+        HashMap<String,Object>  wdCount = (HashMap<String,Object> )redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_BUILD_WD_LIST).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
 
-        List<TopologicalBuildingWd> list = topologicalBuildWdSerevice.list(topologicalWdAceeptVo);
+        HashMap<String,Object> list = topologicalBuildWdSerevice.list(topologicalWdAceeptVo);
 
         redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_BUILD_WD_LIST).put(md5,list);
         redisTemplate.expire(RedisContant.TOPOLOGICAL_BUILD_WD_LIST,RedisContant.TOPOLOGICAL_BUILD_WD_LIST_TIME, TimeUnit.MINUTES); //30分钟

+ 3 - 2
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TopologicalCommonController.java

@@ -6,6 +6,7 @@ import com.ruoyi.demo.entity.WdInfo;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 import com.ruoyi.demo.service.TopologicalCommonService;
 import com.ruoyi.demo.service.WdInfoService;
+import io.swagger.v3.oas.models.security.SecurityScheme;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -29,8 +30,8 @@ public class TopologicalCommonController {
     RedisTemplate redisTemplate;
 
     @RequestMapping("/prefixSearch")
-    public R prefixSearch(String searchText){
-        List<WdInfo> wdInfos = topologicalCommonService.prefixSearch(searchText);
+    public R prefixSearch(String searchText,Integer size){
+        List<WdInfo> wdInfos = topologicalCommonService.prefixSearch(searchText,size);
         return R.ok(wdInfos);
     }
     @RequestMapping("/range")

+ 3 - 2
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TopologicalEnterpriseWdController.java

@@ -13,6 +13,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
@@ -29,12 +30,12 @@ public class TopologicalEnterpriseWdController {
     public R list(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
         String md5 = topologicalWdAceeptVo.getHash();
         //2.查看redis中是否存在有缓存
-        List<TopologicalEnterpriseWd> wdCount = (List<TopologicalEnterpriseWd>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST).get(md5);
+        HashMap<String,Object> wdCount = (HashMap<String,Object>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
 
-        List<TopologicalEnterpriseWd> list = topologicalEnterpriseWdService.list(topologicalWdAceeptVo);
+        HashMap<String,Object> list = topologicalEnterpriseWdService.list(topologicalWdAceeptVo);
 
         redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST).put(md5,list);
         redisTemplate.expire(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST,RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST_TIME, TimeUnit.MINUTES); //30分钟

+ 3 - 2
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TopologicalHouseWdController.java

@@ -15,6 +15,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
@@ -50,12 +51,12 @@ public class TopologicalHouseWdController {
     public R list(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
         String md5 = topologicalWdAceeptVo.getHash();
         //2.查看redis中是否存在有缓存
-        List<TopologicalHouseWd> wdCount = (List<TopologicalHouseWd>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_HOUSE_WD_LIST).get(md5);
+        HashMap<String, Object> wdCount = (HashMap<String, Object>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_HOUSE_WD_LIST).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
 
-        List<TopologicalHouseWd> list = topologicalHouseWdService.list(topologicalWdAceeptVo);
+        HashMap<String, Object> list = topologicalHouseWdService.list(topologicalWdAceeptVo);
 
         redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_HOUSE_WD_LIST).put(md5,list);
         redisTemplate.expire(RedisContant.TOPOLOGICAL_HOUSE_WD_LIST,RedisContant.TOPOLOGICAL_HOUSE_WD_LIST_TIME, TimeUnit.MINUTES); //30分钟

+ 14 - 4
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TopologicalStoreWdController.java

@@ -16,9 +16,13 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
+/**
+ * 点位评估模块:
+ */
 @RestController
 @RequestMapping("/poi/topologicalStoreWd")
 public class TopologicalStoreWdController {
@@ -29,20 +33,26 @@ public class TopologicalStoreWdController {
     @Autowired
     RedisTemplate redisTemplate;
 
+    /**
+     * 获取周边网点分类
+     * @param topologicalWdAceeptVo
+     * @return
+     */
     @RequestMapping("/category")
     public R category(@Validated(value = {TopologicalWdGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
+        //1.查看redis中是否存在有缓存
         String md5 = topologicalWdAceeptVo.getHash();
-        //2.查看redis中是否存在有缓存
         List<StoreWdCategoryCount>wdCount = (List<StoreWdCategoryCount>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_CATEGORY).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
 
+        //2.查询结果
         List<StoreWdCategoryCount> category = topologicalStoreWdService.category(topologicalWdAceeptVo);
 
+        //3.存入redis
         redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_CATEGORY).put(md5,category);
         redisTemplate.expire(RedisContant.TOPOLOGICAL_STORE_WD_CATEGORY, RedisContant.TOPOLOGICAL_STORE_WD_CATEGORY_TIME, TimeUnit.MINUTES); //30分钟
-
         return R.ok(category);
     }
 
@@ -50,13 +60,13 @@ public class TopologicalStoreWdController {
     public R list(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
         String md5 = topologicalWdAceeptVo.getHash();
         //2.查看redis中是否存在有缓存
-        List<TopologicalStoreWd> wdCount = (List<TopologicalStoreWd>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_LIST).get(md5);
+        HashMap<String,Object> wdCount = (HashMap<String,Object>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_LIST).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
 
 
-        List<TopologicalStoreWd> list = topologicalStoreWdService.list(topologicalWdAceeptVo);
+        HashMap<String,Object> list = topologicalStoreWdService.list(topologicalWdAceeptVo);
 
         redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_LIST).put(md5,list);
         redisTemplate.expire(RedisContant.TOPOLOGICAL_STORE_WD_LIST,RedisContant.TOPOLOGICAL_STORE_WD_LIST_TIME, TimeUnit.MINUTES); //30分钟

+ 6 - 11
ruoyi-demo/src/main/java/com/ruoyi/demo/entity/TopologicalBuildingWd.java

@@ -11,35 +11,30 @@ import java.time.LocalDateTime;
 @TableName("bl_topological_building_wd_list")
 public class TopologicalBuildingWd implements Serializable {
 
-    @TableField("around_wd_id")
     private String aroundWdId;
-    @TableField("around_wd_name")
     private String aroundWdName;
-    @TableField("around_wd_type_code")
     private String aroundWdTypeCode;
-    @TableField("distance")
     private double distance;
-    @TableField("addr_code")
     private String addrCode;
-    @TableField("addr_code_info")
     private String addrCodeInfo;
-    @TableField("addr_info")
     private String addrInfo;
-    @TableField("rent")
     private double rent;
-    @TableField("build_type")
     private String buildType;
-    @TableField("property_type")
     private String propertyType;
-    @TableField("analyse_time")
     private LocalDateTime analyseTime;
 
+    private double lat;
+
+    private double lng;
+
     public TopologicalBuildingWd(WdInfo wdInfo) {
         this.aroundWdId = wdInfo.getWdId();
         this.aroundWdName = wdInfo.getWdName();
         this.aroundWdTypeCode = wdInfo.getWdTypeCode();
         this.addrCode = wdInfo.getAddrCode();
         this.addrInfo = wdInfo.getAddrInfo();
+        this.lat = wdInfo.getLat().doubleValue();
+        this.lng = wdInfo.getLng().doubleValue();
     }
 
     public TopologicalBuildingWd() {

+ 5 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/entity/TopologicalEnterpriseWd.java

@@ -36,12 +36,17 @@ public class TopologicalEnterpriseWd implements Serializable {
     @TableField("analyse_time")
     private LocalDateTime analyseTime;
 
+    private double lat;
+    private double lng;
+
     public TopologicalEnterpriseWd(WdInfo wdInfo) {
         this.aroundWdId = wdInfo.getWdId();
         this.aroundWdName = wdInfo.getWdName();
         this.aroundWdTypeCode = wdInfo.getWdTypeCode();
         this.addrCode = wdInfo.getAddrCode();
         this.addrInfo = wdInfo.getAddrInfo();
+        this.lat = wdInfo.getLat().doubleValue();
+        this.lng = wdInfo.getLng().doubleValue();
     }
 
     public TopologicalEnterpriseWd() {

+ 6 - 12
ruoyi-demo/src/main/java/com/ruoyi/demo/entity/TopologicalHouseWd.java

@@ -11,45 +11,39 @@ import java.time.LocalDateTime;
 @TableName("bl_topological_house_wd_list")
 public class TopologicalHouseWd implements Serializable {
 
-    @TableField("around_wd_id")
     public String aroundWdId;
-    @TableField("around_wd_name")
     public String aroundWdName;
-    @TableField("around_wd_type_code")
     public String aroundWdTypeCode;
-    @TableField("distance")
     public double distance;
 
-    @TableField("addr_code")
     public String addrCode;
 
-    @TableField("addr_code_info")
     public String addrCodeInfo;
 
-    @TableField("addr_info")
     public String addrInfo;
 
-    @TableField("rent")
     public double rent;
 
-    @TableField("property_type")
     public String propertyType;
 
-    @TableField("households")
     public int households;
 
-    @TableField("people_count")
     public int peopleCount;
 
-    @TableField("analyse_time")
     private LocalDateTime analyseTime;
 
+    private double lat;
+
+    private double lng;
+
     public TopologicalHouseWd(WdInfo wdInfo) {
         this.aroundWdId = wdInfo.getWdId();
         this.aroundWdName = wdInfo.getWdName();
         this.aroundWdTypeCode = wdInfo.getWdTypeCode();
         this.addrCode = wdInfo.getAddrCode();
         this.addrInfo = wdInfo.getAddrInfo();
+        this.lat = wdInfo.getLat().doubleValue();
+        this.lng = wdInfo.getLng().doubleValue();
     }
 
     public TopologicalHouseWd() {

+ 4 - 18
ruoyi-demo/src/main/java/com/ruoyi/demo/entity/TopologicalStoreWd.java

@@ -8,35 +8,19 @@ import java.time.LocalDateTime;
 
 @Data
 public class TopologicalStoreWd implements Serializable {
-    @TableField("around_wd_id")
     private String aroundWdId;
-    @TableField("around_wd_name")
     private String aroundWdName;
-    @TableField("around_wd_type_code")
     private String aroundWdTypeCode;
-    @TableField("distance")
     private double distance;
 
-    @TableField("addr_code")
     private String addrCode;
 
-    @TableField("addr_code_info")
     private String addrCodeInfo;
 
-    @TableField("addr_info")
     private String addrInfo;
 
-    @TableField("industry_code")
-    private String industryCode;
-
-    @TableField("manage_type_code")
-    private String manageTypeCode;
-
-    @TableField("analyse_time")
-    private LocalDateTime analyseTime;
-
-    @TableField("brand_id")
-    private String brandId;
+    private double lng;
+    private double lat;
 
     public TopologicalStoreWd(WdInfo wdInfo) {
         this.aroundWdId = wdInfo.getWdId();
@@ -44,6 +28,8 @@ public class TopologicalStoreWd implements Serializable {
         this.aroundWdTypeCode = wdInfo.getWdTypeCode();
         this.addrCode = wdInfo.getAddrCode();
         this.addrInfo = wdInfo.getAddrInfo();
+        this.lng = wdInfo.getLng().doubleValue();
+        this.lat = wdInfo.getLat().doubleValue();
     }
 
     public TopologicalStoreWd() {

+ 3 - 1
ruoyi-demo/src/main/java/com/ruoyi/demo/entity/bo/Histogram.java

@@ -3,8 +3,10 @@ package com.ruoyi.demo.entity.bo;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.io.Serializable;
+
 @Data
-public class Histogram {
+public class Histogram implements Serializable {
     private String name;
     private int count;
 

+ 0 - 1
ruoyi-demo/src/main/java/com/ruoyi/demo/entity/bo/StoreWdCategoryCount.java

@@ -11,7 +11,6 @@ public class StoreWdCategoryCount implements Serializable {
 
     private String name;
     private List<StoreWdCategoryCountBody> storeWdCategoryCountBodyList;
-
     private int count;
     private double radio;
 }

+ 5 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/entity/vo/ChannelMapAceeptVo.java

@@ -41,6 +41,11 @@ public class ChannelMapAceeptVo implements Serializable {
 
     String orderby = ""; //排序字段,(list接口)
 
+    String isBrand = ""; //有无关联品牌
+
+    String isTelephone = ""; //有无联系方式
+
+    String storeAge = ""; //店零
     int size = 15; //tag分析时候用
 
     /*

+ 27 - 23
ruoyi-demo/src/main/java/com/ruoyi/demo/entity/vo/TopologicalWdAceeptVo.java

@@ -1,6 +1,7 @@
 package com.ruoyi.demo.entity.vo;
 
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.ruoyi.demo.constant.ChannelMapContant;
 import com.ruoyi.demo.utils.HashUtil;
 import com.ruoyi.demo.valida.TopologicalWdGroup;
@@ -10,49 +11,52 @@ import lombok.Data;
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
+import java.math.BigDecimal;
 
 @Data
 public class TopologicalWdAceeptVo implements Serializable {
 
-    //中心网点Id
-    @NotBlank(groups = {TopologicalWdGroup.class, TopologicalWdListGroup.class},message = "请选择中心点")
-    String centerWdId;
-
-    //半径范围
+    /**
+     * 中心点半径范围
+     */
     @NotNull(groups = {TopologicalWdGroup.class,TopologicalWdListGroup.class},message = "半径范围未正确选择")
     int radius;
 
-    //地区Code
+    /**
+     * 经纬度
+     */
+    @NotNull(groups = {TopologicalWdGroup.class,TopologicalWdListGroup.class},message = "lat不能为空")
+    private Double lat;
+    @NotNull(groups = {TopologicalWdGroup.class,TopologicalWdListGroup.class},message = "lng不能为空")
+    private Double lng;
+
+    /**
+     * 地区Code
+     */
+    @NotBlank(groups = {TopologicalWdGroup.class, TopologicalWdListGroup.class},message = "addrCode不能为空")
     String addrCode;
 
-    //限制条数
-    int size = 10;
+    /**
+     * 分页
+     */
+    Integer pageSize = 10;
 
-    //网点分类
-    String[] channel;
+    Integer pageNum = 1;
 
 
     public String getHash(){
         StringBuilder stringBuilder = new StringBuilder();
-        stringBuilder.append(centerWdId);
+        stringBuilder.append(lat);
+        stringBuilder.append(lng);
         stringBuilder.append(radius);
-        stringBuilder.append(size);
-
-        for (String s : getChannel()) {
-            stringBuilder.append(s);
-        }
-
+        stringBuilder.append(pageSize);
+        stringBuilder.append(pageNum);
 
         String s = stringBuilder.toString();
         String md5 = HashUtil.hash(s, "MD5");
         return md5;
     }
 
-    public String[] getChannel() {
-        if(this.channel == null || this.channel.length == 0){
-            return channel = ChannelMapContant.FULL_CHANNEL;
-        }
-        return channel;
-    }
+
 
 }

+ 1 - 2
ruoyi-demo/src/main/java/com/ruoyi/demo/init/BenyunCoreInit.java

@@ -2,7 +2,6 @@ package com.ruoyi.demo.init;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 
-import com.ruoyi.demo.config.RedisConfiguration;
 import com.ruoyi.demo.constant.RedisInitContant;
 import com.ruoyi.demo.entity.AddrCategory;
 import com.ruoyi.demo.entity.ManageType;
@@ -56,7 +55,7 @@ public class BenyunCoreInit {
         queryWrapper.isNotNull("city_tier");
         for (AddrCategory addrCategory : addrCategoryDao.selectList(queryWrapper)) {
             if (addrCategory.getCityTier() != null && !addrCategory.getCityTier().equals("")) {
-                redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_MAP).put(addrCategory.getAddrCode().substring(0, 4), addrCategory.getCityTier());
+                redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_MAP).put(addrCategory.getAddrCode(), addrCategory.getCityTier());
             }
         }
         initCityTierListMap();

+ 2 - 1
ruoyi-demo/src/main/java/com/ruoyi/demo/service/ChannelAnalyseService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.demo.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageInfo;
 import com.ruoyi.demo.entity.Brand;
 import com.ruoyi.demo.entity.bo.Histogram;
@@ -16,7 +17,7 @@ import java.util.List;
 public interface ChannelAnalyseService {
     public HashMap cityTier(ChannelMapAceeptVo channelMapAceeptVo);
 
-    PageInfo<Brand> brandList(ChannelAnalyseAceeptVo channelAnalyseAceeptVo);
+    Page<Brand> brandList(ChannelAnalyseAceeptVo channelAnalyseAceeptVo);
 
     HashMap<String,Object> tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo);
 

+ 8 - 1
ruoyi-demo/src/main/java/com/ruoyi/demo/service/ChannelMapService.java

@@ -1,6 +1,7 @@
 package com.ruoyi.demo.service;
 
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageInfo;
 import com.ruoyi.demo.entity.WdInfo;
 import com.ruoyi.demo.entity.bo.WdCount;
@@ -12,7 +13,13 @@ public interface ChannelMapService {
     public WdCount area(ChannelMapAceeptVo channel);
     public HashMap list(ChannelMapAceeptVo channel);
 
-    public PageInfo<WdInfo> point(String[] channel, String searchText, String[] addrCode, int pageNum, int pageSize);
+    public Page<WdInfo> point(ChannelMapAceeptVo channel);
 
     WdInfo getWdInfo(String wdId);
+
+    WdCount areaProvince(ChannelMapAceeptVo channel);
+
+    WdCount areaCity(ChannelMapAceeptVo channelMapAceeptVo);
+
+    WdCount areaZone(ChannelMapAceeptVo channelMapAceeptVo);
 }

+ 2 - 1
ruoyi-demo/src/main/java/com/ruoyi/demo/service/TopologicalBuildWdSerevice.java

@@ -6,11 +6,12 @@ import com.ruoyi.demo.entity.bo.BuildWdCategoryCount;
 import com.ruoyi.demo.entity.bo.Histogram;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 
+import java.util.HashMap;
 import java.util.List;
 
 public interface TopologicalBuildWdSerevice {
     public List<BuildWdCategoryCount> buildingLevel(TopologicalWdAceeptVo topologicalWdAceeptVo);
-    public List<TopologicalBuildingWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
+    public HashMap<String,Object> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
 
     List<Histogram> buildingHistogram(TopologicalWdAceeptVo topologicalWdAceeptVo);
 }

+ 1 - 2
ruoyi-demo/src/main/java/com/ruoyi/demo/service/TopologicalCommonService.java

@@ -8,8 +8,7 @@ import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 import java.util.List;
 
 public interface TopologicalCommonService {
-    public List<WdInfo> prefixSearch(String searchText);
-    void search(String searchText,int radius);
+    public List<WdInfo> prefixSearch(String searchText,Integer size);
 
     List<WdInfo> map(TopologicalWdAceeptVo topologicalWdAceeptVo);
 }

+ 2 - 1
ruoyi-demo/src/main/java/com/ruoyi/demo/service/TopologicalEnterpriseWdService.java

@@ -4,8 +4,9 @@ package com.ruoyi.demo.service;
 import com.ruoyi.demo.entity.TopologicalEnterpriseWd;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 
+import java.util.HashMap;
 import java.util.List;
 
 public interface TopologicalEnterpriseWdService {
-    public List<TopologicalEnterpriseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
+    public HashMap<String,Object> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
 }

+ 2 - 1
ruoyi-demo/src/main/java/com/ruoyi/demo/service/TopologicalHouseWdService.java

@@ -5,10 +5,11 @@ import com.ruoyi.demo.entity.TopologicalHouseWd;
 import com.ruoyi.demo.entity.TopologicalHouseWdStatisticsData;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 
+import java.util.HashMap;
 import java.util.List;
 
 public interface TopologicalHouseWdService {
-    public List<TopologicalHouseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
+    public HashMap<String,Object> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
 
     public TopologicalHouseWdStatisticsData info(TopologicalWdAceeptVo topologicalWdAceeptVo);
 }

+ 2 - 1
ruoyi-demo/src/main/java/com/ruoyi/demo/service/TopologicalStoreWdService.java

@@ -6,10 +6,11 @@ import com.ruoyi.demo.entity.bo.Histogram;
 import com.ruoyi.demo.entity.bo.StoreWdCategoryCount;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 
+import java.util.HashMap;
 import java.util.List;
 
 public interface TopologicalStoreWdService {
-    public List<TopologicalStoreWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
+    public HashMap<String,Object> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
 
     List<StoreWdCategoryCount> category(TopologicalWdAceeptVo topologicalWdAceeptVo);
 

+ 330 - 213
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/ChannelAnalyseServiceImpl.java

@@ -1,26 +1,22 @@
 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;
 import com.ruoyi.demo.constant.RedisContant;
-import com.ruoyi.demo.entity.Brand;
-import com.ruoyi.demo.entity.ManageType;
-import com.ruoyi.demo.entity.StoreWd;
-import com.ruoyi.demo.entity.WdInfo;
+import com.ruoyi.demo.entity.*;
 import com.ruoyi.demo.entity.bo.Histogram;
 import com.ruoyi.demo.entity.bo.StoreWdCategoryCount;
 import com.ruoyi.demo.entity.bo.StoreWdCategoryCountBody;
 import com.ruoyi.demo.entity.vo.ChannelAnalyseAceeptVo;
 import com.ruoyi.demo.entity.vo.ChannelMapAceeptVo;
 import com.ruoyi.demo.entity.vo.TagAnalyse;
-import com.ruoyi.demo.mapper.BrandMapper;
-import com.ruoyi.demo.mapper.StoreWdDao;
-import com.ruoyi.demo.mapper.WdInfoDao;
-import com.ruoyi.demo.mapper.WdTopologicalInfoDao;
+import com.ruoyi.demo.mapper.*;
 import com.ruoyi.demo.service.ChannelAnalyseService;
 import com.ruoyi.demo.utils.InitMapUtil;
 import com.ruoyi.demo.utils.WdRedisStoreage;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.geo.Circle;
@@ -41,10 +37,13 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.stream.Collectors;
 
+@Slf4j
 @Service
 @Transactional
 public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
 
+    @Autowired
+    private AddrCategoryDao addrCategoryDao;
     @Autowired
     WdInfoDao wdInfoDao;
 
@@ -69,9 +68,14 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
     ExecutorService executor;
 
 
+    /**
+     * 网点城市等级分布统计
+     * @param channelMapAceeptVo
+     * @return
+     */
     @Override
     public HashMap cityTier(ChannelMapAceeptVo channelMapAceeptVo) {
-        //1.统计结果
+        //1.初始化统计结果
         HashMap<String, Long> result = new HashMap<>();
         result.put("一线", 0L);
         result.put("新一线", 0L);
@@ -82,150 +86,47 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         result.put("其他", 0L);
 
 
-        //1.获取所有符合条件的网点信息
+        //2.获取所有符合条件的网点信息
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("addr_code","count(*) as audit");
-        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
+        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);  //封装过滤条件
         queryWrapper.groupBy("addr_code");
         List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
 
+        //3.统计各个城市等级的网点数量
         for (WdInfo wdInfo : wdInfos) {
+            //通过 网点区码 得到 该网点属于几线城市 例如:4509010000 -> 二线
             String initCityTierMap = initMapUtil.getInitCityTierMap(wdInfo.getAddrCode());
+
             if (initCityTierMap != null) {
                 result.put(initCityTierMap, result.get(initCityTierMap) + wdInfo.getAudit());
             } else
                 result.put("其他", result.get("其他") + wdInfo.getAudit());
         }
 
-
         return result;
     }
 
+    /**
+     * 品牌列表
+     * @param channelAnalyseAceeptVo
+     * @return
+     */
     @Override
-    public PageInfo<Brand> brandList(ChannelAnalyseAceeptVo channelAnalyseAceeptVo) {
-        String text = "";
-        if (channelAnalyseAceeptVo.getSearchText() != null)
-            text = channelAnalyseAceeptVo.getSearchText();
-        PageHelper.startPage(channelAnalyseAceeptVo.getPageNum(), channelAnalyseAceeptVo.getPageSize());
-        List<Brand> brands = brandMapper.searchList(text);
-        PageInfo<Brand> pageInfo = new PageInfo<>(brands);
-        return pageInfo;
+    public Page<Brand> brandList(ChannelAnalyseAceeptVo channelAnalyseAceeptVo) {
+        QueryWrapper<Brand> queryWrapper = new QueryWrapper<>();
+        if (channelAnalyseAceeptVo.getSearchText() != null && !channelAnalyseAceeptVo.getSearchText().equals(""))
+            queryWrapper.like("brand_name",channelAnalyseAceeptVo.getSearchText());
+
+        Page<Brand> page = new Page<>();
+        page.setSize(channelAnalyseAceeptVo.getPageSize());
+        page.setCurrent(channelAnalyseAceeptVo.getPageNum());
+        Page<Brand> brandPage = brandMapper.selectPage(page, queryWrapper);
+        return brandPage;
     }
 
 
-    //版本1
-//    @Override
-//    public HashMap<String, Object> tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
-//        //1.根据条件的到位网点信息
-//        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-//        queryWrapper.select("wd_id");
-//        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
-//        queryWrapper.and(queryWrapper2 ->{
-//            queryWrapper2.eq("show_delete",0);
-//        });
-//        List<WdInfo> queryWd = wdInfoDao.selectList(queryWrapper);
-//
-//        //2.获取周边标签
-//        List<String> collect = queryWd.stream().map(item -> {
-//            return RedisContant.WD_TAG + "_" + item.getWdId();
-//        }).collect(Collectors.toList());
-//
-//        //切割获取redis数据
-//        int split = 60000;
-//        int splitCount = collect.size()/split;
-//        int p1 = 0,p2 = split;
-//        ArrayList<CompletableFuture<List<List<String>>>> splitList = new ArrayList<>();
-//        for (int i=1;i<=splitCount;i++){
-//            if (p2 > collect.size())
-//                p2 = collect.size();
-//            List<String> list2 = collect.subList(p1, p2);
-//            CompletableFuture<List<List<String>>> future = CompletableFuture.supplyAsync(()->{
-//                return wdRedisStoreage.getWdTagList(list2);
-//            },executor);
-//            splitList.add(future);
-//            p1 = p2;
-//            p2+=split;
-//        }
-//
-//        //3.统计
-//        Hashtable<String, Integer> hashtable = new Hashtable<>();
-//        hashtable.put("total",0);
-//        ArrayList<CompletableFuture<Void>> list1 = new ArrayList<>();
-//        for (CompletableFuture<List<List<String>>> listCompletableFuture : splitList) {
-//            try {
-//                List<List<String>> lists = listCompletableFuture.get();
-//                for (List<String> list : lists) {
-//                    if (list != null && !list.isEmpty()){
-//                        CompletableFuture<Void> future = CompletableFuture.runAsync(()->{
-//                            for (String s : list) {
-//                                s += "边";
-//                                Integer integer = hashtable.get(s);
-//                                if (integer == null)
-//                                    hashtable.put(s,1);
-//                                else
-//                                    hashtable.put(s,integer+1);
-//                            }
-//                            hashtable.put("total",hashtable.get("total")+1);
-//                        },executor);
-//                        list1.add(future);
-//                    }
-//                }
-//                CompletableFuture.allOf(list1.toArray(new CompletableFuture[list1.size()])).join();
-//                lists = null;
-//            } catch (InterruptedException e) {
-//                throw new RuntimeException(e);
-//            } catch (ExecutionException e) {
-//                throw new RuntimeException(e);
-//            }
-//
-//        }
-//
-//        collect = null;
-//        queryWd = null;
-//
-//
-//        //4.封装统计值
-//        HashMap<String, Object> result = new HashMap<>();
-//        List<TagAnalyse> list = new ArrayList<>();
-//        Integer total = hashtable.get("total");
-//        for (String s : hashtable.keySet()) {
-//            if (s.equals("total"))
-//                continue;
-//
-//            TagAnalyse tagAnalyse = new TagAnalyse();
-//            tagAnalyse.setName(s);
-//            tagAnalyse.setCount(hashtable.get(s));
-//            BigDecimal bigDecimal = new BigDecimal((double) tagAnalyse.getCount() / total);
-//            double v = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
-//            tagAnalyse.setRadio(v);
-//            list.add(tagAnalyse);
-//        }
-//
-//        //5.对结果集进行排序
-//        Collections.sort(list, new Comparator<TagAnalyse>() {
-//            @Override
-//            public int compare(TagAnalyse o1, TagAnalyse o2) {
-//                return o2.getCount() - o1.getCount();
-//            }
-//        });
-//
-//
-//        //5.分页返回结果集
-//        int i = 1;
-//        int start = 0,end = 6;
-//        while(start<list.size()){
-//            if(end>=list.size())
-//                end = list.size();
-//            result.put(""+i++,new ArrayList(list.subList(start,end)));
-//            start=end;
-//            end+=6;
-//        }
-//        result.put("pages",i-1);
-//        result.put("total",total);
-//        return result;
-//    }
-
-    //版本2
+    //TODO 待优化
     @Override
     public HashMap<String, Object> tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
         //1.根据条件的到位网点信息
@@ -308,6 +209,7 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         return result;
     }
 
+    //TODO 待优化
     public void tagAnalyseItem(ConcurrentHashMap<String,Integer> concurrentHashMap, List<String> keys){
         //2.获取网点周边标签,并进行统计
         int total = 0;
@@ -329,129 +231,141 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         concurrentHashMap.put("total",concurrentHashMap.get("total")+total);
     }
 
+    /**
+     * 网点分类统计
+     * @param channelMapAceeptVo
+     * @return
+     */
     @Override
     public List<StoreWdCategoryCount> category(ChannelMapAceeptVo channelMapAceeptVo) {
-
-        //2.组装条件构造器找到网点信息网点
+        //1.查询所有符合的门店网点
+        channelMapAceeptVo.setChannel(new String[]{"1"});
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("wd_id");
-        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
-        queryWrapper.and(queryWrapper2 ->{
-            queryWrapper2.eq("show_delete",0);
-        });
-
-        //门店
-        queryWrapper.and(queryWrapper1 -> {
-            queryWrapper1.eq("wd_type_code","1");
-        });
-
-
-        //5.查询周边网点结果,并统计
+        assembleQueryWrapper(queryWrapper,channelMapAceeptVo); //封装过滤条件
         List<StoreWd> storeWds = storeWdDao.category(queryWrapper);
+
+        //2.统计各个分类的网点数量 HashMap<分类code,门店网点分类数量对象>
         HashMap<String,StoreWdCategoryCount> hashMap = new HashMap<>();
-        for (StoreWd wdInfo : storeWds) {
-            if(wdInfo.getManageTypeCode() == null || wdInfo.getManageTypeCode().equals(""))
+        for (StoreWd storeWd : storeWds) {
+            //分类为null、空跳过
+            if(storeWd.getManageTypeCode() == null || storeWd.getManageTypeCode().equals(""))
                 continue;
 
-            String s = wdInfo.getManageTypeCode().substring(0, 4) + "00";
+            //2.1 通过 分类Code 得到 具体的分类实体
+            ManageType manageType = initMapUtil.getInitManageType(storeWd.getManageTypeCode());
+
+            //2.2 通过 分类Code 得到 门店网点分类数量对象
+            String s = storeWd.getManageTypeCode().substring(0, 4) + "00";
             StoreWdCategoryCount storeWdCategoryCount = hashMap.get(s);
 
-            ManageType initManageType = initMapUtil.getInitManageType(wdInfo.getManageTypeCode());
             if (storeWdCategoryCount == null){
-                StoreWdCategoryCountBody storeWdCategoryCountBody = new StoreWdCategoryCountBody();
-                if(initManageType.getSubCategory() != null && !initManageType.getSubCategory().equals("")){
-                    storeWdCategoryCountBody.setName(initManageType.getSubCategory());
-                }else if(initManageType.getMidCategory() != null && !initManageType.getMidCategory().equals("")){
-                    storeWdCategoryCountBody.setName(initManageType.getMidCategory());
-                }else if (initManageType.getBigCategory() != null && !initManageType.getBigCategory().equals("")){
-                    storeWdCategoryCountBody.setName(initManageType.getBigCategory());
-                }
-                storeWdCategoryCountBody.setManageTypeCode(wdInfo.getManageTypeCode());
-                storeWdCategoryCountBody.setCount(wdInfo.getCommentCount());
+                //创建 门店网点分类数量体
+                StoreWdCategoryCountBody storeWdCategoryCountBody = createStoreWdCategoryCountBody(manageType);
+                storeWdCategoryCountBody.setManageTypeCode(storeWd.getManageTypeCode()); //分类code
+                storeWdCategoryCountBody.setCount(storeWd.getCommentCount()); //数量
 
+                //初始化 门店网点分类数量对象
                 StoreWdCategoryCount storeWdCategoryCount1 = new StoreWdCategoryCount();
                 storeWdCategoryCount1.setManageTypeCode(s);
                 storeWdCategoryCount1.setName(initMapUtil.getInitManageType(s).getMidCategory());
-                storeWdCategoryCount1.setCount(wdInfo.getCommentCount());
+                storeWdCategoryCount1.setCount(storeWd.getCommentCount());
+
+                //将 门店网点分类数量体 封装进 门店网点数量对象
                 ArrayList<StoreWdCategoryCountBody> list = new ArrayList<>();
                 list.add(storeWdCategoryCountBody);
                 storeWdCategoryCount1.setStoreWdCategoryCountBodyList(list);
                 hashMap.put(s,storeWdCategoryCount1);
             }else {
-                StoreWdCategoryCountBody storeWdCategoryCountBody = new StoreWdCategoryCountBody();
-                if(initManageType.getSubCategory() != null && !initManageType.getSubCategory().equals("")){
-                    storeWdCategoryCountBody.setName(initManageType.getSubCategory());
-                }else if(initManageType.getMidCategory() != null && !initManageType.getMidCategory().equals("")){
-                    storeWdCategoryCountBody.setName(initManageType.getMidCategory());
-                }else if (initManageType.getBigCategory() != null && !initManageType.getBigCategory().equals("")){
-                    storeWdCategoryCountBody.setName(initManageType.getBigCategory());
-                }
-                storeWdCategoryCountBody.setManageTypeCode(wdInfo.getManageTypeCode());
-                storeWdCategoryCountBody.setCount(wdInfo.getCommentCount());
+                //创建 门店网点分类数量体
+                StoreWdCategoryCountBody storeWdCategoryCountBody = createStoreWdCategoryCountBody(manageType);
+                storeWdCategoryCountBody.setManageTypeCode(storeWd.getManageTypeCode());
+                storeWdCategoryCountBody.setCount(storeWd.getCommentCount());
 
+                //将 门店网点分类数量体 封装进 门店网点数量对象
                 storeWdCategoryCount.getStoreWdCategoryCountBodyList().add(storeWdCategoryCountBody);
                 storeWdCategoryCount.setCount(storeWdCategoryCountBody.getCount()+storeWdCategoryCount.getCount());
                 //hashMap.put(s,storeWdCategoryCount);
             }
         }
 
-        //6.组装结果集
+        //3.组装结果集
         List<StoreWdCategoryCount> storeWdCategoryCounts = new ArrayList<>();
         for (String s : hashMap.keySet()) {
             storeWdCategoryCounts.add(hashMap.get(s));
         }
 
-
         return storeWdCategoryCounts;
     }
 
+    /**
+     * 创建门店网点分类体
+      * @param manageType 具体的分类实体
+     * @return
+     */
+    public StoreWdCategoryCountBody createStoreWdCategoryCountBody(ManageType manageType){
+        StoreWdCategoryCountBody storeWdCategoryCountBody = new StoreWdCategoryCountBody();
+        if(manageType.getSubCategory() != null && !manageType.getSubCategory().equals("")){
+            storeWdCategoryCountBody.setName(manageType.getSubCategory());
+        }else if(manageType.getMidCategory() != null && !manageType.getMidCategory().equals("")){
+            storeWdCategoryCountBody.setName(manageType.getMidCategory());
+        }else if (manageType.getBigCategory() != null && !manageType.getBigCategory().equals("")){
+            storeWdCategoryCountBody.setName(manageType.getBigCategory());
+        }
+        return storeWdCategoryCountBody;
+    }
+
+    /**
+     * 网点营业状态统计
+     * @param channelMapAceeptVo
+     * @return
+     */
     @Override
     public HashMap businessStatusAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
+        //1.查询所有符合的门店网点
+        channelMapAceeptVo.setChannel(new String[]{"1"});
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("wd_id");
-        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
-        queryWrapper.and(queryWrapper1 -> {
-            queryWrapper1.eq("wd_type_code","1");
-        });
-        queryWrapper.and(queryWrapper2 ->{
-            queryWrapper2.eq("show_delete",0);
-        });
-
+        assembleQueryWrapper(queryWrapper,channelMapAceeptVo); //封装过滤条件
         List<StoreWd> storeWds = storeWdDao.businessStatusAnalyse(queryWrapper);
-        HashMap<String,Integer> hashMap = new HashMap<>();
+
+        //2.统计 HashMap<营业状态,直方图统计体>
+        ArrayList<Histogram> list = new ArrayList<>();
         int total = 0;
         for (StoreWd storeWd : storeWds) {
             total+=storeWd.getCommentCount();
-            hashMap.put(storeWd.getBusinessStatus(),storeWd.getCommentCount());
-        }
-
-        ArrayList<Histogram> list = new ArrayList<>();
-        for (String s : hashMap.keySet()) {
             Histogram histogram = new Histogram();
-            histogram.setName(s);
-            histogram.setCount(hashMap.get(s));
+            histogram.setName(storeWd.getBusinessStatus());
+            histogram.setCount(storeWd.getCommentCount());
             list.add(histogram);
         }
 
+        //3.返回结果集
         HashMap<String, Object> result = new HashMap<>();
         result.put("total",total);
         result.put("data",list);
         return result;
     }
 
+    /**
+     * 楼宇类别统计
+     * @param channelMapAceeptVo
+     * @return
+     */
     @Override
     public ArrayList<Histogram> aroundBuildAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
+        //1.查询所有符合的网点
+        channelMapAceeptVo.setChannel(new String[]{"3"});
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("type_code_by","count(*) as audit");
-        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
-        queryWrapper.and(queryWrapper1 -> {
-            queryWrapper1.eq("wd_type_code","3");
-        });
+        assembleQueryWrapper(queryWrapper,channelMapAceeptVo); //封装过滤条件
         queryWrapper.and(queryWrapper1 -> {
             queryWrapper1.isNotNull("type_code_by");
         });
         queryWrapper.groupBy("type_code_by");
         List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
+        //2.统计楼宇类别数量
         int total = 0;
         HashMap<String,Integer> hashMap = new HashMap<>();
         for (WdInfo wdInfo : wdInfos) {
@@ -464,10 +378,12 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
             }
             total+=wdInfo.getAudit();
         }
+
+        //3.分装统计结果
         ArrayList<Histogram> list = new ArrayList<>();
         for (String s : hashMap.keySet()) {
             Integer integer = hashMap.get(s);
-            String initTypeByMap = initMapUtil.getInitTypeByMap(s + "0000").replace(":","");
+            String initTypeByMap = initMapUtil.getInitTypeByMap(s + "0000").replace(":","");  //根据需求取大类
             Histogram histogram = new Histogram();
             histogram.setName(initTypeByMap);
             histogram.setCount(integer);
@@ -477,25 +393,29 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         return list;
     }
 
+    /**
+     * 获取人均消费直方图
+     * @param channelMapAceeptVo
+     * @return
+     */
     @Override
     public ArrayList<Histogram> perCapitaConsumpAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
+        //1.查询所有符合的网点
+        channelMapAceeptVo.setChannel(new String[]{"1"});
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("wd_id");
         assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
-        queryWrapper.and(queryWrapper1 -> {
-            queryWrapper1.eq("wd_type_code","1");
-        });
-        queryWrapper.and(queryWrapper2 ->{
-            queryWrapper2.eq("show_delete",0);
-        });
-
         List<StoreWd> storeWds = storeWdDao.perCapitaConsumpAnalyse(queryWrapper);
+
+        //初始化
         LinkedHashMap<String, Integer> linkedHashMap = new LinkedHashMap<>();
         linkedHashMap.put("0~20",0);
         linkedHashMap.put("20~50",0);
         linkedHashMap.put("50~100",0);
         linkedHashMap.put("100~200",0);
         linkedHashMap.put("200以上",0);
+
+        //2.统计各个人均消费的数量
         for (StoreWd storeWd : storeWds) {
             if (storeWd.getPerCapitaConsumption() != null){
                 if (storeWd.getPerCapitaConsumption() >= 0 && storeWd.getPerCapitaConsumption()<20){
@@ -512,6 +432,7 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
             }
         }
 
+        //3.分装统计结果
         ArrayList<Histogram> list = new ArrayList<>();
         for (String s : linkedHashMap.keySet()) {
             Histogram histogram1 = new Histogram(s,linkedHashMap.get(s));
@@ -520,20 +441,21 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         return list;
     }
 
+    /**
+     * 获取聚道分析-店龄 / 经营时长统计
+     * @param channelMapAceeptVo
+     * @return
+     */
     @Override
     public ArrayList<Histogram> operateTimeAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
+        //1.查询所有符合的网点
+        channelMapAceeptVo.setChannel(new String[]{"1"});
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("wd_id");
         assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
-        queryWrapper.and(queryWrapper1 -> {
-            queryWrapper1.eq("wd_type_code","1");
-        });
-        queryWrapper.and(queryWrapper2 ->{
-            queryWrapper2.eq("show_delete",0);
-        });
-
         List<StoreWd> storeWds = storeWdDao.operateTimeAnalyse(queryWrapper);
 
+        //2.统计经营时长
         HashMap<Integer,Integer> hashMap = new HashMap<>();
         for (StoreWd storeWd : storeWds) {
             Integer opentime = Integer.valueOf(storeWd.getOpentime().substring(0,2));
@@ -546,7 +468,7 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
                 hashMap.put(i,integer+1);
         }
 
-
+        //3.分装统计结果
         ArrayList<Histogram> list = new ArrayList<>();
         for (Integer s : hashMap.keySet()) {
             Histogram histogram = new Histogram();
@@ -557,7 +479,204 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         return list;
     }
 
+    /**
+     * 封装网点过滤条件(v1.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);
+//            }
+//        }else {
+//            //省码
+//            for (String s : channelMapAceeptVo.getAddrCode()) {
+//                String substring = s.substring(0, 2);
+//                addrCodeList.add(substring);
+//            }
+//        }
+//
+//        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.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);
+//                }
+//            }
+//            queryWrapper.and(wdInfoQueryWrapper -> {
+//                for (String s : tierCode) {
+//                    wdInfoQueryWrapper.likeRight("addr_code", s).or();
+//                }
+//            });
+//        }
+//
+//        //排序字段查询
+//        if (channelMapAceeptVo.getOrderby() != null && !channelMapAceeptVo.getOrderby().trim().equals("")) {
+//            PageHelper.orderBy(channelMapAceeptVo.getOrderby());
+//        }
+//
+//    }
+
+    /**
+     * 封装网点过滤条件(v2.0)
+     * @param queryWrapper
+     * @param channelMapAceeptVo
+     */
     public void assembleQueryWrapper(QueryWrapper<WdInfo> queryWrapper,ChannelMapAceeptVo channelMapAceeptVo){
+        //1.根据不同级别得到需要查询的 地区码
+        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.and(wdInfoQueryWrapper -> {
+            wdInfoQueryWrapper.in("addr_code", wdAddrCode);
+        });
+
+
+        //渠道过滤
+        if(channelMapAceeptVo.getChannel() != null && channelMapAceeptVo.getChannel().length != 6){
+            queryWrapper.and(wdInfoQueryWrapper -> {
+                wdInfoQueryWrapper.in("wd_type_code", channelMapAceeptVo.getChannel());
+            });
+        }
+
+
+        //城市等级分类
+        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);
+                }
+            }
+            queryWrapper.and(wdInfoQueryWrapper -> {
+                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() );
+            });
+        }
+
+        //排序字段查询
+        if (channelMapAceeptVo.getOrderby() != null && !channelMapAceeptVo.getOrderby().trim().equals("")) {
+            PageHelper.orderBy(channelMapAceeptVo.getOrderby());
+        }
+
+    }
+
+    /**
+     * 找到所有满足条件的网点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.select("addr_code");
+        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;
+    }
+
+    /**
+     * 分装筛选条件(模糊查询)
+     * @param queryWrapper
+     * @param channelMapAceeptVo
+     */
+    /*    public void assembleQueryWrapper(QueryWrapper<WdInfo> queryWrapper,ChannelMapAceeptVo channelMapAceeptVo){
         //1.根据不同级别得到需要查询的 地区码
         List<String> addrCodeList = new ArrayList<>();
         if ("province".equals(channelMapAceeptVo.getRankType())) {
@@ -626,8 +745,6 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
             PageHelper.orderBy(channelMapAceeptVo.getOrderby());
         }
 
-    }
-
-
+    }*/
 
 }

+ 573 - 63
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/ChannelMapServiceImpl.java

@@ -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;
+    }
 }

+ 84 - 82
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalBuildWdSereviceImpl.java

@@ -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;
 import com.ruoyi.demo.entity.BuildWd;
@@ -44,41 +45,32 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
     @Autowired
     BuildWdDao buildWdDao;
 
+    /**
+     * 周边楼宇物业类别统计
+     * @param topologicalWdAceeptVo
+     * @return
+     */
     @Override
     public List<BuildWdCategoryCount> buildingLevel(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-        //1.根据中心网点Id找到网点详细信息
-        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
-        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-        if (wdInfo1 == null)
-            return new ArrayList<>();
-
-        //2.根据中心网点找到周边网点Id
-        // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
-        //半径范围
-        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
-        //圆
-        Circle circle = new Circle(point, distance);
-        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle);
-        //周边网点Id
         List<String> aroundWdId = new ArrayList<>();
-        radius.getContent().stream().forEach(item -> {
-            //记录网点坐标及距离
-            aroundWdId.add((String) item.getContent().getName());
-        });
+
+        //1.根据经纬度 找到 周边网点Id 及 距离
+        getAroundWdIdList(topologicalWdAceeptVo,aroundWdId,null);
         if (aroundWdId.isEmpty())
             return new ArrayList<>();
 
-        //4.分页查找网点信息
+        //2.分页查找网点信息
         QueryWrapper<BuildWd> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("property_type","count(*) as people_count");
         queryWrapper.in("wd_id",aroundWdId);
         queryWrapper.groupBy("property_type");
+        List<BuildWd> buildWds = buildWdDao.selectList(queryWrapper);
 
+        //3.封装结果集
         List<BuildWdCategoryCount> list = new ArrayList<>();
-        List<BuildWd> buildWds = buildWdDao.selectList(queryWrapper);
         for (BuildWd buildWd : buildWds) {
+            if (buildWd.getPropertyType().equals(""))
+                continue;
             BuildWdCategoryCount buildWdCategoryCount = new BuildWdCategoryCount();
             buildWdCategoryCount.setName(buildWd.getPropertyType());
             buildWdCategoryCount.setCount(buildWd.getPeopleCount());
@@ -88,91 +80,71 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
         return list;
     }
 
+    /**
+     * 获取周边楼宇列表
+     * @param topologicalWdAceeptVo
+     * @return
+     */
     @Override
-    public List<TopologicalBuildingWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-
-        //1.根据中心网点Id找到网点详细信息
-        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
-        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-        if(wdInfo1 == null)
-            return new ArrayList<>();
-
-        //2.根据中心网点找到周边网点Id
-        // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
-        //半径范围
-        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
-        //圆
-        Circle circle = new Circle(point, distance);
-        RedisGeoCommands.GeoRadiusCommandArgs geoRadiusCommandArgs = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs();
-        geoRadiusCommandArgs.includeDistance();
-        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle,geoRadiusCommandArgs);
-        //周边网点Id
+    public HashMap<String,Object>  list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
         List<String> aroundWdId = new ArrayList<>();
-        HashMap<String,Double> hashMap = new HashMap<>();
-        radius.getContent().stream().forEach(item -> {
-            //记录网点坐标及距离
-            aroundWdId.add((String) item.getContent().getName());
-            hashMap.put((String) item.getContent().getName(), item.getDistance().getValue());
-        });
-        if (aroundWdId.isEmpty())
-            return new ArrayList<>();
+        HashMap<String,Double> wdDistMap = new HashMap<>();
+
+        //1.根据经纬度 找到 周边网点Id 及 距离
+        getAroundWdIdList(topologicalWdAceeptVo,aroundWdId,wdDistMap);
+        if (aroundWdId.isEmpty()){
+            //没有周边网点
+            HashMap<String,Object> result = new HashMap();
+            Page<WdInfo> page = new Page<>(topologicalWdAceeptVo.getPageNum(),topologicalWdAceeptVo.getPageSize());
+            result.put("page",page);
+            result.put("data",new ArrayList<>());
+            return result;
+        }
 
-        //4.分页查找网点信息
+        //2.分页查找网点信息
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("wd_type_code","3");
         queryWrapper.and(wdInfoQueryWrapper -> {
-                wdInfoQueryWrapper.in("wd_id", aroundWdId);
+            wdInfoQueryWrapper.in("wd_id", aroundWdId);
         });
 
-
-        //5.查询周边网点结果
-        PageHelper.startPage(1, topologicalWdAceeptVo.getSize());
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-        PageInfo<WdInfo> pageInfo = new PageInfo<>(wdInfos);
+        Page<WdInfo> page = new Page<>(topologicalWdAceeptVo.getPageNum(),topologicalWdAceeptVo.getPageSize());
+        Page<WdInfo> page1 = wdInfoDao.selectPage(page, queryWrapper);
 
 
-        //6.组装结果集
+        //3.组装结果集
         List<TopologicalBuildingWd> list = new ArrayList<>();  //返回结果集
-        for (WdInfo wdInfo : pageInfo.getList()) {
+        for (WdInfo wdInfo : page1.getRecords()) {
             TopologicalBuildingWd topologicalBuildingWd = new TopologicalBuildingWd(wdInfo);
-            topologicalBuildingWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalBuildingWd.getAddrCode()));
-            BigDecimal bigDecimal = new BigDecimal(hashMap.get(wdInfo.getWdId()));
+            //topologicalBuildingWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalBuildingWd.getAddrCode()));
+            BigDecimal bigDecimal = new BigDecimal(wdDistMap.get(wdInfo.getWdId()));
             topologicalBuildingWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
             list.add(topologicalBuildingWd);
         }
 
-        return list;
+        //5.返回结果
+        HashMap<String,Object> result = new HashMap();
+        page1.setRecords(null);
+        result.put("page",page1);
+        result.put("data",list);
+        return result;
     }
 
+    /**
+     * 获取楼宇分类统计
+     * @param topologicalWdAceeptVo
+     * @return
+     */
     @Override
     public List<Histogram> buildingHistogram(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-        //1.根据中心网点Id找到网点详细信息
-        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
-        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-        if (wdInfo1 == null)
-            return new ArrayList<>();
-
-        //2.根据中心网点找到周边网点Id
-        // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
-        //半径范围
-        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
-        //圆
-        Circle circle = new Circle(point, distance);
-        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle);
-        //周边网点Id
         List<String> aroundWdId = new ArrayList<>();
-        radius.getContent().stream().forEach(item -> {
-            //记录网点坐标及距离
-            aroundWdId.add((String) item.getContent().getName());
-        });
 
+        //1.根据经纬度 找到 周边网点Id 及 距离
+        getAroundWdIdList(topologicalWdAceeptVo,aroundWdId,null);
         if (aroundWdId.isEmpty())
             return new ArrayList<>();
 
+        //2.获取符合条件的楼宇网点
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("type_code_by","count(*) as audit");
         queryWrapper.and(queryWrapper2 -> {
@@ -184,6 +156,7 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
         queryWrapper.groupBy("type_code_by");
         List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
 
+        //3.统计楼宇分类
         int total = 0;
         HashMap<String,Integer> hashMap = new HashMap<>();
         for (WdInfo wdInfo : wdInfos) {
@@ -199,6 +172,7 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
             total+=wdInfo.getAudit();
         }
 
+        //4.封装结果集
         ArrayList<Histogram> list = new ArrayList<>();
         for (String s : hashMap.keySet()) {
             Integer integer = hashMap.get(s);
@@ -212,5 +186,33 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
         return list;
     }
 
+    /**
+     * 根据坐标获取周边网点Id
+     * @param topologicalWdAceeptVo
+     * @param aroundWdIdList
+     * @param wdDistMap 存储 周边网点与中心网点直接的距离
+     */
+    public void getAroundWdIdList(TopologicalWdAceeptVo topologicalWdAceeptVo,List<String> aroundWdIdList,HashMap<String,Double> wdDistMap){
+        //1.根据经纬度 找到 周边网点Id
+        // 以经纬度为中心,获取半径不超过最大距离的所有元素
+        Point point = new Point(topologicalWdAceeptVo.getLng(),topologicalWdAceeptVo.getLat());
+
+        //半径范围
+        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
+
+        //圆
+        Circle circle = new Circle(point, distance);
+        RedisGeoCommands.GeoRadiusCommandArgs geoRadiusCommandArgs = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs();
+        geoRadiusCommandArgs.includeDistance(); //添加参数:返回距离
+        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(topologicalWdAceeptVo.getAddrCode().substring(0, 4)).radius(circle,geoRadiusCommandArgs);
+
+        //解析周边网点Id
+        radius.getContent().stream().forEach(item -> {
+            //记录网点坐标及距离
+            aroundWdIdList.add((String) item.getContent().getName());
+            if (wdDistMap != null)
+                wdDistMap.put((String) item.getContent().getName(), item.getDistance().getValue());
+        });
+    }
 
 }

+ 51 - 60
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalCommonServiceImpl.java

@@ -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;
 import com.ruoyi.demo.entity.WdInfo;
@@ -20,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 
 @Service
@@ -34,88 +36,77 @@ public class TopologicalCommonServiceImpl implements TopologicalCommonService {
     @Autowired
     RedisTemplate redisTemplate;
 
+    /**
+     * 点位评估中心点查询
+     * @param searchText
+     * @param size
+     * @return
+     */
     @Override
-    public List<WdInfo> prefixSearch(String searchText) {
+    public List<WdInfo> prefixSearch(String searchText,Integer size) {
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.likeRight("wd_name",searchText);
         queryWrapper.and(wdInfoQueryWrapper -> {
             wdInfoQueryWrapper.in("wd_type_code", Arrays.asList("1","2","3","5"));
         });
 
-        PageHelper.startPage(1,8);
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-        PageInfo<WdInfo> pageInfo = new PageInfo<>(wdInfos);
-        return pageInfo.getList();
-    }
-
-    @Override
-    public void search(String searchText, int radius) {
+        int pageSize = size == null ? 8:size;
+        Page<WdInfo> page = new Page<>(1,pageSize);
+        Page<WdInfo> page1 = wdInfoDao.selectPage(page, queryWrapper);
 
+        return page1.getRecords();
     }
 
-//    @Override
-//    public List<WdInfo> map(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-//        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-//
-//        //条件构造
-//        queryWrapper.in("wd_type_code",topologicalWdAceeptVo.getChannel());
-//        queryWrapper.and(wdInfoQueryWrapper -> {
-//            wdInfoQueryWrapper.likeRight("geo_hash",topologicalWdAceeptVo.getGeoHash().substring(0,5));
-//        });
-//
-//        //查询结果
-//        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-//
-//        List<WdInfo> list = new ArrayList<>();  //返回结果集
-//        GlobalCoordinates source = new GlobalCoordinates(topologicalWdAceeptVo.getLat(), topologicalWdAceeptVo.getLng());
-//        for (WdInfo wdInfo : wdInfos) {
-//            //1.计算距离
-//            GlobalCoordinates target = new GlobalCoordinates(wdInfo.getLat().doubleValue(), wdInfo.getLng().doubleValue());
-//            double meter2 = DistanceUtil.getDistanceMeter(source, target, Ellipsoid.WGS84);
-//
-//            if(meter2 <= topologicalWdAceeptVo.getRadius()){
-//                list.add(wdInfo);
-//            }
-//        }
-//        return list;
-//    }
-
+    /**
+     * 获取周边点坐标
+     * @param topologicalWdAceeptVo
+     * @return
+     */
     @Override
     public List<WdInfo> map(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-        //1.根据中心网点Id找到网点详细信息
-        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
-        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-        if (wdInfo1 == null)
+        List<String> aroundWdId = new ArrayList<>();
+
+        //1.根据经纬度 找到 周边网点Id 及 距离
+        getAroundWdIdList(topologicalWdAceeptVo,aroundWdId,null);
+        if (aroundWdId.isEmpty())
             return new ArrayList<>();
 
-        //2.根据中心网点找到周边网点Id
+        //2.查询符合的周边网点信息
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("wd_id","wd_name","addr_info","addr_code","lat","lng","type_code_by","type_name_by","wd_type_code")
+                .in("wd_id",aroundWdId);
+        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
+        return wdInfos;
+    }
+
+    /**
+     * 根据坐标获取周边网点Id
+     * @param topologicalWdAceeptVo
+     * @param aroundWdIdList
+     * @param wdDistMap 存储 周边网点与中心网点直接的距离
+     */
+    public void getAroundWdIdList(TopologicalWdAceeptVo topologicalWdAceeptVo, List<String> aroundWdIdList, HashMap<String,Double> wdDistMap){
+        //1.根据经纬度 找到 周边网点Id
         // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
+        Point point = new Point(topologicalWdAceeptVo.getLng(),topologicalWdAceeptVo.getLat());
+
         //半径范围
         Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
+
         //圆
         Circle circle = new Circle(point, distance);
-        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle);
-        //周边网点Id
-        List<String> aroundWdId = new ArrayList<>();
+        RedisGeoCommands.GeoRadiusCommandArgs geoRadiusCommandArgs = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs();
+        geoRadiusCommandArgs.includeDistance(); //添加参数:返回距离
+        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(topologicalWdAceeptVo.getAddrCode().substring(0, 4)).radius(circle,geoRadiusCommandArgs);
+
+        //解析周边网点Id
         radius.getContent().stream().forEach(item -> {
             //记录网点坐标及距离
-            aroundWdId.add((String) item.getContent().getName());
+            aroundWdIdList.add((String) item.getContent().getName());
+            if (wdDistMap != null)
+                wdDistMap.put((String) item.getContent().getName(), item.getDistance().getValue());
         });
-
-        //条件构造
-        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.select("wd_id","wd_name","addr_info","addr_code","lat","lng","type_code_by","type_name_by","wd_type_code")
-                .in("wd_id",aroundWdId);
-
-        //查询结果
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-        for (WdInfo wdInfo : wdInfos) {
-            wdInfo.setAddrCode(initMapUtil.getInitAddrCodeMap(wdInfo.getAddrCode()));
-        }
-
-        return wdInfos;
     }
 
 }

+ 61 - 39
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalEnterpriseWdServiceImpl.java

@@ -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;
 import com.ruoyi.demo.entity.TopologicalEnterpriseWd;
@@ -37,60 +38,81 @@ public class TopologicalEnterpriseWdServiceImpl implements TopologicalEnterprise
     @Autowired
     RedisTemplate redisTemplate;
 
+    /**
+     * 获取周边企业网点列表
+     * @param topologicalWdAceeptVo
+     * @return
+     */
     @Override
-    public List<TopologicalEnterpriseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-        //1.根据中心网点Id找到网点详细信息
-        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
-        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-        if (wdInfo1 == null)
-            return new ArrayList<>();
-
-        //2.根据中心网点找到周边网点Id
-        // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
-        //半径范围
-        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
-        //圆
-        Circle circle = new Circle(point, distance);
-        RedisGeoCommands.GeoRadiusCommandArgs geoRadiusCommandArgs = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs();
-        geoRadiusCommandArgs.includeDistance();
-        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle,geoRadiusCommandArgs);
-        //周边网点Id
+    public HashMap<String,Object> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
         List<String> aroundWdId = new ArrayList<>();
-        HashMap<String,Double> hashMap = new HashMap<>();
-        radius.getContent().stream().forEach(item -> {
-            //记录网点坐标及距离
-            aroundWdId.add((String) item.getContent().getName());
-            hashMap.put((String) item.getContent().getName(), item.getDistance().getValue());
-        });
-        if (aroundWdId.isEmpty())
-            return new ArrayList<>();
+        HashMap<String,Double> wdDistMap = new HashMap<>();
+
+        //1.根据经纬度 找到 周边网点Id 及 距离
+        getAroundWdIdList(topologicalWdAceeptVo,aroundWdId,wdDistMap);
+        if (aroundWdId.isEmpty()){
+            //没有周边网点
+            HashMap<String,Object> result = new HashMap();
+            Page<WdInfo> page = new Page<>(topologicalWdAceeptVo.getPageNum(),topologicalWdAceeptVo.getPageSize());
+            result.put("page",page);
+            result.put("data",new ArrayList<>());
+            return result;
+        }
 
-        //4.分页查找网点信息
+        //2.分页获取周边企业网点信息
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("wd_type_code","5");
         queryWrapper.and(wdInfoQueryWrapper -> {
             wdInfoQueryWrapper.in("wd_id", aroundWdId);
         });
+        Page<WdInfo> page = new Page<>(topologicalWdAceeptVo.getPageNum(),topologicalWdAceeptVo.getPageSize());
+        Page<WdInfo> page1 = wdInfoDao.selectPage(page, queryWrapper);
 
 
-        //5.查询周边网点结果
-        PageHelper.startPage(1, topologicalWdAceeptVo.getSize());
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-        PageInfo<WdInfo> pageInfo = new PageInfo<>(wdInfos);
-
-
-        //6.组装结果集
+        //3.组装结果集
         List<TopologicalEnterpriseWd> list = new ArrayList<>();  //返回结果集
-        for (WdInfo wdInfo : pageInfo.getList()) {
+        for (WdInfo wdInfo : page1.getRecords()) {
             TopologicalEnterpriseWd topologicalEnterpriseWd = new TopologicalEnterpriseWd(wdInfo);
-            topologicalEnterpriseWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalEnterpriseWd.getAddrCode()));
-            BigDecimal bigDecimal = new BigDecimal(hashMap.get(wdInfo.getWdId()));
+            //topologicalEnterpriseWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalEnterpriseWd.getAddrCode()));
+            BigDecimal bigDecimal = new BigDecimal(wdDistMap.get(wdInfo.getWdId()));
             topologicalEnterpriseWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
             list.add(topologicalEnterpriseWd);
         }
 
-        return list;
+        //4.返回结果
+        HashMap<String,Object> result = new HashMap();
+        page1.setRecords(null);
+        result.put("page",page1);
+        result.put("data",list);
+        return result;
+    }
+
+    /**
+     * 根据坐标获取周边网点Id
+     * @param topologicalWdAceeptVo
+     * @param aroundWdIdList
+     * @param wdDistMap 存储 周边网点与中心网点直接的距离
+     */
+    public void getAroundWdIdList(TopologicalWdAceeptVo topologicalWdAceeptVo,List<String> aroundWdIdList,HashMap<String,Double> wdDistMap){
+        //1.根据经纬度 找到 周边网点Id
+        // 以经纬度为中心,获取半径不超过最大距离的所有元素
+        Point point = new Point(topologicalWdAceeptVo.getLng(),topologicalWdAceeptVo.getLat());
+
+        //半径范围
+        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
+
+        //圆
+        Circle circle = new Circle(point, distance);
+        RedisGeoCommands.GeoRadiusCommandArgs geoRadiusCommandArgs = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs();
+        geoRadiusCommandArgs.includeDistance(); //添加参数:返回距离
+        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(topologicalWdAceeptVo.getAddrCode().substring(0, 4)).radius(circle,geoRadiusCommandArgs);
+
+        //解析周边网点Id
+        radius.getContent().stream().forEach(item -> {
+            //记录网点坐标及距离
+            aroundWdIdList.add((String) item.getContent().getName());
+            if (wdDistMap != null)
+                wdDistMap.put((String) item.getContent().getName(), item.getDistance().getValue());
+        });
     }
 }

+ 77 - 62
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalHouseServiceWdImpl.java

@@ -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;
 import com.ruoyi.demo.entity.TopologicalHouseWd;
@@ -43,37 +44,28 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
     @Autowired
     HouseWdDao houseWdDao;
 
+    /**
+     * 获取周边小区网点列表
+     * @param topologicalWdAceeptVo
+     * @return
+     */
     @Override
-    public List<TopologicalHouseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-        //1.根据中心网点Id找到网点详细信息
-        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id", topologicalWdAceeptVo.getCenterWdId());
-        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-        if (wdInfo1 == null)
-            return new ArrayList<>();
-
-        //2.根据中心网点找到周边网点Id
-        // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(), wdInfo1.getLat().doubleValue());
-        //半径范围
-        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
-        //圆
-        Circle circle = new Circle(point, distance);
-        RedisGeoCommands.GeoRadiusCommandArgs geoRadiusCommandArgs = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs();
-        geoRadiusCommandArgs.includeDistance();
-        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle, geoRadiusCommandArgs);
-        //周边网点Id
+    public HashMap<String,Object> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
         List<String> aroundWdId = new ArrayList<>();
-        HashMap<String, Double> hashMap = new HashMap<>();
-        radius.getContent().stream().forEach(item -> {
-            //记录网点坐标及距离
-            aroundWdId.add((String) item.getContent().getName());
-            hashMap.put((String) item.getContent().getName(), item.getDistance().getValue());
-        });
-        if (aroundWdId.isEmpty())
-            return new ArrayList<>();
+        HashMap<String,Double> wdDistMap = new HashMap<>();
+
+        //1.根据经纬度 找到 周边网点Id 及 距离
+        getAroundWdIdList(topologicalWdAceeptVo,aroundWdId,wdDistMap);
+        if (aroundWdId.isEmpty()){
+            //没有周边网点
+            HashMap<String,Object> result = new HashMap();
+            Page<WdInfo> page = new Page<>(topologicalWdAceeptVo.getPageNum(),topologicalWdAceeptVo.getPageSize());
+            result.put("page",page);
+            result.put("data",new ArrayList<>());
+            return result;
+        }
 
-        //4.分页查找网点信息
+        //2.分页查找网点信息
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("wd_type_code", "2");
         if (!aroundWdId.isEmpty()) {
@@ -81,55 +73,48 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
                 wdInfoQueryWrapper.in("wd_id", aroundWdId);
             });
         }
+        Page<WdInfo> page = new Page<>(topologicalWdAceeptVo.getPageNum(),topologicalWdAceeptVo.getPageSize());
+        Page<WdInfo> page1 = wdInfoDao.selectPage(page, queryWrapper);
 
 
-        //5.查询周边网点结果
-        PageHelper.startPage(1, topologicalWdAceeptVo.getSize());
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-        PageInfo<WdInfo> pageInfo = new PageInfo<>(wdInfos);
-
-
-        //6.组装结果集
+        //3.组装结果集
         List<TopologicalHouseWd> list = new ArrayList<>();  //返回结果集
-        for (WdInfo wdInfo : pageInfo.getList()) {
+        for (WdInfo wdInfo : page1.getRecords()) {
             TopologicalHouseWd topologicalHouseWd = new TopologicalHouseWd(wdInfo);
-            topologicalHouseWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalHouseWd.getAddrCode()));
-            BigDecimal bigDecimal = new BigDecimal(hashMap.get(wdInfo.getWdId()));
+            //topologicalHouseWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalHouseWd.getAddrCode()));
+            BigDecimal bigDecimal = new BigDecimal(wdDistMap.get(wdInfo.getWdId()));
             topologicalHouseWd.setDistance(bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
             list.add(topologicalHouseWd);
         }
 
-        return list;
+        //4.返回结果
+        HashMap<String,Object> result = new HashMap();
+        page1.setRecords(null);
+        result.put("page",page1);
+        result.put("data",list);
+        return result;
     }
 
+    /**
+     * 获取周边小区关键统计信息
+     * @param topologicalWdAceeptVo
+     * @return
+     */
     @Override
     public TopologicalHouseWdStatisticsData info(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-        //1.根据中心网点Id找到网点详细信息
-        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id", topologicalWdAceeptVo.getCenterWdId());
-        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-
-        //2.根据中心网点找到周边网点Id
-        // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(), wdInfo1.getLat().doubleValue());
-        //半径范围
-        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
-        //圆
-        Circle circle = new Circle(point, distance);
-        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle);
-        //周边网点Id
         List<String> aroundWdId = new ArrayList<>();
-        radius.getContent().stream().forEach(item -> {
-            //记录网点坐标及距离
-            aroundWdId.add((String) item.getContent().getName());
-        });
+
+        //1.根据经纬度 找到 周边网点Id 及 距离
+        getAroundWdIdList(topologicalWdAceeptVo,aroundWdId,null);
         if (aroundWdId.isEmpty())
-            return null;
+            return new TopologicalHouseWdStatisticsData();
 
-        //4.分页查找网点信息
-        TopologicalHouseWdStatisticsData result = new TopologicalHouseWdStatisticsData();
-        int total = 0;
+        //2.得到符合的小区网点信息
         List<TopologicalHouseWdStatisticsData> houseWdStatisticsData = houseWdDao.selectAndStatistics(aroundWdId);
+
+        //3.分装数据集
+        int total = 0;
+        TopologicalHouseWdStatisticsData result = new TopologicalHouseWdStatisticsData();
         for (TopologicalHouseWdStatisticsData houseWdStatisticsDatum : houseWdStatisticsData) {
             result.setTotalPeopleCount(houseWdStatisticsDatum.getTotalPeopleCount() + result.getTotalPeopleCount());
             result.setTotalHouseholds(houseWdStatisticsDatum.getTotalHouseholds() + result.getTotalHouseholds());
@@ -137,8 +122,38 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
             total++;
         }
         result.setHouseWdCount(total);
-        result.setAverageRent(result.getAverageRent() / total);
+        double averageRent = (total == 0) ? 0 : (result.getAverageRent() / total);
+        result.setAverageRent(averageRent);
 
         return result;
     }
+
+    /**
+     * 根据坐标获取周边网点Id
+     * @param topologicalWdAceeptVo
+     * @param aroundWdIdList
+     * @param wdDistMap 存储 周边网点与中心网点直接的距离
+     */
+    public void getAroundWdIdList(TopologicalWdAceeptVo topologicalWdAceeptVo,List<String> aroundWdIdList,HashMap<String,Double> wdDistMap){
+        //1.根据经纬度 找到 周边网点Id
+        // 以经纬度为中心,获取半径不超过最大距离的所有元素
+        Point point = new Point(topologicalWdAceeptVo.getLng(),topologicalWdAceeptVo.getLat());
+
+        //半径范围
+        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
+
+        //圆
+        Circle circle = new Circle(point, distance);
+        RedisGeoCommands.GeoRadiusCommandArgs geoRadiusCommandArgs = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs();
+        geoRadiusCommandArgs.includeDistance(); //添加参数:返回距离
+        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(topologicalWdAceeptVo.getAddrCode().substring(0, 4)).radius(circle,geoRadiusCommandArgs);
+
+        //解析周边网点Id
+        radius.getContent().stream().forEach(item -> {
+            //记录网点坐标及距离
+            aroundWdIdList.add((String) item.getContent().getName());
+            if (wdDistMap != null)
+                wdDistMap.put((String) item.getContent().getName(), item.getDistance().getValue());
+        });
+    }
 }

+ 132 - 122
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalStoreWdServiceImpl.java

@@ -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;
 import com.ruoyi.demo.entity.ManageType;
@@ -46,40 +47,28 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
     @Autowired
     RedisTemplate redisTemplate;
 
-    //TODO 待测试
+    /**
+     * 获取周边门店网点列表
+     * @param topologicalWdAceeptVo
+     * @return
+     */
     @Override
-    public List<TopologicalStoreWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-        //1.根据中心网点Id找到网点详细信息
-        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
-        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-        if (wdInfo1 == null)
-            return new ArrayList<>();
-        //2.根据中心网点找到周边网点Id
-        // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
-        //半径范围
-        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
-        //圆
-        Circle circle = new Circle(point, distance);
-        RedisGeoCommands.GeoRadiusCommandArgs geoRadiusCommandArgs = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs();
-        geoRadiusCommandArgs.includeDistance();
-        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle,geoRadiusCommandArgs);
-        //周边网点Id
+    public HashMap<String,Object> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
         List<String> aroundWdId = new ArrayList<>();
-        HashMap<String,Double> hashMap = new HashMap<>();
-        radius.getContent().stream().forEach(item -> {
-            //记录网点坐标及距离
-            aroundWdId.add((String) item.getContent().getName());
-            hashMap.put((String) item.getContent().getName(), item.getDistance().getValue());
-        });
+        HashMap<String,Double> wdDistMap = new HashMap<>();
 
+        //1.根据经纬度 找到 周边网点Id 及 距离
+        getAroundWdIdList(topologicalWdAceeptVo,aroundWdId,wdDistMap);
         if (aroundWdId.isEmpty()){
-            return new ArrayList<>();
+            //没有周边网点
+            HashMap<String,Object> result = new HashMap();
+            Page<WdInfo> page = new Page<>(topologicalWdAceeptVo.getPageNum(),topologicalWdAceeptVo.getPageSize());
+            result.put("page",page);
+            result.put("data",new ArrayList<>());
+            return result;
         }
 
-
-        //4.分页查找网点信息
+        //2.分页查找网点信息
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("wd_type_code","1");
         queryWrapper.and(wdInfoQueryWrapper -> {
@@ -87,100 +76,88 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
         });
 
 
-        //5.查询周边网点结果
-        PageHelper.startPage(1, topologicalWdAceeptVo.getSize());
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-        PageInfo<WdInfo> pageInfo = new PageInfo<>(wdInfos);
+        //3.查询周边网点结果
+        Page<WdInfo> page = new Page<>(topologicalWdAceeptVo.getPageNum(),topologicalWdAceeptVo.getPageSize());
+        Page<WdInfo> page1 = wdInfoDao.selectPage(page, queryWrapper);
 
 
-        //6.组装结果集
+        //4.组装结果集
         List<TopologicalStoreWd> list = new ArrayList<>();  //返回结果集
-        for (WdInfo wdInfo : pageInfo.getList()) {
+        for (WdInfo wdInfo : page1.getRecords()) {
             TopologicalStoreWd topologicalStoreWd = new TopologicalStoreWd(wdInfo);
-            topologicalStoreWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalStoreWd.getAddrCode()));
-            BigDecimal bigDecimal = new BigDecimal(hashMap.get(wdInfo.getWdId()));
+            //topologicalStoreWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalStoreWd.getAddrCode()));
+            BigDecimal bigDecimal = new BigDecimal(wdDistMap.get(wdInfo.getWdId()));
             topologicalStoreWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
             list.add(topologicalStoreWd);
         }
 
-        return list;
+        //5.返回结果
+        HashMap<String,Object> result = new HashMap();
+        page1.setRecords(null);
+        result.put("page",page1);
+        result.put("data",list);
+        return result;
     }
 
-    //TODO 待测试
+    /**
+     * 获取周边门店网点分类统计
+     * @param topologicalWdAceeptVo
+     * @return
+     */
     @Override
     public List<StoreWdCategoryCount> category(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-        //1.根据中心网点Id找到网点详细信息
-        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
-        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-        if (wdInfo1 == null)
-            return new ArrayList<>();
-        //2.根据中心网点找到周边网点Id
-        // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
-        //半径范围
-        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
-        //圆
-        Circle circle = new Circle(point, distance);
-        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle);
-        //周边网点Id
         List<String> aroundWdId = new ArrayList<>();
-        radius.getContent().stream().forEach(item -> {
-            //记录网点坐标及距离
-            aroundWdId.add((String) item.getContent().getName());
-        });
 
+        //1.根据经纬度 找到 周边网点Id 及 距离
+        getAroundWdIdList(topologicalWdAceeptVo,aroundWdId,null);
         if (aroundWdId.isEmpty())
             return new ArrayList<>();
 
+        //2.查找符合的门店网点
         QueryWrapper<StoreWd> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("manage_type_code","count(*) as comment_count")
             .in("wd_id",aroundWdId)
             .groupBy("manage_type_code");
+        List<StoreWd> storeWds = storeWdDao.selectList(queryWrapper);
 
-        //5.查询周边网点结果,并统计
-        List<StoreWd> wdInfos = storeWdDao.selectList(queryWrapper);
+        //5.统计各个分类的网点数量 HashMap<分类code,门店网点分类数量对象>
         HashMap<String,StoreWdCategoryCount> hashMap = new HashMap<>();
-        for (StoreWd wdInfo : wdInfos) {
-            if(wdInfo.getManageTypeCode() == null || wdInfo.getManageTypeCode().equals(""))
+        for (StoreWd storeWd : storeWds) {
+            //分类为null、空跳过
+            if(storeWd.getManageTypeCode() == null || storeWd.getManageTypeCode().equals(""))
                 continue;
 
-            String s = wdInfo.getManageTypeCode().substring(0, 4) + "00";
+            //5.1 通过 分类Code 得到 具体的分类实体
+            ManageType manageType = initMapUtil.getInitManageType(storeWd.getManageTypeCode());
+
+            //5.2 通过 分类Code 得到 门店网点分类数量对象
+            String s = storeWd.getManageTypeCode().substring(0, 4) + "00";
             StoreWdCategoryCount storeWdCategoryCount = hashMap.get(s);
 
-            ManageType initManageType = initMapUtil.getInitManageType(wdInfo.getManageTypeCode());
             if (storeWdCategoryCount == null){
-                StoreWdCategoryCountBody storeWdCategoryCountBody = new StoreWdCategoryCountBody();
-                if(initManageType.getSubCategory() != null && !initManageType.getSubCategory().equals("")){
-                    storeWdCategoryCountBody.setName(initManageType.getSubCategory());
-                }else if(initManageType.getMidCategory() != null && !initManageType.getMidCategory().equals("")){
-                    storeWdCategoryCountBody.setName(initManageType.getMidCategory());
-                }else if (initManageType.getBigCategory() != null && !initManageType.getBigCategory().equals("")){
-                    storeWdCategoryCountBody.setName(initManageType.getBigCategory());
-                }
-                storeWdCategoryCountBody.setManageTypeCode(wdInfo.getManageTypeCode());
-                storeWdCategoryCountBody.setCount(wdInfo.getCommentCount());
+                //创建 门店网点分类数量体
+                StoreWdCategoryCountBody storeWdCategoryCountBody = createStoreWdCategoryCountBody(manageType);
+                storeWdCategoryCountBody.setManageTypeCode(storeWd.getManageTypeCode()); //分类code
+                storeWdCategoryCountBody.setCount(storeWd.getCommentCount()); //数量
 
+                //初始化 门店网点分类数量对象
                 StoreWdCategoryCount storeWdCategoryCount1 = new StoreWdCategoryCount();
                 storeWdCategoryCount1.setManageTypeCode(s);
                 storeWdCategoryCount1.setName(initMapUtil.getInitManageType(s).getMidCategory());
-                storeWdCategoryCount1.setCount(wdInfo.getCommentCount());
+                storeWdCategoryCount1.setCount(storeWd.getCommentCount());
+
+                //将 门店网点分类数量体 封装进 门店网点数量对象
                 ArrayList<StoreWdCategoryCountBody> list = new ArrayList<>();
                 list.add(storeWdCategoryCountBody);
                 storeWdCategoryCount1.setStoreWdCategoryCountBodyList(list);
                 hashMap.put(s,storeWdCategoryCount1);
             }else {
-                StoreWdCategoryCountBody storeWdCategoryCountBody = new StoreWdCategoryCountBody();
-                if(initManageType.getSubCategory() != null && !initManageType.getSubCategory().equals("")){
-                    storeWdCategoryCountBody.setName(initManageType.getSubCategory());
-                }else if(initManageType.getMidCategory() != null && !initManageType.getMidCategory().equals("")){
-                    storeWdCategoryCountBody.setName(initManageType.getMidCategory());
-                }else if (initManageType.getBigCategory() != null && !initManageType.getBigCategory().equals("")){
-                    storeWdCategoryCountBody.setName(initManageType.getBigCategory());
-                }
-                storeWdCategoryCountBody.setManageTypeCode(wdInfo.getManageTypeCode());
-                storeWdCategoryCountBody.setCount(wdInfo.getCommentCount());
+                //创建 门店网点分类数量体
+                StoreWdCategoryCountBody storeWdCategoryCountBody = createStoreWdCategoryCountBody(manageType);
+                storeWdCategoryCountBody.setManageTypeCode(storeWd.getManageTypeCode());
+                storeWdCategoryCountBody.setCount(storeWd.getCommentCount());
 
+                //将 门店网点分类数量体 封装进 门店网点数量对象
                 storeWdCategoryCount.getStoreWdCategoryCountBodyList().add(storeWdCategoryCountBody);
                 storeWdCategoryCount.setCount(storeWdCategoryCountBody.getCount()+storeWdCategoryCount.getCount());
                 //hashMap.put(s,storeWdCategoryCount);
@@ -197,32 +174,22 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
         return storeWdCategoryCounts;
     }
 
+    /**
+     * 商业网点分类数量统计
+     * @param topologicalWdAceeptVo
+     * @return
+     */
     @Override
     public List<Histogram> storeHistogram(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-        //1.根据中心网点Id找到网点详细信息
-        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
-        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-        if (wdInfo1 == null)
-            return new ArrayList<>();
-        //2.根据中心网点找到周边网点Id
-        // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
-        //半径范围
-        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
-        //圆
-        Circle circle = new Circle(point, distance);
-        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle);
-        //周边网点Id
         List<String> aroundWdId = new ArrayList<>();
-        radius.getContent().stream().forEach(item -> {
-            //记录网点坐标及距离
-            aroundWdId.add((String) item.getContent().getName());
-        });
 
+        //1.根据经纬度 找到 周边网点Id 及 距离
+        getAroundWdIdList(topologicalWdAceeptVo,aroundWdId,null);
         if (aroundWdId.isEmpty())
             return new ArrayList<>();
 
+
+        //2.获取符合的门店网点分类统计信息
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("type_code_by","count(*) as audit");
         queryWrapper.and(queryWrapper2 -> {
@@ -234,6 +201,8 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
         queryWrapper.groupBy("type_code_by");
         List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
 
+
+        //3.统计
         int total = 0;
         HashMap<String,Integer> hashMap = new HashMap<>();
         for (WdInfo wdInfo : wdInfos) {
@@ -249,6 +218,7 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
             total+=wdInfo.getAudit();
         }
 
+        //4.组装返回结果
         ArrayList<Histogram> list = new ArrayList<>();
         for (String s : hashMap.keySet()) {
             Integer integer = hashMap.get(s);
@@ -262,44 +232,37 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
         return list;
     }
 
+    /**
+     * 消费水平统计
+     * @param topologicalWdAceeptVo
+     * @return
+     */
     @Override
     public List<Histogram> perCapitaConsumpHistogram(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-        //1.根据中心网点Id找到网点详细信息
-        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
-        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-        if (wdInfo1 == null)
-            return new ArrayList<>();
-        //2.根据中心网点找到周边网点Id
-        // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
-        //半径范围
-        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
-        //圆
-        Circle circle = new Circle(point, distance);
-        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle);
-        //周边网点Id
         List<String> aroundWdId = new ArrayList<>();
-        radius.getContent().stream().forEach(item -> {
-            //记录网点坐标及距离
-            aroundWdId.add((String) item.getContent().getName());
-        });
 
+        //1.根据经纬度 找到 周边网点Id 及 距离
+        getAroundWdIdList(topologicalWdAceeptVo,aroundWdId,null);
         if (aroundWdId.isEmpty())
             return new ArrayList<>();
 
+        //2.获取符合条件的网点信息
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("wd_id");
         queryWrapper.and(queryWrapper2 -> {
             queryWrapper2.eq("wd_type_code","1");
         });
         List<StoreWd> storeWds = storeWdDao.perCapitaConsumpAnalyse(queryWrapper);
+
+        //统计初始化
         HashMap<String, Integer> hashMap = new HashMap<>();
         hashMap.put("0~20",0);
         hashMap.put("20~50",0);
         hashMap.put("50~100",0);
         hashMap.put("100~200",0);
         hashMap.put("200以上",0);
+
+        //3.统计
         for (StoreWd storeWd : storeWds) {
             if (storeWd.getPerCapitaConsumption() != null){
                 if (storeWd.getPerCapitaConsumption() >= 0 && storeWd.getPerCapitaConsumption()<20){
@@ -316,6 +279,7 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
             }
         }
 
+        //4.组装返回结果
         ArrayList<Histogram> list = new ArrayList<>();
         for (String s : hashMap.keySet()) {
             Histogram histogram = new Histogram();
@@ -325,4 +289,50 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
         }
         return list;
     }
+
+    /**
+     * 根据坐标获取周边网点Id
+     * @param topologicalWdAceeptVo
+     * @param aroundWdIdList
+     * @param wdDistMap 存储 周边网点与中心网点直接的距离
+     */
+    public void getAroundWdIdList(TopologicalWdAceeptVo topologicalWdAceeptVo,List<String> aroundWdIdList,HashMap<String,Double> wdDistMap){
+        //1.根据经纬度 找到 周边网点Id
+        // 以经纬度为中心,获取半径不超过最大距离的所有元素
+        Point point = new Point(topologicalWdAceeptVo.getLng(),topologicalWdAceeptVo.getLat());
+
+        //半径范围
+        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
+
+        //圆
+        Circle circle = new Circle(point, distance);
+        RedisGeoCommands.GeoRadiusCommandArgs geoRadiusCommandArgs = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs();
+        geoRadiusCommandArgs.includeDistance(); //添加参数:返回距离
+        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(topologicalWdAceeptVo.getAddrCode().substring(0, 4)).radius(circle,geoRadiusCommandArgs);
+
+        //解析周边网点Id
+        radius.getContent().stream().forEach(item -> {
+            //记录网点坐标及距离
+            aroundWdIdList.add((String) item.getContent().getName());
+            if (wdDistMap != null)
+                wdDistMap.put((String) item.getContent().getName(), item.getDistance().getValue());
+        });
+    }
+
+    /**
+     * 创建门店网点分类体
+     * @param manageType 具体的分类实体
+     * @return
+     */
+    public StoreWdCategoryCountBody createStoreWdCategoryCountBody(ManageType manageType){
+        StoreWdCategoryCountBody storeWdCategoryCountBody = new StoreWdCategoryCountBody();
+        if(manageType.getSubCategory() != null && !manageType.getSubCategory().equals("")){
+            storeWdCategoryCountBody.setName(manageType.getSubCategory());
+        }else if(manageType.getMidCategory() != null && !manageType.getMidCategory().equals("")){
+            storeWdCategoryCountBody.setName(manageType.getMidCategory());
+        }else if (manageType.getBigCategory() != null && !manageType.getBigCategory().equals("")){
+            storeWdCategoryCountBody.setName(manageType.getBigCategory());
+        }
+        return storeWdCategoryCountBody;
+    }
 }

+ 1 - 1
ruoyi-demo/src/main/java/com/ruoyi/demo/utils/InitMapUtil.java

@@ -16,8 +16,8 @@ public class InitMapUtil {
     @Autowired
     RedisTemplate redisTemplate;
 
-
     public String getInitCityTierMap(String addrCode){
+        //redis -> hash(addrCode,城市等级)
         return (String) redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_MAP).get(addrCode.substring(0,4));
     }
 

+ 0 - 2
ruoyi-demo/src/main/java/com/ruoyi/demo/utils/WdRedisStoreage.java

@@ -47,8 +47,6 @@ public class WdRedisStoreage {
      */
     public  List<String> getWdTag(WdInfo wdInfo){
         List<String> tag = (List<String>) redisTemplate.boundValueOps(RedisContant.WD_TAG+"_"+wdInfo.getWdId()).get();
-        System.out.println(RedisContant.WD_TAG+"_"+wdInfo.getWdId());
-        System.out.println(tag);
         return tag;
     }
 

+ 2 - 2
ruoyi-demo/src/main/resources/mapper/demo/StoreWdDaoMapper.xml

@@ -10,10 +10,10 @@
     </select>
 
     <select id="category" resultType="com.ruoyi.demo.entity.StoreWd">
-        select manage_type_code,count(*) as comment_count from ddt_store_wd where opentime != '' and closetime != '' and wd_id in (select ${ew.sqlSelect} from ddt_wd_info ${ew.customSqlSegment}) group by manage_type_code
+        select manage_type_code,count(*) as comment_count from ddt_store_wd where wd_id in (select ${ew.sqlSelect} from ddt_wd_info ${ew.customSqlSegment}) group by manage_type_code
     </select>
 
     <select id="businessStatusAnalyse" resultType="com.ruoyi.demo.entity.StoreWd">
-        select business_status,count(*) as comment_count from ddt_store_wd where opentime != '' and closetime != '' and wd_id in (select ${ew.sqlSelect} from ddt_wd_info ${ew.customSqlSegment}) group by business_status
+        select business_status,count(*) as comment_count from ddt_store_wd where wd_id in (select ${ew.sqlSelect} from ddt_wd_info ${ew.customSqlSegment}) group by business_status
     </select>
 </mapper>