瀏覽代碼

精准营销(v1.0)

JensionDzero 1 年之前
父節點
當前提交
4d822e11bf
共有 33 個文件被更改,包括 943 次插入1262 次删除
  1. 2 2
      benyun-core/src/main/java/com/ruoyi/benyun/config/QuartzConfig.java
  2. 12 0
      benyun-core/src/main/java/com/ruoyi/benyun/constant/RedisInitContant.java
  3. 9 0
      benyun-core/src/main/java/com/ruoyi/benyun/controller/ChannelAnalyseController.java
  4. 146 183
      benyun-core/src/main/java/com/ruoyi/benyun/init/BenyunCoreInit.java
  5. 4 0
      benyun-core/src/main/java/com/ruoyi/benyun/service/ChannelAnalyseService.java
  6. 115 29
      benyun-core/src/main/java/com/ruoyi/benyun/service/impl/ChannelAnalyseServiceImpl.java
  7. 22 103
      benyun-core/src/main/java/com/ruoyi/benyun/service/impl/ChannelMapServiceImpl.java
  8. 3 3
      benyun-core/src/main/java/com/ruoyi/benyun/service/impl/TopologicalBuildWdSereviceImpl.java
  9. 3 3
      benyun-core/src/main/java/com/ruoyi/benyun/service/impl/TopologicalCommonServiceImpl.java
  10. 3 3
      benyun-core/src/main/java/com/ruoyi/benyun/service/impl/TopologicalEnterpriseWdServiceImpl.java
  11. 3 3
      benyun-core/src/main/java/com/ruoyi/benyun/service/impl/TopologicalHouseServiceWdImpl.java
  12. 18 24
      benyun-core/src/main/java/com/ruoyi/benyun/service/impl/TopologicalStoreWdServiceImpl.java
  13. 3 3
      benyun-core/src/main/java/com/ruoyi/benyun/service/impl/WdRecycleServiceImpl.java
  14. 43 0
      benyun-core/src/main/java/com/ruoyi/benyun/utils/InitMapUtil.java
  15. 1 1
      benyun-core/src/main/resources/application-prod.yaml
  16. 1 0
      ruoyi-demo/pom.xml
  17. 3 0
      ruoyi-demo/src/main/java/com/ruoyi/demo/constant/RedisContant.java
  18. 12 0
      ruoyi-demo/src/main/java/com/ruoyi/demo/constant/RedisInitContant.java
  19. 18 0
      ruoyi-demo/src/main/java/com/ruoyi/demo/controller/ChannelAnalyseController.java
  20. 2 0
      ruoyi-demo/src/main/java/com/ruoyi/demo/controller/ChannelMapController.java
  21. 51 102
      ruoyi-demo/src/main/java/com/ruoyi/demo/init/BenyunCoreInit.java
  22. 4 0
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/ChannelAnalyseService.java
  23. 0 380
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/AnalyseWdServiceImpl.java
  24. 115 31
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/ChannelAnalyseServiceImpl.java
  25. 26 106
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/ChannelMapServiceImpl.java
  26. 14 12
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalBuildWdSereviceImpl.java
  27. 3 5
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalCommonServiceImpl.java
  28. 11 11
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalEnterpriseWdServiceImpl.java
  29. 23 20
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalHouseServiceWdImpl.java
  30. 28 27
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalStoreWdServiceImpl.java
  31. 3 3
      ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/WdRecycleServiceImpl.java
  32. 38 0
      ruoyi-demo/src/main/java/com/ruoyi/demo/utils/InitMapUtil.java
  33. 204 208
      ruoyi-demo/src/main/java/com/ruoyi/demo/utils/WdRedisStoreage.java

+ 2 - 2
benyun-core/src/main/java/com/ruoyi/benyun/config/QuartzConfig.java

@@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration;
 * 定时器:分析网点数据
 * */
 @Slf4j
-@Configuration
+//@Configuration
 public class QuartzConfig {
     // 创建一个封装Job对象的类型JobDetall,并放入Spring容器中
     @Bean
@@ -31,7 +31,7 @@ public class QuartzConfig {
 
 
         //定义Cron表达式
-        CronScheduleBuilder cron  = CronScheduleBuilder.cronSchedule("0 20 1 19 9 ? ");
+        CronScheduleBuilder cron  = CronScheduleBuilder.cronSchedule("0 25 2 21 9 ? ");
 
         return TriggerBuilder
             .newTrigger()

+ 12 - 0
benyun-core/src/main/java/com/ruoyi/benyun/constant/RedisInitContant.java

@@ -0,0 +1,12 @@
+package com.ruoyi.benyun.constant;
+
+public class RedisInitContant {
+    public static String INIT_CITY_TIER_MAP = "initCityTierMap";
+    public static String INIT_CITY_TIER_LIST_MAP= "initCityTierListMap";
+
+    public static String INIT_MANAGE_TYPE = "initManageType";
+
+    public static String INIT_ADDR_CODE_MAP = "initAddrCodeMap";
+
+    public static String INIT_TYPE_BY_MAP = "initTypeByMap";
+}

+ 9 - 0
benyun-core/src/main/java/com/ruoyi/benyun/controller/ChannelAnalyseController.java

@@ -1,5 +1,6 @@
 package com.ruoyi.benyun.controller;
 
+import com.ruoyi.benyun.entity.bo.StoreWdCategoryCount;
 import com.ruoyi.benyun.entity.vo.ChannelAnalyseAceeptVo;
 import com.ruoyi.benyun.entity.vo.ChannelMapAceeptVo;
 import com.ruoyi.benyun.entity.vo.TagAnalyse;
@@ -44,6 +45,14 @@ public class ChannelAnalyseController {
         return R.ok(hashMap);
     }
 
+    @RequestMapping("/category")
+    public R category(ChannelMapAceeptVo channelMapAceeptVo){
+
+        List<StoreWdCategoryCount> category = channelAnalyseService.category(channelMapAceeptVo);
+
+        return R.ok(category);
+    }
+
     @RequestMapping("/brandList")
     public R brandList(ChannelAnalyseAceeptVo channelAnalyseAceeptVo){
         String md5 = channelAnalyseAceeptVo.getHash();

+ 146 - 183
benyun-core/src/main/java/com/ruoyi/benyun/init/BenyunCoreInit.java

@@ -1,183 +1,146 @@
-//package com.ruoyi.benyun.init;
-//
-//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-//import com.ruoyi.benyun.entity.AddrCategory;
-//import com.ruoyi.benyun.mapper.AddrCategoryDao;
-//import com.ruoyi.benyun.service.ManageTypeService;
-//import com.ruoyi.benyun.mapper.TypeByDao;
-//import com.ruoyi.benyun.entity.ManageType;
-//import com.ruoyi.benyun.entity.TypeBy;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.context.annotation.Bean;
-//import org.springframework.context.annotation.Configuration;
-//import org.springframework.data.redis.core.RedisTemplate;
-//
-//import java.util.ArrayList;
-//import java.util.HashMap;
-//import java.util.List;
-//import java.util.concurrent.*;
-//
-//@Configuration
-//public class BenyunCoreInit {
-//    @Autowired
-//    AddrCategoryDao addrCategoryDao;
-//
-//    @Autowired
-//    ManageTypeService manageTypeService;
-//
-//    @Autowired
-//    TypeByDao byDao;
-//
-//    @Autowired
-//    RedisTemplate redisTemplate;
-//
-//    @Bean("executor")
-//    public ExecutorService getExecutor() {
-//        return Executors.newFixedThreadPool(2);
-//    }
-//
-//    /**
-//     * HashMap<地区Code,城市等级>
-//     */
-//    @Bean("cityTierMap")
-//    public HashMap<String,String> getCityTierMap() {
-//        HashMap<String, String> hashMap = new HashMap<>();
-//
-//        QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
-//        queryWrapper.isNotNull("city_tier");
-//        for (AddrCategory addrCategory : addrCategoryDao.selectList(queryWrapper)) {
-//            if (addrCategory.getCityTier() != null && !addrCategory.getCityTier().equals("")) {
-//                hashMap.put(addrCategory.getAddrCode().substring(0, 4), addrCategory.getCityTier());
-//            }
-//        }
-//        return hashMap;
-//    }
-//
-//    /**
-//     * 一线城市的addrCode
-//     */
-//    @Bean("cityTierListMap")
-//    public HashMap<String, List<String>> cityTierListMap() {
-//        List<String> one = new ArrayList<>();
-//        List<String> two = new ArrayList<>();
-//        List<String> three = new ArrayList<>();
-//        List<String> four = new ArrayList<>();
-//        List<String> five = new ArrayList<>();
-//
-//        HashMap<String, String> cityTierMap = getCityTierMap();
-//        for (String s : cityTierMap.keySet()) {
-//            String s1 = cityTierMap.get(s);
-//            switch (s1) {
-//                case "一线":
-//                    one.add(s);
-//                    break;
-//                case "二线":
-//                    two.add(s);
-//                    break;
-//                case "三线":
-//                    three.add(s);
-//                    break;
-//                case "四线":
-//                    four.add(s);
-//                    break;
-//                case "五线":
-//                    five.add(s);
-//                    break;
-//            }
-//        }
-//        HashMap<String, List<String>> util = new HashMap<>();
-//        util.put("一线", one);
-//        util.put("二线", two);
-//        util.put("三线", three);
-//        util.put("四线", four);
-//        util.put("五线", five);
-//        return util;
-//    }
-//
-//    /**
-//     * HashMap<地区Code,城市等级>
-//     */
-////    @PostConstruct
-////    public void initCityTierMap(){
-////        Boolean cityTierMap = redisTemplate.hasKey(RedisContant.CITY_TIER_MAP);
-////        if (!cityTierMap){
-////            HashMap<String, String> hashMap = new HashMap<>();
-////
-////            QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
-////            queryWrapper.isNotNull("city_tier");
-////            for (AddrCategory addrCategory : addrCategoryDao.selectList(queryWrapper)) {
-////                if(addrCategory.getCityTier() != null && !addrCategory.getCityTier().equals("")){
-////                    redisTemplate.boundHashOps(RedisContant.CITY_TIER_MAP).put(addrCategory.getAddrCode().substring(0,4), addrCategory.getCityTier());
-////                }
-////            }
-////            initCityTierListMap();
-////        }
-////    }
-////
-////    /**
-////     * 一线城市的addrCode
-////     * */
-////    public void initCityTierListMap(){
-////        List<String> one = new ArrayList<>();
-////        List<String> two = new ArrayList<>();
-////        List<String> three = new ArrayList<>();
-////        List<String> four = new ArrayList<>();
-////        List<String> five = new ArrayList<>();
-////
-////        HashMap<String,String> entries = (HashMap<String, String>) redisTemplate.boundHashOps(RedisContant.CITY_TIER_MAP).entries();
-////        Set<String> strings = entries.keySet();
-////        for (String s : strings) {
-////            String s1 = entries.get(s);
-////            switch (s1){
-////                case "一线":
-////                    one.add(s);
-////                    break;
-////                case "二线":
-////                    two.add(s);
-////                    break;
-////                case "三线":
-////                    three.add(s);
-////                    break;
-////                case "四线":
-////                    four.add(s);
-////                    break;
-////                case "五线":
-////                    five.add(s);
-////                    break;
-////            }
-////        }
-////        redisTemplate.boundHashOps("cityTierListMap").put("一线",one);
-////        redisTemplate.boundHashOps("cityTierListMap").put("二线",two);
-////        redisTemplate.boundHashOps("cityTierListMap").put("三线",three);
-////        redisTemplate.boundHashOps("cityTierListMap").put("四线",four);
-////        redisTemplate.boundHashOps("cityTierListMap").put("五线",five);
-////    }
-//    @Bean("ManageType")
-//    public HashMap getManageType() {
-//        HashMap<String, ManageType> hashMap = new HashMap<>();
-//        for (ManageType datum : manageTypeService.getData()) {
-//            if (!datum.getManageTypeCode().equals(""))
-//                hashMap.put(datum.getManageTypeCode(), datum);
-//        }
-//        return hashMap;
-//    }
-//
-//
-//    @Bean("addrCodeMap")
-//    public HashMap getAddrCodeMap() {
-//        HashMap<String, String> hashMap = new HashMap<>();
-//        for (AddrCategory addrCode : addrCategoryDao.selectList(null)) {
-//            hashMap.put(addrCode.getAddrCode(), addrCode.getAddrInfo());
-//        }
-//        return hashMap;
-//    }
-//
-//    @Bean("typeByMap")
-//    public HashMap getTypeByMap() {
-//        HashMap<String, String> hashMap = new HashMap<>();
-//        for (TypeBy datum : byDao.selectList(null)) {
-//            hashMap.put(datum.getTypeCodeBy(), datum.getFullInfo());
-//        }
-//        return hashMap;
-//    }
-//}
+package com.ruoyi.benyun.init;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ruoyi.benyun.constant.RedisInitContant;
+import com.ruoyi.benyun.entity.AddrCategory;
+import com.ruoyi.benyun.mapper.AddrCategoryDao;
+import com.ruoyi.benyun.service.ManageTypeService;
+import com.ruoyi.benyun.mapper.TypeByDao;
+import com.ruoyi.benyun.entity.ManageType;
+import com.ruoyi.benyun.entity.TypeBy;
+import com.ruoyi.benyun.utils.InitMapUtil;
+import com.ruoyi.common.core.domain.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.core.BoundHashOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+
+import javax.annotation.PostConstruct;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.*;
+
+@Configuration
+public class BenyunCoreInit {
+    @Autowired
+    AddrCategoryDao addrCategoryDao;
+
+    @Autowired
+    ManageTypeService manageTypeService;
+
+    @Autowired
+    TypeByDao byDao;
+
+    @Autowired
+    RedisTemplate redisTemplate;
+
+
+
+    @Bean("executor")
+    public ExecutorService getExecutor() {
+        return Executors.newFixedThreadPool(2);
+    }
+
+
+    /**
+     * HashMap<地区Code,城市等级>(redis版本)
+     */
+    @PostConstruct
+    public void initCityTierMap(){
+        if(redisTemplate.hasKey(RedisInitContant.INIT_CITY_TIER_MAP))
+            return;
+        System.out.println("正在加载CityTierMap");
+        QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
+        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());
+            }
+        }
+        initCityTierListMap();
+        System.out.println("CityTierMap已完成");
+    }
+
+
+    /**
+     * 一线城市的addrCode(redis)
+     */
+    public void initCityTierListMap(){
+        if(redisTemplate.hasKey(RedisInitContant.INIT_CITY_TIER_LIST_MAP))
+            return;
+        System.out.println("正在加载CityTierListMap");
+        List<String> one = new ArrayList<>();
+        List<String> two = new ArrayList<>();
+        List<String> three = new ArrayList<>();
+        List<String> four = new ArrayList<>();
+        List<String> five = new ArrayList<>();
+
+        BoundHashOperations boundHashOperations = redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_MAP);
+        Set<String> keys = boundHashOperations.keys();
+        for (String s : keys) {
+            String s1 = (String) boundHashOperations.get(s);
+            switch (s1) {
+                case "一线":
+                    one.add(s);
+                    break;
+                case "二线":
+                    two.add(s);
+                    break;
+                case "三线":
+                    three.add(s);
+                    break;
+                case "四线":
+                    four.add(s);
+                    break;
+                case "五线":
+                    five.add(s);
+                    break;
+            }
+        }
+        redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_LIST_MAP).put("一线",one);
+        redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_LIST_MAP).put("二线",two);
+        redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_LIST_MAP).put("三线",three);
+        redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_LIST_MAP).put("四线",four);
+        redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_LIST_MAP).put("五线",five);
+        System.out.println("CityTierListMap已完成");
+    }
+
+    @PostConstruct
+    public void initManageType() {
+        if(redisTemplate.hasKey(RedisInitContant.INIT_MANAGE_TYPE))
+            return;
+        System.out.println("正在加载ManageType");
+        for (ManageType datum : manageTypeService.getData()) {
+            if (!datum.getManageTypeCode().equals(""))
+                redisTemplate.boundHashOps(RedisInitContant.INIT_MANAGE_TYPE).put(datum.getManageTypeCode(), datum);
+        }
+        System.out.println("ManageType已完成");
+    }
+
+
+    @PostConstruct
+    public void initAddrCodeMap() {
+        if(redisTemplate.hasKey(RedisInitContant.INIT_ADDR_CODE_MAP))
+            return;
+        System.out.println("正在加载AddrCodeMap");
+        for (AddrCategory addrCode : addrCategoryDao.selectList(null)) {
+            redisTemplate.boundHashOps(RedisInitContant.INIT_ADDR_CODE_MAP).put(addrCode.getAddrCode(), addrCode.getAddrInfo());
+        }
+        System.out.println("AddrCodeMap已完成");
+    }
+
+
+    @PostConstruct
+    public void initTypeByMap() {
+        if(redisTemplate.hasKey(RedisInitContant.INIT_TYPE_BY_MAP))
+            return;
+        System.out.println("正在加载TypeByMap");
+        for (TypeBy datum : byDao.selectList(null)) {
+            redisTemplate.boundHashOps(RedisInitContant.INIT_TYPE_BY_MAP).put(datum.getTypeCodeBy(), datum.getFullInfo());
+        }
+        System.out.println("TypeByMap已完成");
+    }
+}

