Commit 82ba668f by guojx

趋势接口时间补零

parent fe7a09b0
......@@ -17,6 +17,8 @@ import com.gic.haoban.manage.web.utils.AuthorizedUserUtils;
import com.gic.haoban.manage.web.utils.data.ConcurrencyUtils;
import com.gic.haoban.manage.web.utils.data.MapThreadHandlerRequest;
import com.gic.haoban.manage.web.utils.data.StoreAuthUtils;
import com.gic.haoban.manage.web.utils.eventtracking.DateExpandUtils;
import com.gic.haoban.manage.web.vo.eventtracking.TrendVO;
import com.gic.haoban.manage.web.vo.eventtracking.ViewModuleVO;
import com.gic.haoban.manage.web.vo.eventtracking.WechatEventTrackingClerkVO;
import com.gic.haoban.manage.web.vo.eventtracking.WechatEventTrackingStoreGroupVO;
......@@ -35,8 +37,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 好办小程序埋点分析
......@@ -72,10 +76,29 @@ public class EventTrackingController extends NewBaseController {
* @return
*/
@RequestMapping(value = "trend")
public RestResponse trend(@RequestBody WechatOverviewQO qo) {
public RestResponse<List<TrendVO>> trend(@RequestBody WechatOverviewQO qo) {
Map<String, Object> res = DataApiUtils.http(getOverviewParam(qo).toJSONString(), "data_point_anal_hb_app_trend");
List<JSONObject> list = DataApiUtils.getDataList(res);
return RestResponse.successResult(list);
Map<String, JSONObject> map = new HashMap<>();
if (CollectionUtils.isNotEmpty(list)) {
map = list.stream().collect(Collectors.toMap(e ->e.getString("bizDate"), e -> e));
}
//日期补零
List<String> dateList = DateExpandUtils.getDateList(qo.getStartDate(), qo.getEndDate(), qo.getDateType());
List<TrendVO> voList = new ArrayList<>();
for (String date : dateList) {
TrendVO vo = null;
JSONObject temp = map.get(date);
if (temp == null) {
vo = new TrendVO();
} else {
vo = JSONObject.parseObject(temp.toJSONString(), TrendVO.class);
}
vo.setBizDate(date);
voList.add(vo);
}
return RestResponse.successResult(voList);
}
/**
......
......@@ -16,6 +16,8 @@ public class WechatOverviewQO implements Serializable {
*/
private String startDate;
private String endDate;
/**
* 数据类型 1天 2近7天 3近30天 4周 5月
*/
......
package com.gic.haoban.manage.web.utils.eventtracking;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.DataApiUtils;
import com.gic.commons.util.DateUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Author guojx
* @Date 2024/5/30 15:34
*/
public class DateExpandUtils {
public static List<String> getDateList(String startDate, String endDate, Integer dateType) {
//数据类型 1天 2近7天 3近30天 4周 5月
List<String> list = new ArrayList<>();
if (dateType == null) {
dateType = 1;
}
try {
switch (dateType) {
case 1:
list.add(startDate);
break;
case 4:
JSONObject jsonObject = new JSONObject();
jsonObject.put("startDate", startDate);
jsonObject.put("pageNum", 1);
jsonObject.put("pageSize", 100);
Map<String, Object> res = DataApiUtils.http(jsonObject.toJSONString(), "data_pub_date_week");
List<JSONObject> data = DataApiUtils.getPageList(res);
list = data.stream().map(e ->e.getString("weekYear")).collect(Collectors.toList());
break;
default:
list = DateUtil.getBetweenDates(startDate, endDate);
}
} catch (Exception e) {
}
return list;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment