Commit 80b39cf3 by songyinghui

feat: 数据接口

parent 16d27e12
......@@ -10,6 +10,8 @@ import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.content.api.dto.material.ContentMaterialFrontDTO;
import com.gic.content.api.qdto.material.ContentMaterialPageFrontQDTO;
import com.gic.content.api.service.ContentMaterialApiService;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.StoreService;
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;
......@@ -34,9 +36,14 @@ import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 素材-好办数据统计
......@@ -53,6 +60,8 @@ public class MaterialDataStaticsController {
private ContentMaterialApiService contentMaterialApiService;
@Autowired
private ClerkService clerkService;
@Autowired
private StoreService storeService;
/**
* 获取素材首页数据
......@@ -265,8 +274,8 @@ public class MaterialDataStaticsController {
} else {
storeIds.add(materialReportQO.getStoreId());
}
MaterialStoreUsedDataVO materialStoreUsedDataVO = materialDataAdaptor.queryMaterialAreaOverviewData(materialReportQO.getEnterpriseId(), materialReportQO.getClerkId(), materialReportQO.getReportType(), storeIds);
return RestResponse.successResult();
MaterialAreaUsedDataVO materialAreaUsedDataVO = materialDataAdaptor.queryMaterialAreaOverviewData(materialReportQO.getEnterpriseId(), materialReportQO.getClerkId(), materialReportQO.getReportType(), storeIds);
return RestResponse.successResult(materialAreaUsedDataVO);
}
......@@ -292,14 +301,25 @@ public class MaterialDataStaticsController {
return RestResponse.successResult();
}
// 补充导购信息
ClerkDTO clerkInfo = clerkService.getClerkByClerkId(materialReportQO.getClerkId());
if (clerkInfo != null) {
for (MaterialPersonalUsedDataVO materialPersonalUsedDataVO : usedDataVOPage.getResult()) {
Set<String> clerkIds = usedDataVOPage.getResult()
.stream()
.map(MaterialPersonalUsedDataVO::getClerkId)
.collect(Collectors.toSet());
List<ClerkDTO> clerkInfos = clerkService.getClerkByClerkIds(clerkIds);
Map<String, ClerkDTO> clerkInfoMap = Collections.emptyMap();
if (CollectionUtils.isNotEmpty(clerkInfos)) {
clerkInfoMap = clerkInfos.stream()
.collect(Collectors.toMap(ClerkDTO::getClerkId, Function.identity(), (v1, v2) -> v1));
}
for (MaterialPersonalUsedDataVO materialPersonalUsedDataVO : usedDataVOPage.getResult()) {
ClerkDTO clerkInfo = clerkInfoMap.get(materialPersonalUsedDataVO.getClerkId());
if (clerkInfo != null) {
materialPersonalUsedDataVO.setClerkId(materialReportQO.getClerkId());
materialPersonalUsedDataVO.setClerkName(clerkInfo.getClerkName());
materialPersonalUsedDataVO.setImageUrl(clerkInfo.getImageUrl());
}
}
return RestResponse.successResult(usedDataVOPage);
}
......@@ -325,13 +345,23 @@ public class MaterialDataStaticsController {
if (usedDataVOPage == null || CollectionUtils.isEmpty(usedDataVOPage.getResult())) {
return RestResponse.successResult();
}
// 补充导购信息
ClerkDTO clerkInfo = clerkService.getClerkByClerkId(materialReportQO.getClerkId());
if (clerkInfo != null) {
for (MaterialStoreUsedDataVO materialStoreUsedDataVO : usedDataVOPage.getResult()) {
materialStoreUsedDataVO.setClerkId(materialReportQO.getClerkId());
materialStoreUsedDataVO.setClerkName(clerkInfo.getClerkName());
materialStoreUsedDataVO.setImageUrl(clerkInfo.getImageUrl());
// 补充门店信息
List<String> tempStoreIds = usedDataVOPage.getResult()
.stream()
.map(MaterialStoreUsedDataVO::getStoreId)
.collect(Collectors.toList());
List<StoreDTO> storeDTOS = storeService.queryStore(tempStoreIds);
Map<String, StoreDTO> storeInfoMap = Collections.emptyMap();
if (CollectionUtils.isNotEmpty(storeDTOS)) {
storeInfoMap = storeDTOS
.stream()
.collect(Collectors.toMap(StoreDTO::getStoreId, Function.identity(), (v1, v2) -> v1));
}
for (MaterialStoreUsedDataVO materialStoreUsedDataVO : usedDataVOPage.getResult()) {
StoreDTO storeDTO = storeInfoMap.get(materialStoreUsedDataVO.getStoreId());
if (storeDTO != null) {
materialStoreUsedDataVO.setStoreCode(storeDTO.getStoreCode());
materialStoreUsedDataVO.setStoreName(storeDTO.getStoreName());
}
}
return RestResponse.successResult(usedDataVOPage);
......
......@@ -7,6 +7,7 @@ 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.MaterialAreaUsedDataVO;
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;
......@@ -352,8 +353,8 @@ public class MaterialDataAdaptor {
*
* @return
*/
public MaterialStoreUsedDataVO queryMaterialAreaOverviewData(String enterpriseId, String clerkId,
Integer reportType, List<String> storeIds) {
public MaterialAreaUsedDataVO queryMaterialAreaOverviewData(String enterpriseId, String clerkId,
Integer reportType, List<String> storeIds) {
// 获取当前时间周期
DateTime startTime = null;
......@@ -384,12 +385,16 @@ public class MaterialDataAdaptor {
}
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), apolloKey);
if (result.get("data") == null) {
return new MaterialStoreUsedDataVO();
return new MaterialAreaUsedDataVO();
}
MaterialStoreUsedDataVO materialStoreUsedDataVO = JSON.parseObject(JSON.toJSONString(result), MaterialStoreUsedDataVO.class);
materialStoreUsedDataVO.setStartTime(startTime);
materialStoreUsedDataVO.setEndTime(endTime);
return materialStoreUsedDataVO;
List<MaterialAreaUsedDataVO> areaUsedDataVOS = JSON.parseArray(JSON.toJSONString(result.get("data")), MaterialAreaUsedDataVO.class);
if (CollectionUtils.isEmpty(areaUsedDataVOS)) {
return new MaterialAreaUsedDataVO();
}
MaterialAreaUsedDataVO materialAreaUsedDataVO = areaUsedDataVOS.get(0);
materialAreaUsedDataVO.setStartTime(startTime);
materialAreaUsedDataVO.setEndTime(endTime);
return materialAreaUsedDataVO;
}
......
......@@ -4,6 +4,7 @@ import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Author MUSI
......@@ -85,4 +86,14 @@ public class MaterialAreaUsedDataVO implements Serializable {
* 门店名称
*/
private String storeName;
/**
* 开始时间
*/
private Date startTime;
/**
* 结束时间
*/
private Date endTime;
}
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