Merge branch 'feature/my' of http://1.95.137.212:57001/APP/FlutterApp into feature/my

This commit is contained in:
mmc
2026-03-12 13:52:08 +08:00
3 changed files with 23 additions and 0 deletions

View File

@@ -4,7 +4,9 @@ import 'package:flutter/cupertino.dart';
import 'package:maibu_satabot_v2/features/devices/data/models/device_add_path_point_model.dart';
import '../../features/devices/domain/repositories/route_planning_repository.dart';
import '../../features/devices/presentation/bloc/devices_cubit.dart';
import '../../features/devices/services/path_planning_service.dart';
import '../di/injection.dart';
import 'protocol_decoder.dart';
import 'tcp/tcp_client.dart';
// import '../../features/auth/data/models/user_model.dart';
@@ -101,6 +103,13 @@ class NetMessageDispatcher {
/// _pathPlanningService.updateQueue(queue as List<DeviceAddPathPointModel>);
_pathPlanningService.updateQueue(queue.toList());
debugPrint('📡 [Dispatcher] 准备触发下一个路径点发送,队列剩余:${queue.length}');
///如果还剩0个数据 就停止发送
if (queue.length==0) {
debugPrint('⚠️ [Dispatcher] 队列已空,停止发送');
final devicesCubit = sl<DevicesCubit>();
devicesCubit.finishWork();
return false;
}
routePlanningRepository.startRoutePlanning(queue);
return true;
} else {

View File

@@ -398,4 +398,13 @@ class DevicesCubit extends Cubit<DevicesState> {
emit(state.copyWith(appState: appState));
(_routePlanningUseCase as dynamic).repository.setAppState(appState);
}
void finishWork() {
emit(state.copyWith(isFinshWork: true));
}
/// 重置完成状态
void resetWorkStatus() {
emit(state.copyWith(isFinshWork: false));
}
}

View File

@@ -27,6 +27,7 @@ class DevicesState extends Equatable {
final List<Map<String, dynamic>>? pathData;
final List<DeviceAddPathPointModel>? generatedPath; // 新增字段
final AppState appState;
final bool isFinshWork;
@@ -42,6 +43,7 @@ class DevicesState extends Equatable {
this.pathData,
this.generatedPath,
this.appState = AppState.none,
this.isFinshWork = false,
});
// 使用 copyWith 方便局部更新状态
@@ -57,6 +59,7 @@ class DevicesState extends Equatable {
List<Map<String, dynamic>>? pathData,
List<DeviceAddPathPointModel>? generatedPath,
AppState? appState,
bool? isFinshWork,
}) {
return DevicesState(
devices: devices ?? this.devices,
@@ -70,6 +73,7 @@ class DevicesState extends Equatable {
operationType: operationType ?? this.operationType, // 更新操作类型
generatedPath: generatedPath ?? this.generatedPath, // 更新生成的路径数据
appState: appState ?? this.appState, // 更新应用状态
isFinshWork: isFinshWork ?? this.isFinshWork,
);
}
@@ -83,5 +87,6 @@ class DevicesState extends Equatable {
operationType,
generatedPath,
appState,
isFinshWork
];
}