Selaa lähdekoodia

获取聚道分析-店龄 / 经营时长统计图表

JensionDzero 1 vuosi sitten
vanhempi
säilyke
845dcca381

+ 19 - 2
ruoyi-demo/src/main/java/com/ruoyi/demo/constant/RedisContant.java

@@ -19,11 +19,23 @@ public class RedisContant {
 
     public static int TOPOLOGICAL_STORE_WD_CATEGORY_TIME = 60*8;
 
+    public static String TOPOLOGICAL_STORE_WD_STORE_HISTOGRAM = "topological_store_wd_store_histogram";
+
+    public static int TOPOLOGICAL_STORE_WD_STORE_HISTOGRAM_TIME = 60*8;
+
+    public static String TOPOLOGICAL_STORE_WD_PER_CAPITA_CONSUMP_HISTOGRAM = "topological_store_wd_pre_capita_consump_histogram";
+
+    public static int TOPOLOGICAL_STORE_WD_PER_CAPITA_CONSUMP_HISTOGRAM_TIME = 60*8;
+
+
+
     public static String TOPOLOGICAL_BUILD_WD_LIST = "topological_build_wd_list";
     public static int TOPOLOGICAL_BUILD_WD_LIST_TIME = 60*8;
     public static String TOPOLOGICAL_BUILD_WD_CATEGORY= "topological_build_wd_category";
     public static int TOPOLOGICAL_BUILD_WD_CATEGORY_TIME = 60*8;
 
+    public static String TOPOLOGICAL_BUILD_WD_BUILDING_HISTOGRAM = "topological_build_wd_building_histogram";
+    public static int TOPOLOGICAL_BUILD_WD_BUILDING_HISTOGRAM_TIME = 60*8;
     public static String TOPOLOGICAL_ENTERPRISE_WD_LIST = "topological_enterprise_wd_list";
     public static int TOPOLOGICAL_ENTERPRISE_WD_LIST_TIME = 60*8;
     public static String TOPOLOGICAL_HOUSE_WD_LIST = "topological_house_wd_list";
@@ -42,13 +54,18 @@ public class RedisContant {
 
     public static int CHANNEL_ANALYSE_BUSINESS_STATUS_ANALYSE_TIME = 60*8;
 
+    public static String CHANNEL_ANALYSE_PER_CAPITA_CONSUMP_ANALYSE = "channel_analyse_per_capita_consump_analyse";
+
+    public static int CHANNEL_ANALYSE_PER_CAPITA_CONSUMP_ANALYSE_TIME = 60*8;
+
     public static String CHANNEL_ANALYSE_AROUND_BUILD_ANALYSE= "channel_analyse_around_build_analyse";
 
     public static int CHANNEL_ANALYSE_AROUND_BUILD_ANALYSE_TIME = 60*8;
 
-    public static String CHANNEL_ANALYSE_PER_CAPITA_COSUMP_ANALYSE= "channel_analyse_pre_capita_cosump_analyse";
+    public static String CHANNEL_ANALYSE_OPERATE_TIME_ANALYSE = "channel_analyse_operate_time_analyse";
+
+    public static int CHANNEL_ANALYSE_OPERATE_TIME_ANALYSE_TIME = 60*8;
 
-    public static int CHANNEL_ANALYSE_PER_CAPITA_COSUMP_ANALYSE_TIME = 60*8;
 
     public static String TOPOLOGICAL_COMMON_MAP = "topological_common_map";
     public static int TOPOLOGICAL_COMMON_MAP_TIME = 60*8;

+ 26 - 11
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/ChannelAnalyseController.java

@@ -153,22 +153,37 @@ public class ChannelAnalyseController {
         String md5 = channelMapAceeptVo.getHash();
 
         //2.查看redis中是否存在有缓存
-//        ArrayList<Histogram> wdCount = (ArrayList<Histogram>) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_PER_CAPITA_COSUMP_ANALYSE).get(md5);
-//        if (wdCount != null) {
-//            return R.ok(wdCount);
-//        }
+        ArrayList<Histogram> wdCount = (ArrayList<Histogram>) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_PER_CAPITA_CONSUMP_ANALYSE).get(md5);
+        if (wdCount != null) {
+            return R.ok(wdCount);
+        }
         ArrayList<Histogram> hashtable = channelAnalyseService.perCapitaConsumpAnalyse(channelMapAceeptVo);
 
         //4.保存到redis中
-        redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_BUSINESS_STATUS_ANALYSE).put(md5,hashtable);
-        redisTemplate.expire(RedisContant.CHANNEL_ANALYSE_PER_CAPITA_COSUMP_ANALYSE,RedisContant.CHANNEL_ANALYSE_PER_CAPITA_COSUMP_ANALYSE_TIME, TimeUnit.MINUTES); //30分钟
+        redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_PER_CAPITA_CONSUMP_ANALYSE).put(md5,hashtable);
+        redisTemplate.expire(RedisContant.CHANNEL_ANALYSE_PER_CAPITA_CONSUMP_ANALYSE,RedisContant.CHANNEL_ANALYSE_PER_CAPITA_CONSUMP_ANALYSE_TIME, TimeUnit.MINUTES); //30分钟
 
         return R.ok(hashtable);
     }
 
