Commit 8fe65855 by 墨竹

Merge remote-tracking branch 'origin/developer' into developer

parents 46662f37 e8dddca6
......@@ -18,6 +18,8 @@ public class HmLinkSearchQDTO implements Serializable {
private Integer linkType;
private String sortColumn ;
private String sortType ;
private Long linkId;
private String storeId;
public String getSortColumn() {
return sortColumn;
......@@ -82,4 +84,22 @@ public class HmLinkSearchQDTO implements Serializable {
public void setLinkType(Integer linkType) {
this.linkType = linkType;
}
public Long getLinkId() {
return linkId;
}
public HmLinkSearchQDTO setLinkId(Long linkId) {
this.linkId = linkId;
return this;
}
public String getStoreId() {
return storeId;
}
public HmLinkSearchQDTO setStoreId(String storeId) {
this.storeId = storeId;
return this;
}
}
package com.gic.haoban.manage.web.controller.hm;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import com.gic.commons.util.DateUtil;
import com.gic.haoban.manage.api.service.statistics.DataStatisticsApiService;
import com.gic.haoban.manage.web.utils.statistics.DataStatisticsParamUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
......@@ -74,6 +73,8 @@ public class HmLinkController {
private MemberTagApiService memberTagApiService;
@Autowired
private WxUserAddLogApiService wxUserAddLogApiService;
@Autowired
private DataStatisticsApiService dataStatisticsApiService;
@RequestMapping("add")
@GicLogRecord(value = "${#logValue}", category = GicLogRecordCategoryEnum.RECHAGE_CENTER, optType = GicLogRecordOptTypeEnum.RECHAGE_MODIFY_OPT, userFunc = LogRecordUserService.class, optPage = "活码")
......@@ -499,12 +500,45 @@ public class HmLinkController {
@RequestMapping("page")
public RestResponse<Object> page(HmLinkSearchQDTO qdto, BasePageInfo basePageInfo) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
qdto.setWxEnterpriseId(loginUser.getWxEnterpriseId());
qdto.setEnterpriseId(loginUser.getEnterpriseId());
ServiceResponse<Page<HmLinkDTO>> resp = this.hmLinkApiService.listPage(qdto, basePageInfo);
Page<HmLinkDTO> page = resp.getResult();
JSONObject jsonObject = new JSONObject();
jsonObject.put("enterpriseId", loginUser.getEnterpriseId());
if (qdto.getLinkId() != null) {
jsonObject.put("linkId", qdto.getLinkId());
}
if (StringUtils.isNotBlank(qdto.getStoreId())) {
jsonObject.put("storeId", qdto.getStoreId());
}
if (qdto.getLinkType() != null) {
jsonObject.put("linkType", qdto.getLinkType());
}
if (qdto.getStartDate() != null) {
jsonObject.put("startTime", DateUtil.getStartTimeOfDay(qdto.getStartDate()));
}
if (qdto.getEndDate() != null) {
jsonObject.put("endTime", DateUtil.getEndTimeOfDay(qdto.getEndDate()));
}
if (StringUtils.isNotBlank(qdto.getSearchParams())) {
jsonObject.put("linkSelect", qdto.getSearchParams());
}
if (StringUtils.isBlank(qdto.getSortColumn())) {
qdto.setSortColumn("createTime");
}
if (StringUtils.isBlank(qdto.getSortType())) {
qdto.setSortType("desc");
}
jsonObject.put("orderByField", qdto.getSortColumn() + " " + qdto.getSortType());
//用于好办链接列表数据 企业+链接
JSONObject param = DataStatisticsParamUtils.getParam(basePageInfo, jsonObject);
Page page = DataStatisticsParamUtils.getPage(dataStatisticsApiService.post("data_haoban_link_list", param));
if (page == null) {
return RestResponse.successResult();
}
Page<HmLinkListVO> retPage = EntityUtil.changeEntityByJSON(Page.class, page);
List<HmLinkListVO> list = EntityUtil.changeEntityListByJSON(HmLinkListVO.class, page.getResult());
if (CollectionUtils.isEmpty(list)) {
return RestResponse.successResult(retPage);
}
ServiceResponse<String> urlResp = this.hmLinkApiService.getHmLinkUrl();
list.forEach(item -> {
item.setLinkUrl(urlResp.getResult() + item.getShortCode());
......@@ -555,28 +589,80 @@ public class HmLinkController {
// 链接统计
@RequestMapping("statistics/total")
public RestResponse<Object> statistics(Long linkId) {
HmLinkStatisticsVO vo = new HmLinkStatisticsVO();
return RestResponse.successResult(vo);
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
JSONObject jsonObject = new JSONObject();
jsonObject.put("enterpriseId", loginUser.getEnterpriseId());
jsonObject.put("linkId", linkId);
JSONObject param = DataStatisticsParamUtils.getParamNoPage(jsonObject);
//HmLinkStatisticsVO vo = new HmLinkStatisticsVO();
//用于好办链接概览数据 企业+链接
return DataStatisticsParamUtils.responseOne(dataStatisticsApiService.post("data_haoban_link_overview", param));
}
// 统计图表
@RequestMapping("statistics/chart")
public RestResponse<Object> statisticsChart(Long linkId, Date startTime, Date endTime) {
HmLinkStatisticsVO vo = new HmLinkStatisticsVO();
List<HmLinkStatisticsVO> list = new ArrayList<>();
list.add(vo);
return RestResponse.successResult(list);
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
JSONObject jsonObject = new JSONObject();
jsonObject.put("enterpriseId", loginUser.getEnterpriseId());
jsonObject.put("linkId", linkId);
if (startTime == null) {
//过去7天
Calendar cl = Calendar.getInstance();
cl.add(Calendar.DATE, -7);
startTime = cl.getTime();
}
startTime = DateUtil.getStartTimeOfDay(startTime);
jsonObject.put("startTime", startTime);
if (endTime == null) {
endTime = new Date();
}
endTime = DateUtil.getEndTimeOfDay(endTime);
jsonObject.put("endTime", endTime);
//用于链接添加趋势图数据 企业+链接+日期
String apolloKey = "data_haoban_link_add_trend_d";
//如果天数大于60,调用月接口
if (DateUtil.daysBetween(startTime, endTime) > 60) {
apolloKey = "data_haoban_link_add_trend_m";
}
JSONObject param = DataStatisticsParamUtils.getParamNoPage(jsonObject);
return DataStatisticsParamUtils.response(dataStatisticsApiService.post(apolloKey, param));
}
// 导购统计
@RequestMapping("statistics/clerk")
public RestResponse<Object> statisticsClerk(Long linkId, String storeSearchParams, String clerkSearchParams,
Date startTime, Date endTime, BasePageInfo basePageInfo) {
List<HmLinkStatisticsClerkVO> list = new ArrayList<>();
list.add(new HmLinkStatisticsClerkVO());
Page<HmLinkStatisticsClerkVO> page = new Page<>();
page.setResult(list);
return RestResponse.successResult(page);
Date startTime, Date endTime, BasePageInfo basePageInfo, String sortColumn, String sortType) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
JSONObject jsonObject = new JSONObject();
jsonObject.put("enterpriseId", loginUser.getEnterpriseId());
jsonObject.put("linkId", linkId);
if (startTime != null) {
jsonObject.put("startTime", DateUtil.getStartTimeOfDay(startTime));
}
if (endTime != null) {
jsonObject.put("endTime", DateUtil.getEndTimeOfDay(endTime));
}
if (StringUtils.isNotBlank(storeSearchParams)) {
jsonObject.put("linkSelect1", storeSearchParams);
}
if (StringUtils.isNotBlank(clerkSearchParams)) {
jsonObject.put("linkSelect2", clerkSearchParams);
}
if (StringUtils.isBlank(sortColumn)) {
//今日新增人数
sortColumn = "addNum";
}
if (StringUtils.isBlank(sortType)) {
sortType = "desc";
}
jsonObject.put("orderByField", sortColumn + " " + sortType);
JSONObject param = DataStatisticsParamUtils.getParam(basePageInfo, jsonObject);
//用于链接明细导购数据 企业+链接+导购
return DataStatisticsParamUtils.responsePage(dataStatisticsApiService.post("data_haoban_link_detail", param));
}
// 加好友列表
......
package com.gic.haoban.manage.web.utils.statistics;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.web.qo.PageQo;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.manage.api.dto.statistics.StatisticsDTO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* 数据接口参数拼接工具
* @Author guojx
* @Date 2022/7/13 10:49
*/
public class DataStatisticsParamUtils {
private static final Logger LOGGER = LogManager.getLogger(DataStatisticsParamUtils.class);
public static JSONObject getParam(BasePageInfo basePageInfo, JSONObject objParam) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("pageNo", basePageInfo.getPageNum());
jsonObject.put("pageSize", basePageInfo.getPageSize());
if (objParam != null) {
if (objParam.containsKey("storeId")) {
Object storeId = objParam.get("storeId");
if (storeId == null || StringUtils.isBlank(storeId.toString())) {
objParam.remove("storeId");
}
}
}
jsonObject.put("inFields", objParam);
return jsonObject;
}
public static JSONObject getParamNoPage(JSONObject objParam) {
JSONObject jsonObject = new JSONObject();
if (objParam != null) {
if (objParam.containsKey("storeId")) {
Object storeId = objParam.get("storeId");
if (storeId == null || StringUtils.isBlank(storeId.toString())) {
objParam.remove("storeId");
}
}
}
jsonObject.put("inFields", objParam);
return jsonObject;
}
public static RestResponse response(ServiceResponse<StatisticsDTO> res) {
if (res.isSuccess()) {
StatisticsDTO statisticsDTO = res.getResult();
if (statisticsDTO == null) {
return RestResponse.successResult();
}
return RestResponse.successResult(statisticsDTO.getData());
}
return RestResponse.failure(res.getCode(), res.getMessage());
}
public static RestResponse responseOne(ServiceResponse<StatisticsDTO> res) {
if (res.isSuccess()) {
StatisticsDTO statisticsDTO = res.getResult();
if (statisticsDTO == null) {
return RestResponse.successResult();
}
if (CollectionUtils.isNotEmpty(statisticsDTO.getData())) {
return RestResponse.successResult(statisticsDTO.getData().get(0));
}
return RestResponse.successResult();
}
return RestResponse.failure(res.getCode(), res.getMessage());
}
public static RestResponse responsePage(ServiceResponse<StatisticsDTO> res) {
if (res.isSuccess()) {
StatisticsDTO statisticsDTO = res.getResult();
if (statisticsDTO == null) {
return RestResponse.successResult();
}
Page page = new Page();
page.setResult(statisticsDTO.getData());
page.setPageSize(statisticsDTO.getPage().getPageSize());
page.setCurrentPage(statisticsDTO.getPage().getCurrentPage());
page.setTotalPage(statisticsDTO.getPage().getTotalPage());
page.setTotalCount(statisticsDTO.getPage().getTotalCount());
return RestResponse.successResult(page);
}
return RestResponse.failure(res.getCode(), res.getMessage());
}
public static Page getPage(ServiceResponse<StatisticsDTO> res) {
RestResponse response = responsePage(res);
if ("0".equals(response.getCode())) {
Page page = (Page) response.getResult();
return page;
}
return null;
}
}
......@@ -113,4 +113,7 @@
timeout="10000" retries="0" check="false" />
<dubbo:reference id="hmQrcodeApiService" interface="com.gic.haoban.manage.api.service.hm.HmQrcodeApiService"
timeout="10000" retries="0" check="false" />
<dubbo:reference id="dataStatisticsApiService" interface="com.gic.haoban.manage.api.service.statistics.DataStatisticsApiService"
timeout="10000" retries="0" check="false" />
</beans>
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