修复高清地图(贴图)不支持手动滑动地理位置显示问题;修复地图显示上次设备位置的异常情况;修复打点保存少携带mode +orgid参数问题。
This commit is contained in:
@@ -52,6 +52,9 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
|
||||
// 🔥 当前监听的设备ID
|
||||
String? _currentDeviceId;
|
||||
|
||||
// 🔥 当前 MQTT 机器状态监听的设备 SN(用于换设备时清空旧缓存)
|
||||
String? _currentListeningSn;
|
||||
|
||||
// 🔥 MQTT机器状态收帧计数(用于链路日志)
|
||||
int _mqttVehicleFrameCount = 0;
|
||||
int _mqttLocationFrameCount = 0;
|
||||
@@ -222,6 +225,20 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
|
||||
|
||||
debugPrint('${LogTime.now()} 🚀 [DeviceStatusBloc] 启动MQTT机器状态监听: $deviceSn');
|
||||
|
||||
// 🔥 换设备兜底:SN 变化时清空上一个设备的缓存与状态,
|
||||
// 防止旧坐标通过 copyWith(base) 残留污染新设备数据(即使入口漏调 Reset 也能兜住)
|
||||
if (_currentListeningSn != deviceSn) {
|
||||
_throttleTimer?.cancel();
|
||||
_throttleTimer = null;
|
||||
_cachedStatus = null;
|
||||
_cachedGps = null;
|
||||
_currentListeningSn = deviceSn;
|
||||
if (!isClosed) {
|
||||
emit(DeviceStatusInitial());
|
||||
}
|
||||
debugPrint('${LogTime.now()} 🧹 [DeviceStatusBloc] 切换设备,已清空旧缓存: $deviceSn');
|
||||
}
|
||||
|
||||
// 按SN订阅(数据源内部自动退旧订新、同SN去重)
|
||||
_mowerRealtimeRepo.startListening(deviceSn: deviceSn).then((result) {
|
||||
result.fold(
|
||||
@@ -434,9 +451,18 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
|
||||
'🔄 [DeviceStatusBloc] 收到重置事件:清空状态 - 当前状态:${state.runtimeType}',
|
||||
);
|
||||
|
||||
// 🔥 关键修复:清空缓存与节流器,避免上一个设备的坐标/状态残留,
|
||||
// 并通过 copyWith(base) 污染新设备的数据
|
||||
_throttleTimer?.cancel();
|
||||
_throttleTimer = null;
|
||||
_cachedStatus = null;
|
||||
_cachedGps = null;
|
||||
_mqttVehicleFrameCount = 0;
|
||||
_mqttLocationFrameCount = 0;
|
||||
|
||||
// 只 emit 初始状态,让 UI 清除旧设备的数据
|
||||
emit(DeviceStatusInitial());
|
||||
debugPrint('⚠️ [DeviceStatusBloc] 已emit DeviceStatusInitial');
|
||||
debugPrint('⚠️ [DeviceStatusBloc] 已emit DeviceStatusInitial,缓存已清空');
|
||||
}
|
||||
|
||||
Future<void> _handleDeviceStatusLoaded(
|
||||
@@ -552,6 +578,7 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
|
||||
|
||||
// 🔥 重置设备ID
|
||||
_currentDeviceId = null;
|
||||
_currentListeningSn = null;
|
||||
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user