Explorar el Código

分析网点-plus(v3.0)

JensionDzero hace 2 años
padre
commit
286c4ff9f1
Se han modificado 37 ficheros con 1121 adiciones y 339 borrados
  1. 2 2
      benyun-core/Dockerfile
  2. 6 0
      benyun-core/pom.xml
  3. 41 0
      benyun-core/src/main/java/com/benyun/core/config/QuartzConfig.java
  4. 2 2
      benyun-core/src/main/java/com/benyun/core/controller/TopologicalBuildWdController.java
  5. 10 0
      benyun-core/src/main/java/com/benyun/core/controller/TopologicalCommonController.java
  6. 3 2
      benyun-core/src/main/java/com/benyun/core/controller/TopologicalEnterpriseWdController.java
  7. 3 2
      benyun-core/src/main/java/com/benyun/core/controller/TopologicalHouseWdController.java
  8. 8 7
      benyun-core/src/main/java/com/benyun/core/controller/TopologicalStoreWdController.java
  9. 2 1
      benyun-core/src/main/java/com/benyun/core/dao/TopologicalStoreWdStatisticsCategoryDao.java
  10. 11 0
      benyun-core/src/main/java/com/benyun/core/entity/TopologicalBuildingWd.java
  11. 11 4
      benyun-core/src/main/java/com/benyun/core/entity/TopologicalEnterpriseWd.java
  12. 12 4
      benyun-core/src/main/java/com/benyun/core/entity/TopologicalHouseWd.java
  13. 20 13
      benyun-core/src/main/java/com/benyun/core/entity/TopologicalStoreWd.java
  14. 0 31
      benyun-core/src/main/java/com/benyun/core/entity/WdTopological.java
  15. 1 1
      benyun-core/src/main/java/com/benyun/core/entity/bo/StoreWdCategoryCount.java
  16. 1 1
      benyun-core/src/main/java/com/benyun/core/entity/bo/StoreWdCategoryCountBody.java
  17. 17 4
      benyun-core/src/main/java/com/benyun/core/entity/vo/TopologicalWdAceeptVo.java
  18. 3 3
      benyun-core/src/main/java/com/benyun/core/init/BenyunCoreInit.java
  19. 54 0
      benyun-core/src/main/java/com/benyun/core/job/AnalyseJob.java
  20. 5 1
      benyun-core/src/main/java/com/benyun/core/service/AnalyseWdService.java
  21. 1 1
      benyun-core/src/main/java/com/benyun/core/service/TopologicalBuildWdSerevice.java
  22. 3 1
      benyun-core/src/main/java/com/benyun/core/service/TopologicalEnterpriseWdService.java
  23. 1 1
      benyun-core/src/main/java/com/benyun/core/service/TopologicalHouseWdService.java
  24. 3 2
      benyun-core/src/main/java/com/benyun/core/service/TopologicalStoreWdService.java
  25. 2 0
      benyun-core/src/main/java/com/benyun/core/service/WdInfoService.java
  26. 468 158
      benyun-core/src/main/java/com/benyun/core/service/impl/AnalyseWdServiceImpl.java
  27. 100 0
      benyun-core/src/main/java/com/benyun/core/service/impl/ChannelAnalyseServiceImpl.java
  28. 61 11
      benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalBuildWdSereviceImpl.java
  29. 49 5
      benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalEnterpriseWdServiceImpl.java
  30. 51 5
      benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalHouseServiceWdImpl.java
  31. 77 36
      benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalStoreWdServiceImpl.java
  32. 44 0
      benyun-core/src/main/java/com/benyun/core/service/impl/WdInfoServiceImpl.java
  33. 7 16
      benyun-core/src/main/resources/application-dev.yaml
  34. 11 20
      benyun-core/src/main/resources/application-prod.yaml
  35. 3 3
      benyun-core/src/main/resources/mapper/TopologicalStoreWdStatisticsCategoryDao.xml
  36. 1 1
      benyun-core/src/main/resources/mapper/WdTopologicalDao.xml
  37. 27 1
      benyun-core/src/test/java/com/benyun/core/service/AnalyseWdServiceImplTest.java

+ 2 - 2
benyun-core/Dockerfile

@@ -11,11 +11,11 @@ WORKDIR /saas/modules/integral
 #ENV SERVER_PORT=9210
 #
 
-ADD ./target/benyun-core-4.8.0.jar ./app.jar
+ADD ./target/benyun-core-4.8.0.jar ./ds.jar
 
 ENTRYPOINT ["java", \
             "-Djava.security.egd=file:/dev/./urandom", \
 #            "-Dserver.port=${SERVER_PORT}", \
 #            "-Dskywalking.agent.service_name=saas-auth", \
 #            "-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar", \
-            "-jar", "app.jar"]
+            "-jar", "ds.jar"]

+ 6 - 0
benyun-core/pom.xml

@@ -49,6 +49,12 @@
 <!--    </properties>-->
     <dependencies>
 
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-quartz</artifactId>
+        </dependency>
+
+
         <!--redis坐标-->
         <dependency>
             <groupId>org.springframework.boot</groupId>

+ 41 - 0
benyun-core/src/main/java/com/benyun/core/config/QuartzConfig.java

@@ -0,0 +1,41 @@
+package com.benyun.core.config;
+
+
+import com.benyun.core.job.AnalyseJob;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.*;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Slf4j
+@Configuration
+public class QuartzConfig {
+    // 创建一个封装Job对象的类型JobDetall,并放入Spring容器中
+    @Bean
+    public JobDetail clearImgJobDetail(){
+        log.info("分析网点数据的 JobDetall");
+
+        return JobBuilder.newJob(AnalyseJob.class) //newJob方法就是在绑定要运行的Job接口实现。
+            .withIdentity("abcJobDetail") //给当前JobDetail对象取名字
+            .storeDurably() //及时没有触发器绑定当前JobDetail对象,也不会被删除
+            .build();
+    }
+
+    //触发器声明,设置job的运行时机,并放入Spring容器中
+    @Bean
+    public Trigger clearImgTrigger(){
+        log.info("创建分析网点数据的 Trigger");
+
+
+        //定义Cron表达式
+        CronScheduleBuilder cron  = CronScheduleBuilder.cronSchedule("0 38 9 3 9 ? ");
+
+        return TriggerBuilder
+            .newTrigger()
+            .forJob(clearImgJobDetail()) //绑定要运行的JobDetail对象,这是得到的是Spring容器里的JobDetail
+            .withIdentity("abcTrigger") //给当前Trigger对象起名字,名字任意
+            .withSchedule(cron) //绑定cron表达式
+            .build();
+    }
+
+}

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

@@ -49,12 +49,12 @@ public class TopologicalBuildWdController {
     public R list(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
         String md5 = topologicalWdAceeptVo.getHash();
         //2.查看redis中是否存在有缓存
-        PageInfo<TopologicalBuildingWd> wdCount = (PageInfo<TopologicalBuildingWd> )redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_BUILD_WD_LIST).get(md5);
+        List<TopologicalBuildingWd> wdCount = (List<TopologicalBuildingWd>)redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_BUILD_WD_LIST).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
 
-        PageInfo<TopologicalBuildingWd> list = topologicalBuildWdSerevice.list(topologicalWdAceeptVo);
+        List<TopologicalBuildingWd> list = topologicalBuildWdSerevice.list(topologicalWdAceeptVo);
 
         redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_BUILD_WD_LIST).put(md5,list);
         redisTemplate.expire(RedisContant.TOPOLOGICAL_BUILD_WD_LIST,RedisContant.TOPOLOGICAL_BUILD_WD_LIST_TIME, TimeUnit.MINUTES); //30分钟

+ 10 - 0
benyun-core/src/main/java/com/benyun/core/controller/TopologicalCommonController.java

@@ -2,6 +2,7 @@ package com.benyun.core.controller;
 
 import com.benyun.core.entity.WdInfo;
 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.web.bind.annotation.RequestMapping;
