|
@@ -3,20 +3,20 @@ package com.benyun.core.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.benyun.core.dao.BrandMapper;
|
|
|
import com.benyun.core.dao.WdInfoDao;
|
|
|
-import com.benyun.core.entity.Brand;
|
|
|
-import com.benyun.core.entity.CityTierBody;
|
|
|
-import com.benyun.core.entity.TopologicalStoreWd;
|
|
|
-import com.benyun.core.entity.WdInfo;
|
|
|
+import com.benyun.core.dao.WdTopologicalInfoDao;
|
|
|
+import com.benyun.core.entity.*;
|
|
|
import com.benyun.core.entity.vo.ChannelAnalyseAceeptVo;
|
|
|
+import com.benyun.core.entity.vo.ChannelMapAceeptVo;
|
|
|
+import com.benyun.core.entity.vo.TagAnalyse;
|
|
|
import com.benyun.core.service.ChannelAnalyseService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.boot.origin.Origin;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
@@ -31,6 +31,13 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
@Autowired
|
|
|
BrandMapper brandMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ WdTopologicalInfoDao wdTopologicalInfoDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("typeByMap")
|
|
|
+ private HashMap<String,String> typeByMap;
|
|
|
+
|
|
|
@Override
|
|
|
public HashMap cityTier(ChannelAnalyseAceeptVo channelAnalyseAceeptVo) {
|
|
|
HashMap<String,Long> result = new HashMap<>();
|
|
@@ -73,8 +80,153 @@ public class ChannelAnalyseServiceImpl implements ChannelAnalyseService {
|
|
|
@Override
|
|
|
public PageInfo<Brand> brandList(ChannelAnalyseAceeptVo channelAnalyseAceeptVo) {
|
|
|
PageHelper.startPage(channelAnalyseAceeptVo.getPageNum(),channelAnalyseAceeptVo.getPageSize());
|
|
|
- List<Brand> brands = brandMapper.searchList(channelAnalyseAceeptVo.getSearchText());
|
|
|
+ String text = null;
|
|
|
+ if(channelAnalyseAceeptVo.getSearchText() != null)
|
|
|
+ text = channelAnalyseAceeptVo.getSearchText();
|
|
|
+ List<Brand> brands = brandMapper.searchList(text);
|
|
|
PageInfo<Brand> pageInfo = new PageInfo<>(brands);
|
|
|
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 void businessAnalyse(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.select("wd_id");
|
|
|
+ queryWrapper.in("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("wd_name", channelMapAceeptVo.getSearchText());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|