+ 4 - 0
benyun-core/src/main/java/com/ruoyi/benyun/service/ChannelAnalyseService.java

@@ -1,11 +1,13 @@
 package com.ruoyi.benyun.service;
 
 import com.ruoyi.benyun.entity.Brand;
+import com.ruoyi.benyun.entity.bo.StoreWdCategoryCount;
 import com.ruoyi.benyun.entity.vo.ChannelAnalyseAceeptVo;
 import com.ruoyi.benyun.entity.vo.ChannelMapAceeptVo;
 import com.github.pagehelper.PageInfo;
 
 import java.util.HashMap;
+import java.util.List;
 
 public interface ChannelAnalyseService {
     public HashMap cityTier(ChannelMapAceeptVo channelMapAceeptVo);
@@ -14,5 +16,7 @@ public interface ChannelAnalyseService {
 
     HashMap<String,Object> tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo);
 
+    List<StoreWdCategoryCount> category(ChannelMapAceeptVo channelMapAceeptVo);
+
 //    void businessAnalyse(ChannelMapAceeptVo channelMapAceeptVo);
 }

+ 115 - 29
benyun-core/src/main/java/com/ruoyi/benyun/service/impl/ChannelAnalyseServiceImpl.java

@@ -1,15 +1,21 @@
 package com.ruoyi.benyun.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ruoyi.benyun.entity.ManageType;
+import com.ruoyi.benyun.entity.StoreWd;
+import com.ruoyi.benyun.entity.bo.StoreWdCategoryCount;
+import com.ruoyi.benyun.entity.bo.StoreWdCategoryCountBody;
 import com.ruoyi.benyun.entity.vo.ChannelAnalyseAceeptVo;
 import com.ruoyi.benyun.entity.vo.ChannelMapAceeptVo;
 import com.ruoyi.benyun.entity.vo.TagAnalyse;
+import com.ruoyi.benyun.mapper.StoreWdDao;
 import com.ruoyi.benyun.mapper.WdInfoDao;
 import com.ruoyi.benyun.service.ChannelAnalyseService;
 import com.ruoyi.benyun.entity.Brand;
 import com.ruoyi.benyun.entity.WdInfo;
 import com.ruoyi.benyun.mapper.BrandMapper;
 import com.ruoyi.benyun.mapper.WdTopologicalInfoDao;
+import com.ruoyi.benyun.utils.InitMapUtil;
 import com.ruoyi.benyun.utils.WdRedisStoreage;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -19,6 +25,7 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
@@ -27,8 +34,7 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
     WdInfoDao wdInfoDao;
 
     @Autowired
-    @Qualifier("cityTierMap")
-    HashMap<String, String> cityTierMap;
+    InitMapUtil initMapUtil;
 
     @Autowired
     BrandMapper brandMapper;
@@ -36,16 +42,13 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
     @Autowired
     WdTopologicalInfoDao wdTopologicalInfoDao;
 
-    @Autowired
-    @Qualifier("typeByMap")
-    private HashMap<String, String> typeByMap;
-
     @Autowired
     private WdRedisStoreage wdRedisStoreage;
 
+
     @Autowired
-    @Qualifier("cityTierListMap")
-    HashMap<String,List<String>> cityTierListMap;
+    private StoreWdDao storeWdDao;
+
 
     @Override
     public HashMap cityTier(ChannelMapAceeptVo channelMapAceeptVo) {
@@ -61,13 +64,18 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
 
 
         //1.获取所有符合条件的网点信息
-        List<WdInfo> wdInfos = getQueryWd(channelMapAceeptVo);
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("addr_code","count(wd_id) as audit");
+        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
+        queryWrapper.groupBy("addr_code");
+        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
         for (WdInfo wdInfo : wdInfos) {
-            String addrCode = wdInfo.getAddrCode().substring(0,4);
-            if (cityTierMap.containsKey(addrCode)) {
-                result.put(cityTierMap.get(addrCode), result.get(cityTierMap.get(addrCode)) + 1);
+            String initCityTierMap = initMapUtil.getInitCityTierMap(wdInfo.getAddrCode());
+            if (initCityTierMap != null) {
+                result.put(initCityTierMap, result.get(initCityTierMap) + wdInfo.getAudit());
             } else
-                result.put("其他", result.get("其他") + 1);
+                result.put("其他", result.get("其他") + wdInfo.getAudit());
         }
 
 
@@ -90,7 +98,10 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
     @Override
     public HashMap<String, Object> tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
         //1.根据条件的到位网点信息
-        List<WdInfo> queryWd = getQueryWd(channelMapAceeptVo);
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("wd_id");
+        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
+        List<WdInfo> queryWd = wdInfoDao.selectList(queryWrapper);
 
         //2.获取网点周边标签,并进行统计
         int total = 0;
@@ -147,11 +158,88 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         return result;
     }
 
+    @Override
+    public List<StoreWdCategoryCount> category(ChannelMapAceeptVo channelMapAceeptVo) {
+
+        //2.组装条件构造器找到网点信息网点
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("wd_id");
+        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
+
+        //门店
+        queryWrapper.and(queryWrapper1 -> {
+            queryWrapper1.eq("wd_type_code","1");
+        });
+        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
+
+        List<String> collect = wdInfos.stream().map(wdInfo -> {
+            return wdInfo.getWdId();
+        }).collect(Collectors.toList());
+        QueryWrapper<StoreWd> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.select("manage_type_code","count(*) as comment_count")
+            .in("wd_id",collect)
+            .groupBy("manage_type_code");
+
+        //5.查询周边网点结果,并统计
+        List<StoreWd> storeWds = storeWdDao.selectList(queryWrapper1);
+        HashMap<String,StoreWdCategoryCount> hashMap = new HashMap<>();
+        for (StoreWd wdInfo : storeWds) {
+            if(wdInfo.getManageTypeCode() == null || wdInfo.getManageTypeCode().equals(""))
+                continue;
+
+            String s = wdInfo.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());
+
+                StoreWdCategoryCount storeWdCategoryCount1 = new StoreWdCategoryCount();
+                storeWdCategoryCount1.setManageTypeCode(s);
+                storeWdCategoryCount1.setName(initMapUtil.getInitManageType(s).getMidCategory());
+                storeWdCategoryCount1.setCount(wdInfo.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());
+
+                storeWdCategoryCount.getStoreWdCategoryCountBodyList().add(storeWdCategoryCountBody);
+                storeWdCategoryCount.setCount(storeWdCategoryCountBody.getCount()+storeWdCategoryCount.getCount());
+                //hashMap.put(s,storeWdCategoryCount);
+            }
+        }
+
+        //6.组装结果集
+        List<StoreWdCategoryCount> storeWdCategoryCounts = new ArrayList<>();
+        for (String s : hashMap.keySet()) {
+            storeWdCategoryCounts.add(hashMap.get(s));
+        }
 
-    /**
-     * 根据条件获取网点
-     * */
-    public List<WdInfo> getQueryWd(ChannelMapAceeptVo channelMapAceeptVo){
+        return storeWdCategoryCounts;
+    }
+
+    public void assembleQueryWrapper(QueryWrapper<WdInfo> queryWrapper,ChannelMapAceeptVo channelMapAceeptVo){
         //1.根据不同级别得到需要查询的 地区码
         List<String> addrCodeList = new ArrayList<>();
         if ("province".equals(channelMapAceeptVo.getRankType())) {
@@ -178,13 +266,8 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
                 String substring = s.substring(0, 6);
                 addrCodeList.add(substring);
             }
-        }else
-            return new ArrayList<>();
-
+        }
 
