修复完成作业停止之后再开始作业
This commit is contained in:
@@ -181,6 +181,13 @@ class PathPlanner {
|
|||||||
_isStopped = true;
|
_isStopped = true;
|
||||||
_isPaused = false; // 清除暂停状态
|
_isPaused = false; // 清除暂停状态
|
||||||
|
|
||||||
|
// 🔥 核心修复:清空队列
|
||||||
|
print("🗑️ 清空待发送队列,剩余 ${locationQueue.length} 个点");
|
||||||
|
locationQueue.clear();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var entity = new RoutePlanSendEntity(
|
var entity = new RoutePlanSendEntity(
|
||||||
commandType: 0x01,
|
commandType: 0x01,
|
||||||
pointCounts: 0,
|
pointCounts: 0,
|
||||||
|
|||||||
@@ -391,6 +391,8 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
Future<void> stopRoutePlanning() async {
|
Future<void> stopRoutePlanning() async {
|
||||||
emit(state.copyWith(isLoading: true));
|
emit(state.copyWith(isLoading: true));
|
||||||
final result = await _routePlanningUseCase.stopRoutePlanning();
|
final result = await _routePlanningUseCase.stopRoutePlanning();
|
||||||
|
// 🔥 重置 PathPlanningService 中的全局的队列
|
||||||
|
_pathPlanningService.clear();
|
||||||
result.fold((failure) => emit(state.copyWith(isLoading: false, errorMessage: failure.message ?? '停止失败')), (_) => emit(state.copyWith(isLoading: false)));
|
result.fold((failure) => emit(state.copyWith(isLoading: false, errorMessage: failure.message ?? '停止失败')), (_) => emit(state.copyWith(isLoading: false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,4 +73,5 @@ class PathPlanningService {
|
|||||||
Queue<DeviceAddPathPointModel> getQueue() {
|
Queue<DeviceAddPathPointModel> getQueue() {
|
||||||
return Queue.of(locationQueue);
|
return Queue.of(locationQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1485,6 +1485,12 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
_workStatus = WorkStatus.working;
|
_workStatus = WorkStatus.working;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 🔥 核心修复:先更新 AppState 为 routePlanning
|
||||||
|
context.read<DevicesCubit>().updateAppState(AppState.routePlanning);
|
||||||
|
// 🔥 延迟一下,确保状态已更新
|
||||||
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
|
|
||||||
|
|
||||||
//// 步骤1:将 List<LatLng> 转换为 List<DeviceAddPathPointModel>
|
//// 步骤1:将 List<LatLng> 转换为 List<DeviceAddPathPointModel>
|
||||||
//final List<work_area_model.DeviceAddPathPointModel> pathModels = gcjPathPoints.map((latLng) {
|
//final List<work_area_model.DeviceAddPathPointModel> pathModels = gcjPathPoints.map((latLng) {
|
||||||
// return work_area_model.DeviceAddPathPointModel(
|
// return work_area_model.DeviceAddPathPointModel(
|
||||||
@@ -1502,7 +1508,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
|
|
||||||
// 步骤 3:调用 Cubit 方法(类型匹配)
|
// 步骤 3:调用 Cubit 方法(类型匹配)
|
||||||
await context.read<DevicesCubit>().startRoutePlanning(pathQueue);
|
await context.read<DevicesCubit>().startRoutePlanning(pathQueue);
|
||||||
context.read<DevicesCubit>().updateAppState(AppState.routePlanning);
|
///context.read<DevicesCubit>().updateAppState(AppState.routePlanning);
|
||||||
// 可选:显示作业提示
|
// 可选:显示作业提示
|
||||||
ToastUtils.showSuccess(context, '作业已开始');
|
ToastUtils.showSuccess(context, '作业已开始');
|
||||||
//ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('作业已开始'), backgroundColor: Colors.green));
|
//ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('作业已开始'), backgroundColor: Colors.green));
|
||||||
|
|||||||
Reference in New Issue
Block a user