Browse Source

Merge branch 'master' of http://47.107.53.207:3000/traineeCoder001/Bailian-Al

# Conflicts:
#	benyun-core/src/main/java/com/benyun/core/controller/TopologicalCommonController.java
#	benyun-core/src/main/java/com/benyun/core/controller/TopologicalEnterpriseWdController.java
#	benyun-core/src/main/java/com/benyun/core/entity/vo/TopologicalWdAceeptVo.java
#	benyun-core/src/main/java/com/benyun/core/service/WdInfoService.java
#	benyun-core/src/main/java/com/benyun/core/service/impl/AnalyseWdServiceImpl.java
#	benyun-core/src/main/java/com/benyun/core/service/impl/ChannelAnalyseServiceImpl.java
#	benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalBuildWdSereviceImpl.java
#	benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalEnterpriseWdServiceImpl.java
#	benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalHouseServiceWdImpl.java
#	benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalStoreWdServiceImpl.java
JensionDzero 2 years ago
parent
commit
8eda0f6a89
31 changed files with 566 additions and 220 deletions
  1. 18 11
      benyun-core/src/main/java/com/benyun/core/constant/RedisContant.java
  2. 32 13
      benyun-core/src/main/java/com/benyun/core/controller/BrandController.java
  3. 24 1
      benyun-core/src/main/java/com/benyun/core/controller/ChannelAnalyseController.java
  4. 1 1
      benyun-core/src/main/java/com/benyun/core/controller/TopologicalBuildWdController.java
  5. 23 2
      benyun-core/src/main/java/com/benyun/core/controller/TopologicalCommonController.java
  6. 1 1
      benyun-core/src/main/java/com/benyun/core/controller/TopologicalEnterpriseWdController.java
  7. 37 16
      benyun-core/src/main/java/com/benyun/core/controller/WdInfoController.java
  8. 3 0
      benyun-core/src/main/java/com/benyun/core/dao/WdInfoMapper.java
  9. 0 1
      benyun-core/src/main/java/com/benyun/core/entity/BrandStatistics.java
  10. 1 4
      benyun-core/src/main/java/com/benyun/core/entity/TopologicalBuildingWd.java
  11. 11 0
      benyun-core/src/main/java/com/benyun/core/entity/vo/AddStatusVo.java
  12. 2 0
      benyun-core/src/main/java/com/benyun/core/entity/vo/ChannelMapAceeptVo.java
  13. 3 1
      benyun-core/src/main/java/com/benyun/core/entity/vo/ListQueryBody.java
  14. 5 2
      benyun-core/src/main/java/com/benyun/core/entity/vo/TagAnalyse.java
  15. 14 2
      benyun-core/src/main/java/com/benyun/core/entity/vo/TopologicalWdAceeptVo.java
  16. 4 4
      benyun-core/src/main/java/com/benyun/core/service/BrandService.java
  17. 3 0
      benyun-core/src/main/java/com/benyun/core/service/TopologicalCommonService.java
  18. 1 2
      benyun-core/src/main/java/com/benyun/core/service/WdInfoService.java
  19. 33 33
      benyun-core/src/main/java/com/benyun/core/service/impl/BrandServiceImpl.java
  20. 4 5
      benyun-core/src/main/java/com/benyun/core/service/impl/ChannelAnalyseServiceImpl.java
  21. 119 27
      benyun-core/src/main/java/com/benyun/core/service/impl/ChannelMapServiceImpl.java
  22. 1 4
      benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalBuildWdSereviceImpl.java
  23. 32 0
      benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalCommonServiceImpl.java
  24. 1 2
      benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalEnterpriseWdServiceImpl.java
  25. 1 1
      benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalHouseServiceWdImpl.java
  26. 3 1
      benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalStoreWdServiceImpl.java
  27. 88 46
      benyun-core/src/main/java/com/benyun/core/service/impl/WdInfoServiceImpl.java
  28. 0 1
      benyun-core/src/main/resources/mapper/BrandStatisticsMapper.xml
  29. 33 0
      benyun-core/src/main/resources/mapper/WdInfoMapper.xml
  30. 15 15
      benyun-core/src/test/java/com/benyun/core/service/BrandServiceImplTest.java
  31. 53 24
      benyun-core/src/test/java/com/benyun/core/service/WdInfoServiceImplTest.java

+ 18 - 11
benyun-core/src/main/java/com/benyun/core/constant/RedisContant.java

@@ -2,35 +2,42 @@ package com.benyun.core.constant;
 
 public class RedisContant {
     public static String CHANNEL_MAP_AREA = "channel_area";  //保存渠道地图area数据的Hash名
-    public static int CHANNEL_MAP_AREA_TIME = 30;  //渠道地图area数据的超时时间
+    public static int CHANNEL_MAP_AREA_TIME = 60*8;  //渠道地图area数据的超时时间
     public static String CHANNEL_MAP_LIST = "channel_list";  //保存渠道地图list数据的Hash名
 
-    public static int CHANNEL_MAP_LIST_TIME = 30;  //渠道地图list数据的超时时间
+    public static int CHANNEL_MAP_LIST_TIME = 60*8;  //渠道地图list数据的超时时间
     public static String CHANNEL_MAP_POINT = "channel_point"; //保存渠道地图point数据的Hash名
 
-    public static int CHANNEL_MAP_POINT_TIME = 30;  //渠道地图point数据的超时时间
+    public static int CHANNEL_MAP_POINT_TIME = 60*8;  //渠道地图point数据的超时时间
 
 
     public static String TOPOLOGICAL_STORE_WD_LIST = "topological_store_wd_list";
 
-    public static int TOPOLOGICAL_STORE_WD_LIST_TIME = 30;
+    public static int TOPOLOGICAL_STORE_WD_LIST_TIME = 60*8;
 
     public static String TOPOLOGICAL_STORE_WD_CATEGORY = "topological_store_wd_category";
 
-    public static int TOPOLOGICAL_STORE_WD_CATEGORY_TIME = 30;
+    public static int TOPOLOGICAL_STORE_WD_CATEGORY_TIME = 60*8;
 
     public static String TOPOLOGICAL_BUILD_WD_LIST = "topological_build_wd_list";
-    public static int TOPOLOGICAL_BUILD_WD_LIST_TIME = 30;
+    public static int TOPOLOGICAL_BUILD_WD_LIST_TIME = 60*8;
     public static String TOPOLOGICAL_BUILD_WD_CATEGORY= "topological_build_wd_category";
-    public static int TOPOLOGICAL_BUILD_WD_CATEGORY_TIME = 30;
+    public static int TOPOLOGICAL_BUILD_WD_CATEGORY_TIME = 60*8;
 
     public static String TOPOLOGICAL_ENTERPRISE_WD_LIST = "topological_enterprise_wd_list";
-    public static int TOPOLOGICAL_ENTERPRISE_WD_LIST_TIME = 30;
+    public static int TOPOLOGICAL_ENTERPRISE_WD_LIST_TIME = 60*8;
     public static String TOPOLOGICAL_HOUSE_WD_LIST = "topological_house_wd_list";
-    public static int TOPOLOGICAL_HOUSE_WD_LIST_TIME = 30;
+    public static int TOPOLOGICAL_HOUSE_WD_LIST_TIME = 60*8;
     public static String TOPOLOGICAL_HOUSE_WD_INFO = "topological_house_wd_info";
-    public static int TOPOLOGICAL_HOUSE_WD_INFO_TIME = 30;
+    public static int TOPOLOGICAL_HOUSE_WD_INFO_TIME = 60*8;
 
     public static String CHANNEL_ANALYSE_CITYTIER = "channel_analyse_cityiter";
-    public static int CHANNEL_ANALYSE_CITYTIER_TIME = 30;
+    public static int CHANNEL_ANALYSE_CITYTIER_TIME = 60*8;
+
+    public static String CHANNEL_ANALYSE_TAG_ANLYSE = "channel_analyse_tag_anlyse";
+
+    public static int CHANNEL_ANALYSE_TAG_ANLYSE_TIME = 60*8;
+
+    public static String TOPOLOGICAL_COMMON_MAP = "topological_common_map";
+    public static int TOPOLOGICAL_COMMON_MAP_TIME = 60*8;
 }

