|
@@ -3,6 +3,7 @@ package com.ruoyi.demo.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.ruoyi.demo.constant.RedisContant;
|
|
|
import com.ruoyi.demo.entity.Brand;
|
|
|
import com.ruoyi.demo.entity.ManageType;
|
|
|
import com.ruoyi.demo.entity.StoreWd;
|
|
@@ -116,37 +117,71 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.select("wd_id");
|
|
|
assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
|
|
|
+ queryWrapper.and(queryWrapper2 ->{
|
|
|
+ queryWrapper2.eq("deleted",0);
|
|
|
+ });
|
|
|
List<WdInfo> queryWd = wdInfoDao.selectList(queryWrapper);
|
|
|
|
|
|
- //2.获取网点周边标签,并进行统计
|
|
|
+ //2.获取周边标签
|
|
|
+ List<String> collect = queryWd.stream().map(item -> {
|
|
|
+ return RedisContant.WD_TAG + "_" + item.getWdId();
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //切割获取redis数据
|
|
|
+ int split = 60000;
|
|
|
+ int splitCount = collect.size()/split;
|
|
|
+ int p1 = 0,p2 = split;
|
|
|
+ ArrayList<CompletableFuture<List<List<String>>>> splitList = new ArrayList<>();
|
|
|
+ for (int i=1;i<=splitCount;i++){
|
|
|
+ if (p2 > collect.size())
|
|
|
+ p2 = collect.size();
|
|
|
+ List<String> list2 = collect.subList(p1, p2);
|
|
|
+ CompletableFuture<List<List<String>>> future = CompletableFuture.supplyAsync(()->{
|
|
|
+ return wdRedisStoreage.getWdTagList(list2);
|
|
|
+ },executor);
|
|
|
+ splitList.add(future);
|
|
|
+ p1 = p2;
|
|
|
+ p2+=split;
|
|
|
+ }
|
|
|
+
|
|
|
+ //3.统计
|
|
|
Hashtable<String, Integer> hashtable = new Hashtable<>();
|
|
|
hashtable.put("total",0);
|
|
|
- CompletableFuture<Void> future = null;
|
|
|
- for (WdInfo wdInfo : queryWd) {
|
|
|
- future = CompletableFuture.runAsync(()->{
|
|
|
- List<String> wdTag = wdRedisStoreage.getWdTag(wdInfo);
|
|
|
- if (wdTag != null){
|
|
|
- for (String s : wdTag) {
|
|
|
- s += "边";
|
|
|
- Integer integer = hashtable.get(s);
|
|
|
- if (integer == null)
|
|
|
- hashtable.put(s,1);
|
|
|
- else
|
|
|
- hashtable.put(s,integer+1);
|
|
|
- hashtable.put("total",hashtable.get("total")+1);
|
|
|
+ ArrayList<CompletableFuture<Void>> list1 = new ArrayList<>();
|
|
|
+ for (CompletableFuture<List<List<String>>> listCompletableFuture : splitList) {
|
|
|
+ try {
|
|
|
+ List<List<String>> lists = listCompletableFuture.get();
|
|
|
+ for (List<String> list : lists) {
|
|
|
+ if (list != null && !list.isEmpty()){
|
|
|
+ CompletableFuture<Void> future = CompletableFuture.runAsync(()->{
|
|
|
+ for (String s : list) {
|
|
|
+ s += "边";
|
|
|
+ Integer integer = hashtable.get(s);
|
|
|
+ if (integer == null)
|
|
|
+ hashtable.put(s,1);
|
|
|
+ else
|
|
|
+ hashtable.put(s,integer+1);
|
|
|
+ }
|
|
|
+ hashtable.put("total",hashtable.get("total")+1);
|
|
|
+ },executor);
|
|
|
+ list1.add(future);
|
|
|
}
|
|
|
}
|
|
|
- },executor);
|
|
|
- }
|
|
|
- try {
|
|
|
- future.get();
|
|
|
- } catch (InterruptedException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- } catch (ExecutionException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
+ CompletableFuture.allOf(list1.toArray(new CompletableFuture[list1.size()])).join();
|
|
|
+ lists = null;
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } catch (ExecutionException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- //3.封装统计值
|
|
|
+ collect = null;
|
|
|
+ queryWd = null;
|
|
|
+
|
|
|
+
|
|
|
+ //4.封装统计值
|
|
|
HashMap<String, Object> result = new HashMap<>();
|
|
|
List<TagAnalyse> list = new ArrayList<>();
|
|
|
Integer total = hashtable.get("total");
|
|
@@ -163,7 +198,7 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
list.add(tagAnalyse);
|
|
|
}
|
|
|
|
|
|
- //4.对结果集进行排序
|
|
|
+ //5.对结果集进行排序
|
|
|
Collections.sort(list, new Comparator<TagAnalyse>() {
|
|
|
@Override
|
|
|
public int compare(TagAnalyse o1, TagAnalyse o2) {
|
|
@@ -194,24 +229,18 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.select("wd_id");
|
|
|
assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
|
|
|
+ queryWrapper.and(queryWrapper2 ->{
|
|
|
+ queryWrapper2.eq("deleted",0);
|
|
|
+ });
|
|
|
|
|
|
//门店
|
|
|
queryWrapper.and(queryWrapper1 -> {
|
|
|
queryWrapper1.eq("wd_type_code","1");
|
|
|
});
|
|
|
- List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
|
|
|
|
|
|
|
|
|
- List<String> collect = wdInfos.stream().map(wdInfo -> {
|
|
|
- return wdInfo.getWdId();
|
|
|
- }).collect(Collectors.toList());
|
|
|
- QueryWrapper<StoreWd> queryWrapper1 = new QueryWrapper<>();
|
|
|
- queryWrapper1.select("manage_type_code","count(*) as comment_count")
|
|
|
- .in("wd_id",collect)
|
|
|
- .groupBy("manage_type_code");
|
|
|
-
|
|
|
//5.查询周边网点结果,并统计
|
|
|
- List<StoreWd> storeWds = storeWdDao.selectList(queryWrapper1);
|
|
|
+ List<StoreWd> storeWds = storeWdDao.category(queryWrapper);
|
|
|
HashMap<String,StoreWdCategoryCount> hashMap = new HashMap<>();
|
|
|
for (StoreWd wdInfo : storeWds) {
|
|
|
if(wdInfo.getManageTypeCode() == null || wdInfo.getManageTypeCode().equals(""))
|
|
@@ -270,31 +299,37 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HashMap<String,Integer> businessStatusAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
+ public HashMap businessStatusAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.select("wd_id");
|
|
|
assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
|
|
|
queryWrapper.and(queryWrapper1 -> {
|
|
|
queryWrapper1.eq("wd_type_code","1");
|
|
|
});
|
|
|
- List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
|
|
|
+ queryWrapper.and(queryWrapper2 ->{
|
|
|
+ queryWrapper2.eq("deleted",0);
|
|
|
+ });
|
|
|
|
|
|
- List<String> collect = wdInfos.stream().map(wdInfo -> {
|
|
|
- return wdInfo.getWdId();
|
|
|
- }).collect(Collectors.toList());
|
|
|
- QueryWrapper<StoreWd> queryWrapper1 = new QueryWrapper<>();
|
|
|
- queryWrapper1.select("business_status","count(*) as comment_count")
|
|
|
- .in("wd_id",collect)
|
|
|
- .groupBy("business_status");
|
|
|
- List<StoreWd> storeWds = storeWdDao.selectList(queryWrapper1);
|
|
|
+ List<StoreWd> storeWds = storeWdDao.businessStatusAnalyse(queryWrapper);
|
|
|
HashMap<String,Integer> hashMap = new HashMap<>();
|
|
|
int total = 0;
|
|
|
for (StoreWd storeWd : storeWds) {
|
|
|
total+=storeWd.getCommentCount();
|
|
|
hashMap.put(storeWd.getBusinessStatus(),storeWd.getCommentCount());
|
|
|
}
|
|
|
- hashMap.put("total",total);
|
|
|
- return hashMap;
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ HashMap<String, Object> result = new HashMap<>();
|
|
|
+ result.put("total",total);
|
|
|
+ result.put("data",list);
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -343,6 +378,10 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
queryWrapper.and(queryWrapper1 -> {
|
|
|
queryWrapper1.eq("wd_type_code","1");
|
|
|
});
|
|
|
+ queryWrapper.and(queryWrapper2 ->{
|
|
|
+ queryWrapper2.eq("deleted",0);
|
|
|
+ });
|
|
|
+
|
|
|
List<StoreWd> storeWds = storeWdDao.perCapitaConsumpAnalyse(queryWrapper);
|
|
|
HashMap<String, Integer> hashMap = new HashMap<>();
|
|
|
hashMap.put("0~20",0);
|
|
@@ -367,12 +406,16 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
- }
|
|
|
+ Histogram histogram1 = new Histogram("0~20",hashMap.get("0~20"));
|
|
|
+ Histogram histogram2 = new Histogram("20~50",hashMap.get("20~50"));
|
|
|
+ Histogram histogram3 = new Histogram("50~100",hashMap.get("50~100"));
|
|
|
+ Histogram histogram4 = new Histogram("100~200",hashMap.get("100~200"));
|
|
|
+ Histogram histogram5 = new Histogram("200以上",hashMap.get("200以上"));
|
|
|
+ list.add(histogram1);
|
|
|
+ list.add(histogram2);
|
|
|
+ list.add(histogram3);
|
|
|
+ list.add(histogram4);
|
|
|
+ list.add(histogram5);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
@@ -384,6 +427,10 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
queryWrapper.and(queryWrapper1 -> {
|
|
|
queryWrapper1.eq("wd_type_code","1");
|
|
|
});
|
|
|
+ queryWrapper.and(queryWrapper2 ->{
|
|
|
+ queryWrapper2.eq("deleted",0);
|
|
|
+ });
|
|
|
+
|
|
|
List<StoreWd> storeWds = storeWdDao.operateTimeAnalyse(queryWrapper);
|
|
|
|
|
|
HashMap<Integer,Integer> hashMap = new HashMap<>();
|