-//    @RequestMapping("/businessAnalyse")
-//    public R businessAnalyse(ChannelMapAceeptVo channelMapAceeptVo){
-//        channelAnalyseService.businessAnalyse(channelMapAceeptVo);
-//        return R.ok();
-//    }
+    @GetMapping("/operateTimeAnalyse")
+    public R operateTimeAnalyse(ChannelMapAceeptVo channelMapAceeptVo){
+        String md5 = channelMapAceeptVo.getHash();
+
+        //2.查看redis中是否存在有缓存
+        ArrayList<Histogram> wdCount = (ArrayList<Histogram>) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_OPERATE_TIME_ANALYSE).get(md5);
+        if (wdCount != null) {
+            return R.ok(wdCount);
+        }
+        ArrayList<Histogram> hashtable = channelAnalyseService.operateTimeAnalyse(channelMapAceeptVo);
+
+        //4.保存到redis中
+        redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_OPERATE_TIME_ANALYSE).put(md5,hashtable);
+        redisTemplate.expire(RedisContant.CHANNEL_ANALYSE_OPERATE_TIME_ANALYSE,RedisContant.CHANNEL_ANALYSE_OPERATE_TIME_ANALYSE_TIME, TimeUnit.MINUTES); //30分钟
+
+        return R.ok(hashtable);
+    }
+
+
+
 }

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

@@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.R;
 import com.ruoyi.demo.constant.RedisContant;
 import com.ruoyi.demo.entity.TopologicalBuildingWd;
 import com.ruoyi.demo.entity.bo.BuildWdCategoryCount;
+import com.ruoyi.demo.entity.bo.Histogram;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 import com.ruoyi.demo.service.TopologicalBuildWdSerevice;
 import com.ruoyi.demo.valida.TopologicalWdListGroup;
@@ -59,4 +60,21 @@ public class TopologicalBuildWdController {
 
         return R.ok(list);
     }
+
+    @RequestMapping("/buildingHistogram")
+    public R buildingHistogram(@Validated(value = {TopologicalWdListGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
+        String md5 = topologicalWdAceeptVo.getHash();
+        //2.查看redis中是否存在有缓存
+        List<Histogram> wdCount = (List<Histogram>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_BUILD_WD_BUILDING_HISTOGRAM).get(md5);
+        if (wdCount != null) {
+            return R.ok(wdCount);
+        }
+
+        List<Histogram> list = topologicalBuildWdSerevice.buildingHistogram(topologicalWdAceeptVo);
+
+        redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_BUILD_WD_BUILDING_HISTOGRAM).put(md5,list);
+        redisTemplate.expire(RedisContant.TOPOLOGICAL_BUILD_WD_BUILDING_HISTOGRAM, RedisContant.TOPOLOGICAL_BUILD_WD_BUILDING_HISTOGRAM_TIME, TimeUnit.MINUTES); //30分钟
+
+        return R.ok(list);
+    }
 }