+ 32 - 13
benyun-core/src/main/java/com/benyun/core/controller/BrandController.java

@@ -2,13 +2,12 @@ package com.benyun.core.controller;
 
 import com.benyun.core.entity.bo.BrandGeoLabelBo;
 import com.benyun.core.entity.bo.BrandSearch;
-import com.benyun.core.entity.vo.BrandListQueryBody;
+import com.benyun.core.entity.vo.ListQueryBody;
 import com.benyun.core.service.BrandService;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.R;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -31,7 +30,7 @@ public class BrandController extends BaseController {
 
 //    获取品牌信息列表
     @PostMapping("/list")
-    public R list(BrandListQueryBody body){
+    public R list(ListQueryBody body){
         String userId = "1";
         return R.ok(brandService.searchListByMulti(body,userId));
     }
@@ -78,24 +77,26 @@ public class BrandController extends BaseController {
         return R.ok(brandService.searchDistributionByBrandId(brandId));
     }
 
-//    获取所有品牌网点数量
+//    品牌网点数量对比
     @GetMapping("/total")
     public R total(Integer pageSize){
         return R.ok(brandService.searchTotal(pageSize));
     }
 
 //    获取品牌均分分布
-    @GetMapping("/average")
-    public R average(String brandId){
-        return R.ok(brandService.searchAvgScoreByBrandId(brandId));
-    }
+//    已废弃
+//    @GetMapping("/average")
+//    public R average(String brandId){
+//        return R.ok(brandService.searchAvgScoreByBrandId(brandId));
+//    }
 
 //    获取各地区品牌网点数量分布情况
-    @PostMapping("/countDistribution")
-    public R categoryDis(BrandListQueryBody body){
-        List<String> addrCode = body.getAddrCode();
-        return R.ok(brandService.searchAddrDistribution(addrCode));
-    }
+//    已废弃
+//    @PostMapping("/countDistribution")
+//    public R categoryDis(ListQueryBody body){
+//        List<String> addrCode = body.getAddrCode();
+//        return R.ok(brandService.searchAddrDistribution(addrCode));
+//    }
 
 //    获取品牌地理位置标签分布
     @GetMapping("/geolabel")
@@ -103,4 +104,22 @@ public class BrandController extends BaseController {
         List<BrandGeoLabelBo> brandGeoLabelBos = brandService.searchGeoLabel(brandId);
         return R.ok(brandGeoLabelBos);
     }
+
+//    行业连锁品牌发展情况
+    @PostMapping("/develop")
+    public R develop(ListQueryBody body){
+        List<String> addrCode = body.getAddrCode();
+        List<String> typeCode = body.getTypeCode(); // 网点分类(犇云)预留
+        List<String> brandId = body.getBrandId();
+        return null;
+    }
+
+//    连锁品牌近期开关店情况
+    @GetMapping("/opclose")
+    public R opclose(ListQueryBody body){
+        List<String> industryCode = body.getIndustryCode(); // 预留
+        String startTime = body.getStartTime();
+        String endTime = body.getEndTime();
+        return null;
+    }
 }

+ 24 - 1
benyun-core/src/main/java/com/benyun/core/controller/ChannelAnalyseController.java

@@ -5,6 +5,7 @@ import com.benyun.core.entity.Brand;
 import com.benyun.core.entity.bo.WdCount;
 import com.benyun.core.entity.vo.ChannelAnalyseAceeptVo;
 import com.benyun.core.entity.vo.ChannelMapAceeptVo;
+import com.benyun.core.entity.vo.TagAnalyse;
 import com.benyun.core.service.ChannelAnalyseService;
 import com.github.pagehelper.PageInfo;
 import com.ruoyi.common.core.domain.R;
@@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 @RestController
@@ -51,8 +53,29 @@ public class ChannelAnalyseController {
 
     @RequestMapping("/tagAnalyse")
     public R tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo){
+        int page = channelMapAceeptVo.getPageNum();
+        channelMapAceeptVo.setPageNum(0);
+        String md5 = channelMapAceeptVo.getHash();
+
+        //2.查看redis中是否存在有缓存
+        HashMap<String, Object> result = new HashMap<>();
+        HashMap<String,Object> wdCount = (HashMap<String,Object>) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_TAG_ANLYSE).get(md5);
+        if (wdCount != null) {
+            result.put("data",(List<TagAnalyse>) wdCount.get(page + ""));
+            result.put("pages",(int)wdCount.get("pages"));
+            result.put("total",(int)wdCount.get("total"));
+            return R.ok(result);
+        }
         HashMap<String, Object> hashMap = channelAnalyseService.tagAnalyse(channelMapAceeptVo);
-        return R.ok(hashMap);
+
+        //4.保存到redis中
+        redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_TAG_ANLYSE).put(md5,hashMap);
+        redisTemplate.expire(RedisContant.CHANNEL_ANALYSE_TAG_ANLYSE,RedisContant.CHANNEL_ANALYSE_TAG_ANLYSE_TIME, TimeUnit.MINUTES); //30分钟
+
+        result.put("data",(List<TagAnalyse>) hashMap.get(page + ""));
+        result.put("pages",(int)hashMap.get("pages"));
+        result.put("total",(int)hashMap.get("total"));
+        return R.ok(result);
     }
 
 //    @RequestMapping("/businessAnalyse")

+ 1 - 1
benyun-core/src/main/java/com/benyun/core/controller/TopologicalBuildWdController.java

