- Equipment DTO 필드명 변경 (name → equipment_number 등) 완료 - Phase 1-7 파생 수정사항 체계적 진행 예정 - 통합 모델 정리, Controller 동기화, UI 업데이트 예정 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
380 lines
11 KiB
Dart
380 lines
11 KiB
Dart
import 'package:superport/utils/constants.dart';
|
|
|
|
// 장비 정보 모델
|
|
class Equipment {
|
|
final int? id;
|
|
final String manufacturer;
|
|
final String name;
|
|
final String category;
|
|
final String subCategory;
|
|
final String subSubCategory;
|
|
final String? serialNumber;
|
|
final String? barcode;
|
|
final int quantity;
|
|
final DateTime? inDate;
|
|
final String? remark; // 비고
|
|
final String? warrantyLicense; // 워런티 라이센스 명
|
|
DateTime? warrantyStartDate; // 워런티 시작일(수정 가능)
|
|
DateTime? warrantyEndDate; // 워런티 종료일(수정 가능)
|
|
|
|
// 백엔드 API 구조 변경으로 추가된 필드들
|
|
final double? purchasePrice; // 구매 가격
|
|
final int? currentCompanyId; // 현재 배치된 회사 ID
|
|
final int? warehouseLocationId; // 현재 창고 위치 ID
|
|
final int? currentBranchId; // 현재 배치된 지점 ID (Deprecated)
|
|
final DateTime? lastInspectionDate; // 최근 점검일
|
|
final DateTime? nextInspectionDate; // 다음 점검일
|
|
final String? equipmentStatus; // 장비 상태
|
|
|
|
// 새로운 백엔드 API 필드들 (컨트롤러 호환성용)
|
|
final String? equipmentNumber; // 장비 번호
|
|
final String? modelName; // 모델명 (name과 동일하지만 명확성을 위해)
|
|
final String? category1; // 대분류 (category와 매핑)
|
|
final String? category2; // 중분류 (subCategory와 매핑)
|
|
final String? category3; // 소분류 (subSubCategory와 매핑)
|
|
final int? companyId; // 구매처 회사 ID
|
|
final DateTime? purchaseDate; // 구매일
|
|
|
|
Equipment({
|
|
this.id,
|
|
required this.manufacturer,
|
|
required this.name,
|
|
required this.category,
|
|
required this.subCategory,
|
|
required this.subSubCategory,
|
|
this.serialNumber,
|
|
this.barcode,
|
|
required this.quantity,
|
|
this.inDate,
|
|
this.remark,
|
|
this.warrantyLicense,
|
|
this.warrantyStartDate,
|
|
this.warrantyEndDate,
|
|
// 새로운 필드들
|
|
this.purchasePrice,
|
|
this.currentCompanyId,
|
|
this.warehouseLocationId,
|
|
this.currentBranchId, // Deprecated
|
|
this.lastInspectionDate,
|
|
this.nextInspectionDate,
|
|
this.equipmentStatus,
|
|
// 백엔드 API 호환성 필드들
|
|
this.equipmentNumber,
|
|
this.modelName,
|
|
this.category1,
|
|
this.category2,
|
|
this.category3,
|
|
this.companyId,
|
|
this.purchaseDate,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'manufacturer': manufacturer,
|
|
'name': name,
|
|
'category': category,
|
|
'subCategory': subCategory,
|
|
'subSubCategory': subSubCategory,
|
|
'serialNumber': serialNumber,
|
|
'barcode': barcode,
|
|
'quantity': quantity,
|
|
'inDate': inDate?.toIso8601String(),
|
|
'remark': remark,
|
|
'warrantyLicense': warrantyLicense,
|
|
'warrantyStartDate': warrantyStartDate?.toIso8601String(),
|
|
'warrantyEndDate': warrantyEndDate?.toIso8601String(),
|
|
// 새로운 필드들
|
|
'purchasePrice': purchasePrice,
|
|
'currentCompanyId': currentCompanyId,
|
|
'warehouseLocationId': warehouseLocationId,
|
|
'currentBranchId': currentBranchId, // Deprecated
|
|
'lastInspectionDate': lastInspectionDate?.toIso8601String(),
|
|
'nextInspectionDate': nextInspectionDate?.toIso8601String(),
|
|
'equipmentStatus': equipmentStatus,
|
|
// 백엔드 API 호환성 필드들
|
|
'equipmentNumber': equipmentNumber,
|
|
'modelName': modelName,
|
|
'category1': category1,
|
|
'category2': category2,
|
|
'category3': category3,
|
|
'companyId': companyId,
|
|
'purchaseDate': purchaseDate?.toIso8601String(),
|
|
};
|
|
}
|
|
|
|
factory Equipment.fromJson(Map<String, dynamic> json) {
|
|
return Equipment(
|
|
id: json['id'],
|
|
manufacturer: json['manufacturer'],
|
|
name: json['name'],
|
|
category: json['category'],
|
|
subCategory: json['subCategory'],
|
|
subSubCategory: json['subSubCategory'],
|
|
serialNumber: json['serialNumber'],
|
|
barcode: json['barcode'],
|
|
quantity: json['quantity'],
|
|
inDate: json['inDate'] != null ? DateTime.parse(json['inDate']) : null,
|
|
remark: json['remark'],
|
|
warrantyLicense: json['warrantyLicense'],
|
|
warrantyStartDate:
|
|
json['warrantyStartDate'] != null
|
|
? DateTime.parse(json['warrantyStartDate'])
|
|
: null,
|
|
warrantyEndDate:
|
|
json['warrantyEndDate'] != null
|
|
? DateTime.parse(json['warrantyEndDate'])
|
|
: null,
|
|
// 새로운 필드들
|
|
purchasePrice: json['purchasePrice']?.toDouble(),
|
|
currentCompanyId: json['currentCompanyId'],
|
|
warehouseLocationId: json['warehouseLocationId'],
|
|
currentBranchId: json['currentBranchId'], // Deprecated
|
|
lastInspectionDate: json['lastInspectionDate'] != null
|
|
? DateTime.parse(json['lastInspectionDate'])
|
|
: null,
|
|
nextInspectionDate: json['nextInspectionDate'] != null
|
|
? DateTime.parse(json['nextInspectionDate'])
|
|
: null,
|
|
equipmentStatus: json['equipmentStatus'],
|
|
// 백엔드 API 호환성 필드들
|
|
equipmentNumber: json['equipmentNumber'],
|
|
modelName: json['modelName'],
|
|
category1: json['category1'],
|
|
category2: json['category2'],
|
|
category3: json['category3'],
|
|
companyId: json['companyId'],
|
|
purchaseDate: json['purchaseDate'] != null
|
|
? DateTime.parse(json['purchaseDate'])
|
|
: null,
|
|
);
|
|
}
|
|
}
|
|
|
|
class EquipmentIn {
|
|
final int? id;
|
|
final Equipment equipment;
|
|
final DateTime inDate;
|
|
final String status; // I (입고)
|
|
final String type; // 장비 유형: '신제품', '중고', '계약'
|
|
final String? warehouseLocation; // 입고지
|
|
final String? partnerCompany; // 파트너사
|
|
final String? remark; // 비고
|
|
|
|
EquipmentIn({
|
|
this.id,
|
|
required this.equipment,
|
|
required this.inDate,
|
|
this.status = 'I',
|
|
this.type = EquipmentType.new_, // 기본값은 '신제품'으로 설정
|
|
this.warehouseLocation,
|
|
this.partnerCompany,
|
|
this.remark,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'equipment': equipment.toJson(),
|
|
'inDate': inDate.toIso8601String(),
|
|
'status': status,
|
|
'type': type,
|
|
'warehouseLocation': warehouseLocation,
|
|
'partnerCompany': partnerCompany,
|
|
'remark': remark,
|
|
};
|
|
}
|
|
|
|
factory EquipmentIn.fromJson(Map<String, dynamic> json) {
|
|
return EquipmentIn(
|
|
id: json['id'],
|
|
equipment: Equipment.fromJson(json['equipment']),
|
|
inDate: DateTime.parse(json['inDate']),
|
|
status: json['status'],
|
|
type: json['type'] ?? EquipmentType.new_,
|
|
warehouseLocation: json['warehouseLocation'],
|
|
partnerCompany: json['partnerCompany'],
|
|
remark: json['remark'],
|
|
);
|
|
}
|
|
}
|
|
|
|
class EquipmentOut {
|
|
final int? id;
|
|
final Equipment equipment;
|
|
final DateTime outDate;
|
|
final String status; // O (출고), I (재입고), R (수리)
|
|
final String? company; // 출고 회사
|
|
final String? manager; // 담당자
|
|
final String? license; // 라이센스
|
|
final DateTime? returnDate; // 재입고/수리 날짜
|
|
final String? returnType; // 재입고/수리 유형
|
|
final String? remark; // 비고
|
|
|
|
EquipmentOut({
|
|
this.id,
|
|
required this.equipment,
|
|
required this.outDate,
|
|
this.status = 'O',
|
|
this.company,
|
|
this.manager,
|
|
this.license,
|
|
this.returnDate,
|
|
this.returnType,
|
|
this.remark,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'equipment': equipment.toJson(),
|
|
'outDate': outDate.toIso8601String(),
|
|
'status': status,
|
|
'company': company,
|
|
'manager': manager,
|
|
'license': license,
|
|
'returnDate': returnDate?.toIso8601String(),
|
|
'returnType': returnType,
|
|
'remark': remark,
|
|
};
|
|
}
|
|
|
|
factory EquipmentOut.fromJson(Map<String, dynamic> json) {
|
|
return EquipmentOut(
|
|
id: json['id'],
|
|
equipment: Equipment.fromJson(json['equipment']),
|
|
outDate: DateTime.parse(json['outDate']),
|
|
status: json['status'],
|
|
company: json['company'],
|
|
manager: json['manager'],
|
|
license: json['license'],
|
|
returnDate:
|
|
json['returnDate'] != null
|
|
? DateTime.parse(json['returnDate'])
|
|
: null,
|
|
returnType: json['returnType'],
|
|
remark: json['remark'],
|
|
);
|
|
}
|
|
}
|
|
|
|
class UnifiedEquipment {
|
|
final int? id;
|
|
final Equipment equipment;
|
|
final DateTime date; // 입고일 또는 출고일
|
|
final String
|
|
status; // 상태 코드: 'I'(입고), 'O'(출고), 'R'(수리중), 'D'(손상), 'L'(분실), 'E'(기타)
|
|
final String? notes; // 추가 비고
|
|
final String? _type; // 내부용: 입고 장비 유형
|
|
|
|
// 백엔드 API 구조 변경으로 추가된 필드들 (리스트 화면용)
|
|
final String? currentCompany; // 현재 회사명
|
|
final String? currentBranch; // 현재 지점명
|
|
final String? warehouseLocation; // 창고 위치
|
|
final DateTime? lastInspectionDate; // 최근 점검일
|
|
final DateTime? nextInspectionDate; // 다음 점검일
|
|
|
|
UnifiedEquipment({
|
|
this.id,
|
|
required this.equipment,
|
|
required this.date,
|
|
required this.status,
|
|
this.notes,
|
|
String? type,
|
|
// 새로운 필드들
|
|
this.currentCompany,
|
|
this.currentBranch,
|
|
this.warehouseLocation,
|
|
this.lastInspectionDate,
|
|
this.nextInspectionDate,
|
|
}) : _type = type;
|
|
|
|
// 장비 유형 반환 (입고 장비만)
|
|
String? get type => status == 'I' ? _type : null;
|
|
|
|
// 장비 상태 텍스트 변환
|
|
String get statusText {
|
|
switch (status) {
|
|
case EquipmentStatus.in_:
|
|
return '입고';
|
|
case EquipmentStatus.out:
|
|
return '출고';
|
|
case EquipmentStatus.rent:
|
|
return '대여';
|
|
case EquipmentStatus.repair:
|
|
return '수리중';
|
|
case EquipmentStatus.damaged:
|
|
return '손상';
|
|
case EquipmentStatus.lost:
|
|
return '분실';
|
|
case EquipmentStatus.etc:
|
|
return '기타';
|
|
default:
|
|
return '알 수 없음';
|
|
}
|
|
}
|
|
|
|
// EquipmentIn 모델에서 변환
|
|
factory UnifiedEquipment.fromEquipmentIn(
|
|
id,
|
|
equipment,
|
|
inDate,
|
|
status, {
|
|
String? type,
|
|
}) {
|
|
return UnifiedEquipment(
|
|
id: id,
|
|
equipment: equipment,
|
|
date: inDate,
|
|
status: status,
|
|
type: type,
|
|
);
|
|
}
|
|
|
|
// EquipmentOut 모델에서 변환
|
|
factory UnifiedEquipment.fromEquipmentOut(id, equipment, outDate, status) {
|
|
return UnifiedEquipment(
|
|
id: id,
|
|
equipment: equipment,
|
|
date: outDate,
|
|
status: status,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'equipment': equipment.toJson(),
|
|
'date': date.toIso8601String(),
|
|
'status': status,
|
|
'notes': notes,
|
|
// 새로운 필드들
|
|
'currentCompany': currentCompany,
|
|
'currentBranch': currentBranch,
|
|
'warehouseLocation': warehouseLocation,
|
|
'lastInspectionDate': lastInspectionDate?.toIso8601String(),
|
|
'nextInspectionDate': nextInspectionDate?.toIso8601String(),
|
|
};
|
|
}
|
|
|
|
factory UnifiedEquipment.fromJson(Map<String, dynamic> json) {
|
|
return UnifiedEquipment(
|
|
id: json['id'],
|
|
equipment: Equipment.fromJson(json['equipment']),
|
|
date: DateTime.parse(json['date']),
|
|
status: json['status'],
|
|
notes: json['notes'],
|
|
// 새로운 필드들
|
|
currentCompany: json['currentCompany'],
|
|
currentBranch: json['currentBranch'],
|
|
warehouseLocation: json['warehouseLocation'],
|
|
lastInspectionDate: json['lastInspectionDate'] != null
|
|
? DateTime.parse(json['lastInspectionDate'])
|
|
: null,
|
|
nextInspectionDate: json['nextInspectionDate'] != null
|
|
? DateTime.parse(json['nextInspectionDate'])
|
|
: null,
|
|
);
|
|
}
|
|
}
|