Commit 9c86aa21233acfcba2c6340572e1e90ccfad0ffc
1 parent
03d7ac84
feature(*): 线索到期后mq通知
- 线索到期后mq通知
Showing
9 changed files
with
132 additions
and
24 deletions
fw-valhalla-sdk/pom.xml
fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/enums/CustomerFollowTypeEnum.java
... | ... | @@ -12,6 +12,10 @@ import lombok.Getter; |
12 | 12 | */ |
13 | 13 | public enum CustomerFollowTypeEnum { |
14 | 14 | /** |
15 | + * 首保 | |
16 | + */ | |
17 | + FM(1, "首保"), | |
18 | + /** | |
15 | 19 | * 例保 |
16 | 20 | */ |
17 | 21 | RM(2, "流失客户"), |
... | ... | @@ -19,6 +23,10 @@ public enum CustomerFollowTypeEnum { |
19 | 23 | * 续保 |
20 | 24 | */ |
21 | 25 | IR(4, "续保"), |
26 | + /** | |
27 | + * 公共池专属线索 | |
28 | + */ | |
29 | + PL(10, "公共池专属线索"), | |
22 | 30 | ; |
23 | 31 | |
24 | 32 | /** | ... | ... |
fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/result/ClueChangeResult.java
... | ... | @@ -61,6 +61,22 @@ public class ClueChangeResult { |
61 | 61 | |
62 | 62 | public enum ChangeType { |
63 | 63 | ADD, |
64 | - STOP | |
64 | + STOP, | |
65 | + /** | |
66 | + * 主动放弃 | |
67 | + */ | |
68 | + ABANDON, | |
69 | + /** | |
70 | + * 成交 | |
71 | + */ | |
72 | + COMPLETE, | |
73 | + /** | |
74 | + * 他人成交 | |
75 | + */ | |
76 | + OTHER_COMPLETE, | |
77 | + /** | |
78 | + * 角色变动 | |
79 | + */ | |
80 | + ROLE_CHANGE | |
65 | 81 | } |
66 | 82 | } | ... | ... |
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/ClueChangeNoticeTask.java
... | ... | @@ -2,11 +2,17 @@ package cn.fw.valhalla.controller.task; |
2 | 2 | |
3 | 3 | import cn.fw.valhalla.component.producer.ClueChangeProducer; |
4 | 4 | import cn.fw.valhalla.component.producer.RenewalSwitchProducer; |
5 | +import cn.fw.valhalla.domain.db.follow.ClueTask; | |
5 | 6 | import cn.fw.valhalla.domain.db.follow.FollowClue; |
7 | +import cn.fw.valhalla.domain.db.pub.PubCluePool; | |
6 | 8 | import cn.fw.valhalla.domain.enums.FollowTypeEnum; |
9 | +import cn.fw.valhalla.domain.enums.TaskDefeatTypeEnum; | |
10 | +import cn.fw.valhalla.domain.enums.TaskStateEnum; | |
7 | 11 | import cn.fw.valhalla.sdk.enums.CustomerFollowTypeEnum; |
8 | 12 | import cn.fw.valhalla.sdk.result.ClueChangeResult; |
13 | +import cn.fw.valhalla.service.data.ClueTaskService; | |
9 | 14 | import cn.fw.valhalla.service.data.FollowClueService; |
15 | +import cn.fw.valhalla.service.data.PubCluePoolService; | |
10 | 16 | import lombok.Getter; |
11 | 17 | import lombok.extern.slf4j.Slf4j; |
12 | 18 | import org.springframework.beans.factory.annotation.Autowired; |
... | ... | @@ -37,7 +43,9 @@ import java.util.Objects; |
37 | 43 | public class ClueChangeNoticeTask { |
38 | 44 | private final ClueChangeProducer clueChangeProducer; |
39 | 45 | private final RenewalSwitchProducer renewalSwitchProducer; |
46 | + private final ClueTaskService clueTaskService; | |
40 | 47 | private final FollowClueService followClueService; |
48 | + private final PubCluePoolService pubCluePoolService; | |
41 | 49 | private final StringRedisTemplate redisTemplate; |
42 | 50 | @Value("${spring.cache.custom.global-prefix}:follow:clue:change") |
43 | 51 | @Getter |
... | ... | @@ -46,11 +54,15 @@ public class ClueChangeNoticeTask { |
46 | 54 | @Autowired |
47 | 55 | public ClueChangeNoticeTask(final ClueChangeProducer clueChangeProducer, |
48 | 56 | final RenewalSwitchProducer renewalSwitchProducer, |
57 | + final ClueTaskService clueTaskService, | |
49 | 58 | final FollowClueService followClueService, |
59 | + final PubCluePoolService pubCluePoolService, | |
50 | 60 | final StringRedisTemplate redisTemplate) { |
51 | 61 | this.clueChangeProducer = clueChangeProducer; |
52 | 62 | this.renewalSwitchProducer = renewalSwitchProducer; |
63 | + this.clueTaskService = clueTaskService; | |
53 | 64 | this.followClueService = followClueService; |
65 | + this.pubCluePoolService = pubCluePoolService; | |
54 | 66 | this.redisTemplate = redisTemplate; |
55 | 67 | } |
56 | 68 | |
... | ... | @@ -61,21 +73,16 @@ public class ClueChangeNoticeTask { |
61 | 73 | String pop; |
62 | 74 | while ((pop = operations.pop()) != null) { |
63 | 75 | try { |
64 | - final Long clueId = Long.valueOf(pop); | |
65 | - FollowClue clue = followClueService.getById(clueId); | |
66 | - if (Objects.nonNull(clue)) { | |
67 | - ClueChangeResult result = new ClueChangeResult(); | |
68 | - result.setFrameNo(clue.getVin()); | |
69 | - result.setGroupId(clue.getGroupId()); | |
70 | - result.setChangeType(ClueChangeResult.ChangeType.STOP); | |
71 | - if (FollowTypeEnum.RM.equals(clue.getClueType())) { | |
72 | - result.setClueType(CustomerFollowTypeEnum.RM.getValue()); | |
73 | - } else if (FollowTypeEnum.IR.equals(clue.getClueType())) { | |
74 | - result.setClueType(CustomerFollowTypeEnum.IR.getValue()); | |
75 | - renewalSwitchProducer.send(clue.getVin(), clue.getEndTime().toLocalDate(), clue.getGroupId()); | |
76 | - } | |
77 | - clueChangeProducer.send(result); | |
76 | + final Long taskId = Long.valueOf(pop); | |
77 | + ClueTask task = clueTaskService.getById(taskId); | |
78 | + if (Objects.isNull(task)) { | |
79 | + continue; | |
78 | 80 | } |
81 | + if (FollowTypeEnum.PL.equals(task.getType())) { | |
82 | + sendPubMQ(task); | |
83 | + return; | |
84 | + } | |
85 | + sendNormalMQ(task); | |
79 | 86 | } catch (Exception ex) { |
80 | 87 | failList.add(pop); |
81 | 88 | log.error(ex.getMessage(), ex); |
... | ... | @@ -86,6 +93,64 @@ public class ClueChangeNoticeTask { |
86 | 93 | } |
87 | 94 | } |
88 | 95 | |
96 | + private void sendNormalMQ(ClueTask task) { | |
97 | + FollowClue clue = followClueService.getById(task.getClueId()); | |
98 | + if (Objects.isNull(clue)) { | |
99 | + return; | |
100 | + } | |
101 | + ClueChangeResult result = new ClueChangeResult(); | |
102 | + result.setFrameNo(clue.getVin()); | |
103 | + result.setGroupId(clue.getGroupId()); | |
104 | + TaskDefeatTypeEnum reason = task.getReason(); | |
105 | + | |
106 | + if (FollowTypeEnum.RM.equals(clue.getClueType())) { | |
107 | + result.setClueType(CustomerFollowTypeEnum.RM.getValue()); | |
108 | + } else if (FollowTypeEnum.IR.equals(clue.getClueType())) { | |
109 | + result.setClueType(CustomerFollowTypeEnum.IR.getValue()); | |
110 | + renewalSwitchProducer.send(clue.getVin(), clue.getEndTime().toLocalDate(), clue.getGroupId()); | |
111 | + } else if (FollowTypeEnum.FM.equals(clue.getClueType())) { | |
112 | + result.setClueType(CustomerFollowTypeEnum.FM.getValue()); | |
113 | + } | |
114 | + | |
115 | + if (TaskStateEnum.COMPLETE.equals(task.getState())) { | |
116 | + result.setChangeType(ClueChangeResult.ChangeType.COMPLETE); | |
117 | + } else { | |
118 | + processChangeType(reason, result); | |
119 | + } | |
120 | + | |
121 | + clueChangeProducer.send(result); | |
122 | + } | |
123 | + | |
124 | + private void sendPubMQ(ClueTask task) { | |
125 | + PubCluePool clue = pubCluePoolService.getById(task.getClueId()); | |
126 | + ClueChangeResult result = new ClueChangeResult(); | |
127 | + result.setFrameNo(clue.getVin()); | |
128 | + result.setGroupId(clue.getGroupId()); | |
129 | + TaskDefeatTypeEnum reason = task.getReason(); | |
130 | + result.setClueType(CustomerFollowTypeEnum.PL.getValue()); | |
131 | + if (TaskStateEnum.COMPLETE.equals(task.getState())) { | |
132 | + result.setChangeType(ClueChangeResult.ChangeType.COMPLETE); | |
133 | + } else { | |
134 | + processChangeType(reason, result); | |
135 | + } | |
136 | + clueChangeProducer.send(result); | |
137 | + } | |
138 | + | |
139 | + private void processChangeType(TaskDefeatTypeEnum reason, ClueChangeResult result) { | |
140 | + if (TaskDefeatTypeEnum.A.equals(reason)) { | |
141 | + result.setChangeType(ClueChangeResult.ChangeType.ABANDON); | |
142 | + } | |
143 | + if (TaskDefeatTypeEnum.F.equals(reason)) { | |
144 | + result.setChangeType(ClueChangeResult.ChangeType.OTHER_COMPLETE); | |
145 | + } | |
146 | + if (TaskDefeatTypeEnum.D.equals(reason)) { | |
147 | + result.setChangeType(ClueChangeResult.ChangeType.ROLE_CHANGE); | |
148 | + } | |
149 | + if (TaskDefeatTypeEnum.C.equals(reason)) { | |
150 | + result.setChangeType(ClueChangeResult.ChangeType.STOP); | |
151 | + } | |
152 | + } | |
153 | + | |
89 | 154 | private String generateStopKey() { |
90 | 155 | return String.format("%s:%s", getClueChangeKeyPrefix(), "STOP"); |
91 | 156 | } | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/component/producer/RenewalSwitchProducer.kt
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/AbstractFollowStrategy.java
... | ... | @@ -203,7 +203,7 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { |
203 | 203 | clue.setCloseTime(task.getCloseTime()); |
204 | 204 | clue.setClueState(ClueStatusEnum.FAILURE); |
205 | 205 | followClueService.updateById(clue); |
206 | - redisTemplate.opsForSet().add(generateStopKey(), String.valueOf(clueId)); | |
206 | + redisTemplate.opsForSet().add(generateStopKey(), String.valueOf(task.getId())); | |
207 | 207 | customerBizService.taskEndAbandon(task, clue); |
208 | 208 | } |
209 | 209 | } |
... | ... | @@ -249,7 +249,7 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { |
249 | 249 | clue.setClueState(ClueStatusEnum.FAILURE); |
250 | 250 | followClueService.updateById(clue); |
251 | 251 | |
252 | - redisTemplate.opsForSet().add(generateStopKey(), String.valueOf(clueId)); | |
252 | + redisTemplate.opsForSet().add(generateStopKey(), String.valueOf(task.getId())); | |
253 | 253 | } else { |
254 | 254 | task.setRpcSuccess(true); |
255 | 255 | clueTaskService.updateById(task); |
... | ... | @@ -295,7 +295,7 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { |
295 | 295 | clue.setClueState(ClueStatusEnum.FAILURE); |
296 | 296 | clue.setCloseTime(LocalDateTime.now()); |
297 | 297 | followClueService.updateById(clue); |
298 | - redisTemplate.opsForSet().add(generateStopKey(), String.valueOf(clueId)); | |
298 | + redisTemplate.opsForSet().add(generateStopKey(), String.valueOf(task.getId())); | |
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
... | ... | @@ -439,6 +439,7 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { |
439 | 439 | clueTask.setFinishShop(originalData.getShopId()); |
440 | 440 | followClue.setCloseTime(clueTask.getCloseTime()); |
441 | 441 | followClueService.updateById(followClue); |
442 | + redisTemplate.opsForSet().add(generateStopKey(), String.valueOf(clueTask.getId())); | |
442 | 443 | boolean rpcSucess = rpcStopTask(clueTask); |
443 | 444 | clueTask.setRpcSuccess(rpcSucess); |
444 | 445 | clueTaskService.updateById(clueTask); | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/IRFollowStrategy.java
... | ... | @@ -149,7 +149,7 @@ public class IRFollowStrategy extends AbstractFollowStrategy { |
149 | 149 | clue.setClueState(ClueStatusEnum.FAILURE); |
150 | 150 | clue.setCloseTime(task.getCloseTime()); |
151 | 151 | followClueService.updateById(clue); |
152 | - redisTemplate.opsForSet().add(generateStopKey(), String.valueOf(clueId)); | |
152 | + redisTemplate.opsForSet().add(generateStopKey(), String.valueOf(task.getId())); | |
153 | 153 | afterStopClue(clue); |
154 | 154 | } |
155 | 155 | clueTaskService.updateById(task); |
... | ... | @@ -221,7 +221,7 @@ public class IRFollowStrategy extends AbstractFollowStrategy { |
221 | 221 | clue.setCloseTime(LocalDateTime.now()); |
222 | 222 | followClueService.updateById(clue); |
223 | 223 | afterStopClue(clue); |
224 | - redisTemplate.opsForSet().add(generateStopKey(), String.valueOf(clueId)); | |
224 | + redisTemplate.opsForSet().add(generateStopKey(), String.valueOf(task.getId())); | |
225 | 225 | } |
226 | 226 | Optional<SettingVO> settingVO = settingBizService.querySettingByType(getFollowType(), SettingTypeEnum.MODE, clue.getGroupId(), COMMON_BRAND_ID); |
227 | 227 | // 模式 1、续保角色 2、续保角色+服务接待/新车销售 | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/PubFollowStrategy.java
... | ... | @@ -24,8 +24,11 @@ import cn.fw.valhalla.service.bus.setting.SettingBizService; |
24 | 24 | import cn.fw.valhalla.service.data.ClueTaskService; |
25 | 25 | import cn.fw.valhalla.service.data.PubCluePoolService; |
26 | 26 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
27 | +import lombok.Getter; | |
27 | 28 | import lombok.extern.slf4j.Slf4j; |
28 | 29 | import org.springframework.beans.factory.annotation.Autowired; |
30 | +import org.springframework.beans.factory.annotation.Value; | |
31 | +import org.springframework.data.redis.core.StringRedisTemplate; | |
29 | 32 | import org.springframework.stereotype.Component; |
30 | 33 | import org.springframework.transaction.annotation.Transactional; |
31 | 34 | |
... | ... | @@ -55,6 +58,11 @@ public class PubFollowStrategy implements FollowStrategy { |
55 | 58 | private final OopService oopService; |
56 | 59 | private final SettingBizService settingBizService; |
57 | 60 | private final EhrRpcService ehrRpcService; |
61 | + private final StringRedisTemplate redisTemplate; | |
62 | + | |
63 | + @Value("${spring.cache.custom.global-prefix}:follow:clue:change:STOP") | |
64 | + @Getter | |
65 | + private String clueChangeKey; | |
58 | 66 | |
59 | 67 | @Autowired |
60 | 68 | public PubFollowStrategy(final PubCluePoolService pubCluePoolService, |
... | ... | @@ -63,7 +71,8 @@ public class PubFollowStrategy implements FollowStrategy { |
63 | 71 | final ShirasawaRpcService shirasawaRpcService, |
64 | 72 | final OopService oopService, |
65 | 73 | final SettingBizService settingBizService, |
66 | - final EhrRpcService ehrRpcService) { | |
74 | + final EhrRpcService ehrRpcService, | |
75 | + final StringRedisTemplate redisTemplate) { | |
67 | 76 | this.pubCluePoolService = pubCluePoolService; |
68 | 77 | this.clueTaskService = clueTaskService; |
69 | 78 | this.customerBizService = customerBizService; |
... | ... | @@ -71,6 +80,7 @@ public class PubFollowStrategy implements FollowStrategy { |
71 | 80 | this.oopService = oopService; |
72 | 81 | this.settingBizService = settingBizService; |
73 | 82 | this.ehrRpcService = ehrRpcService; |
83 | + this.redisTemplate = redisTemplate; | |
74 | 84 | } |
75 | 85 | |
76 | 86 | @Override |
... | ... | @@ -148,6 +158,8 @@ public class PubFollowStrategy implements FollowStrategy { |
148 | 158 | boolean rpcSucess = rpcStopTask(clueTask); |
149 | 159 | clueTask.setRpcSuccess(rpcSucess); |
150 | 160 | clueTaskService.updateById(clueTask); |
161 | + | |
162 | + redisTemplate.opsForSet().add(getClueChangeKey(), String.valueOf(clueTask.getId())); | |
151 | 163 | } |
152 | 164 | pubCluePoolService.updateById(pubClue); |
153 | 165 | } |
... | ... | @@ -172,6 +184,8 @@ public class PubFollowStrategy implements FollowStrategy { |
172 | 184 | boolean rpcSucess = rpcStopTask(clueTask); |
173 | 185 | clueTask.setRpcSuccess(rpcSucess); |
174 | 186 | clueTaskService.updateById(clueTask); |
187 | + | |
188 | + redisTemplate.opsForSet().add(getClueChangeKey(), String.valueOf(clueTask.getId())); | |
175 | 189 | } |
176 | 190 | pubCluePoolService.updateById(pubClue); |
177 | 191 | } |
... | ... | @@ -201,6 +215,8 @@ public class PubFollowStrategy implements FollowStrategy { |
201 | 215 | boolean rpcSucess = rpcStopTask(clueTask); |
202 | 216 | clueTask.setRpcSuccess(rpcSucess); |
203 | 217 | clueTaskService.updateById(clueTask); |
218 | + | |
219 | + redisTemplate.opsForSet().add(getClueChangeKey(), String.valueOf(clueTask.getId())); | |
204 | 220 | } |
205 | 221 | if (PublicClueStateEnum.ONGOING.equals(cluePool.getState())) { |
206 | 222 | cluePool.setState(PublicClueStateEnum.DEFEAT); |
... | ... | @@ -223,6 +239,7 @@ public class PubFollowStrategy implements FollowStrategy { |
223 | 239 | } |
224 | 240 | task.setRpcSuccess(rpcSucess); |
225 | 241 | clueTaskService.updateById(task); |
242 | + redisTemplate.opsForSet().add(getClueChangeKey(), String.valueOf(task.getId())); | |
226 | 243 | } |
227 | 244 | |
228 | 245 | @Override |
... | ... | @@ -276,6 +293,7 @@ public class PubFollowStrategy implements FollowStrategy { |
276 | 293 | pubCluePool.setDefeatReason(task.getReason()); |
277 | 294 | pubCluePoolService.updateById(pubCluePool); |
278 | 295 | customerBizService.pubTaskEndAbandon(pubCluePool); |
296 | + redisTemplate.opsForSet().add(getClueChangeKey(), String.valueOf(task.getId())); | |
279 | 297 | } |
280 | 298 | |
281 | 299 | private boolean rpcStopTask(ClueTask clueTask) { | ... | ... |
pom.xml