+ 37 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TopologicalStoreWdController.java

@@ -4,6 +4,7 @@ package com.ruoyi.demo.controller;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.demo.constant.RedisContant;
 import com.ruoyi.demo.entity.TopologicalStoreWd;
+import com.ruoyi.demo.entity.bo.Histogram;
 import com.ruoyi.demo.entity.bo.StoreWdCategoryCount;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 import com.ruoyi.demo.service.TopologicalStoreWdService;
@@ -62,4 +63,40 @@ public class TopologicalStoreWdController {
 
         return R.ok(list);
     }
+
+    @RequestMapping("/storeHistogram")
+    public R storeHistogram(@Validated(value = {TopologicalWdGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
+        String md5 = topologicalWdAceeptVo.getHash();
+        //2.查看redis中是否存在有缓存
+        List<Histogram> wdCount = (List<Histogram>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_STORE_HISTOGRAM).get(md5);
+        if (wdCount != null) {
+            return R.ok(wdCount);
+        }
+
+
+        List<Histogram> list = topologicalStoreWdService.storeHistogram(topologicalWdAceeptVo);
+
+        redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_STORE_HISTOGRAM).put(md5,list);
+        redisTemplate.expire(RedisContant.TOPOLOGICAL_STORE_WD_STORE_HISTOGRAM,RedisContant.TOPOLOGICAL_STORE_WD_STORE_HISTOGRAM_TIME, TimeUnit.MINUTES); //30分钟
+
+        return R.ok(list);
+    }
+
+    @RequestMapping("/perCapitaConsumpHistogram")
+    public R perCapitaConsumpHistogram(@Validated(value = {TopologicalWdGroup.class}) TopologicalWdAceeptVo topologicalWdAceeptVo){
+        String md5 = topologicalWdAceeptVo.getHash();
+        //2.查看redis中是否存在有缓存
+        List<Histogram> wdCount = (List<Histogram>) redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_PER_CAPITA_CONSUMP_HISTOGRAM).get(md5);
+        if (wdCount != null) {
+            return R.ok(wdCount);
+        }
+
+
+        List<Histogram> list = topologicalStoreWdService.perCapitaConsumpHistogram(topologicalWdAceeptVo);
+
+        redisTemplate.boundHashOps(RedisContant.TOPOLOGICAL_STORE_WD_PER_CAPITA_CONSUMP_HISTOGRAM).put(md5,list);
+        redisTemplate.expire(RedisContant.TOPOLOGICAL_STORE_WD_PER_CAPITA_CONSUMP_HISTOGRAM,RedisContant.TOPOLOGICAL_STORE_WD_PER_CAPITA_CONSUMP_HISTOGRAM_TIME, TimeUnit.MINUTES); //30分钟
+
+        return R.ok(list);
+    }
 }

+ 4 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/entity/StoreWd.java

@@ -42,4 +42,8 @@ public class StoreWd implements Serializable {
 
     @TableField("contact")
     private String contact;
+    @TableField("opentime")
+    private String opentime;
+    @TableField("closetime")
+    private String closetime;
 }

+ 9 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/mapper/StoreWdDao.java

@@ -1,9 +1,18 @@
 package com.ruoyi.demo.mapper;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.ruoyi.demo.entity.StoreWd;
+import com.ruoyi.demo.entity.WdInfo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 @Mapper
 public interface StoreWdDao extends BaseMapper<StoreWd> {
+    List<StoreWd> perCapitaConsumpAnalyse(@Param(Constants.WRAPPER) QueryWrapper<WdInfo> queryWrapper);
+
+    List<StoreWd> operateTimeAnalyse(@Param(Constants.WRAPPER) QueryWrapper<WdInfo> queryWrapper);
 }

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

