Commit bfac3874dedee4608b123c333121c22863663692
1 parent
776234a0
public_report_data 表 公共池报表数据(初次抽取)
Showing
27 changed files
with
1146 additions
and
4 deletions
fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/PubCluePoolMapper.java
... | ... | @@ -2,6 +2,8 @@ package cn.fw.valhalla.dao.mapper; |
2 | 2 | |
3 | 3 | import cn.fw.valhalla.domain.db.pub.PubCluePool; |
4 | 4 | import cn.fw.valhalla.domain.dto.FollowPoolDTO; |
5 | +import cn.fw.valhalla.domain.dto.PubCluePoolReportDTO; | |
6 | +import cn.fw.valhalla.domain.dto.PubCluePoolReportQueryDTO; | |
5 | 7 | import cn.fw.valhalla.domain.query.FollowPoolQueryVO; |
6 | 8 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
7 | 9 | import org.apache.ibatis.annotations.Param; |
... | ... | @@ -37,4 +39,11 @@ public interface PubCluePoolMapper extends BaseMapper<PubCluePool> { |
37 | 39 | * @return |
38 | 40 | */ |
39 | 41 | Long followListCount(@Param("condition") FollowPoolQueryVO queryVO); |
42 | + | |
43 | + /** | |
44 | + * 查询站岗分配 | |
45 | + * @param dto | |
46 | + * @return | |
47 | + */ | |
48 | + List<PubCluePoolReportDTO> countPubCluePoolList(PubCluePoolReportQueryDTO dto); | |
40 | 49 | } | ... | ... |
fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/PublicPoolMapper.java
... | ... | @@ -2,6 +2,8 @@ package cn.fw.valhalla.dao.mapper; |
2 | 2 | |
3 | 3 | import cn.fw.valhalla.domain.db.pool.PublicPool; |
4 | 4 | import cn.fw.valhalla.domain.dto.PublicPoolDTO; |
5 | +import cn.fw.valhalla.domain.dto.PublicPoolReportDTO; | |
6 | +import cn.fw.valhalla.domain.dto.PublicPoolReportQueryDTO; | |
5 | 7 | import cn.fw.valhalla.domain.query.PublicPoolQueryVO; |
6 | 8 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
7 | 9 | import org.apache.ibatis.annotations.Param; |
... | ... | @@ -41,4 +43,11 @@ public interface PublicPoolMapper extends BaseMapper<PublicPool> { |
41 | 43 | * @return |
42 | 44 | */ |
43 | 45 | List<String> queryIdListByShops(@Param("shopIds") List<Long> shopIds); |
46 | + | |
47 | + /** | |
48 | + * 查询公共池来源统计 | |
49 | + * @param dto | |
50 | + * @return | |
51 | + */ | |
52 | + List<PublicPoolReportDTO> countPublicPoolList(PublicPoolReportQueryDTO dto); | |
44 | 53 | } | ... | ... |
fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/PublicReportDataMapper.java
0 → 100644
1 | +package cn.fw.valhalla.dao.mapper; | |
2 | + | |
3 | +import cn.fw.valhalla.domain.db.PublicReportData; | |
4 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
5 | +import org.springframework.stereotype.Repository; | |
6 | + | |
7 | +/** | |
8 | + * @author : kurisu | |
9 | + * @className : SecretReportHistoryMapper | |
10 | + * @description : 公共池报表数据(初次抽取)mapper | |
11 | + * @date: 2021-02-21 14:54 | |
12 | + */ | |
13 | +@Repository | |
14 | +public interface PublicReportDataMapper extends BaseMapper<PublicReportData> { | |
15 | + | |
16 | +} | ... | ... |
fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/StammkundePoolMapper.java
... | ... | @@ -2,6 +2,8 @@ package cn.fw.valhalla.dao.mapper; |
2 | 2 | |
3 | 3 | import cn.fw.valhalla.domain.db.pool.StammkundePool; |
4 | 4 | import cn.fw.valhalla.domain.dto.StammkundePoolDTO; |
5 | +import cn.fw.valhalla.domain.dto.StammkundePoolReportDTO; | |
6 | +import cn.fw.valhalla.domain.dto.StammkundePoolReportQueryDTO; | |
5 | 7 | import cn.fw.valhalla.domain.query.StammkundePoolQueryVO; |
6 | 8 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
7 | 9 | import org.apache.ibatis.annotations.Param; |
... | ... | @@ -32,4 +34,13 @@ public interface StammkundePoolMapper extends BaseMapper<StammkundePool> { |
32 | 34 | * @return |
33 | 35 | */ |
34 | 36 | Long stammkundeListCount(@Param("condition") StammkundePoolQueryVO queryVO); |
37 | + | |
38 | + | |
39 | + | |
40 | + /** | |
41 | + * 查询渠道到店统计 | |
42 | + * @param dto | |
43 | + * @return | |
44 | + */ | |
45 | + List<StammkundePoolReportDTO> countStammkundePoolList(StammkundePoolReportQueryDTO dto); | |
35 | 46 | } | ... | ... |
fw-valhalla-dao/src/main/resources/mapper/PubCluePoolMapper.xml
... | ... | @@ -180,4 +180,36 @@ |
180 | 180 | </if> |
181 | 181 | </where> |
182 | 182 | </select> |
183 | + | |
184 | + | |
185 | + <select id="countPubCluePoolList" resultType="cn.fw.valhalla.domain.dto.PubCluePoolReportDTO" parameterType="cn.fw.valhalla.domain.dto.PubCluePoolReportQueryDTO"> | |
186 | + SELECT | |
187 | + shop_id, | |
188 | + shop_name, | |
189 | + adviser_id, | |
190 | + adviser_name, | |
191 | + COUNT(*) total | |
192 | + FROM | |
193 | + pub_clue_pool | |
194 | + <where> | |
195 | + group_id = #{groupId} | |
196 | + <if test="startDate != null"> | |
197 | + and create_time <![CDATA[ >= ]]> #{startDate} | |
198 | + </if> | |
199 | + <if test="endDate != null"> | |
200 | + and create_time <![CDATA[ <= ]]> #{endDate} | |
201 | + </if> | |
202 | + <if test="sourceTypes != null and sourceTypes.size > 0 "> | |
203 | + AND source_type IN | |
204 | + <foreach collection="sourceTypes" item="v" separator=" , " open="(" close=")"> | |
205 | + #{v} | |
206 | + </foreach> | |
207 | + </if> | |
208 | + </where> | |
209 | + GROUP BY | |
210 | + shop_id, | |
211 | + adviser_id | |
212 | + </select> | |
213 | + | |
214 | + | |
183 | 215 | </mapper> | ... | ... |
fw-valhalla-dao/src/main/resources/mapper/PublicPoolMapper.xml
... | ... | @@ -165,4 +165,27 @@ |
165 | 165 | </if> |
166 | 166 | </where> |
167 | 167 | </select> |
168 | + | |
169 | + | |
170 | + <select id="countPublicPoolList" resultType="cn.fw.valhalla.domain.dto.PublicPoolReportDTO" parameterType="cn.fw.valhalla.domain.dto.PublicPoolReportQueryDTO"> | |
171 | + SELECT | |
172 | + `type`, | |
173 | + shop_id, | |
174 | + shop_name, | |
175 | + COUNT(*) total | |
176 | + FROM | |
177 | + public_pool | |
178 | + WHERE | |
179 | + group_id = #{groupId} | |
180 | + <if test="startDate != null"> | |
181 | + and create_time <![CDATA[ >= ]]> #{startDate} | |
182 | + </if> | |
183 | + <if test="endDate != null"> | |
184 | + and create_time <![CDATA[ <= ]]> #{endDate} | |
185 | + </if> | |
186 | + GROUP BY | |
187 | + shop_id,`type` | |
188 | + </select> | |
189 | + | |
190 | + | |
168 | 191 | </mapper> | ... | ... |
fw-valhalla-dao/src/main/resources/mapper/PublicReportDataMapper.xml
0 → 100644
fw-valhalla-dao/src/main/resources/mapper/StammkundePoolMapper.xml
... | ... | @@ -245,4 +245,38 @@ |
245 | 245 | </if> |
246 | 246 | </where> |
247 | 247 | </select> |
248 | + | |
249 | + | |
250 | + <select id="countStammkundePoolList" resultType="cn.fw.valhalla.domain.dto.StammkundePoolReportDTO" parameterType="cn.fw.valhalla.domain.dto.StammkundePoolReportQueryDTO"> | |
251 | + SELECT | |
252 | + shop_id, | |
253 | + adviser_id, | |
254 | + adviser_name, | |
255 | + COUNT(*) total | |
256 | + FROM | |
257 | + stammkunde_pool | |
258 | + <where> | |
259 | + group_id = #{groupId} | |
260 | + <if test="fromPublic != null"> | |
261 | + and from_public = #{fromPublic} | |
262 | + </if> | |
263 | + <if test="startDate != null"> | |
264 | + and create_time <![CDATA[ >= ]]> #{startDate} | |
265 | + </if> | |
266 | + <if test="endDate != null"> | |
267 | + and create_time <![CDATA[ <= ]]> #{endDate} | |
268 | + </if> | |
269 | + <if test="sourceSets != null and sourceSets.size > 0 "> | |
270 | + AND sources IN | |
271 | + <foreach collection="sourceSets" item="v" separator=" , " open="(" close=")"> | |
272 | + #{v} | |
273 | + </foreach> | |
274 | + </if> | |
275 | + </where> | |
276 | + GROUP BY | |
277 | + shop_id, | |
278 | + adviser_id | |
279 | + </select> | |
280 | + | |
281 | + | |
248 | 282 | </mapper> | ... | ... |
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/PublicReportData.java
0 → 100644
1 | +package cn.fw.valhalla.domain.db; | |
2 | + | |
3 | +import cn.fw.common.data.entity.BaseAuditableTimeEntity; | |
4 | +import lombok.Data; | |
5 | + | |
6 | +import java.time.LocalDate; | |
7 | + | |
8 | +/** | |
9 | + * 公共池报表数据(初次抽取)(PublicReportData)实体类 | |
10 | + * @author makejava | |
11 | + * @since 2023-05-12 16:09:45 | |
12 | + */ | |
13 | +@Data | |
14 | +public class PublicReportData extends BaseAuditableTimeEntity<PublicReportData, Long> { | |
15 | + /** | |
16 | + * 数据日期 | |
17 | + */ | |
18 | + private LocalDate dataDate; | |
19 | + /** | |
20 | + * 数据维度: 10门店,20人员,99来源 | |
21 | + */ | |
22 | + private String reportDimension; | |
23 | + /** | |
24 | + * 来源类型 1:首保 2:流失 3:主动放弃 (店,来源) | |
25 | + */ | |
26 | + private Integer type; | |
27 | + /** | |
28 | + * 用户id | |
29 | + */ | |
30 | + private Long userId; | |
31 | + /** | |
32 | + * 用户名称 | |
33 | + */ | |
34 | + private String userName; | |
35 | + /** | |
36 | + * 门店id | |
37 | + */ | |
38 | + private Long shopId; | |
39 | + /** | |
40 | + * 门店名称 | |
41 | + */ | |
42 | + private String shopName; | |
43 | + /** | |
44 | + * 月初始数(店,来源) | |
45 | + */ | |
46 | + private Integer monthInitial; | |
47 | + /** | |
48 | + * 日新增(店,来源) | |
49 | + */ | |
50 | + private Integer dayIncrease; | |
51 | + /** | |
52 | + * 月新增(店,来源) | |
53 | + */ | |
54 | + private Integer monthIncrease; | |
55 | + /** | |
56 | + * 截止当前(店,来源) | |
57 | + */ | |
58 | + private Integer currentQuantity; | |
59 | + /** | |
60 | + * 日站岗分配(店,人) | |
61 | + */ | |
62 | + private Integer dayStandQuantity; | |
63 | + /** | |
64 | + * 月站岗分配(店,人) | |
65 | + */ | |
66 | + private Integer monthStandQuantity; | |
67 | + /** | |
68 | + * 日自然到店成交((店,人)) | |
69 | + */ | |
70 | + private Integer dayNaturalQuantity; | |
71 | + /** | |
72 | + * 月自然到店成交((店,人)) | |
73 | + */ | |
74 | + private Integer monthNaturalQuantity; | |
75 | + /** | |
76 | + * 集团id | |
77 | + */ | |
78 | + private Long groupId; | |
79 | + | |
80 | + public PublicReportData() { | |
81 | + } | |
82 | + | |
83 | + public PublicReportData(String reportDimension, Long groupId) { | |
84 | + this.reportDimension = reportDimension; | |
85 | + this.groupId = groupId; | |
86 | + } | |
87 | +} | |
88 | + | ... | ... |
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/PubCluePoolReportDTO.java
0 → 100644
1 | +package cn.fw.valhalla.domain.dto; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +/** | |
6 | + * @author : kurisu | |
7 | + * @className : FollowClueDTO | |
8 | + * @description : 查询站岗分配聚合 | |
9 | + * @date: 2020-11-20 15:27 | |
10 | + */ | |
11 | +@Data | |
12 | +public class PubCluePoolReportDTO { | |
13 | + | |
14 | + /** | |
15 | + * 门店id | |
16 | + */ | |
17 | + private Long shopId; | |
18 | + | |
19 | + /** | |
20 | + * 门店名称 | |
21 | + */ | |
22 | + private String shopName; | |
23 | + | |
24 | + /** | |
25 | + * 顾问id | |
26 | + */ | |
27 | + private Long adviserId; | |
28 | + | |
29 | + /** | |
30 | + * 顾问名称 | |
31 | + */ | |
32 | + private String adviserName; | |
33 | + | |
34 | + /** | |
35 | + * 统计值 | |
36 | + */ | |
37 | + private Long total; | |
38 | +} | ... | ... |
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/PubCluePoolReportQueryDTO.java
0 → 100644
1 | +package cn.fw.valhalla.domain.dto; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +import java.time.LocalDateTime; | |
6 | +import java.util.Set; | |
7 | + | |
8 | +/** | |
9 | + * @author : kurisu | |
10 | + * @className : FollowClueDTO | |
11 | + * @description : 查询站岗分配聚合 | |
12 | + * @date: 2020-11-20 15:27 | |
13 | + */ | |
14 | +@Data | |
15 | +public class PubCluePoolReportQueryDTO { | |
16 | + | |
17 | + private LocalDateTime startDate; | |
18 | + | |
19 | + private LocalDateTime endDate; | |
20 | + | |
21 | + private Set<Integer> sourceTypes; | |
22 | + | |
23 | + private Long groupId; | |
24 | + | |
25 | + public PubCluePoolReportQueryDTO() { | |
26 | + } | |
27 | + | |
28 | + public PubCluePoolReportQueryDTO(Long groupId) { | |
29 | + this.groupId = groupId; | |
30 | + } | |
31 | +} | ... | ... |
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/PublicPoolReportDTO.java
0 → 100644
1 | +package cn.fw.valhalla.domain.dto; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +/** | |
6 | + * @author : kurisu | |
7 | + * @className : FollowClueDTO | |
8 | + * @description : 查询分配聚合 | |
9 | + * @date: 2020-11-20 15:27 | |
10 | + */ | |
11 | +@Data | |
12 | +public class PublicPoolReportDTO { | |
13 | + | |
14 | + /** | |
15 | + * 类型 1:首保 2:流失 3:主动放弃 | |
16 | + */ | |
17 | + private Integer type; | |
18 | + | |
19 | + /** | |
20 | + * 门店id | |
21 | + */ | |
22 | + private Long shopId; | |
23 | + | |
24 | + /** | |
25 | + * 门店名称 | |
26 | + */ | |
27 | + private String shopName; | |
28 | + | |
29 | + /** | |
30 | + * 统计值 | |
31 | + */ | |
32 | + private Long total; | |
33 | +} | ... | ... |
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/PublicPoolReportQueryDTO.java
0 → 100644
1 | +package cn.fw.valhalla.domain.dto; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +import java.time.LocalDateTime; | |
6 | + | |
7 | +/** | |
8 | + * @author : kurisu | |
9 | + * @className : FollowClueDTO | |
10 | + * @description : 查询分配聚合 | |
11 | + * @date: 2020-11-20 15:27 | |
12 | + */ | |
13 | +@Data | |
14 | +public class PublicPoolReportQueryDTO { | |
15 | + | |
16 | + private LocalDateTime startDate; | |
17 | + | |
18 | + private LocalDateTime endDate; | |
19 | + | |
20 | + private Long groupId; | |
21 | + | |
22 | + public PublicPoolReportQueryDTO() { | |
23 | + } | |
24 | + | |
25 | + public PublicPoolReportQueryDTO(Long groupId) { | |
26 | + this.groupId = groupId; | |
27 | + } | |
28 | +} | ... | ... |
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/StammkundePoolReportDTO.java
0 → 100644
1 | +package cn.fw.valhalla.domain.dto; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +/** | |
6 | + * @author : kurisu | |
7 | + * @className : FollowClueDTO | |
8 | + * @description : 查询分配聚合 | |
9 | + * @date: 2020-11-20 15:27 | |
10 | + */ | |
11 | +@Data | |
12 | +public class StammkundePoolReportDTO { | |
13 | + | |
14 | + /** | |
15 | + * 门店id | |
16 | + */ | |
17 | + private Long shopId; | |
18 | + | |
19 | + /** | |
20 | + * 顾问id | |
21 | + */ | |
22 | + private Long adviserId; | |
23 | + | |
24 | + /** | |
25 | + * 顾问名称 | |
26 | + */ | |
27 | + private String adviserName; | |
28 | + | |
29 | + /** | |
30 | + * 统计值 | |
31 | + */ | |
32 | + private Long total; | |
33 | +} | ... | ... |
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/StammkundePoolReportQueryDTO.java
0 → 100644
1 | +package cn.fw.valhalla.domain.dto; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +import java.time.LocalDateTime; | |
6 | +import java.util.Set; | |
7 | + | |
8 | +/** | |
9 | + * @author : kurisu | |
10 | + * @className : FollowClueDTO | |
11 | + * @description : 查询分配聚合 | |
12 | + * @date: 2020-11-20 15:27 | |
13 | + */ | |
14 | +@Data | |
15 | +public class StammkundePoolReportQueryDTO { | |
16 | + | |
17 | + private LocalDateTime startDate; | |
18 | + | |
19 | + private LocalDateTime endDate; | |
20 | + | |
21 | + private Set<Integer> sourceSets; | |
22 | + | |
23 | + /** | |
24 | + * 公共池来源【针对自然进店的标识】 | |
25 | + */ | |
26 | + private Boolean fromPublic; | |
27 | + | |
28 | + private Long groupId; | |
29 | + | |
30 | + public StammkundePoolReportQueryDTO() { | |
31 | + } | |
32 | + | |
33 | + public StammkundePoolReportQueryDTO(Long groupId) { | |
34 | + this.groupId = groupId; | |
35 | + } | |
36 | +} | ... | ... |
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/enums/ValhallaReportDimension.java
0 → 100644
1 | +package cn.fw.valhalla.domain.enums; | |
2 | + | |
3 | +import com.fasterxml.jackson.annotation.JsonCreator; | |
4 | +import lombok.AllArgsConstructor; | |
5 | +import lombok.Getter; | |
6 | + | |
7 | +/** | |
8 | + * 维度 | |
9 | + * <p> | |
10 | + * create at 2020-07-14 | |
11 | + * | |
12 | + * @author zhangjj | |
13 | + */ | |
14 | +@AllArgsConstructor | |
15 | +public enum ValhallaReportDimension { | |
16 | + /** | |
17 | + * 门店 | |
18 | + */ | |
19 | + D10("10"), | |
20 | + /** | |
21 | + * 人员 | |
22 | + */ | |
23 | + D20("20"), | |
24 | + /** | |
25 | + * 来源 | |
26 | + */ | |
27 | + D99("99"), | |
28 | + ; | |
29 | + | |
30 | + /** | |
31 | + * 值 | |
32 | + */ | |
33 | + @Getter | |
34 | + private final String value; | |
35 | + | |
36 | + @JsonCreator | |
37 | + public static ValhallaReportDimension ofValue(final String value) { | |
38 | + for (final ValhallaReportDimension instance : ValhallaReportDimension.values()) { | |
39 | + if (instance.getValue().equals(value)) { | |
40 | + return instance; | |
41 | + } | |
42 | + } | |
43 | + return null; | |
44 | + } | |
45 | +} | ... | ... |
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/debug/DebugController.java
0 → 100644
1 | +package cn.fw.valhalla.controller.debug; | |
2 | + | |
3 | +import cn.fw.common.web.annotation.ControllerMethod; | |
4 | +import cn.fw.data.base.domain.common.Message; | |
5 | +import cn.fw.security.auth.client.annotation.Authorization; | |
6 | +import cn.fw.security.auth.client.annotation.IgnoreAuth; | |
7 | +import cn.fw.security.auth.client.enums.AuthType; | |
8 | +import cn.fw.valhalla.common.utils.DateUtil; | |
9 | +import cn.fw.valhalla.service.report.PublicReportBizService; | |
10 | +import lombok.RequiredArgsConstructor; | |
11 | +import lombok.extern.slf4j.Slf4j; | |
12 | +import org.springframework.validation.annotation.Validated; | |
13 | +import org.springframework.web.bind.annotation.GetMapping; | |
14 | +import org.springframework.web.bind.annotation.RequestMapping; | |
15 | +import org.springframework.web.bind.annotation.RequestParam; | |
16 | +import org.springframework.web.bind.annotation.RestController; | |
17 | + | |
18 | +import java.time.LocalDate; | |
19 | +import java.util.Date; | |
20 | +import java.util.Objects; | |
21 | + | |
22 | +import static cn.fw.common.web.util.ResultBuilder.success; | |
23 | + | |
24 | +/** | |
25 | + * @author : kurisu | |
26 | + * @className : DebugController | |
27 | + * @description : 调试接口 | |
28 | + * @date: 2020-10-22 11:06 | |
29 | + */ | |
30 | +@Slf4j | |
31 | +@RestController | |
32 | +@RequiredArgsConstructor | |
33 | +@IgnoreAuth | |
34 | +@Authorization(AuthType.APP) | |
35 | +@Validated | |
36 | +@RequestMapping("/valhalla/debug") | |
37 | +public class DebugController { | |
38 | + private final PublicReportBizService publicReportBizService; | |
39 | + | |
40 | + @GetMapping("/run/publicReportData") | |
41 | + @ControllerMethod("公共池报表数据准备") | |
42 | + public Message<Void> publicReportData(@RequestParam(required = false) Long groupId, | |
43 | + @RequestParam(required = false)Date date) { | |
44 | + if (Objects.isNull(groupId)) { | |
45 | + groupId = 2L; | |
46 | + } | |
47 | + if (Objects.isNull(date)) { | |
48 | + publicReportBizService.extracting(LocalDate.now().minusDays(1),groupId); | |
49 | + } else { | |
50 | + publicReportBizService.extracting(DateUtil.date2LocalDate(date),groupId); | |
51 | + } | |
52 | + return success(); | |
53 | + } | |
54 | +} | ... | ... |
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/ReportPrepareTask.java
... | ... | @@ -37,13 +37,12 @@ public class ReportPrepareTask { |
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | - * 公共池报表数据准备 | |
40 | + * 公共池报表数据准备,0点30分抽取 | |
41 | 41 | */ |
42 | 42 | @Scheduled(cron = "0 30 0 ? * * ") |
43 | 43 | public void extractingPublicData() { |
44 | 44 | final List<GroupDTO> groupList = oopService.allGroup(); |
45 | - final LocalDate now = LocalDate.now(); | |
46 | - | |
45 | + final LocalDate now = LocalDate.now().minusDays(1); | |
47 | 46 | for (GroupDTO group : groupList) { |
48 | 47 | try { |
49 | 48 | publicReportBizService.extracting(now, group.getId()); | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/PubCluePoolService.java
... | ... | @@ -2,6 +2,8 @@ package cn.fw.valhalla.service.data; |
2 | 2 | |
3 | 3 | import cn.fw.valhalla.domain.db.pub.PubCluePool; |
4 | 4 | import cn.fw.valhalla.domain.dto.FollowPoolDTO; |
5 | +import cn.fw.valhalla.domain.dto.PubCluePoolReportDTO; | |
6 | +import cn.fw.valhalla.domain.dto.PubCluePoolReportQueryDTO; | |
5 | 7 | import cn.fw.valhalla.domain.query.FollowPoolQueryVO; |
6 | 8 | import com.baomidou.mybatisplus.extension.service.IService; |
7 | 9 | |
... | ... | @@ -20,4 +22,11 @@ public interface PubCluePoolService extends IService<PubCluePool> { |
20 | 22 | List<FollowPoolDTO> followList(FollowPoolQueryVO queryVO); |
21 | 23 | |
22 | 24 | long followListCount(FollowPoolQueryVO queryVO); |
25 | + | |
26 | + /** | |
27 | + * 查询站岗分配 | |
28 | + * @param dto | |
29 | + * @return | |
30 | + */ | |
31 | + List<PubCluePoolReportDTO> countPubCluePoolList(PubCluePoolReportQueryDTO dto); | |
23 | 32 | } | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/PublicPoolService.java
... | ... | @@ -2,6 +2,8 @@ package cn.fw.valhalla.service.data; |
2 | 2 | |
3 | 3 | import cn.fw.valhalla.domain.db.pool.PublicPool; |
4 | 4 | import cn.fw.valhalla.domain.dto.PublicPoolDTO; |
5 | +import cn.fw.valhalla.domain.dto.PublicPoolReportDTO; | |
6 | +import cn.fw.valhalla.domain.dto.PublicPoolReportQueryDTO; | |
5 | 7 | import cn.fw.valhalla.domain.query.PublicPoolQueryVO; |
6 | 8 | import com.baomidou.mybatisplus.extension.service.IService; |
7 | 9 | import org.springframework.transaction.annotation.Transactional; |
... | ... | @@ -74,4 +76,11 @@ public interface PublicPoolService extends IService<PublicPool> { |
74 | 76 | * @return |
75 | 77 | */ |
76 | 78 | List<String> queryIdListByShops(List<Long> shopIds); |
79 | + | |
80 | + /** | |
81 | + * 查询公共池来源统计 | |
82 | + * @param dto | |
83 | + * @return | |
84 | + */ | |
85 | + List<PublicPoolReportDTO> countPublicPoolList(PublicPoolReportQueryDTO dto); | |
77 | 86 | } | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/PublicReportDataService.java
0 → 100644
1 | +package cn.fw.valhalla.service.data; | |
2 | + | |
3 | +import cn.fw.valhalla.domain.db.PublicReportData; | |
4 | +import com.baomidou.mybatisplus.extension.service.IService; | |
5 | + | |
6 | +/** | |
7 | + * @author : kurisu | |
8 | + * @className : PublicReportDataService | |
9 | + * @description : 公共池报表数据(初次抽取) | |
10 | + * @date: 2021-02-21 14:58 | |
11 | + */ | |
12 | +public interface PublicReportDataService extends IService<PublicReportData> { | |
13 | + | |
14 | +} | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/StammkundePoolService.java
... | ... | @@ -3,6 +3,8 @@ package cn.fw.valhalla.service.data; |
3 | 3 | import cn.fw.valhalla.domain.db.pool.StammkundePool; |
4 | 4 | import cn.fw.valhalla.domain.dto.StammkundeDto; |
5 | 5 | import cn.fw.valhalla.domain.dto.StammkundePoolDTO; |
6 | +import cn.fw.valhalla.domain.dto.StammkundePoolReportDTO; | |
7 | +import cn.fw.valhalla.domain.dto.StammkundePoolReportQueryDTO; | |
6 | 8 | import cn.fw.valhalla.domain.enums.DefeatReasonEnum; |
7 | 9 | import cn.fw.valhalla.domain.query.StammkundePoolQueryVO; |
8 | 10 | import com.baomidou.mybatisplus.extension.service.IService; |
... | ... | @@ -96,4 +98,11 @@ public interface StammkundePoolService extends IService<StammkundePool> { |
96 | 98 | * @param groupId |
97 | 99 | */ |
98 | 100 | void removeByCustomerId(@NonNull Long customerId, @NonNull Long groupId); |
101 | + | |
102 | + /** | |
103 | + * 查询渠道到店统计 | |
104 | + * @param dto | |
105 | + * @return | |
106 | + */ | |
107 | + List<StammkundePoolReportDTO> countStammkundePoolList(StammkundePoolReportQueryDTO dto); | |
99 | 108 | } | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/PubCluePoolServiceImpl.java
... | ... | @@ -3,6 +3,8 @@ package cn.fw.valhalla.service.data.impl; |
3 | 3 | import cn.fw.valhalla.dao.mapper.PubCluePoolMapper; |
4 | 4 | import cn.fw.valhalla.domain.db.pub.PubCluePool; |
5 | 5 | import cn.fw.valhalla.domain.dto.FollowPoolDTO; |
6 | +import cn.fw.valhalla.domain.dto.PubCluePoolReportDTO; | |
7 | +import cn.fw.valhalla.domain.dto.PubCluePoolReportQueryDTO; | |
6 | 8 | import cn.fw.valhalla.domain.query.FollowPoolQueryVO; |
7 | 9 | import cn.fw.valhalla.service.data.PubCluePoolService; |
8 | 10 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
... | ... | @@ -10,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; |
10 | 12 | import org.springframework.stereotype.Service; |
11 | 13 | |
12 | 14 | import java.util.ArrayList; |
15 | +import java.util.Collections; | |
13 | 16 | import java.util.List; |
14 | 17 | import java.util.Optional; |
15 | 18 | |
... | ... | @@ -37,4 +40,14 @@ public class PubCluePoolServiceImpl extends ServiceImpl<PubCluePoolMapper, PubCl |
37 | 40 | public long followListCount(FollowPoolQueryVO queryVO) { |
38 | 41 | return Optional.ofNullable(getBaseMapper().followListCount(queryVO)).orElse(0L); |
39 | 42 | } |
43 | + | |
44 | + /** | |
45 | + * 查询站岗分配 | |
46 | + * @param dto | |
47 | + * @return | |
48 | + */ | |
49 | + @Override | |
50 | + public List<PubCluePoolReportDTO> countPubCluePoolList(PubCluePoolReportQueryDTO dto){ | |
51 | + return Optional.ofNullable(getBaseMapper().countPubCluePoolList(dto)).orElse(Collections.emptyList()); | |
52 | + } | |
40 | 53 | } | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/PublicPoolServiceImpl.java
... | ... | @@ -3,6 +3,8 @@ package cn.fw.valhalla.service.data.impl; |
3 | 3 | import cn.fw.valhalla.dao.mapper.PublicPoolMapper; |
4 | 4 | import cn.fw.valhalla.domain.db.pool.PublicPool; |
5 | 5 | import cn.fw.valhalla.domain.dto.PublicPoolDTO; |
6 | +import cn.fw.valhalla.domain.dto.PublicPoolReportDTO; | |
7 | +import cn.fw.valhalla.domain.dto.PublicPoolReportQueryDTO; | |
6 | 8 | import cn.fw.valhalla.domain.query.PublicPoolQueryVO; |
7 | 9 | import cn.fw.valhalla.service.data.PublicPoolService; |
8 | 10 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
... | ... | @@ -87,4 +89,9 @@ public class PublicPoolServiceImpl extends ServiceImpl<PublicPoolMapper, PublicP |
87 | 89 | // mybatis plus 性能有问题 不使用 |
88 | 90 | return Optional.ofNullable(this.getBaseMapper().queryIdListByShops(shopIds)).orElse(Collections.emptyList()); |
89 | 91 | } |
92 | + | |
93 | + @Override | |
94 | + public List<PublicPoolReportDTO> countPublicPoolList(PublicPoolReportQueryDTO dto) { | |
95 | + return Optional.ofNullable(this.getBaseMapper().countPublicPoolList(dto)).orElse(Collections.emptyList()); | |
96 | + } | |
90 | 97 | } | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/PublicReportDataServiceImpl.java
0 → 100644
1 | +package cn.fw.valhalla.service.data.impl; | |
2 | + | |
3 | +import cn.fw.valhalla.dao.mapper.PublicReportDataMapper; | |
4 | +import cn.fw.valhalla.domain.db.PublicReportData; | |
5 | +import cn.fw.valhalla.service.data.PublicReportDataService; | |
6 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
7 | +import lombok.extern.slf4j.Slf4j; | |
8 | +import org.springframework.stereotype.Service; | |
9 | + | |
10 | +/** | |
11 | + * @author : kurisu | |
12 | + * @className : PublicReportDataServiceImpl | |
13 | + * @description : 公共池报表数据(初次抽取) | |
14 | + * @date: 2021-02-21 14:58 | |
15 | + */ | |
16 | +@Slf4j | |
17 | +@Service | |
18 | +public class PublicReportDataServiceImpl extends ServiceImpl<PublicReportDataMapper, PublicReportData> implements PublicReportDataService { | |
19 | + | |
20 | +} | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/StammkundePoolServiceImpl.java
... | ... | @@ -4,6 +4,8 @@ import cn.fw.valhalla.dao.mapper.StammkundePoolMapper; |
4 | 4 | import cn.fw.valhalla.domain.db.pool.StammkundePool; |
5 | 5 | import cn.fw.valhalla.domain.dto.StammkundeDto; |
6 | 6 | import cn.fw.valhalla.domain.dto.StammkundePoolDTO; |
7 | +import cn.fw.valhalla.domain.dto.StammkundePoolReportDTO; | |
8 | +import cn.fw.valhalla.domain.dto.StammkundePoolReportQueryDTO; | |
7 | 9 | import cn.fw.valhalla.domain.enums.DefeatReasonEnum; |
8 | 10 | import cn.fw.valhalla.domain.enums.StammkundeStatusEnum; |
9 | 11 | import cn.fw.valhalla.domain.query.StammkundePoolQueryVO; |
... | ... | @@ -123,4 +125,13 @@ public class StammkundePoolServiceImpl extends ServiceImpl<StammkundePoolMapper, |
123 | 125 | .eq(StammkundePool::getGroupId, groupId) |
124 | 126 | ); |
125 | 127 | } |
128 | + | |
129 | + /** | |
130 | + * 查询渠道到店统计 | |
131 | + * @param dto | |
132 | + * @return | |
133 | + */ | |
134 | + public List<StammkundePoolReportDTO> countStammkundePoolList(StammkundePoolReportQueryDTO dto){ | |
135 | + return Optional.ofNullable(getBaseMapper().countStammkundePoolList(dto)).orElse(Collections.emptyList()); | |
136 | + } | |
126 | 137 | } | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/report/PublicReportBizService.java
1 | 1 | package cn.fw.valhalla.service.report; |
2 | 2 | |
3 | 3 | import cn.fw.common.cache.locker.DistributedLocker; |
4 | +import cn.fw.valhalla.domain.db.PublicReportData; | |
5 | +import cn.fw.valhalla.domain.dto.*; | |
6 | +import cn.fw.valhalla.domain.enums.PubStandType; | |
7 | +import cn.fw.valhalla.domain.enums.StammkundeSourcesEnum; | |
8 | +import cn.fw.valhalla.domain.enums.ValhallaReportDimension; | |
9 | +import cn.fw.valhalla.service.data.PubCluePoolService; | |
10 | +import cn.fw.valhalla.service.data.PublicPoolService; | |
11 | +import cn.fw.valhalla.service.data.PublicReportDataService; | |
12 | +import cn.fw.valhalla.service.data.StammkundePoolService; | |
13 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
14 | +import com.google.common.collect.Sets; | |
4 | 15 | import lombok.Getter; |
5 | 16 | import lombok.RequiredArgsConstructor; |
6 | 17 | import lombok.extern.slf4j.Slf4j; |
... | ... | @@ -9,8 +20,14 @@ import org.springframework.beans.factory.annotation.Value; |
9 | 20 | import org.springframework.stereotype.Service; |
10 | 21 | import org.springframework.transaction.annotation.Transactional; |
11 | 22 | import org.springframework.util.Assert; |
23 | +import org.springframework.util.CollectionUtils; | |
24 | +import org.springframework.util.StringUtils; | |
12 | 25 | |
13 | 26 | import java.time.LocalDate; |
27 | +import java.time.LocalDateTime; | |
28 | +import java.time.temporal.TemporalAdjusters; | |
29 | +import java.util.*; | |
30 | +import java.util.stream.Collectors; | |
14 | 31 | |
15 | 32 | /** |
16 | 33 | * 公共池报表数据服务 |
... | ... | @@ -26,6 +43,10 @@ import java.time.LocalDate; |
26 | 43 | @RequiredArgsConstructor |
27 | 44 | public class PublicReportBizService { |
28 | 45 | private final DistributedLocker distributedLocker; |
46 | + private final PublicReportDataService publicReportDataService; | |
47 | + private final PubCluePoolService pubCluePoolService; | |
48 | + private final StammkundePoolService stammkundePoolService; | |
49 | + private final PublicPoolService publicPoolService; | |
29 | 50 | |
30 | 51 | @Value("${spring.cache.custom.global-prefix}:PublicReport:extracting") |
31 | 52 | @Getter |
... | ... | @@ -46,7 +67,81 @@ public class PublicReportBizService { |
46 | 67 | return; |
47 | 68 | } |
48 | 69 | try { |
49 | - // TODO: 2023/5/4 完成方法 | |
70 | + /** | |
71 | + * 1.准备数据 | |
72 | + */ | |
73 | + HashSet<Integer> sourceTypes = Sets.newHashSet(PubStandType.PUB.getValue(), PubStandType.ACTIVITY.getValue()); | |
74 | + HashSet<Integer> sourceSets = Sets.newHashSet(StammkundeSourcesEnum.NATURAL.getValue()); | |
75 | + //开始时间 | |
76 | + LocalDateTime startDayDateTime = nowDate.atTime(0, 0, 0); | |
77 | + //结束时间 | |
78 | + LocalDateTime endDayDateTime = nowDate.atTime(23, 59, 59); | |
79 | + //月初日期 | |
80 | + LocalDate startMonDate = nowDate.with(TemporalAdjusters.firstDayOfMonth()); | |
81 | + //月初时间 | |
82 | + LocalDateTime startMonDateTime = startMonDate.atTime(0,0,0); | |
83 | + //月初的截止结束时间 = 月初的上一天的23:59:59 | |
84 | + LocalDateTime startMonDateTimeOver = startMonDate.minusDays(1).atTime(23, 59, 59); | |
85 | + /** | |
86 | + * 1.1 查询日站岗分配(人) | |
87 | + */ | |
88 | + List<PubCluePoolReportDTO> cluePoolDayList = getCluePoolTimeList(groupId, sourceTypes, startDayDateTime, endDayDateTime); | |
89 | + /** | |
90 | + * 1.2 查询月站岗分配(人) | |
91 | + */ | |
92 | + List<PubCluePoolReportDTO> cluePoolMonList = getCluePoolTimeList(groupId, sourceTypes,startMonDateTime, endDayDateTime); | |
93 | + /** | |
94 | + * 1.3 查询日自然到店成交(人) | |
95 | + */ | |
96 | + List<StammkundePoolReportDTO> stammkundePoolReportDayList = getStammkundePoolReportTimeList(groupId, startDayDateTime, endDayDateTime, sourceSets); | |
97 | + /** | |
98 | + * 1.4 查询月自然到店成交(人) | |
99 | + */ | |
100 | + List<StammkundePoolReportDTO> stammkundePoolReportMonList = getStammkundePoolReportTimeList(groupId, startMonDateTime,endDayDateTime, sourceSets); | |
101 | + /** | |
102 | + * 1.5 查询日新增(来源) | |
103 | + */ | |
104 | + List<PublicPoolReportDTO> poolReportDayDTOList = getPoolReportList(groupId, startDayDateTime, endDayDateTime); | |
105 | + /** | |
106 | + * 1.6 查询月新增(来源) | |
107 | + */ | |
108 | + List<PublicPoolReportDTO> poolReportMonDTOList = getPoolReportList(groupId, startMonDateTime, endDayDateTime); | |
109 | + /** | |
110 | + * 1.7 截止当前(来源) | |
111 | + */ | |
112 | + List<PublicPoolReportDTO> poolReportCutDTOList = getPoolReportList(groupId,null, endDayDateTime); | |
113 | + | |
114 | + /** | |
115 | + * 1.8 月初始数(来源) | |
116 | + */ | |
117 | + List<PublicPoolReportDTO> poolReportMonFirstDTOList = getPoolReportMonFirstDTOList(nowDate,startMonDate, groupId, startMonDateTimeOver); | |
118 | + /** | |
119 | + * 2.处理数据 | |
120 | + */ | |
121 | + /** | |
122 | + * 2.1 人员维度 | |
123 | + */ | |
124 | + List<PublicReportData> publicReportDataD20List = extractedD20(nowDate, groupId, cluePoolDayList, cluePoolMonList, stammkundePoolReportDayList, stammkundePoolReportMonList); | |
125 | + /** | |
126 | + * 2.2 来源维度 | |
127 | + */ | |
128 | + List<PublicReportData> publicReportDataD99List = extractedD99(nowDate, groupId, poolReportDayDTOList, poolReportMonDTOList, poolReportCutDTOList, poolReportMonFirstDTOList); | |
129 | + /** | |
130 | + * 2.3 门店维度 = 来源 + 人员 | |
131 | + */ | |
132 | + List<PublicReportData> publicReportDataD10List = extractedD10(nowDate, groupId, publicReportDataD20List, publicReportDataD99List); | |
133 | + | |
134 | + /** | |
135 | + * 3.存储数据 | |
136 | + */ | |
137 | + /** | |
138 | + * 3.1 清理旧数据 | |
139 | + */ | |
140 | + delNowDate(nowDate); | |
141 | + /** | |
142 | + * 3.2 存储新数据 | |
143 | + */ | |
144 | + save(publicReportDataD20List, publicReportDataD99List, publicReportDataD10List); | |
50 | 145 | } finally { |
51 | 146 | if (lock.isLocked()) { |
52 | 147 | lock.unlock(); |
... | ... | @@ -54,6 +149,437 @@ public class PublicReportBizService { |
54 | 149 | } |
55 | 150 | } |
56 | 151 | |
152 | + /** | |
153 | + * 获取月初的数据 | |
154 | + * @param nowDate | |
155 | + * @param startMonDate | |
156 | + * @param groupId | |
157 | + * @param startMonDateTimeOver | |
158 | + * @return | |
159 | + */ | |
160 | + private List<PublicPoolReportDTO> getPoolReportMonFirstDTOList(LocalDate nowDate,LocalDate startMonDate, Long groupId, LocalDateTime startMonDateTimeOver) { | |
161 | + List<PublicPoolReportDTO> poolReportMonFirstDTOList = new ArrayList<>(); | |
162 | + if (nowDate.equals(startMonDate)) { | |
163 | + //如果是月初一就去查询小于月初一的数据统计 | |
164 | + poolReportMonFirstDTOList = getPoolReportList(groupId,null, startMonDateTimeOver); | |
165 | + }else { | |
166 | + //不是1号的数据直接从上次抽取的数据中查询月初一的数据 | |
167 | + List<PublicReportData> reportDataList = publicReportDataService.list(Wrappers.<PublicReportData>lambdaQuery() | |
168 | + .eq(PublicReportData::getReportDimension, ValhallaReportDimension.D99.getValue()) | |
169 | + .eq(PublicReportData::getDataDate, startMonDate) | |
170 | + ); | |
171 | + if (!CollectionUtils.isEmpty(reportDataList)){ | |
172 | + for (PublicReportData publicReportData : reportDataList) { | |
173 | + PublicPoolReportDTO publicPoolReportDTO = new PublicPoolReportDTO(); | |
174 | + publicPoolReportDTO.setType(publicReportData.getType()); | |
175 | + publicPoolReportDTO.setShopId(publicReportData.getShopId()); | |
176 | + publicPoolReportDTO.setShopName(publicReportData.getShopName()); | |
177 | + if (Objects.nonNull(publicReportData.getMonthInitial())){ | |
178 | + publicPoolReportDTO.setTotal(publicReportData.getMonthInitial().longValue()); | |
179 | + } | |
180 | + poolReportMonFirstDTOList.add(publicPoolReportDTO); | |
181 | + } | |
182 | + } | |
183 | + } | |
184 | + return poolReportMonFirstDTOList; | |
185 | + } | |
186 | + | |
187 | + /** | |
188 | + * 查询指定时间 | |
189 | + * @param groupId | |
190 | + * @param startDayDateTime | |
191 | + * @param endDayDateTime | |
192 | + * @return | |
193 | + */ | |
194 | + private List<PublicPoolReportDTO> getPoolReportList(Long groupId,LocalDateTime startDayDateTime,LocalDateTime endDayDateTime){ | |
195 | + PublicPoolReportQueryDTO publicPoolReportQueryDayDTO = new PublicPoolReportQueryDTO(groupId); | |
196 | + publicPoolReportQueryDayDTO.setStartDate(startDayDateTime); | |
197 | + publicPoolReportQueryDayDTO.setEndDate(endDayDateTime); | |
198 | + return publicPoolService.countPublicPoolList(publicPoolReportQueryDayDTO); | |
199 | + } | |
200 | + | |
201 | + /** | |
202 | + * 1.3 查询指定时间自然到店成交(人) | |
203 | + * @param groupId | |
204 | + * @param startDayDateTime | |
205 | + * @param endDayDateTime | |
206 | + * @param sourceSets | |
207 | + * @return | |
208 | + */ | |
209 | + private List<StammkundePoolReportDTO> getStammkundePoolReportTimeList(Long groupId, LocalDateTime startDayDateTime, LocalDateTime endDayDateTime, HashSet<Integer> sourceSets) { | |
210 | + StammkundePoolReportQueryDTO stammkundePoolReportQueryDayDTO = new StammkundePoolReportQueryDTO(groupId); | |
211 | + stammkundePoolReportQueryDayDTO.setStartDate(startDayDateTime); | |
212 | + stammkundePoolReportQueryDayDTO.setEndDate(endDayDateTime); | |
213 | + stammkundePoolReportQueryDayDTO.setSourceSets(sourceSets); | |
214 | + return stammkundePoolService.countStammkundePoolList(stammkundePoolReportQueryDayDTO); | |
215 | + } | |
216 | + | |
217 | + /** | |
218 | + * 1.1 查询指定时间站岗分配(人) | |
219 | + * @param groupId | |
220 | + * @param sourceTypes | |
221 | + * @param startDayDateTime | |
222 | + * @param endDayDateTime | |
223 | + * @return | |
224 | + */ | |
225 | + private List<PubCluePoolReportDTO> getCluePoolTimeList(Long groupId, HashSet<Integer> sourceTypes, LocalDateTime startDayDateTime, LocalDateTime endDayDateTime) { | |
226 | + PubCluePoolReportQueryDTO reportQueryDayDTO = new PubCluePoolReportQueryDTO(groupId); | |
227 | + reportQueryDayDTO.setStartDate(startDayDateTime); | |
228 | + reportQueryDayDTO.setEndDate(endDayDateTime); | |
229 | + reportQueryDayDTO.setSourceTypes(sourceTypes); | |
230 | + return pubCluePoolService.countPubCluePoolList(reportQueryDayDTO); | |
231 | + } | |
232 | + | |
233 | + /** | |
234 | + * 3.1 清理旧数据 | |
235 | + * @param nowDate | |
236 | + */ | |
237 | + private void delNowDate(LocalDate nowDate) { | |
238 | + publicReportDataService.remove(Wrappers.<PublicReportData>lambdaUpdate() | |
239 | + .eq(PublicReportData::getDataDate, nowDate) | |
240 | + ); | |
241 | + } | |
242 | + | |
243 | + /** | |
244 | + * 3.2 存储新数据 | |
245 | + * @param publicReportDataD20List 人员的 | |
246 | + * @param publicReportDataD99List 来源的 | |
247 | + * @param publicReportDataD10List 店的 | |
248 | + */ | |
249 | + private void save(List<PublicReportData> publicReportDataD20List, List<PublicReportData> publicReportDataD99List, List<PublicReportData> publicReportDataD10List) { | |
250 | + if (!CollectionUtils.isEmpty(publicReportDataD20List)){ | |
251 | + for (PublicReportData reportData : publicReportDataD20List) { | |
252 | + dealDefaultValueD20(reportData); | |
253 | + } | |
254 | + publicReportDataService.saveBatch(publicReportDataD20List); | |
255 | + } | |
256 | + if (!CollectionUtils.isEmpty(publicReportDataD99List)){ | |
257 | + for (PublicReportData reportData : publicReportDataD99List) { | |
258 | + dealDefaultValueD99(reportData); | |
259 | + } | |
260 | + publicReportDataService.saveBatch(publicReportDataD99List); | |
261 | + } | |
262 | + if (!CollectionUtils.isEmpty(publicReportDataD10List)){ | |
263 | + for (PublicReportData reportData : publicReportDataD10List) { | |
264 | + //店的默认值处理,共8个 = 人的+店的 | |
265 | + dealDefaultValueD20(reportData); | |
266 | + dealDefaultValueD99(reportData); | |
267 | + } | |
268 | + publicReportDataService.saveBatch(publicReportDataD10List); | |
269 | + } | |
270 | + } | |
271 | + | |
272 | + /** | |
273 | + * 来源的默认值处理,共4个 | |
274 | + * @param reportData | |
275 | + */ | |
276 | + private static void dealDefaultValueD99(PublicReportData reportData) { | |
277 | + if (Objects.isNull(reportData.getMonthInitial())){ | |
278 | + reportData.setMonthInitial(0); | |
279 | + } | |
280 | + if (Objects.isNull(reportData.getDayIncrease())){ | |
281 | + reportData.setDayIncrease(0); | |
282 | + } | |
283 | + if (Objects.isNull(reportData.getMonthIncrease())){ | |
284 | + reportData.setMonthIncrease(0); | |
285 | + } | |
286 | + if (Objects.isNull(reportData.getCurrentQuantity())){ | |
287 | + reportData.setCurrentQuantity(0); | |
288 | + } | |
289 | + } | |
290 | + | |
291 | + /** | |
292 | + * 人员的默认值处理,共4个 | |
293 | + * @param reportData | |
294 | + */ | |
295 | + private static void dealDefaultValueD20(PublicReportData reportData) { | |
296 | + //人员的默认值处理,共4个 | |
297 | + if (Objects.isNull(reportData.getDayStandQuantity())){ | |
298 | + reportData.setDayStandQuantity(0); | |
299 | + } | |
300 | + if (Objects.isNull(reportData.getMonthStandQuantity())){ | |
301 | + reportData.setMonthStandQuantity(0); | |
302 | + } | |
303 | + if (Objects.isNull(reportData.getDayNaturalQuantity())){ | |
304 | + reportData.setDayNaturalQuantity(0); | |
305 | + } | |
306 | + if (Objects.isNull(reportData.getMonthNaturalQuantity())){ | |
307 | + reportData.setMonthNaturalQuantity(0); | |
308 | + } | |
309 | + } | |
310 | + | |
311 | + | |
312 | + /** | |
313 | + * 处理门店维度的数据 | |
314 | + * @param nowDate | |
315 | + * @param groupId | |
316 | + * @param publicReportDataD20List | |
317 | + * @param publicReportDataD99List | |
318 | + * @return | |
319 | + */ | |
320 | + private List<PublicReportData> extractedD10(LocalDate nowDate, Long groupId, List<PublicReportData> publicReportDataD20List, List<PublicReportData> publicReportDataD99List) { | |
321 | + List<PublicReportData> publicReportData10List = new ArrayList<>(); | |
322 | + if (!CollectionUtils.isEmpty(publicReportDataD20List)){ | |
323 | + Map<Long, List<PublicReportData>> shopIdListMap = publicReportDataD20List.stream().collect(Collectors.groupingBy(PublicReportData::getShopId)); | |
324 | + shopIdListMap.forEach((shopId,shopList) -> { | |
325 | + PublicReportData publicReportData = getPublicReportDataD10(publicReportData10List, shopId, groupId); | |
326 | + publicReportData.setDataDate(nowDate); | |
327 | + publicReportData.setShopId(shopId); | |
328 | + if (StringUtils.isEmpty(publicReportData.getShopName())){ | |
329 | + publicReportData.setShopName(Objects.nonNull(shopList.get(0)) ? shopList.get(0).getShopName():null); | |
330 | + } | |
331 | + publicReportData.setDayStandQuantity(shopList.stream().filter(e -> Objects.nonNull(e.getDayStandQuantity())).mapToInt(PublicReportData :: getDayStandQuantity).sum()); | |
332 | + publicReportData.setMonthStandQuantity(shopList.stream().filter(e -> Objects.nonNull(e.getMonthStandQuantity())).mapToInt(PublicReportData :: getMonthStandQuantity).sum()); | |
333 | + publicReportData.setDayNaturalQuantity(shopList.stream().filter(e -> Objects.nonNull(e.getDayNaturalQuantity())).mapToInt(PublicReportData :: getDayNaturalQuantity).sum()); | |
334 | + publicReportData.setMonthNaturalQuantity(shopList.stream().filter(e -> Objects.nonNull(e.getMonthNaturalQuantity())).mapToInt(PublicReportData :: getMonthNaturalQuantity).sum()); | |
335 | + publicReportData.setCreateTime(new Date()); | |
336 | + publicReportData.setUpdateTime(publicReportData.getCreateTime()); | |
337 | + if (!publicReportData10List.contains(publicReportData)){ | |
338 | + publicReportData10List.add(publicReportData); | |
339 | + } | |
340 | + }); | |
341 | + } | |
342 | + if (!CollectionUtils.isEmpty(publicReportDataD99List)){ | |
343 | + Map<Long, List<PublicReportData>> shopIdListMap = publicReportDataD99List.stream().collect(Collectors.groupingBy(PublicReportData::getShopId)); | |
344 | + shopIdListMap.forEach((shopId,shopList) -> { | |
345 | + PublicReportData publicReportData = getPublicReportDataD10(publicReportData10List, shopId, groupId); | |
346 | + publicReportData.setDataDate(nowDate); | |
347 | + publicReportData.setShopId(shopId); | |
348 | + if (StringUtils.isEmpty(publicReportData.getShopName())){ | |
349 | + publicReportData.setShopName(Objects.nonNull(shopList.get(0)) ? shopList.get(0).getShopName():null); | |
350 | + } | |
351 | + publicReportData.setDayIncrease(shopList.stream().filter(e -> Objects.nonNull(e.getDayIncrease())).mapToInt(PublicReportData :: getDayIncrease).sum()); | |
352 | + publicReportData.setMonthIncrease(shopList.stream().filter(e -> Objects.nonNull(e.getMonthIncrease())).mapToInt(PublicReportData :: getMonthIncrease).sum()); | |
353 | + publicReportData.setCurrentQuantity(shopList.stream().filter(e -> Objects.nonNull(e.getCurrentQuantity())).mapToInt(PublicReportData :: getCurrentQuantity).sum()); | |
354 | + publicReportData.setMonthInitial(shopList.stream().filter(e -> Objects.nonNull(e.getMonthInitial())).mapToInt(PublicReportData :: getMonthInitial).sum()); | |
355 | + publicReportData.setCreateTime(new Date()); | |
356 | + publicReportData.setUpdateTime(publicReportData.getCreateTime()); | |
357 | + if (!publicReportData10List.contains(publicReportData)){ | |
358 | + publicReportData10List.add(publicReportData); | |
359 | + } | |
360 | + }); | |
361 | + } | |
362 | + return publicReportData10List; | |
363 | + } | |
364 | + | |
365 | + | |
366 | + /** | |
367 | + * 处理来源维度的数据 | |
368 | + * @param nowDate | |
369 | + * @param groupId | |
370 | + * @param poolReportDayDTOList | |
371 | + * @param poolReportMonDTOList | |
372 | + * @param poolReportCutDTOList | |
373 | + * @param poolReportMonFirstDTOList | |
374 | + */ | |
375 | + private List<PublicReportData> extractedD99(LocalDate nowDate, Long groupId, | |
376 | + List<PublicPoolReportDTO> poolReportDayDTOList, | |
377 | + List<PublicPoolReportDTO> poolReportMonDTOList, | |
378 | + List<PublicPoolReportDTO> poolReportCutDTOList, | |
379 | + List<PublicPoolReportDTO> poolReportMonFirstDTOList) { | |
380 | + List<PublicReportData> publicReportData99List = new ArrayList<>(); | |
381 | + if (!CollectionUtils.isEmpty(poolReportDayDTOList)){ | |
382 | + for (PublicPoolReportDTO publicPoolReportDTO : poolReportDayDTOList) { | |
383 | + PublicReportData publicReportData = getPublicReportDataD99Increase(publicReportData99List, publicPoolReportDTO, groupId); | |
384 | + publicReportData.setDataDate(nowDate); | |
385 | + publicReportData.setShopId(publicPoolReportDTO.getShopId()); | |
386 | + if (StringUtils.isEmpty(publicReportData.getShopName())){ | |
387 | + publicReportData.setShopName(publicPoolReportDTO.getShopName()); | |
388 | + } | |
389 | + publicReportData.setDayIncrease(publicPoolReportDTO.getTotal().intValue()); | |
390 | + publicReportData.setType(publicPoolReportDTO.getType()); | |
391 | + publicReportData.setCreateTime(new Date()); | |
392 | + publicReportData.setUpdateTime(publicReportData.getCreateTime()); | |
393 | + if (!publicReportData99List.contains(publicReportData)){ | |
394 | + publicReportData99List.add(publicReportData); | |
395 | + } | |
396 | + } | |
397 | + } | |
398 | + if (!CollectionUtils.isEmpty(poolReportMonDTOList)){ | |
399 | + for (PublicPoolReportDTO publicPoolReportDTO : poolReportMonDTOList) { | |
400 | + PublicReportData publicReportData = getPublicReportDataD99Increase(publicReportData99List, publicPoolReportDTO, groupId); | |
401 | + publicReportData.setDataDate(nowDate); | |
402 | + publicReportData.setShopId(publicPoolReportDTO.getShopId()); | |
403 | + if (StringUtils.isEmpty(publicReportData.getShopName())){ | |
404 | + publicReportData.setShopName(publicPoolReportDTO.getShopName()); | |
405 | + } | |
406 | + publicReportData.setMonthIncrease(publicPoolReportDTO.getTotal().intValue()); | |
407 | + publicReportData.setType(publicPoolReportDTO.getType()); | |
408 | + publicReportData.setCreateTime(new Date()); | |
409 | + publicReportData.setUpdateTime(publicReportData.getCreateTime()); | |
410 | + if (!publicReportData99List.contains(publicReportData)){ | |
411 | + publicReportData99List.add(publicReportData); | |
412 | + } | |
413 | + } | |
414 | + } | |
415 | + if (!CollectionUtils.isEmpty(poolReportCutDTOList)){ | |
416 | + for (PublicPoolReportDTO publicPoolReportDTO : poolReportCutDTOList) { | |
417 | + PublicReportData publicReportData = getPublicReportDataD99Increase(publicReportData99List, publicPoolReportDTO, groupId); | |
418 | + publicReportData.setDataDate(nowDate); | |
419 | + publicReportData.setShopId(publicPoolReportDTO.getShopId()); | |
420 | + if (StringUtils.isEmpty(publicReportData.getShopName())){ | |
421 | + publicReportData.setShopName(publicPoolReportDTO.getShopName()); | |
422 | + } | |
423 | + publicReportData.setCurrentQuantity(publicPoolReportDTO.getTotal().intValue()); | |
424 | + publicReportData.setType(publicPoolReportDTO.getType()); | |
425 | + publicReportData.setCreateTime(new Date()); | |
426 | + publicReportData.setUpdateTime(publicReportData.getCreateTime()); | |
427 | + if (!publicReportData99List.contains(publicReportData)){ | |
428 | + publicReportData99List.add(publicReportData); | |
429 | + } | |
430 | + } | |
431 | + } | |
432 | + if (!CollectionUtils.isEmpty(poolReportMonFirstDTOList)){ | |
433 | + for (PublicPoolReportDTO publicPoolReportDTO : poolReportMonFirstDTOList) { | |
434 | + PublicReportData publicReportData = getPublicReportDataD99Increase(publicReportData99List, publicPoolReportDTO, groupId); | |
435 | + publicReportData.setDataDate(nowDate); | |
436 | + publicReportData.setShopId(publicPoolReportDTO.getShopId()); | |
437 | + if (StringUtils.isEmpty(publicReportData.getShopName())){ | |
438 | + publicReportData.setShopName(publicPoolReportDTO.getShopName()); | |
439 | + } | |
440 | + publicReportData.setMonthInitial(publicPoolReportDTO.getTotal().intValue()); | |
441 | + publicReportData.setType(publicPoolReportDTO.getType()); | |
442 | + publicReportData.setCreateTime(new Date()); | |
443 | + publicReportData.setUpdateTime(publicReportData.getCreateTime()); | |
444 | + if (!publicReportData99List.contains(publicReportData)){ | |
445 | + publicReportData99List.add(publicReportData); | |
446 | + } | |
447 | + } | |
448 | + } | |
449 | + return publicReportData99List; | |
450 | + } | |
451 | + | |
452 | + /** | |
453 | + * 处理人员维度的数据 | |
454 | + * @param nowDate | |
455 | + * @param groupId | |
456 | + * @param cluePoolDayList | |
457 | + * @param cluePoolMonList | |
458 | + * @param stammkundePoolReportDayDTOS | |
459 | + * @param stammkundePoolReportMonDTOS | |
460 | + */ | |
461 | + private List<PublicReportData> extractedD20(LocalDate nowDate, Long groupId, | |
462 | + List<PubCluePoolReportDTO> cluePoolDayList, | |
463 | + List<PubCluePoolReportDTO> cluePoolMonList, | |
464 | + List<StammkundePoolReportDTO> stammkundePoolReportDayDTOS, | |
465 | + List<StammkundePoolReportDTO> stammkundePoolReportMonDTOS) { | |
466 | + List<PublicReportData> publicReportData20List = new ArrayList<>(); | |
467 | + if (!CollectionUtils.isEmpty(cluePoolDayList)){ | |
468 | + for (PubCluePoolReportDTO pubCluePoolReportDTO : cluePoolDayList) { | |
469 | + PublicReportData data = getPublicReportDataD20Stand(publicReportData20List, pubCluePoolReportDTO, groupId); | |
470 | + data.setDataDate(nowDate); | |
471 | + data.setUserId(pubCluePoolReportDTO.getAdviserId()); | |
472 | + data.setUserName(pubCluePoolReportDTO.getAdviserName()); | |
473 | + data.setShopId(pubCluePoolReportDTO.getShopId()); | |
474 | + if (StringUtils.isEmpty(data.getShopName())){ | |
475 | + data.setShopName(pubCluePoolReportDTO.getShopName()); | |
476 | + } | |
477 | + data.setDayStandQuantity(pubCluePoolReportDTO.getTotal().intValue()); | |
478 | + data.setCreateTime(new Date()); | |
479 | + data.setUpdateTime(data.getCreateTime()); | |
480 | + if (!publicReportData20List.contains(data)){ | |
481 | + publicReportData20List.add(data); | |
482 | + } | |
483 | + } | |
484 | + } | |
485 | + if (!CollectionUtils.isEmpty(cluePoolMonList)){ | |
486 | + for (PubCluePoolReportDTO pubCluePoolReportDTO : cluePoolMonList) { | |
487 | + PublicReportData data = getPublicReportDataD20Stand(publicReportData20List, pubCluePoolReportDTO, groupId); | |
488 | + data.setDataDate(nowDate); | |
489 | + data.setUserId(pubCluePoolReportDTO.getAdviserId()); | |
490 | + data.setUserName(pubCluePoolReportDTO.getAdviserName()); | |
491 | + data.setShopId(pubCluePoolReportDTO.getShopId()); | |
492 | + if (StringUtils.isEmpty(data.getShopName())){ | |
493 | + data.setShopName(pubCluePoolReportDTO.getShopName()); | |
494 | + } | |
495 | + data.setMonthStandQuantity((pubCluePoolReportDTO.getTotal().intValue())); | |
496 | + data.setCreateTime(new Date()); | |
497 | + data.setUpdateTime(data.getCreateTime()); | |
498 | + if (!publicReportData20List.contains(data)){ | |
499 | + publicReportData20List.add(data); | |
500 | + } | |
501 | + } | |
502 | + } | |
503 | + if (!CollectionUtils.isEmpty(stammkundePoolReportDayDTOS)){ | |
504 | + for (StammkundePoolReportDTO stammkundePoolReportDTO : stammkundePoolReportDayDTOS) { | |
505 | + PublicReportData data = getPublicReportDataD20Natural(publicReportData20List, stammkundePoolReportDTO, groupId); | |
506 | + data.setDataDate(nowDate); | |
507 | + data.setUserId(stammkundePoolReportDTO.getAdviserId()); | |
508 | + data.setUserName(stammkundePoolReportDTO.getAdviserName()); | |
509 | + data.setShopId(stammkundePoolReportDTO.getShopId()); | |
510 | + data.setDayNaturalQuantity((stammkundePoolReportDTO.getTotal().intValue())); | |
511 | + data.setCreateTime(new Date()); | |
512 | + data.setUpdateTime(new Date()); | |
513 | + if (!publicReportData20List.contains(data)){ | |
514 | + publicReportData20List.add(data); | |
515 | + } | |
516 | + } | |
517 | + } | |
518 | + if (!CollectionUtils.isEmpty(stammkundePoolReportMonDTOS)){ | |
519 | + for (StammkundePoolReportDTO stammkundePoolReportDTO : stammkundePoolReportMonDTOS) { | |
520 | + PublicReportData data = getPublicReportDataD20Natural(publicReportData20List, stammkundePoolReportDTO, groupId); | |
521 | + data.setDataDate(nowDate); | |
522 | + data.setUserId(stammkundePoolReportDTO.getAdviserId()); | |
523 | + data.setUserName(stammkundePoolReportDTO.getAdviserName()); | |
524 | + data.setShopId(stammkundePoolReportDTO.getShopId()); | |
525 | + data.setMonthNaturalQuantity((stammkundePoolReportDTO.getTotal().intValue())); | |
526 | + data.setCreateTime(new Date()); | |
527 | + data.setUpdateTime(new Date()); | |
528 | + if (!publicReportData20List.contains(data)){ | |
529 | + publicReportData20List.add(data); | |
530 | + } | |
531 | + } | |
532 | + } | |
533 | + return publicReportData20List; | |
534 | + } | |
535 | + | |
536 | + private PublicReportData getPublicReportDataD20Stand(List<PublicReportData> publicReportData20List,PubCluePoolReportDTO pubCluePoolReportDTO,Long groupId){ | |
537 | + if (CollectionUtils.isEmpty(publicReportData20List)){ | |
538 | + return new PublicReportData(ValhallaReportDimension.D20.getValue(),groupId); | |
539 | + } | |
540 | + Optional<PublicReportData> dataOptional = publicReportData20List.stream().filter(e -> pubCluePoolReportDTO.getAdviserId().equals(e.getUserId()) && pubCluePoolReportDTO.getShopId().equals(e.getShopId())).findFirst(); | |
541 | + if (dataOptional.isPresent()){ | |
542 | + return dataOptional.get(); | |
543 | + } | |
544 | + return new PublicReportData(ValhallaReportDimension.D20.getValue(),groupId); | |
545 | + } | |
546 | + | |
547 | + private PublicReportData getPublicReportDataD20Natural(List<PublicReportData> publicReportData20List,StammkundePoolReportDTO stammkundePoolReportMonDTO,Long groupId){ | |
548 | + if (CollectionUtils.isEmpty(publicReportData20List)){ | |
549 | + return new PublicReportData(ValhallaReportDimension.D20.getValue(),groupId); | |
550 | + } | |
551 | + Optional<PublicReportData> dataOptional = publicReportData20List.stream().filter(e -> stammkundePoolReportMonDTO.getAdviserId().equals(e.getUserId()) && stammkundePoolReportMonDTO.getShopId().equals(e.getShopId())).findFirst(); | |
552 | + if (dataOptional.isPresent()){ | |
553 | + return dataOptional.get(); | |
554 | + } | |
555 | + return new PublicReportData(ValhallaReportDimension.D20.getValue(),groupId); | |
556 | + } | |
557 | + | |
558 | + private PublicReportData getPublicReportDataD99Increase(List<PublicReportData> publicReportData20List,PublicPoolReportDTO publicPoolReportDTO,Long groupId){ | |
559 | + if (CollectionUtils.isEmpty(publicReportData20List)){ | |
560 | + return new PublicReportData(ValhallaReportDimension.D99.getValue(),groupId); | |
561 | + } | |
562 | + Optional<PublicReportData> dataOptional = publicReportData20List.stream().filter(e -> publicPoolReportDTO.getType().equals(e.getType()) && publicPoolReportDTO.getShopId().equals(e.getShopId())).findFirst(); | |
563 | + if (dataOptional.isPresent()){ | |
564 | + return dataOptional.get(); | |
565 | + } | |
566 | + return new PublicReportData(ValhallaReportDimension.D99.getValue(),groupId); | |
567 | + } | |
568 | + | |
569 | + private PublicReportData getPublicReportDataD10(List<PublicReportData> publicReportData20List,Long shopId,Long groupId){ | |
570 | + if (CollectionUtils.isEmpty(publicReportData20List)){ | |
571 | + return new PublicReportData(ValhallaReportDimension.D10.getValue(),groupId); | |
572 | + } | |
573 | + Optional<PublicReportData> dataOptional = publicReportData20List.stream().filter(e -> shopId.equals(e.getShopId())).findFirst(); | |
574 | + if (dataOptional.isPresent()){ | |
575 | + return dataOptional.get(); | |
576 | + } | |
577 | + return new PublicReportData(ValhallaReportDimension.D10.getValue(),groupId); | |
578 | + } | |
579 | + | |
580 | + | |
581 | + | |
582 | + | |
57 | 583 | private String generateKey(final Long groupId) { |
58 | 584 | Assert.notNull(groupId, "groupId cannot be null"); |
59 | 585 | return String.format("%s:%s", getKeyPrefix(), groupId); | ... | ... |