|
@@ -1,6 +1,8 @@
|
1
|
1
|
package com.huiju.estateagents.statistic.service.impl;
|
2
|
2
|
|
3
|
3
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
4
|
+import com.huiju.estateagents.common.CommConstant;
|
|
5
|
+import com.huiju.estateagents.statistic.entity.GenderStatistic;
|
4
|
6
|
import com.huiju.estateagents.statistic.entity.TaCustomerGenderStatistic;
|
5
|
7
|
import com.huiju.estateagents.statistic.mapper.TaCustomerGenderStatisticMapper;
|
6
|
8
|
import com.huiju.estateagents.statistic.service.ITaCustomerGenderStatisticService;
|
|
@@ -8,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
8
|
10
|
import org.springframework.stereotype.Service;
|
9
|
11
|
|
10
|
12
|
import java.time.LocalDateTime;
|
|
13
|
+import java.util.ArrayList;
|
|
14
|
+import java.util.List;
|
11
|
15
|
|
12
|
16
|
/**
|
13
|
17
|
* <p>
|
|
@@ -30,7 +34,10 @@ public class TaCustomerGenderStatisticServiceImpl extends ServiceImpl<TaCustomer
|
30
|
34
|
*/
|
31
|
35
|
@Override
|
32
|
36
|
public void newCustomerSexStatisticDaily(LocalDateTime nowDate) {
|
33
|
|
-
|
|
37
|
+ //获取新增客户的男女性别比和性别数
|
|
38
|
+ List<GenderStatistic> newCustomerSexList = customerGenderStatisticMapper.getNewCustomerSexCount();
|
|
39
|
+ //批量保存
|
|
40
|
+ saveBatchCustomerSexData(newCustomerSexList,nowDate);
|
34
|
41
|
}
|
35
|
42
|
|
36
|
43
|
/**
|
|
@@ -40,7 +47,10 @@ public class TaCustomerGenderStatisticServiceImpl extends ServiceImpl<TaCustomer
|
40
|
47
|
*/
|
41
|
48
|
@Override
|
42
|
49
|
public void followUpSexStatisticDaily(LocalDateTime nowDate) {
|
43
|
|
-
|
|
50
|
+ //获取跟进客户的男女性别比和性别数
|
|
51
|
+ List<GenderStatistic> followUpSexList = customerGenderStatisticMapper.getFollowUpSexCount();
|
|
52
|
+ //批量保存
|
|
53
|
+ saveBatchCustomerSexData(followUpSexList,nowDate);
|
44
|
54
|
}
|
45
|
55
|
|
46
|
56
|
/**
|
|
@@ -50,6 +60,55 @@ public class TaCustomerGenderStatisticServiceImpl extends ServiceImpl<TaCustomer
|
50
|
60
|
*/
|
51
|
61
|
@Override
|
52
|
62
|
public void visiteSexStatisticDaily(LocalDateTime nowDate) {
|
|
63
|
+ //获取到访客户的男女性别比和性别数
|
|
64
|
+ List<GenderStatistic> visiteSexList = customerGenderStatisticMapper.getVisiteSexCount();
|
|
65
|
+ List<GenderStatistic> newVisiteSexList = new ArrayList<>();
|
|
66
|
+ visiteSexList.forEach(e -> {
|
|
67
|
+ if (null != e.getOrgId() && !e.getOrgId().equals("null")){
|
|
68
|
+ newVisiteSexList.add(e);
|
|
69
|
+ }
|
|
70
|
+ });
|
|
71
|
+ //批量保存
|
|
72
|
+ saveBatchCustomerSexData(newVisiteSexList,nowDate);
|
|
73
|
+ }
|
53
|
74
|
|
|
75
|
+ /**
|
|
76
|
+ * 批量保存性别数据
|
|
77
|
+ * @param customerSexList
|
|
78
|
+ * @param nowDate
|
|
79
|
+ */
|
|
80
|
+ private void saveBatchCustomerSexData(List<GenderStatistic> customerSexList, LocalDateTime nowDate) {
|
|
81
|
+ List<TaCustomerGenderStatistic> list = new ArrayList<>();
|
|
82
|
+ //划分男女未知三条数据
|
|
83
|
+ customerSexList.forEach(e -> {
|
|
84
|
+ TaCustomerGenderStatistic maleCustomer = new TaCustomerGenderStatistic();
|
|
85
|
+ maleCustomer.setCreateDate(nowDate);
|
|
86
|
+ maleCustomer.setGenderType(CommConstant.SEX_MALE);
|
|
87
|
+ maleCustomer.setCustomerType(CommConstant.CUSTOMER_TYPE_NEW);
|
|
88
|
+ maleCustomer.setCustomerNum(e.getManSum());
|
|
89
|
+ maleCustomer.setPercentage(e.getManPct());
|
|
90
|
+ maleCustomer.setOrgId(e.getOrgId());
|
|
91
|
+ list.add(maleCustomer);
|
|
92
|
+
|
|
93
|
+ TaCustomerGenderStatistic femaleCustomer = new TaCustomerGenderStatistic();
|
|
94
|
+ femaleCustomer.setCreateDate(nowDate);
|
|
95
|
+ femaleCustomer.setGenderType(CommConstant.SEX_FEMALE);
|
|
96
|
+ femaleCustomer.setCustomerType(CommConstant.CUSTOMER_TYPE_NEW);
|
|
97
|
+ femaleCustomer.setCustomerNum(e.getWomanSum());
|
|
98
|
+ femaleCustomer.setPercentage(e.getWomanPct());
|
|
99
|
+ femaleCustomer.setOrgId(e.getOrgId());
|
|
100
|
+ list.add(femaleCustomer);
|
|
101
|
+
|
|
102
|
+ TaCustomerGenderStatistic unknownCustomer = new TaCustomerGenderStatistic();
|
|
103
|
+ unknownCustomer.setCreateDate(nowDate);
|
|
104
|
+ unknownCustomer.setGenderType(CommConstant.SEX_UNKNOWN);
|
|
105
|
+ unknownCustomer.setCustomerType(CommConstant.CUSTOMER_TYPE_NEW);
|
|
106
|
+ unknownCustomer.setCustomerNum(e.getUnknownSum());
|
|
107
|
+ unknownCustomer.setPercentage(e.getUnknownPct());
|
|
108
|
+ unknownCustomer.setOrgId(e.getOrgId());
|
|
109
|
+ list.add(unknownCustomer);
|
|
110
|
+ });
|
|
111
|
+ //批量插入
|
|
112
|
+ this.saveBatch(list);
|
54
|
113
|
}
|
55
|
114
|
}
|