CustomEventListener.java
3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package cn.fw.valhalla.service.bus.listener;
import cn.fw.valhalla.domain.db.follow.ClueTask;
import cn.fw.valhalla.domain.enums.FollowTypeEnum;
import cn.fw.valhalla.domain.vo.setting.SettingVO;
import cn.fw.valhalla.service.bus.follow.FollowBizService;
import cn.fw.valhalla.service.bus.follow.strategy.impl.PubFollowStrategy;
import cn.fw.valhalla.service.bus.setting.SettingBizService;
import cn.fw.valhalla.service.event.PublicPoolEvent;
import cn.fw.valhalla.service.event.SettingChangeEvent;
import cn.fw.valhalla.service.event.StopTaskEvent;
import cn.fw.valhalla.service.event.TaskCancelEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
/**
* @author : kurisu
* @className : CustomEventListener
* @description : 事件监听器
* @date: 2020-08-18 16:28
*/
@Component
@Slf4j
public class CustomEventListener {
private final SettingBizService settingBizService;
private final FollowBizService followBizService;
private final PubFollowStrategy pubFollowStrategy;
@Autowired
public CustomEventListener(final SettingBizService settingBizService,
final FollowBizService followBizService,
final PubFollowStrategy pubFollowStrategy) {
this.settingBizService = settingBizService;
this.followBizService = followBizService;
this.pubFollowStrategy = pubFollowStrategy;
}
/**
* 监听跟进任务取消事件
*
* @param event
*/
@EventListener(TaskCancelEvent.class)
public void onDataCancel(final TaskCancelEvent event) {
followBizService.onDataCancel(event);
}
/**
* 当设置发生改变时
*
* @param event
*/
@EventListener(SettingChangeEvent.class)
public void onSettingChange(final SettingChangeEvent event) {
final FollowTypeEnum type = event.getType();
if (Objects.isNull(type) || FollowTypeEnum.OT.equals(type)) {
return;
}
Optional<List<SettingVO>> listOptional = Optional.ofNullable(settingBizService.querySettingByCat(type.getValue(), event.getGroupId(), event.getBrandId()));
listOptional.ifPresent(settingList -> followBizService.synFollowTask(settingList, type, event.getGroupId()));
}
/**
* 档案进入公共池
*
* @param event
*/
@EventListener(PublicPoolEvent.class)
public void stopTaskAndAddPublic(final PublicPoolEvent event) {
String vin = event.getVin();
Long groupId = event.getGroupId();
boolean fromTask = event.isFromTask();
followBizService.stopClue(vin, groupId, fromTask);
pubFollowStrategy.clueConvertFailedFromFlow(vin, groupId);
}
/**
* 审批终止 续保/事故车 任务
*
* @param event
*/
@EventListener(StopTaskEvent.class)
public void stopTask(final StopTaskEvent event) {
ClueTask task = event.getTask();
followBizService.stopTask(task);
}
}