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 待启用 → 不推送,等定时任务触发
|
}
|
}
|