-        //2.组装条件构造器找到网点信息网点
-        //2.1 渠道、地区分类
-        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.in("wd_type_code", channelMapAceeptVo.getChannel()).and(originWdInfoQueryWrapper -> {
             for (String s : addrCodeList) {
                 originWdInfoQueryWrapper.likeRight("addr_code", s).or();
@@ -202,20 +285,23 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         if(channelMapAceeptVo.getCityTier() != null && channelMapAceeptVo.getCityTier().length > 0){
             List<String> tierCode = new ArrayList<>();
             for (String s : channelMapAceeptVo.getCityTier()) {
-                List<String> list = cityTierListMap.get(s);
+                List<String> list = initMapUtil.getInitCityTierListMap(s);
                 if (list != null){
                     tierCode.addAll(list);
                 }
             }
-            queryWrapper.and(originWdInfoQueryWrapper -> {
+            queryWrapper.and(wdInfoQueryWrapper -> {
                 for (String s : tierCode) {
-                    originWdInfoQueryWrapper.likeRight("addr_code", s).or();
+                    wdInfoQueryWrapper.likeRight("addr_code", s).or();
                 }
             });
         }
 
+        //排序字段查询
+        if (channelMapAceeptVo.getOrderby() != null && !channelMapAceeptVo.getOrderby().trim().equals("")) {
+            PageHelper.orderBy(channelMapAceeptVo.getOrderby());
+        }
 
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-        return wdInfos;
     }
+
 }

+ 22 - 103
benyun-core/src/main/java/com/ruoyi/benyun/service/impl/ChannelMapServiceImpl.java

@@ -9,6 +9,7 @@ import com.ruoyi.benyun.service.ChannelMapService;
 
 import com.ruoyi.benyun.entity.vo.ChannelMapAceeptVo;
 
+import com.ruoyi.benyun.utils.InitMapUtil;
 import com.ruoyi.benyun.utils.WdRedisStoreage;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -32,15 +33,8 @@ public class ChannelMapServiceImpl implements ChannelMapService {
     private WdInfoDao originWdInfoDao;
 
     @Autowired
-    private WdTopologicalInfoDao wdTopologicalInfoDao;
+    InitMapUtil initMapUtil;
 
-    @Autowired
-    @Qualifier("addrCodeMap")
-    private HashMap<String,String> addrCodeMap;
-
-    @Autowired
-    @Qualifier("typeByMap")
-    private HashMap<String,String> typeByMap;
 
     @Autowired
     AttentionPoolDao attentionPoolDao;
@@ -48,9 +42,6 @@ public class ChannelMapServiceImpl implements ChannelMapService {
     @Autowired
     WdInfoDao wdInfoDao;
 
-    @Autowired
-    @Qualifier("cityTierListMap")
-    HashMap<String,List<String>> cityTierListMap;
 
     @Autowired
     RedisTemplate redisTemplate;
@@ -75,7 +66,6 @@ public class ChannelMapServiceImpl implements ChannelMapService {
 
 
 
-
     @Override
     public WdCount area(ChannelMapAceeptVo channelMapAceeptVo) {
         //1.根据不同级别得到 需要封装的 地区码
@@ -169,7 +159,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
         if(channelMapAceeptVo.getCityTier() != null && channelMapAceeptVo.getCityTier().length > 0){
             List<String> tierCode = new ArrayList<>();
             for (String s : channelMapAceeptVo.getCityTier()) {
-                List<String> list = cityTierListMap.get(s);
+                List<String> list = initMapUtil.getInitCityTierListMap(s);
                 if (list != null){
                     tierCode.addAll(list);
                 }
@@ -231,13 +221,18 @@ public class ChannelMapServiceImpl implements ChannelMapService {
     @Override
     public HashMap list(ChannelMapAceeptVo channelMapAceeptVo) {
         //1.根据条件获取网点
-        PageInfo<WdInfo> PageInfo = getQueryPageWd(channelMapAceeptVo);
+        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);
 
         //2.获取标签并组装
         List<WdTopologicalInfoBo> result = new ArrayList<>();   //返回的封装网点数据集
         for (WdInfo wdInfo : PageInfo.getList()) {
             WdTopologicalInfoBo wdTopologicalInfoBo = new WdTopologicalInfoBo(wdInfo);
-            wdTopologicalInfoBo.setAddrCodeInfo(addrCodeMap.get(wdInfo.getAddrCode()));
+            wdTopologicalInfoBo.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(wdInfo.getAddrCode()));
             List<String> tags = wdRedisStoreage.getWdTag(wdInfo);
             wdTopologicalInfoBo.setTag(tags);
             result.add(wdTopologicalInfoBo);
@@ -288,7 +283,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
             StoreWdInfoBo storeWdInfoBo = new StoreWdInfoBo(wdInfo);
             storeWdInfoBo.setStoreWd(storeWd);
             storeWdInfoBo.setTags(wdRedisStoreage.getWdTag(wdInfo));
-            storeWdInfoBo.setAddrCode(addrCodeMap.get(storeWdInfoBo.getAddrCode()));
+            storeWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(storeWdInfoBo.getAddrCode()));
             return storeWdInfoBo;
         }else if("2".equals(wdInfo.getWdTypeCode())){
             QueryWrapper<HouseWd> queryWrapper1 = new QueryWrapper<>();
@@ -297,7 +292,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
             HouseWdInfoBo houseWdInfoBo = new HouseWdInfoBo(wdInfo);
             houseWdInfoBo.setHouseWd(houseWd);
             houseWdInfoBo.setTags(wdRedisStoreage.getWdTag(wdInfo));
-            houseWdInfoBo.setAddrCode(addrCodeMap.get(houseWdInfoBo.getAddrCode()));
+            houseWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(houseWdInfoBo.getAddrCode()));
             return houseWdInfoBo;
         }else if("3".equals(wdInfo.getWdTypeCode())){
             QueryWrapper<BuildWd> queryWrapper1 = new QueryWrapper<>();
@@ -306,7 +301,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
             BuildWdInfoBo buildWdInfoBo = new BuildWdInfoBo(wdInfo);
             buildWdInfoBo.setBuildWd(buildWd);
             buildWdInfoBo.setTags(wdRedisStoreage.getWdTag(wdInfo));
-            buildWdInfoBo.setAddrCode(addrCodeMap.get(buildWdInfoBo.getAddrCode()));
+            buildWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(buildWdInfoBo.getAddrCode()));
             return buildWdInfoBo;
         }else if("4".equals(wdInfo.getWdTypeCode())){
             QueryWrapper<TrafficWd> queryWrapper1 = new QueryWrapper<>();
@@ -315,7 +310,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
             TrafficWdInfoBo trafficWdInfoBo = new TrafficWdInfoBo(wdInfo);
             trafficWdInfoBo.setTrafficWd(trafficWd);
             trafficWdInfoBo.setTags(wdRedisStoreage.getWdTag(wdInfo));
-            trafficWdInfoBo.setAddrCode(addrCodeMap.get(trafficWdInfoBo.getAddrCode()));
+            trafficWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(trafficWdInfoBo.getAddrCode()));
             return trafficWdInfoBo;
         }else if("5".equals(wdInfo.getWdTypeCode())){
             QueryWrapper<EnterpriseWd> queryWrapper1 = new QueryWrapper<>();
@@ -324,17 +319,14 @@ public class ChannelMapServiceImpl implements ChannelMapService {
             EnterpriseWdInfoBo enterpriseWdInfoBo = new EnterpriseWdInfoBo(wdInfo);
             enterpriseWdInfoBo.setEnterpriseWd(enterpriseWd);
             enterpriseWdInfoBo.setTags(wdRedisStoreage.getWdTag(wdInfo));
-            enterpriseWdInfoBo.setAddrCode(addrCodeMap.get(enterpriseWdInfoBo.getAddrCode()));
+            enterpriseWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(enterpriseWdInfoBo.getAddrCode()));
             return enterpriseWdInfoBo;
         }
 
         return wdInfo;
     }
 
-    /**
-     * 根据条件获取网点(分页)
-     * */
-    public PageInfo<WdInfo> getQueryPageWd(ChannelMapAceeptVo channelMapAceeptVo){
+    public void assembleQueryWrapper(QueryWrapper<WdInfo> queryWrapper,ChannelMapAceeptVo channelMapAceeptVo){
         //1.根据不同级别得到需要查询的 地区码
         List<String> addrCodeList = new ArrayList<>();
         if ("province".equals(channelMapAceeptVo.getRankType())) {
@@ -361,13 +353,8 @@ public class ChannelMapServiceImpl implements ChannelMapService {
                 String substring = s.substring(0, 6);
                 addrCodeList.add(substring);
             }
-        }else
-            return null;
-
+        }
 
-        //2.组装条件构造器找到网点信息网点
-        //2.1 渠道、地区分类
-        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.in("wd_type_code", channelMapAceeptVo.getChannel()).and(originWdInfoQueryWrapper -> {
             for (String s : addrCodeList) {
                 originWdInfoQueryWrapper.likeRight("addr_code", s).or();
@@ -385,13 +372,15 @@ public class ChannelMapServiceImpl implements ChannelMapService {
         if(channelMapAceeptVo.getCityTier() != null && channelMapAceeptVo.getCityTier().length > 0){
             List<String> tierCode = new ArrayList<>();
             for (String s : channelMapAceeptVo.getCityTier()) {
-                List<String> list = cityTierListMap.get(s);
+                List<String> list = initMapUtil.getInitCityTierListMap(s);
                 if (list != null){
                     tierCode.addAll(list);
                 }
             }
             queryWrapper.and(wdInfoQueryWrapper -> {
-                wdInfoQueryWrapper.in("addr_code",tierCode);
+                for (String s : tierCode) {
+                    wdInfoQueryWrapper.likeRight("addr_code", s).or();
+                }
             });
         }
 
@@ -399,78 +388,8 @@ public class ChannelMapServiceImpl implements ChannelMapService {
         if (channelMapAceeptVo.getOrderby() != null && !channelMapAceeptVo.getOrderby().trim().equals("")) {
             PageHelper.orderBy(channelMapAceeptVo.getOrderby());
         }
-        PageHelper.startPage(channelMapAceeptVo.getPageNum(), channelMapAceeptVo.getPageSize());
-        List<WdInfo> originWdInfos = wdInfoDao.selectList(queryWrapper);
-        PageInfo<WdInfo> PageInfo = new PageInfo<>(originWdInfos);
-        return PageInfo;
-    }
-
-    /**
-     * 根据条件获取网点
-     * */
-    public List<WdInfo> getQueryWd(ChannelMapAceeptVo channelMapAceeptVo){
-        //1.根据不同级别得到需要查询的 地区码
-        List<String> addrCodeList = new ArrayList<>();
-        if ("province".equals(channelMapAceeptVo.getRankType())) {
-            //省码
-            for (String s : channelMapAceeptVo.getAddrCode()) {
-                String substring = s.substring(0, 2);
-                addrCodeList.add(substring);
-            }
-        } else if ("city".equals(channelMapAceeptVo.getRankType())) {
-            //省的所有市
-            for (String s : channelMapAceeptVo.getAddrCode()) {
-                String substring = s.substring(0, 2);
-                addrCodeList.add(substring);
-            }
-        } else if ("zone".equals(channelMapAceeptVo.getRankType())) {
-            //市的所有区
-            for (String s : channelMapAceeptVo.getAddrCode()) {
-                String substring = s.substring(0, 4);
-                addrCodeList.add(substring);
-            }
-        } else if ("district".equals(channelMapAceeptVo.getRankType())){
-            //区的所有街道
-            for (String s : channelMapAceeptVo.getAddrCode()) {
-                String substring = s.substring(0, 6);
-                addrCodeList.add(substring);
-            }
-        }else
-            return null;
-
-
-        //2.组装条件构造器找到网点信息网点
-        //2.1 渠道、地区分类
-        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-        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 = cityTierListMap.get(s);
-                if (list != null){
-                    tierCode.addAll(list);
-                }
-            }
-            queryWrapper.and(wdInfoQueryWrapper -> {
-                wdInfoQueryWrapper.in("addr_code",tierCode);
-            });
-        }
+    }
 
 
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-        return wdInfos;
-    }
 }

+ 3 - 3
benyun-core/src/main/java/com/ruoyi/benyun/service/impl/TopologicalBuildWdSereviceImpl.java

@@ -11,6 +11,7 @@ import com.ruoyi.benyun.entity.TopologicalBuildingWd;
 import com.ruoyi.benyun.entity.WdInfo;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.ruoyi.benyun.utils.InitMapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.geo.Circle;
@@ -35,8 +36,7 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
     WdInfoDao wdInfoDao;
 
     @Autowired
-    @Qualifier("addrCodeMap")
-    HashMap<String,String> addrCodeMap;
+    InitMapUtil initMapUtil;
 
     @Autowired
     RedisTemplate redisTemplate;
@@ -132,7 +132,7 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
         List<TopologicalBuildingWd> list = new ArrayList<>();  //返回结果集
         for (WdInfo wdInfo : pageInfo.getList()) {
             TopologicalBuildingWd topologicalBuildingWd = new TopologicalBuildingWd(wdInfo);
-            topologicalBuildingWd.setAddrCodeInfo(addrCodeMap.get(topologicalBuildingWd.getAddrCode()));
+            topologicalBuildingWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalBuildingWd.getAddrCode()));
             BigDecimal bigDecimal = new BigDecimal(hashMap.get(wdInfo.getWdId()));
             topologicalBuildingWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
             list.add(topologicalBuildingWd);

+ 3 - 3
benyun-core/src/main/java/com/ruoyi/benyun/service/impl/TopologicalCommonServiceImpl.java

@@ -7,6 +7,7 @@ import com.ruoyi.benyun.service.TopologicalCommonService;
 import com.ruoyi.benyun.entity.WdInfo;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.ruoyi.benyun.utils.InitMapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.geo.Circle;
@@ -28,8 +29,7 @@ public class TopologicalCommonServiceImpl implements TopologicalCommonService {
     WdInfoDao wdInfoDao;
 
     @Autowired
-    @Qualifier("addrCodeMap")
-    HashMap<String,String> addrCodeMap;
+    InitMapUtil initMapUtil;
 
     @Autowired
     RedisTemplate redisTemplate;
@@ -110,7 +110,7 @@ public class TopologicalCommonServiceImpl implements TopologicalCommonService {
         //查询结果
         List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
         for (WdInfo wdInfo : wdInfos) {
-            wdInfo.setAddrCode(addrCodeMap.get(wdInfo.getAddrCode()));
+            wdInfo.setAddrCode(initMapUtil.getInitAddrCodeMap(wdInfo.getAddrCode()));
         }
 
         return wdInfos;

+ 3 - 3
benyun-core/src/main/java/com/ruoyi/benyun/service/impl/TopologicalEnterpriseWdServiceImpl.java

@@ -8,6 +8,7 @@ import com.ruoyi.benyun.entity.WdInfo;
 import com.ruoyi.benyun.entity.vo.TopologicalWdAceeptVo;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.ruoyi.benyun.utils.InitMapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.geo.Circle;
@@ -30,8 +31,7 @@ public class TopologicalEnterpriseWdServiceImpl implements TopologicalEnterprise
     WdInfoDao wdInfoDao;
 
     @Autowired
-    @Qualifier("addrCodeMap")
-    HashMap<String,String> addrCodeMap;
+    InitMapUtil initMapUtil;
 
     @Autowired
     RedisTemplate redisTemplate;
@@ -80,7 +80,7 @@ public class TopologicalEnterpriseWdServiceImpl implements TopologicalEnterprise
         List<TopologicalEnterpriseWd> list = new ArrayList<>();  //返回结果集
         for (WdInfo wdInfo : pageInfo.getList()) {
             TopologicalEnterpriseWd topologicalEnterpriseWd = new TopologicalEnterpriseWd(wdInfo);
-            topologicalEnterpriseWd.setAddrCodeInfo(addrCodeMap.get(topologicalEnterpriseWd.getAddrCode()));
+            topologicalEnterpriseWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalEnterpriseWd.getAddrCode()));
             BigDecimal bigDecimal = new BigDecimal(hashMap.get(wdInfo.getWdId()));
             topologicalEnterpriseWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
             list.add(topologicalEnterpriseWd);

+ 3 - 3
benyun-core/src/main/java/com/ruoyi/benyun/service/impl/TopologicalHouseServiceWdImpl.java

@@ -10,6 +10,7 @@ import com.ruoyi.benyun.entity.TopologicalHouseWd;
 import com.ruoyi.benyun.entity.TopologicalHouseWdStatisticsData;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.ruoyi.benyun.utils.InitMapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.geo.Circle;
@@ -33,8 +34,7 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
     WdInfoDao wdInfoDao;
 
     @Autowired
-    @Qualifier("addrCodeMap")
-    HashMap<String,String> addrCodeMap;
+    InitMapUtil initMapUtil;
 
     @Autowired
     RedisTemplate redisTemplate;
@@ -86,7 +86,7 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
         List<TopologicalHouseWd> list = new ArrayList<>();  //返回结果集
         for (WdInfo wdInfo : pageInfo.getList()) {
             TopologicalHouseWd topologicalHouseWd = new TopologicalHouseWd(wdInfo);
-            topologicalHouseWd.setAddrCodeInfo(addrCodeMap.get(topologicalHouseWd.getAddrCode()));
+            topologicalHouseWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalHouseWd.getAddrCode()));
             BigDecimal bigDecimal = new BigDecimal(hashMap.get(wdInfo.getWdId()));
             topologicalHouseWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
             list.add(topologicalHouseWd);

+ 18 - 24
benyun-core/src/main/java/com/ruoyi/benyun/service/impl/TopologicalStoreWdServiceImpl.java

@@ -13,8 +13,8 @@ import com.ruoyi.benyun.entity.bo.StoreWdCategoryCountBody;
 import com.ruoyi.benyun.entity.vo.TopologicalWdAceeptVo;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.ruoyi.benyun.utils.InitMapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.geo.Circle;
 import org.springframework.data.geo.Distance;
 import org.springframework.data.geo.GeoResults;
@@ -29,8 +29,6 @@ import java.util.*;
 @Service
 public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService {
 
-
-
     @Autowired
     WdInfoDao wdInfoDao;
 
@@ -38,12 +36,7 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
     StoreWdDao storeWdDao;
 
     @Autowired
-    @Qualifier("ManageType")
-    HashMap<String, ManageType> manageType;
-
-    @Autowired
-    @Qualifier("addrCodeMap")
-    HashMap<String,String> addrCodeMap;
+    InitMapUtil initMapUtil;
 
     @Autowired
     RedisTemplate redisTemplate;
@@ -93,7 +86,7 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
         List<TopologicalStoreWd> list = new ArrayList<>();  //返回结果集
         for (WdInfo wdInfo : pageInfo.getList()) {
             TopologicalStoreWd topologicalStoreWd = new TopologicalStoreWd(wdInfo);
-            topologicalStoreWd.setAddrCodeInfo(addrCodeMap.get(topologicalStoreWd.getAddrCode()));
+            topologicalStoreWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalStoreWd.getAddrCode()));
             BigDecimal bigDecimal = new BigDecimal(hashMap.get(wdInfo.getWdId()));
             topologicalStoreWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
             list.add(topologicalStoreWd);
@@ -126,7 +119,6 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
         });
 
 
-        //4.分页查找网点信息
         QueryWrapper<StoreWd> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("manage_type_code","count(*) as comment_count")
             .in("wd_id",aroundWdId)
@@ -141,21 +133,23 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
 
             String s = wdInfo.getManageTypeCode().substring(0, 4) + "00";
             StoreWdCategoryCount storeWdCategoryCount = hashMap.get(s);
+
+            ManageType initManageType = initMapUtil.getInitManageType(wdInfo.getManageTypeCode());
             if (storeWdCategoryCount == null){
                 StoreWdCategoryCountBody storeWdCategoryCountBody = new StoreWdCategoryCountBody();
-                if(manageType.get(wdInfo.getManageTypeCode()).getSubCategory() != null && manageType.get(wdInfo.getManageTypeCode()).getSubCategory().equals("")){
-                    storeWdCategoryCountBody.setName(manageType.get(wdInfo.getManageTypeCode()).getSubCategory());
-                }else if(manageType.get(wdInfo.getManageTypeCode()).getMidCategory() != null && manageType.get(wdInfo.getManageTypeCode()).getMidCategory().equals("")){
-                    storeWdCategoryCountBody.setName(manageType.get(wdInfo.getManageTypeCode()).getMidCategory());
-                }else if (manageType.get(wdInfo.getManageTypeCode()).getBigCategory() != null && manageType.get(wdInfo.getManageTypeCode()).getBigCategory().equals("")){
-                    storeWdCategoryCountBody.setName(manageType.get(wdInfo.getManageTypeCode()).getBigCategory());
+                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());
 
                 StoreWdCategoryCount storeWdCategoryCount1 = new StoreWdCategoryCount();
                 storeWdCategoryCount1.setManageTypeCode(s);
-                storeWdCategoryCount1.setName(manageType.get(s).getMidCategory());
+                storeWdCategoryCount1.setName(initMapUtil.getInitManageType(s).getMidCategory());
                 storeWdCategoryCount1.setCount(wdInfo.getCommentCount());
                 ArrayList<StoreWdCategoryCountBody> list = new ArrayList<>();
                 list.add(storeWdCategoryCountBody);
@@ -163,12 +157,12 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
                 hashMap.put(s,storeWdCategoryCount1);
             }else {
                 StoreWdCategoryCountBody storeWdCategoryCountBody = new StoreWdCategoryCountBody();
-                if(manageType.get(wdInfo.getManageTypeCode()).getSubCategory() != null && manageType.get(wdInfo.getManageTypeCode()).getSubCategory().equals("")){
-                    storeWdCategoryCountBody.setName(manageType.get(wdInfo.getManageTypeCode()).getSubCategory());
-                }else if(manageType.get(wdInfo.getManageTypeCode()).getMidCategory() != null && manageType.get(wdInfo.getManageTypeCode()).getMidCategory().equals("")){
-                    storeWdCategoryCountBody.setName(manageType.get(wdInfo.getManageTypeCode()).getMidCategory());
-                }else if (manageType.get(wdInfo.getManageTypeCode()).getBigCategory() != null && manageType.get(wdInfo.getManageTypeCode()).getBigCategory().equals("")){
-                    storeWdCategoryCountBody.setName(manageType.get(wdInfo.getManageTypeCode()).getBigCategory());
+                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());

+ 3 - 3
benyun-core/src/main/java/com/ruoyi/benyun/service/impl/WdRecycleServiceImpl.java

@@ -6,6 +6,7 @@ import com.ruoyi.benyun.service.WdRecycleService;
 import com.ruoyi.benyun.entity.WdInfo;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.ruoyi.benyun.utils.InitMapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
@@ -26,8 +27,7 @@ public class WdRecycleServiceImpl implements WdRecycleService {
 
 
     @Autowired
-    @Qualifier("addrCodeMap")
-    private HashMap<String,String> addrCodeMap;
+    InitMapUtil initMapUtil;
 
 
 
@@ -51,7 +51,7 @@ public class WdRecycleServiceImpl implements WdRecycleService {
             }
 
             WdInfoVo wdInfoVo1 = new WdInfoVo(wdInfo);
-            wdInfoVo1.setAddrCodeInfo(addrCodeMap.get(wdInfoVo1.getAddrCode()));
+            wdInfoVo1.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(wdInfoVo1.getAddrCode()));
             return wdInfoVo1;
         }).collect(Collectors.toList());
 

+ 43 - 0
benyun-core/src/main/java/com/ruoyi/benyun/utils/InitMapUtil.java

@@ -0,0 +1,43 @@
+package com.ruoyi.benyun.utils;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ruoyi.benyun.constant.RedisInitContant;
+import com.ruoyi.benyun.entity.AddrCategory;
+import com.ruoyi.benyun.entity.ManageType;
+import com.ruoyi.benyun.entity.TypeBy;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+@Component
+public class InitMapUtil {
+    @Autowired
+    RedisTemplate redisTemplate;
+
+
+    public String getInitCityTierMap(String addrCode){
+        return (String) redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_MAP).get(addrCode.substring(0,4));
+    }
+
+    public List<String> getInitCityTierListMap(String cityTier){
+        return (List<String>) redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_LIST_MAP).get(cityTier);
+    }
+
+    public ManageType getInitManageType(String manageTypeCode){
+        return (ManageType) redisTemplate.boundHashOps(RedisInitContant.INIT_MANAGE_TYPE).get(manageTypeCode);
+    }
+
+    public String getInitAddrCodeMap(String addrCode){
+        return (String) redisTemplate.boundHashOps(RedisInitContant.INIT_ADDR_CODE_MAP).get(addrCode);
+    }
+
+    public String getInitTypeByMap(String typeCodeBy){
+        return (String) redisTemplate.boundHashOps(RedisInitContant.INIT_TYPE_BY_MAP).get(typeCodeBy);
+    }
+
+}

+ 1 - 1
benyun-core/src/main/resources/application-prod.yaml

@@ -1,5 +1,5 @@
 server:
-  port: 8009
+  port: 8080
   servlet:
     context-path: /bailianAi
     encoding:

+ 1 - 0
ruoyi-demo/pom.xml

@@ -37,4 +37,5 @@
 
     </dependencies>
 
+
 </project>

+ 3 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/constant/RedisContant.java

