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,199 @@
import 'package:equatable/equatable.dart';
/// Repräsentiert einen Zählerstand für einen Objekttyp
/// Entspricht der Lua-Logik in CreateLoadingStockStartView etc.
class ObjectCounter extends Equatable {
final String objectType; // z.B. 'meka', 'beka', 'hp1a', etc.
final String label; // z.B. 'MEK', 'BEK', 'H1'
final int currentCount; // Aktueller Bestand (z.B. im Fahrzeug)
final int targetCount; // Soll-Zahl (z.B. Beladezähler)
final int? alternateCount; // Alternative Zählung (z.B. HADAG, CR, SST)
const ObjectCounter({
required this.objectType,
required this.label,
required this.currentCount,
required this.targetCount,
this.alternateCount,
});
bool get isComplete => currentCount >= targetCount;
bool get isOver => currentCount > targetCount;
int get difference => targetCount - currentCount;
@override
List<Object?> get props => [objectType, label, currentCount, targetCount, alternateCount];
}
/// Gruppen von Zählern für verschiedene Ansichten
class CounterGroup extends Equatable {
final String title;
final List<ObjectCounter> counters;
const CounterGroup({
required this.title,
required this.counters,
});
@override
List<Object?> get props => [title, counters];
}
/// Zähler-Übersicht für eine komplette Tour/Page
class CounterOverview extends Equatable {
final int tourId;
final String? pageId;
final List<CounterGroup> groups;
final DateTime? lastUpdated;
const CounterOverview({
required this.tourId,
this.pageId,
required this.groups,
this.lastUpdated,
});
/// Standard-Gruppen für StockStart (Lager Beladung)
/// Entspricht Lua: CreateLoadingStockStartView
factory CounterOverview.stockStart({
required int tourId,
required List<ObjectCounter> vehicleStock, // Bestand Fzg
required List<ObjectCounter> loadingCounters, // Beladezähler
required List<ObjectCounter> hadagCounters, // HADAG
required List<ObjectCounter> sstCounters, // SST
required List<ObjectCounter> crCounters, // CR
}) {
return CounterOverview(
tourId: tourId,
groups: [
CounterGroup(title: 'Bestand Fzg', counters: vehicleStock),
CounterGroup(title: 'Beladezähler', counters: loadingCounters),
CounterGroup(title: 'HADAG', counters: hadagCounters),
CounterGroup(title: 'SST', counters: sstCounters),
CounterGroup(title: 'CR', counters: crCounters),
],
);
}
/// Standard-Gruppen für VehStart
/// Entspricht Lua: CreateLoadingVehStartView
factory CounterOverview.vehStart({
required int tourId,
required List<ObjectCounter> loadingCounters,
}) {
return CounterOverview(
tourId: tourId,
groups: [
CounterGroup(title: 'Beladezähler', counters: loadingCounters),
],
);
}
/// Standard-Gruppen für Veh (Station)
/// Entspricht Lua: CreateLoadingVehView
factory CounterOverview.veh({
required int tourId,
String? pageId,
required List<ObjectCounter> swapCounters, // Wechselzähler
required List<ObjectCounter> pickupCounters, // Abholzähler
}) {
return CounterOverview(
tourId: tourId,
pageId: pageId,
groups: [
CounterGroup(title: 'Wechsel', counters: swapCounters),
CounterGroup(title: 'Abholung', counters: pickupCounters),
],
);
}
@override
List<Object?> get props => [tourId, pageId, groups, lastUpdated];
}
/// Pickup/Abhol-Zähler aus der Datenbank
/// Entspricht Lua: page_pickup_count Tabelle
class PickupCount extends Equatable {
final int tourId;
final String pageId;
final String objectType;
final int count;
const PickupCount({
required this.tourId,
required this.pageId,
required this.objectType,
required this.count,
});
@override
List<Object?> get props => [tourId, pageId, objectType, count];
}
/// Swap/Wechsel-Zähler aus der Datenbank
/// Entspricht Lua: page_swap_count Tabelle
class SwapCount extends Equatable {
final int tourId;
final String pageId;
final String objectType;
final int count;
const SwapCount({
required this.tourId,
required this.pageId,
required this.objectType,
required this.count,
});
@override
List<Object?> get props => [tourId, pageId, objectType, count];
}
/// Container-Information für VS/Verwahrungsstelle
/// Entspricht Lua: ContainerId, ContainerType in vsStateMachine
class ContainerInfo extends Equatable {
final String containerId;
final String containerType; // 'a' = Geldinstitut, 'b' = Dienststelle
final String? subtype; // 'cntra' oder 'cntrb'
final int? objectCount; // Anzahl Objekte im Container
const ContainerInfo({
required this.containerId,
required this.containerType,
this.subtype,
this.objectCount,
});
bool get isForGI => containerType == 'a';
bool get isForDS => containerType == 'b';
String get displayName {
if (isForGI) return 'Container Geldinstitut';
if (isForDS) return 'Container Dienststelle';
return 'Container $containerId';
}
@override
List<Object?> get props => [containerId, containerType, subtype, objectCount];
}
/// Letzte gescannte Objekte für die Anzeige
/// Entspricht Lua: Die Liste in ShowStockStartScreen etc.
class RecentScan extends Equatable {
final String objectCode;
final String objectName;
final String state;
final DateTime scanTime;
final String? imageName;
const RecentScan({
required this.objectCode,
required this.objectName,
required this.state,
required this.scanTime,
this.imageName,
});
@override
List<Object?> get props => [objectCode, objectName, state, scanTime, imageName];
}

