Commit d6c5c38088618cb6e9649a9171eb066c18f81d5e
1 parent
e237bcd9
feature(*): 分配档案后发送mq
- 分配档案后发送mq
Showing
6 changed files
with
107 additions
and
3 deletions
fw-valhalla-sdk/pom.xml
fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/result/CustomerDistributedMQ.java
0 → 100644
1 | +package cn.fw.valhalla.sdk.result; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Data; | |
5 | +import lombok.NoArgsConstructor; | |
6 | +import org.springframework.lang.Nullable; | |
7 | + | |
8 | +import java.util.ArrayDeque; | |
9 | +import java.util.Date; | |
10 | + | |
11 | +/** | |
12 | + * 档案分配后的mq通知 | |
13 | + * | |
14 | + * @author : kurisu | |
15 | + * @version : 1.0 | |
16 | + * @className : CustomerDistributedMQ | |
17 | + * @description : 档案分配后的mq通知 | |
18 | + * @date : 2023-03-15 15:39 | |
19 | + */ | |
20 | +@Data | |
21 | +@AllArgsConstructor | |
22 | +@NoArgsConstructor | |
23 | +public class CustomerDistributedMQ { | |
24 | + public final static String TOPIC = "valhalla_customer_distribute"; | |
25 | + /** | |
26 | + * 被分配的服务顾问id | |
27 | + */ | |
28 | + private ArrayDeque<Long> staffIds; | |
29 | + /** | |
30 | + * 分配时间 | |
31 | + */ | |
32 | + private Date distributeTime; | |
33 | + /** | |
34 | + * 离职分配 | |
35 | + * <p>为false的时候为管理者主动分配</p> | |
36 | + */ | |
37 | + private boolean resign; | |
38 | + | |
39 | + /** | |
40 | + * 获取第一个staff | |
41 | + * | |
42 | + * @return | |
43 | + */ | |
44 | + @Nullable | |
45 | + public Long getStaffId() { | |
46 | + return staffIds.pollFirst(); | |
47 | + } | |
48 | + | |
49 | + /** | |
50 | + * 获取最后一个staff | |
51 | + * | |
52 | + * @return | |
53 | + */ | |
54 | + @Nullable | |
55 | + public Long getLastStaffId() { | |
56 | + return staffIds.pollFirst(); | |
57 | + } | |
58 | + | |
59 | +} | ... | ... |
fw-valhalla-server/src/main/resources/application.yml
fw-valhalla-service/src/main/java/cn/fw/valhalla/component/CustAfterDistProducer.kt
0 → 100644
1 | +package cn.fw.valhalla.component | |
2 | + | |
3 | +import cn.fw.valhalla.sdk.result.CustomerDistributedMQ | |
4 | +import org.apache.rocketmq.spring.core.RocketMQTemplate | |
5 | +import org.slf4j.Logger | |
6 | +import org.slf4j.LoggerFactory | |
7 | +import org.springframework.stereotype.Component | |
8 | +import org.springframework.web.bind.annotation.RequestMapping | |
9 | +import java.util.* | |
10 | + | |
11 | +/** | |
12 | + * 保有客分配后的mq生产者 | |
13 | + * | |
14 | + * @author : kurisu | |
15 | + * @version : 1.0 | |
16 | + * @className : CustAfterDistProducer | |
17 | + * @description : 保有客分配后的mq生产者 | |
18 | + * @date : 2023-03-15 15:37 | |
19 | + */ | |
20 | +@Component | |
21 | +class CustAfterDistProducer(private val rocketMQTemplate: RocketMQTemplate) { | |
22 | + private val log: Logger = LoggerFactory.getLogger(CustAfterDistProducer::class.java) | |
23 | + | |
24 | + @RequestMapping(value = ["send"]) | |
25 | + fun send(resign: Boolean, staffIds: List<Long>?) { | |
26 | + log.info("发送保有客分配结束mq消息。staffIds:{}", staffIds) | |
27 | + try { | |
28 | + when { | |
29 | + staffIds.isNullOrEmpty() -> return | |
30 | + else -> { | |
31 | + val distributedMQ = CustomerDistributedMQ(ArrayDeque(staffIds), Date(), resign) | |
32 | + rocketMQTemplate.syncSend(CustomerDistributedMQ.TOPIC + ":*", distributedMQ) | |
33 | + } | |
34 | + } | |
35 | + } catch (e: Exception) { | |
36 | + log.info("发送保有客分配结束mq消息失败!", e) | |
37 | + } | |
38 | + } | |
39 | +} | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/LeaveNeedDoBizService.java
... | ... | @@ -9,6 +9,7 @@ import cn.fw.hermes.sdk.api.ImSendMessage; |
9 | 9 | import cn.fw.hermes.sdk.api.para.MsgParamCondition; |
10 | 10 | import cn.fw.valhalla.common.constant.RoleCode; |
11 | 11 | import cn.fw.valhalla.common.utils.DateUtil; |
12 | +import cn.fw.valhalla.component.CustAfterDistProducer; | |
12 | 13 | import cn.fw.valhalla.domain.db.LeaveNeedDo; |
13 | 14 | import cn.fw.valhalla.domain.db.customer.Customer; |
14 | 15 | import cn.fw.valhalla.domain.db.follow.ClueTask; |
... | ... | @@ -73,6 +74,7 @@ public class LeaveNeedDoBizService { |
73 | 74 | private final StammkundePoolService stammkundePoolService; |
74 | 75 | private final FollowClueService followClueService; |
75 | 76 | private final ClueTaskService clueTaskService; |
77 | + private final CustAfterDistProducer custAfterDistProducer; | |
76 | 78 | |
77 | 79 | /** |
78 | 80 | * Redis工具 |
... | ... | @@ -170,6 +172,7 @@ public class LeaveNeedDoBizService { |
170 | 172 | doAllocation(dto, key); |
171 | 173 | //完成分配发送消息提醒等 |
172 | 174 | finish(user, dto.getId(), key); |
175 | + custAfterDistProducer.send(Boolean.TRUE, Collections.singletonList(dto.getAdviserId())); | |
173 | 176 | } finally { |
174 | 177 | clearKey(key); |
175 | 178 | } |
... | ... | @@ -277,6 +280,9 @@ public class LeaveNeedDoBizService { |
277 | 280 | return; |
278 | 281 | } |
279 | 282 | try { |
283 | + List<Long> longList = dto.getBeAssignedList().stream().map(DistributableDTO.BeAssignedDTO::getUserId).collect(Collectors.toList()); | |
284 | + custAfterDistProducer.send(Boolean.FALSE, longList); | |
285 | + | |
280 | 286 | String text = String.format("%s通过资源分配给你%s台保有客", user.getUserName(), size); |
281 | 287 | final MsgParamCondition msgPara = MsgParamCondition.getOfflineTxetPara(text, null, "保有客分配", |
282 | 288 | "保有客分配", null, dto.getAdviserId()).build(); | ... | ... |
pom.xml