@@ -44,6 +44,9 @@ public class RedisContant {
     public static String CHANNEL_ANALYSE_BRANDLIST = "channel_analyse_brandList";
     public static int CHANNEL_ANALYSE_BRANDLIST_TIME = 60*8;
 
+    public static String CHANNEL_ANALYSE_CATEGORY = "channel_analyse_category";
+    public static int CHANNEL_ANALYSE_CATEGORY_TIME = 60*8;
+
     public static String CHANNEL_MAP_TAG_STOREAGE = "channel_map_tag_storeage";
 
     public static int CHANNEL_MAP_TAG_STOREAGE_TIME = 60*8;

+ 12 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/constant/RedisInitContant.java

@@ -0,0 +1,12 @@
+package com.ruoyi.demo.constant;
+
+public class RedisInitContant {
+    public static String INIT_CITY_TIER_MAP = "initCityTierMap";
+    public static String INIT_CITY_TIER_LIST_MAP= "initCityTierListMap";
+
+    public static String INIT_MANAGE_TYPE = "initManageType";
+
+    public static String INIT_ADDR_CODE_MAP = "initAddrCodeMap";
+
+    public static String INIT_TYPE_BY_MAP = "initTypeByMap";
+}

+ 18 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/ChannelAnalyseController.java

@@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.demo.constant.RedisContant;
 import com.ruoyi.demo.entity.Brand;
+import com.ruoyi.demo.entity.bo.StoreWdCategoryCount;
 import com.ruoyi.demo.entity.vo.ChannelAnalyseAceeptVo;
 import com.ruoyi.demo.entity.vo.ChannelMapAceeptVo;
 import com.ruoyi.demo.entity.vo.TagAnalyse;
@@ -63,6 +64,23 @@ public class ChannelAnalyseController {
         return R.ok(brandPageInfo);
     }
 
+    @RequestMapping("/category")
+    public R category(ChannelMapAceeptVo channelMapAceeptVo){
+        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);
+        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);
+    }
+
     @RequestMapping("/tagAnalyse")
     public R tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo){
         int page = channelMapAceeptVo.getPageNum();

+ 2 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/ChannelMapController.java

@@ -88,6 +88,8 @@ public class ChannelMapController {
         return R.ok(hashMap);
     }
 
+
+
     @RequestMapping("/point")
     public R point(@Validated(value={ChannelPointGroup.class}) ChannelMapAceeptVo channel){
         String md5 = channel.getHash();

+ 51 - 102
ruoyi-demo/src/main/java/com/ruoyi/demo/init/BenyunCoreInit.java

@@ -2,6 +2,7 @@ package com.ruoyi.demo.init;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 
+import com.ruoyi.demo.constant.RedisInitContant;
 import com.ruoyi.demo.entity.AddrCategory;
 import com.ruoyi.demo.entity.ManageType;
 import com.ruoyi.demo.entity.TypeBy;
@@ -9,15 +10,14 @@ import com.ruoyi.demo.mapper.AddrCategoryDao;
 import com.ruoyi.demo.mapper.TypeByDao;
 import com.ruoyi.demo.service.ManageTypeService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.core.BoundHashOperations;
 import org.springframework.data.redis.core.RedisTemplate;
 
+import javax.annotation.PostConstruct;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.Set;
 
 @Configuration
 public class BenyunCoreInit {
@@ -33,42 +33,43 @@ public class BenyunCoreInit {
     @Autowired
     RedisTemplate redisTemplate;
 
-    @Bean("executor")
-    public ExecutorService getExecutor() {
-        return Executors.newFixedThreadPool(2);
-    }
-
     /**
-     * HashMap<地区Code,城市等级>
+     * HashMap<地区Code,城市等级>(redis版本)
      */
-    @Bean("cityTierMap")
-    public HashMap<String,String> getCityTierMap() {
-        HashMap<String, String> hashMap = new HashMap<>();
-
+    @PostConstruct
+    public void initCityTierMap(){
+        if(redisTemplate.hasKey(RedisInitContant.INIT_CITY_TIER_MAP))
+            return;
+        System.out.println("正在加载CityTierMap");
         QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
         queryWrapper.isNotNull("city_tier");
         for (AddrCategory addrCategory : addrCategoryDao.selectList(queryWrapper)) {
             if (addrCategory.getCityTier() != null && !addrCategory.getCityTier().equals("")) {
-                hashMap.put(addrCategory.getAddrCode().substring(0, 4), addrCategory.getCityTier());
+                redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_MAP).put(addrCategory.getAddrCode().substring(0, 4), addrCategory.getCityTier());
             }
         }
-        return hashMap;
+        initCityTierListMap();
+        System.out.println("CityTierMap已完成");
     }
 
+
     /**
-     * 一线城市的addrCode
+     * 一线城市的addrCode(redis)
      */
-    @Bean("cityTierListMap")
-    public HashMap<String, List<String>> cityTierListMap() {
+    public void initCityTierListMap(){
+        if(redisTemplate.hasKey(RedisInitContant.INIT_CITY_TIER_LIST_MAP))
+            return;
+        System.out.println("正在加载CityTierListMap");
         List<String> one = new ArrayList<>();
         List<String> two = new ArrayList<>();
         List<String> three = new ArrayList<>();
         List<String> four = new ArrayList<>();
         List<String> five = new ArrayList<>();
 
-        HashMap<String, String> cityTierMap = getCityTierMap();
-        for (String s : cityTierMap.keySet()) {
-            String s1 = cityTierMap.get(s);
+        BoundHashOperations boundHashOperations = redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_MAP);
+        Set<String> keys = boundHashOperations.keys();
+        for (String s : keys) {
+            String s1 = (String) boundHashOperations.get(s);
             switch (s1) {
                 case "一线":
                     one.add(s);
@@ -87,99 +88,47 @@ public class BenyunCoreInit {
                     break;
             }
         }
-        HashMap<String, List<String>> util = new HashMap<>();
-        util.put("一线", one);
-        util.put("二线", two);
-        util.put("三线", three);
-        util.put("四线", four);
-        util.put("五线", five);
-        return util;
+        redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_LIST_MAP).put("一线",one);
+        redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_LIST_MAP).put("二线",two);
+        redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_LIST_MAP).put("三线",three);
+        redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_LIST_MAP).put("四线",four);
+        redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_LIST_MAP).put("五线",five);
+        System.out.println("CityTierListMap已完成");
     }
 
-    /**
-     * HashMap<地区Code,城市等级>
-     */
-//    @PostConstruct
-//    public void initCityTierMap(){
-//        Boolean cityTierMap = redisTemplate.hasKey(RedisContant.CITY_TIER_MAP);
-//        if (!cityTierMap){
-//            HashMap<String, String> hashMap = new HashMap<>();
-//
-//            QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
-//            queryWrapper.isNotNull("city_tier");
-//            for (AddrCategory addrCategory : addrCategoryDao.selectList(queryWrapper)) {
-//                if(addrCategory.getCityTier() != null && !addrCategory.getCityTier().equals("")){
-//                    redisTemplate.boundHashOps(RedisContant.CITY_TIER_MAP).put(addrCategory.getAddrCode().substring(0,4), addrCategory.getCityTier());
-//                }
-//            }
-//            initCityTierListMap();
-//        }
-//    }
-//
-//    /**
-//     * 一线城市的addrCode
-//     * */
-//    public void initCityTierListMap(){
-//        List<String> one = new ArrayList<>();
-//        List<String> two = new ArrayList<>();
-//        List<String> three = new ArrayList<>();
-//        List<String> four = new ArrayList<>();
-//        List<String> five = new ArrayList<>();
-//
-//        HashMap<String,String> entries = (HashMap<String, String>) redisTemplate.boundHashOps(RedisContant.CITY_TIER_MAP).entries();
-//        Set<String> strings = entries.keySet();
-//        for (String s : strings) {
-//            String s1 = entries.get(s);
-//            switch (s1){
-//                case "一线":
-//                    one.add(s);
-//                    break;
-//                case "二线":
-//                    two.add(s);
-//                    break;
-//                case "三线":
-//                    three.add(s);
-//                    break;
-//                case "四线":
-//                    four.add(s);
-//                    break;
-//                case "五线":
-//                    five.add(s);
-//                    break;
-//            }
-//        }
-//        redisTemplate.boundHashOps("cityTierListMap").put("一线",one);
-//        redisTemplate.boundHashOps("cityTierListMap").put("二线",two);
-//        redisTemplate.boundHashOps("cityTierListMap").put("三线",three);
-//        redisTemplate.boundHashOps("cityTierListMap").put("四线",four);
-//        redisTemplate.boundHashOps("cityTierListMap").put("五线",five);
-//    }
-    @Bean("ManageType")
-    public HashMap getManageType() {
-        HashMap<String, ManageType> hashMap = new HashMap<>();
+    @PostConstruct
+    public void initManageType() {
+        if(redisTemplate.hasKey(RedisInitContant.INIT_MANAGE_TYPE))
+            return;
+        System.out.println("正在加载ManageType");
         for (ManageType datum : manageTypeService.getData()) {
             if (!datum.getManageTypeCode().equals(""))
-                hashMap.put(datum.getManageTypeCode(), datum);
+                redisTemplate.boundHashOps(RedisInitContant.INIT_MANAGE_TYPE).put(datum.getManageTypeCode(), datum);
         }
-        return hashMap;
+        System.out.println("ManageType已完成");
     }
 
 
-    @Bean("addrCodeMap")
-    public HashMap getAddrCodeMap() {
-        HashMap<String, String> hashMap = new HashMap<>();
+    @PostConstruct
+    public void initAddrCodeMap() {
+        if(redisTemplate.hasKey(RedisInitContant.INIT_ADDR_CODE_MAP))
+            return;
+        System.out.println("正在加载AddrCodeMap");
         for (AddrCategory addrCode : addrCategoryDao.selectList(null)) {
-            hashMap.put(addrCode.getAddrCode(), addrCode.getAddrInfo());
+            redisTemplate.boundHashOps(RedisInitContant.INIT_ADDR_CODE_MAP).put(addrCode.getAddrCode(), addrCode.getAddrInfo());
         }
-        return hashMap;
+        System.out.println("AddrCodeMap已完成");
     }
 
-    @Bean("typeByMap")
-    public HashMap getTypeByMap() {
-        HashMap<String, String> hashMap = new HashMap<>();
+
+    @PostConstruct
+    public void initTypeByMap() {
+        if(redisTemplate.hasKey(RedisInitContant.INIT_TYPE_BY_MAP))
+            return;
+        System.out.println("正在加载TypeByMap");
         for (TypeBy datum : byDao.selectList(null)) {
-            hashMap.put(datum.getTypeCodeBy(), datum.getFullInfo());
+            redisTemplate.boundHashOps(RedisInitContant.INIT_TYPE_BY_MAP).put(datum.getTypeCodeBy(), datum.getFullInfo());
         }
-        return hashMap;
+        System.out.println("TypeByMap已完成");
     }
 }

+ 4 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/service/ChannelAnalyseService.java

@@ -2,11 +2,13 @@ package com.ruoyi.demo.service;
 
 import com.github.pagehelper.PageInfo;
 import com.ruoyi.demo.entity.Brand;
+import com.ruoyi.demo.entity.bo.StoreWdCategoryCount;
 import com.ruoyi.demo.entity.vo.ChannelAnalyseAceeptVo;
 import com.ruoyi.demo.entity.vo.ChannelMapAceeptVo;
 
 
 import java.util.HashMap;
+import java.util.List;
 
 public interface ChannelAnalyseService {
     public HashMap cityTier(ChannelMapAceeptVo channelMapAceeptVo);
@@ -15,5 +17,7 @@ public interface ChannelAnalyseService {
 
     HashMap<String,Object> tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo);
 
+    List<StoreWdCategoryCount> category(ChannelMapAceeptVo channelMapAceeptVo);
+
 //    void businessAnalyse(ChannelMapAceeptVo channelMapAceeptVo);
 }

+ 0 - 380
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/AnalyseWdServiceImpl.java

@@ -1,380 +0,0 @@
-package com.ruoyi.demo.service.impl;//package com.benyun.core.service.impl;
-//
-//import com.alibaba.fastjson.JSON;
-//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-//import com.benyun.core.mapper.*;
-//import com.benyun.core.entity.*;
-//import com.benyun.core.service.AnalyseWdService;
-//import com.benyun.core.utils.DistanceUtil;
-//import org.gavaghan.geodesy.Ellipsoid;
-//import org.gavaghan.geodesy.GlobalCoordinates;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.beans.factory.annotation.Qualifier;
-//import org.springframework.stereotype.Service;
-//import org.springframework.transaction.annotation.Transactional;
-//
-//import java.time.LocalDateTime;
-//import java.util.*;
-//
-//
-//@Service
-//@Transactional
-//public class AnalyseWdServiceImpl implements AnalyseWdService {
-//
-//    //分析范围集
-//    List<Integer> anly = Arrays.asList(2000, 1000, 500);
-//
-//    @Autowired
-//    WdInfoDao wdInfoDao;
-//
-//    @Autowired
-//    StoreWdDao storeWdDao;
-//
-//    @Autowired
-//    HouseWdDao houseWdDao;
-//
-//    @Autowired
-//    BuildWdDao buildWdDao;
-//
-//    @Autowired
-//    EnterpriseWdDao enterpriseWdDao;
-//
-//    @Autowired
-//    EnterpriseDao enterpriseDao;
-//
-//    /*分析信息*/
-//    @Autowired
-//    WdTopologicalDao wdTopologicalDao;
-//
-//    @Autowired
-//    TopologicalBuildWdDao topologicalBuildWdDao;
-//
-//
-//    @Autowired
-//    TopologicalStoreWdDao topologicalStoreWdDao;
-//
-//    @Autowired
-//    TopologicalHouseWdDao topologicalHouseWdDao;
-//
-//    @Autowired
-//    TopologicalEnterpriseWdDao topologicalEnterpriseWdDao;
-//
-//    /*统计信息*/
-//    @Autowired
-//    TopologicalHouseWdStatisticsDataDao houseWdStatisticsDataDao;
-//    @Autowired
-//    TopologicalBuildWdStatisticsCategoryDao buildWdStatisticsCategoryDao;
-//    @Autowired
-//    TopologicalStoreWdStatisticsCategoryDao storeWdStatisticsCategoryDao;
-//    @Autowired
-//    WdTopologicalInfoDao wdTopologicalInfoDao;
-//
-//
-//    @Autowired
-//    @Qualifier("addrCodeMap")
-//    HashMap<String,String> addrCodeMap;
-//
-//
-//    @Override
-//    public void analyse(WdInfo wdInfo,LocalDateTime now,int size,int index) {
-//
-//            //1.找到该点半径 r = 4.89km 内的所有点
-//            QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-//            queryWrapper.likeRight("geo_hash", wdInfo.getGeoHash().substring(0, 5));
-//            List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-//
-//            //2.初始化
-//            //关键信息统计
-//            HashMap<String, HashMap<String, Integer>>[] storeCategory = new HashMap[anly.size()];  //经营分类统计:<中类,<小类,数量>>
-//            HashMap<String, Double>[] houseData = new HashMap[anly.size()];  //小区分析统计:key:totalHouseholds、totalPeopleCount、totalRent
-//            HashMap<String, Integer>[] buildCategory = new HashMap[anly.size()];   //楼宇网点分析统计,key:甲类、乙类...
-//            HashMap<String, Integer>[] wdTopologicalInfoHash = new HashMap[anly.size()];  //分类tag:key:byCode value:数量
-//            List<WdToologicalItem>[] wdToologicalItemList = new ArrayList[anly.size()];
-//
-//            for (int i = 0; i < anly.size(); i++) {
-//                storeCategory[i] = new HashMap<>();
-//                houseData[i] = new HashMap<>();
-//                houseData[i].put("houseWdCount", 0.0);
-//                houseData[i].put("totalHouseholds", 0.0);   //总户数
-//                houseData[i].put("totalPeopleCount", 0.0);  //总人口数
-//                houseData[i].put("totalRent", 0.0); //房价
-//                buildCategory[i] = new HashMap<>();
-//                wdTopologicalInfoHash[i] = new HashMap<>();
-//                wdToologicalItemList[i] = new ArrayList<>();
-//            }
-//
-//            //关键信息集合
-//            List<TopologicalStoreWdStatisticsCategory> storeWdStatisticsCategoryList = new ArrayList<>();
-//            List<TopologicalBuildWdStatisticsCategory> buildWdStatisticsCategoryList = new ArrayList<>();
-//            List<TopologicalHouseWdStatisticsData> houseWdStatisticsDataList = new ArrayList<>();
-//            List<WdTopologicalInfo> wdTopologicalInfoList = new ArrayList<>();
-//
-//            //各拓扑网点集合
-//            List<WdTopological> wdTopologicals = new ArrayList<>();
-//            System.out.println("process:" + size + "/" + index);
-//
-//            //WdTopological
-//            WdTopological wdTopological = new WdTopological();
-//            wdTopological.setCenterWdId(wdInfo.getWdId());
-//            wdTopological.setCenterWdName(wdInfo.getWdName());
-//            wdTopological.setAnalyseTime(now);
-//
-//            //3.开始分析
-//            for (WdInfo info : wdInfos) {
-//
-//                //网点等于自己不要
-//                if (info.getWdId().equals(wdInfo.getWdId()))
-//                    continue;
-//
-//                //计算距离
-//                GlobalCoordinates source = new GlobalCoordinates(wdInfo.getLat().doubleValue(), wdInfo.getLng().doubleValue());
-//                GlobalCoordinates target = new GlobalCoordinates(info.getLat().doubleValue(), info.getLng().doubleValue());
-//                double meter2 = DistanceUtil.getDistanceMeter(source, target, Ellipsoid.WGS84);
-//
-//                //大于4.89Km不要
-//                if (meter2 > anly.get(0))
-//                    continue;
-//
-//                Integer r = anly.get(anly.size() - 1);
-//                int p = anly.size() - 1; //记录r位置
-//                for (int i = 1; i < anly.size(); i++) {
-//                    if (meter2 > anly.get(i)) {
-//                        r = anly.get(i - 1);
-//                        p = i - 1;
-//                        break;
-//                    } else if (meter2 == anly.get(i)) {
-//                        r = anly.get(i);
-//                        p = i;
-//                        break;
-//                    }
-//                }
-//
-//                //3.2 组装WdTologicalItem
-//                WdToologicalItem wdToologicalItem = new WdToologicalItem();
-//                wdToologicalItem.setAroundWdId(info.getWdId());
-//                wdToologicalItem.setAroundWdName(info.getWdName());
-//                wdToologicalItem.setAddrCodeInfo(addrCodeMap.get(info.getAddrCode()));
-//                wdToologicalItem.setAddrCode(info.getAddrCode());
-//                wdToologicalItem.setAddrInfo(info.getAddrInfo());
-//                wdToologicalItem.setLat(info.getLat());
-//                wdToologicalItem.setLng(info.getLng());
-//                wdToologicalItem.setAroundWdTypeCode(info.getWdTypeCode());
-//                wdToologicalItem.setAroundTypeCodeBy(info.getTypeCodeBy());
-//                wdToologicalItem.setDistance(meter2);
-//
-//                //3.3 将WdTologicalItem放入满足半径的区域
-//                for(int i=p;i>=0;i--){
-//                    wdToologicalItemList[p].add(wdToologicalItem);
-//                }
-//
-//                //3.4 犇云标签统计
-//                if (info.getTypeCodeBy() != null && !info.getTypeCodeBy().equals("")) {
-//                    for(int i=p;i>=0;i--){
-//                        HashMap<String, Integer> wdTopologicalInfoHash1 = wdTopologicalInfoHash[i];
-//                        Integer put = wdTopologicalInfoHash1.get(info.getTypeCodeBy());
-//                        if (put == null) {
-//                            wdTopologicalInfoHash1.put(info.getTypeCodeBy(), 1);
-//                        } else {
-//                            wdTopologicalInfoHash1.put(info.getTypeCodeBy(), wdTopologicalInfoHash1.get(info.getTypeCodeBy()) + 1);
-//                        }
-//                    }
-//                }
-//
-//
-//                if (wdToologicalItem.getAroundWdTypeCode().equals("1")) {
-//                    //门店分析
-//                    StoreWd storeWd = storeWdDao.selectById(info.getWdId());
-//                    if (storeWd != null) {
-//                        String manageTypeCode = storeWd.getManageTypeCode();
-//
-//                        //TODO 分析经营分类
-//                        if (manageTypeCode != null && !manageTypeCode.equals("")) {
-//                            for(int i=p;i>=0;i--){
-//                                HashMap<String, HashMap<String, Integer>> stringHashMapHashMap = storeCategory[i];
-//                                HashMap<String, Integer> hashMap = stringHashMapHashMap.get(manageTypeCode.substring(0, 4));
-//                                if (hashMap == null) {
-//                                    HashMap<String, Integer> map = new HashMap<>();
-//                                    map.put(manageTypeCode, 1);
-//                                    stringHashMapHashMap.put(manageTypeCode.substring(0, 4),map);
-//                                } else {
-//                                    Integer integer = hashMap.get(manageTypeCode);
-//                                    if (integer == null)
-//                                        hashMap.put(manageTypeCode, 1);
-//                                    else
-//                                        hashMap.put(manageTypeCode, hashMap.get(manageTypeCode) + 1);
-//                                }
-//                            }
-//                        }
-//                    }
-//                } else if (wdToologicalItem.getAroundWdTypeCode().equals("2")) {
-//                    //小区分析
-//                    HouseWd houseWd = houseWdDao.selectById(info.getWdId());
-//                    //小区关键信息
-//                    for(int i=p;i>=0;i--){
-//                        HashMap<String, Double> houseDatum = houseData[i];
-//                        houseDatum.put("houseWdCount", houseDatum.get("houseWdCount") + 1.0);
-//
-//                        //小区关键信息统计
-//                        if (houseWd != null) {
-//                            houseDatum.put("totalRent", houseDatum.get("totalRent") + info.getRent());
-//                            houseDatum.put("totalHouseholds", houseDatum.get("totalHouseholds") + houseWd.getHouseholds());
-//                            houseDatum.put("totalPeopleCount", houseDatum.get("totalPeopleCount") + houseWd.getPeopleCount());
-//                        }
-//                    }
-//                } else if (wdToologicalItem.getAroundWdTypeCode().equals("3")) {
-//                    //楼宇分析
-//                    BuildWd buildWd = buildWdDao.selectById(info.getWdId());
-//                    if (buildWd != null) {
-//                        //分析楼宇分类
-//                        if (buildWd.getPropertyType() != null && !buildWd.getPropertyType().trim().equals("")) {
-//                            for(int i=p;i>=0;i--){
-//                                HashMap<String, Integer> buildCategoryMap = buildCategory[i];
-//                                Integer integer = buildCategoryMap.get(buildWd.getPropertyType());
-//                                if (integer == null) {
-//                                    buildCategoryMap.put(buildWd.getPropertyType(), 1);
-//                                } else
-//                                    buildCategoryMap.put(buildWd.getPropertyType(), buildCategoryMap.get(buildWd.getPropertyType()) + 1);
-//                            }
-//                        }
-//                    }
-//
-//                }
-//            }
-//
-//            //TODO 门店分类
-//            for (int i = 0; i < anly.size(); i++) {
-//                HashMap<String, HashMap<String, Integer>> stringHashMapHashMap = storeCategory[i];
-//                for (String s : stringHashMapHashMap.keySet()) {
-//                    TopologicalStoreWdStatisticsCategory storeWdStatisticsCategory = new TopologicalStoreWdStatisticsCategory();
-//                    storeWdStatisticsCategory.setCenterWdId(wdInfo.getWdId());
-//                    storeWdStatisticsCategory.setRadius(anly.get(i));
-//                    storeWdStatisticsCategory.setBigManageTypeCode(s.substring(0, 2) + "0000");
-//
-//                    HashMap<String, Integer> hashMap = stringHashMapHashMap.get(s);
-//                    StringBuilder stringBuilder = new StringBuilder();
-//                    int total = 0;
-//                    for (String s1 : hashMap.keySet()) {
-//                        total+=hashMap.get(s1);
-//
-//                        if(!s.equals(s1)){
-//                            stringBuilder.append(s1);
-//                            stringBuilder.append(":");
-//                            stringBuilder.append(hashMap.get(s1));
-//                            stringBuilder.append(";");
-//                        }else
-//                            break;
-//                    }
-//                    storeWdStatisticsCategory.setMidManageTypeCode(s+":"+total);
-//                    storeWdStatisticsCategory.setSubCategoryCodeStatistics(stringBuilder.toString());
-//                    storeWdStatisticsCategory.setAnalyseTime(now);
-//                    storeWdStatisticsCategoryList.add(storeWdStatisticsCategory);
-//                }
-//            }
-//
-//            //TODO 楼宇分类
-//            for (int i = 0; i < anly.size(); i++) {
-//                TopologicalBuildWdStatisticsCategory buildWdStatisticsCategory = new TopologicalBuildWdStatisticsCategory();
-//                buildWdStatisticsCategory.setCenterWdId(wdInfo.getWdId());
-//                buildWdStatisticsCategory.setRadius(anly.get(i));
-//
-//                HashMap<String, Integer> hashMap = buildCategory[i];
-//                StringBuilder stringBuilder = new StringBuilder();
-//                for (String s : hashMap.keySet()) {
-//                    stringBuilder.append(s + ":" + hashMap.get(s) + ";");
-//                }
-//                buildWdStatisticsCategory.setPropertyTypeStatistics(stringBuilder.toString());
-//                buildWdStatisticsCategory.setAnalyseTime(now);
-//                buildWdStatisticsCategoryList.add(buildWdStatisticsCategory);
-//            }
-//
-//            //TODO 社区关键数据
-//            for (int i = 0; i < anly.size(); i++) {
-//                TopologicalHouseWdStatisticsData houseWdStatisticsData = new TopologicalHouseWdStatisticsData();
-//                houseWdStatisticsData.setCenterWdId(wdInfo.getWdId());
-//                houseWdStatisticsData.setRadius(anly.get(i));
-//                HashMap<String, Double> houseDatum = houseData[i];
-//                double houseWdCount = houseDatum.get("houseWdCount");
-//                double totalHouseholds = houseDatum.get("totalHouseholds");
-//                double totalPeopleCount = houseDatum.get("totalPeopleCount");
-//                double totalRent = houseDatum.get("totalRent");
-//                houseWdStatisticsData.setHouseWdCount((int) houseWdCount);
-//                houseWdStatisticsData.setTotalHouseholds((int) totalHouseholds);
-//                houseWdStatisticsData.setTotalPeopleCount((int) totalPeopleCount);
-//                if(houseWdCount != 0.0)
-//                    houseWdStatisticsData.setAverageRent(totalRent / houseWdCount);
-//                else
-//                    houseWdStatisticsData.setAverageRent(0.0);
-//
-//                houseWdStatisticsData.setAnalyseTime(now);
-//                houseWdStatisticsDataList.add(houseWdStatisticsData);
-//            }
-//
-//            //TODO 网点拓扑信息
-//            for (int i = 0; i < anly.size(); i++) {
-//                WdTopologicalInfo wdTopologicalInfo = new WdTopologicalInfo();
-//                wdTopologicalInfo.setCenterWdId(wdInfo.getWdId());
-//                wdTopologicalInfo.setCenterWdName(wdInfo.getWdName());
-//                wdTopologicalInfo.setCenterWdTypeCode(wdInfo.getWdTypeCode());
-//                wdTopologicalInfo.setTypeCodeBy(wdInfo.getTypeCodeBy());
-//                wdTopologicalInfo.setLat(wdInfo.getLat());
-//                wdTopologicalInfo.setLng(wdInfo.getLng());
-//                wdTopologicalInfo.setRadius(anly.get(i));
-//                wdTopologicalInfo.setAddrCode(wdInfo.getAddrCode());
-//                wdTopologicalInfo.setAddrCodeInfo(addrCodeMap.get(wdInfo.getAddrCode()));
-//                wdTopologicalInfo.setAddrInfo(wdInfo.getAddrInfo());
-//                wdTopologicalInfo.setGeoHash(wdInfo.getGeoHash());
-//                wdTopologicalInfo.setAnalyseTime(now);
-//
-//                HashMap<String, Integer> wdTopologicalInfoHash1 = wdTopologicalInfoHash[i];
-//                StringBuilder stringBuilder = new StringBuilder();
-//                for (String s : wdTopologicalInfoHash1.keySet()) {
-//                    stringBuilder.append(s + ":" + wdTopologicalInfoHash1.get(s) + ";");
-//                }
-//                wdTopologicalInfo.setTag(stringBuilder.toString());
-//                wdTopologicalInfoList.add(wdTopologicalInfo);
-//            }
-//
-//            //TODO 网点拓扑
-//            for (int i = 0; i < anly.size(); i++) {
-//                int start = 0,end = 100;
-//                while(start < wdToologicalItemList[i].size()){
-//                    if(end >= wdToologicalItemList[i].size()){
-//                        end = wdToologicalItemList[i].size();
-//                    }
-//
-//                    WdTopological wdTopological1 = new WdTopological();
-//                    wdTopological1.setCenterWdId(wdInfo.getWdId());
-//                    wdTopological1.setCenterWdName(wdInfo.getWdName());
-//                    wdTopological1.setAnalyseTime(now);
-//                    wdTopological1.setRadius(anly.get(i));
-//                    List<WdToologicalItem> wdToologicalItemList1 = wdToologicalItemList[i].subList(start, end);
-//                    String json = JSON.toJSON(wdToologicalItemList1).toString();
-//                    wdTopological1.setAroundWdInfo(json);
-//                    wdTopologicals.add(wdTopological1);
-//
-//                    start = end;
-//                    end+=100;
-//                }
-//            }
-//
-//            System.out.println("完成------");
-//
-//
-//            //4.导入数据库
-//            if (!wdTopologicals.isEmpty())
-//                wdTopologicalDao.insertList(wdTopologicals);//保存网点拓扑
-//
-//
-//            //4.2 保存其他相关统计信息
-//            if (!storeWdStatisticsCategoryList.isEmpty())
-//                storeWdStatisticsCategoryDao.insertList(storeWdStatisticsCategoryList);
-//            if (!houseWdStatisticsDataList.isEmpty())
-//                houseWdStatisticsDataDao.insertList(houseWdStatisticsDataList);
-//            if (!buildWdStatisticsCategoryList.isEmpty())
-//                buildWdStatisticsCategoryDao.insertList(buildWdStatisticsCategoryList);
-//            if (!wdTopologicalInfoList.isEmpty())
-//                wdTopologicalInfoDao.insertList(wdTopologicalInfoList);
-//
-//        }
-//
-//}

+ 115 - 31
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/ChannelAnalyseServiceImpl.java

@@ -3,23 +3,28 @@ package com.ruoyi.demo.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-
 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.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.service.ChannelAnalyseService;
+import com.ruoyi.demo.utils.InitMapUtil;
 import com.ruoyi.demo.utils.WdRedisStoreage;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
@@ -28,8 +33,7 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
     WdInfoDao wdInfoDao;
 
     @Autowired
-    @Qualifier("cityTierMap")
-    HashMap<String, String> cityTierMap;
+    InitMapUtil initMapUtil;
 
     @Autowired
     BrandMapper brandMapper;
@@ -37,16 +41,13 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
     @Autowired
     WdTopologicalInfoDao wdTopologicalInfoDao;
 
-    @Autowired
-    @Qualifier("typeByMap")
-    private HashMap<String, String> typeByMap;
-
     @Autowired
     private WdRedisStoreage wdRedisStoreage;
 
+
     @Autowired
-    @Qualifier("cityTierListMap")
-    HashMap<String,List<String>> cityTierListMap;
+    private StoreWdDao storeWdDao;
+
 
     @Override
     public HashMap cityTier(ChannelMapAceeptVo channelMapAceeptVo) {
@@ -62,13 +63,18 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
 
 
         //1.获取所有符合条件的网点信息
-        List<WdInfo> wdInfos = getQueryWd(channelMapAceeptVo);
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("addr_code","count(wd_id) as audit");
+        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
+        queryWrapper.groupBy("addr_code");
+        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
         for (WdInfo wdInfo : wdInfos) {
-            String addrCode = wdInfo.getAddrCode().substring(0,4);
-            if (cityTierMap.containsKey(addrCode)) {
-                result.put(cityTierMap.get(addrCode), result.get(cityTierMap.get(addrCode)) + 1);
+            String initCityTierMap = initMapUtil.getInitCityTierMap(wdInfo.getAddrCode());
+            if (initCityTierMap != null) {
+                result.put(initCityTierMap, result.get(initCityTierMap) + wdInfo.getAudit());
             } else
-                result.put("其他", result.get("其他") + 1);
+                result.put("其他", result.get("其他") + wdInfo.getAudit());
         }
 
 
@@ -91,7 +97,10 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
     @Override
     public HashMap<String, Object> tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
         //1.根据条件的到位网点信息
-        List<WdInfo> queryWd = getQueryWd(channelMapAceeptVo);
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("wd_id");
+        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
+        List<WdInfo> queryWd = wdInfoDao.selectList(queryWrapper);
 
         //2.获取网点周边标签,并进行统计
         int total = 0;
@@ -148,11 +157,88 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         return result;
     }
 
+    @Override
+    public List<StoreWdCategoryCount> category(ChannelMapAceeptVo channelMapAceeptVo) {
+
+        //2.组装条件构造器找到网点信息网点
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("wd_id");
+        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
+
+        //门店
+        queryWrapper.and(queryWrapper1 -> {
+            queryWrapper1.eq("wd_type_code","1");
+        });
+        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
+
+        List<String> collect = wdInfos.stream().map(wdInfo -> {
+            return wdInfo.getWdId();
+        }).collect(Collectors.toList());
+        QueryWrapper<StoreWd> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.select("manage_type_code","count(*) as comment_count")
+            .in("wd_id",collect)
+            .groupBy("manage_type_code");
+
+        //5.查询周边网点结果,并统计
+        List<StoreWd> storeWds = storeWdDao.selectList(queryWrapper1);
+        HashMap<String,StoreWdCategoryCount> hashMap = new HashMap<>();
+        for (StoreWd wdInfo : storeWds) {
+            if(wdInfo.getManageTypeCode() == null || wdInfo.getManageTypeCode().equals(""))
+                continue;
 
-    /**
-     * 根据条件获取网点
-     * */
-    public List<WdInfo> getQueryWd(ChannelMapAceeptVo channelMapAceeptVo){
+            String s = wdInfo.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());
+
+                StoreWdCategoryCount storeWdCategoryCount1 = new StoreWdCategoryCount();
+                storeWdCategoryCount1.setManageTypeCode(s);
+                storeWdCategoryCount1.setName(initMapUtil.getInitManageType(s).getMidCategory());
+                storeWdCategoryCount1.setCount(wdInfo.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());
+
+                storeWdCategoryCount.getStoreWdCategoryCountBodyList().add(storeWdCategoryCountBody);
+                storeWdCategoryCount.setCount(storeWdCategoryCountBody.getCount()+storeWdCategoryCount.getCount());
+                //hashMap.put(s,storeWdCategoryCount);
+            }
+        }
+
+        //6.组装结果集
+        List<StoreWdCategoryCount> storeWdCategoryCounts = new ArrayList<>();
+        for (String s : hashMap.keySet()) {
+            storeWdCategoryCounts.add(hashMap.get(s));
+        }
+
+        return storeWdCategoryCounts;
+    }
+
+    public void assembleQueryWrapper(QueryWrapper<WdInfo> queryWrapper,ChannelMapAceeptVo channelMapAceeptVo){
         //1.根据不同级别得到需要查询的 地区码
         List<String> addrCodeList = new ArrayList<>();
         if ("province".equals(channelMapAceeptVo.getRankType())) {
@@ -179,13 +265,8 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
                 String substring = s.substring(0, 6);
                 addrCodeList.add(substring);
             }
-        }else
-            return new ArrayList<>();
-
+        }
 
-        //2.组装条件构造器找到网点信息网点
-        //2.1 渠道、地区分类
-        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.in("wd_type_code", channelMapAceeptVo.getChannel()).and(originWdInfoQueryWrapper -> {
             for (String s : addrCodeList) {
                 originWdInfoQueryWrapper.likeRight("addr_code", s).or();
@@ -203,20 +284,23 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         if(channelMapAceeptVo.getCityTier() != null && channelMapAceeptVo.getCityTier().length > 0){
             List<String> tierCode = new ArrayList<>();
             for (String s : channelMapAceeptVo.getCityTier()) {
-                List<String> list = cityTierListMap.get(s);
+                List<String> list = initMapUtil.getInitCityTierListMap(s);
                 if (list != null){
                     tierCode.addAll(list);
                 }
             }
-            queryWrapper.and(originWdInfoQueryWrapper -> {
+            queryWrapper.and(wdInfoQueryWrapper -> {
                 for (String s : tierCode) {
-                    originWdInfoQueryWrapper.likeRight("addr_code", s).or();
+                    wdInfoQueryWrapper.likeRight("addr_code", s).or();
                 }
             });
         }
 
+        //排序字段查询
+        if (channelMapAceeptVo.getOrderby() != null && !channelMapAceeptVo.getOrderby().trim().equals("")) {
+            PageHelper.orderBy(channelMapAceeptVo.getOrderby());
+        }
 
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-        return wdInfos;
     }
+
 }

+ 26 - 106
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/ChannelMapServiceImpl.java

@@ -9,10 +9,10 @@ import com.ruoyi.demo.entity.bo.*;
 import com.ruoyi.demo.entity.vo.ChannelMapAceeptVo;
 import com.ruoyi.demo.mapper.*;
 import com.ruoyi.demo.service.ChannelMapService;
+import com.ruoyi.demo.utils.InitMapUtil;
 import com.ruoyi.demo.utils.WdRedisStoreage;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
@@ -32,15 +32,8 @@ public class ChannelMapServiceImpl implements ChannelMapService {
     private WdInfoDao originWdInfoDao;
 
     @Autowired
-    private WdTopologicalInfoDao wdTopologicalInfoDao;
+    InitMapUtil initMapUtil;
 
-    @Autowired
-    @Qualifier("addrCodeMap")
-    private HashMap<String,String> addrCodeMap;
-
-    @Autowired
-    @Qualifier("typeByMap")
-    private HashMap<String,String> typeByMap;
 
     @Autowired
     AttentionPoolDao attentionPoolDao;
@@ -48,9 +41,6 @@ public class ChannelMapServiceImpl implements ChannelMapService {
     @Autowired
     WdInfoDao wdInfoDao;
 
-    @Autowired
-    @Qualifier("cityTierListMap")
-    HashMap<String,List<String>> cityTierListMap;
 
     @Autowired
     RedisTemplate redisTemplate;
@@ -75,7 +65,6 @@ public class ChannelMapServiceImpl implements ChannelMapService {
 
 
 
-
     @Override
     public WdCount area(ChannelMapAceeptVo channelMapAceeptVo) {
         //1.根据不同级别得到 需要封装的 地区码
@@ -169,13 +158,15 @@ public class ChannelMapServiceImpl implements ChannelMapService {
         if(channelMapAceeptVo.getCityTier() != null && channelMapAceeptVo.getCityTier().length > 0){
             List<String> tierCode = new ArrayList<>();
             for (String s : channelMapAceeptVo.getCityTier()) {
-                List<String> list = cityTierListMap.get(s);
+                List<String> list = initMapUtil.getInitCityTierListMap(s);
                 if (list != null){
                     tierCode.addAll(list);
                 }
             }
-            queryWrapper2.and(wdInfoQueryWrapper -> {
-                wdInfoQueryWrapper.in("addr_code",tierCode);
+            queryWrapper.and(wdInfoQueryWrapper -> {
+                for (String s : tierCode) {
+                    wdInfoQueryWrapper.likeRight("addr_code", s).or();
+                }
             });
         }
         queryWrapper2.groupBy("addr_code");
@@ -231,13 +222,18 @@ public class ChannelMapServiceImpl implements ChannelMapService {
     @Override
     public HashMap list(ChannelMapAceeptVo channelMapAceeptVo) {
         //1.根据条件获取网点
-        PageInfo<WdInfo> PageInfo = getQueryPageWd(channelMapAceeptVo);
+        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);
 
         //2.获取标签并组装
         List<WdTopologicalInfoBo> result = new ArrayList<>();   //返回的封装网点数据集
         for (WdInfo wdInfo : PageInfo.getList()) {
             WdTopologicalInfoBo wdTopologicalInfoBo = new WdTopologicalInfoBo(wdInfo);
-            wdTopologicalInfoBo.setAddrCodeInfo(addrCodeMap.get(wdInfo.getAddrCode()));
+            wdTopologicalInfoBo.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(wdInfo.getAddrCode()));
             List<String> tags = wdRedisStoreage.getWdTag(wdInfo);
             wdTopologicalInfoBo.setTag(tags);
             result.add(wdTopologicalInfoBo);
@@ -288,7 +284,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
             StoreWdInfoBo storeWdInfoBo = new StoreWdInfoBo(wdInfo);
             storeWdInfoBo.setStoreWd(storeWd);
             storeWdInfoBo.setTags(wdRedisStoreage.getWdTag(wdInfo));
-            storeWdInfoBo.setAddrCode(addrCodeMap.get(storeWdInfoBo.getAddrCode()));
+            storeWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(storeWdInfoBo.getAddrCode()));
             return storeWdInfoBo;
         }else if("2".equals(wdInfo.getWdTypeCode())){
             QueryWrapper<HouseWd> queryWrapper1 = new QueryWrapper<>();
@@ -297,7 +293,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
             HouseWdInfoBo houseWdInfoBo = new HouseWdInfoBo(wdInfo);
             houseWdInfoBo.setHouseWd(houseWd);
             houseWdInfoBo.setTags(wdRedisStoreage.getWdTag(wdInfo));
-            houseWdInfoBo.setAddrCode(addrCodeMap.get(houseWdInfoBo.getAddrCode()));
+            houseWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(houseWdInfoBo.getAddrCode()));
             return houseWdInfoBo;
         }else if("3".equals(wdInfo.getWdTypeCode())){
             QueryWrapper<BuildWd> queryWrapper1 = new QueryWrapper<>();
@@ -306,7 +302,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
             BuildWdInfoBo buildWdInfoBo = new BuildWdInfoBo(wdInfo);
             buildWdInfoBo.setBuildWd(buildWd);
             buildWdInfoBo.setTags(wdRedisStoreage.getWdTag(wdInfo));
-            buildWdInfoBo.setAddrCode(addrCodeMap.get(buildWdInfoBo.getAddrCode()));
+            buildWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(buildWdInfoBo.getAddrCode()));
             return buildWdInfoBo;
         }else if("4".equals(wdInfo.getWdTypeCode())){
             QueryWrapper<TrafficWd> queryWrapper1 = new QueryWrapper<>();
@@ -315,7 +311,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
             TrafficWdInfoBo trafficWdInfoBo = new TrafficWdInfoBo(wdInfo);
             trafficWdInfoBo.setTrafficWd(trafficWd);
             trafficWdInfoBo.setTags(wdRedisStoreage.getWdTag(wdInfo));
-            trafficWdInfoBo.setAddrCode(addrCodeMap.get(trafficWdInfoBo.getAddrCode()));
+            trafficWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(trafficWdInfoBo.getAddrCode()));
             return trafficWdInfoBo;
         }else if("5".equals(wdInfo.getWdTypeCode())){
             QueryWrapper<EnterpriseWd> queryWrapper1 = new QueryWrapper<>();
@@ -324,17 +320,14 @@ public class ChannelMapServiceImpl implements ChannelMapService {
             EnterpriseWdInfoBo enterpriseWdInfoBo = new EnterpriseWdInfoBo(wdInfo);
             enterpriseWdInfoBo.setEnterpriseWd(enterpriseWd);
             enterpriseWdInfoBo.setTags(wdRedisStoreage.getWdTag(wdInfo));
-            enterpriseWdInfoBo.setAddrCode(addrCodeMap.get(enterpriseWdInfoBo.getAddrCode()));
+            enterpriseWdInfoBo.setAddrCode(initMapUtil.getInitAddrCodeMap(enterpriseWdInfoBo.getAddrCode()));
             return enterpriseWdInfoBo;
         }
 
         return wdInfo;
     }
 
-    /**
-     * 根据条件获取网点(分页)
-     * */
-    public PageInfo<WdInfo> getQueryPageWd(ChannelMapAceeptVo channelMapAceeptVo){
+    public void assembleQueryWrapper(QueryWrapper<WdInfo> queryWrapper,ChannelMapAceeptVo channelMapAceeptVo){
         //1.根据不同级别得到需要查询的 地区码
         List<String> addrCodeList = new ArrayList<>();
         if ("province".equals(channelMapAceeptVo.getRankType())) {
@@ -361,13 +354,8 @@ public class ChannelMapServiceImpl implements ChannelMapService {
                 String substring = s.substring(0, 6);
                 addrCodeList.add(substring);
             }
-        }else
-            return null;
-
+        }
 
-        //2.组装条件构造器找到网点信息网点
-        //2.1 渠道、地区分类
-        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.in("wd_type_code", channelMapAceeptVo.getChannel()).and(originWdInfoQueryWrapper -> {
             for (String s : addrCodeList) {
                 originWdInfoQueryWrapper.likeRight("addr_code", s).or();
@@ -385,13 +373,15 @@ public class ChannelMapServiceImpl implements ChannelMapService {
         if(channelMapAceeptVo.getCityTier() != null && channelMapAceeptVo.getCityTier().length > 0){
             List<String> tierCode = new ArrayList<>();
             for (String s : channelMapAceeptVo.getCityTier()) {
-                List<String> list = cityTierListMap.get(s);
+                List<String> list = initMapUtil.getInitCityTierListMap(s);
                 if (list != null){
                     tierCode.addAll(list);
                 }
             }
             queryWrapper.and(wdInfoQueryWrapper -> {
-                wdInfoQueryWrapper.in("addr_code",tierCode);
+                for (String s : tierCode) {
+                    wdInfoQueryWrapper.likeRight("addr_code", s).or();
+                }
             });
         }
 
@@ -399,78 +389,8 @@ public class ChannelMapServiceImpl implements ChannelMapService {
         if (channelMapAceeptVo.getOrderby() != null && !channelMapAceeptVo.getOrderby().trim().equals("")) {
             PageHelper.orderBy(channelMapAceeptVo.getOrderby());
         }
-        PageHelper.startPage(channelMapAceeptVo.getPageNum(), channelMapAceeptVo.getPageSize());
-        List<WdInfo> originWdInfos = wdInfoDao.selectList(queryWrapper);
-        PageInfo<WdInfo> PageInfo = new PageInfo<>(originWdInfos);
-        return PageInfo;
-    }
-
-    /**
-     * 根据条件获取网点
-     * */
-    public List<WdInfo> getQueryWd(ChannelMapAceeptVo channelMapAceeptVo){
-        //1.根据不同级别得到需要查询的 地区码
-        List<String> addrCodeList = new ArrayList<>();
-        if ("province".equals(channelMapAceeptVo.getRankType())) {
-            //省码
-            for (String s : channelMapAceeptVo.getAddrCode()) {
-                String substring = s.substring(0, 2);
-                addrCodeList.add(substring);
-            }
-        } else if ("city".equals(channelMapAceeptVo.getRankType())) {
-            //省的所有市
-            for (String s : channelMapAceeptVo.getAddrCode()) {
-                String substring = s.substring(0, 2);
-                addrCodeList.add(substring);
-            }
-        } else if ("zone".equals(channelMapAceeptVo.getRankType())) {
-            //市的所有区
-            for (String s : channelMapAceeptVo.getAddrCode()) {
-                String substring = s.substring(0, 4);
-                addrCodeList.add(substring);
-            }
-        } else if ("district".equals(channelMapAceeptVo.getRankType())){
-            //区的所有街道
-            for (String s : channelMapAceeptVo.getAddrCode()) {
-                String substring = s.substring(0, 6);
-                addrCodeList.add(substring);
-            }
-        }else
-            return null;
-
-
-        //2.组装条件构造器找到网点信息网点
-        //2.1 渠道、地区分类
-        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-        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 = cityTierListMap.get(s);
-                if (list != null){
-                    tierCode.addAll(list);
-                }
-            }
-            queryWrapper.and(wdInfoQueryWrapper -> {
-                wdInfoQueryWrapper.in("addr_code",tierCode);
-            });
-        }
+    }
 
 
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-        return wdInfos;
-    }
 }

+ 14 - 12
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalBuildWdSereviceImpl.java

@@ -11,8 +11,8 @@ import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 import com.ruoyi.demo.mapper.BuildWdDao;
 import com.ruoyi.demo.mapper.WdInfoDao;
 import com.ruoyi.demo.service.TopologicalBuildWdSerevice;
+import com.ruoyi.demo.utils.InitMapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.geo.Circle;
 import org.springframework.data.geo.Distance;
 import org.springframework.data.geo.GeoResults;
@@ -35,8 +35,7 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
     WdInfoDao wdInfoDao;
 
     @Autowired
-    @Qualifier("addrCodeMap")
-    HashMap<String,String> addrCodeMap;
+    InitMapUtil initMapUtil;
 
     @Autowired
     RedisTemplate redisTemplate;
@@ -65,13 +64,14 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
             //记录网点坐标及距离
             aroundWdId.add((String) item.getContent().getName());
         });
-
+        if (aroundWdId.isEmpty())
+            return new ArrayList<>();
 
         //4.分页查找网点信息
         QueryWrapper<BuildWd> queryWrapper = new QueryWrapper<>();
-        queryWrapper.select("property_type","count(*) as people_count")
-            .in("wd_id",aroundWdId)
-            .groupBy("property_type");
+        queryWrapper.select("property_type","count(*) as people_count");
+        queryWrapper.in("wd_id",aroundWdId);
+        queryWrapper.groupBy("property_type");
 
         List<BuildWdCategoryCount> list = new ArrayList<>();
         List<BuildWd> buildWds = buildWdDao.selectList(queryWrapper);
@@ -113,14 +113,16 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
             aroundWdId.add((String) item.getContent().getName());
             hashMap.put((String) item.getContent().getName(), item.getDistance().getValue());
         });
-
+        if (aroundWdId.isEmpty())
+            return new ArrayList<>();
 
         //4.分页查找网点信息
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("wd_type_code","3")
-            .and(wdInfoQueryWrapper -> {
+        queryWrapper.eq("wd_type_code","3");
+        queryWrapper.and(wdInfoQueryWrapper -> {
                 wdInfoQueryWrapper.in("wd_id", aroundWdId);
-            });
+        });
+
 
         //5.查询周边网点结果
         PageHelper.startPage(1, topologicalWdAceeptVo.getSize());
@@ -132,7 +134,7 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
         List<TopologicalBuildingWd> list = new ArrayList<>();  //返回结果集
         for (WdInfo wdInfo : pageInfo.getList()) {
             TopologicalBuildingWd topologicalBuildingWd = new TopologicalBuildingWd(wdInfo);
-            topologicalBuildingWd.setAddrCodeInfo(addrCodeMap.get(topologicalBuildingWd.getAddrCode()));
+            topologicalBuildingWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalBuildingWd.getAddrCode()));
             BigDecimal bigDecimal = new BigDecimal(hashMap.get(wdInfo.getWdId()));
             topologicalBuildingWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
             list.add(topologicalBuildingWd);

+ 3 - 5
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalCommonServiceImpl.java

@@ -7,8 +7,8 @@ import com.ruoyi.demo.entity.WdInfo;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 import com.ruoyi.demo.mapper.WdInfoDao;
 import com.ruoyi.demo.service.TopologicalCommonService;
+import com.ruoyi.demo.utils.InitMapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.geo.Circle;
 import org.springframework.data.geo.Distance;
 import org.springframework.data.geo.GeoResults;
@@ -19,7 +19,6 @@ import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
 
 @Service
@@ -28,8 +27,7 @@ public class TopologicalCommonServiceImpl implements TopologicalCommonService {
     WdInfoDao wdInfoDao;
 
     @Autowired
-    @Qualifier("addrCodeMap")
-    HashMap<String,String> addrCodeMap;
+    InitMapUtil initMapUtil;
 
     @Autowired
     RedisTemplate redisTemplate;
@@ -110,7 +108,7 @@ public class TopologicalCommonServiceImpl implements TopologicalCommonService {
         //查询结果
         List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
         for (WdInfo wdInfo : wdInfos) {
-            wdInfo.setAddrCode(addrCodeMap.get(wdInfo.getAddrCode()));
+            wdInfo.setAddrCode(initMapUtil.getInitAddrCodeMap(wdInfo.getAddrCode()));
         }
 
         return wdInfos;

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

@@ -8,8 +8,8 @@ import com.ruoyi.demo.entity.WdInfo;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 import com.ruoyi.demo.mapper.WdInfoDao;
 import com.ruoyi.demo.service.TopologicalEnterpriseWdService;
+import com.ruoyi.demo.utils.InitMapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.geo.Circle;
 import org.springframework.data.geo.Distance;
 import org.springframework.data.geo.GeoResults;
@@ -30,8 +30,7 @@ public class TopologicalEnterpriseWdServiceImpl implements TopologicalEnterprise
     WdInfoDao wdInfoDao;
 
     @Autowired
-    @Qualifier("addrCodeMap")
-    HashMap<String,String> addrCodeMap;
+    InitMapUtil initMapUtil;
 
     @Autowired
     RedisTemplate redisTemplate;
@@ -39,8 +38,7 @@ public class TopologicalEnterpriseWdServiceImpl implements TopologicalEnterprise
     @Override
     public List<TopologicalEnterpriseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
         //1.根据中心网点Id找到网点详细信息
-        QueryWrapper<WdInfo> queryWrapper1;
-        queryWrapper1 = new QueryWrapper<>();
+        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
         queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
         WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
 
@@ -62,14 +60,16 @@ public class TopologicalEnterpriseWdServiceImpl implements TopologicalEnterprise
             aroundWdId.add((String) item.getContent().getName());
             hashMap.put((String) item.getContent().getName(), item.getDistance().getValue());
         });
-
+        if (aroundWdId.isEmpty())
+            return new ArrayList<>();
 
         //4.分页查找网点信息
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("wd_type_code","5")
-            .and(wdInfoQueryWrapper -> {
-                wdInfoQueryWrapper.in("wd_id", aroundWdId);
-            });
+        queryWrapper.eq("wd_type_code","5");
+        queryWrapper.and(wdInfoQueryWrapper -> {
+            wdInfoQueryWrapper.in("wd_id", aroundWdId);
+        });
+
 
         //5.查询周边网点结果
         PageHelper.startPage(1, topologicalWdAceeptVo.getSize());
@@ -81,7 +81,7 @@ public class TopologicalEnterpriseWdServiceImpl implements TopologicalEnterprise
         List<TopologicalEnterpriseWd> list = new ArrayList<>();  //返回结果集
         for (WdInfo wdInfo : pageInfo.getList()) {
             TopologicalEnterpriseWd topologicalEnterpriseWd = new TopologicalEnterpriseWd(wdInfo);
-            topologicalEnterpriseWd.setAddrCodeInfo(addrCodeMap.get(topologicalEnterpriseWd.getAddrCode()));
+            topologicalEnterpriseWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalEnterpriseWd.getAddrCode()));
             BigDecimal bigDecimal = new BigDecimal(hashMap.get(wdInfo.getWdId()));
             topologicalEnterpriseWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
             list.add(topologicalEnterpriseWd);

+ 23 - 20
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalHouseServiceWdImpl.java

@@ -10,8 +10,8 @@ import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 import com.ruoyi.demo.mapper.HouseWdDao;
 import com.ruoyi.demo.mapper.WdInfoDao;
 import com.ruoyi.demo.service.TopologicalHouseWdService;
+import com.ruoyi.demo.utils.InitMapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.geo.Circle;
 import org.springframework.data.geo.Distance;
 import org.springframework.data.geo.GeoResults;
@@ -33,8 +33,7 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
     WdInfoDao wdInfoDao;
 
     @Autowired
-    @Qualifier("addrCodeMap")
-    HashMap<String,String> addrCodeMap;
+    InitMapUtil initMapUtil;
 
     @Autowired
     RedisTemplate redisTemplate;
@@ -46,35 +45,39 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
     public List<TopologicalHouseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
         //1.根据中心网点Id找到网点详细信息
         QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
+        queryWrapper1.eq("wd_id", topologicalWdAceeptVo.getCenterWdId());
         WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
 
         //2.根据中心网点找到周边网点Id
         // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
+        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);
+        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle, geoRadiusCommandArgs);
         //周边网点Id
         List<String> aroundWdId = new ArrayList<>();
-        HashMap<String,Double> hashMap = new HashMap<>();
+        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<>();
 
         //4.分页查找网点信息
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("wd_type_code","2")
-            .and(wdInfoQueryWrapper -> {
+        queryWrapper.eq("wd_type_code", "2");
+        if (!aroundWdId.isEmpty()) {
+            queryWrapper.and(wdInfoQueryWrapper -> {
                 wdInfoQueryWrapper.in("wd_id", aroundWdId);
             });
+        }
+
 
         //5.查询周边网点结果
         PageHelper.startPage(1, topologicalWdAceeptVo.getSize());
@@ -86,9 +89,9 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
         List<TopologicalHouseWd> list = new ArrayList<>();  //返回结果集
         for (WdInfo wdInfo : pageInfo.getList()) {
             TopologicalHouseWd topologicalHouseWd = new TopologicalHouseWd(wdInfo);
-            topologicalHouseWd.setAddrCodeInfo(addrCodeMap.get(topologicalHouseWd.getAddrCode()));
+            topologicalHouseWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalHouseWd.getAddrCode()));
             BigDecimal bigDecimal = new BigDecimal(hashMap.get(wdInfo.getWdId()));
-            topologicalHouseWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
+            topologicalHouseWd.setDistance(bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
             list.add(topologicalHouseWd);
         }
 
@@ -99,12 +102,12 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
     public TopologicalHouseWdStatisticsData info(TopologicalWdAceeptVo topologicalWdAceeptVo) {
         //1.根据中心网点Id找到网点详细信息
         QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
+        queryWrapper1.eq("wd_id", topologicalWdAceeptVo.getCenterWdId());
         WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
 
         //2.根据中心网点找到周边网点Id
         // 以经纬度为中心,获取半径不超过最大距离的所有元素
-        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
+        Point point = new Point(wdInfo1.getLng().doubleValue(), wdInfo1.getLat().doubleValue());
         //半径范围
         Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
         //圆
@@ -116,21 +119,21 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
             //记录网点坐标及距离
             aroundWdId.add((String) item.getContent().getName());
         });
-
-
+        if (aroundWdId.isEmpty())
+            return null;
 
         //4.分页查找网点信息
         TopologicalHouseWdStatisticsData result = new TopologicalHouseWdStatisticsData();
         int total = 0;
         List<TopologicalHouseWdStatisticsData> houseWdStatisticsData = houseWdDao.selectAndStatistics(aroundWdId);
         for (TopologicalHouseWdStatisticsData houseWdStatisticsDatum : houseWdStatisticsData) {
-            result.setTotalPeopleCount(houseWdStatisticsDatum.getTotalPeopleCount()+result.getTotalPeopleCount());
-            result.setTotalHouseholds(houseWdStatisticsDatum.getTotalHouseholds()+result.getTotalHouseholds());
-            result.setAverageRent(houseWdStatisticsDatum.getAverageRent()+result.getAverageRent());
+            result.setTotalPeopleCount(houseWdStatisticsDatum.getTotalPeopleCount() + result.getTotalPeopleCount());
+            result.setTotalHouseholds(houseWdStatisticsDatum.getTotalHouseholds() + result.getTotalHouseholds());
+            result.setAverageRent(houseWdStatisticsDatum.getAverageRent() + result.getAverageRent());
             total++;
         }
         result.setHouseWdCount(total);
-        result.setAverageRent(result.getAverageRent()/total);
+        result.setAverageRent(result.getAverageRent() / total);
 
         return result;
     }

