修复重复工作和发送点异常的情况
This commit is contained in:
@@ -95,6 +95,17 @@ class NetMessageDispatcher {
|
||||
///取全局的路径规划发送实体 queue
|
||||
/// 发送下一个指令 移除上一条数据
|
||||
var queue = _pathPlanningService.getQueue();
|
||||
// 🔥 关键:必须先检查空队列!
|
||||
if (queue.isEmpty) {
|
||||
devicesCubit.finishWork();
|
||||
Future.delayed(Duration(seconds: 1), () {
|
||||
devicesCubit.resetWorkStatus();
|
||||
});
|
||||
// 手动停止
|
||||
//routePlanningRepository.stopRoutePlanning();
|
||||
debugPrint('⚠️ [Dispatcher] 队列已经为空,跳过本次响应处理');
|
||||
return false;
|
||||
}
|
||||
///更新完成jwd
|
||||
var deviceAddPathPointModel = queue.first;
|
||||
var d = deviceAddPathPointModel.latitude;
|
||||
@@ -106,20 +117,26 @@ class NetMessageDispatcher {
|
||||
debugPrint("准确更新完成的路径点经纬度,$d,$e");
|
||||
//去除上一条数据
|
||||
queue.removeFirst();
|
||||
|
||||
|
||||
/// _pathPlanningService.updateQueue(queue as List<DeviceAddPathPointModel>);
|
||||
_pathPlanningService.updateQueue(queue.toList());
|
||||
debugPrint('📡 [Dispatcher] 准备触发下一个路径点发送,队列剩余:${queue.length}');
|
||||
DateTime now = DateTime.now();
|
||||
String timeStr = "${now.hour.toString().padLeft(2, '0')}:"
|
||||
"${now.minute.toString().padLeft(2, '0')}:"
|
||||
"${now.second.toString().padLeft(2, '0')}";
|
||||
|
||||
debugPrint('📡${timeStr} [Dispatcher] 准备触发下一个路径点发送,队列剩余:${queue.length}');
|
||||
///如果还剩0个数据 就停止发送
|
||||
if (queue.length==0) {
|
||||
debugPrint('⚠️ [Dispatcher] 队列已空,停止发送');
|
||||
|
||||
// final devicesCubit = sl<DevicesCubit>();
|
||||
devicesCubit.finishWork();
|
||||
Future.delayed(Duration(seconds: 1), () {
|
||||
devicesCubit.resetWorkStatus();
|
||||
});
|
||||
|
||||
// 手动停止
|
||||
routePlanningRepository.stopRoutePlanning();
|
||||
debugPrint('⚠️ [Dispatcher] 队列已空,发送停止指令已发送');
|
||||
return false;
|
||||
}
|
||||
routePlanningRepository.startRoutePlanning(queue);
|
||||
|
||||
@@ -70,8 +70,11 @@ class PathPlanningService {
|
||||
int get length => locationQueue.length;
|
||||
|
||||
/// 获取当前队列(供 Cubit 使用)
|
||||
Queue<DeviceAddPathPointModel> getQueue() {
|
||||
return Queue.of(locationQueue);
|
||||
}
|
||||
// Queue<DeviceAddPathPointModel> getQueue() {
|
||||
// return Queue.of(locationQueue);
|
||||
// }
|
||||
|
||||
Queue<DeviceAddPathPointModel> getQueue() {
|
||||
return locationQueue; // 直接返回引用
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user