@@ -28,5 +28,7 @@ public interface ChannelAnalyseService {
 
     ArrayList<Histogram> perCapitaConsumpAnalyse(ChannelMapAceeptVo channelMapAceeptVo);
 
+    ArrayList<Histogram> operateTimeAnalyse(ChannelMapAceeptVo channelMapAceeptVo);
+
 //    void businessAnalyse(ChannelMapAceeptVo channelMapAceeptVo);
 }

+ 3 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/service/TopologicalBuildWdSerevice.java

@@ -3,6 +3,7 @@ package com.ruoyi.demo.service;
 
 import com.ruoyi.demo.entity.TopologicalBuildingWd;
 import com.ruoyi.demo.entity.bo.BuildWdCategoryCount;
+import com.ruoyi.demo.entity.bo.Histogram;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 
 import java.util.List;
@@ -10,4 +11,6 @@ import java.util.List;
 public interface TopologicalBuildWdSerevice {
     public List<BuildWdCategoryCount> buildingLevel(TopologicalWdAceeptVo topologicalWdAceeptVo);
     public List<TopologicalBuildingWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
+
+    List<Histogram> buildingHistogram(TopologicalWdAceeptVo topologicalWdAceeptVo);
 }

+ 5 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/service/TopologicalStoreWdService.java

@@ -2,6 +2,7 @@ package com.ruoyi.demo.service;
 
 
 import com.ruoyi.demo.entity.TopologicalStoreWd;
+import com.ruoyi.demo.entity.bo.Histogram;
 import com.ruoyi.demo.entity.bo.StoreWdCategoryCount;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 
@@ -11,4 +12,8 @@ public interface TopologicalStoreWdService {
     public List<TopologicalStoreWd> list(TopologicalWdAceeptVo topologicalWdAceeptVo);
 
     List<StoreWdCategoryCount> category(TopologicalWdAceeptVo topologicalWdAceeptVo);
+
+    List<Histogram> storeHistogram(TopologicalWdAceeptVo topologicalWdAceeptVo);
+
+    List<Histogram> perCapitaConsumpHistogram(TopologicalWdAceeptVo topologicalWdAceeptVo);
 }

+ 49 - 29
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/ChannelAnalyseServiceImpl.java

@@ -305,13 +305,14 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         queryWrapper.and(queryWrapper1 -> {
             queryWrapper1.eq("wd_type_code","3");
         });
