机器状态数据和地图切换,系统配置页面
This commit is contained in:
@@ -37,7 +37,10 @@ class RunningStatusEntity extends Equatable {
|
||||
// === 扩展信息 (字段 18-23) ===
|
||||
final String timestamp; // [18] 时间戳 (格式:20-1-11-31 08:00:00)
|
||||
final String knifeCuttingSpeed; // [19] 割刀速度
|
||||
final String controlMode; // [20] 控制模式
|
||||
/// [20] 控制模式。**空串 = 后端从未给过**(UI 显示「未知」);
|
||||
/// 协议值 0=未知 1=本地 2=自主任务 3=远程遥控。
|
||||
/// 以前默认写死 '0',把「没数据」也当成一个有效档位,UI 无从分辨。
|
||||
final String controlMode;
|
||||
final String battery; // [21] 电量百分比
|
||||
final String workingArea; // [22] 工作面积
|
||||
final String obstacleFlag; // [23] 障碍物标志
|
||||
@@ -69,7 +72,7 @@ class RunningStatusEntity extends Equatable {
|
||||
this.longitude = 0.0,
|
||||
this.timestamp = '',
|
||||
this.knifeCuttingSpeed = '0',
|
||||
this.controlMode = '0',
|
||||
this.controlMode = '',
|
||||
this.battery = '0',
|
||||
this.workingArea = '0',
|
||||
this.obstacleFlag = '0',
|
||||
@@ -143,7 +146,8 @@ class RunningStatusEntity extends Equatable {
|
||||
// 扩展信息 (保持原始字符串,由调用方决定如何解析)
|
||||
timestamp: fields[18].trim(),
|
||||
knifeCuttingSpeed: fields[19].trim().isNotEmpty ? fields[19].trim() : '0',
|
||||
controlMode: fields[20].trim().isNotEmpty ? fields[20].trim() : '0',
|
||||
// 空串原样保留:表示后端这一帧没带该字段,UI 据此显示「未知」
|
||||
controlMode: fields[20].trim(),
|
||||
battery: fields[21].trim().isNotEmpty ? fields[21].trim() : '0',
|
||||
workingArea: fields[22].trim().isNotEmpty ? fields[22].trim() : '0',
|
||||
obstacleFlag: fields[23].trim().isNotEmpty ? fields[23].trim() : '0',
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import '../../../../core/domain/usecases/base_usecase.dart';
|
||||
import '../../../../core/error/failure.dart';
|
||||
import '../entities/device_schedule_plan_entity.dart';
|
||||
import '../repositories/device_task_repository.dart';
|
||||
|
||||
/// 创建设备定时任务(定时作业计划,按天/周/月循环触发)。
|
||||
///
|
||||
/// 提交前先执行实体的本地校验(与后端入参规则逐条对齐,
|
||||
/// 含「生效区间内必须存在可执行日期」的业务强校验),
|
||||
/// 本地能拦的直接 Left,不再浪费一次失败往返。
|
||||
class SaveDeviceSchedulePlanUseCase
|
||||
implements BaseUseCase<bool, SaveDeviceSchedulePlanParams> {
|
||||
final DeviceTaskRepository repository;
|
||||
|
||||
SaveDeviceSchedulePlanUseCase(this.repository);
|
||||
|
||||
@override
|
||||
Future<Either<Failure, bool>> call(
|
||||
SaveDeviceSchedulePlanParams params,
|
||||
) async {
|
||||
final error = params.plan.getValidationError();
|
||||
if (error != null) return Left(Failure(error));
|
||||
return await repository.saveDeviceSchedulePlan(plan: params.plan);
|
||||
}
|
||||
}
|
||||
|
||||
class SaveDeviceSchedulePlanParams {
|
||||
final DeviceSchedulePlanEntity plan;
|
||||
|
||||
SaveDeviceSchedulePlanParams({required this.plan});
|
||||
}
|
||||
Reference in New Issue
Block a user