+ 28 - 27
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalStoreWdServiceImpl.java

@@ -13,8 +13,8 @@ import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 import com.ruoyi.demo.mapper.StoreWdDao;
 import com.ruoyi.demo.mapper.WdInfoDao;
 import com.ruoyi.demo.service.TopologicalStoreWdService;
+import com.ruoyi.demo.utils.InitMapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.geo.Circle;
 import org.springframework.data.geo.Distance;
 import org.springframework.data.geo.GeoResults;
@@ -31,8 +31,6 @@ import java.util.List;
 @Service
 public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService {
 
-
-
     @Autowired
     WdInfoDao wdInfoDao;
 
@@ -40,12 +38,7 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
     StoreWdDao storeWdDao;
 
     @Autowired
-    @Qualifier("ManageType")
-    HashMap<String, ManageType> manageType;
-
-    @Autowired
-    @Qualifier("addrCodeMap")
-    HashMap<String,String> addrCodeMap;
+    InitMapUtil initMapUtil;
 
     @Autowired
     RedisTemplate redisTemplate;
@@ -77,14 +70,19 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
             hashMap.put((String) item.getContent().getName(), item.getDistance().getValue());
         });
 
+        if (aroundWdId.isEmpty()){
+            return new ArrayList<>();
+        }
+
 
         //4.分页查找网点信息
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("wd_type_code","1")
-            .and(wdInfoQueryWrapper -> {
-                wdInfoQueryWrapper.in("wd_id", aroundWdId);
+        queryWrapper.eq("wd_type_code","1");
+        queryWrapper.and(wdInfoQueryWrapper -> {
+            wdInfoQueryWrapper.in("wd_id", aroundWdId);
         });
 
+
         //5.查询周边网点结果
         PageHelper.startPage(1, topologicalWdAceeptVo.getSize());
         List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
@@ -95,7 +93,7 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
         List<TopologicalStoreWd> list = new ArrayList<>();  //返回结果集
         for (WdInfo wdInfo : pageInfo.getList()) {
             TopologicalStoreWd topologicalStoreWd = new TopologicalStoreWd(wdInfo);
-            topologicalStoreWd.setAddrCodeInfo(addrCodeMap.get(topologicalStoreWd.getAddrCode()));
+            topologicalStoreWd.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(topologicalStoreWd.getAddrCode()));
             BigDecimal bigDecimal = new BigDecimal(hashMap.get(wdInfo.getWdId()));
             topologicalStoreWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
             list.add(topologicalStoreWd);
@@ -127,8 +125,9 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
             aroundWdId.add((String) item.getContent().getName());
         });
 
