|
@@ -26,7 +26,15 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import redis.clients.jedis.Jedis;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.YearMonth;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -68,12 +76,12 @@ public class ShopServiceImpl implements ShopService {
|
|
|
@Override
|
|
|
public ResponseJson<UserLoginVo> shortcutLogin(Integer userId) {
|
|
|
UserLoginVo userLoginVo = shopMapper.getShopByUserId(userId);
|
|
|
- // 生成token给用户
|
|
|
- String token = JwtUtil.createToken(userId);
|
|
|
- // 为了过期续签,将token存入redis,并设置超时时间
|
|
|
- redisService.set(token, token, JwtUtil.getExpireTime());
|
|
|
- userLoginVo.setToken(token);
|
|
|
if (null != userLoginVo) {
|
|
|
+ // 生成token给用户
|
|
|
+ String token = JwtUtil.createToken(userId);
|
|
|
+ // 为了过期续签,将token存入redis,并设置超时时间
|
|
|
+ redisService.set(token, token, JwtUtil.getExpireTime());
|
|
|
+ userLoginVo.setToken(token);
|
|
|
if (null != userLoginVo.getShopId()) {
|
|
|
if (null != userLoginVo.getShopStatus() && null != userLoginVo.getUserIdentity() && 3 == userLoginVo.getUserIdentity()) {
|
|
|
|
|
@@ -472,7 +480,13 @@ public class ShopServiceImpl implements ShopService {
|
|
|
m4.put("time", "近一年");
|
|
|
salesStatisticsList.add(m4);
|
|
|
result.put("salesStatisticsList", salesStatisticsList);
|
|
|
-
|
|
|
+ // 是否为营销供应商
|
|
|
+ Integer shopIsMark = shopMapper.getShopIsMark(shop.getShopId());
|
|
|
+ if (null != shopIsMark) {
|
|
|
+ result.put("isMark", true);
|
|
|
+ } else {
|
|
|
+ result.put("isMark", false);
|
|
|
+ }
|
|
|
return ResponseJson.success(result);
|
|
|
}
|
|
|
|
|
@@ -850,4 +864,487 @@ public class ShopServiceImpl implements ShopService {
|
|
|
return ResponseJson.success(null);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 供应商营销数据看板
|
|
|
+ *
|
|
|
+ * @param type
|
|
|
+ * @param marketReportId
|
|
|
+ * @param shopId
|
|
|
+ * @param startTime
|
|
|
+ * @param endTime
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<Map<String, Object>> preview(Integer type, Integer marketReportId, Integer shopId, String startTime, String endTime) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
+ SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(startTime)) {
|
|
|
+ startTime = dateFormat.format(dateFormat.parse(startTime));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(endTime)) {
|
|
|
+ endTime = dateFormat.format(dateFormat.parse(endTime));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ // name集合
|
|
|
+ ArrayList<String> name = new ArrayList<>();
|
|
|
+ // value 集合
|
|
|
+ ArrayList<Integer> value = new ArrayList<>();
|
|
|
+ // 备份(第二value)集合
|
|
|
+ ArrayList<Integer> backupsValues = new ArrayList<>();
|
|
|
+ // 唯一name集合
|
|
|
+ Set<String> set = new HashSet<>();
|
|
|
+ // 获取报表对应供应商数据
|
|
|
+ CmMarketShopVo shopInfo = shopMapper.getShopInfoById(shopId, type, marketReportId);
|
|
|
+ List<Integer> marketReportIds = shopMapper.getMarketReportIds(shopInfo.getId(), type, marketReportId, startTime, endTime);
|
|
|
+ log.info("marketReportIds===="+marketReportIds);
|
|
|
+ // 获取阶段描述
|
|
|
+ List<StageVo> summarize = new ArrayList<>();
|
|
|
+ List<StageVo> summarize1 = new ArrayList<>();
|
|
|
+ List<StageVo> summarize2 = new ArrayList<>();
|
|
|
+ if (null != marketReportIds && marketReportIds.size() > 0) {
|
|
|
+ List<StageVo> marketStage = shopMapper.getMarketStage(marketReportIds);
|
|
|
+ if (null != marketStage && marketStage.size() > 0) {
|
|
|
+ for (StageVo stage : marketStage) {
|
|
|
+ try {
|
|
|
+ stage.setAddTime(dateFormat.format(dateFormat.parse(stage.getReportDate())));
|
|
|
+ if ("1".equals(stage.getStage())) {
|
|
|
+ summarize.add(stage);
|
|
|
+ }
|
|
|
+ if ("2".equals(stage.getStage())) {
|
|
|
+ summarize1.add(stage);
|
|
|
+ }
|
|
|
+ if ("3".equals(stage.getStage())) {
|
|
|
+ summarize2.add(stage);
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("summarize", summarize);
|
|
|
+ map.put("summarize1", summarize1);
|
|
|
+ map.put("summarize2", summarize2);
|
|
|
+ // 获取漏斗模型数据
|
|
|
+ if (null != marketReportIds && marketReportIds.size() > 0) {
|
|
|
+ List<FunnelModelVo> marketFunnelModel = shopMapper.getMarketFunnelModel(marketReportIds);
|
|
|
+ int impressions = 0, hits = 0, visits = 0, consultation = 0, report = 0;
|
|
|
+ if (null != marketFunnelModel && marketFunnelModel.size() > 0) {
|
|
|
+ for (FunnelModelVo funnelModel : marketFunnelModel) {
|
|
|
+ impressions += funnelModel.getImpressions();
|
|
|
+ hits += funnelModel.getHits();
|
|
|
+ visits += funnelModel.getVisits();
|
|
|
+ consultation += funnelModel.getConsultation();
|
|
|
+ report += funnelModel.getReport();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) {
|
|
|
+ shopInfo.setChartTitle("("+startTime.replaceAll("-", "/") + "-" + endTime.replaceAll("-", "/")+")");
|
|
|
+ } else if (1 == type && null != marketReportId) {
|
|
|
+ shopInfo.setChartTitle("("+dateFormat.format(dateFormat.parse(shopInfo.getReportDate())).replaceAll("-", "/")+")");
|
|
|
+ } else {
|
|
|
+ shopInfo.setChartTitle("("+ (StringUtils.isNotBlank(shopInfo.getEndDate()) ? dateFormat.format(dateFormat.parse(shopInfo.getEndDate())).replaceAll("-", "/") : "") + ")");
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ shopInfo.setImpressions(impressions);
|
|
|
+ shopInfo.setHits(hits);
|
|
|
+ shopInfo.setVisits(visits);
|
|
|
+ shopInfo.setConsultation(consultation);
|
|
|
+ shopInfo.setReport(report);
|
|
|
+ }
|
|
|
+ map.put("shopInfo", shopInfo);
|
|
|
+ // 获取推文数据
|
|
|
+ List<ArticleReadVolumeVo> articleReadVolumeList = new ArrayList<>();
|
|
|
+ if (null != marketReportIds && marketReportIds.size() > 0) {
|
|
|
+ List<ArticleReadVolumeVo> marketArticleReadVolume = shopMapper.getMarketArticleReadVolume(marketReportIds);
|
|
|
+ if (null != marketArticleReadVolume && marketArticleReadVolume.size() > 0) {
|
|
|
+ for (ArticleReadVolumeVo articleReadVolume : marketArticleReadVolume) {
|
|
|
+ try {
|
|
|
+ articleReadVolume.setFirstTime(formatDate.format(formatDate.parse(articleReadVolume.getFirstTime())));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (!set.contains(articleReadVolume.getTitle())) {
|
|
|
+ set.add(articleReadVolume.getTitle());
|
|
|
+ articleReadVolumeList.add(articleReadVolume);
|
|
|
+ } else {
|
|
|
+ // 将有重复的推文数据 总阅读量 总展现量相加为一组数据
|
|
|
+ for (ArticleReadVolumeVo readVolume : articleReadVolumeList) {
|
|
|
+ if (articleReadVolume.getTitle().equals(readVolume.getTitle())) {
|
|
|
+ readVolume.setWechatNumber(MathUtil.add(readVolume.getWechatNumber(), articleReadVolume.getWechatNumber()).intValue());
|
|
|
+ readVolume.setTouchNumber(MathUtil.add(readVolume.getTouchNumber(), articleReadVolume.getTouchNumber()).intValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("volumeList", articleReadVolumeList);
|
|
|
+ // 公众号推文数据
|
|
|
+ ReturnDataVo articleReturnData = new ReturnDataVo();
|
|
|
+ if (null != marketReportIds && marketReportIds.size() > 0) {
|
|
|
+ if (null != articleReadVolumeList && articleReadVolumeList.size() > 0) {
|
|
|
+ name = new ArrayList<>(articleReadVolumeList.stream().map(ArticleReadVolumeVo::getTitleReferred).collect(Collectors.toList()));
|
|
|
+ articleReturnData.setNames(name);
|
|
|
+ value = new ArrayList<>(articleReadVolumeList.stream().map(ArticleReadVolumeVo::getWechatNumber).collect(Collectors.toList()));
|
|
|
+ articleReturnData.setValues(value);
|
|
|
+ backupsValues = new ArrayList<>(articleReadVolumeList.stream().map(ArticleReadVolumeVo::getTouchNumber).collect(Collectors.toList()));
|
|
|
+ articleReturnData.setBackupsValues(backupsValues);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("wechats", articleReturnData);
|
|
|
+ // 获取展现量数据
|
|
|
+ name = new ArrayList<>();
|
|
|
+ value = new ArrayList<>();
|
|
|
+ int generalNumber = 0, microBlog = 0, redBookNumber = 0, otherNumber = 0;
|
|
|
+ if (null != marketReportIds && marketReportIds.size() > 0) {
|
|
|
+ List<ImpressionsVo> marketImpressions = shopMapper.getMarketImpressions(marketReportIds);
|
|
|
+ if (null != marketImpressions && marketImpressions.size() > 0) {
|
|
|
+ for (ImpressionsVo imp : marketImpressions) {
|
|
|
+ generalNumber += imp.getGeneralNumber();
|
|
|
+ microBlog += imp.getMicroBlog();
|
|
|
+ redBookNumber += imp.getRedBookNumber();
|
|
|
+ otherNumber += imp.getOtherNumber();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ReturnDataVo returnData = new ReturnDataVo();
|
|
|
+ name.add("公众号");
|
|
|
+ name.add("微博");
|
|
|
+ name.add("小红书");
|
|
|
+ name.add("其它自媒体渠道");
|
|
|
+ returnData.setNames(name);
|
|
|
+ value.add(generalNumber);
|
|
|
+ value.add(microBlog);
|
|
|
+ value.add(redBookNumber);
|
|
|
+ value.add(otherNumber);
|
|
|
+ returnData.setValues(value);
|
|
|
+ map.put("intention", returnData);
|
|
|
+ // 获取点击量数据
|
|
|
+ name = new ArrayList<>();
|
|
|
+ value = new ArrayList<>();
|
|
|
+ generalNumber = 0; microBlog = 0; redBookNumber = 0; otherNumber = 0;
|
|
|
+ if (null != marketReportIds && marketReportIds.size() > 0) {
|
|
|
+ List<ReadVolumeVo> marketReadVolume = shopMapper.getMarketReadVolume(marketReportIds);
|
|
|
+ if (null != marketReadVolume && marketReadVolume.size() > 0) {
|
|
|
+ for (ReadVolumeVo readVolume : marketReadVolume) {
|
|
|
+ generalNumber += readVolume.getGeneralNumber();
|
|
|
+ microBlog += readVolume.getMicroBlog();
|
|
|
+ redBookNumber += readVolume.getRedBookNumber();
|
|
|
+ otherNumber += readVolume.getOtherNumber();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ReturnDataVo readVolumeReturnData = new ReturnDataVo();
|
|
|
+ name.add("公众号");
|
|
|
+ name.add("微博");
|
|
|
+ name.add("小红书");
|
|
|
+ name.add("其它自媒体渠道");
|
|
|
+ readVolumeReturnData.setNames(name);
|
|
|
+ value.add(generalNumber);
|
|
|
+ value.add(microBlog);
|
|
|
+ value.add(redBookNumber);
|
|
|
+ value.add(otherNumber);
|
|
|
+ readVolumeReturnData.setValues(value);
|
|
|
+ map.put("allVisits", readVolumeReturnData);
|
|
|
+ // 获取SEO汇总数据
|
|
|
+ List<SummaryVo> summaryList = new ArrayList<>();
|
|
|
+ set = new HashSet<>();
|
|
|
+ if (null != marketReportIds && marketReportIds.size() > 0) {
|
|
|
+ List<SummaryVo> marketSummary = shopMapper.getMarketSummary(marketReportIds);
|
|
|
+ List<ReturnDataVo> returnDataList = new ArrayList<>();
|
|
|
+ if (null != marketSummary && marketSummary.size() > 0) {
|
|
|
+ for (SummaryVo summary : marketSummary) {
|
|
|
+ if (!set.contains(summary.getKeyword())) {
|
|
|
+ set.add(summary.getKeyword());
|
|
|
+ summaryList.add(summary);
|
|
|
+ } else {
|
|
|
+ for (SummaryVo summary1 : summaryList) {
|
|
|
+ if (summary.getKeyword().equals(summary1.getKeyword())) {
|
|
|
+ summary1.setSearchVolume(MathUtil.add(summary1.getSearchVolume(), summary.getSearchVolume()).intValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null != summaryList && summaryList.size() > 0) {
|
|
|
+ for (SummaryVo summary : summaryList) {
|
|
|
+ ReturnDataVo summaryReturnData = new ReturnDataVo();
|
|
|
+ summaryReturnData.setName(summary.getKeyword());
|
|
|
+ summaryReturnData.setValue(summary.getSearchVolume());
|
|
|
+ summaryReturnData.setSeo(summary.getSeoRanking());
|
|
|
+ returnDataList.add(summaryReturnData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("keywordList", summaryList);
|
|
|
+ // 获取访问量数据
|
|
|
+ name = new ArrayList<>();
|
|
|
+ value = new ArrayList<>();
|
|
|
+ int clubNumber = 0, touristNumber = 0;
|
|
|
+ if (null != marketReportIds && marketReportIds.size() > 0) {
|
|
|
+ List<VisitsVo> marketVisits = shopMapper.getMarketVisits(marketReportIds);
|
|
|
+ if (null != marketVisits && marketVisits.size() > 0) {
|
|
|
+ for (VisitsVo vis : marketVisits) {
|
|
|
+ clubNumber += vis.getClubNumber();
|
|
|
+ touristNumber += vis.getTouristNumber();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ReturnDataVo visitsReturnData = new ReturnDataVo();
|
|
|
+ name.add("机构访问量");
|
|
|
+ name.add("游客访问量");
|
|
|
+ visitsReturnData.setNames(name);
|
|
|
+ value.add(clubNumber);
|
|
|
+ value.add(touristNumber);
|
|
|
+ visitsReturnData.setValues(value);
|
|
|
+ map.put("stationVisits", visitsReturnData);
|
|
|
+ // 获取访客来源分布数据
|
|
|
+ int search = 0, general = 0, proMicroBlog = 0, directAccess = 0;
|
|
|
+ if (null != marketReportIds && marketReportIds.size() > 0) {
|
|
|
+ List<ProportionVo> marketProportion = shopMapper.getMarketProportion(marketReportIds);
|
|
|
+ if (null != marketProportion && marketProportion.size() > 0) {
|
|
|
+ for (ProportionVo proportion : marketProportion) {
|
|
|
+ search += proportion.getSearch();
|
|
|
+ general += proportion.getGeneral();
|
|
|
+ proMicroBlog += proportion.getMicroBlog();
|
|
|
+ directAccess += proportion.getDirectAccess();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<ReturnDataVo> proportionDataList = new ArrayList<>();
|
|
|
+ ReturnDataVo proportionReturnData = new ReturnDataVo();
|
|
|
+ proportionReturnData.setName("搜索引擎");
|
|
|
+ proportionReturnData.setValue(search);
|
|
|
+ proportionDataList.add(proportionReturnData);
|
|
|
+ proportionReturnData = new ReturnDataVo();
|
|
|
+ proportionReturnData.setName("微信平台");
|
|
|
+ proportionReturnData.setValue(general);
|
|
|
+ proportionDataList.add(proportionReturnData);
|
|
|
+ proportionReturnData = new ReturnDataVo();
|
|
|
+ proportionReturnData.setName("微博");
|
|
|
+ proportionReturnData.setValue(proMicroBlog);
|
|
|
+ proportionDataList.add(proportionReturnData);
|
|
|
+ proportionReturnData = new ReturnDataVo();
|
|
|
+ proportionReturnData.setName("直接访问");
|
|
|
+ proportionReturnData.setValue(directAccess);
|
|
|
+ proportionDataList.add(proportionReturnData);
|
|
|
+ map.put("proportion", proportionDataList);
|
|
|
+ // 获取页面平均访问时长数据
|
|
|
+ set = new HashSet<>();
|
|
|
+ List<PageDurationVo> pageDurationList = new ArrayList<>();
|
|
|
+ if (null != marketReportIds && marketReportIds.size() > 0) {
|
|
|
+ List<PageDurationVo> marketPageDuration = shopMapper.getMarketPageDuration(marketReportIds);
|
|
|
+ if (null != marketPageDuration && marketPageDuration.size() > 0) {
|
|
|
+ for (PageDurationVo pageDuration : marketPageDuration) {
|
|
|
+ if (!set.contains(pageDuration.getPageLabel())) {
|
|
|
+ set.add(pageDuration.getPageLabel());
|
|
|
+ pageDurationList.add(pageDuration);
|
|
|
+ } else {
|
|
|
+ for (PageDurationVo pageDuration1 : pageDurationList) {
|
|
|
+ if (pageDuration.getPageLabel().equals(pageDuration1.getPageLabel())) {
|
|
|
+ pageDuration1.setAccessDuration(MathUtil.add(pageDuration1.getAccessDuration(), pageDuration.getAccessDuration()).intValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ReturnDataVo pageDurationReturnData = new ReturnDataVo();
|
|
|
+ name = new ArrayList<>(set);
|
|
|
+ pageDurationReturnData.setNames(name);
|
|
|
+ value = new ArrayList<>(pageDurationList.stream().map(PageDurationVo::getAccessDuration).collect(Collectors.toList()));
|
|
|
+ pageDurationReturnData.setValues(value);
|
|
|
+ map.put("visitTimes", pageDurationReturnData);
|
|
|
+ // 获取广告图点击量数据
|
|
|
+ List<AdvertHitsVo> marketAdvertHits = new ArrayList<>();
|
|
|
+ if (null != marketReportIds && marketReportIds.size() > 0) {
|
|
|
+ marketAdvertHits = shopMapper.getMarketAdvertHits(marketReportIds);
|
|
|
+ }
|
|
|
+ map.put("bannerList", marketAdvertHits);
|
|
|
+ // 获取咨询数量数据
|
|
|
+ name = new ArrayList<>();
|
|
|
+ value = new ArrayList<>();
|
|
|
+ if (null != marketReportIds && marketReportIds.size() > 0) {
|
|
|
+ List<CmMarketRemarkVo> marketRemark = shopMapper.getMarketRemark(marketReportIds);
|
|
|
+ if (null != marketRemark && marketRemark.size() > 0) {
|
|
|
+ for (CmMarketRemarkVo remark : marketRemark) {
|
|
|
+ try {
|
|
|
+ name.add(dateFormat.format(dateFormat.parse(remark.getAddTime())));
|
|
|
+ value.add(remark.getRemarkNumber());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ReturnDataVo remarkReturnData = new ReturnDataVo();
|
|
|
+ remarkReturnData.setNames(name);
|
|
|
+ remarkReturnData.setValues(value);
|
|
|
+ map.put("leadUserMonthly", remarkReturnData);
|
|
|
+ // 供应商相关标签
|
|
|
+ List<String> shopKeyword = shopMapper.getShopKeyword(shopInfo.getShopId());
|
|
|
+
|
|
|
+ List<ReturnDataVo> regionMap = new ArrayList<>();
|
|
|
+ // 访问供应商用户对应身份
|
|
|
+ List<ReturnEntityVo> userIdentity = new ArrayList<>();
|
|
|
+ // 访问供应商用户对应机构类型
|
|
|
+ List<ReturnEntityVo> clubType = new ArrayList<>();
|
|
|
+ if (1 == type) {
|
|
|
+ // 预览
|
|
|
+ if (StringUtils.isBlank(startTime)) {
|
|
|
+ startTime = monthFirstDay(shopInfo.getReportDate());
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(endTime)) {
|
|
|
+ endTime = monthLastDay(shopInfo.getReportDate());
|
|
|
+ }
|
|
|
+ } else{
|
|
|
+ // 供应商主页进入
|
|
|
+ if (StringUtils.isBlank(startTime)) {
|
|
|
+ startTime = shopInfo.getStartDate();
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(endTime)) {
|
|
|
+ endTime = shopInfo.getEndDate();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ log.info("startTime===="+startTime);
|
|
|
+ log.info("endTime===="+endTime);
|
|
|
+ log.info("shopKeyword===="+shopKeyword);
|
|
|
+ if (null != shopKeyword && shopKeyword.size() > 0) {
|
|
|
+ // 访问供应商用户对于所在地区
|
|
|
+ List<String> region = shopMapper.getRegion(startTime, endTime, shopKeyword);
|
|
|
+ region.removeIf(re -> re.length() < 2);
|
|
|
+ Set<String> province = new HashSet<>();
|
|
|
+ String com = "";
|
|
|
+ for (String str : region) {
|
|
|
+ String trim = str.trim();
|
|
|
+ com = trim.substring(0, 2);
|
|
|
+ province.add(com);
|
|
|
+ }
|
|
|
+ for (String str : province) {
|
|
|
+ ReturnDataVo rData = new ReturnDataVo();
|
|
|
+ rData.setName(str);
|
|
|
+ List<String> collect = region.stream().filter(pro -> pro.substring(0, 3).contains(str)).collect(Collectors.toList());
|
|
|
+ rData.setValue(collect.size());
|
|
|
+ regionMap.add(rData);
|
|
|
+ }
|
|
|
+ set = new HashSet<>();
|
|
|
+ List<ReturnEntityVo> userIdentity1 = shopMapper.getUserIdentity(startTime, endTime, shopKeyword);
|
|
|
+ // 所有值之和
|
|
|
+ AtomicInteger maxUserValue = new AtomicInteger(0);
|
|
|
+ if (null != userIdentity1 && userIdentity1.size() > 0) {
|
|
|
+ for (ReturnEntityVo returnEntityVo : userIdentity1) {
|
|
|
+ maxUserValue.updateAndGet(max -> max + Integer.parseInt(returnEntityVo.getValue()));
|
|
|
+ if (!set.contains(returnEntityVo.getName())) {
|
|
|
+ set.add(returnEntityVo.getName());
|
|
|
+ userIdentity.add(returnEntityVo);
|
|
|
+ } else {
|
|
|
+ for (ReturnEntityVo returnUserIdentity : userIdentity) {
|
|
|
+ returnUserIdentity.setValue(MathUtil.add(returnUserIdentity.getValue(), returnEntityVo.getValue()).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userIdentity.forEach(returnUserIdentity -> returnUserIdentity.setValue(MathUtil.div(returnUserIdentity.getValue(), maxUserValue.get(), 2).toString()));
|
|
|
+ }
|
|
|
+ set = new HashSet<>();
|
|
|
+ List<ReturnEntityVo> clubType1 = shopMapper.getClubType(startTime, endTime, shopKeyword);
|
|
|
+ if (null != clubType1 && clubType1.size() > 0) {
|
|
|
+ // 所有值之和
|
|
|
+ AtomicInteger maxClubTypeValue = new AtomicInteger(0);
|
|
|
+ for (ReturnEntityVo returnEntityVo : clubType1) {
|
|
|
+ maxClubTypeValue.updateAndGet(max -> max + Integer.parseInt(returnEntityVo.getValue()));
|
|
|
+ if (!set.contains(returnEntityVo.getName())) {
|
|
|
+ set.add(returnEntityVo.getName());
|
|
|
+ clubType.add(returnEntityVo);
|
|
|
+ } else {
|
|
|
+ for (ReturnEntityVo returnUserIdentity : clubType) {
|
|
|
+ returnUserIdentity.setValue(MathUtil.add(returnUserIdentity.getValue(), returnEntityVo.getValue()).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userIdentity.forEach(returnUserIdentity -> returnUserIdentity.setValue(MathUtil.div(returnUserIdentity.getValue(), maxClubTypeValue.get(), 2).toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("channels", regionMap);
|
|
|
+ map.put("userIdentity", userIdentity);
|
|
|
+ map.put("urbanize", clubType);
|
|
|
+ // 是否有数据
|
|
|
+ if (null == marketReportIds || marketReportIds.size() <= 0) {
|
|
|
+ map.put("code", -1);
|
|
|
+ } else {
|
|
|
+ map.put("code", 0);
|
|
|
+ }
|
|
|
+ // 时间筛选
|
|
|
+ List<String> marketReportDataList = new ArrayList<>();
|
|
|
+ if (null != shopInfo) {
|
|
|
+ marketReportDataList = shopMapper.getMarketReportDataList(shopInfo.getShopId());
|
|
|
+ List<String> yearMonth = monthList(marketReportDataList);
|
|
|
+ map.put("yearMonth", yearMonth);
|
|
|
+ } else {
|
|
|
+ List<String> yearMonth = monthList(marketReportDataList);
|
|
|
+ map.put("yearMonth", yearMonth);
|
|
|
+ }
|
|
|
+ return ResponseJson.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取该月份首日日期
|
|
|
+ * @param reportDate 2023-12
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String monthFirstDay(String reportDate) {
|
|
|
+ String[] split = reportDate.split("-");
|
|
|
+ Integer year = Integer.parseInt(split[0]);
|
|
|
+ Integer month = Integer.parseInt(split[1]);
|
|
|
+
|
|
|
+ LocalDate firstDayOfMonth = LocalDate.of(year, month, 1);
|
|
|
+ return firstDayOfMonth.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取该月份最后一天日期
|
|
|
+ * @param reportDate 2023-12
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String monthLastDay(String reportDate) {
|
|
|
+ String[] split = reportDate.split("-");
|
|
|
+ Integer year = Integer.parseInt(split[0]);
|
|
|
+ Integer month = Integer.parseInt(split[1]);
|
|
|
+
|
|
|
+ LocalDate firstDayOfMonth = LocalDate.of(year, month, 1);
|
|
|
+ LocalDate lastDayOfMonth = firstDayOfMonth.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ return lastDayOfMonth.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 不包含的月份
|
|
|
+ * todo 暂定5年
|
|
|
+ * @param marketReportDataList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<String> monthList(List<String> marketReportDataList) {
|
|
|
+ Integer[] yearList = new Integer[]{2023, 2024, 2025, 2026, 2027};
|
|
|
+ ArrayList<String> yearMonth = new ArrayList<>();
|
|
|
+ for (Integer year : yearList) {
|
|
|
+ List<YearMonth> collect = Stream.iterate(YearMonth.of(year, 1), month -> month.plusMonths(1)).limit(12).collect(Collectors.toList());
|
|
|
+ String strip = StringUtils.strip(collect.toString(), "[]");
|
|
|
+ String[] split = strip.split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ yearMonth.add(s.replaceAll("-", "").trim());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null != marketReportDataList && marketReportDataList.size() > 0) {
|
|
|
+ marketReportDataList.replaceAll(market -> market.replaceAll("-", ""));
|
|
|
+ }
|
|
|
+ yearMonth.removeIf(marketReportDataList::contains);
|
|
|
+ return yearMonth;
|
|
|
+ }
|
|
|
}
|