对接连续任务列表接口和连续任务下发,便捷操作中暂停任务的对接,底部导航tab项的设置根据用户角色显示和设置

This commit is contained in:
2026-11-11 16:51:21 +08:00
parent 47f518f94c
commit 985bcf4b55
54 changed files with 5017 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
import '../../domain/entities/work_history_record.dart';
class WorkHistoryModel {
static int? _int(dynamic value) => int.tryParse('$value');
static String? _text(dynamic value) {
final text = value?.toString().trim();
return text == null || text.isEmpty ? null : text;
}
static WorkHistoryRecord fromJson(Map<String, dynamic> json) {
final id = _int(json['id']);
if (id == null || id <= 0) throw const FormatException('作业历史缺少有效任务 ID');
final accepted = json['taskAccepted'];
return WorkHistoryRecord(
id: id,
deviceId: _text(json['deviceId']) ?? '',
deviceAlias: _text(json['deviceAlias']),
workName: _text(json['workName']) ?? '',
// 后端原字段为 taskStaus(缺少 t),优先按真实接口解析。
status: _text(json['taskStaus'] ?? json['taskStatus']) ?? '',
statusLabel:
_text(json['taskStausTranslate'] ?? json['taskStatusTranslate']) ??
'',
siteId: _int(json['siteId']),
orgId: _int(json['orgId']),
planId: _int(json['planId']),
routeId: _int(json['routeId']),
createdAt: _text(json['createTime']),
updatedAt: _text(json['updateTime']),
startedAt: _text(json['startTime']),
finishedAt: _text(json['finishTime']),
taskType: _text(json['taskType']),
routeType: _text(json['routeType']),
remark: _text(json['remark']),
accepted: accepted is bool
? accepted
: accepted == 1 || accepted == '1'
? true
: accepted == 0 || accepted == '0'
? false
: null,
);
}
}