Commit 0f78e5c6 by songyinghui

feat: 好书周报数据使用数据

parent 6efd94ee
......@@ -4,6 +4,8 @@ import cn.hutool.core.date.DateUtil;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.content.api.dto.material.ContentMaterialFrontDTO;
import com.gic.content.api.qdto.material.ContentMaterialPageFrontQDTO;
......@@ -12,7 +14,7 @@ import com.gic.haoban.manage.web.controller.content.adaptor.ClerkStoreAdaptor;
import com.gic.haoban.manage.web.controller.content.adaptor.MaterialDataAdaptor;
import com.gic.haoban.manage.web.qo.content.ContentMaterialBaseQO;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialAnalyzeDataQO;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialPersonalUsedQO;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialReportQO;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialStatisticsBaseQO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialClerkUsedDataVO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialDataOverviewVO;
......@@ -48,6 +50,8 @@ public class MaterialDataStaticsController {
private MaterialDataAdaptor materialDataAdaptor;
@Autowired
private ContentMaterialApiService contentMaterialApiService;
@Autowired
private ClerkService clerkService;
/**
* 获取素材首页数据
......@@ -183,39 +187,74 @@ public class MaterialDataStaticsController {
* @return
*/
@RequestMapping(path = "/content/material/personal/used/data")
public RestResponse<MaterialPersonalUsedDataVO> queryMaterialUsedReport(@RequestBody MaterialPersonalUsedQO materialPersonalUsedQO) {
return RestResponse.successResult();
public RestResponse<MaterialPersonalUsedDataVO> queryMaterialUsedReport(@RequestBody MaterialReportQO materialReportQO) {
List<String> storeIds = new ArrayList<>();
if (StringUtils.isBlank(materialReportQO.getStoreId())) {
storeIds = clerkStoreAdaptor.queryClerkStoreIds(materialReportQO.getClerkId(), materialReportQO.getWxEnterpriseId());
} else {
storeIds.add(materialReportQO.getStoreId());
}
MaterialPersonalUsedDataVO materialPersonalUsedDataVO =
materialDataAdaptor.queryMaterialUsedReport(materialReportQO.getEnterpriseId(), materialReportQO.getClerkId(), materialReportQO.getReportType(), storeIds);
// 补充导购信息
ClerkDTO clerkInfo = clerkService.getClerkByClerkId(materialReportQO.getClerkId());
if (clerkInfo != null) {
materialPersonalUsedDataVO.setClerkId(materialReportQO.getClerkId());
materialPersonalUsedDataVO.setClerkName(clerkInfo.getClerkName());
materialPersonalUsedDataVO.setImageUrl(clerkInfo.getImageUrl());
}
return RestResponse.successResult(materialPersonalUsedDataVO);
}
/**
* 周/月报--查询导购素材使用数据列表
* 周/月报--查询门店素材使用数据 店长
*
* @param materialReportQO
* @return
*/
@RequestMapping(path = "/content/material/personal/used/data/list")
public RestResponse<Page<MaterialPersonalUsedDataVO>> queryMaterialUsedReportList(@RequestBody MaterialPersonalUsedQO materialPersonalUsedQO) {
@RequestMapping(path = "/content/material/store/used/data")
public RestResponse<MaterialStoreUsedDataVO> queryMaterialStoreUseReport(@RequestBody MaterialReportQO materialReportQO) {
return RestResponse.successResult();
}
/**
* 周/月报--查询门店纬度素材使用数据(店长和区经)
* 周/月报--查询区经素材使用数据 区经
*
* @param materialPersonalUsedQO
* @param materialReportQO
* @return
*/
@RequestMapping(path = "/content/material/store/used/data")
public RestResponse<MaterialStoreUsedDataVO> queryMaterialStoreUseReport(@RequestBody MaterialPersonalUsedQO materialPersonalUsedQO) {
public RestResponse<MaterialStoreUsedDataVO> queryMaterialAreaUseReport(@RequestBody MaterialReportQO materialReportQO) {
return RestResponse.successResult();
}
/**
* 周/月报--查询导购素材使用数据列表
*
* @return
*/
@RequestMapping(path = "/content/material/personal/used/data/list")
public RestResponse<Page<MaterialPersonalUsedDataVO>> queryMaterialUsedReportList(@RequestBody MaterialReportQO materialReportQO) {
return RestResponse.successResult();
}
/**
* 周/月报--查询门店纬度素材使用数据列表
*
* @param materialPersonalUsedQO
* @param materialReportQO
* @return
*/
@RequestMapping(path = "/content/material/store/used/data/list")
public RestResponse<Page<MaterialStoreUsedDataVO>> queryMaterialStoreUseReportList(@RequestBody MaterialPersonalUsedQO materialPersonalUsedQO) {
public RestResponse<Page<MaterialStoreUsedDataVO>> queryMaterialStoreUseReportList(@RequestBody MaterialReportQO materialReportQO) {
return RestResponse.successResult();
}
......
package com.gic.haoban.manage.web.controller.content.adaptor;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
import com.gic.haoban.manage.api.enums.content.MaterialReportType;
import com.gic.haoban.manage.web.utils.target.DataTargetHttpUtils;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialClerkUsedDataVO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialDataOverviewVO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialStoreUsedDataVO;
import com.gic.haoban.manage.web.vo.content.statistics.bo.MaterialTodayDataBO;
import com.gic.haoban.manage.web.vo.content.statistics.report.MaterialPersonalUsedDataVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -22,8 +26,7 @@ import java.util.Map;
* @Author MUSI
* @Date 2023/3/27 10:49 AM
* @Description
* @Version
* 素材数据统计
* @Version 素材数据统计
**/
@Slf4j
@Component
......@@ -47,10 +50,20 @@ public class MaterialDataAdaptor {
*/
private static final String MATERIAL_STORE_DATA = "data_matl_haoban_store_stats";
/**
* 素材导购周报数据
*/
private static final String MATERIAL_CLERK_WEEK_DATA = "data_cms_clerk_week_report_list";
/**
* 素材导购月报数据
*/
private static final String MATERIAL_CLERK_MONTH_DATA = "data_cms_clerk_month_report_list";
/**
* 查询素材首页使用数据
*
* @param enterpriseId
* @return
*/
......@@ -63,7 +76,7 @@ public class MaterialDataAdaptor {
if (CollectionUtil.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ","));
}
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_INDEX_DATA);
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_INDEX_DATA);
if (result.get("data") == null) {
return MaterialTodayDataBO.empty();
}
......@@ -74,6 +87,7 @@ public class MaterialDataAdaptor {
/**
* 店长/区经
* 查询数据概览
*
* @param enterpriseId
* @param storeIds
* @param fixedDateDiff
......@@ -89,7 +103,7 @@ public class MaterialDataAdaptor {
if (CollectionUtil.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ","));
}
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_OVERVIEW_DATA);
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_OVERVIEW_DATA);
if (result.get("data") == null) {
return new MaterialDataOverviewVO();
}
......@@ -99,6 +113,7 @@ public class MaterialDataAdaptor {
/**
* 导购纬度数据统计
*
* @param enterpriseId
* @param storeIds
* @param fixedDateDiff
......@@ -121,7 +136,7 @@ public class MaterialDataAdaptor {
if (CollectionUtil.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ","));
}
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_CLERK_DATA);
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_CLERK_DATA);
if (result.get("data") == null) {
return new Page<>();
}
......@@ -135,6 +150,7 @@ public class MaterialDataAdaptor {
/**
* 门店纬度数据统计
*
* @param enterpriseId
* @param storeIds
* @param fixedDateDiff
......@@ -158,7 +174,7 @@ public class MaterialDataAdaptor {
if (CollectionUtil.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ","));
}
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_CLERK_DATA);
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_CLERK_DATA);
if (result.get("data") == null) {
return new Page<>();
}
......@@ -171,14 +187,79 @@ public class MaterialDataAdaptor {
}
private Map<String, Object> doHttp(String jsonParam, String apolloKey){
// --------------- 周报/月报 ---------------
/**
* 查询素材使用情况
*
* @param enterpriseId
* @param reportType
* @param storeIds
* @return
*/
public MaterialPersonalUsedDataVO queryMaterialUsedReport(String enterpriseId, String clerkId,
Integer reportType, List<String> storeIds) {
MaterialPersonalUsedDataVO temp = new MaterialPersonalUsedDataVO();
// 获取当前时间是
DateTime startTime = null;
DateTime endTime = null;
int bizDate = 0;
if (MaterialReportType.WEEK.getCode().equals(reportType)) {
// 周报
startTime = DateUtil.beginOfWeek(DateUtil.lastWeek());
endTime = DateUtil.endOfWeek(DateUtil.lastWeek());
bizDate = DateUtil.weekOfYear(DateUtil.lastWeek());
} else {
startTime = DateUtil.beginOfMonth(DateUtil.lastWeek());
endTime = DateUtil.endOfMonth(DateUtil.lastWeek());
bizDate = DateUtil.month(DateUtil.lastMonth());
}
temp.setStartTime(startTime);
temp.setEndTime(endTime);
Map<String, Object> params = new HashMap<>();
Map<String, Object> inlineParams = new HashMap<>();
params.put("inFields", inlineParams);
inlineParams.put("clerkId", clerkId);
inlineParams.put("enterprsieId", enterpriseId);
inlineParams.put("bizDate", bizDate);
if (CollectionUtil.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ","));
}
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_CLERK_DATA);
if (result.get("data") == null) {
return temp;
}
MaterialPersonalUsedDataVO materialPersonalUsedDataVO = JSON.parseObject(JSON.toJSONString(result.get("data")), MaterialPersonalUsedDataVO.class);
materialPersonalUsedDataVO.setStartTime(startTime);
materialPersonalUsedDataVO.setEndTime(endTime);
return materialPersonalUsedDataVO;
}
/**
* 查询门店/区经使用数据
* @param enterpriseId
* @param clerkId
* @param reportType
* @param storeIds
* @return
*/
public MaterialStoreUsedDataVO queryMaterialStoreUseReport(String enterpriseId, String clerkId,
Integer reportType, List<String> storeIds) {
return null;
}
private Map<String, Object> doHttp(String jsonParam, String apolloKey) {
try {
log.info("调用接口 apolloKey:{}, 参数:{}", apolloKey, jsonParam);
Map<String, Object> result = DataTargetHttpUtils.http(jsonParam, apolloKey);
if (result == null) {
return Collections.emptyMap();
}
return result;
}catch (Exception ex) {
} catch (Exception ex) {
log.info("请求接口失败 apolloKey:{}", apolloKey, ex);
}
return Collections.emptyMap();
......
......@@ -7,7 +7,7 @@ package com.gic.haoban.manage.web.qo.content.statistics;
* @Version
* 素材
**/
public class MaterialPersonalUsedQO extends MaterialStatisticsBaseQO {
public class MaterialReportQO extends MaterialStatisticsBaseQO {
private static final long serialVersionUID = -4105397589798480404L;
......
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