陈昶聿
2 天以前 d9281d43e27ab6c510d390ddb26eaffc8ccc1add
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
package com.ruoyi.task.event;
 
import com.ruoyi.common.core.event.FollowupCompletedEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
 
import java.util.Date;
 
/**
 * 随访完成事件发布器。
 *
 * <p>任务模块在子任务状态更新为已完成(sendstate=6)后发布事件,
 * 档案等下游模块通过 {@code @TransactionalEventListener} 异步消费。</p>
 *
 * @author ruoyi
 * @date 2026-11-11
 */
@Slf4j
@Component
public class FollowupCompletedEventPublisher {
 
    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;
 
    public void publish(Long subId) {
        if (subId == null) {
            return;
        }
        try {
            applicationEventPublisher.publishEvent(new FollowupCompletedEvent(subId, new Date()));
        } catch (Exception e) {
            log.error("发布随访完成事件失败,subId={}", subId, e);
        }
    }
}