|
@@ -21,7 +21,14 @@ import com.ruoyi.demo.utils.InitMapUtil;
|
|
|
import com.ruoyi.demo.utils.WdRedisStoreage;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.data.geo.Circle;
|
|
|
+import org.springframework.data.geo.Distance;
|
|
|
+import org.springframework.data.geo.GeoResults;
|
|
|
+import org.springframework.data.geo.Point;
|
|
|
+import org.springframework.data.redis.connection.RedisGeoCommands;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
@@ -48,10 +55,12 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
@Autowired
|
|
|
private WdRedisStoreage wdRedisStoreage;
|
|
|
|
|
|
-
|
|
|
@Autowired
|
|
|
private StoreWdDao storeWdDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisTemplate redisTemplate;
|
|
|
+
|
|
|
@Autowired
|
|
|
@Qualifier("executor")
|
|
|
ExecutorService executor;
|
|
@@ -257,9 +266,75 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
storeWdCategoryCounts.add(hashMap.get(s));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
return storeWdCategoryCounts;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HashMap<String,Integer> 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);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Hashtable<String, Integer> aroundBuildAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
+ QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.select("wd_id","wd_type_code","lat","lng");
|
|
|
+ assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
|
|
|
+ queryWrapper.and(queryWrapper1 -> {
|
|
|
+ queryWrapper1.eq("wd_type_code","3");
|
|
|
+ });
|
|
|
+ List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
|
|
|
+
|
|
|
+ Hashtable<String,Integer> hashtable = new Hashtable<>();
|
|
|
+ hashtable.put("0~100",0);
|
|
|
+ hashtable.put("100~500",0);
|
|
|
+ hashtable.put("500~1000",0);
|
|
|
+ hashtable.put("1000以上",0);
|
|
|
+ ArrayList<CompletableFuture<Void>> list = new ArrayList<>();
|
|
|
+ for (WdInfo wdInfo : wdInfos) {
|
|
|
+ list.add(CompletableFuture.runAsync(() -> {
|
|
|
+ //半径范围
|
|
|
+ Distance distance = new Distance(1000, RedisGeoCommands.DistanceUnit.METERS);
|
|
|
+ GeoResults radius = redisTemplate.boundGeoOps(wdInfo.getAddrCode().substring(0, 4)).radius(wdInfo.getWdId(), distance);
|
|
|
+ int size = radius.getContent().size();
|
|
|
+ if (size <= 100)
|
|
|
+ hashtable.put("0~100", hashtable.get("0~100") + 1);
|
|
|
+ else if (size > 100 && size <= 500)
|
|
|
+ hashtable.put("100~500", hashtable.get("100~500") + 1);
|
|
|
+ else if (size > 500 && size <= 1000)
|
|
|
+ hashtable.put("500~1000", hashtable.get("500~1000") + 1);
|
|
|
+ else
|
|
|
+ hashtable.put("1000以上", hashtable.get("1000以上") + 1);
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ CompletableFuture.allOf(list.toArray(new CompletableFuture[0]));
|
|
|
+
|
|
|
+ return hashtable;
|
|
|
+ }
|
|
|
+
|
|
|
public void assembleQueryWrapper(QueryWrapper<WdInfo> queryWrapper,ChannelMapAceeptVo channelMapAceeptVo){
|
|
|
//1.根据不同级别得到需要查询的 地区码
|
|
|
List<String> addrCodeList = new ArrayList<>();
|