+        if (aroundWdId.isEmpty())
+            return new ArrayList<>();
 
-        //4.分页查找网点信息
         QueryWrapper<StoreWd> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("manage_type_code","count(*) as comment_count")
             .in("wd_id",aroundWdId)
@@ -143,21 +142,23 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
 
             String s = wdInfo.getManageTypeCode().substring(0, 4) + "00";
             StoreWdCategoryCount storeWdCategoryCount = hashMap.get(s);
+
+            ManageType initManageType = initMapUtil.getInitManageType(wdInfo.getManageTypeCode());
             if (storeWdCategoryCount == null){
                 StoreWdCategoryCountBody storeWdCategoryCountBody = new StoreWdCategoryCountBody();
-                if(manageType.get(wdInfo.getManageTypeCode()).getSubCategory() != null && manageType.get(wdInfo.getManageTypeCode()).getSubCategory().equals("")){
-                    storeWdCategoryCountBody.setName(manageType.get(wdInfo.getManageTypeCode()).getSubCategory());
-                }else if(manageType.get(wdInfo.getManageTypeCode()).getMidCategory() != null && manageType.get(wdInfo.getManageTypeCode()).getMidCategory().equals("")){
-                    storeWdCategoryCountBody.setName(manageType.get(wdInfo.getManageTypeCode()).getMidCategory());
-                }else if (manageType.get(wdInfo.getManageTypeCode()).getBigCategory() != null && manageType.get(wdInfo.getManageTypeCode()).getBigCategory().equals("")){
-                    storeWdCategoryCountBody.setName(manageType.get(wdInfo.getManageTypeCode()).getBigCategory());
+                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());
 
                 StoreWdCategoryCount storeWdCategoryCount1 = new StoreWdCategoryCount();
                 storeWdCategoryCount1.setManageTypeCode(s);
-                storeWdCategoryCount1.setName(manageType.get(s).getMidCategory());
+                storeWdCategoryCount1.setName(initMapUtil.getInitManageType(s).getMidCategory());
                 storeWdCategoryCount1.setCount(wdInfo.getCommentCount());
                 ArrayList<StoreWdCategoryCountBody> list = new ArrayList<>();
                 list.add(storeWdCategoryCountBody);
@@ -165,12 +166,12 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
                 hashMap.put(s,storeWdCategoryCount1);
             }else {
                 StoreWdCategoryCountBody storeWdCategoryCountBody = new StoreWdCategoryCountBody();
-                if(manageType.get(wdInfo.getManageTypeCode()).getSubCategory() != null && manageType.get(wdInfo.getManageTypeCode()).getSubCategory().equals("")){
-                    storeWdCategoryCountBody.setName(manageType.get(wdInfo.getManageTypeCode()).getSubCategory());
-                }else if(manageType.get(wdInfo.getManageTypeCode()).getMidCategory() != null && manageType.get(wdInfo.getManageTypeCode()).getMidCategory().equals("")){
-                    storeWdCategoryCountBody.setName(manageType.get(wdInfo.getManageTypeCode()).getMidCategory());
-                }else if (manageType.get(wdInfo.getManageTypeCode()).getBigCategory() != null && manageType.get(wdInfo.getManageTypeCode()).getBigCategory().equals("")){
-                    storeWdCategoryCountBody.setName(manageType.get(wdInfo.getManageTypeCode()).getBigCategory());
+                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());

+ 3 - 3
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/WdRecycleServiceImpl.java

@@ -6,6 +6,7 @@ import com.ruoyi.demo.entity.WdInfo;
 import com.ruoyi.demo.entity.vo.WdInfoVo;
 import com.ruoyi.demo.mapper.WdInfoMapper;
 import com.ruoyi.demo.service.WdRecycleService;
+import com.ruoyi.demo.utils.InitMapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
@@ -26,8 +27,7 @@ public class WdRecycleServiceImpl implements WdRecycleService {
 
 
     @Autowired
-    @Qualifier("addrCodeMap")
-    private HashMap<String,String> addrCodeMap;
+    InitMapUtil initMapUtil;
 
 
 
@@ -51,7 +51,7 @@ public class WdRecycleServiceImpl implements WdRecycleService {
             }
 
             WdInfoVo wdInfoVo1 = new WdInfoVo(wdInfo);
-            wdInfoVo1.setAddrCodeInfo(addrCodeMap.get(wdInfoVo1.getAddrCode()));
+            wdInfoVo1.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(wdInfoVo1.getAddrCode()));
             return wdInfoVo1;
         }).collect(Collectors.toList());
 

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