View File

@@ -0,0 +1,89 @@
import 'package:equatable/equatable.dart';
class Location extends Equatable {
final int id;
final int locationId;
final int version;
final String name;
final String? street;
final String? number;
final String? zip;
final String? city;
final double? latitude;
final double? longitude;
final String? remark;
const Location({
required this.id,
required this.locationId,
required this.version,
required this.name,
this.street,
this.number,
this.zip,
this.city,
this.latitude,
this.longitude,
this.remark,
});
Location copyWith({
int? id,
int? locationId,
int? version,
String? name,
String? street,
String? number,
String? zip,
String? city,
double? latitude,
double? longitude,
String? remark,
}) {
return Location(
id: id ?? this.id,
locationId: locationId ?? this.locationId,
version: version ?? this.version,
name: name ?? this.name,
street: street ?? this.street,
number: number ?? this.number,
zip: zip ?? this.zip,
city: city ?? this.city,
latitude: latitude ?? this.latitude,
longitude: longitude ?? this.longitude,
remark: remark ?? this.remark,
);
}
String get fullAddress {
final parts = <String>[];
if (street != null && street!.isNotEmpty) {
parts.add(street!);
if (number != null && number!.isNotEmpty) {
parts.add(number!);
}
}
if (zip != null && zip!.isNotEmpty) {
parts.add(zip!);
}
if (city != null && city!.isNotEmpty) {
parts.add(city!);
}
return parts.join(', ');
}
@override
List<Object?> get props => [
id,
locationId,
version,
name,
street,
number,
zip,
city,
latitude,
longitude,
remark,
];
}

View File

