first commit

This commit is contained in:
2026-03-24 15:03:35 +01:00
commit cdba16ebe8
162 changed files with 194406 additions and 0 deletions

View File

@@ -0,0 +1,163 @@
import '../../domain/entities/logistic_object.dart';
class LogisticObjectModel extends LogisticObject {
const LogisticObjectModel({
required super.id,
required super.objectId,
required super.type,
required super.version,
super.locationId,
required super.code,
super.remark,
required super.state,
required super.subtype,
super.origin,
super.isManual,
super.lastModified,
super.typeName,
super.typeMnemonic,
});
factory LogisticObjectModel.fromJson(Map<String, dynamic> json) {
return LogisticObjectModel(
id: json['id'] ?? 0,
objectId: json['object_id'] ?? json['id'] ?? 0,
type: json['type'] ?? 0,
version: json['version'] ?? json['ver'] ?? 0,
locationId: json['loc_id'],
code: json['code'] ?? '',
remark: json['rem'],
state: json['state'] ?? 'unknown',
subtype: json['subtype'] ?? json['type']?.toString() ?? '',
origin: json['origin'],
isManual: json['manual'] == '1' || json['manual'] == true,
lastModified: json['last_modified'] != null
? DateTime.parse(json['last_modified'])
: null,
);
}
factory LogisticObjectModel.fromMap(Map<String, dynamic> map) {
return LogisticObjectModel(
id: map['id'] ?? 0,
objectId: map['object_id'] ?? 0,
type: map['type'] ?? 0,
version: map['version'] ?? 0,
locationId: map['loc_id'],
code: map['code'] ?? '',
remark: map['rem'],
state: map['state'] ?? 'unknown',
subtype: map['subtype'] ?? '',
origin: map['origin'],
isManual: map['manual'] == '1' || map['manual'] == 1,
lastModified: map['last_modified'] != null
? DateTime.tryParse(map['last_modified'])
: null,
typeName: map['type_name'],
typeMnemonic: map['type_mnemonic'],
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'object_id': objectId,
'type': type,
'version': version,
'loc_id': locationId,
'code': code,
'rem': remark,
'state': state,
'subtype': subtype,
'origin': origin,
'manual': isManual ? 1 : 0,
'last_modified': lastModified?.toIso8601String(),
};
}
LogisticObjectModel copyWithModel({
int? id,
int? objectId,
int? type,
int? version,
int? locationId,
String? code,
String? remark,
String? state,
String? subtype,
String? origin,
bool? isManual,
DateTime? lastModified,
String? typeName,
String? typeMnemonic,
}) {
return LogisticObjectModel(
id: id ?? this.id,
objectId: objectId ?? this.objectId,
type: type ?? this.type,
version: version ?? this.version,
locationId: locationId ?? this.locationId,
code: code ?? this.code,
remark: remark ?? this.remark,
state: state ?? this.state,
subtype: subtype ?? this.subtype,
origin: origin ?? this.origin,
isManual: isManual ?? this.isManual,
lastModified: lastModified ?? this.lastModified,
typeName: typeName ?? this.typeName,
typeMnemonic: typeMnemonic ?? this.typeMnemonic,
);
}
}
class ObjectMetadataModel extends ObjectMetadata {
const ObjectMetadataModel({
required super.id,
required super.type,
required super.version,
required super.mnemonic,
required super.name,
required super.prefix,
required super.subtype,
required super.counterText,
});
factory ObjectMetadataModel.fromJson(Map<String, dynamic> json) {
return ObjectMetadataModel(
id: json['id'] ?? 0,
type: json['type'] ?? 0,
version: json['version'] ?? json['ver'] ?? 0,
mnemonic: json['mnemonic'] ?? '',
name: json['name'] ?? '',
prefix: json['pre'] ?? '',
subtype: json['subtype'] ?? '',
counterText: json['counter_text'] ?? '',
);
}
factory ObjectMetadataModel.fromMap(Map<String, dynamic> map) {
return ObjectMetadataModel(
id: map['id'] ?? 0,
type: map['type'] ?? 0,
version: map['version'] ?? 0,
mnemonic: map['mnemonic'] ?? '',
name: map['name'] ?? '',
prefix: map['prefix'] ?? '',
subtype: map['subtype'] ?? '',
counterText: map['counter_text'] ?? '',
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'type': type,
'version': version,
'mnemonic': mnemonic,
'name': name,
'prefix': prefix,
'subtype': subtype,
'counter_text': counterText,
};
}
}

View File

