公司店均新增柱状图数据

master
wyj2080 6 years ago
parent 25b42d4f57
commit 43b3a65fc9

@ -27,6 +27,9 @@ public class CustomerViewVO {
/**会员总数*/
private Long allVipCount;
/**零售公司店均新增柱状图*/
List<CustomerViewCompanyVO> companyShopAverageNewCustomerList;
/**好友list*/
List<OpCustomerSimpleVO> customerList;
/**好友(去重)list*/

@ -44,6 +44,7 @@ public class CustomerViewService {
static final Integer LEVEL_REGION = 1;
/**零售公司*/
static final Integer LEVEL_COMPANY = 2;
static final Long LEVEL_COMPANY_L = 2L;
/**客户*/
static final Integer LEVEL_CUSTOMER = 3;
@ -114,13 +115,16 @@ public class CustomerViewService {
//会员总数
Long vipCount = opVipDOMapper.selectVipCount(shopIds, null, null);
//设置柱状图list
List<OpCustomer> newCustimerList = customerList.stream().filter(customerDO -> filterCustomerByRegisterTime(customerDO, selectStartTime, selectEndTime)).collect(Collectors.toList());
//零售公司店均新增
List<CustomerViewCompanyVO> shopAverageNewCustomerList = getOrgShopAvgNewCustomerList(newCustimerList, userId);
customerViewVO.setCompanyShopAverageNewCustomerList(shopAverageNewCustomerList);
//设置趋势柱状图list
List<OpCustomer> validCustomerList = customerList.stream().filter(customerDO -> VALID.equals(customerDO.getValidType())).collect(Collectors.toList());
handleChartData(customerList, validCustomerList, customerViewVO);
//设置新增好友好友总数拉黑数vip人数柱状图list等数据
//设置新增好友好友总数拉黑数vip人数
setCustomerViewData(customerViewVO, customerCount, validCustomerCount, validDeleteCustomerCount, vipCount, customerList, validCustomerList, selectStartTime, selectEndTime);
//前十名排行list等
List<OpCustomer> newCustimerList = customerList.stream().filter(customerDO -> filterCustomerByRegisterTime(customerDO, selectStartTime, selectEndTime)).collect(Collectors.toList());
List<CustomerViewCompanyVO> orgNewCustomerList = getOrgNewCustomerList(newCustimerList);
List<CustomerViewShopVO> shopNewCustomerList = getShopNewCustomerList(newCustimerList);
List<CustomerViewZeroExtendVO> zeroExtendList = getZeroExtendList(newCustimerList, shopIds);
@ -141,7 +145,7 @@ public class CustomerViewService {
}
/**
* viplist
* vip
* @param customerViewVO VO
* @param customerCount
* @param validCustomerCount ()
@ -228,7 +232,56 @@ public class CustomerViewService {
}
/**
*
*
* @param newCustimerList list
* @param userId id
* @return list
*/
public List<CustomerViewCompanyVO> getOrgShopAvgNewCustomerList(List<OpCustomer> newCustimerList, Long userId){
List<CustomerViewCompanyVO> orgShopAvgNewCustomerList = new ArrayList<>();
//初始化所有零售公司
List<PrivilageOrganizational> companyList = retailCompanyService.listOfRetailOrg(userId, null, null, null).stream().filter(org -> LEVEL_COMPANY_L.equals(org.getLevel())).distinct().collect(Collectors.toList());
companyList.forEach(companyDO -> {
CustomerViewCompanyVO companyVO = new CustomerViewCompanyVO();
companyVO.setOrgId(companyDO.getId());
companyVO.setOrgName(companyDO.getName());
companyVO.setNewCustomerCount(0);
orgShopAvgNewCustomerList.add(companyVO);
});
//店铺id-新增好友数map
Map<Long, Long> shopIdCountMap = newCustimerList.stream().collect(Collectors.groupingBy(OpCustomer::getShopId, Collectors.counting()));
//店铺id→零售公司名称
List<Long> shopIds = newCustimerList.stream().map(OpCustomer::getShopId).collect(Collectors.toList());
if(CollectionUtils.isEmpty(shopIds)){
return orgShopAvgNewCustomerList;
}
//零售公司id-公司店铺list map
List<ShopOrgInfoVO> shopOrgInfoList = getOrgInfoByShopIds(shopIds, true, null);
Map<Long, List<ShopOrgInfoVO>> companyShopListMap = shopOrgInfoList.stream().distinct().collect(Collectors.groupingBy(ShopOrgInfoVO::getCompanyId));
//每个公司店均新增数
companyShopListMap.forEach((companyId,companyShopList) -> {
CustomerViewCompanyVO orgViewDO = new CustomerViewCompanyVO();
orgViewDO.setOrgId(companyId);
orgViewDO.setOrgName(companyShopList.get(0).getCompanyName());
AtomicInteger newCustomerCount = new AtomicInteger(0);
companyShopList.forEach(companyShopVO -> {
Long shopId = companyShopVO.getShopId();
int tmpCount = shopIdCountMap.get(shopId) == null ? 0 : Math.toIntExact(shopIdCountMap.get(shopId));
newCustomerCount.updateAndGet(v -> v + tmpCount);
});
//平均
if(companyShopList.size() > 0){
newCustomerCount.updateAndGet(v -> Math.round(v / (float)companyShopList.size()));
}
orgViewDO.setNewCustomerCount(newCustomerCount.get());
orgShopAvgNewCustomerList.stream().filter(orgShopAvg -> orgShopAvg.getOrgName().equals(orgViewDO.getOrgName())).forEach(orgShopAvg -> orgShopAvg.setNewCustomerCount(orgViewDO.getNewCustomerCount()));
});
//公司店均
return orgShopAvgNewCustomerList;
}
/**
*
* @param customerList list
* @param validCustomerList list
* @param customerViewVO VO
@ -272,7 +325,7 @@ public class CustomerViewService {
//零售公司id-公司店铺list map
List<ShopOrgInfoVO> shopOrgInfoList = getOrgInfoByShopIds(shopIds, true, null);
Map<Long, List<ShopOrgInfoVO>> companyShopListMap = shopOrgInfoList.stream().distinct().collect(Collectors.groupingBy(ShopOrgInfoVO::getCompanyId));
//每个公司新增数
//每个公司店均新增数
List<CustomerViewCompanyVO> tmpList = new ArrayList<>();
companyShopListMap.forEach((companyId,companyShopList) -> {
CustomerViewCompanyVO orgViewDO = new CustomerViewCompanyVO();

Loading…
Cancel
Save