@@ -0,0 +1,250 @@
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
class LogisticObject extends Equatable {
final int id;
final int objectId;
final int type;
final int version;
final int? locationId;
final String code;
final String? remark;
final String state;
final String subtype;
final String? origin;
final bool isManual;
final DateTime? lastModified;
final String? typeName;
final String? typeMnemonic;
const LogisticObject({
required this.id,
required this.objectId,
required this.type,
required this.version,
this.locationId,
required this.code,
this.remark,
required this.state,
required this.subtype,
this.origin,
this.isManual = false,
this.lastModified,
this.typeName,
this.typeMnemonic,
});
LogisticObject copyWith({
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 LogisticObject(
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,
);
}
@override
List<Object?> get props => [
id,
objectId,
type,
version,
locationId,
code,
remark,
state,
subtype,
origin,
isManual,
lastModified,
typeName,
typeMnemonic,
];
}
class ObjectMetadata extends Equatable {
final int id;
final int type;
final int version;
final String mnemonic;
final String name;
final String prefix;
final String subtype;
final String counterText;
const ObjectMetadata({
required this.id,
required this.type,
required this.version,
required this.mnemonic,
required this.name,
required this.prefix,
required this.subtype,
required this.counterText,
});
@override
List<Object?> get props => [
id,
type,
version,
mnemonic,
name,
prefix,
subtype,
counterText,
];
}
class ObjectStateInfo {
final String state;
final String displayName;
final int colorValue;
final String iconName;
const ObjectStateInfo({
required this.state,
required this.displayName,
required this.colorValue,
required this.iconName,
});
static const Map<String, ObjectStateInfo> stateInfos = {
'unknown': ObjectStateInfo(
state: 'unknown',
displayName: 'Unbekannt',
colorValue: 0xFFFFFFFF,
iconName: 'help',
),
'delivery': ObjectStateInfo(
state: 'delivery',
displayName: 'Im Fahrzeug',
colorValue: 0xFFB3B3B3,
iconName: 'local_shipping',
),
'to_delivery': ObjectStateInfo(
state: 'to_delivery',
displayName: 'Zum Fahrzeug',
colorValue: 0xFFB3B3B3,
iconName: 'local_shipping_outlined',
),
'station': ObjectStateInfo(
state: 'station',
displayName: 'An Station',
colorValue: 0xFFFFDD00,
iconName: 'location_on',
),
'in_fa': ObjectStateInfo(
state: 'in_fa',
displayName: 'Im Fahrscheinautomat',
colorValue: 0xFF9CDA7A,
iconName: 'confirmation_number',
),
'in_vs': ObjectStateInfo(
state: 'in_vs',
displayName: 'In Versorgungsstelle',
colorValue: 0xFFFAE14B,
iconName: 'inventory',
),
'ret_fail': ObjectStateInfo(
state: 'ret_fail',
displayName: 'Fehler - zur Dienststelle',
colorValue: 0xFFFF9081,
iconName: 'error',
),
'ret_fail_fzg': ObjectStateInfo(
state: 'ret_fail_fzg',
displayName: 'Fehler - im Fahrzeug',
colorValue: 0xFFFF9081,
iconName: 'error_outline',
),
'ret_ds': ObjectStateInfo(
state: 'ret_ds',
displayName: 'Zur Dienststelle',
colorValue: 0xFFAFE0ED,
iconName: 'account_balance',
),
'ret_ds_fzg': ObjectStateInfo(
state: 'ret_ds_fzg',
displayName: 'Zur Dienststelle (Fzg)',
colorValue: 0xFFAFE0ED,
iconName: 'account_balance_outlined',
),
'ret_gi': ObjectStateInfo(
state: 'ret_gi',
displayName: 'Zum Geldinstitut',
colorValue: 0xFFAFE0ED,
iconName: 'account_balance_wallet',
),
'ret_gi_fzg': ObjectStateInfo(
state: 'ret_gi_fzg',
displayName: 'Zum Geldinstitut (Fzg)',
colorValue: 0xFFAFE0ED,
iconName: 'account_balance_wallet_outlined',
),
'fin_ds': ObjectStateInfo(
state: 'fin_ds',
displayName: 'In Dienststelle',
colorValue: 0xFF29B7FB,
iconName: 'check_circle',
),
'fin_gi': ObjectStateInfo(
state: 'fin_gi',
displayName: 'In Geldinstitut',
colorValue: 0xFF25BAFC,
iconName: 'check_circle_outline',
),
'hdl': ObjectStateInfo(
state: 'hdl',
displayName: 'Handel',
colorValue: 0xFF9E9E9E,
iconName: 'shopping_cart',
),
'ret_ds_empty': ObjectStateInfo(
state: 'ret_ds_empty',
displayName: 'Leer - zur Dienststelle',
colorValue: 0xFFAFE0ED,
iconName: 'remove_circle_outline',
),
};
static Color getColorForState(String state) {
final info = stateInfos[state];
return info != null ? Color(info.colorValue) : const Color(0xFFFFFFFF);
}
static String getDisplayName(String state) {
final info = stateInfos[state];
return info?.displayName ?? 'Unbekannt';
}
static String getIconName(String state) {
final info = stateInfos[state];
return info?.iconName ?? 'help';
}
}

View File

@@ -0,0 +1,163 @@
import 'package:equatable/equatable.dart';
class Tour extends Equatable {
final int id;
final int jobId;
final int tourId;
final int version;
final int state; // 0 = offen, 1 = erledigt, 2 = abgeschlossen
final String type;
final int sort;
final int locationId;
final String locationCode;
final String? locationCode2;
final String? remark;
final String? menuText;
final int modified;
final String? deliveryCode;
final String? locationName;
final bool isCompleted;
final List<TourPage> pages;
const Tour({
required this.id,
required this.jobId,
required this.tourId,
required this.version,
required this.state,
required this.type,
required this.sort,
required this.locationId,
required this.locationCode,
this.locationCode2,
this.remark,
this.menuText,
required this.modified,
this.deliveryCode,
this.locationName,
this.isCompleted = false,
this.pages = const [],
});
Tour copyWith({
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 Tour(
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,
);
}
@override
List<Object?> get props => [
id,
jobId,
tourId,
version,
state,
type,
sort,
locationId,
locationCode,
locationCode2,
remark,
menuText,
modified,
deliveryCode,
locationName,
isCompleted,
pages,
];
}
class TourPage extends Equatable {
final int id;
final int tourId;
final int pageNumber;
final String pageId;
final String type;
final String? code;
final String? label;
final Map<String, int> pickupCounts;
final Map<String, int> swapCounts;
const TourPage({
required this.id,
required this.tourId,
required this.pageNumber,
required this.pageId,
required this.type,
this.code,
this.label,
this.pickupCounts = const {},
this.swapCounts = const {},
});
TourPage copyWith({
int? id,
int? tourId,
int? pageNumber,
String? pageId,
String? type,
String? code,
String? label,
Map<String, int>? pickupCounts,
Map<String, int>? swapCounts,
}) {
return TourPage(
id: id ?? this.id,
tourId: tourId ?? this.tourId,
pageNumber: pageNumber ?? this.pageNumber,
pageId: pageId ?? this.pageId,
type: type ?? this.type,
code: code ?? this.code,
label: label ?? this.label,
pickupCounts: pickupCounts ?? this.pickupCounts,
swapCounts: swapCounts ?? this.swapCounts,
);
}
@override
List<Object?> get props => [
id,
tourId,
pageNumber,
pageId,
type,
code,
label,
pickupCounts,
swapCounts,
];
}