完成点 初始

This commit is contained in:
mmc
2026-03-12 16:18:12 +08:00
parent 83a57d0cce
commit 64125eb0a8
2 changed files with 22 additions and 18 deletions

View File

@@ -2,6 +2,7 @@ import 'package:equatable/equatable.dart';
import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart'; import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart';
import '../../data/models/device_add_path_point_model.dart'; import '../../data/models/device_add_path_point_model.dart';
enum DeviceOperationType { enum DeviceOperationType {
none, // 无操作 none, // 无操作
unbind, // 解绑设备 unbind, // 解绑设备
@@ -13,8 +14,6 @@ enum AppState {
routePlanning, //正在规划路径 routePlanning, //正在规划路径
} }
class DevicesState extends Equatable { class DevicesState extends Equatable {
final List<DeviceEntity> devices; // 名下所有设备列表 final List<DeviceEntity> devices; // 名下所有设备列表
final DeviceEntity? selectedDevice; // 当前主界面选中的/操作的设备 final DeviceEntity? selectedDevice; // 当前主界面选中的/操作的设备
@@ -31,9 +30,6 @@ class DevicesState extends Equatable {
final double? arriLatitude; final double? arriLatitude;
final double? arriLongitude; final double? arriLongitude;
const DevicesState({ const DevicesState({
this.devices = const [], this.devices = const [],
this.selectedDevice, this.selectedDevice,
@@ -46,7 +42,9 @@ class DevicesState extends Equatable {
this.pathData, this.pathData,
this.generatedPath, this.generatedPath,
this.appState = AppState.none, this.appState = AppState.none,
this.isFinshWork = false, this.arriLatitude, this.arriLongitude, this.isFinshWork = false,
this.arriLatitude,
this.arriLongitude,
}); });
// 使用 copyWith 方便局部更新状态 // 使用 copyWith 方便局部更新状态
@@ -85,7 +83,10 @@ class DevicesState extends Equatable {
} }
@override @override
List<Object?> get props => [devices, selectedDevice, isLoading, List<Object?> get props => [
devices,
selectedDevice,
isLoading,
errorMessage, errorMessage,
deviceLatitude, deviceLatitude,
deviceLongitude, deviceLongitude,
@@ -96,6 +97,6 @@ class DevicesState extends Equatable {
appState, appState,
isFinshWork, isFinshWork,
arriLatitude, arriLatitude,
arriLongitude arriLongitude,
]; ];
} }

View File

@@ -555,8 +555,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
'outer': 'outer':
// 核心修改:根据机器人模式选择不同的坐标源 // 核心修改:根据机器人模式选择不同的坐标源
(_currentRobotMode == RobotMode.robot ? _robotModeWgsPoints : gcjOuterPoints).map((point) { (_currentRobotMode == RobotMode.robot ? _robotModeWgsPoints : gcjOuterPoints).map((point) {
// Robot模式:_robotModeWgsPoints本身就是WGS84坐标,无需转换
// Point模式:gcjOuterPoints是GCJ02坐标,需要转换为WGS84
final wgs84 = _currentRobotMode == RobotMode.robot final wgs84 = _currentRobotMode == RobotMode.robot
? point // Robot模式直接使用原始WGS84坐标 ? point // Robot模式直接使用原始WGS84坐标
: gcj02ToWgs84(point.latitude, point.longitude); // Point模式转换 : gcj02ToWgs84(point.latitude, point.longitude); // Point模式转换
@@ -2025,9 +2023,14 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
final devicesState = context.watch<DevicesCubit>().state; final devicesState = context.watch<DevicesCubit>().state;
// 2. 读取 isFinishWork 数据(修正拼写,设置默认值) // 2. 读取 isFinishWork 数据(修正拼写,设置默认值)
bool isFinishWork = devicesState.isFinshWork ?? false; bool isFinishWork = devicesState.isFinshWork ?? false;
// 初始化默认值 double? arriLatitude = devicesState.arriLatitude;
String yaw = '--'; double? arriLongitude = devicesState.arriLongitude;
String satelliteCnt = '--'; LatLng? targetLatLng;
if (arriLatitude != null && arriLongitude != null) {
targetLatLng = LatLng(arriLatitude, arriLongitude);
_traceManager.upsert(targetLatLng, TPAction.ADD);
}
double currentLat = 0.0; double currentLat = 0.0;
double currentLng = 0.0; double currentLng = 0.0;
bool obfFlag = false; //障碍物标志位 bool obfFlag = false; //障碍物标志位
@@ -2052,8 +2055,8 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
//debugPrint("路径规划四十数据 - 经纬度:"); //debugPrint("路径规划四十数据 - 经纬度:");
//debugPrint(" RunningStatus纬度:${updatedState.status.latitude}"); //debugPrint(" RunningStatus纬度:${updatedState.status.latitude}");
//debugPrint(" RunningStatus经度:${updatedState.status.longitude}"); //debugPrint(" RunningStatus经度:${updatedState.status.longitude}");
//debugPrint("${updatedState.status.obstacleFlag},${updatedState.status.qual},${updatedState.status.controlMode}"); // debugPrint("障碍物${updatedState.status.obstacleFlag}");
//debugPrint("${updatedState.status.headingStatus},${updatedState.status.yaw}"); // debugPrint("初始化${updatedState.status.headingStatus}");
// 提取经纬度并更新本地变量 // 提取经纬度并更新本地变量
currentLat = updatedState.status.latitude; currentLat = updatedState.status.latitude;