@@ -15,6 +16,9 @@ import java.util.List;
 public class TopologicalCommonController {
     @Autowired
     TopologicalCommonService topologicalCommonService;
+
+    @Autowired
+    WdInfoService wdInfoService;
     @RequestMapping("/prefixSearch")
     public R prefixSearch(String searchText){
         List<WdInfo> wdInfos = topologicalCommonService.prefixSearch(searchText);
@@ -28,4 +32,10 @@ public class TopologicalCommonController {
         hashMap.put("2km",2000);
         return R.ok(hashMap);
     }
+
+    @RequestMapping("/map")
+    public R map(String wdId,int r,int size,String wdTypeCode){
+        List<WdInfo> map = wdInfoService.map(wdId, r,size,wdTypeCode);
+        return R.ok(map);
+    }
 }

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

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

+ 3 - 2
benyun-core/src/main/java/com/benyun/core/controller/TopologicalHouseWdController.java

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

+ 8 - 7
benyun-core/src/main/java/com/benyun/core/controller/TopologicalStoreWdController.java

@@ -2,6 +2,7 @@ package com.benyun.core.controller;
 
 import com.benyun.core.constant.RedisContant;
 import com.benyun.core.entity.TopologicalStoreWd;
+import com.benyun.core.entity.bo.StoreWdCategoryCount;
 import com.benyun.core.entity.bo.StoreWdCategoryCountBody;
 import com.benyun.core.entity.bo.WdCount;
 import com.benyun.core.entity.vo.TopologicalWdAceeptVo;
@@ -33,12 +34,12 @@ public class TopologicalStoreWdController {
     public R category(@Validated(value = {TopologicalWdGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
         String md5 = topologicalWdAceeptVo.getHash();
         //2.查看redis中是否存在有缓存
-        List<StoreWdCategoryCountBody> wdCount = (List<StoreWdCategoryCountBody>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_CATEGORY).get(md5);
-        if (wdCount != null) {
-            return R.ok(wdCount);
-        }
+//        List<StoreWdCategoryCount>wdCount = (List<StoreWdCategoryCount>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_CATEGORY).get(md5);
+//        if (wdCount != null) {
+//            return R.ok(wdCount);
+//        }
 
-        List<StoreWdCategoryCountBody> category = topologicalStoreWdService.category(topologicalWdAceeptVo);
+        List<StoreWdCategoryCount> category = topologicalStoreWdService.category(topologicalWdAceeptVo);
 
         redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_CATEGORY).put(md5,category);
         redisTemplate.expire(RedisContant.TOPOLOGICAL_STORE_WD_CATEGORY,RedisContant.TOPOLOGICAL_STORE_WD_CATEGORY_TIME, TimeUnit.MINUTES); //30分钟
@@ -50,13 +51,13 @@ public class TopologicalStoreWdController {
     public R list(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
         String md5 = topologicalWdAceeptVo.getHash();
         //2.查看redis中是否存在有缓存
-        PageInfo<TopologicalStoreWd> wdCount = (PageInfo<TopologicalStoreWd>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_LIST).get(md5);
+        List<TopologicalStoreWd> wdCount = (List<TopologicalStoreWd>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_LIST).get(md5);
         if (wdCount != null) {
             return R.ok(wdCount);
         }
 
 
-        PageInfo<TopologicalStoreWd> list = topologicalStoreWdService.list(topologicalWdAceeptVo);
+        List<TopologicalStoreWd> list = topologicalStoreWdService.list(topologicalWdAceeptVo);
 
         redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_LIST).put(md5,list);
         redisTemplate.expire(RedisContant.TOPOLOGICAL_STORE_WD_LIST,RedisContant.TOPOLOGICAL_STORE_WD_LIST_TIME, TimeUnit.MINUTES); //30分钟

+ 2 - 1
benyun-core/src/main/java/com/benyun/core/dao/TopologicalStoreWdStatisticsCategoryDao.java

@@ -3,6 +3,7 @@ package com.benyun.core.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.benyun.core.entity.TopologicalBuildWdStatisticsCategory;
 import com.benyun.core.entity.TopologicalStoreWdStatisticsCategory;
+import com.benyun.core.entity.vo.TopologicalWdAceeptVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -11,5 +12,5 @@ import java.util.List;
 @Mapper
 public interface TopologicalStoreWdStatisticsCategoryDao extends BaseMapper<TopologicalStoreWdStatisticsCategory> {
     public void insertList(@Param("topologicalStoreWdStatisticsCategoryList")List<TopologicalStoreWdStatisticsCategory> topologicalStoreWdStatisticsCategoryList);
-    List<TopologicalStoreWdStatisticsCategory> category(@Param("centerWdId") String centerWdId, @Param("radius") int radius);
+    List<TopologicalStoreWdStatisticsCategory> category(TopologicalWdAceeptVo topologicalWdAceeptVo);
 }

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

@@ -36,4 +36,15 @@ public class TopologicalBuildingWd {
     private String propertyType;
     @TableField("analyse_time")
     private LocalDateTime analyseTime;
+
+    public TopologicalBuildingWd(WdInfo wdInfo) {
+        this.aroundWdId = wdInfo.getWdId();
+        this.aroundWdName = wdInfo.getWdName();
+        this.aroundWdTypeCode = wdInfo.getWdTypeCode();
+        this.addrCode = wdInfo.getAddrCode();
+        this.addrInfo = wdInfo.getAddrInfo();
+    }
+
+    public TopologicalBuildingWd() {
+    }
 }

+ 11 - 4
benyun-core/src/main/java/com/benyun/core/entity/TopologicalEnterpriseWd.java

@@ -10,10 +10,6 @@ import java.time.LocalDateTime;
 @Data
 @TableName("bl_topological_enterprise_wd_list")
 public class TopologicalEnterpriseWd {
-    @TableField("center_wd_id")
-    private String centerWdId;
-    @TableField("radius")
-    private int radius;
     @TableField("around_wd_id")
     private String aroundWdId;
     @TableField("around_wd_name")
@@ -38,4 +34,15 @@ public class TopologicalEnterpriseWd {
 
     @TableField("analyse_time")
     private LocalDateTime analyseTime;
+
+    public TopologicalEnterpriseWd(WdInfo wdInfo) {
+        this.aroundWdId = wdInfo.getWdId();
+        this.aroundWdName = wdInfo.getWdName();
+        this.aroundWdTypeCode = wdInfo.getWdTypeCode();
+        this.addrCode = wdInfo.getAddrCode();
+        this.addrInfo = wdInfo.getAddrInfo();
+    }
+
+    public TopologicalEnterpriseWd() {
+    }
 }

+ 12 - 4
benyun-core/src/main/java/com/benyun/core/entity/TopologicalHouseWd.java

@@ -11,10 +11,6 @@ import java.time.LocalDateTime;
 @TableName("bl_topological_house_wd_list")
 public class TopologicalHouseWd {
 
-    @TableField("center_wd_id")
-    public String centerWdId;
-    @TableField("radius")
-    public int radius;
     @TableField("around_wd_id")
     public String aroundWdId;
     @TableField("around_wd_name")
@@ -47,4 +43,16 @@ public class TopologicalHouseWd {
 
     @TableField("analyse_time")
     private LocalDateTime analyseTime;
+
+    public TopologicalHouseWd(WdInfo wdInfo) {
+        this.aroundWdId = wdInfo.getWdId();
+        this.aroundWdName = wdInfo.getWdName();
+        this.aroundWdTypeCode = wdInfo.getWdTypeCode();
+        this.addrCode = wdInfo.getAddrCode();
+        this.addrInfo = wdInfo.getAddrInfo();
+    }
+
+    public TopologicalHouseWd() {
+
+    }
 }

+ 20 - 13
benyun-core/src/main/java/com/benyun/core/entity/TopologicalStoreWd.java

@@ -7,37 +7,44 @@ import java.time.LocalDateTime;
 
 @Data
 public class TopologicalStoreWd {
-    @TableField("center_wd_id")
-    public String centerWdId;
-    @TableField("radius")
-    public int radius;
     @TableField("around_wd_id")
-    public String aroundWdId;
+    private String aroundWdId;
     @TableField("around_wd_name")
-    public String aroundWdName;
+    private String aroundWdName;
     @TableField("around_wd_type_code")
-    public String aroundWdTypeCode;
+    private String aroundWdTypeCode;
     @TableField("distance")
-    public double distance;
+    private double distance;
 
     @TableField("addr_code")
-    public String addrCode;
+    private String addrCode;
 
     @TableField("addr_code_info")
-    public String addrCodeInfo;
+    private String addrCodeInfo;
 
     @TableField("addr_info")
-    public String addrInfo;
+    private String addrInfo;
 
     @TableField("industry_code")
-    public String industryCode;
+    private String industryCode;
 
     @TableField("manage_type_code")
-    public String manageTypeCode;
+    private String manageTypeCode;
 
     @TableField("analyse_time")
     private LocalDateTime analyseTime;
 
     @TableField("brand_id")
     private String brandId;
+
+    public TopologicalStoreWd(WdInfo wdInfo) {
+        this.aroundWdId = wdInfo.getWdId();
+        this.aroundWdName = wdInfo.getWdName();
+        this.aroundWdTypeCode = wdInfo.getWdTypeCode();
+        this.addrCode = wdInfo.getAddrCode();
+        this.addrInfo = wdInfo.getAddrInfo();
+    }
+
+    public TopologicalStoreWd() {
+    }
 }

+ 0 - 31
benyun-core/src/main/java/com/benyun/core/entity/WdTopological.java

@@ -21,35 +21,4 @@ public class WdTopological {
     @TableField("analyse_time")
     private LocalDateTime analyseTime;
 
-//    @TableField("center_wd_id")
-//    private String centerWdId;
-//    @TableField("center_wd_name")
-//    private String centerWdName;
-//    @TableField("radius")
-//    private int radius;
-//    @TableField("around_wd_id")
-//    private String aroundWdId;
-//    @TableField("around_wd_name")
-//    private String aroundWdName;
-//    @TableField("around_wd_type_code")
-//    private String aroundWdTypeCode;
-//    @TableField("around_type_code_by")
-//    private String aroundTypeCodeBy;
-//    @TableField("distance")
-//    private double distance;
-//    @TableField("addr_code")
-//    private String addrCode;
-//    @TableField("addr_code_info")
-//    private String addrCodeInfo;
-//    @TableField("addr_info")
-//    private String addrInfo;
-//    @TableField("lat")
-//    private BigDecimal lat;
-//    @TableField("lng")
-//    private BigDecimal lng;
-//    @TableField("geo_hash")
-//    private String geoHash;
-//
-//    @TableField("analyse_time")
-//    private LocalDateTime analyseTime;
 }

+ 1 - 1
benyun-core/src/main/java/com/benyun/core/entity/bo/StoreWdCategoryCount.java

@@ -6,7 +6,7 @@ import java.util.List;
 
 @Data
 public class StoreWdCategoryCount {
-    private String manage_type_code;
+    private String manageTypeCode;
 
     private String name;
     private List<StoreWdCategoryCountBody> storeWdCategoryCountBodyList;

+ 1 - 1
benyun-core/src/main/java/com/benyun/core/entity/bo/StoreWdCategoryCountBody.java

@@ -5,7 +5,7 @@ import lombok.Data;
 @Data
 public class StoreWdCategoryCountBody {
 
-    private String manage_type_code;
+    private String manageTypeCode;
     private String name;
     private int count;
     private double radio;

+ 17 - 4
benyun-core/src/main/java/com/benyun/core/entity/vo/TopologicalWdAceeptVo.java

@@ -15,15 +15,28 @@ public class TopologicalWdAceeptVo {
     String centerWdId;
     @NotNull(groups = {TopologicalWdGroup.class,TopologicalWdListGroup.class},message = "半径范围未正确选择")
     int radius;
-    int pageNum = 1;
-    int pageSize = 10;
+    int size = 10;
+
+    @NotBlank(groups = {TopologicalWdListGroup.class},message = "geoHash不能为空")
+    String geoHash;
+
+    @NotNull(groups = {TopologicalWdListGroup.class},message = "lat不能为空")
+    double lat;
+    @NotNull(groups = {TopologicalWdListGroup.class},message = "lng不能为空")
+    double lng;
+
+    @NotNull(groups = {TopologicalWdListGroup.class},message = "aroundChannel不能为空")
+    String aroundChannel;
+
 
     public String getHash(){
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.append(centerWdId);
         stringBuilder.append(radius);
-        stringBuilder.append(pageNum);
-        stringBuilder.append(pageSize);
+        stringBuilder.append(size);
+        stringBuilder.append(geoHash);
+        stringBuilder.append(lat);
+        stringBuilder.append(lng);
 
         String s = stringBuilder.toString();
         String md5 = HashUtil.hash(s, "MD5");

+ 3 - 3
benyun-core/src/main/java/com/benyun/core/init/BenyunCoreInit.java

@@ -42,10 +42,10 @@ public class BenyunCoreInit {
 
     @Bean("ManageType")
     public HashMap getManageType(){
-        HashMap<String,String> hashMap = new HashMap<>();
+        HashMap<String,ManageType> hashMap = new HashMap<>();
         for (ManageType datum : manageTypeService.getData()) {
-            if(!datum.getMidCategory().equals(""))
-                hashMap.put(datum.getMidCategory(),datum.getManageTypeCode());
+            if(!datum.getManageTypeCode().equals(""))
+                hashMap.put(datum.getManageTypeCode(),datum);
         }
         return hashMap;
     }

+ 54 - 0
benyun-core/src/main/java/com/benyun/core/job/AnalyseJob.java

@@ -0,0 +1,54 @@
+package com.benyun.core.job;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.benyun.core.dao.WdInfoDao;
+import com.benyun.core.entity.WdInfo;
+import com.benyun.core.service.AnalyseWdService;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+@Component
+public class AnalyseJob implements Job {
+
+    @Autowired
+    AnalyseWdService analyseWdService;
+
+    public static ExecutorService executor = Executors.newFixedThreadPool(10);
+
+    @Autowired
+    WdInfoDao wdInfoDao;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        ZoneId zone = ZoneId.of("Asia/Shanghai");
+        LocalDateTime now = LocalDateTime.now(zone);  //分析时间
+
+        System.out.println("start:");
+
+        //测试需要
+        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.in("wd_type_code", Arrays.asList("1","2","3"));
+
+        List<WdInfo> wdInfos1 = wdInfoDao.selectList(queryWrapper1);
+        int index = 1;
+        System.out.println(wdInfos1.size());
+        //1.遍历所有网点
+        for (WdInfo wdInfo : wdInfos1) {
+            analyseWdService.analyse(wdInfo,now,wdInfos1.size(),index++);
+        }
+    }
+}

+ 5 - 1
benyun-core/src/main/java/com/benyun/core/service/AnalyseWdService.java

@@ -1,5 +1,9 @@
 package com.benyun.core.service;
 
+import com.benyun.core.entity.WdInfo;
+
+import java.time.LocalDateTime;
+
 public interface AnalyseWdService {
-    public void analyse();
+    public void analyse(WdInfo wdInfo, LocalDateTime now, int size, int index);
 }

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

@@ -9,5 +9,5 @@ import java.util.List;
 
 public interface TopologicalBuildWdSerevice {
     public List<BuildWdCategoryCount> buildingLevel(TopologicalWdAceeptVo topologicalWdAceeptVo);
-    public PageInfo<TopologicalBuildingWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
+    public List<TopologicalBuildingWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
 }

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

@@ -4,6 +4,8 @@ import com.benyun.core.entity.TopologicalEnterpriseWd;
 import com.benyun.core.entity.vo.TopologicalWdAceeptVo;
 import com.github.pagehelper.PageInfo;
 
+import java.util.List;
+
 public interface TopologicalEnterpriseWdService {
-    public PageInfo<TopologicalEnterpriseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
+    public List<TopologicalEnterpriseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
 }

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

@@ -10,7 +10,7 @@ import com.github.pagehelper.PageInfo;
 import java.util.List;
 
 public interface TopologicalHouseWdService {
-    public PageInfo<TopologicalHouseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
+    public List<TopologicalHouseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
 
     public TopologicalHouseWdStatisticsData info(TopologicalWdAceeptVo topologicalWdAceeptVo);
 }

+ 3 - 2
benyun-core/src/main/java/com/benyun/core/service/TopologicalStoreWdService.java

@@ -2,6 +2,7 @@ package com.benyun.core.service;
 
 
 import com.benyun.core.entity.TopologicalStoreWd;
+import com.benyun.core.entity.bo.StoreWdCategoryCount;
 import com.benyun.core.entity.bo.StoreWdCategoryCountBody;
 import com.benyun.core.entity.vo.TopologicalWdAceeptVo;
 import com.github.pagehelper.PageInfo;
@@ -9,7 +10,7 @@ import com.github.pagehelper.PageInfo;
 import java.util.List;
 
 public interface TopologicalStoreWdService {
-    public PageInfo<TopologicalStoreWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
+    public List<TopologicalStoreWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
 
-    List<StoreWdCategoryCountBody> category(TopologicalWdAceeptVo topologicalWdAceeptVo);
+    List<StoreWdCategoryCount> category(TopologicalWdAceeptVo topologicalWdAceeptVo);
 }

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

@@ -13,4 +13,6 @@ 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);
 }

+ 468 - 158
benyun-core/src/main/java/com/benyun/core/service/impl/AnalyseWdServiceImpl.java

@@ -9,6 +9,7 @@ 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;
 
@@ -71,6 +72,11 @@ public class AnalyseWdServiceImpl implements AnalyseWdService {
     WdTopologicalInfoDao wdTopologicalInfoDao;
 
 
+    @Autowired
+    @Qualifier("addrCodeMap")
+    HashMap<String,String> addrCodeMap;
+
+
 //    @Override
 //    public void analyse() {
 //        ZoneId zone = ZoneId.of("Asia/Shanghai");
@@ -449,19 +455,419 @@ public class AnalyseWdServiceImpl implements AnalyseWdService {
 //        }
 //    }
 
+//    @Override
+//    public void analyse() {
+//        ZoneId zone = ZoneId.of("Asia/Shanghai");
+//        LocalDateTime now = LocalDateTime.now(zone);  //分析时间
+//
+//        //测试需要
+//        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
+//        queryWrapper1.eq("wd_type_code", "5");
+//
+//        List<WdInfo> wdInfos1 = wdInfoDao.selectList(queryWrapper1);
+//        int index = 1;
+//        //1.遍历所有网点
+//        for (WdInfo wdInfo : wdInfos1) {
+//            //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<>();
+//            List<TopologicalEnterpriseWd> topologicalEnterpriseWds = new ArrayList<>();
+//            List<TopologicalStoreWd> topologicalStoreWds = new ArrayList<>();
+//            List<TopologicalHouseWd> topologicalHouseWds = new ArrayList<>();
+//            List<TopologicalBuildingWd> topologicalBuildingWds = new ArrayList<>();
+//
+//            System.out.println("初始化完成------总进度:" + wdInfos1.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放入满足半径的区域
+//                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")) {
+//                    //门店网点
+//                    TopologicalStoreWd topologicalStoreWd = new TopologicalStoreWd();
+//                    topologicalStoreWd.setCenterWdId(wdTopological.getCenterWdId());
+//                    topologicalStoreWd.setRadius(r);
+//
+//                    topologicalStoreWd.setAroundWdId(wdToologicalItem.getAroundWdId());
+//                    topologicalStoreWd.setAroundWdName(wdToologicalItem.getAroundWdName());
+//                    topologicalStoreWd.setAroundWdTypeCode(wdToologicalItem.getAroundWdTypeCode());
+//
+//                    topologicalStoreWd.setAddrCode(wdToologicalItem.getAddrCode());
+//                    topologicalStoreWd.setAddrCodeInfo(wdToologicalItem.getAddrCodeInfo());
+//                    topologicalStoreWd.setAddrInfo(wdToologicalItem.getAddrInfo());
+//
+//                    topologicalStoreWd.setDistance(wdToologicalItem.getDistance());
+//
+//                    //门店分析
+//                    StoreWd storeWd = storeWdDao.selectById(info.getWdId());
+//                    if (storeWd != null) {
+//                        topologicalStoreWd.setIndustryCode(storeWd.getIndustryCode());
+//                        String manageTypeCode = storeWd.getManageTypeCode();
+//                        topologicalStoreWd.setManageTypeCode(manageTypeCode);
+//                        topologicalStoreWd.setBrandId(storeWd.getBrandId());
+//
+//                        //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);
+//                                }
+//                            }
+//                        }
+//
+//                    }
+//
+//                    topologicalStoreWd.setAnalyseTime(wdTopological.getAnalyseTime());
+//                    topologicalStoreWds.add(topologicalStoreWd);
+//                } else if (wdToologicalItem.getAroundWdTypeCode().equals("2")) {
+//                    //小区网点
+//                    TopologicalHouseWd topologicalHouseWd = new TopologicalHouseWd();
+//                    topologicalHouseWd.setCenterWdId(wdTopological.getCenterWdId());
+//                    topologicalHouseWd.setRadius(r);
+//
+//                    topologicalHouseWd.setAroundWdId(wdToologicalItem.getAroundWdId());
+//                    topologicalHouseWd.setAroundWdName(wdToologicalItem.getAroundWdName());
+//                    topologicalHouseWd.setAroundWdTypeCode(wdToologicalItem.getAroundWdTypeCode());
+//
+//                    topologicalHouseWd.setAddrCode(wdToologicalItem.getAddrCode());
+//                    topologicalHouseWd.setAddrCodeInfo(wdToologicalItem.getAddrCodeInfo());
+//                    topologicalHouseWd.setAddrInfo(wdToologicalItem.getAddrInfo());
+//
+//                    topologicalHouseWd.setDistance(wdToologicalItem.getDistance());
+//
+//                    //小区分析
+//                    HouseWd houseWd = houseWdDao.selectById(info.getWdId());
+//                    if (houseWd != null) {
+//                        topologicalHouseWd.setHouseholds(houseWd.getHouseholds());
+//                        topologicalHouseWd.setRent(info.getRent());
+//                        topologicalHouseWd.setPeopleCount(houseWd.getPeopleCount());
+//                        topologicalHouseWd.setPropertyType(houseWd.getPropertyType());
+//                    }
+//
+//                    //小区关键信息
+//                    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") + topologicalHouseWd.getRent());
+//                            houseDatum.put("totalHouseholds", houseDatum.get("totalHouseholds") + topologicalHouseWd.getHouseholds());
+//                            houseDatum.put("totalPeopleCount", houseDatum.get("totalPeopleCount") + topologicalHouseWd.getPeopleCount());
+//                        }
+//                    }
+//
+//                    topologicalHouseWd.setAnalyseTime(wdTopological.getAnalyseTime());
+//                    topologicalHouseWds.add(topologicalHouseWd);
+//                } else if (wdToologicalItem.getAroundWdTypeCode().equals("3")) {
+//                    //楼宇网点
+//                    TopologicalBuildingWd topologicalBuildingWd = new TopologicalBuildingWd();
+//                    topologicalBuildingWd.setCenterWdId(wdTopological.getCenterWdId());
+//                    topologicalBuildingWd.setRadius(r);
+//
+//                    topologicalBuildingWd.setAroundWdId(wdToologicalItem.getAroundWdId());
+//                    topologicalBuildingWd.setAroundWdName(wdToologicalItem.getAroundWdName());
+//                    topologicalBuildingWd.setAroundWdTypeCode(wdToologicalItem.getAroundWdTypeCode());
+//
+//                    topologicalBuildingWd.setAddrCode(wdToologicalItem.getAddrCode());
+//                    topologicalBuildingWd.setAddrCodeInfo(wdToologicalItem.getAddrCodeInfo());
+//                    topologicalBuildingWd.setAddrInfo(wdToologicalItem.getAddrInfo());
+//
+//                    topologicalBuildingWd.setDistance(wdToologicalItem.getDistance());
+//
+//                    //楼宇分析
+//                    BuildWd buildWd = buildWdDao.selectById(info.getWdId());
+//                    if (buildWd != null) {
+//                        //topologicalBuildingWd.setRent(info.getRent());  先不分析房租
+//                        topologicalBuildingWd.setBuildType(buildWd.getBuildType());
+//                        topologicalBuildingWd.setPropertyType(buildWd.getPropertyType());
+//
+//                        //分析楼宇分类
+//                        if (topologicalBuildingWd.getPropertyType() != null && !topologicalBuildingWd.getPropertyType().equals("")) {
+//                            for(int i=p;i>=0;i--){
+//                                HashMap<String, Integer> buildCategoryMap = buildCategory[i];
+//                                Integer integer = buildCategoryMap.get(topologicalBuildingWd.getPropertyType());
+//                                if (integer == null) {
+//                                    buildCategoryMap.put(topologicalBuildingWd.getPropertyType(), 1);
+//                                } else
+//                                    buildCategoryMap.put(topologicalBuildingWd.getPropertyType(), buildCategoryMap.get(topologicalBuildingWd.getPropertyType()) + 1);
+//                            }
+//                        }
+//                    }
+//
+//                    topologicalBuildingWd.setAnalyseTime(wdTopological.getAnalyseTime());
+//                    topologicalBuildingWds.add(topologicalBuildingWd);
+//                } else if (wdToologicalItem.getAroundWdTypeCode().equals("5")) {
+//                    //公司网点
+//                    TopologicalEnterpriseWd topologicalEnterpriseWd = new TopologicalEnterpriseWd();
+//                    topologicalEnterpriseWd.setCenterWdId(wdTopological.getCenterWdId());
+//                    topologicalEnterpriseWd.setRadius(r);
+//
+//                    topologicalEnterpriseWd.setAroundWdId(wdToologicalItem.getAroundWdId());
+//                    topologicalEnterpriseWd.setAroundWdName(wdToologicalItem.getAroundWdName());
+//                    topologicalEnterpriseWd.setAroundWdTypeCode(wdToologicalItem.getAroundWdTypeCode());
+//
+//                    topologicalEnterpriseWd.setAddrCode(wdToologicalItem.getAddrCode());
+//                    topologicalEnterpriseWd.setAddrCodeInfo(wdToologicalItem.getAddrCodeInfo());
+//                    topologicalEnterpriseWd.setAddrInfo(wdToologicalItem.getAddrInfo());
+//
+//                    topologicalEnterpriseWd.setDistance(wdToologicalItem.getDistance());
+//
+//                    //公司分析
+//                    EnterpriseWd enterpriseWd = enterpriseWdDao.selectById(info.getWdId());
+//                    if (enterpriseWd != null) {
+//                        Enterprise enterprise = enterpriseDao.selectById(enterpriseWd.getEnterpriseUsci());
+//                        if (enterprise != null) {
+//                            topologicalEnterpriseWd.setIndustryCode(enterprise.getIndustryCode());
+//                            topologicalEnterpriseWd.setRegisteredCapital(enterprise.getRegisteredCapital());
+//                            topologicalEnterpriseWd.setEnterpriseScale(enterprise.getEnterpriseScale());
+//                        }
+//                    }
+//                    topologicalEnterpriseWd.setAnalyseTime(wdTopological.getAnalyseTime());
+//                    topologicalEnterpriseWds.add(topologicalEnterpriseWd);
+//                }
+//
+//            }
+//
+//            //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.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++) {
+//                WdTopological wdTopological1 = new WdTopological();
+//                wdTopological1.setCenterWdId(wdTopological.getCenterWdId());
+//                wdTopological1.setCenterWdName(wdTopological.getCenterWdName());
+//                wdTopological1.setAnalyseTime(wdTopological.getAnalyseTime());
+//                wdTopological1.setRadius(anly.get(i));
+//                String o = JSON.toJSON(wdToologicalItemList[i]).toString();
+//                wdTopological1.setAroundWdInfo(o);
+//                wdTopologicals.add(wdTopological1);
+//            }
+//
+//            System.out.println("完成------");
+//
+//
+//            //4.导入数据库
+//
+////            wdTopologicalDao.insertList(wdTopologicals);//保存网点拓扑
+////
+////            //4.1 保存拓扑信息
+////            if (!topologicalStoreWds.isEmpty())
+////                topologicalStoreWdDao.insertList(topologicalStoreWds);
+////            if (!topologicalHouseWds.isEmpty())
+////                topologicalHouseWdDao.insertList(topologicalHouseWds);
+////            if (!topologicalBuildingWds.isEmpty())
+////                topologicalBuildWdDao.insertList(topologicalBuildingWds);
+////            if (!topologicalEnterpriseWds.isEmpty()){
+////                topologicalEnterpriseWdDao.insertList(topologicalEnterpriseWds);
+////            }
+////
+////            //4.2 保存其他相关统计信息
+////            if (!houseWdStatisticsDataList.isEmpty())
+////                houseWdStatisticsDataDao.insertList(houseWdStatisticsDataList);
+////            if (!storeWdStatisticsCategoryList.isEmpty())
+////                storeWdStatisticsCategoryDao.insertList(storeWdStatisticsCategoryList);
+////            if (!buildWdStatisticsCategoryList.isEmpty())
+////                buildWdStatisticsCategoryDao.insertList(buildWdStatisticsCategoryList);
+////            if (!wdTopologicalInfoList.isEmpty())
+////                wdTopologicalInfoDao.insertList(wdTopologicalInfoList);
+//
+//        }
+//    }
     @Override
-    public void analyse() {
-        ZoneId zone = ZoneId.of("Asia/Shanghai");
-        LocalDateTime now = LocalDateTime.now(zone);  //分析时间
-
-        //测试需要
-        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
-        queryWrapper1.eq("wd_type_code", "5");
-
-        List<WdInfo> wdInfos1 = wdInfoDao.selectList(queryWrapper1);
-        int index = 1;
-        //1.遍历所有网点
-        for (WdInfo wdInfo : wdInfos1) {
+    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));
@@ -495,12 +901,7 @@ public class AnalyseWdServiceImpl implements AnalyseWdService {
 
             //各拓扑网点集合
             List<WdTopological> wdTopologicals = new ArrayList<>();
-            List<TopologicalEnterpriseWd> topologicalEnterpriseWds = new ArrayList<>();
-            List<TopologicalStoreWd> topologicalStoreWds = new ArrayList<>();
-            List<TopologicalHouseWd> topologicalHouseWds = new ArrayList<>();
-            List<TopologicalBuildingWd> topologicalBuildingWds = new ArrayList<>();
-
-            System.out.println("初始化完成------总进度:" + wdInfos1.size() + "/" + index++);
+            System.out.println("process:" + size + "/" + index);
 
             //WdTopological
             WdTopological wdTopological = new WdTopological();
@@ -542,7 +943,7 @@ public class AnalyseWdServiceImpl implements AnalyseWdService {
                 WdToologicalItem wdToologicalItem = new WdToologicalItem();
                 wdToologicalItem.setAroundWdId(info.getWdId());
                 wdToologicalItem.setAroundWdName(info.getWdName());
-                wdToologicalItem.setAddrCodeInfo(info.getAddrInfo());
+                wdToologicalItem.setAddrCodeInfo(addrCodeMap.get(info.getAddrCode()));
                 wdToologicalItem.setAddrCode(info.getAddrCode());
                 wdToologicalItem.setAddrInfo(info.getAddrInfo());
                 wdToologicalItem.setLat(info.getLat());
@@ -552,7 +953,9 @@ public class AnalyseWdServiceImpl implements AnalyseWdService {
                 wdToologicalItem.setDistance(meter2);
 
                 //3.3 将WdTologicalItem放入满足半径的区域
-                wdToologicalItemList[p].add(wdToologicalItem);
+                for(int i=p;i>=0;i--){
+                    wdToologicalItemList[p].add(wdToologicalItem);
+                }
 
                 //3.4 犇云标签统计
                 if (info.getTypeCodeBy() != null && !info.getTypeCodeBy().equals("")) {
@@ -567,29 +970,12 @@ public class AnalyseWdServiceImpl implements AnalyseWdService {
                     }
                 }
 
-                if (wdToologicalItem.getAroundWdTypeCode().equals("1")) {
-                    //门店网点
-                    TopologicalStoreWd topologicalStoreWd = new TopologicalStoreWd();
-                    topologicalStoreWd.setCenterWdId(wdTopological.getCenterWdId());
-                    topologicalStoreWd.setRadius(r);
-
-                    topologicalStoreWd.setAroundWdId(wdToologicalItem.getAroundWdId());
-                    topologicalStoreWd.setAroundWdName(wdToologicalItem.getAroundWdName());
-                    topologicalStoreWd.setAroundWdTypeCode(wdToologicalItem.getAroundWdTypeCode());
-
-                    topologicalStoreWd.setAddrCode(wdToologicalItem.getAddrCode());
-                    topologicalStoreWd.setAddrCodeInfo(wdToologicalItem.getAddrCodeInfo());
-                    topologicalStoreWd.setAddrInfo(wdToologicalItem.getAddrInfo());
-
-                    topologicalStoreWd.setDistance(wdToologicalItem.getDistance());
 
+                if (wdToologicalItem.getAroundWdTypeCode().equals("1")) {
                     //门店分析
                     StoreWd storeWd = storeWdDao.selectById(info.getWdId());
                     if (storeWd != null) {
-                        topologicalStoreWd.setIndustryCode(storeWd.getIndustryCode());
                         String manageTypeCode = storeWd.getManageTypeCode();
-                        topologicalStoreWd.setManageTypeCode(manageTypeCode);
-                        topologicalStoreWd.setBrandId(storeWd.getBrandId());
 
                         //TODO 分析经营分类
                         if (manageTypeCode != null && !manageTypeCode.equals("")) {
@@ -599,6 +985,7 @@ public class AnalyseWdServiceImpl implements AnalyseWdService {
                                 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)
@@ -608,36 +995,10 @@ public class AnalyseWdServiceImpl implements AnalyseWdService {
                                 }
                             }
                         }
-
                     }
-
-                    topologicalStoreWd.setAnalyseTime(wdTopological.getAnalyseTime());
-                    topologicalStoreWds.add(topologicalStoreWd);
                 } else if (wdToologicalItem.getAroundWdTypeCode().equals("2")) {
-                    //小区网点
-                    TopologicalHouseWd topologicalHouseWd = new TopologicalHouseWd();
-                    topologicalHouseWd.setCenterWdId(wdTopological.getCenterWdId());
-                    topologicalHouseWd.setRadius(r);
-
-                    topologicalHouseWd.setAroundWdId(wdToologicalItem.getAroundWdId());
-                    topologicalHouseWd.setAroundWdName(wdToologicalItem.getAroundWdName());
-                    topologicalHouseWd.setAroundWdTypeCode(wdToologicalItem.getAroundWdTypeCode());
-
-                    topologicalHouseWd.setAddrCode(wdToologicalItem.getAddrCode());
-                    topologicalHouseWd.setAddrCodeInfo(wdToologicalItem.getAddrCodeInfo());
-                    topologicalHouseWd.setAddrInfo(wdToologicalItem.getAddrInfo());
-
-                    topologicalHouseWd.setDistance(wdToologicalItem.getDistance());
-
                     //小区分析
                     HouseWd houseWd = houseWdDao.selectById(info.getWdId());
-                    if (houseWd != null) {
-                        topologicalHouseWd.setHouseholds(houseWd.getHouseholds());
-                        topologicalHouseWd.setRent(info.getRent());
-                        topologicalHouseWd.setPeopleCount(houseWd.getPeopleCount());
-                        topologicalHouseWd.setPropertyType(houseWd.getPropertyType());
-                    }
-
                     //小区关键信息
                     for(int i=p;i>=0;i--){
                         HashMap<String, Double> houseDatum = houseData[i];
@@ -645,91 +1006,38 @@ public class AnalyseWdServiceImpl implements AnalyseWdService {
 
                         //小区关键信息统计
                         if (houseWd != null) {
-                            houseDatum.put("totalRent", houseDatum.get("totalRent") + topologicalHouseWd.getRent());
-                            houseDatum.put("totalHouseholds", houseDatum.get("totalHouseholds") + topologicalHouseWd.getHouseholds());
-                            houseDatum.put("totalPeopleCount", houseDatum.get("totalPeopleCount") + topologicalHouseWd.getPeopleCount());
+                            houseDatum.put("totalRent", houseDatum.get("totalRent") + info.getRent());
+                            houseDatum.put("totalHouseholds", houseDatum.get("totalHouseholds") + houseWd.getHouseholds());
+                            houseDatum.put("totalPeopleCount", houseDatum.get("totalPeopleCount") + houseWd.getPeopleCount());
                         }
                     }
-
-                    topologicalHouseWd.setAnalyseTime(wdTopological.getAnalyseTime());
-                    topologicalHouseWds.add(topologicalHouseWd);
                 } else if (wdToologicalItem.getAroundWdTypeCode().equals("3")) {
-                    //楼宇网点
-                    TopologicalBuildingWd topologicalBuildingWd = new TopologicalBuildingWd();
-                    topologicalBuildingWd.setCenterWdId(wdTopological.getCenterWdId());
-                    topologicalBuildingWd.setRadius(r);
-
-                    topologicalBuildingWd.setAroundWdId(wdToologicalItem.getAroundWdId());
-                    topologicalBuildingWd.setAroundWdName(wdToologicalItem.getAroundWdName());
-                    topologicalBuildingWd.setAroundWdTypeCode(wdToologicalItem.getAroundWdTypeCode());
-
-                    topologicalBuildingWd.setAddrCode(wdToologicalItem.getAddrCode());
-                    topologicalBuildingWd.setAddrCodeInfo(wdToologicalItem.getAddrCodeInfo());
-                    topologicalBuildingWd.setAddrInfo(wdToologicalItem.getAddrInfo());
-
-                    topologicalBuildingWd.setDistance(wdToologicalItem.getDistance());
-
                     //楼宇分析
                     BuildWd buildWd = buildWdDao.selectById(info.getWdId());
                     if (buildWd != null) {
-                        topologicalBuildingWd.setRent(info.getRent());
-                        topologicalBuildingWd.setBuildType(buildWd.getBuildType());
-                        topologicalBuildingWd.setPropertyType(buildWd.getPropertyType());
-
                         //分析楼宇分类
-                        if (topologicalBuildingWd.getPropertyType() != null && !topologicalBuildingWd.getPropertyType().equals("")) {
+                        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(topologicalBuildingWd.getPropertyType());
+                                Integer integer = buildCategoryMap.get(buildWd.getPropertyType());
                                 if (integer == null) {
-                                    buildCategoryMap.put(topologicalBuildingWd.getPropertyType(), 1);
+                                    buildCategoryMap.put(buildWd.getPropertyType(), 1);
                                 } else
-                                    buildCategoryMap.put(topologicalBuildingWd.getPropertyType(), buildCategoryMap.get(topologicalBuildingWd.getPropertyType()) + 1);
+                                    buildCategoryMap.put(buildWd.getPropertyType(), buildCategoryMap.get(buildWd.getPropertyType()) + 1);
                             }
                         }
                     }
 
-                    topologicalBuildingWd.setAnalyseTime(wdTopological.getAnalyseTime());
-                    topologicalBuildingWds.add(topologicalBuildingWd);
-                } else if (wdToologicalItem.getAroundWdTypeCode().equals("5")) {
-                    //公司网点
-                    TopologicalEnterpriseWd topologicalEnterpriseWd = new TopologicalEnterpriseWd();
-                    topologicalEnterpriseWd.setCenterWdId(wdTopological.getCenterWdId());
-                    topologicalEnterpriseWd.setRadius(r);
-
-                    topologicalEnterpriseWd.setAroundWdId(wdToologicalItem.getAroundWdId());
-                    topologicalEnterpriseWd.setAroundWdName(wdToologicalItem.getAroundWdName());
-                    topologicalEnterpriseWd.setAroundWdTypeCode(wdToologicalItem.getAroundWdTypeCode());
-
-                    topologicalEnterpriseWd.setAddrCode(wdToologicalItem.getAddrCode());
-                    topologicalEnterpriseWd.setAddrCodeInfo(wdToologicalItem.getAddrCodeInfo());
-                    topologicalEnterpriseWd.setAddrInfo(wdToologicalItem.getAddrInfo());
-
-                    topologicalEnterpriseWd.setDistance(wdToologicalItem.getDistance());
-
-                    //公司分析
-                    EnterpriseWd enterpriseWd = enterpriseWdDao.selectById(info.getWdId());
-                    if (enterpriseWd != null) {
-                        Enterprise enterprise = enterpriseDao.selectById(enterpriseWd.getEnterpriseUsci());
-                        if (enterprise != null) {
-                            topologicalEnterpriseWd.setIndustryCode(enterprise.getIndustryCode());
-                            topologicalEnterpriseWd.setRegisteredCapital(enterprise.getRegisteredCapital());
-                            topologicalEnterpriseWd.setEnterpriseScale(enterprise.getEnterpriseScale());
-                        }
-                    }
-                    topologicalEnterpriseWd.setAnalyseTime(wdTopological.getAnalyseTime());
-                    topologicalEnterpriseWds.add(topologicalEnterpriseWd);
                 }
-
             }
 
             //TODO 门店分类
             for (int i = 0; i < anly.size(); i++) {
-                TopologicalStoreWdStatisticsCategory storeWdStatisticsCategory = new TopologicalStoreWdStatisticsCategory();
-                storeWdStatisticsCategory.setCenterWdId(wdInfo.getWdId());
-                storeWdStatisticsCategory.setRadius(anly.get(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);
@@ -802,6 +1110,7 @@ public class AnalyseWdServiceImpl implements AnalyseWdService {
                 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);
@@ -817,44 +1126,45 @@ public class AnalyseWdServiceImpl implements AnalyseWdService {
 
             //TODO 网点拓扑
             for (int i = 0; i < anly.size(); i++) {
-                WdTopological wdTopological1 = new WdTopological();
-                wdTopological1.setCenterWdId(wdTopological.getCenterWdId());
-                wdTopological1.setCenterWdName(wdTopological.getCenterWdName());
-                wdTopological1.setAnalyseTime(wdTopological.getAnalyseTime());
-                wdTopological1.setRadius(anly.get(i));
-                String o = JSON.toJSON(wdToologicalItemList[i]).toString();
-                wdTopological1.setAroundWdInfo(o);
-                wdTopologicals.add(wdTopological1);
+                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);//保存网点拓扑
 
-//            wdTopologicalDao.insertList(wdTopologicals);//保存网点拓扑
-//
-//            //4.1 保存拓扑信息
-//            if (!topologicalStoreWds.isEmpty())
-//                topologicalStoreWdDao.insertList(topologicalStoreWds);
-//            if (!topologicalHouseWds.isEmpty())
-//                topologicalHouseWdDao.insertList(topologicalHouseWds);
-//            if (!topologicalBuildingWds.isEmpty())
-//                topologicalBuildWdDao.insertList(topologicalBuildingWds);
-//            if (!topologicalEnterpriseWds.isEmpty()){
-//                topologicalEnterpriseWdDao.insertList(topologicalEnterpriseWds);
-//            }
-//
-//            //4.2 保存其他相关统计信息
-//            if (!houseWdStatisticsDataList.isEmpty())
-//                houseWdStatisticsDataDao.insertList(houseWdStatisticsDataList);
-//            if (!storeWdStatisticsCategoryList.isEmpty())
-//                storeWdStatisticsCategoryDao.insertList(storeWdStatisticsCategoryList);
-//            if (!buildWdStatisticsCategoryList.isEmpty())
-//                buildWdStatisticsCategoryDao.insertList(buildWdStatisticsCategoryList);
-//            if (!wdTopologicalInfoList.isEmpty())
-//                wdTopologicalInfoDao.insertList(wdTopologicalInfoList);
+
+            //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);
 
         }
-    }
+
 }

+ 100 - 0
benyun-core/src/main/java/com/benyun/core/service/impl/ChannelAnalyseServiceImpl.java

@@ -88,6 +88,105 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         return pageInfo;
     }
 
+//    @Override
+//    public HashMap<String,Object> tagAnalyse(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, 4);
+//                addrCodeList.add(substring);
+//            }
+//        } else if ("zone".equals(channelMapAceeptVo.getRankType())) {
+//            //区
+//            for (String s : channelMapAceeptVo.getAddrCode()) {
+//                String substring = s.substring(0, 6);
+//                addrCodeList.add(substring);
+//            }
+//        } else {
+//            return null;
+//        }
+//
+//
+//        //2.根据地区前缀找到所有的网点
+//        QueryWrapper<WdTopologicalInfo> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.in("center_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("center_wd_name", channelMapAceeptVo.getSearchText());
+//            });
+//        }
+//
+//        queryWrapper.and(wdTopologicalInfoQueryWrapper -> {
+//            wdTopologicalInfoQueryWrapper.eq("radius",1000); //1km内算附近
+//        });
+//        List<WdTopologicalInfo> originWdInfos = wdTopologicalInfoDao.selectList(queryWrapper);
+//
+//        //统计
+//        Integer total = 0 ;
+//        HashMap<String,Integer> hashMap = new HashMap<>();
+//        for (WdTopologicalInfo originWdInfo : originWdInfos) {
+//            String tag = originWdInfo.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];
+//
+//                    if(!t.equals("")) {
+//                        Integer integer = hashMap.get(t);
+//                        if(integer == null)
+//                            hashMap.put(t,1);
+//                        else {
+//                            hashMap.put(t,hashMap.get(t)+1);
+//                        }
+//                        total++;
+//                    }
+//                }
+//            }
+//        }
+//        HashMap<String, Object> result = new HashMap<>();
+//        List<TagAnalyse> list = new ArrayList<>();
+//        for (String s : hashMap.keySet()) {
+//            TagAnalyse tagAnalyse = new TagAnalyse();
+//            tagAnalyse.setName(s);
+//            tagAnalyse.setCount(hashMap.get(s));
+//            tagAnalyse.setRadio((double)tagAnalyse.getCount()/total);
+//            list.add(tagAnalyse);
+//        }
+//
+//        Collections.sort(list, new Comparator<TagAnalyse>() {
+//            @Override
+//            public int compare(TagAnalyse o1, TagAnalyse o2) {
+//                return o2.getCount() - o1.getCount();
+//            }
+//        });
+//
+//        result.put("total",total);
+//        result.put("data",list);
+//        return result;
+//    }
+
     @Override
     public HashMap<String,Object> tagAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
         //1.根据不同级别得到地区码
@@ -187,6 +286,7 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         return result;
     }
 
+
     @Override
     public void businessAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
         //1.根据不同级别得到地区码

+ 61 - 11
benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalBuildWdSereviceImpl.java

@@ -3,22 +3,26 @@ package com.benyun.core.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.benyun.core.dao.TopologicalBuildWdDao;
 import com.benyun.core.dao.TopologicalBuildWdStatisticsCategoryDao;
-import com.benyun.core.entity.TopologicalBuildWdStatisticsCategory;
-import com.benyun.core.entity.TopologicalBuildingWd;
-import com.benyun.core.entity.TopologicalStoreWd;
-import com.benyun.core.entity.TopologicalStoreWdStatisticsCategory;
+import com.benyun.core.dao.WdInfoDao;
+import com.benyun.core.entity.*;
 import com.benyun.core.entity.bo.BuildWdCategoryCount;
 import com.benyun.core.entity.bo.StoreWdCategoryCount;
 import com.benyun.core.entity.bo.StoreWdCategoryCountBody;
 import com.benyun.core.entity.vo.TopologicalWdAceeptVo;
 import com.benyun.core.service.TopologicalBuildWdSerevice;
+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.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 
 @Service
@@ -31,6 +35,13 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
     @Autowired
     TopologicalBuildWdStatisticsCategoryDao topologicalBuildWdStatisticsCategoryDao;
 
+    @Autowired
+    WdInfoDao wdInfoDao;
+
+    @Autowired
+    @Qualifier("addrCodeMap")
+    HashMap<String,String> addrCodeMap;
+
     @Override
     public List<BuildWdCategoryCount> buildingLevel(TopologicalWdAceeptVo topologicalWdAceeptVo) {
         QueryWrapper<TopologicalBuildWdStatisticsCategory> queryWrapper = new QueryWrapper<>();
@@ -42,29 +53,68 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
         List<BuildWdCategoryCount> list = new ArrayList<>();
         TopologicalBuildWdStatisticsCategory topologicalBuildWdStatisticsCategory = topologicalBuildWdStatisticsCategoryDao.selectOne(queryWrapper);
         String propertyTypeStatistics = topologicalBuildWdStatisticsCategory.getPropertyTypeStatistics();
+        if (propertyTypeStatistics == null)
+            return list;
+
         int total = 0;
         for (String s : propertyTypeStatistics.split(";")) {
             BuildWdCategoryCount buildWdCategoryCount = new BuildWdCategoryCount();
             String[] split = s.split(":");
             if (split.length !=2)
                 continue;
-            buildWdCategoryCount.setName(split[1]);
+            buildWdCategoryCount.setName(split[0]);
             buildWdCategoryCount.setCount(Integer.parseInt(split[1]));
             total+=buildWdCategoryCount.getCount();
             list.add(buildWdCategoryCount);
         }
         for (BuildWdCategoryCount buildWdCategoryCount : list) {
-            buildWdCategoryCount.setRadio(buildWdCategoryCount.getCount()/total);
+            BigDecimal bigDecimal = new BigDecimal((double) buildWdCategoryCount.getCount() / total);
+            double v = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+            buildWdCategoryCount.setRadio(v);
         }
         return list;
     }
 
     @Override
-    public PageInfo<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);
+    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.and(wdInfoQueryWrapper -> {
+            wdInfoQueryWrapper.likeRight("geo_hash",topologicalWdAceeptVo.getGeoHash().substring(0,5));
+        });
 
-        return pageInfo;
+        //查询结果
+        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
+        List<TopologicalBuildingWd> list = new ArrayList<>();  //返回结果集
+        GlobalCoordinates source = new GlobalCoordinates(topologicalWdAceeptVo.getLat(), topologicalWdAceeptVo.getLng());
+        for (WdInfo wdInfo : wdInfos) {
+            if(list.size() >= topologicalWdAceeptVo.getSize())
+                break;
+
+            //1.计算距离
+            GlobalCoordinates target = new GlobalCoordinates(wdInfo.getLat().doubleValue(), wdInfo.getLng().doubleValue());
+            double meter2 = DistanceUtil.getDistanceMeter(source, target, Ellipsoid.WGS84);
+
+            if(meter2 <= topologicalWdAceeptVo.getRadius()){
+                TopologicalBuildingWd topologicalBuildingWd = new TopologicalBuildingWd(wdInfo);
+                topologicalBuildingWd.setAddrCodeInfo(addrCodeMap.get(topologicalBuildingWd.getAddrCode()));
+                BigDecimal bigDecimal = new BigDecimal(meter2);
+                topologicalBuildingWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
+
+                //补充公司数据
+                //....
+
+                list.add(topologicalBuildingWd);
+            }
+        }
+        return list;
     }
 }

+ 49 - 5
benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalEnterpriseWdServiceImpl.java

@@ -2,28 +2,72 @@ package com.benyun.core.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.benyun.core.dao.TopologicalEnterpriseWdDao;
+import com.benyun.core.dao.WdInfoDao;
 import com.benyun.core.entity.TopologicalEnterpriseWd;
 import com.benyun.core.entity.TopologicalStoreWd;
+import com.benyun.core.entity.WdInfo;
 import com.benyun.core.entity.vo.TopologicalWdAceeptVo;
 import com.benyun.core.service.TopologicalEnterpriseWdService;
+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.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 
 @Service
 public class TopologicalEnterpriseWdServiceImpl implements TopologicalEnterpriseWdService {
     @Autowired
     TopologicalEnterpriseWdDao topologicalEnterpriseWdDao;
+
+    @Autowired
+    WdInfoDao wdInfoDao;
+
+    @Autowired
+    @Qualifier("addrCodeMap")
+    HashMap<String,String> addrCodeMap;
     @Override
-    public PageInfo<TopologicalEnterpriseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
+    public List<TopologicalEnterpriseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+
+        //条件构造
+        queryWrapper.eq("wd_type_code",topologicalWdAceeptVo.getAroundChannel());
+        queryWrapper.and(wdInfoQueryWrapper -> {
+            wdInfoQueryWrapper.likeRight("geo_hash",topologicalWdAceeptVo.getGeoHash().substring(0,5));
+        });
+
+        //查询结果
+        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
+        List<TopologicalEnterpriseWd> list = new ArrayList<>();  //返回结果集
+        GlobalCoordinates source = new GlobalCoordinates(topologicalWdAceeptVo.getLat(), topologicalWdAceeptVo.getLng());
+        for (WdInfo wdInfo : wdInfos) {
+            if(list.size() >= topologicalWdAceeptVo.getSize())
+                break;
+
+            //1.计算距离
+            GlobalCoordinates target = new GlobalCoordinates(wdInfo.getLat().doubleValue(), wdInfo.getLng().doubleValue());
+            double meter2 = DistanceUtil.getDistanceMeter(source, target, Ellipsoid.WGS84);
+
+            if(meter2 <= topologicalWdAceeptVo.getRadius()){
+                TopologicalEnterpriseWd topologicalEnterpriseWd = new TopologicalEnterpriseWd(wdInfo);
+                topologicalEnterpriseWd.setAddrCodeInfo(addrCodeMap.get(topologicalEnterpriseWd.getAddrCode()));
+                BigDecimal bigDecimal = new BigDecimal(meter2);
+                topologicalEnterpriseWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
 
-        PageHelper.startPage(topologicalWdAceeptVo.getPageNum(), topologicalWdAceeptVo.getPageSize());
-        List<TopologicalEnterpriseWd> topologicalStoreWds = topologicalEnterpriseWdDao.list(topologicalWdAceeptVo.getCenterWdId(), Integer.valueOf(topologicalWdAceeptVo.getRadius()));
-        PageInfo<TopologicalEnterpriseWd> pageInfo = new PageInfo<>(topologicalStoreWds);
+                //补充公司数据
+                //....
 
-        return pageInfo;
+                list.add(topologicalEnterpriseWd);
+            }
+        }
+        return list;
     }
 }

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

@@ -3,16 +3,25 @@ package com.benyun.core.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.benyun.core.dao.TopologicalHouseWdDao;
 import com.benyun.core.dao.TopologicalHouseWdStatisticsDataDao;
+import com.benyun.core.dao.WdInfoDao;
 import com.benyun.core.entity.TopologicalHouseWd;
 import com.benyun.core.entity.TopologicalHouseWdStatisticsData;
 import com.benyun.core.entity.TopologicalStoreWd;
+import com.benyun.core.entity.WdInfo;
 import com.benyun.core.entity.vo.TopologicalWdAceeptVo;
 import com.benyun.core.service.TopologicalHouseWdService;
+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.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 
 @Service
@@ -20,15 +29,52 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
     @Autowired
     TopologicalHouseWdDao topologicalHouseWdDao;
 
+    @Autowired
+    WdInfoDao wdInfoDao;
+
     @Autowired
     TopologicalHouseWdStatisticsDataDao topologicalHouseWdStatisticsDataDao;
 
+    @Autowired
+    @Qualifier("addrCodeMap")
+    HashMap<String,String> addrCodeMap;
+
     @Override
-    public PageInfo<TopologicalHouseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-        PageHelper.startPage(topologicalWdAceeptVo.getPageNum(), topologicalWdAceeptVo.getPageSize());
-        List<TopologicalHouseWd> topologicalStoreWds = topologicalHouseWdDao.list(topologicalWdAceeptVo.getCenterWdId(), Integer.valueOf(topologicalWdAceeptVo.getRadius()));
-        PageInfo<TopologicalHouseWd> pageInfo = new PageInfo<>(topologicalStoreWds);
-        return pageInfo;
+    public List<TopologicalHouseWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+
+        //条件构造
+        queryWrapper.eq("wd_type_code",topologicalWdAceeptVo.getAroundChannel());
+        queryWrapper.and(wdInfoQueryWrapper -> {
+            wdInfoQueryWrapper.likeRight("geo_hash",topologicalWdAceeptVo.getGeoHash().substring(0,5));
+        });
+
+        //查询结果
+        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
+        List<TopologicalHouseWd> list = new ArrayList<>();  //返回结果集
+        GlobalCoordinates source = new GlobalCoordinates(topologicalWdAceeptVo.getLat(), topologicalWdAceeptVo.getLng());
+        for (WdInfo wdInfo : wdInfos) {
+            if(list.size() >= topologicalWdAceeptVo.getSize())
+                break;
+
+            //1.计算距离
+            GlobalCoordinates target = new GlobalCoordinates(wdInfo.getLat().doubleValue(), wdInfo.getLng().doubleValue());
+            double meter2 = DistanceUtil.getDistanceMeter(source, target, Ellipsoid.WGS84);
+
+            if(meter2 <= topologicalWdAceeptVo.getRadius()){
+                TopologicalHouseWd topologicalHouseWd = new TopologicalHouseWd(wdInfo);
+                topologicalHouseWd.setAddrCodeInfo(addrCodeMap.get(topologicalHouseWd.getAddrCode()));
+                BigDecimal bigDecimal = new BigDecimal(meter2);
+                topologicalHouseWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
+
+                //补充门店数据
+                //....
+
+                list.add(topologicalHouseWd);
+            }
+        }
+        return list;
     }
 
     @Override

+ 77 - 36
benyun-core/src/main/java/com/benyun/core/service/impl/TopologicalStoreWdServiceImpl.java

@@ -3,6 +3,8 @@ package com.benyun.core.service.impl;
 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.entity.ManageType;
 import com.benyun.core.entity.TopologicalStoreWd;
 import com.benyun.core.entity.TopologicalStoreWdStatisticsCategory;
 import com.benyun.core.entity.WdInfo;
@@ -10,12 +12,16 @@ import com.benyun.core.entity.bo.StoreWdCategoryCount;
 import com.benyun.core.entity.bo.StoreWdCategoryCountBody;
 import com.benyun.core.entity.vo.TopologicalWdAceeptVo;
 import com.benyun.core.service.TopologicalStoreWdService;
+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.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -24,66 +30,101 @@ import java.util.List;
 public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService {
 
     @Autowired
-    TopologicalStoreWdDao topologicalStoreWdDao;
+    TopologicalStoreWdStatisticsCategoryDao storeWdStatisticsCategoryDao;
 
     @Autowired
-    TopologicalStoreWdStatisticsCategoryDao storeWdStatisticsCategoryDao;
+    WdInfoDao wdInfoDao;
 
     @Autowired
     @Qualifier("ManageType")
-    HashMap<String,String> manageType;
+    HashMap<String, ManageType> manageType;
+
+    @Autowired
+    @Qualifier("addrCodeMap")
+    HashMap<String,String> addrCodeMap;
+
 
     @Override
-    public PageInfo<TopologicalStoreWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
-        PageHelper.startPage(topologicalWdAceeptVo.getPageNum(), topologicalWdAceeptVo.getPageSize());
-        List<TopologicalStoreWd> topologicalStoreWds = topologicalStoreWdDao.list(topologicalWdAceeptVo.getCenterWdId(), Integer.valueOf(topologicalWdAceeptVo.getRadius()));
-        PageInfo<TopologicalStoreWd> pageInfo = new PageInfo<>(topologicalStoreWds);
-        return pageInfo;
+    public List<TopologicalStoreWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo) {
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+
+        //条件构造
+        queryWrapper.eq("wd_type_code",topologicalWdAceeptVo.getAroundChannel());
+        queryWrapper.and(wdInfoQueryWrapper -> {
+            wdInfoQueryWrapper.likeRight("geo_hash",topologicalWdAceeptVo.getGeoHash().substring(0,5));
+        });
+
+        //查询结果
+        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
+        List<TopologicalStoreWd> list = new ArrayList<>();  //返回结果集
+        GlobalCoordinates source = new GlobalCoordinates(topologicalWdAceeptVo.getLat(), topologicalWdAceeptVo.getLng());
+        for (WdInfo wdInfo : wdInfos) {
+            if(list.size() >= topologicalWdAceeptVo.getSize())
+                break;
+
+            //1.计算距离
+            GlobalCoordinates target = new GlobalCoordinates(wdInfo.getLat().doubleValue(), wdInfo.getLng().doubleValue());
+            double meter2 = DistanceUtil.getDistanceMeter(source, target, Ellipsoid.WGS84);
+
+            if(meter2 <= topologicalWdAceeptVo.getRadius()){
+                TopologicalStoreWd topologicalStoreWd = new TopologicalStoreWd(wdInfo);
+                topologicalStoreWd.setAddrCodeInfo(addrCodeMap.get(topologicalStoreWd.getAddrCode()));
+                BigDecimal bigDecimal = new BigDecimal(meter2);
+                topologicalStoreWd.setDistance(bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
+
+                //补充门店数据
+                //....
+
+                list.add(topologicalStoreWd);
+            }
+        }
+        return list;
     }
 
-    //TODO 需要优化
+    //TODO 未返回total
     @Override
-    public List<StoreWdCategoryCountBody> category(TopologicalWdAceeptVo topologicalWdAceeptVo) {
+    public List<StoreWdCategoryCount> category(TopologicalWdAceeptVo topologicalWdAceeptVo) {
 
-        List<StoreWdCategoryCountBody> storeWdCategoryCountBodyList = new ArrayList<>();
         List<StoreWdCategoryCount> storeWdCategoryCounts = new ArrayList<>();
 
-        int index1 = 0;
-        List<TopologicalStoreWdStatisticsCategory> statisticsCategories = storeWdStatisticsCategoryDao.category(topologicalWdAceeptVo.getCenterWdId(),Integer.valueOf(topologicalWdAceeptVo.getRadius()));
+        int total = 0;
+        List<TopologicalStoreWdStatisticsCategory> statisticsCategories = storeWdStatisticsCategoryDao.category(topologicalWdAceeptVo);
         for (TopologicalStoreWdStatisticsCategory statisticsCategory : statisticsCategories) {
-            StoreWdCategoryCountBody storeWdCategoryCountBody = new StoreWdCategoryCountBody();
-            storeWdCategoryCountBody.setName(manageType.get(statisticsCategory.getMidManageTypeCode()));
-            storeWdCategoryCountBody.setManage_type_code(statisticsCategory.getMidManageTypeCode());
+            StoreWdCategoryCount storeWdCategoryCount = new StoreWdCategoryCount();
+
+            String midManageTypeCode = statisticsCategory.getMidManageTypeCode();
+            String[] split1 = midManageTypeCode.split(":");
+            storeWdCategoryCount.setManageTypeCode(split1[0]+"00");
+            ManageType manageType1 = manageType.get(storeWdCategoryCount.getManageTypeCode());
+            storeWdCategoryCount.setName(manageType1.getMidCategory());
+            storeWdCategoryCount.setCount(Integer.parseInt(split1[1]));
+            total+=storeWdCategoryCount.getCount();
 
             //拆分
-            int index2 = 0;
             String subCategoryCodeStatistics = statisticsCategory.getSubCategoryCodeStatistics();
+            List<StoreWdCategoryCountBody> storeWdCategoryCountBodyList = new ArrayList<>();
             for (String s : subCategoryCodeStatistics.split(";")) {
-                StoreWdCategoryCount storeWdCategoryCount = new StoreWdCategoryCount();
                 String[] split = s.split(":");
                 if (split.length !=2)
                     continue;
-                storeWdCategoryCount.setName(manageType.get(split[0]));
-                storeWdCategoryCount.setCount(Integer.parseInt(split[1]));
-                index2+=storeWdCategoryCount.getCount();
-                storeWdCategoryCounts.add(storeWdCategoryCount);
-            }
-            storeWdCategoryCountBody.setCount(index2);
+                if(split[0].equals(storeWdCategoryCount.getManageTypeCode()))
+                    break;
 
-            //计算radio
-            for (StoreWdCategoryCount storeWdCategoryCount : storeWdCategoryCounts) {
-                storeWdCategoryCount.setRadio(storeWdCategoryCount.getCount()/index2);
+                StoreWdCategoryCountBody storeWdCategoryCountBody = new StoreWdCategoryCountBody();
+                storeWdCategoryCountBody.setManageTypeCode(split[0]);
+                ManageType manageType2 = manageType.get(storeWdCategoryCountBody.getManageTypeCode());
+                storeWdCategoryCountBody.setName(manageType2.getSubCategory());
+                storeWdCategoryCountBody.setCount(Integer.parseInt(split[1]));
+                BigDecimal bigDecimal = new BigDecimal((double) storeWdCategoryCount.getCount() / storeWdCategoryCountBody.getCount());
+                double v = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+                storeWdCategoryCountBody.setRadio(v);
+                storeWdCategoryCountBodyList.add(storeWdCategoryCountBody);
             }
-
-            index1+=index2;
-            storeWdCategoryCountBodyList.add(storeWdCategoryCountBody);
-        }
-
-        //计算radio
-        for (StoreWdCategoryCountBody storeWdCategoryCountBody : storeWdCategoryCountBodyList) {
-            storeWdCategoryCountBody.setRadio(storeWdCategoryCountBody.getCount()/index1);
+            storeWdCategoryCount.setStoreWdCategoryCountBodyList(storeWdCategoryCountBodyList);
+            storeWdCategoryCounts.add(storeWdCategoryCount);
         }
 
-        return storeWdCategoryCountBodyList;
+        return storeWdCategoryCounts;
     }
 }

+ 44 - 0
benyun-core/src/main/java/com/benyun/core/service/impl/WdInfoServiceImpl.java

@@ -14,8 +14,11 @@ import com.benyun.core.entity.vo.TypeByBody;
 import com.benyun.core.entity.vo.WdInfoVo;
 import com.benyun.core.service.CategoryService;
 import com.benyun.core.service.WdInfoService;
+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.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
@@ -175,4 +178,45 @@ public class WdInfoServiceImpl implements WdInfoService {
         return list;
     }
 
+    @Override
+    public List<WdInfo> map(String wdId,int r,int size,String wd_type_code) {
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("wd_id", wdId);
+        WdInfo wdInfo = wdInfoMapper.selectOne(queryWrapper);
+
+        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.select("wd_id","wd_name","addr_info","type_name_by","wd_type_code","lat","lng","geo_hash");
+        queryWrapper1.eq("wd_type_code",wd_type_code);
+        queryWrapper1.and(wdInfoQueryWrapper -> {
+            wdInfoQueryWrapper.likeRight("geo_hash", wdInfo.getGeoHash().substring(0, 5));
+        });
+        List<WdInfo> wdInfos = wdInfoMapper.selectList(queryWrapper1);
+
+        System.out.println(wdInfos.size());
+
+        List<WdInfo> map = new ArrayList<>();
+        for (WdInfo info : wdInfos) {
+            if(map.size() == size)
+                break;
+
+            //网点等于自己不要
+            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 > r)
+                continue;
+
+            map.add(info);
+        }
+        System.out.println(map.size());
+        return map;
+
+    }
+
 }

+ 7 - 16
benyun-core/src/main/resources/application-dev.yaml

@@ -78,7 +78,7 @@ spring:
     sharding:
       tables:
         bl_wd_topological:
-          actual-data-nodes: ds1.bl_wd_topological_$->{1..10}
+          actual-data-nodes: ds1.bl_wd_topological_$->{1..20}
           key-generator:
             column: center_wd_id
             type: SNOWFLAKE
@@ -86,8 +86,8 @@ spring:
             standard:
               sharding-column: center_wd_id
               precise-algorithm-class-name: com.benyun.core.utils.sharding.ConsistenceHashAlgorithm
-        bl_topological_store_wd_list:
-          actual-data-nodes: ds1.bl_topological_store_wd_list_$->{1..5}
+        bl_topological_store_wd_statistics_category:
+          actual-data-nodes: ds1.bl_topological_store_wd_statistics_category_$->{1..5}
           key-generator:
             column: center_wd_id
             type: SNOWFLAKE
@@ -95,8 +95,8 @@ spring:
             standard:
               sharding-column: center_wd_id
               precise-algorithm-class-name: com.benyun.core.utils.sharding.ConsistenceHashAlgorithm
-        bl_topological_house_wd_list:
-          actual-data-nodes: ds1.bl_topological_house_wd_list_$->{1..5}
+        bl_topological_house_wd_statistics_data:
+          actual-data-nodes: ds1.bl_topological_house_wd_statistics_data_$->{1..5}
           key-generator:
             column: center_wd_id
             type: SNOWFLAKE
@@ -104,17 +104,8 @@ spring:
             standard:
               sharding-column: center_wd_id
               precise-algorithm-class-name: com.benyun.core.utils.sharding.ConsistenceHashAlgorithm
-        bl_topological_building_wd_list:
-          actual-data-nodes: ds1.bl_topological_building_wd_list_$->{1..5}
-          key-generator:
-            column: center_wd_id
-            type: SNOWFLAKE
-          table-strategy:
-            standard:
-              sharding-column: center_wd_id
-              precise-algorithm-class-name: com.benyun.core.utils.sharding.ConsistenceHashAlgorithm
-        bl_topological_enterprise_wd_list:
-          actual-data-nodes: ds1.bl_topological_enterprise_wd_list_$->{1..5}
+        bl_topological_build_wd_statistics_category:
+          actual-data-nodes: ds1.bl_topological_build_wd_statistics_category_$->{1..5}
           key-generator:
             column: center_wd_id
             type: SNOWFLAKE

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

@@ -1,5 +1,5 @@
 server:
-  port: 8000
+  port: 8009
   servlet:
     context-path: /bailianAi
     encoding:
@@ -49,7 +49,7 @@ spring:
           driverClassName: com.mysql.cj.jdbc.Driver
           # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
           # rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
-          url: jdbc:mysql://192.168.2.64:3306/bailian-ai?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
+          url: jdbc:mysql://192.168.2.64:3306/bailian-ai-plus?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
           username: root
           password: benyun
         # 从库数据源
@@ -57,7 +57,7 @@ spring:
           lazy: true
           type: ${spring.datasource.type}
           driverClassName: com.mysql.cj.jdbc.Driver
-          url: jdbc:mysql://192.168.2.64:3306/bailian-ai?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
+          url: jdbc:mysql://192.168.2.64:3306/bailian-ai-plus?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
           username: root
           password: benyun
       #        oracle:
@@ -103,13 +103,13 @@ spring:
       ds1:
         type: com.zaxxer.hikari.HikariDataSource
         driver-class-name: com.mysql.cj.jdbc.Driver
-        jdbcUrl: jdbc:mysql://192.168.2.64:3306/bailian-ai?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
+        jdbcUrl: jdbc:mysql://192.168.2.64:3306/bailian-ai-plus?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
         username: root
         password: benyun
     sharding:
       tables:
         bl_wd_topological:
-          actual-data-nodes: ds1.bl_wd_topological_$->{1..10}
+          actual-data-nodes: ds1.bl_wd_topological_$->{1..20}
           key-generator:
             column: center_wd_id
             type: SNOWFLAKE
@@ -117,8 +117,8 @@ spring:
             standard:
               sharding-column: center_wd_id
               precise-algorithm-class-name: com.benyun.core.utils.sharding.ConsistenceHashAlgorithm
-        bl_topological_store_wd_list:
-          actual-data-nodes: ds1.bl_topological_store_wd_list_$->{1..5}
+        bl_topological_store_wd_statistics_category:
+          actual-data-nodes: ds1.bl_topological_store_wd_statistics_category_$->{1..5}
           key-generator:
             column: center_wd_id
             type: SNOWFLAKE
@@ -126,8 +126,8 @@ spring:
             standard:
               sharding-column: center_wd_id
               precise-algorithm-class-name: com.benyun.core.utils.sharding.ConsistenceHashAlgorithm
-        bl_topological_house_wd_list:
-          actual-data-nodes: ds1.bl_topological_house_wd_list_$->{1..5}
+        bl_topological_house_wd_statistics_data:
+          actual-data-nodes: ds1.bl_topological_house_wd_statistics_data_$->{1..5}
           key-generator:
             column: center_wd_id
             type: SNOWFLAKE
@@ -135,17 +135,8 @@ spring:
             standard:
               sharding-column: center_wd_id
               precise-algorithm-class-name: com.benyun.core.utils.sharding.ConsistenceHashAlgorithm
-        bl_topological_building_wd_list:
-          actual-data-nodes: ds1.bl_topological_building_wd_list_$->{1..5}
-          key-generator:
-            column: center_wd_id
-            type: SNOWFLAKE
-          table-strategy:
-            standard:
-              sharding-column: center_wd_id
-              precise-algorithm-class-name: com.benyun.core.utils.sharding.ConsistenceHashAlgorithm
-        bl_topological_enterprise_wd_list:
-          actual-data-nodes: ds1.bl_topological_enterprise_wd_list_$->{1..5}
+        bl_topological_build_wd_statistics_category:
+          actual-data-nodes: ds1.bl_topological_build_wd_statistics_category_$->{1..5}
           key-generator:
             column: center_wd_id
             type: SNOWFLAKE

+ 3 - 3
benyun-core/src/main/resources/mapper/TopologicalStoreWdStatisticsCategoryDao.xml

@@ -5,12 +5,12 @@
     <insert id="insertList">
         insert into bl_topological_store_wd_statistics_category values
         <foreach collection="topologicalStoreWdStatisticsCategoryList"  separator="," item="item">
-            (#{item.centerWdId},#{item.radius},#{item.houseWdCount},#{item.bigManageTypeCode},#{item.midManageTypeCode},#{item.subCategoryCodeStatistics},#{item.averageRent},#{item.analyseTime})
+            (#{item.centerWdId},#{item.radius},#{item.bigManageTypeCode},#{item.midManageTypeCode},#{item.subCategoryCodeStatistics},#{item.analyseTime})
         </foreach>
     </insert>
 
-    <select id="category" resultType="com.benyun.core.entity.TopologicalStoreWdStatisticsCategory">
-        select * from bl_topological_store_wd_statistics_category where center_wd_id = #{centerWdId} and  #{radius} >= radius
+    <select id="category" parameterType="com.benyun.core.entity.vo.TopologicalWdAceeptVo" resultType="com.benyun.core.entity.TopologicalStoreWdStatisticsCategory">
+        select * from bl_topological_store_wd_statistics_category where center_wd_id = #{centerWdId} and  radius = #{radius}
     </select>
 </mapper>
 

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

@@ -5,7 +5,7 @@
     <insert id="insertList">
         insert into bl_wd_topological values
         <foreach collection="wdTopological"  separator="," item="item">
-            (#{item.centerWdId},#{item.centerWdName},#{item.radius},#{item.aroundWdId},#{item.aroundWdName},#{item.aroundWdTypeCode},#{item.aroundTypeCodeBy},#{item.distance},#{item.addrCode},#{item.addrCodeInfo},#{item.addrInfo},#{item.lat},#{item.lng},#{item.geoHash},#{item.analyseTime})
+            (#{item.centerWdId},#{item.centerWdName},#{item.radius},#{item.aroundWdInfo},#{item.analyseTime})
         </foreach>
     </insert>
 </mapper>

+ 27 - 1
benyun-core/src/test/java/com/benyun/core/service/AnalyseWdServiceImplTest.java

@@ -1,16 +1,42 @@
 package com.benyun.core.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.benyun.core.dao.WdInfoDao;
+import com.benyun.core.entity.WdInfo;
 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.ZoneId;
+import java.util.Arrays;
+import java.util.List;
+
 @SpringBootTest
 public class AnalyseWdServiceImplTest {
     @Autowired
     AnalyseWdService analyseWdService;
 
+    @Autowired
+    WdInfoDao wdInfoDao;
+
     @Test
     public void analys(){
-        analyseWdService.analyse();
+        ZoneId zone = ZoneId.of("Asia/Shanghai");
+        LocalDateTime now = LocalDateTime.now(zone);  //分析时间
+
+        System.out.println("start:");
+
+        //测试需要
+        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.in("wd_type_code", Arrays.asList("1","2","3"));
+
+        List<WdInfo> wdInfos1 = wdInfoDao.selectList(queryWrapper1);
+        int index = 1;
+        System.out.println(wdInfos1.size());
+        //1.遍历所有网点
+        for (WdInfo wdInfo : wdInfos1) {
+            analyseWdService.analyse(wdInfo,now,wdInfos1.size(),index++);
+        }
     }
 }