完善自主作业下发、暂停恢复和轨迹保留
This commit is contained in:
@@ -14,6 +14,8 @@ import 'package:maibu_satabot_v2/features/autonomous_work/data/site_device_realt
|
||||
import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/autonomous_work/domain/entities/work_session_models.dart';
|
||||
import 'package:maibu_satabot_v2/features/autonomous_work/domain/repositories/autonomous_work_gateway.dart';
|
||||
import 'package:maibu_satabot_v2/features/device_control_mode/domain/entities/device_control_mode.dart';
|
||||
import 'package:maibu_satabot_v2/features/device_control_mode/domain/usecases/device_control_mode_usecases.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/domain/entities/running_status_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/device_status_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/device_status_state.dart';
|
||||
@@ -485,6 +487,7 @@ class _RobotAutonomousWorkPageV2State extends State<RobotAutonomousWorkPageV2> {
|
||||
// ===== 底部操作栏动作(全部走 gateway,状态由真实任务回流驱动)=====
|
||||
|
||||
Future<void> _startWork() async {
|
||||
if (_busy) return;
|
||||
final route = _route;
|
||||
if (route == null) {
|
||||
CapsuleToast.show(
|
||||
@@ -556,10 +559,27 @@ class _RobotAutonomousWorkPageV2State extends State<RobotAutonomousWorkPageV2> {
|
||||
return;
|
||||
}
|
||||
|
||||
final deviceId = _deviceId;
|
||||
final modeSent = await showWorkConfirmDialog(
|
||||
context,
|
||||
title: _l10n.translate('autonomous_work.dispatch_mode_title'),
|
||||
desc: _l10n.translate('autonomous_work.dispatch_mode_description'),
|
||||
checks: const [],
|
||||
confirmLabel: _l10n.translate('autonomous_work.dispatch_mode_confirm'),
|
||||
onConfirm: () async {
|
||||
final result = await sl<ChangeDeviceControlModeUseCase>()(
|
||||
deviceId,
|
||||
ControlModeTarget.autonomous,
|
||||
);
|
||||
return result.fold((failure) => failure.message, (_) => null);
|
||||
},
|
||||
);
|
||||
if (modeSent != true || !mounted) return;
|
||||
|
||||
// ③ 下发(复用已有任务或新建)
|
||||
final result = await _gateway.startWork(
|
||||
WorkStartRequest(
|
||||
deviceId: _deviceId,
|
||||
deviceId: deviceId,
|
||||
route: route,
|
||||
reuseTaskId: reuse?.taskId,
|
||||
),
|
||||
@@ -1025,6 +1045,22 @@ class _RobotAutonomousWorkPageV2State extends State<RobotAutonomousWorkPageV2> {
|
||||
return _buildPage(context);
|
||||
}
|
||||
|
||||
void _recordTaskGeometry({
|
||||
List<LatLng>? recordedPoints,
|
||||
List<LatLng>? plannedRoute,
|
||||
}) {
|
||||
final task = _session;
|
||||
final gateway = _gateway;
|
||||
if (task == null || gateway is! WorkTaskGeometrySource) return;
|
||||
final geometrySource = gateway as WorkTaskGeometrySource;
|
||||
geometrySource.recordTaskGeometry(
|
||||
deviceId: _deviceId,
|
||||
taskId: task.taskId,
|
||||
recordedPoints: recordedPoints,
|
||||
plannedRoute: plannedRoute,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPage(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF26331F),
|
||||
@@ -1042,9 +1078,15 @@ class _RobotAutonomousWorkPageV2State extends State<RobotAutonomousWorkPageV2> {
|
||||
expectedTaskId: _session?.taskId,
|
||||
traceDiagnosticsEnabled: true,
|
||||
recordLocationTrace: false,
|
||||
savedRoute: _session?.plannedRoute ?? const <LatLng>[],
|
||||
onTaskTraceChanged: (points) =>
|
||||
_recordTaskGeometry(recordedPoints: points),
|
||||
onTaskRouteChanged: (points) =>
|
||||
_recordTaskGeometry(plannedRoute: points),
|
||||
taskTrace: WorkTraceInput(
|
||||
taskId: _session?.taskId,
|
||||
completedPoints: _session?.completedPoints ?? const <LatLng>[],
|
||||
recordedPoints: _session?.recordedPoints ?? const <LatLng>[],
|
||||
recording: _session?.canRecordTrace ?? false,
|
||||
visible:
|
||||
_phase == WorkRunState.running ||
|
||||
@@ -1754,39 +1796,6 @@ class _RobotAutonomousWorkPageV2State extends State<RobotAutonomousWorkPageV2> {
|
||||
),
|
||||
),
|
||||
),
|
||||
// 底部按钮(固定,不被滚动区顶走)
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
px,
|
||||
m.tiny ? 4 : 8,
|
||||
px,
|
||||
m.tiny ? 4 : (compact ? 12 : 14),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () =>
|
||||
_pushPortrait(RobotSensorPageV2(robot: widget.robot)),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: m.tiny ? 26 : (compact ? 34 : 38),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: kWtSoftBlue,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Text(
|
||||
_l10n.translate('autonomous_work.view_sensors'),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: m.fsx(12, 9),
|
||||
fontWeight: FontWeight.w800,
|
||||
color: kWtBlue,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user