@@ -0,0 +1,38 @@
+package com.ruoyi.demo.utils;
+
+
+import com.ruoyi.demo.constant.RedisInitContant;
+import com.ruoyi.demo.entity.ManageType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public class InitMapUtil {
+    @Autowired
+    RedisTemplate redisTemplate;
+
+
+    public String getInitCityTierMap(String addrCode){
+        return (String) redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_MAP).get(addrCode.substring(0,4));
+    }
+
+    public List<String> getInitCityTierListMap(String cityTier){
+        return (List<String>) redisTemplate.boundHashOps(RedisInitContant.INIT_CITY_TIER_LIST_MAP).get(cityTier);
+    }
+
+    public ManageType getInitManageType(String manageTypeCode){
+        return (ManageType) redisTemplate.boundHashOps(RedisInitContant.INIT_MANAGE_TYPE).get(manageTypeCode);
+    }
+
+    public String getInitAddrCodeMap(String addrCode){
+        return (String) redisTemplate.boundHashOps(RedisInitContant.INIT_ADDR_CODE_MAP).get(addrCode);
+    }
+
+    public String getInitTypeByMap(String typeCodeBy){
+        return (String) redisTemplate.boundHashOps(RedisInitContant.INIT_TYPE_BY_MAP).get(typeCodeBy);
+    }
+
+}

