Commit c3b33c0a020b954a928d4902efede18729229a7a
1 parent
eef76d3f
feature(*): 准备公共池报表数据
- 准备公共池报表数据
Showing
5 changed files
with
98 additions
and
8 deletions
doc/public_report/sql.sql
0 → 100644
1 | +create table public_report_data | |
2 | +( | |
3 | + id bigint auto_increment, | |
4 | + data_date date not null, | |
5 | + user_id bigint not null comment '用户id', | |
6 | + user_name varchar(64) null comment '用户名称', | |
7 | + shop_id bigint not null comment '门店id', | |
8 | + shop_name varchar(256) null comment '门店名称', | |
9 | + month_initial int default 0 null comment '每月初始数', | |
10 | + day_increase int default 0 null comment '日新增', | |
11 | + month_increase int default 0 null comment '月新增', | |
12 | + current_quantity int default 0 null, | |
13 | + day_stand_quantity int default 0 null, | |
14 | + month_stand_quantity int default 0 null, | |
15 | + day_natural_quantity int default 0 null, | |
16 | + month_natural_quantity int default 0 null, | |
17 | + group_id bigint not null comment '集团id', | |
18 | + create_time datetime null comment '创建日期', | |
19 | + update_time datetime null comment '更新日期', | |
20 | + constraint public_report_data_pk | |
21 | + primary key (id) | |
22 | +) | |
23 | + comment '公共池报表数据'; | |
24 | + | |
25 | +create index public_report_data_shop_id_index | |
26 | + on public_report_data (shop_id); | |
27 | + | |
28 | +create index public_report_data_user_id_index | |
29 | + on public_report_data (user_id); | |
30 | + | |
31 | + | ... | ... |
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/CommonController.java
... | ... | @@ -9,10 +9,10 @@ import cn.fw.valhalla.common.utils.DateUtil; |
9 | 9 | import cn.fw.valhalla.domain.vo.PostUserVO; |
10 | 10 | import cn.fw.valhalla.service.bus.CommonService; |
11 | 11 | import cn.fw.valhalla.service.bus.CustomerImportBizService; |
12 | -import cn.fw.valhalla.service.bus.CustomerRetentionRatioBizService; | |
13 | 12 | import cn.fw.valhalla.service.bus.LeaveNeedDoBizService; |
14 | 13 | import cn.fw.valhalla.service.bus.follow.FollowBizService; |
15 | 14 | import cn.fw.valhalla.service.bus.pub.PubStandBizService; |
15 | +import cn.fw.valhalla.service.report.CustomerRetentionRatioBizService; | |
16 | 16 | import lombok.RequiredArgsConstructor; |
17 | 17 | import lombok.extern.slf4j.Slf4j; |
18 | 18 | import org.apache.commons.lang3.StringUtils; | ... | ... |
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/ReportPrepareTask.java
1 | 1 | package cn.fw.valhalla.controller.task; |
2 | 2 | |
3 | 3 | import cn.fw.valhalla.common.utils.DateUtil; |
4 | -import cn.fw.valhalla.common.utils.ThreadPoolUtil; | |
5 | -import cn.fw.valhalla.service.bus.CustomerRetentionRatioBizService; | |
4 | +import cn.fw.valhalla.rpc.oop.OopService; | |
5 | +import cn.fw.valhalla.rpc.oop.dto.GroupDTO; | |
6 | +import cn.fw.valhalla.service.report.CustomerRetentionRatioBizService; | |
7 | +import cn.fw.valhalla.service.report.PublicReportBizService; | |
6 | 8 | import lombok.RequiredArgsConstructor; |
7 | 9 | import lombok.extern.slf4j.Slf4j; |
8 | 10 | import org.springframework.scheduling.annotation.Scheduled; |
9 | 11 | import org.springframework.stereotype.Component; |
10 | -import org.springframework.transaction.annotation.Transactional; | |
11 | 12 | |
13 | +import java.time.LocalDate; | |
12 | 14 | import java.util.Date; |
13 | -import java.util.concurrent.CompletableFuture; | |
15 | +import java.util.List; | |
14 | 16 | |
15 | 17 | /** |
16 | 18 | * @author : kurisu |
... | ... | @@ -22,11 +24,33 @@ import java.util.concurrent.CompletableFuture; |
22 | 24 | @Component |
23 | 25 | @Slf4j |
24 | 26 | public class ReportPrepareTask { |
27 | + private final OopService oopService; | |
25 | 28 | private final CustomerRetentionRatioBizService retentionRatioBizService; |
29 | + private final PublicReportBizService publicReportBizService; | |
26 | 30 | |
31 | + /** | |
32 | + * 保持率进站率报表数据准备 | |
33 | + */ | |
27 | 34 | @Scheduled(cron = "0 0 0 ? * * ") |
28 | - @Transactional(rollbackFor = Exception.class) | |
29 | 35 | public void extractingData() { |
30 | - CompletableFuture.runAsync(() -> retentionRatioBizService.extracting(DateUtil.startDate(new Date())), ThreadPoolUtil.getInstance().getExecutor()); | |
36 | +// CompletableFuture.runAsync(() -> retentionRatioBizService.extracting(DateUtil.startDate(new Date())), ThreadPoolUtil.getInstance().getExecutor()); | |
37 | + retentionRatioBizService.extracting(DateUtil.startDate(new Date())); | |
38 | + } | |
39 | + | |
40 | + /** | |
41 | + * 公共池报表数据准备 | |
42 | + */ | |
43 | + @Scheduled(cron = "0 30 0 ? * * ") | |
44 | + public void extractingPublicData() { | |
45 | + final List<GroupDTO> groupList = oopService.allGroup(); | |
46 | + final LocalDate now = LocalDate.now(); | |
47 | + | |
48 | + for (GroupDTO group : groupList) { | |
49 | + try { | |
50 | + publicReportBizService.extracting(now, group.getId()); | |
51 | + } catch (Exception e) { | |
52 | + log.warn("准备公共池报表数据失败[groupId: {} data: {}]", group.getId(), now, e); | |
53 | + } | |
54 | + } | |
31 | 55 | } |
32 | 56 | } | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/CustomerRetentionRatioBizService.java renamed to fw-valhalla-service/src/main/java/cn/fw/valhalla/service/report/CustomerRetentionRatioBizService.java
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/report/PublicReportBizService.java
0 → 100644
1 | +package cn.fw.valhalla.service.report; | |
2 | + | |
3 | +import lombok.RequiredArgsConstructor; | |
4 | +import lombok.extern.slf4j.Slf4j; | |
5 | +import org.springframework.stereotype.Service; | |
6 | +import org.springframework.transaction.annotation.Transactional; | |
7 | + | |
8 | +import java.time.LocalDate; | |
9 | + | |
10 | +/** | |
11 | + * 公共池报表数据服务 | |
12 | + * | |
13 | + * @author : kurisu | |
14 | + * @version : 2.0 | |
15 | + * @className : PublicReportBizService | |
16 | + * @description : 公共池报表数据服务 | |
17 | + * @date : 2023-05-04 15:07 | |
18 | + */ | |
19 | +@Service | |
20 | +@Slf4j | |
21 | +@RequiredArgsConstructor | |
22 | +public class PublicReportBizService { | |
23 | + | |
24 | + /** | |
25 | + * 抽取集团公共池数据 | |
26 | + * | |
27 | + * @param nowDate 日期 | |
28 | + * @param groupId 集团id | |
29 | + */ | |
30 | + @Transactional(rollbackFor = Exception.class) | |
31 | + public void extracting(LocalDate nowDate, Long groupId) { | |
32 | + log.info("开始抽取公共池报表数据,日期:{} 集团:{}", nowDate, groupId); | |
33 | + // TODO: 2023/5/4 完成方法 | |
34 | + } | |
35 | +} | ... | ... |