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 16:43:08 +08:00
4 changed files with 17 additions and 1 deletions

View File

@@ -181,6 +181,13 @@ class PathPlanner {
_isStopped = true;
_isPaused = false; // 清除暂停状态
// 🔥 核心修复:清空队列
print("🗑️ 清空待发送队列,剩余 ${locationQueue.length} 个点");
locationQueue.clear();
var entity = new RoutePlanSendEntity(
commandType: 0x01,
pointCounts: 0,

View File

@@ -391,6 +391,8 @@ class DevicesCubit extends Cubit<DevicesState> {
Future<void> stopRoutePlanning() async {
emit(state.copyWith(isLoading: true));
final result = await _routePlanningUseCase.stopRoutePlanning();
// 🔥 重置 PathPlanningService 中的全局的队列
_pathPlanningService.clear();
result.fold((failure) => emit(state.copyWith(isLoading: false, errorMessage: failure.message ?? '停止失败')), (_) => emit(state.copyWith(isLoading: false)));
}

View File

@@ -73,4 +73,5 @@ class PathPlanningService {
Queue<DeviceAddPathPointModel> getQueue() {
return Queue.of(locationQueue);
}
}

View File

@@ -1485,6 +1485,12 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
_workStatus = WorkStatus.working;
});
// 🔥 核心修复:先更新 AppState 为 routePlanning
context.read<DevicesCubit>().updateAppState(AppState.routePlanning);
// 🔥 延迟一下,确保状态已更新
await Future.delayed(const Duration(milliseconds: 100));
//// 步骤1:将 List<LatLng> 转换为 List<DeviceAddPathPointModel>
//final List<work_area_model.DeviceAddPathPointModel> pathModels = gcjPathPoints.map((latLng) {
// return work_area_model.DeviceAddPathPointModel(
@@ -1502,7 +1508,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
// 步骤 3:调用 Cubit 方法(类型匹配)
await context.read<DevicesCubit>().startRoutePlanning(pathQueue);
context.read<DevicesCubit>().updateAppState(AppState.routePlanning);
///context.read<DevicesCubit>().updateAppState(AppState.routePlanning);
// 可选:显示作业提示
ToastUtils.showSuccess(context, '作业已开始');
//ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('作业已开始'), backgroundColor: Colors.green));