|
@@ -7,6 +7,7 @@ import com.ruoyi.demo.entity.Brand;
|
|
|
import com.ruoyi.demo.entity.ManageType;
|
|
|
import com.ruoyi.demo.entity.StoreWd;
|
|
|
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.ChannelAnalyseAceeptVo;
|
|
@@ -58,8 +59,6 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
@Autowired
|
|
|
private StoreWdDao storeWdDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RedisTemplate redisTemplate;
|
|
|
|
|
|
@Autowired
|
|
|
@Qualifier("executor")
|
|
@@ -299,40 +298,95 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Hashtable<String, Integer> aroundBuildAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
+ public ArrayList<Histogram> aroundBuildAnalyse(ChannelMapAceeptVo channelMapAceeptVo) {
|
|
|
QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.select("wd_id","wd_type_code","lat","lng");
|
|
|
+ queryWrapper.select("type_code_by","count(*) as audit");
|
|
|
assembleQueryWrapper(queryWrapper,channelMapAceeptVo);
|
|
|
queryWrapper.and(queryWrapper1 -> {
|
|
|
queryWrapper1.eq("wd_type_code","3");
|
|
|
});
|
|
|
+ queryWrapper.groupBy("type_code_by");
|
|
|
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<>();
|
|
|
+ int total = 0;
|
|
|
+ HashMap<String,Integer> hashMap = new HashMap<>();
|
|
|
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);
|
|
|
- }));
|
|
|
+ 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 ArrayList<Histogram> perCapitaConsumpAnalyse(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(item -> {
|
|
|
+ return item.getWdId();
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- CompletableFuture.allOf(list.toArray(new CompletableFuture[0]));
|
|
|
|
|
|
- return hashtable;
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
|
public void assembleQueryWrapper(QueryWrapper<WdInfo> queryWrapper,ChannelMapAceeptVo channelMapAceeptVo){
|
|
@@ -406,4 +460,6 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|