|
@@ -199,6 +199,11 @@ public class BossDataExhibitionServiceImpl implements IBossDataExhibitionService
|
|
|
*/
|
|
|
@Override
|
|
|
public Result getAccountTrendByMediaType(String mediaType, String startTime, String endTime) {
|
|
|
+ Map<String,Object> resultMap = new HashMap();
|
|
|
+ // 获取两个日期之间 所有的 时间 年-月-日
|
|
|
+ List<String> betweenDaysList = DateUtils.getAllDatesOfTwoTimes(startTime,endTime);
|
|
|
+ resultMap.put("time",betweenDaysList);
|
|
|
+
|
|
|
Integer stat_tim = DateUtils.getDateInteger(startTime);
|
|
|
Integer end_tim = DateUtils.getDateInteger(endTime);
|
|
|
List<AccountTrendPojo> resultList = Arrays.asList();
|
|
@@ -208,14 +213,90 @@ public class BossDataExhibitionServiceImpl implements IBossDataExhibitionService
|
|
|
}else if (StringUtils.equals("2",mediaType)){
|
|
|
resultList = bossDataExhibitionMapper.getMediaTypeAccountTrendKuaishou(stat_tim,end_tim);
|
|
|
}
|
|
|
- if (!Check.isNull(resultList)){
|
|
|
- Map<String,List<AccountTrendPojo>> resultMap = resultList.stream().collect(Collectors.groupingBy(AccountTrendPojo::getArea));
|
|
|
- return Result.successMsg(("1".equals(mediaType) ? "【头条】" : "【快手】")+"===分公司-分日-账户消耗数据查询成功。",resultMap);
|
|
|
+
|
|
|
+ if (Check.isNull(resultList)) {
|
|
|
+ return Result.error("账户消耗数据查询为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据组装
|
|
|
+ */
|
|
|
+ //根据 区域分组
|
|
|
+ Map<String,List<AccountTrendPojo>> map = resultList.stream().collect(Collectors.groupingBy(AccountTrendPojo::getArea));
|
|
|
+
|
|
|
+ //1-华北
|
|
|
+ List<AccountTrendPojo> huaBeiList = !map.containsKey("华北") ? null : map.get("华北");
|
|
|
+
|
|
|
+ List<String> huaBeiCostList = new ArrayList();
|
|
|
+ if (!Check.isNull(huaBeiList)){
|
|
|
+ //获取数据 时间 集合
|
|
|
+ List<String> huabeiTime = huaBeiList.stream().map(AccountTrendPojo::getTime).collect(Collectors.toList());
|
|
|
+ // 补充数据
|
|
|
+ huaBeiList = getDateSupplement(betweenDaysList,huabeiTime,huaBeiList);
|
|
|
+ // 获取属性 cost 返回数组
|
|
|
+ huaBeiCostList = huaBeiList.stream().map(AccountTrendPojo::getCost).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ resultMap.put("huaBei",huaBeiCostList);
|
|
|
+
|
|
|
+ //2-华南
|
|
|
+ List<String> huaNanCostList = new ArrayList();
|
|
|
+ List<AccountTrendPojo> huaNanList = !map.containsKey("华南") ? null : map.get("华南");
|
|
|
+ if (!Check.isNull(huaNanList)){
|
|
|
+ List<String> huaNanTime = huaNanList.stream().map(AccountTrendPojo::getTime).collect(Collectors.toList());
|
|
|
+ huaNanList = getDateSupplement(betweenDaysList,huaNanTime,huaNanList);
|
|
|
+ huaNanCostList = huaNanList.stream().map(AccountTrendPojo::getCost).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ resultMap.put("huaNan",huaNanCostList);
|
|
|
+
|
|
|
+ //3-华东
|
|
|
+ List<String> huaDongCostList = new ArrayList();
|
|
|
+ List<AccountTrendPojo> huaDongList = !map.containsKey("华东") ? null : map.get("华东");
|
|
|
+ if (!Check.isNull(huaDongList)){
|
|
|
+ List<String> huaDongTime = huaDongList.stream().map(AccountTrendPojo::getTime).collect(Collectors.toList());
|
|
|
+ huaDongList = getDateSupplement(betweenDaysList,huaDongTime,huaDongList);
|
|
|
+ huaDongCostList = huaDongList.stream().map(AccountTrendPojo::getCost).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ resultMap.put("huaDong",huaDongCostList);
|
|
|
+
|
|
|
+ //4-骄阳
|
|
|
+ List<String> jiaoYangCostList = new ArrayList();
|
|
|
+ List<AccountTrendPojo> jiaoYangList = !map.containsKey("骄阳") ? null : map.get("骄阳");
|
|
|
+ if (!Check.isNull(jiaoYangList)){
|
|
|
+ List<String> jiaoYangTime = jiaoYangList.stream().map(AccountTrendPojo::getTime).collect(Collectors.toList());
|
|
|
+ jiaoYangList = getDateSupplement(betweenDaysList,jiaoYangTime,jiaoYangList);
|
|
|
+ jiaoYangCostList = jiaoYangList.stream().map(AccountTrendPojo::getCost).collect(Collectors.toList());
|
|
|
}
|
|
|
- return Result.error("暂无数据。");
|
|
|
+ resultMap.put("jiaoYang",jiaoYangCostList);
|
|
|
+
|
|
|
+ return Result.successMsg(("1".equals(mediaType) ? "【头条】" : "【快手】")+"===分公司-分日-账户消耗数据查询成功。",resultMap);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 补充数据 没有时间的补充时间并添加数据为0
|
|
|
+ * @param betweenDaysList 两个日期中间的所有日期集合
|
|
|
+ * @param nowList 现有日期的集合
|
|
|
+ * @param accountTrendPojoList 数据集合
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<AccountTrendPojo> getDateSupplement(List<String> betweenDaysList,List<String> nowList,List<AccountTrendPojo> accountTrendPojoList){
|
|
|
+ // 时间差集(所有时间段 - 已有的时间段)
|
|
|
+ List<String> reduceList = betweenDaysList.stream().filter(item -> !nowList.contains(item)).collect(Collectors.toList());
|
|
|
+ reduceList.forEach(str ->{
|
|
|
+ AccountTrendPojo pojo = new AccountTrendPojo();
|
|
|
+ pojo.setTime(str);
|
|
|
+ pojo.setCost("0");
|
|
|
+ accountTrendPojoList.add(pojo);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ //时间排序
|
|
|
+ accountTrendPojoList.sort(Comparator.comparing(AccountTrendPojo::getTime));
|
|
|
+ return accountTrendPojoList;
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @description: 项目消耗排行top10
|