liujie
2026-06-09 c96fbe6b0aeb413a17c429133ee6d81d138144b9
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
package com.xiaopeng.map.event;
 
import com.xiaopeng.map.service.AdcFencePushService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
 
/**
 * 围栏变更事件监听器。
 * 同步处理 ADC 推送,推送失败时异常会向上抛出,调用方可感知。
 */
@Slf4j
@Component
public class FenceChangeEventListener {
 
    @Autowired
    private AdcFencePushService adcFencePushService;
 
    @EventListener
    public void onFenceChanged(FenceChangedEvent event) {
        Long electronicId = event.getElectronicId();
        Integer status = event.getStatus();
        log.info("[ADC推送] 收到围栏变更事件, electronicId={}, status={}", electronicId, status);
 
        if (status == 2) {
            // 启用中 → 推送最新 FBS 到绑定车辆
            adcFencePushService.pushFenceToVehicles(electronicId);
        } else if (status == 0 || status == 3) {
            // 草稿/已停用 → 上传范围框占位FBS标记围栏失效
            adcFencePushService.deactivateFenceForVehicles(electronicId);
        }
        // status=1 待启用 → 不推送,等定时任务触发
    }
}