diff --git a/src/main/java/com/kiisoo/ic/customer/entity/OpCustomerSimpleVO.java b/src/main/java/com/kiisoo/ic/customer/entity/OpCustomerSimpleVO.java index 3faaec4..d59c205 100644 --- a/src/main/java/com/kiisoo/ic/customer/entity/OpCustomerSimpleVO.java +++ b/src/main/java/com/kiisoo/ic/customer/entity/OpCustomerSimpleVO.java @@ -2,8 +2,6 @@ package com.kiisoo.ic.customer.entity; import lombok.Data; -import java.util.Date; - /** * @Description: 客户表简单VO * @Author: wangyinjia @@ -11,21 +9,13 @@ import java.util.Date; */ @Data public class OpCustomerSimpleVO { - /** - * 主键ID - */ - private Long id; - /** * 注册时间 */ - private Date registerTime; + private String registerTime; /** - * 初始化 + * 客户数量 */ - public OpCustomerSimpleVO(Long id, Date registerTime){ - this.id = id; - this.registerTime = registerTime; - } + private Long customerSize; } diff --git a/src/main/java/com/kiisoo/ic/customer/service/CustomerViewService.java b/src/main/java/com/kiisoo/ic/customer/service/CustomerViewService.java index 09ccf20..b057088 100644 --- a/src/main/java/com/kiisoo/ic/customer/service/CustomerViewService.java +++ b/src/main/java/com/kiisoo/ic/customer/service/CustomerViewService.java @@ -116,10 +116,7 @@ public class CustomerViewService { //设置柱状图list List validCustomerList = customerList.stream().filter(customerDO -> VALID.equals(customerDO.getValidType())).collect(Collectors.toList()); - List simpleCustomerList = customerList.stream().map(customer -> new OpCustomerSimpleVO(customer.getId(), customer.getRegisterTime())).collect(Collectors.toList()); - List simpleValidCustomerList = customerList.stream().filter(customerDO -> VALID.equals(customerDO.getValidType())).map(customer -> new OpCustomerSimpleVO(customer.getId(), customer.getRegisterTime())).collect(Collectors.toList()); - customerViewVO.setCustomerList(simpleCustomerList); - customerViewVO.setValidCustomerList(simpleValidCustomerList); + handleChartData(customerList, validCustomerList, customerViewVO); //设置新增好友,好友总数,拉黑数,vip人数,柱状图list等数据 setCustomerViewData(customerViewVO, customerCount, validCustomerCount, validDeleteCustomerCount, vipCount, customerList, validCustomerList, selectStartTime, selectEndTime); //前十名排行list等 @@ -230,6 +227,34 @@ public class CustomerViewService { return shopOrgInfoList; } + /** + * 柱状图数据 + * @param customerList 好友list + * @param validCustomerList 好友(去重)list + * @param customerViewVO 概览VO + */ + public void handleChartData(List customerList, List validCustomerList, CustomerViewVO customerViewVO){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Map customerSizeMap = customerList.stream().filter(customer -> customer.getRegisterTime() != null).collect(Collectors.groupingBy(customer -> sdf.format(customer.getRegisterTime()), Collectors.counting())); + Map validCustomerSizeMap = validCustomerList.stream().filter(customer -> customer.getRegisterTime() != null).collect(Collectors.groupingBy(customer -> sdf.format(customer.getRegisterTime()), Collectors.counting())); + List simpleCustomerList = new ArrayList<>(); + List simpleValidCustomerList = new ArrayList<>(); + customerSizeMap.forEach((k,v) -> { + OpCustomerSimpleVO customerSimpleVO = new OpCustomerSimpleVO(); + customerSimpleVO.setRegisterTime(k); + customerSimpleVO.setCustomerSize(v); + simpleCustomerList.add(customerSimpleVO); + }); + validCustomerSizeMap.forEach((k,v) -> { + OpCustomerSimpleVO validCustomerSimpleVO = new OpCustomerSimpleVO(); + validCustomerSimpleVO.setRegisterTime(k); + validCustomerSimpleVO.setCustomerSize(v); + simpleValidCustomerList.add(validCustomerSimpleVO); + }); + customerViewVO.setCustomerList(simpleCustomerList); + customerViewVO.setValidCustomerList(simpleValidCustomerList); + } + /** * 零售公司新增排行list * @param newCustimerList 新增好友list