Showing
8 changed files
with
154 additions
and
0 deletions
1 | +package com.yohoufo.order.service.stat; | ||
2 | + | ||
3 | +/** | ||
4 | + * Created by jiexiang.wu on 2019/7/19. | ||
5 | + */ | ||
6 | +public interface StatsConfigManager<T extends StatsEntry> { | ||
7 | + | ||
8 | + StatsProcessorRegistry getRegistry(); | ||
9 | + | ||
10 | + /** | ||
11 | + * 获取统计器 | ||
12 | + * | ||
13 | + * @param statsEntry | ||
14 | + * @return | ||
15 | + */ | ||
16 | + StatsProcessor getStatsProcessor(T statsEntry); | ||
17 | +} |
1 | +package com.yohoufo.order.service.stat; | ||
2 | + | ||
3 | +import java.util.function.Consumer; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by jiexiang.wu on 2019/7/19. | ||
7 | + * 统计处理器 | ||
8 | + */ | ||
9 | +public interface StatsProcessor<T extends StatsEntry> extends Consumer<T> { | ||
10 | + | ||
11 | + /** | ||
12 | + * 名称 | ||
13 | + * 必须保证唯一,建议使用类名 | ||
14 | + * | ||
15 | + * @return | ||
16 | + */ | ||
17 | + String getName(); | ||
18 | + | ||
19 | + | ||
20 | + @Override | ||
21 | + void accept(T entry); | ||
22 | +} |
1 | +package com.yohoufo.order.service.stat; | ||
2 | + | ||
3 | +import java.util.HashMap; | ||
4 | +import java.util.Map; | ||
5 | + | ||
6 | +/** | ||
7 | + * Created by jiexiang.wu on 2019/7/19. | ||
8 | + * 统计器注册容器 | ||
9 | + */ | ||
10 | +public class StatsProcessorRegistry { | ||
11 | + | ||
12 | + private final Map<String, StatsProcessor> statisticsMap = new HashMap<String, StatsProcessor>(); | ||
13 | + | ||
14 | + public StatsProcessor getStatsProcessor(String name) { | ||
15 | + return statisticsMap.get(name); | ||
16 | + } | ||
17 | +} |
1 | +package com.yohoufo.order.service.stat.impl; | ||
2 | + | ||
3 | +import com.yohoufo.order.service.stat.StatsProcessor; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by jiexiang.wu on 2019/7/19. | ||
7 | + * 卖家订单数量汇总统计 | ||
8 | + */ | ||
9 | +public class SellerOrderQuantitySummaryStatsProcessor implements StatsProcessor<SellerOrderStatsEntry> { | ||
10 | + | ||
11 | + @Override | ||
12 | + public String getName() { | ||
13 | + return "sellerOrderQuantitySummaryStatsProcessor"; | ||
14 | + } | ||
15 | + | ||
16 | + @Override | ||
17 | + public void accept(SellerOrderStatsEntry entry) { | ||
18 | + | ||
19 | + } | ||
20 | +} |
1 | +package com.yohoufo.order.service.stat.impl; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.common.OrderAttributes; | ||
4 | +import lombok.*; | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | + | ||
8 | +/** | ||
9 | + * Created by jiexiang.wu on 2019/7/19. | ||
10 | + */ | ||
11 | +@Data | ||
12 | +@Builder | ||
13 | +@AllArgsConstructor | ||
14 | +@NoArgsConstructor | ||
15 | +@ToString | ||
16 | +public class SellerOrderStatConfig { | ||
17 | + private String statsCode; | ||
18 | + //排除的uid | ||
19 | + private List<Integer> excludeUids; | ||
20 | + //属性 | ||
21 | + private List<OrderAttributes> orderAttributes; | ||
22 | + private String statsUnit; | ||
23 | + private int statsPeriod; | ||
24 | + private String statsProcessor; | ||
25 | +} |
order/src/main/java/com/yohoufo/order/service/stat/impl/SellerOrderStatConfigurationManager.java
0 → 100644
1 | +package com.yohoufo.order.service.stat.impl; | ||
2 | + | ||
3 | +import com.yohoufo.order.service.stat.StatsConfigManager; | ||
4 | +import com.yohoufo.order.service.stat.StatsProcessor; | ||
5 | +import com.yohoufo.order.service.stat.StatsProcessorRegistry; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by jiexiang.wu on 2019/7/19. | ||
9 | + * 卖家订单统计配置管理 | ||
10 | + */ | ||
11 | +public class SellerOrderStatConfigurationManager implements StatsConfigManager<SellerOrderStatsEntry> { | ||
12 | + | ||
13 | + private StatsProcessorRegistry registry = new StatsProcessorRegistry(); | ||
14 | + | ||
15 | + @Override | ||
16 | + public StatsProcessor getStatsProcessor(SellerOrderStatsEntry statsEntry) { | ||
17 | + return null; | ||
18 | + } | ||
19 | + | ||
20 | + @Override | ||
21 | + public StatsProcessorRegistry getRegistry() { | ||
22 | + return registry; | ||
23 | + } | ||
24 | +} |
1 | +package com.yohoufo.order.service.stat.impl; | ||
2 | + | ||
3 | + | ||
4 | +import com.yohobuy.ufo.model.order.common.OrderAttributes; | ||
5 | +import com.yohoufo.order.service.stat.StatsEntry; | ||
6 | +import lombok.*; | ||
7 | + | ||
8 | +/** | ||
9 | + * Created by jiexiang.wu on 2019/7/19. | ||
10 | + */ | ||
11 | +@Data | ||
12 | +@Builder | ||
13 | +@ToString | ||
14 | +@AllArgsConstructor | ||
15 | +@NoArgsConstructor | ||
16 | +public class SellerOrderStatsEntry implements StatsEntry { | ||
17 | + private int sellerUid; | ||
18 | + private int buyerUid; | ||
19 | + private long buyerOrderCode; | ||
20 | + private OrderAttributes orderAttribute; | ||
21 | +} |
-
Please register or login to post a comment