Commit aec33295 by guojx

好办小程序埋点概览接口

parent 40c32225
package com.gic.haoban.manage.web.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.DataApiUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.manage.web.qo.eventtracking.WechatOverviewQO;
import com.gic.haoban.manage.web.qo.wechatwork.StoreGroupCommonQO;
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.vo.eventtracking.ViewModuleVO;
import com.gic.web.common.controller.NewBaseController;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 好办小程序埋点分析
* @Author guojx
* @Date 2024/5/30 9:06
*/
@RestController
@Slf4j
@RequestMapping("wechat-event-tracking")
public class EventTrackingController extends NewBaseController {
@Autowired
private StoreAuthUtils storeAuthUtils;
/**
* 概览
* @param qo
* @return
*/
@RequestMapping(value = "overview")
public RestResponse overview(@RequestBody WechatOverviewQO qo) {
Map<String, Object> res = DataApiUtils.http(getOverviewParam(qo).toJSONString(), "data_point_anal_hb_app_overview");
List<JSONObject> list = DataApiUtils.getDataList(res);
return RestResponse.successResult(CollectionUtils.isEmpty(list) ? null : list.get(0));
}
/**
* 趋势图
* @param qo
* @return
*/
@RequestMapping(value = "trend")
public RestResponse 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);
}
/**
* 模块访问统计
* @param qo
* @return
*/
@RequestMapping(value = "view-module")
public RestResponse<List<ViewModuleVO>> viewModule(@RequestBody WechatOverviewQO qo) {
JSONObject jsonParam = getOverviewParam(qo);
List<MapThreadHandlerRequest> list = new ArrayList<>();
// 1 访问次数 2 访问人数 3 访问时长
jsonParam.put("orderByField", 1);
list.add(new MapThreadHandlerRequest(jsonParam, "data_point_anal_hb_app_module", "1_visitCnt"));
jsonParam.put("orderByField", 2);
list.add(new MapThreadHandlerRequest(jsonParam, "data_point_anal_hb_app_module", "2_visitNum"));
jsonParam.put("orderByField", 3);
list.add(new MapThreadHandlerRequest(jsonParam, "data_point_anal_hb_app_module", "3_visitTime"));
Map<String, List<JSONObject>> map = ConcurrencyUtils.concurrencyDataForMap(list);
List<ViewModuleVO> voList = new ArrayList<>();
if (map != null && map.size() > 0) {
map.forEach((k,v) -> {
if (CollectionUtils.isNotEmpty(v)) {
String dataType = k.substring(0, 1);
String key = k.substring(2);
List<ViewModuleVO> tempList = new ArrayList<>();
for (JSONObject temp : v) {
ViewModuleVO vo = JSON.parseObject(temp.toJSONString(), ViewModuleVO.class);
vo.setDataType(Integer.parseInt(dataType));
vo.setData(temp.getLong(key));
tempList.add(vo);
}
voList.addAll(tempList);
}
});
}
return RestResponse.successResult(voList);
}
private JSONObject getOverviewParam(WechatOverviewQO qo) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(qo);
jsonObject.remove("storeGroupId");
jsonObject.remove("storeId");
storeAuthUtils.setCommonParam(jsonObject, new StoreGroupCommonQO().setStoreGroupId(qo.getStoreGroupId()).setStoreId(qo.getStoreId()));
return jsonObject;
}
}
package com.gic.haoban.manage.web.qo.eventtracking;
import lombok.Data;
import java.io.Serializable;
/**
* @Author guojx
* @Date 2024/5/30 9:14
*/
@Data
public class WechatOverviewQO implements Serializable {
/**
* yyyy-MM-dd
*/
private String startDate;
/**
* 数据类型 1天 2近7天 3近30天 4周 5月
*/
private Integer dateType;
/**
* 分组ID,可为空
*/
private String storeGroupId;
/**
* 门店ID。可为空
*/
private String storeId;
}
package com.gic.haoban.manage.web.vo.eventtracking;
import lombok.Data;
import java.io.Serializable;
/**
* @Author guojx
* @Date 2024/5/30 9:24
*/
@Data
public class TrendVO implements Serializable {
/**
* 员工总人数
*/
private Integer clerkNum;
/**
* 绑定人数
*/
private Integer bindingNum;
/**
* 绑定率
*/
private Double bindingRate;
/**
* 活跃人数
*/
private Integer visitNum;
/**
* 活跃率
*/
private Double visitRate;
/**
* 访问次数
*/
private Integer visitCnt;
/**
* 业务日期
*/
private String bizDate;
}
package com.gic.haoban.manage.web.vo.eventtracking;
import lombok.Data;
import java.io.Serializable;
/**
* @Author guojx
* @Date 2024/5/30 9:44
*/
@Data
public class ViewModuleVO implements Serializable {
/**
* 模块code
*/
private String moduleCode;
/**
* 模块名称
*/
private String moduleName;
/**
* 数值
*/
private Long data;
/**
* 1:访问次数 2:访问人数 3:访问时长 (单位秒)
*/
private Integer dataType;
}
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