开始作业 暂停、恢复、停止接口对接 未测试
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:collection';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
@@ -143,9 +144,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_mapCenter = highPrecisionCenter;
|
_mapCenter = highPrecisionCenter;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 可选:打印验证精度(保留15位小数)
|
|
||||||
debugPrint('地图中心更新(高精度):纬度=${_mapCenter.latitude.toStringAsFixed(15)}, 经度=${_mapCenter.longitude.toStringAsFixed(15)}');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -983,13 +981,27 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 开始作业
|
/// 开始作业
|
||||||
void _startWork() {
|
void _startWork() async {
|
||||||
if (gcjPathPoints.isEmpty) return;
|
if (gcjPathPoints.isEmpty) return;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_workStatus = WorkStatus.working;
|
_workStatus = WorkStatus.working;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 步骤1:将 List<LatLng> 转换为 List<DeviceAddPathPointModel>
|
||||||
|
final List<work_area_model.DeviceAddPathPointModel> pathModels = gcjPathPoints.map((latLng) {
|
||||||
|
return work_area_model.DeviceAddPathPointModel(
|
||||||
|
latitude: latLng.latitude, // 纬度
|
||||||
|
longitude: latLng.longitude, // 经度
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
// 步骤2:将 List 转换为 Queue(队列)
|
||||||
|
final Queue<work_area_model.DeviceAddPathPointModel> pathQueue = Queue.from(pathModels);
|
||||||
|
|
||||||
|
// 步骤3:调用 Cubit 方法(类型匹配)
|
||||||
|
await context.read<DevicesCubit>().startRoutePlanning(pathQueue);
|
||||||
|
|
||||||
debugPrint('开始作业:${_selectedPlot!.plotName},路径数据:$gcjPathPoints');
|
debugPrint('开始作业:${_selectedPlot!.plotName},路径数据:$gcjPathPoints');
|
||||||
|
|
||||||
// 可选:显示作业提示
|
// 可选:显示作业提示
|
||||||
@@ -997,22 +1009,21 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 暂停作业
|
/// 暂停作业
|
||||||
void _pauseWork() {
|
void _pauseWork() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_workStatus = WorkStatus.paused;
|
_workStatus = WorkStatus.paused;
|
||||||
});
|
});
|
||||||
|
await context.read<DevicesCubit>().pauseRoutePlanning();
|
||||||
|
|
||||||
// 模拟暂停逻辑(替换为你的实际暂停代码)
|
// 模拟暂停逻辑(替换为你的实际暂停代码)
|
||||||
debugPrint('暂停作业:${_selectedPlot!.plotName}');
|
debugPrint('暂停作业:${_selectedPlot!.plotName}');
|
||||||
|
|
||||||
// 可选:显示暂停提示
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('作业已暂停'), backgroundColor: Colors.amber));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _stopWork() {
|
void _stopWork() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_workStatus = WorkStatus.idle;
|
_workStatus = WorkStatus.idle;
|
||||||
});
|
});
|
||||||
|
await context.read<DevicesCubit>().stopRoutePlanning();
|
||||||
// 模拟停止逻辑(替换为你的实际停止代码)
|
// 模拟停止逻辑(替换为你的实际停止代码)
|
||||||
debugPrint('停止作业:${_selectedPlot!.plotName}');
|
debugPrint('停止作业:${_selectedPlot!.plotName}');
|
||||||
// 可选:显示停止提示
|
// 可选:显示停止提示
|
||||||
@@ -1020,10 +1031,11 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 继续作业
|
/// 继续作业
|
||||||
void _resumeWork() {
|
void _resumeWork() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_workStatus = WorkStatus.working;
|
_workStatus = WorkStatus.working;
|
||||||
});
|
});
|
||||||
|
await context.read<DevicesCubit>().resumeRoutePlanning();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showDeleteConfirmDialog(PlotData plot, Function(PlotData) onDelete) {
|
void _showDeleteConfirmDialog(PlotData plot, Function(PlotData) onDelete) {
|
||||||
|
|||||||
Reference in New Issue
Block a user