@@ -29,7 +29,7 @@ public class TopologicalBuildWdController {
     RedisTemplate redisTemplate;
 
     @RequestMapping("/buildingLevel")
-    public R buildingLevel(@Validated(value = {TopologicalWdGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
+    public R buildingLevel(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
         String md5 = topologicalWdAceeptVo.getHash();
         //2.查看redis中是否存在有缓存
         List<BuildWdCategoryCount> wdCount = (List<BuildWdCategoryCount>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_BUILD_WD_CATEGORY).get(md5);

+ 23 - 2
benyun-core/src/main/java/com/benyun/core/controller/TopologicalCommonController.java

@@ -1,15 +1,20 @@
 package com.benyun.core.controller;
 
+import com.benyun.core.constant.RedisContant;
+import com.benyun.core.entity.TopologicalStoreWd;
 import com.benyun.core.entity.WdInfo;
+import com.benyun.core.entity.vo.TopologicalWdAceeptVo;
 import com.benyun.core.service.TopologicalCommonService;
 import com.benyun.core.service.WdInfoService;
 import com.ruoyi.common.core.domain.R;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.HashMap;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 @RestController
 @RequestMapping("/poi/common")
@@ -19,6 +24,11 @@ public class TopologicalCommonController {
 
     @Autowired
     WdInfoService wdInfoService;
+
+
+    @Autowired
+    RedisTemplate redisTemplate;
+
     @RequestMapping("/prefixSearch")
     public R prefixSearch(String searchText){
         List<WdInfo> wdInfos = topologicalCommonService.prefixSearch(searchText);
@@ -34,8 +44,19 @@ public class TopologicalCommonController {
     }
 
     @RequestMapping("/map")
-    public R map(String wdId,int r,int size,String wdTypeCode){
-        List<WdInfo> map = wdInfoService.map(wdId, r,size,wdTypeCode);
+    public R map(TopologicalWdAceeptVo topologicalWdAceeptVo){
+        String md5 = topologicalWdAceeptVo.getHash();
+        //2.查看redis中是否存在有缓存
+        List<WdInfo> wdCount = (List<WdInfo>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_COMMON_MAP).get(md5);
+        if (wdCount != null) {
+            return R.ok(wdCount);
+        }
+
+        List<WdInfo> map = topologicalCommonService.map(topologicalWdAceeptVo);
+        redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_COMMON_MAP).put(md5,map);
+        redisTemplate.expire(RedisContant.TOPOLOGICAL_COMMON_MAP,RedisContant.TOPOLOGICAL_COMMON_MAP_TIME, TimeUnit.MINUTES); //30分钟
+
         return R.ok(map);
     }
+
 }

+ 1 - 1
benyun-core/src/main/java/com/benyun/core/controller/TopologicalEnterpriseWdController.java

@@ -30,7 +30,7 @@ public class TopologicalEnterpriseWdController {
     public R list(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
         String md5 = topologicalWdAceeptVo.getHash();
         //2.查看redis中是否存在有缓存
-        List<TopologicalEnterpriseWd>  wdCount = (List<TopologicalEnterpriseWd>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST).get(md5);
+        List<TopologicalEnterpriseWd> wdCount = (List<TopologicalEnterpriseWd>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_ENTERPRISE_WD_LIST).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }

+ 37 - 16
benyun-core/src/main/java/com/benyun/core/controller/WdInfoController.java

@@ -1,6 +1,7 @@
 package com.benyun.core.controller;
 
-import com.benyun.core.entity.vo.BrandListQueryBody;
+import com.benyun.core.entity.vo.AddStatusVo;
+import com.benyun.core.entity.vo.ListQueryBody;
 import com.benyun.core.service.WdInfoService;
 import com.ruoyi.common.core.domain.R;
 import lombok.RequiredArgsConstructor;
@@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.time.LocalDateTime;
 import java.util.List;
 
 @Validated
@@ -22,25 +24,44 @@ public class WdInfoController {
     WdInfoService wdInfoService;
 
 //    获取各地区网点分类分布情况
-    @PostMapping("/categoryDistribution")
-    public R categoryDistribution(BrandListQueryBody body){
-        List<String> addrCodes = body.getAddrCode();
-        List<String> typeCodes = body.getTypeCode();
-        return R.ok(wdInfoService.searchAddrTypeDistribution(addrCodes,typeCodes));
-    }
+//    已废弃
+//    @PostMapping("/categoryDistribution")
+//    public R categoryDistribution(ListQueryBody body){
+//        List<String> addrCodes = body.getAddrCode();
+//        List<String> typeCodes = body.getTypeCode();
+//        return R.ok(wdInfoService.searchAddrTypeDistribution(addrCodes,typeCodes));
+//    }
 
 //    获取各地区网点类型分布情况
-    @PostMapping("/wdTypeDistribution")
-    public R wdTypeDistribution(BrandListQueryBody body){
-        List<String> addrCodes = body.getAddrCode();
-        List<String> typeCodes = body.getTypeCode();
-        return R.ok(wdInfoService.searchWdTypeDistribution(addrCodes,typeCodes));
-    }
+//    已废弃
+//    @PostMapping("/wdTypeDistribution")
+//    public R wdTypeDistribution(ListQueryBody body){
+//        List<String> addrCodes = body.getAddrCode();
+//        List<String> typeCodes = body.getTypeCode();
+//        return R.ok(wdInfoService.searchWdTypeDistribution(addrCodes,typeCodes));
+//    }
 
 //    获取所有网点类型网点数量(降序)
-    @GetMapping("/total")
-    public R total(){
-        return R.ok(wdInfoService.searchWdTotal());
+//    已废弃
+//    @GetMapping("/total")
+//    public R total(){
+//        return R.ok(wdInfoService.searchWdTotal());
+//    }
+
+//    网点数量新增情况
+    @PostMapping("/addStatus")
+    public R addStatus(ListQueryBody body){
+        List<String> addrCode = body.getAddrCode();
+        List<String> typeCode = body.getTypeCode(); // 网点类型
+        List<AddStatusVo> addStatusVos = wdInfoService.searchAddStatus(addrCode, typeCode);
+        return R.ok(addStatusVos);
     }
 
+//    近期各地区网点开关数量变化情况
+    @PostMapping("/opclose")
+    public R opclose(ListQueryBody body){
+        List<String> addrCode = body.getAddrCode();
+        List<String> typeCode = body.getTypeCode(); // 网点分类(犇云)预留
+        return null;
+    }
 }

+ 3 - 0
benyun-core/src/main/java/com/benyun/core/dao/WdInfoMapper.java

@@ -3,6 +3,7 @@ package com.benyun.core.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.benyun.core.entity.WdInfo;
 import com.benyun.core.entity.bo.WdAddrTypeDistribution;
+import com.benyun.core.entity.vo.AddStatusVo;
 import com.benyun.core.entity.vo.WdInfoVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -18,4 +19,6 @@ public interface WdInfoMapper extends BaseMapper<WdInfo> {
     List<WdInfo> list(WdInfoVo wdInfoVo);
 
     void recoverWd(String wdId);
+
+    List<AddStatusVo> searchAddStatusByMulti(@Param("times") List<String> times, @Param("addrCodes") List<String> addrCodes, @Param("wdTypeCodes") List<String> wdTypeCodes);
 }

+ 0 - 1
benyun-core/src/main/java/com/benyun/core/entity/BrandStatistics.java

@@ -13,7 +13,6 @@ import java.time.LocalDateTime;
 @Data
 @TableName("bl_brand_statistics")
 public class BrandStatistics {
-    private String statId;
     private String brandId;
     private String brandName;
     private int coverProvinceCount;

+ 1 - 4
benyun-core/src/main/java/com/benyun/core/entity/TopologicalBuildingWd.java

@@ -10,10 +10,7 @@ import java.time.LocalDateTime;
 @Data
 @TableName("bl_topological_building_wd_list")
 public class TopologicalBuildingWd {
-    @TableId("center_wd_id")
-    private String centerWdId;
-    @TableField("radius")
-    private int radius;
+
     @TableField("around_wd_id")
     private String aroundWdId;
     @TableField("around_wd_name")

+ 11 - 0
benyun-core/src/main/java/com/benyun/core/entity/vo/AddStatusVo.java

@@ -0,0 +1,11 @@
+package com.benyun.core.entity.vo;
+
+import lombok.Data;
+
+@Data
+public class AddStatusVo {
+    private String typeCode;
+    private String typeName;
+    private Integer count;
+    private String time;
+}

+ 2 - 0
benyun-core/src/main/java/com/benyun/core/entity/vo/ChannelMapAceeptVo.java

@@ -29,6 +29,8 @@ public class ChannelMapAceeptVo {
 
     String orderby = ""; //排序字段,(list接口)
 
+    int size = 15; //tag分析时候用
+
     /*
     * 分页字段(list、point接口)
     * */

+ 3 - 1
benyun-core/src/main/java/com/benyun/core/entity/vo/BrandListQueryBody.java → benyun-core/src/main/java/com/benyun/core/entity/vo/ListQueryBody.java

@@ -5,7 +5,7 @@ import lombok.Data;
 import java.util.List;
 
 @Data
-public class BrandListQueryBody {
+public class ListQueryBody {
     private String text;
     private List<String> brandId;
     private List<String> industryCode;
@@ -14,6 +14,8 @@ public class BrandListQueryBody {
     private List<String> coverCityCount;
     private List<String> addrCode;
     private String orderBy;
+    private String startTime;
+    private String endTime;
     private Integer pageNum;
     private Integer pageSize;
 }

+ 5 - 2
benyun-core/src/main/java/com/benyun/core/entity/vo/TagAnalyse.java

@@ -2,10 +2,13 @@ package com.benyun.core.entity.vo;
 
 import lombok.Data;
 
+import java.io.Serializable;
+
 @Data
-public class TagAnalyse {
+public class TagAnalyse implements Serializable {
     String name ;
     Integer count;
-
     double radio;
+
+
 }

+ 14 - 2
benyun-core/src/main/java/com/benyun/core/entity/vo/TopologicalWdAceeptVo.java

@@ -1,5 +1,6 @@
 package com.benyun.core.entity.vo;
 
+import com.benyun.core.constant.ChannelMapContant;
 import com.benyun.core.utils.HashUtil;
 import com.benyun.core.valida.TopologicalWdGroup;
 import com.benyun.core.valida.TopologicalWdListGroup;
@@ -25,8 +26,7 @@ public class TopologicalWdAceeptVo {
     @NotNull(groups = {TopologicalWdListGroup.class},message = "lng不能为空")
     double lng;
 
-    @NotNull(groups = {TopologicalWdListGroup.class},message = "aroundChannel不能为空")
-    String aroundChannel;
+    String[] channel;
 
 
     public String getHash(){
@@ -37,9 +37,21 @@ public class TopologicalWdAceeptVo {
         stringBuilder.append(geoHash);
         stringBuilder.append(lat);
         stringBuilder.append(lng);
+        for (String s : getChannel()) {
+            stringBuilder.append(s);
+        }
+
 
         String s = stringBuilder.toString();
         String md5 = HashUtil.hash(s, "MD5");
         return md5;
     }
+
+    public String[] getChannel() {
+        if(this.channel == null || this.channel.length == 0){
+            return channel = ChannelMapContant.FULL_CHANNEL;
+        }
+        return channel;
+    }
+
 }

+ 4 - 4
benyun-core/src/main/java/com/benyun/core/service/BrandService.java

@@ -1,7 +1,7 @@
 package com.benyun.core.service;
 
 import com.benyun.core.entity.bo.*;
-import com.benyun.core.entity.vo.BrandListQueryBody;
+import com.benyun.core.entity.vo.ListQueryBody;
 import com.github.pagehelper.PageInfo;
 
 import java.util.List;
@@ -15,9 +15,9 @@ public interface BrandService {
     BrandDistribution searchDistributionByBrandId(String brandId);
     List<BrandProvinceBo> searchProvinceByBrandId(String brandId);
     BrandDisCloud searchDisCloudByBrandId(String brandId);
-    PageInfo<List<BrandSearch>> searchListByMulti(BrandListQueryBody body,String userId);
+    PageInfo<List<BrandSearch>> searchListByMulti(ListQueryBody body, String userId);
     List<BrandTotal> searchTotal(Integer pageSize);
-    BStoreData searchAvgScoreByBrandId(String brandId);
-    List<BrandAddrDistribution> searchAddrDistribution(List<String> addrCodes);
+//    BStoreData searchAvgScoreByBrandId(String brandId);
+//    List<BrandAddrDistribution> searchAddrDistribution(List<String> addrCodes);
     List<BrandGeoLabelBo> searchGeoLabel(String brandId);
 }

+ 3 - 0
benyun-core/src/main/java/com/benyun/core/service/TopologicalCommonService.java

@@ -1,10 +1,13 @@
 package com.benyun.core.service;
 
 import com.benyun.core.entity.WdInfo;
+import com.benyun.core.entity.vo.TopologicalWdAceeptVo;
 
 import java.util.List;
 
 public interface TopologicalCommonService {
     public List<WdInfo> prefixSearch(String searchText);
     void search(String searchText,int radius);
+
+    List<WdInfo> map(TopologicalWdAceeptVo topologicalWdAceeptVo);
 }

+ 1 - 2
benyun-core/src/main/java/com/benyun/core/service/WdInfoService.java

@@ -2,6 +2,7 @@ package com.benyun.core.service;
 
 import com.benyun.core.entity.WdInfo;
 import com.benyun.core.entity.bo.WdAddrTypeDistribution;
+import com.benyun.core.entity.vo.AddStatusVo;
 import com.benyun.core.entity.vo.TypeByBody;
 import com.benyun.core.entity.vo.WdInfoVo;
 import com.github.pagehelper.PageInfo;
@@ -13,6 +14,4 @@ public interface WdInfoService {
     List<WdAddrTypeDistribution> searchAddrTypeDistribution(List<String> addrCodes, List<String> typeCodes);
     List<WdAddrTypeDistribution> searchWdTypeDistribution(List<String> addrCodes, List<String> typeCodes);
     List<WdAddrTypeDistribution> searchWdTotal();
-
-    List<WdInfo> map(String wdId,int r,int size,String wd_type_code);
 }

+ 33 - 33
benyun-core/src/main/java/com/benyun/core/service/impl/BrandServiceImpl.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.benyun.core.dao.*;
 import com.benyun.core.entity.*;
 import com.benyun.core.entity.bo.*;
-import com.benyun.core.entity.vo.BrandListQueryBody;
+import com.benyun.core.entity.vo.ListQueryBody;
 import com.benyun.core.service.BrandService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -244,7 +244,7 @@ public class BrandServiceImpl implements BrandService {
     }
 
     @Override
-    public PageInfo<List<BrandSearch>> searchListByMulti(BrandListQueryBody body,String userId) {
+    public PageInfo<List<BrandSearch>> searchListByMulti(ListQueryBody body, String userId) {
         PageHelper.startPage(body.getPageNum(),body.getPageSize(),true);
         String text = body.getText();
         List<String> industryCode = body.getIndustryCode();
@@ -303,38 +303,38 @@ public class BrandServiceImpl implements BrandService {
         return tList;
     }
 
-    @Override
-    public BStoreData searchAvgScoreByBrandId(String brandId) {
-        Brand brand = brandMapper.searchById(brandId);
-        if (brand == null)
-            return null;
-        BStoreData bStoreData = new BStoreData();
-        bStoreData.setBrandName(brand.getBrandName());
-        List<BrandZone> zones = brandZoneMapper.searchByBrandId(brandId);
-        if (zones.isEmpty())
-            return null;
-        List<Info> infos = new ArrayList<>();
-        wdInfoService.setAddrMap();
-        for (BrandZone bz : zones){
-            Info info = new Info();
-            info.setAddrCode(bz.getAddrCode());
-            info.setAddrName(wdInfoService.addrMap.get(bz.getAddrCode()));
-            info.setAvgScore(bz.getAvgScore());
-            infos.add(info);
-        }
-        bStoreData.setInfo(infos);
-        return bStoreData;
-    }
+//    @Override
+//    public BStoreData searchAvgScoreByBrandId(String brandId) {
+//        Brand brand = brandMapper.searchById(brandId);
+//        if (brand == null)
+//            return null;
+//        BStoreData bStoreData = new BStoreData();
+//        bStoreData.setBrandName(brand.getBrandName());
+//        List<BrandZone> zones = brandZoneMapper.searchByBrandId(brandId);
+//        if (zones.isEmpty())
+//            return null;
+//        List<Info> infos = new ArrayList<>();
+//        wdInfoService.setAddrMap();
+//        for (BrandZone bz : zones){
+//            Info info = new Info();
+//            info.setAddrCode(bz.getAddrCode());
+//            info.setAddrName(wdInfoService.addrMap.get(bz.getAddrCode()));
+//            info.setAvgScore(bz.getAvgScore());
+//            infos.add(info);
+//        }
+//        bStoreData.setInfo(infos);
+//        return bStoreData;
+//    }
 
-    @Override
-    public List<BrandAddrDistribution> searchAddrDistribution(List<String> addrCodes) {
-        List<BrandAddrDistribution> list = brandZoneMapper.searchByAddrCodeGroup(addrCodes);
-        wdInfoService.setAddrMap();
-        for (BrandAddrDistribution dis : list){
-            dis.setAddrName(wdInfoService.addrMap.get(dis.getAddrCode()));
-        }
-        return list;
-    }
+//    @Override
+//    public List<BrandAddrDistribution> searchAddrDistribution(List<String> addrCodes) {
+//        List<BrandAddrDistribution> list = brandZoneMapper.searchByAddrCodeGroup(addrCodes);
+//        wdInfoService.setAddrMap();
+//        for (BrandAddrDistribution dis : list){
+//            dis.setAddrName(wdInfoService.addrMap.get(dis.getAddrCode()));
+//        }
+//        return list;
+//    }
 
     @Override
     public List<BrandGeoLabelBo> searchGeoLabel(String brandId) {

+ 4 - 5
benyun-core/src/main/java/com/benyun/core/service/impl/ChannelAnalyseServiceImpl.java

@@ -79,9 +79,9 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
 
     @Override
     public PageInfo<Brand> brandList(ChannelAnalyseAceeptVo channelAnalyseAceeptVo) {
-        PageHelper.startPage(channelAnalyseAceeptVo.getPageNum(),channelAnalyseAceeptVo.getPageSize());
-        String text = null;
-        if(channelAnalyseAceeptVo.getSearchText() != null)
+        PageHelper.startPage(channelAnalyseAceeptVo.getPageNum(), channelAnalyseAceeptVo.getPageSize());
+        String text = "";
+        if (channelAnalyseAceeptVo.getSearchText() != null)
             text = channelAnalyseAceeptVo.getSearchText();
         List<Brand> brands = brandMapper.searchList(text);
         PageInfo<Brand> pageInfo = new PageInfo<>(brands);
@@ -188,7 +188,7 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
 //    }
 
     @Override
-    public HashMap<String,Object> tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
+    public HashMap<String, Object> tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
         //1.根据不同级别得到地区码
         List<String> addrCodeList = new ArrayList<>();
         if ("province".equals(channelMapAceeptVo.getRankType())) {
@@ -286,7 +286,6 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         return result;
     }
 
-
     @Override
     public void businessAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
         //1.根据不同级别得到地区码

+ 119 - 27
benyun-core/src/main/java/com/benyun/core/service/impl/ChannelMapServiceImpl.java

@@ -49,6 +49,9 @@ public class ChannelMapServiceImpl implements ChannelMapService {
     @Autowired
     AttentionPoolDao attentionPoolDao;
 
+    @Autowired
+    WdInfoDao wdInfoDao;
+
     @Override
     public WdCount area(List<String> channel, String rankType, String searchText, String[] addrCode) {
         long start = System.currentTimeMillis();
@@ -160,6 +163,98 @@ public class ChannelMapServiceImpl implements ChannelMapService {
     }
 
     //TODO 需要优化
+//    @Override
+//    public HashMap list(String[] channel, String rankType, String searchText, String orderby, String[] addrCode, int pageNum, int pageSize) {
+//        //1.根据不同级别得到地区码
+//        List<String> addrCodeList = new ArrayList<>();
+//        if ("province".equals(rankType)) {
+//            //省码
+//            for (String s : addrCode) {
+//                String substring = s.substring(0, 2);
+//                addrCodeList.add(substring);
+//            }
+//        } else if ("city".equals(rankType)) {
+//            //省的所有市
+//            for (String s : addrCode) {
+//                String substring = s.substring(0, 4);
+//                addrCodeList.add(substring);
+//            }
+//        } else if ("zone".equals(rankType)) {
+//            //区
+//            for (String s : addrCode) {
+//                String substring = s.substring(0, 6);
+//                addrCodeList.add(substring);
+//            }
+//        } else {
+//            return null;
+//        }
+//
+//
+//        //2.根据地区前缀找到所有的网点
+//        QueryWrapper<WdTopologicalInfo> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.in("center_wd_type_code", channel).and(originWdInfoQueryWrapper -> {
+//            for (String s : addrCodeList) {
+//                originWdInfoQueryWrapper.likeRight("addr_code", s).or();
+//            }
+//        });
+//
+//        if (searchText != null && !searchText.trim().equals("")) {
+//            queryWrapper.and(originWdInfoQueryWrapper -> {
+//                originWdInfoQueryWrapper.like("center_wd_name", searchText);
+//            });
+//        }
+//
+//        queryWrapper.and(wdTopologicalInfoQueryWrapper -> {
+//            wdTopologicalInfoQueryWrapper.eq("radius",1000); //1km内算附近
+//        });
+//
+//        if (orderby != null && !orderby.trim().equals("")) {
+//            queryWrapper.orderByDesc(orderby);
+//        }
+//
+//        //获取数据
+//        PageHelper.startPage(pageNum, pageSize);
+//        List<WdTopologicalInfo> originWdInfos = wdTopologicalInfoDao.selectList(queryWrapper);
+//        PageInfo<WdTopologicalInfo> PageInfo = new PageInfo<>(originWdInfos);
+//
+//
+//        //组装
+//        List<WdTopologicalInfoBo> collect = PageInfo.getList().stream().map(wdTopologicalInfo -> {
+//            wdTopologicalInfo.setAddrCodeInfo(addrCodeMap.get(wdTopologicalInfo.getAddrCode()));
+//
+//            List<String> list = new ArrayList<>();
+//            String tag = wdTopologicalInfo.getTag();
+//            for (String s : tag.split(";")) {
+//                String[] split = s.split(":");
+//                if (split != null && split.length == 2) {
+//                    if(typeByMap.get(split[0]) == null)
+//                        continue;
+//                    String[] split1 = typeByMap.get(split[0]).split(":");
+//                    String t = "";
+//                    if (split1.length == 3)
+//                        t = split1[2];
+//                    else if (split1.length == 2)
+//                        t = split1[1];
+//                    else if (split1.length == 1)
+//                        t = split1[0];
+//                    list.add(t);
+//                }
+//            }
+//
+//            WdTopologicalInfoBo wdTopologicalInfoBo = new WdTopologicalInfoBo(wdTopologicalInfo);
+//            wdTopologicalInfoBo.setTag(list);
+//            return wdTopologicalInfoBo;
+//        }).collect(Collectors.toList());
+//
+//
+//        PageInfo.setList(null);
+//        HashMap result = new HashMap();
+//        result.put("data",collect);
+//        result.put("page",PageInfo);
+//
+//        return result;
+//    }
+
     @Override
     public HashMap list(String[] channel, String rankType, String searchText, String orderby, String[] addrCode, int pageNum, int pageSize) {
         //1.根据不同级别得到地区码
@@ -188,8 +283,8 @@ public class ChannelMapServiceImpl implements ChannelMapService {
 
 
         //2.根据地区前缀找到所有的网点
-        QueryWrapper<WdTopologicalInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.in("center_wd_type_code", channel).and(originWdInfoQueryWrapper -> {
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("wd_type_code", channel).and(originWdInfoQueryWrapper -> {
             for (String s : addrCodeList) {
                 originWdInfoQueryWrapper.likeRight("addr_code", s).or();
             }
@@ -197,48 +292,44 @@ public class ChannelMapServiceImpl implements ChannelMapService {
 
         if (searchText != null && !searchText.trim().equals("")) {
             queryWrapper.and(originWdInfoQueryWrapper -> {
-                originWdInfoQueryWrapper.like("center_wd_name", searchText);
+                originWdInfoQueryWrapper.like("wd_name", searchText);
             });
         }
 
-        queryWrapper.and(wdTopologicalInfoQueryWrapper -> {
-            wdTopologicalInfoQueryWrapper.eq("radius",1000); //1km内算附近
-        });
-
         if (orderby != null && !orderby.trim().equals("")) {
             queryWrapper.orderByDesc(orderby);
         }
 
         //获取数据
         PageHelper.startPage(pageNum, pageSize);
-        List<WdTopologicalInfo> originWdInfos = wdTopologicalInfoDao.selectList(queryWrapper);
-        PageInfo<WdTopologicalInfo> PageInfo = new PageInfo<>(originWdInfos);
+        List<WdInfo> originWdInfos = wdInfoDao.selectList(queryWrapper);
+        PageInfo<WdInfo> PageInfo = new PageInfo<>(originWdInfos);
 
 
         //组装
-        List<WdTopologicalInfoBo> collect = PageInfo.getList().stream().map(wdTopologicalInfo -> {
-            wdTopologicalInfo.setAddrCodeInfo(addrCodeMap.get(wdTopologicalInfo.getAddrCode()));
+        List<WdTopologicalInfoBo> collect = PageInfo.getList().stream().map(wdInfo -> {
 
             List<String> list = new ArrayList<>();
-            String tag = wdTopologicalInfo.getTag();
-            for (String s : tag.split(";")) {
-                String[] split = s.split(":");
-                if (split != null && split.length == 2) {
-                    if(typeByMap.get(split[0]) == null)
-                        continue;
-                    String[] split1 = typeByMap.get(split[0]).split(":");
-                    String t = "";
-                    if (split1.length == 3)
-                        t = split1[2];
-                    else if (split1.length == 2)
-                        t = split1[1];
-                    else if (split1.length == 1)
-                        t = split1[0];
-                    list.add(t);
+            String tag = wdInfo.getTypeNameBy();
+            if(tag != null){
+                String[] split = tag.split(":");
+                for (String s : split) {
+                    list.add(s);
                 }
             }
 
-            WdTopologicalInfoBo wdTopologicalInfoBo = new WdTopologicalInfoBo(wdTopologicalInfo);
+
+            WdTopologicalInfoBo wdTopologicalInfoBo = new WdTopologicalInfoBo();
+            wdTopologicalInfoBo.setCenterWdId(wdInfo.getWdId());
+            wdTopologicalInfoBo.setCenterWdName(wdInfo.getWdName());
+            wdTopologicalInfoBo.setCenterWdTypeCode(wdInfo.getWdTypeCode());
+            wdTopologicalInfoBo.setAddrCode(wdInfo.getAddrCode());
+            wdTopologicalInfoBo.setAddrCodeInfo(addrCodeMap.get(wdInfo.getAddrCode()));
+            wdTopologicalInfoBo.setAddrInfo(wdInfo.getAddrInfo());
+            wdTopologicalInfoBo.setGeoHash(wdInfo.getGeoHash());
+            wdTopologicalInfoBo.setLat(wdInfo.getLat());
+            wdTopologicalInfoBo.setLng(wdInfo.getLng());
+
             wdTopologicalInfoBo.setTag(list);
             return wdTopologicalInfoBo;
         }).collect(Collectors.toList());
@@ -252,6 +343,7 @@ public class ChannelMapServiceImpl implements ChannelMapService {
         return result;
     }
 
+
     @Override
     public PageInfo<WdInfo> point(String[] channel, String searchText, String[] addrCode, int pageNum, int pageSize) {
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();

+ 1 - 4
benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalBuildWdSereviceImpl.java

@@ -77,15 +77,12 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
 
     @Override
     public List<TopologicalBuildingWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-//        PageHelper.startPage(topologicalWdAceeptVo.getPageNum(), topologicalWdAceeptVo.getPageSize());
-//        List<TopologicalBuildingWd> topologicalStoreWds = topologicalBuildWdDao.list(topologicalWdAceeptVo.getCenterWdId(), Integer.valueOf(topologicalWdAceeptVo.getRadius()));
-//        PageInfo<TopologicalBuildingWd> pageInfo = new  PageInfo<>(topologicalStoreWds);
 
         //return pageInfo;
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
 
         //条件构造
-        queryWrapper.eq("wd_type_code",topologicalWdAceeptVo.getAroundChannel());
+        queryWrapper.eq("wd_type_code","3");
         queryWrapper.and(wdInfoQueryWrapper -> {
             wdInfoQueryWrapper.likeRight("geo_hash",topologicalWdAceeptVo.getGeoHash().substring(0,5));
         });

+ 32 - 0
benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalCommonServiceImpl.java

@@ -4,13 +4,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.benyun.core.dao.WdInfoDao;
 import com.benyun.core.entity.TopologicalStoreWd;
 import com.benyun.core.entity.WdInfo;
+import com.benyun.core.entity.vo.TopologicalWdAceeptVo;
 import com.benyun.core.service.TopologicalCommonService;
+import com.benyun.core.utils.DistanceUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import org.gavaghan.geodesy.Ellipsoid;
+import org.gavaghan.geodesy.GlobalCoordinates;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.lang.reflect.Array;
+import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -38,5 +44,31 @@ public class TopologicalCommonServiceImpl implements TopologicalCommonService {
 
     }
 
+    @Override
+    public List<WdInfo> map(TopologicalWdAceeptVo topologicalWdAceeptVo) {
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+
+        //条件构造
+        queryWrapper.in("wd_type_code",topologicalWdAceeptVo.getChannel());
+        queryWrapper.and(wdInfoQueryWrapper -> {
+            wdInfoQueryWrapper.likeRight("geo_hash",topologicalWdAceeptVo.getGeoHash().substring(0,5));
+        });
+
+        //查询结果
+        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
+        List<WdInfo> list = new ArrayList<>();  //返回结果集
+        GlobalCoordinates source = new GlobalCoordinates(topologicalWdAceeptVo.getLat(), topologicalWdAceeptVo.getLng());
+        for (WdInfo wdInfo : wdInfos) {
+            //1.计算距离
+            GlobalCoordinates target = new GlobalCoordinates(wdInfo.getLat().doubleValue(), wdInfo.getLng().doubleValue());
+            double meter2 = DistanceUtil.getDistanceMeter(source, target, Ellipsoid.WGS84);
+
+            if(meter2 <= topologicalWdAceeptVo.getRadius()){
+                list.add(wdInfo);
+            }
+        }
+        return list;
+    }
 
 }

+ 1 - 2
benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalEnterpriseWdServiceImpl.java

@@ -26,7 +26,6 @@ import java.util.List;
 public class TopologicalEnterpriseWdServiceImpl implements TopologicalEnterpriseWdService {
     @Autowired
     TopologicalEnterpriseWdDao topologicalEnterpriseWdDao;
-
     @Autowired
     WdInfoDao wdInfoDao;
 
@@ -38,7 +37,7 @@ public class TopologicalEnterpriseWdServiceImpl implements TopologicalEnterprise
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
 
         //条件构造
-        queryWrapper.eq("wd_type_code",topologicalWdAceeptVo.getAroundChannel());
+        queryWrapper.eq("wd_type_code","5");
         queryWrapper.and(wdInfoQueryWrapper -> {
             wdInfoQueryWrapper.likeRight("geo_hash",topologicalWdAceeptVo.getGeoHash().substring(0,5));
         });

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

@@ -44,7 +44,7 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
 
         //条件构造
-        queryWrapper.eq("wd_type_code",topologicalWdAceeptVo.getAroundChannel());
+        queryWrapper.eq("wd_type_code","2");
         queryWrapper.and(wdInfoQueryWrapper -> {
             wdInfoQueryWrapper.likeRight("geo_hash",topologicalWdAceeptVo.getGeoHash().substring(0,5));
         });

+ 3 - 1
benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalStoreWdServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.benyun.core.dao.TopologicalStoreWdDao;
 import com.benyun.core.dao.TopologicalStoreWdStatisticsCategoryDao;
 import com.benyun.core.dao.WdInfoDao;
+import com.benyun.core.dao.WdInfoDao;
 import com.benyun.core.entity.ManageType;
 import com.benyun.core.entity.TopologicalStoreWd;
 import com.benyun.core.entity.TopologicalStoreWdStatisticsCategory;
@@ -44,12 +45,13 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
     HashMap<String,String> addrCodeMap;
 
 
+
     @Override
     public List<TopologicalStoreWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
         QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
 
         //条件构造
-        queryWrapper.eq("wd_type_code",topologicalWdAceeptVo.getAroundChannel());
+        queryWrapper.eq("wd_type_code","1");
         queryWrapper.and(wdInfoQueryWrapper -> {
             wdInfoQueryWrapper.likeRight("geo_hash",topologicalWdAceeptVo.getGeoHash().substring(0,5));
         });

+ 88 - 46
benyun-core/src/main/java/com/benyun/core/service/impl/WdInfoServiceImpl.java

@@ -10,6 +10,7 @@ import com.benyun.core.entity.Category;
 import com.benyun.core.entity.TypeBy;
 import com.benyun.core.entity.WdInfo;
 import com.benyun.core.entity.bo.WdAddrTypeDistribution;
+import com.benyun.core.entity.vo.AddStatusVo;
 import com.benyun.core.entity.vo.TypeByBody;
 import com.benyun.core.entity.vo.WdInfoVo;
 import com.benyun.core.service.CategoryService;
@@ -25,6 +26,8 @@ import org.springframework.stereotype.Service;
 
 import java.lang.reflect.Type;
 import java.nio.charset.StandardCharsets;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -34,7 +37,11 @@ import java.util.stream.Collectors;
 @Service
 public class WdInfoServiceImpl implements WdInfoService {
     public Map<String,String> typeMap;
+    public Map<String,List<String>> typeChildren = new HashMap<>();
+
     public Map<String,String> addrMap;
+    public Map<String,List<String>> addrChildren = new HashMap<>();
+
     public Map<String,String> wdTypeMap;
     @Autowired
     WdInfoMapper wdInfoMapper;
@@ -84,12 +91,15 @@ public class WdInfoServiceImpl implements WdInfoService {
             wdTypeMap.put("5","公司网点");
         }
     }
-    private List<String> getAllOtherAddrCode(String addrCode){
+    public List<String> getAllOtherAddrCode(String addrCode){
+        if (addrChildren.get(addrCode) != null){
+//            System.out.println("quickly");
+            return addrChildren.get(addrCode);
+        }
         List<String> addrCodes = new ArrayList<>();
-        byte[] bytes = addrCode.getBytes(StandardCharsets.UTF_8);
-        String big = String.valueOf(bytes[0]) + String.valueOf(bytes[1]);
-        String mid = String.valueOf(bytes[2]) + String.valueOf(bytes[3]);
-        String sub = String.valueOf(bytes[4]) + String.valueOf(bytes[5]);
+        String big = String.valueOf(addrCode.charAt(0))+String.valueOf(addrCode.charAt(1));
+        String mid = String.valueOf(addrCode.charAt(2))+String.valueOf(addrCode.charAt(3));
+        String sub = String.valueOf(addrCode.charAt(4))+String.valueOf(addrCode.charAt(5));
         if (sub.equals("00")){
             QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
             if (mid.equals("00")){
@@ -105,18 +115,24 @@ public class WdInfoServiceImpl implements WdInfoService {
                     addrCategoryQueryWrapper.ne("district","");
                 });
             }
-            List<AddrCategory> provinces = addrCategoryDao.selectList(queryWrapper);
-            addrCodes.add(provinces.listIterator().next().getAddrCode());
+            List<AddrCategory> zones = addrCategoryDao.selectList(queryWrapper);
+            for (AddrCategory zone : zones){
+                addrCodes.add(zone.getAddrCode());
+            }
+            addrChildren.put(addrCode,addrCodes);
         }else
             addrCodes.add(addrCode);
         return addrCodes;
     }
-    private List<String> getAllOtherTypeBy(String typeCode){
+    public List<String> getAllOtherTypeBy(String typeCode){
+        if (typeChildren.get(typeCode) != null){
+//            System.out.println("quickly");
+            return typeChildren.get(typeCode);
+        }
         List<String> types = new ArrayList<>();
-        byte[] bytes = typeCode.getBytes(StandardCharsets.UTF_8);
-        String big = String.valueOf(bytes[0]) + String.valueOf(bytes[1]);
-        String mid = String.valueOf(bytes[2]) + String.valueOf(bytes[3]);
-        String sub = String.valueOf(bytes[4]) + String.valueOf(bytes[5]);
+        String big = String.valueOf(typeCode.charAt(0)) + String.valueOf(typeCode.charAt(1));
+        String mid = String.valueOf(typeCode.charAt(2)) + String.valueOf(typeCode.charAt(3));
+        String sub = String.valueOf(typeCode.charAt(4)) + String.valueOf(typeCode.charAt(5));
         if (sub.equals("00")){
             QueryWrapper<TypeBy> queryWrapper = new QueryWrapper<>();
             if (mid.equals("00")){
@@ -126,57 +142,83 @@ public class WdInfoServiceImpl implements WdInfoService {
                     addrCategoryQueryWrapper.ne("sub_category","");
                 });
             }else{
-                queryWrapper.likeRight("addr_code",big+mid).and(addrCategoryQueryWrapper -> {
+                queryWrapper.likeRight("type_code_by",big+mid).and(addrCategoryQueryWrapper -> {
                     addrCategoryQueryWrapper.ne("mid_category","");
                 }).and(addrCategoryQueryWrapper -> {
                     addrCategoryQueryWrapper.ne("sub_category","");
                 });
             }
             List<TypeBy> typeByList = byDao.selectList(queryWrapper);
-            types.add(typeByList.listIterator().next().getTypeCodeBy());
+            for (TypeBy typeBy : typeByList){
+                types.add(typeBy.getTypeCodeBy());
+            }
+            typeChildren.put(typeCode,types);
         }else
             types.add(typeCode);
         return types;
     }
 
     @Override
-    public List<WdAddrTypeDistribution> searchAddrTypeDistribution(List<String> addrCodes, List<String> typeCodes) {
-        List<String> acodes = new ArrayList<>();
-        for (String s : addrCodes){
-            List<String> allOtherAddrCode = getAllOtherAddrCode(s);
-            acodes.addAll(allOtherAddrCode);
+    public List<AddStatusVo> searchAddStatus(List<String> addrCodes, List<String> typeCodes) {
+        setWdTypeMap();
+        List<String> addrs = new ArrayList<>();
+        List<String> times = new ArrayList<>();
+        for (int i = 0; i < 12; i++){
+            times.add(LocalDateTime.now().plusMonths(-i).format(DateTimeFormatter.ofPattern("yyyy-MM")));
         }
-        List<WdAddrTypeDistribution> list = wdInfoMapper.searchAddrDisByMulti(acodes, typeCodes);
-        setTypeMap();
-        setAddrMap();
-        for (WdAddrTypeDistribution wd : list){
-            wd.setTypeName(typeMap.get(wd.getTypeCode()));
-            wd.setAddrName(addrMap.get(wd.getAddrCode()));
+        if (addrCodes != null){
+            for (String s : addrCodes){
+                List<String> allOtherAddrCode = getAllOtherAddrCode(s);
+                addrs.addAll(allOtherAddrCode);
+            }
+        }else{
+            addrs = null;
         }
-        return list;
-    }
-
-    @Override
-    public List<WdAddrTypeDistribution> searchWdTypeDistribution(List<String> addrCodes, List<String> typeCodes) {
-        List<WdAddrTypeDistribution> list = wdInfoMapper.searchWdTypeDisByMulti(addrCodes, typeCodes);
-        setAddrMap();
-        setWdTypeMap();
-        for (WdAddrTypeDistribution wd : list){
-            wd.setAddrName(addrMap.get(wd.getAddrCode()));
-            wd.setTypeName(wdTypeMap.get(wd.getTypeCode()));
+        List<AddStatusVo> addStatusVos = wdInfoMapper.searchAddStatusByMulti(times, addrs, typeCodes);
+        for (AddStatusVo vo : addStatusVos){
+            vo.setTypeName(wdTypeMap.get(vo.getTypeCode()));
         }
-        return list;
+        return addStatusVos;
     }
 
-    @Override
-    public List<WdAddrTypeDistribution> searchWdTotal() {
-        List<WdAddrTypeDistribution> list = wdInfoMapper.searchWdTotal();
-        setWdTypeMap();
-        for (WdAddrTypeDistribution wd : list){
-            wd.setTypeName(wdTypeMap.get(wd.getTypeCode()));
-        }
-        return list;
-    }
+//    @Override
+//    public List<WdAddrTypeDistribution> searchAddrTypeDistribution(List<String> addrCodes, List<String> typeCodes) {
+//        List<String> acodes = new ArrayList<>();
+//        for (String s : addrCodes){
+//            List<String> allOtherAddrCode = getAllOtherAddrCode(s);
+//            acodes.addAll(allOtherAddrCode);
+//        }
+//        List<WdAddrTypeDistribution> list = wdInfoMapper.searchAddrDisByMulti(acodes, typeCodes);
+//        setTypeMap();
+//        setAddrMap();
+//        for (WdAddrTypeDistribution wd : list){
+//            wd.setTypeName(typeMap.get(wd.getTypeCode()));
+//            wd.setAddrName(addrMap.get(wd.getAddrCode()));
+//        }
+//        return list;
+//    }
+
+//    @Override
+//    public List<WdAddrTypeDistribution> searchWdTypeDistribution(List<String> addrCodes, List<String> typeCodes) {
+//        List<WdAddrTypeDistribution> list = wdInfoMapper.searchWdTypeDisByMulti(addrCodes, typeCodes);
+//        setAddrMap();
+//        setWdTypeMap();
+//        for (WdAddrTypeDistribution wd : list){
+//            wd.setAddrName(addrMap.get(wd.getAddrCode()));
+//            wd.setTypeName(wdTypeMap.get(wd.getTypeCode()));
+//        }
+//        return list;
+//    }
+
+//    @Override
+//    public List<WdAddrTypeDistribution> searchWdTotal() {
+//        List<WdAddrTypeDistribution> list = wdInfoMapper.searchWdTotal();
+//        setWdTypeMap();
+//        for (WdAddrTypeDistribution wd : list){
+//            wd.setTypeName(wdTypeMap.get(wd.getTypeCode()));
+//        }
+//        return list;
+//    }
 
     @Override
     public List<WdInfo> map(String wdId,int r,int size,String wd_type_code) {

+ 0 - 1
benyun-core/src/main/resources/mapper/BrandStatisticsMapper.xml

@@ -4,7 +4,6 @@
     "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.benyun.core.dao.BrandStatisticsMapper">
     <resultMap type="com.benyun.core.entity.BrandStatistics" id="BrandStatisticsResult">
-        <result property="statId" column="stat_id"/>
         <result property="brandId" column="brand_id"/>
         <result property="brandName" column="brand_name"/>
         <result property="coverProvinceCount" column="cover_province_count"/>

+ 33 - 0
benyun-core/src/main/resources/mapper/WdInfoMapper.xml

@@ -17,6 +17,11 @@
         <result property="typeCode" column="wd_type_code"/>
         <result property="count" column="count"/>
     </resultMap>
+    <resultMap type="com.benyun.core.entity.vo.AddStatusVo" id="AddStatusResult">
+        <result property="typeCode" column="wd_type_code"/>
+        <result property="count" column="count"/>
+        <result property="time" column="time"/>
+    </resultMap>
     <select id="searchAddrDisByMulti" resultMap="WdAddrDisResult">
         SELECT
             addr_code,
@@ -93,6 +98,34 @@
             </if>
         </where>
     </select>
+    <select id="searchAddStatusByMulti" resultMap="AddStatusResult">
+        SELECT
+            wd_type_code,
+            COUNT(*) count,
+	        DATE_FORMAT(collect_time, "%Y-%m") time
+        FROM
+            `ddt_wd_info`
+        <trim prefix="where" prefixOverrides="and">
+            <if test="times != null">
+                <foreach collection="times" item="time" open="and DATE_FORMAT(collect_time, '%Y-%m') IN (" separator="," close=")">
+                    #{time,jdbcType=VARCHAR}
+                </foreach>
+            </if>
+            <if test="addrCodes != null">
+                <foreach collection="addrCodes" item="addrCode" open="and addr_code IN (" separator="," close=")">
+                    #{addrCode,jdbcType=VARCHAR}
+                </foreach>
+            </if>
+            <if test="wdTypeCodes != null">
+                <foreach collection="wdTypeCodes" item="type" open="and wd_type_code IN (" separator="," close=")">
+                    #{type,jdbcType=VARCHAR}
+                </foreach>
+            </if>
+        </trim>
+        GROUP BY
+            wd_type_code,
+            time
+    </select>
 
     <update id="recoverWd" parameterType="java.lang.String">
         update ddt_wd_info set show_delete = 0 where wd_id = #{wdId}

+ 15 - 15
benyun-core/src/test/java/com/benyun/core/service/BrandServiceImplTest.java

@@ -2,7 +2,7 @@ package com.benyun.core.service;
 
 import com.benyun.core.entity.bo.BrandAddrDistribution;
 import com.benyun.core.entity.bo.BrandSearch;
-import com.benyun.core.entity.vo.BrandListQueryBody;
+import com.benyun.core.entity.vo.ListQueryBody;
 import com.github.pagehelper.PageInfo;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -71,7 +71,7 @@ public class BrandServiceImplTest {
     @Test
     public void searchListByMultiTest(){
         String userId = "1";
-        BrandListQueryBody body = new BrandListQueryBody();
+        ListQueryBody body = new ListQueryBody();
         body.setText("益禾堂");
         List<String> industryCode = new ArrayList<>();
         industryCode.add("199");
@@ -100,18 +100,18 @@ public class BrandServiceImplTest {
         System.out.println(brandService.searchTotal(10));
     }
 
-    @Test
-    public void searchAvgScoreByBrandIdTest(){
-        String brandId1 = "5eb6d4ccee1d498997c26a140a4bef08";
-        System.out.println(brandService.searchAvgScoreByBrandId(brandId1));
-    }
+//    @Test
+//    public void searchAvgScoreByBrandIdTest(){
+//        String brandId1 = "5eb6d4ccee1d498997c26a140a4bef08";
+//        System.out.println(brandService.searchAvgScoreByBrandId(brandId1));
+//    }
 
-    @Test
-    public void searchAddrTypeDisByMultiTest(){
-        List<String> addrCodes = new ArrayList<>();
-        addrCodes.add("410105000000");
-        addrCodes.add("420111000000");
-        List<BrandAddrDistribution> list = brandService.searchAddrDistribution(addrCodes);
-        System.out.println(list);
-    }
+//    @Test
+//    public void searchAddrTypeDisByMultiTest(){
+//        List<String> addrCodes = new ArrayList<>();
+//        addrCodes.add("410105000000");
+//        addrCodes.add("420111000000");
+//        List<BrandAddrDistribution> list = brandService.searchAddrDistribution(addrCodes);
+//        System.out.println(list);
+//    }
 }

+ 53 - 24
benyun-core/src/test/java/com/benyun/core/service/WdInfoServiceImplTest.java

@@ -1,10 +1,14 @@
 package com.benyun.core.service;
 
 import com.benyun.core.entity.bo.WdAddrTypeDistribution;
+import com.benyun.core.service.impl.WdInfoServiceImpl;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.FormatStyle;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -12,33 +16,58 @@ import java.util.List;
 public class WdInfoServiceImplTest {
     @Autowired
     WdInfoService wdInfoService;
+    @Autowired
+    WdInfoServiceImpl wdImpl;
 
     @Test
-    public void searchWdAddrDistributionTest(){
-        List<String> addrCodes = new ArrayList<>();
-        addrCodes.add("450902000000");
-        addrCodes.add("451302000000");
-        List<String> typeCodes = new ArrayList<>();
-        typeCodes.add("020400");
-        typeCodes.add("020103");
-        List<WdAddrTypeDistribution> list = wdInfoService.searchAddrTypeDistribution(addrCodes, typeCodes);
-        System.out.println(list);
+    public void setWdImpl(){
+//        List<String> allOtherAddrCode = wdImpl.getAllOtherAddrCode("450000000000");
+//        for (String s : allOtherAddrCode){
+//            System.out.println(s);
+//        }
+//        allOtherAddrCode = wdImpl.getAllOtherAddrCode("450000000000");
+//        for (String s : allOtherAddrCode){
+//            System.out.println(s);
+//        }
+//        List<String> allOtherTypeBy = wdImpl.getAllOtherTypeBy("010100");
+//        for (String s : allOtherTypeBy){
+//            System.out.println(s);
+//        }
+//        allOtherTypeBy = wdImpl.getAllOtherTypeBy("010100");
+//        for (String s : allOtherTypeBy){
+//            System.out.println(s);
+//        }
+        for (int i = 0; i < 12; i++){
+            System.out.println(LocalDateTime.now().plusMonths(-i).format(DateTimeFormatter.ofPattern("yyyy-MM")));
+        }
     }
 
-    @Test
-    public void searchWdTypeDistributionTest(){
-        List<String> addrCodes = new ArrayList<>();
-        addrCodes.add("450981000000");
-        addrCodes.add("451002000000");
-        List<String> typeCodes = new ArrayList<>();
-        typeCodes.add("1");
-        typeCodes.add("0");
-        List<WdAddrTypeDistribution> list = wdInfoService.searchWdTypeDistribution(addrCodes, typeCodes);
-        System.out.println(list);
-    }
+//    @Test
+//    public void searchWdAddrDistributionTest(){
+//        List<String> addrCodes = new ArrayList<>();
+//        addrCodes.add("450902000000");
+//        addrCodes.add("451302000000");
+//        List<String> typeCodes = new ArrayList<>();
+//        typeCodes.add("020400");
+//        typeCodes.add("020103");
+//        List<WdAddrTypeDistribution> list = wdInfoService.searchAddrTypeDistribution(addrCodes, typeCodes);
+//        System.out.println(list);
+//    }
 
-    @Test
-    public void searchWdTotalTest(){
-        System.out.println(wdInfoService.searchWdTotal());
-    }
+//    @Test
+//    public void searchWdTypeDistributionTest(){
+//        List<String> addrCodes = new ArrayList<>();
+//        addrCodes.add("450981000000");
+//        addrCodes.add("451002000000");
+//        List<String> typeCodes = new ArrayList<>();
+//        typeCodes.add("1");
+//        typeCodes.add("0");
+//        List<WdAddrTypeDistribution> list = wdInfoService.searchWdTypeDistribution(addrCodes, typeCodes);
+//        System.out.println(list);
+//    }
+
+//    @Test
+//    public void searchWdTotalTest(){
+//        System.out.println(wdInfoService.searchWdTotal());
+//    }
 }