+ 204 - 208
ruoyi-demo/src/main/java/com/ruoyi/demo/utils/WdRedisStoreage.java

@@ -33,10 +33,6 @@ public class WdRedisStoreage {
     @Autowired
     public WdInfoDao wdInfoDao;
 
-    @Autowired
-    @Qualifier("executor")
-    private ExecutorService executorService;
-
 
     @Autowired
     WriteService writeService;
@@ -52,210 +48,210 @@ public class WdRedisStoreage {
         return tag;
     }
 
-    /***
-     * 分析网点周边标签,并把分析结果存入redis(默认范围:1km)
-     * @param wdInfo 中心网点信息
-     * @return
-     */
-    public  List<String> wdTagAnalyse(WdInfo wdInfo){
-        //1. 找到距离中心网点半径1km的所有网点Id
-        Distance distance = new Distance(1, RedisGeoCommands.DistanceUnit.KILOMETERS);
-        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo.getAddrCode().substring(0, 4)).radius(wdInfo.getWdId(), distance);
-        List<GeoResult<RedisGeoCommands.GeoLocation<Object>>> content = radius.getContent();
-        List<String> aroundWdId = content.stream().map(item -> {
-            String name = (String) item.getContent().getName();
-            return name;
-        }).collect(Collectors.toList());
-
-        //2. 查询周边网点标签的Set集
-        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.select("type_name_by")
-                .in("wd_id",aroundWdId)
-                    .groupBy("type_name_by");
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-
-        //3. 打标签
-        List<String> tag = new ArrayList<>();
-        wdInfos.stream().forEach(item -> {
-            if(item != null){
-                String typeNameBy = item.getTypeNameBy();
-                if(typeNameBy != null && !typeNameBy.equals("")){
-                    String[] split = typeNameBy.split(":");
-                    if (split.length > 0)
-                        tag.add(split[split.length-1]);
-                }
-            }
-        });
-        redisTemplate.boundValueOps(RedisContant.WD_TAG+"_"+wdInfo.getWdId()).set(tag);
-        return tag;
-    }
-
-    /**
-     * 将网点数据库 导入 redis
-     * */
-    public void writeWdGeoRedis(){
-        //清重
-        clearSql2();
-        try {
-            Thread.sleep(1000*60*10);
-        } catch (InterruptedException e) {
-            throw new RuntimeException(e);
-        }
-
-        //将所有网点坐标导入redis
-        writeWdGeoRedis1();
-
-        try {
-            Thread.sleep(1000*60*10);
-        } catch (InterruptedException e) {
-            throw new RuntimeException(e);
-        }
-        //给网点打标签并存入redis中
-        writeWdGeoRedis2();
-    }
-
-    public void clearSql2(){
-        List<String> wdId = new ArrayList<>();
-        List<String> storeId = new ArrayList<>();
-        List<String> houseId = new ArrayList<>();
-        List<String> buildId = new ArrayList<>();
-        List<String> trafficId = new ArrayList<>();
-        List<String> enterpriseId = new ArrayList<>();
-        long start = System.currentTimeMillis();
-
-        try{
-            System.out.println("开始清理");
-
-            QueryWrapper<WdInfo> wdInfoOriginQueryWrapper = new QueryWrapper<>();
-            wdInfoOriginQueryWrapper.select("hash", "count(hash) as audit").groupBy("hash").having("count(hash) >= 2");
-            List<WdInfo> wdInfoOrigins = wdInfoDao.selectList(wdInfoOriginQueryWrapper);
-
-            HashMap<String, Integer> hashMap = new HashMap<>();
-            for (WdInfo wdInfo : wdInfoOrigins) {
-                hashMap.put(wdInfo.getHash(), wdInfo.getAudit());
-            }
-
-
-            HashMap<String,Integer> hashMap1 = new HashMap<>();
-            hashMap1.put("total",1);
-            CompletableFuture<Void> future = null;
-            for (String s : hashMap.keySet()) {
-                future = CompletableFuture.runAsync(()->{
-                    synchronized (this){
-                        if(hashMap1.get("total")%1000 == 0){
-                            writeService.clearSql2(wdId,storeId,houseId,buildId,trafficId,enterpriseId);
-                            wdId.clear();
-                            storeId.clear();
-                            houseId.clear();
-                            buildId.clear();
-                            trafficId.clear();
-                            enterpriseId.clear();
-                        }
-                    }
-
-                    QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-                    queryWrapper.eq("hash",s);
-                    queryWrapper.orderByDesc("collect_time");
-                    queryWrapper.last("limit " + (hashMap.get(s) - 1));
-                    List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-                    for (WdInfo wdInfo : wdInfos) {
-                        wdId.add(wdInfo.getWdId());
-
-                        switch (wdInfo.getWdTypeCode()){
-                            case "1":
-                                storeId.add(wdInfo.getWdId());
-                                break;
-                            case "2":
-                                houseId.add(wdInfo.getWdId());
-                                break;
-                            case "3":
-                                buildId.add(wdInfo.getWdId());
-                                break;
-                            case "4":
-                                trafficId.add(wdInfo.getWdId());
-                                break;
-                            case "5":
-                                enterpriseId.add(wdInfo.getWdId());
-                                break;
-                            default:
-                                break;
-                        }
-                    }
-                    System.out.println("进度:"+wdInfoOrigins.size()+"/"+hashMap1.get("total"));
-                    hashMap1.put("total",hashMap1.get("total")+1);
-                },executorService);
-            }
-            future.get();
-        }catch (Exception e){
-            e.printStackTrace();
-        }finally {
-            //删除
-            writeService.clearSql2(wdId,storeId,houseId,buildId,trafficId,enterpriseId);
-            long end = System.currentTimeMillis();
-            System.out.println("完成清理 "+(end-start)/(1000*60));
-        }
-
-
-    }
-
-    private void writeWdGeoRedis1(){
-        //1.将网点坐标存入redis中
-        long start = System.currentTimeMillis();
-        System.out.println("开始将网点坐标存入redis");
-        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.likeRight("collect_time","2023-09-");
-
-        HashMap<String,Integer> hashMap = new HashMap<>();
-        hashMap.put("total",1);
-        CompletableFuture<Void> future = null;
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-        for (WdInfo wdInfo : wdInfos) {
-            //开启线程
-            future = CompletableFuture.runAsync(()->{
-                redisTemplate.boundGeoOps(wdInfo.getAddrCode().substring(0,4)).add(new Point(wdInfo.getLng().doubleValue(),wdInfo.getLat().doubleValue()),wdInfo.getWdId());
-                 System.out.println("进度:"+wdInfos.size()+"/"+hashMap.get("total"));
-                 hashMap.put("total",hashMap.get("total")+1);
-            },executorService);
-        }
-        try {
-            future.get();
-        } catch (InterruptedException e) {
-            throw new RuntimeException(e);
-        } catch (ExecutionException e) {
-            throw new RuntimeException(e);
-        }
-        long end = System.currentTimeMillis();
-        System.out.println("完成存入 "+(end-start)/(1000*60));
-    }
-
-    private void writeWdGeoRedis2(){
-        //2.对所有网点坐标进行分析打标签
-        long start = System.currentTimeMillis();
-        System.out.println("开始打标签");
-        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.in("wd_type_code", Arrays.asList("1","2","3","5"));
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-        CompletableFuture<Void> future = null;
-        HashMap<String,Integer> hashMap = new HashMap<>();
-        hashMap.put("total",1);
-        for (WdInfo wdInfo : wdInfos) {
-            //开启线程
-            future = CompletableFuture.runAsync(()->{
-                wdTagAnalyse(wdInfo);
-                System.out.println("进度:"+wdInfos.size()+"/"+hashMap.get("total"));
-                hashMap.put("total",hashMap.get("total")+1);
-            },executorService);
-        }
-        try {
-            future.get();
-        } catch (InterruptedException e) {
-            throw new RuntimeException(e);
-        } catch (ExecutionException e) {
-            throw new RuntimeException(e);
-        }
-        long end = System.currentTimeMillis();
-        System.out.println("完成打标签 "+(end-start)/(1000*60));
-    }
+//    /***
+//     * 分析网点周边标签,并把分析结果存入redis(默认范围:1km)
+//     * @param wdInfo 中心网点信息
+//     * @return
+//     */
+//    public  List<String> wdTagAnalyse(WdInfo wdInfo){
+//        //1. 找到距离中心网点半径1km的所有网点Id
+//        Distance distance = new Distance(1, RedisGeoCommands.DistanceUnit.KILOMETERS);
+//        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo.getAddrCode().substring(0, 4)).radius(wdInfo.getWdId(), distance);
+//        List<GeoResult<RedisGeoCommands.GeoLocation<Object>>> content = radius.getContent();
+//        List<String> aroundWdId = content.stream().map(item -> {
+//            String name = (String) item.getContent().getName();
+//            return name;
+//        }).collect(Collectors.toList());
+//
+//        //2. 查询周边网点标签的Set集
+//        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.select("type_name_by")
+//                .in("wd_id",aroundWdId)
+//                    .groupBy("type_name_by");
+//        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+//
+//        //3. 打标签
+//        List<String> tag = new ArrayList<>();
+//        wdInfos.stream().forEach(item -> {
+//            if(item != null){
+//                String typeNameBy = item.getTypeNameBy();
+//                if(typeNameBy != null && !typeNameBy.equals("")){
+//                    String[] split = typeNameBy.split(":");
+//                    if (split.length > 0)
+//                        tag.add(split[split.length-1]);
+//                }
+//            }
+//        });
+//        redisTemplate.boundValueOps(RedisContant.WD_TAG+"_"+wdInfo.getWdId()).set(tag);
+//        return tag;
+//    }
+//
+//    /**
+//     * 将网点数据库 导入 redis
+//     * */
+//    public void writeWdGeoRedis(){
+//        //清重
+//        clearSql2();
+//        try {
+//            Thread.sleep(1000*60*10);
+//        } catch (InterruptedException e) {
+//            throw new RuntimeException(e);
+//        }
+//
+//        //将所有网点坐标导入redis
+//        writeWdGeoRedis1();
+//
+//        try {
+//            Thread.sleep(1000*60*10);
+//        } catch (InterruptedException e) {
+//            throw new RuntimeException(e);
+//        }
+//        //给网点打标签并存入redis中
+//        writeWdGeoRedis2();
+//    }
+//
+//    public void clearSql2(){
+//        List<String> wdId = new ArrayList<>();
+//        List<String> storeId = new ArrayList<>();
+//        List<String> houseId = new ArrayList<>();
+//        List<String> buildId = new ArrayList<>();
+//        List<String> trafficId = new ArrayList<>();
+//        List<String> enterpriseId = new ArrayList<>();
+//        long start = System.currentTimeMillis();
+//
+//        try{
+//            System.out.println("开始清理");
+//
+//            QueryWrapper<WdInfo> wdInfoOriginQueryWrapper = new QueryWrapper<>();
+//            wdInfoOriginQueryWrapper.select("hash", "count(hash) as audit").groupBy("hash").having("count(hash) >= 2");
+//            List<WdInfo> wdInfoOrigins = wdInfoDao.selectList(wdInfoOriginQueryWrapper);
+//
+//            HashMap<String, Integer> hashMap = new HashMap<>();
+//            for (WdInfo wdInfo : wdInfoOrigins) {
+//                hashMap.put(wdInfo.getHash(), wdInfo.getAudit());
+//            }
+//
+//
+//            HashMap<String,Integer> hashMap1 = new HashMap<>();
+//            hashMap1.put("total",1);
+//            CompletableFuture<Void> future = null;
+//            for (String s : hashMap.keySet()) {
+//                future = CompletableFuture.runAsync(()->{
+//                    synchronized (this){
+//                        if(hashMap1.get("total")%1000 == 0){
+//                            writeService.clearSql2(wdId,storeId,houseId,buildId,trafficId,enterpriseId);
+//                            wdId.clear();
+//                            storeId.clear();
+//                            houseId.clear();
+//                            buildId.clear();
+//                            trafficId.clear();
+//                            enterpriseId.clear();
+//                        }
+//                    }
+//
+//                    QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+//                    queryWrapper.eq("hash",s);
+//                    queryWrapper.orderByDesc("collect_time");
+//                    queryWrapper.last("limit " + (hashMap.get(s) - 1));
+//                    List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+//                    for (WdInfo wdInfo : wdInfos) {
+//                        wdId.add(wdInfo.getWdId());
+//
+//                        switch (wdInfo.getWdTypeCode()){
+//                            case "1":
+//                                storeId.add(wdInfo.getWdId());
+//                                break;
+//                            case "2":
+//                                houseId.add(wdInfo.getWdId());
+//                                break;
+//                            case "3":
+//                                buildId.add(wdInfo.getWdId());
+//                                break;
+//                            case "4":
+//                                trafficId.add(wdInfo.getWdId());
+//                                break;
+//                            case "5":
+//                                enterpriseId.add(wdInfo.getWdId());
+//                                break;
+//                            default:
+//                                break;
+//                        }
+//                    }
+//                    System.out.println("进度:"+wdInfoOrigins.size()+"/"+hashMap1.get("total"));
+//                    hashMap1.put("total",hashMap1.get("total")+1);
+//                },executorService);
+//            }
+//            future.get();
+//        }catch (Exception e){
+//            e.printStackTrace();
+//        }finally {
+//            //删除
+//            writeService.clearSql2(wdId,storeId,houseId,buildId,trafficId,enterpriseId);
+//            long end = System.currentTimeMillis();
+//            System.out.println("完成清理 "+(end-start)/(1000*60));
+//        }
+//
+//
+//    }
+//
+//    private void writeWdGeoRedis1(){
+//        //1.将网点坐标存入redis中
+//        long start = System.currentTimeMillis();
+//        System.out.println("开始将网点坐标存入redis");
+//        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.likeRight("collect_time","2023-09-");
+//
+//        HashMap<String,Integer> hashMap = new HashMap<>();
+//        hashMap.put("total",1);
+//        CompletableFuture<Void> future = null;
+//        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+//        for (WdInfo wdInfo : wdInfos) {
+//            //开启线程
+//            future = CompletableFuture.runAsync(()->{
+//                redisTemplate.boundGeoOps(wdInfo.getAddrCode().substring(0,4)).add(new Point(wdInfo.getLng().doubleValue(),wdInfo.getLat().doubleValue()),wdInfo.getWdId());
+//                 System.out.println("进度:"+wdInfos.size()+"/"+hashMap.get("total"));
+//                 hashMap.put("total",hashMap.get("total")+1);
+//            },executorService);
+//        }
+//        try {
+//            future.get();
+//        } catch (InterruptedException e) {
+//            throw new RuntimeException(e);
+//        } catch (ExecutionException e) {
+//            throw new RuntimeException(e);
+//        }
+//        long end = System.currentTimeMillis();
+//        System.out.println("完成存入 "+(end-start)/(1000*60));
+//    }
+//
+//    private void writeWdGeoRedis2(){
+//        //2.对所有网点坐标进行分析打标签
+//        long start = System.currentTimeMillis();
+//        System.out.println("开始打标签");
+//        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.in("wd_type_code", Arrays.asList("1","2","3","5"));
+//        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+//        CompletableFuture<Void> future = null;
+//        HashMap<String,Integer> hashMap = new HashMap<>();
+//        hashMap.put("total",1);
+//        for (WdInfo wdInfo : wdInfos) {
+//            //开启线程
+//            future = CompletableFuture.runAsync(()->{
+//                wdTagAnalyse(wdInfo);
+//                System.out.println("进度:"+wdInfos.size()+"/"+hashMap.get("total"));
+//                hashMap.put("total",hashMap.get("total")+1);
+//            },executorService);
+//        }
+//        try {
+//            future.get();
+//        } catch (InterruptedException e) {
+//            throw new RuntimeException(e);
+//        } catch (ExecutionException e) {
+//            throw new RuntimeException(e);
+//        }
+//        long end = System.currentTimeMillis();
+//        System.out.println("完成打标签 "+(end-start)/(1000*60));
+//    }
 
 
 }