Commit a9cdcab2 by 王祖波

数据导出

parent ede647c3
...@@ -9,7 +9,9 @@ import com.gic.api.base.commons.BasePageInfo; ...@@ -9,7 +9,9 @@ import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.commons.util.DataApiUtils; import com.gic.commons.util.DataApiUtils;
import com.gic.enterprise.api.dto.EnterpriseDTO; import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.EnterpriseService; import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.manage.api.enums.content.MaterialReportType; import com.gic.haoban.manage.api.enums.content.MaterialReportType;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialAnalyzeDataQO; import com.gic.haoban.manage.web.qo.content.statistics.MaterialAnalyzeDataQO;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialReportQO; import com.gic.haoban.manage.web.qo.content.statistics.MaterialReportQO;
...@@ -27,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -27,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -105,6 +108,8 @@ public class MaterialDataAdaptor { ...@@ -105,6 +108,8 @@ public class MaterialDataAdaptor {
@Autowired @Autowired
private EnterpriseService enterpriseService; private EnterpriseService enterpriseService;
@Autowired
private StoreService storeService;
/** /**
...@@ -217,6 +222,25 @@ public class MaterialDataAdaptor { ...@@ -217,6 +222,25 @@ public class MaterialDataAdaptor {
} }
Map<String, Object> result = DataApiUtils.http(JSON.toJSONString(inlineParams), MATERIAL_STORE_DATA); Map<String, Object> result = DataApiUtils.http(JSON.toJSONString(inlineParams), MATERIAL_STORE_DATA);
Page<MaterialStoreUsedDataVO> pageData = DataApiUtils.getPageData(result, MaterialStoreUsedDataVO.class); Page<MaterialStoreUsedDataVO> pageData = DataApiUtils.getPageData(result, MaterialStoreUsedDataVO.class);
if (CollectionUtils.isNotEmpty(pageData.getResult())) {
List<String> tempStoreIds = pageData.getResult()
.stream()
.map(MaterialStoreUsedDataVO::getStoreId)
.collect(Collectors.toList());
String[] storeIdsArry = new String[tempStoreIds.size()];
List<StoreDTO> storeDTOS = storeService.getStores(tempStoreIds.toArray(storeIdsArry));
if (CollectionUtils.isNotEmpty(storeDTOS)) {
Map<String, StoreDTO> storeInfoMap = storeDTOS.stream()
.collect(Collectors.toMap(StoreDTO::getStoreId, Function.identity(), (v1, v2) -> v1));
for (MaterialStoreUsedDataVO materialStoreUsedDataVO : pageData.getResult()) {
StoreDTO storeDTO = storeInfoMap.get(materialStoreUsedDataVO.getStoreId());
if (storeDTO != null) {
materialStoreUsedDataVO.setStoreName(storeDTO.getStoreName());
materialStoreUsedDataVO.setStoreCode(storeDTO.getStoreCode());
}
}
}
}
return pageData; return pageData;
} }
......
package com.gic.haoban.manage.web.controller.data;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.DownloadReportQDTQ;
import com.gic.enterprise.api.dto.security.DownloadReportDTO;
import com.gic.enterprise.api.service.DownloadReportService;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.manage.web.qo.data.DataExportListQO;
import com.gic.haoban.manage.web.vo.content.creative.ContentMaterialVO;
import com.gic.marketing.pro.api.dto.clerktask.ClerkTaskPlanDTO;
import com.gic.marketing.pro.api.qdto.clerktask.ClerkTaskPageQDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 数据导出
*/
@Controller
@RequestMapping("data/export")
public class DataExportController {
private static Logger logger = LoggerFactory.getLogger(DataExportController.class);
@Autowired
private DownloadReportService downloadReportService ;
/**
* 数据导出列表
*/
@RequestMapping("page-data-export")
@ResponseBody
public RestResponse<Page<DownloadReportDTO>> getTaskCount(@RequestBody DataExportListQO dataExportListQO) {
String enterpriseId = dataExportListQO.getEnterpriseId();
String clerkId = dataExportListQO.getClerkId();
DownloadReportQDTQ downloadReportQDTQ = new DownloadReportQDTQ();
downloadReportQDTQ.setCurrentPage(dataExportListQO.getPageNum());
downloadReportQDTQ.setPageSize(dataExportListQO.getPageSize());
downloadReportQDTQ.setEnterpriseId(enterpriseId);
downloadReportQDTQ.setApplyClerkId(clerkId);
DateTime date = DateUtil.date();
downloadReportQDTQ.setApplyStartTime(DateUtil.offset(date, DateField.YEAR, -1));
downloadReportQDTQ.setApplyEndTime(date);
downloadReportQDTQ.setDataType(2);
downloadReportQDTQ.setProjectCode("haoban_new");
Page<DownloadReportDTO> page = downloadReportService.listDownloadReportByPage(downloadReportQDTQ);
return RestResponse.successResult(page) ;
}
}
package com.gic.haoban.manage.web.export;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.DateUtil;
import com.gic.enterprise.api.dto.security.DownloadReportDTO;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.web.controller.content.adaptor.MaterialDataAdaptor;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialAnalyzeDataQO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialClerkUsedDataVO;
import com.gic.web.common.download.DownloadHandlerAbstract;
import com.gic.web.common.download.context.Context;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@Component
public class ContentMaterialClerkUsedDataHandler extends DownloadHandlerAbstract<MaterialClerkUsedDataVO> {
private static final Logger log = LoggerFactory.getLogger(ContentMaterialClerkUsedDataHandler.class);
@Autowired
private MaterialDataAdaptor materialDataAdaptor;
@Override
public List<MaterialClerkUsedDataVO> getData(Context context, String searchDataParams, Integer currentPage) {
MaterialAnalyzeDataQO materialStatisticsBaseQO = JSON.parseObject(searchDataParams, MaterialAnalyzeDataQO.class);
materialStatisticsBaseQO.setPageNum(currentPage);
materialStatisticsBaseQO.setPageSize(this.getPageSize());
Page<MaterialClerkUsedDataVO> clerkUsedData = materialDataAdaptor.queryMaterialClerkUsedData(materialStatisticsBaseQO,materialStatisticsBaseQO.getStoreIdList());
List<MaterialClerkUsedDataVO> result = clerkUsedData.getResult();
if (CollectionUtils.isEmpty(result)) {
result.forEach(x -> {
x.setConvsUserNum(x.getConvsUserNum() + x.getOfflineConvsUserNum());
x.setConvsAmt(x.getConvsAmt().add(x.getOfflineConvsAmt()));
});
return Collections.emptyList();
}
return result;
}
@Override
public List<String> getColumnNames() {
return Lists.newArrayList("storeName", "storeCode", "clerkName", "clerkCode",
"useMatlDayNum", "useMatlNum", "singleMatlAvgCnt", "convsUserNum", "convsAmt");
}
@Override
public LinkedHashMap<String, List<String>> doubleColumnNames() {
return null;
}
@Override
public List<String> getColumns() {
return Lists.newArrayList("门店名称", "门店code", "导购姓名", "导购code",
"使用素材天数", "使用素材数", "单个素材平均使用次数", "转化客户数", "转化金额");
}
@Override
public void callBack(Context context) {
DownloadReportDTO downloadReportDTO = context.getDownloadReportDTO();
String clerkId = downloadReportDTO.getApplyClerkId();
String enterpriseId = downloadReportDTO.getEnterpriseId();
NoticeMessageUtil.sendDataExportNotify(enterpriseId, clerkId,
downloadReportDTO.getReportName(), downloadReportDTO.getApplyTime());
}
}
package com.gic.haoban.manage.web.export;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
import com.gic.enterprise.api.dto.security.DownloadReportDTO;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.web.controller.content.adaptor.MaterialDataAdaptor;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialAnalyzeDataQO;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialStoreAnalyzeDataQO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialClerkUsedDataVO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialStoreUsedDataVO;
import com.gic.web.common.download.DownloadHandlerAbstract;
import com.gic.web.common.download.context.Context;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@Component
public class ContentMaterialStoreUsedDataHandler extends DownloadHandlerAbstract<MaterialStoreUsedDataVO> {
private static final Logger log = LoggerFactory.getLogger(ContentMaterialStoreUsedDataHandler.class);
@Autowired
private MaterialDataAdaptor materialDataAdaptor;
@Override
public List<MaterialStoreUsedDataVO> getData(Context context, String searchDataParams, Integer currentPage) {
MaterialStoreAnalyzeDataQO materialStatisticsBaseQO = JSON.parseObject(searchDataParams, MaterialStoreAnalyzeDataQO.class);
materialStatisticsBaseQO.setPageNum(currentPage);
materialStatisticsBaseQO.setPageSize(this.getPageSize());
Page<MaterialStoreUsedDataVO> storeUsedData = materialDataAdaptor.queryMaterialStoreUsedData(materialStatisticsBaseQO, materialStatisticsBaseQO.getStoreIdList());
List<MaterialStoreUsedDataVO> result = storeUsedData.getResult();
if (CollectionUtils.isEmpty(result)) {
result.forEach(x -> {
x.setConvUserNum(x.getConvUserNum() + x.getOfflineConvUserNum());
x.setConvSalesNmt(x.getConvSalesNmt().add(x.getOfflineConvSalesNmt()));
});
return Collections.emptyList();
}
return result;
}
@Override
public List<String> getColumnNames() {
return Lists.newArrayList("storeName", "storeCode",
"dayAvgUseRate", "clickUserNum", "convUserNum", "convSalesNmt");
}
@Override
public LinkedHashMap<String, List<String>> doubleColumnNames() {
return null;
}
@Override
public List<String> getColumns() {
return Lists.newArrayList("门店名称", "门店code",
"日均使用导购占比", "点击客户数", "转化客户数", "转化金额");
}
@Override
public void callBack(Context context) {
DownloadReportDTO downloadReportDTO = context.getDownloadReportDTO();
String clerkId = downloadReportDTO.getApplyClerkId();
String enterpriseId = downloadReportDTO.getEnterpriseId();
NoticeMessageUtil.sendDataExportNotify(enterpriseId, clerkId,
downloadReportDTO.getReportName(), downloadReportDTO.getApplyTime());
}
}
...@@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @Author MUSI * @Author MUSI
...@@ -38,6 +39,11 @@ public class MaterialStatisticsBaseQO extends BasePageInfo { ...@@ -38,6 +39,11 @@ public class MaterialStatisticsBaseQO extends BasePageInfo {
private String storeId; private String storeId;
/** /**
* 门店id列表
*/
private List<String> storeIdList;
/**
* 开始时间 * 开始时间
*/ */
private String startDate; private String startDate;
...@@ -80,6 +86,14 @@ public class MaterialStatisticsBaseQO extends BasePageInfo { ...@@ -80,6 +86,14 @@ public class MaterialStatisticsBaseQO extends BasePageInfo {
this.storeId = storeId; this.storeId = storeId;
} }
public List<String> getStoreIdList() {
return storeIdList;
}
public void setStoreIdList(List<String> storeIdList) {
this.storeIdList = storeIdList;
}
public String getStartDate() { public String getStartDate() {
if (StringUtils.isNotBlank(this.startDate)) { if (StringUtils.isNotBlank(this.startDate)) {
return this.startDate; return this.startDate;
......
package com.gic.haoban.manage.web.qo.data;
import com.gic.commons.web.qo.PageQo;
import java.io.Serializable;
public class DataExportListQO extends PageQo implements Serializable {
/**
* 导购ID
*/
private String clerkId ;
/**
* 企业ID
*/
private String enterpriseId ;
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
}
...@@ -121,6 +121,8 @@ ...@@ -121,6 +121,8 @@
<dubbo:reference interface="com.gic.marketing.pro.api.service.offline.OfflinePreApiService" id="offlinePreApiService" timeout="10000" retries="0" check="false"/> <dubbo:reference interface="com.gic.marketing.pro.api.service.offline.OfflinePreApiService" id="offlinePreApiService" timeout="10000" retries="0" check="false"/>
<dubbo:reference interface="com.gic.enterprise.api.service.AccountService" id="accountService"/> <dubbo:reference interface="com.gic.enterprise.api.service.AccountService" id="accountService"/>
<dubbo:reference interface="com.gic.enterprise.api.service.DownloadReportService" id="downloadReportService" timeout="10000"/>
<dubbo:reference interface="com.gic.content.api.service.ContentColumnApiService" id="contentColumnApiService" timeout="10000" retries="0" check="false"/> <dubbo:reference interface="com.gic.content.api.service.ContentColumnApiService" id="contentColumnApiService" timeout="10000" retries="0" check="false"/>
<dubbo:reference interface="com.gic.content.api.service.ContentMaterialApiService" id="contentMaterialApiService" timeout="10000" retries="0" check="false"/> <dubbo:reference interface="com.gic.content.api.service.ContentMaterialApiService" id="contentMaterialApiService" timeout="10000" retries="0" check="false"/>
......
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