@@ -0,0 +1,194 @@
import '../../domain/entities/tour.dart';
class TourModel extends Tour {
const TourModel({
required super.id,
required super.jobId,
required super.tourId,
required super.version,
required super.state,
required super.type,
required super.sort,
required super.locationId,
required super.locationCode,
super.locationCode2,
super.remark,
super.menuText,
required super.modified,
super.deliveryCode,
super.locationName,
super.isCompleted,
super.pages,
});
factory TourModel.fromJson(Map<String, dynamic> json) {
return TourModel(
id: json['id'] ?? 0,
jobId: json['job_id'] ?? 0,
tourId: json['tour_id'] ?? 0,
version: json['version'] ?? 0,
state: json['state'] ?? 0,
type: json['type'] ?? '',
sort: json['sort'] ?? 0,
locationId: json['loc_id'] ?? 0,
locationCode: json['loc_code'] ?? '',
locationCode2: json['loc_code_2'],
remark: json['rem'],
menuText: json['menu'],
modified: json['modified'] ?? 0,
deliveryCode: json['del_code'],
locationName: json['location_name'],
isCompleted: json['state'] == 1,
pages: (json['pages'] as List?)
?.map((p) => TourPageModel.fromJson(p))
.toList() ??
[],
);
}
factory TourModel.fromMap(Map<String, dynamic> map) {
return TourModel(
id: map['id'] ?? 0,
jobId: map['job_id'] ?? 0,
tourId: map['tour_id'] ?? 0,
version: map['version'] ?? 0,
state: map['state'] ?? 0,
type: map['type'] ?? '',
sort: map['sort'] ?? 0,
locationId: map['loc_id'] ?? 0,
locationCode: map['loc_code'] ?? '',
locationCode2: map['loc_code2'],
remark: map['rem'],
menuText: map['menu'],
modified: map['modified'] ?? 0,
deliveryCode: map['del_code'],
locationName: map['location_name'],
isCompleted: map['state'] == 1,
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'job_id': jobId,
'tour_id': tourId,
'version': version,
'state': state,
'type': type,
'sort': sort,
'loc_id': locationId,
'loc_code': locationCode,
'loc_code2': locationCode2,
'rem': remark,
'menu': menuText,
'modified': modified,
'del_code': deliveryCode,
};
}
TourModel copyWithModel({
int? id,
int? jobId,
int? tourId,
int? version,
int? state,
String? type,
int? sort,
int? locationId,
String? locationCode,
String? locationCode2,
String? remark,
String? menuText,
int? modified,
String? deliveryCode,
String? locationName,
bool? isCompleted,
List<TourPage>? pages,
}) {
return TourModel(
id: id ?? this.id,
jobId: jobId ?? this.jobId,
tourId: tourId ?? this.tourId,
version: version ?? this.version,
state: state ?? this.state,
type: type ?? this.type,
sort: sort ?? this.sort,
locationId: locationId ?? this.locationId,
locationCode: locationCode ?? this.locationCode,
locationCode2: locationCode2 ?? this.locationCode2,
remark: remark ?? this.remark,
menuText: menuText ?? this.menuText,
modified: modified ?? this.modified,
deliveryCode: deliveryCode ?? this.deliveryCode,
locationName: locationName ?? this.locationName,
isCompleted: isCompleted ?? this.isCompleted,
pages: pages ?? this.pages,
);
}
}
class TourPageModel extends TourPage {
const TourPageModel({
required super.id,
required super.tourId,
required super.pageNumber,
required super.pageId,
required super.type,
super.code,
super.label,
super.pickupCounts,
super.swapCounts,
});
factory TourPageModel.fromJson(Map<String, dynamic> json) {
Map<String, int> pickupCounts = {};
Map<String, int> swapCounts = {};
if (json['pickup'] != null && json['pickup']['cnt'] != null) {
final cnt = json['pickup']['cnt'] as Map<String, dynamic>;
pickupCounts = cnt.map((key, value) => MapEntry(key, value as int));
}
if (json['swap'] != null && json['swap']['cnt'] != null) {
final cnt = json['swap']['cnt'] as Map<String, dynamic>;
swapCounts = cnt.map((key, value) => MapEntry(key, value as int));
}
return TourPageModel(
id: json['id'] ?? 0,
tourId: json['tour_id'] ?? 0,
pageNumber: json['page_number'] ?? 0,
pageId: json['page_id'] ?? '',
type: json['type'] ?? '',
code: json['code'],
label: json['lbl'],
pickupCounts: pickupCounts,
swapCounts: swapCounts,
);
}
factory TourPageModel.fromMap(Map<String, dynamic> map) {
return TourPageModel(
id: map['id'] ?? 0,
tourId: map['tour_id'] ?? 0,
pageNumber: map['page_number'] ?? 0,
pageId: map['page_id'] ?? '',
type: map['type'] ?? '',
code: map['code'],
label: map['label'],
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'tour_id': tourId,
'page_number': pageNumber,
'page_id': pageId,
'type': type,
'code': code,
'label': label,
};
}
}