+        queryWrapper.and(queryWrapper1 -> {
+            queryWrapper1.isNotNull("type_code_by");
+        });
         queryWrapper.groupBy("type_code_by");
         List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
         int total = 0;
         HashMap<String,Integer> hashMap = new HashMap<>();
         for (WdInfo wdInfo : wdInfos) {
-            if(wdInfo.getTypeCodeBy() == null)
-                continue;
             String typeCodeBy = wdInfo.getTypeCodeBy().substring(0,2);
             Integer integer = hashMap.get(typeCodeBy);
             if (integer == null){
@@ -342,39 +343,25 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         queryWrapper.and(queryWrapper1 -> {
             queryWrapper1.eq("wd_type_code","1");
         });
-        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-
-        List<String> collect = wdInfos.stream().map(item -> {
-            return item.getWdId();
-        }).collect(Collectors.toList());
-
+        List<StoreWd> storeWds = storeWdDao.perCapitaConsumpAnalyse(queryWrapper);
         HashMap<String, Integer> hashMap = new HashMap<>();
         hashMap.put("0~20",0);
         hashMap.put("20~50",0);
         hashMap.put("50~100",0);
         hashMap.put("100~200",0);
         hashMap.put("200以上",0);
-        if (!collect.isEmpty()){
-            QueryWrapper<StoreWd> queryWrapper1 = new QueryWrapper<>();
-            queryWrapper1.select("per_capita_consumption");
-            //queryWrapper1.in("wd_id",collect);
-            for (String s : collect) {
-                queryWrapper1.eq("wd_id",s).or();
-            }
-            List<StoreWd> storeWds = storeWdDao.selectList(queryWrapper1);
-            for (StoreWd storeWd : storeWds) {
-                if (storeWd.getPerCapitaConsumption() != null){
-                    if (storeWd.getPerCapitaConsumption() >= 0 && storeWd.getPerCapitaConsumption()<20){
-                        hashMap.put("0~20",hashMap.get("0~20")+1);
-                    }else if(storeWd.getPerCapitaConsumption() >= 20 && storeWd.getPerCapitaConsumption()<50){
-                        hashMap.put("20~50",hashMap.get("20~50")+1);
-                    }else if(storeWd.getPerCapitaConsumption() >= 50 && storeWd.getPerCapitaConsumption()< 100){
-                        hashMap.put("50~100",hashMap.get("50~1000")+1);
-                    }else if(storeWd.getPerCapitaConsumption() >= 100 && storeWd.getPerCapitaConsumption()< 200){
-                        hashMap.put("100~200",hashMap.get("100~200")+1);
-                    }else {
-                        hashMap.put("200以上",hashMap.get("200以上")+1);
-                    }
+        for (StoreWd storeWd : storeWds) {
+            if (storeWd.getPerCapitaConsumption() != null){
+                if (storeWd.getPerCapitaConsumption() >= 0 && storeWd.getPerCapitaConsumption()<20){
+                    hashMap.put("0~20",hashMap.get("0~20")+1);
+                }else if(storeWd.getPerCapitaConsumption() >= 20 && storeWd.getPerCapitaConsumption()<50){
+                    hashMap.put("20~50",hashMap.get("20~50")+1);
+                }else if(storeWd.getPerCapitaConsumption() >= 50 && storeWd.getPerCapitaConsumption()< 100){
+                    hashMap.put("50~100",hashMap.get("50~100")+1);
+                }else if(storeWd.getPerCapitaConsumption() >= 100 && storeWd.getPerCapitaConsumption()< 200){
+                    hashMap.put("100~200",hashMap.get("100~200")+1);
+                }else {
+                    hashMap.put("200以上",hashMap.get("200以上")+1);
                 }
             }
         }
@@ -389,6 +376,39 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
         return list;
     }
 
+    @Override
+    public ArrayList<Histogram> operateTimeAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("wd_id");
+        assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
+        queryWrapper.and(queryWrapper1 -> {
+            queryWrapper1.eq("wd_type_code","1");
+        });
+        List<StoreWd> storeWds = storeWdDao.operateTimeAnalyse(queryWrapper);
+
+        HashMap<Integer,Integer> hashMap = new HashMap<>();
+        for (StoreWd storeWd : storeWds) {
+            Integer opentime = Integer.valueOf(storeWd.getOpentime().substring(0,2));
+            Integer closetime = Integer.valueOf(storeWd.getClosetime().substring(0,2));
+            int i = closetime - opentime;
+            Integer integer = hashMap.get(i);
+            if (integer == null)
+                hashMap.put(i,1);
+            else
+                hashMap.put(i,integer+1);
+        }
+
+
+        ArrayList<Histogram> list = new ArrayList<>();
+        for (Integer s : hashMap.keySet()) {
+            Histogram histogram = new Histogram();
+            histogram.setName(s+"");
+            histogram.setCount(hashMap.get(s));
+            list.add(histogram);
+        }
+        return list;
+    }
+
     public void assembleQueryWrapper(QueryWrapper<WdInfo> queryWrapper,ChannelMapAceeptVo channelMapAceeptVo){
         //1.根据不同级别得到需要查询的 地区码
         List<String> addrCodeList = new ArrayList<>();

+ 71 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalBuildWdSereviceImpl.java

@@ -7,6 +7,7 @@ import com.ruoyi.demo.entity.BuildWd;
 import com.ruoyi.demo.entity.TopologicalBuildingWd;
 import com.ruoyi.demo.entity.WdInfo;
 import com.ruoyi.demo.entity.bo.BuildWdCategoryCount;
+import com.ruoyi.demo.entity.bo.Histogram;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
 import com.ruoyi.demo.mapper.BuildWdDao;
 import com.ruoyi.demo.mapper.WdInfoDao;
@@ -49,6 +50,8 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
         QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
         queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
         WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
+        if (wdInfo1 == null)
+            return new ArrayList<>();
 
         //2.根据中心网点找到周边网点Id
         // 以经纬度为中心,获取半径不超过最大距离的所有元素
@@ -142,4 +145,72 @@ public class TopologicalBuildWdSereviceImpl implements TopologicalBuildWdSerevic
 
         return list;
     }
+
+    @Override
+    public List<Histogram> buildingHistogram(TopologicalWdAceeptVo topologicalWdAceeptVo) {
+        //1.根据中心网点Id找到网点详细信息
+        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
+        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
+        if (wdInfo1 == null)
+            return new ArrayList<>();
+
+        //2.根据中心网点找到周边网点Id
+        // 以经纬度为中心,获取半径不超过最大距离的所有元素
+        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
+        //半径范围
+        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
+        //圆
+        Circle circle = new Circle(point, distance);
+        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle);
+        //周边网点Id
+        List<String> aroundWdId = new ArrayList<>();
+        radius.getContent().stream().forEach(item -> {
+            //记录网点坐标及距离
+            aroundWdId.add((String) item.getContent().getName());
+        });
+
+        if (aroundWdId.isEmpty())
+            return new ArrayList<>();
+
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("type_code_by","count(*) as audit");
+        queryWrapper.and(queryWrapper2 -> {
+            queryWrapper2.eq("wd_type_code","3");
+        });
+        queryWrapper.and(queryWrapper2 -> {
+            queryWrapper2.isNotNull("type_code_by");
+        });
+        queryWrapper.groupBy("type_code_by");
+        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
+        int total = 0;
+        HashMap<String,Integer> hashMap = new HashMap<>();
+        for (WdInfo wdInfo : wdInfos) {
+            if(wdInfo.getTypeCodeBy() == null)
+                continue;
+            String typeCodeBy = wdInfo.getTypeCodeBy().substring(0,2);
+            Integer integer = hashMap.get(typeCodeBy);
+            if (integer == null){
+                hashMap.put(typeCodeBy,wdInfo.getAudit());
+            }else {
+                hashMap.put(typeCodeBy,hashMap.get(typeCodeBy)+wdInfo.getAudit());
+            }
+            total+=wdInfo.getAudit();
+        }
+
+        ArrayList<Histogram> list = new ArrayList<>();
+        for (String s : hashMap.keySet()) {
+            Integer integer = hashMap.get(s);
+            String initTypeByMap = initMapUtil.getInitTypeByMap(s + "0000").replace(":","");
+            Histogram histogram = new Histogram();
+            histogram.setName(initTypeByMap);
+            histogram.setCount(integer);
+            list.add(histogram);
+        }
+
+        return list;
+    }
+
+
 }

+ 2 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalCommonServiceImpl.java

@@ -84,6 +84,8 @@ public class TopologicalCommonServiceImpl implements TopologicalCommonService {
         QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
         queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
         WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
+        if (wdInfo1 == null)
+            return new ArrayList<>();
 
         //2.根据中心网点找到周边网点Id
         // 以经纬度为中心,获取半径不超过最大距离的所有元素

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

@@ -41,6 +41,8 @@ public class TopologicalEnterpriseWdServiceImpl implements TopologicalEnterprise
         QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
         queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
         WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
+        if (wdInfo1 == null)
+            return new ArrayList<>();
 
         //2.根据中心网点找到周边网点Id
         // 以经纬度为中心,获取半径不超过最大距离的所有元素

+ 2 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalHouseServiceWdImpl.java

@@ -47,6 +47,8 @@ public class TopologicalHouseServiceWdImpl implements TopologicalHouseWdService
         QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
         queryWrapper1.eq("wd_id", topologicalWdAceeptVo.getCenterWdId());
         WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
+        if (wdInfo1 == null)
+            return new ArrayList<>();
 
         //2.根据中心网点找到周边网点Id
         // 以经纬度为中心,获取半径不超过最大距离的所有元素

+ 134 - 2
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TopologicalStoreWdServiceImpl.java

@@ -7,6 +7,7 @@ import com.ruoyi.demo.entity.ManageType;
 import com.ruoyi.demo.entity.StoreWd;
 import com.ruoyi.demo.entity.TopologicalStoreWd;
 import com.ruoyi.demo.entity.WdInfo;
+import com.ruoyi.demo.entity.bo.Histogram;
 import com.ruoyi.demo.entity.bo.StoreWdCategoryCount;
 import com.ruoyi.demo.entity.bo.StoreWdCategoryCountBody;
 import com.ruoyi.demo.entity.vo.TopologicalWdAceeptVo;
@@ -50,7 +51,8 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
         QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
         queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
         WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-
+        if (wdInfo1 == null)
+            return new ArrayList<>();
         //2.根据中心网点找到周边网点Id
         // 以经纬度为中心,获取半径不超过最大距离的所有元素
         Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
@@ -109,7 +111,8 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
         QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
         queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
         WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
-
+        if (wdInfo1 == null)
+            return new ArrayList<>();
         //2.根据中心网点找到周边网点Id
         // 以经纬度为中心,获取半径不超过最大距离的所有元素
         Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
@@ -191,4 +194,133 @@ public class TopologicalStoreWdServiceImpl implements TopologicalStoreWdService
 
         return storeWdCategoryCounts;
     }
+
+    @Override
+    public List<Histogram> storeHistogram(TopologicalWdAceeptVo topologicalWdAceeptVo) {
+        //1.根据中心网点Id找到网点详细信息
+        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
+        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
+        if (wdInfo1 == null)
+            return new ArrayList<>();
+        //2.根据中心网点找到周边网点Id
+        // 以经纬度为中心,获取半径不超过最大距离的所有元素
+        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
+        //半径范围
+        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
+        //圆
+        Circle circle = new Circle(point, distance);
+        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle);
+        //周边网点Id
+        List<String> aroundWdId = new ArrayList<>();
+        radius.getContent().stream().forEach(item -> {
+            //记录网点坐标及距离
+            aroundWdId.add((String) item.getContent().getName());
+        });
+
+        if (aroundWdId.isEmpty())
+            return new ArrayList<>();
+
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("type_code_by","count(*) as audit");
+        queryWrapper.and(queryWrapper2 -> {
+            queryWrapper2.eq("wd_type_code","1");
+        });
+        queryWrapper.and(queryWrapper2 -> {
+            queryWrapper2.isNotNull("type_code_by");
+        });
+        queryWrapper.groupBy("type_code_by");
+        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+
+        int total = 0;
+        HashMap<String,Integer> hashMap = new HashMap<>();
+        for (WdInfo wdInfo : wdInfos) {
+            if(wdInfo.getTypeCodeBy() == null)
+                continue;
+            String typeCodeBy = wdInfo.getTypeCodeBy().substring(0,2);
+            Integer integer = hashMap.get(typeCodeBy);
+            if (integer == null){
+                hashMap.put(typeCodeBy,wdInfo.getAudit());
+            }else {
+                hashMap.put(typeCodeBy,hashMap.get(typeCodeBy)+wdInfo.getAudit());
+            }
+            total+=wdInfo.getAudit();
+        }
+
+        ArrayList<Histogram> list = new ArrayList<>();
+        for (String s : hashMap.keySet()) {
+            Integer integer = hashMap.get(s);
+            String initTypeByMap = initMapUtil.getInitTypeByMap(s + "0000").replace(":","");
+            Histogram histogram = new Histogram();
+            histogram.setName(initTypeByMap);
+            histogram.setCount(integer);
+            list.add(histogram);
+        }
+
+        return list;
+    }
+
+    @Override
+    public List<Histogram> perCapitaConsumpHistogram(TopologicalWdAceeptVo topologicalWdAceeptVo) {
+        //1.根据中心网点Id找到网点详细信息
+        QueryWrapper<WdInfo> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.eq("wd_id",topologicalWdAceeptVo.getCenterWdId());
+        WdInfo wdInfo1 = wdInfoDao.selectOne(queryWrapper1);
+        if (wdInfo1 == null)
+            return new ArrayList<>();
+        //2.根据中心网点找到周边网点Id
+        // 以经纬度为中心,获取半径不超过最大距离的所有元素
+        Point point = new Point(wdInfo1.getLng().doubleValue(),wdInfo1.getLat().doubleValue());
+        //半径范围
+        Distance distance = new Distance(topologicalWdAceeptVo.getRadius(), RedisGeoCommands.DistanceUnit.METERS);
+        //圆
+        Circle circle = new Circle(point, distance);
+        GeoResults<RedisGeoCommands.GeoLocation<Object>> radius = redisTemplate.boundGeoOps(wdInfo1.getAddrCode().substring(0, 4)).radius(circle);
+        //周边网点Id
+        List<String> aroundWdId = new ArrayList<>();
+        radius.getContent().stream().forEach(item -> {
+            //记录网点坐标及距离
+            aroundWdId.add((String) item.getContent().getName());
+        });
+
+        if (aroundWdId.isEmpty())
+            return new ArrayList<>();
+
+        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("wd_id");
+        queryWrapper.and(queryWrapper2 -> {
+            queryWrapper2.eq("wd_type_code","1");
+        });
+        List<StoreWd> storeWds = storeWdDao.perCapitaConsumpAnalyse(queryWrapper);
+        HashMap<String, Integer> hashMap = new HashMap<>();
+        hashMap.put("0~20",0);
+        hashMap.put("20~50",0);
+        hashMap.put("50~100",0);
+        hashMap.put("100~200",0);
+        hashMap.put("200以上",0);
+        for (StoreWd storeWd : storeWds) {
+            if (storeWd.getPerCapitaConsumption() != null){
+                if (storeWd.getPerCapitaConsumption() >= 0 && storeWd.getPerCapitaConsumption()<20){
+                    hashMap.put("0~20",hashMap.get("0~20")+1);
+                }else if(storeWd.getPerCapitaConsumption() >= 20 && storeWd.getPerCapitaConsumption()<50){
+                    hashMap.put("20~50",hashMap.get("20~50")+1);
+                }else if(storeWd.getPerCapitaConsumption() >= 50 && storeWd.getPerCapitaConsumption()< 100){
+                    hashMap.put("50~100",hashMap.get("50~100")+1);
+                }else if(storeWd.getPerCapitaConsumption() >= 100 && storeWd.getPerCapitaConsumption()< 200){
+                    hashMap.put("100~200",hashMap.get("100~200")+1);
+                }else {
+                    hashMap.put("200以上",hashMap.get("200以上")+1);
+                }
+            }
+        }
+
+        ArrayList<Histogram> list = new ArrayList<>();
+        for (String s : hashMap.keySet()) {
+            Histogram histogram = new Histogram();
+            histogram.setName(s);
+            histogram.setCount(hashMap.get(s));
+            list.add(histogram);
+        }
+        return list;
+    }
 }

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

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.ruoyi.demo.mapper.StoreWdDao">
+    <select id="perCapitaConsumpAnalyse" resultType="com.ruoyi.demo.entity.StoreWd">
+        select per_capita_consumption from ddt_store_wd where per_capita_consumption is not null and wd_id in (select ${ew.sqlSelect} from ddt_wd_info ${ew.customSqlSegment})
+    </select>
+    <select id="operateTimeAnalyse" resultType="com.ruoyi.demo.entity.StoreWd">
+        select opentime,closetime from ddt_store_wd where opentime != '' and closetime != '' and wd_id in (select ${ew.sqlSelect} from ddt_wd_info ${ew.customSqlSegment})
+    </select>
+</mapper>