XuGongTeJi_flutter/lib/model/bo/stock_in_data_xugong.dart
2025-02-23 16:19:27 +08:00

128 lines
3.8 KiB
Dart

import 'package:intl/intl.dart';
class StockInDataXuGong {
String recordId = "";
String listId = "";
String orderType = ""; // 单据类型
String customerId = "";
String orderId = "test"; // 单据号
String vehicleNo = "";
String goodsId = ""; // 物料号
int goodsNum = 0; // 物料数量
String goodsCode = "";
String goodsDesc = ""; // 物料描述
String unit = "";
String spare1 = ""; // 备用1
String spare2 = ""; // 备用2
int status = 0;
int storageType = 0;
String createPerson = "empty";
String remark = "test";
DateTime createTime = DateTime.now();
DateTime updateTime = DateTime.now();
double weight = 0; // 重量
String customerName = ""; // 客户名称
String size = ""; // 尺寸
String containerNo = ""; // 容器号
StockInDataXuGong({
required this.recordId,
required this.goodsId,
required this.goodsNum,
required this.orderId,
required this.orderType,
required this.goodsDesc,
required this.weight,
required this.size,
required this.customerName,
required this.containerNo,
required this.spare1,
required this.spare2,
required this.vehicleNo,
required this.customerId,
required this.goodsCode,
required this.listId,
required this.unit,
required this.status,
required this.storageType,
required this.createPerson,
required this.remark,
required this.createTime,
required this.updateTime,
});
// Updated fromJson method
factory StockInDataXuGong.fromJson(Map<String, dynamic> json) {
return StockInDataXuGong(
containerNo: json["containerNo"] ?? "0",
customerName: json["customerName"] ?? "",
listId: json["listId"] ?? "",
customerId: json["customerId"] ?? "",
recordId: json["recordId"] ?? "",
goodsId: json["goodsId"] ?? "",
// 物料号
vehicleNo: json["vehicleNo"] ?? "",
// 物料号
goodsNum: json["goodsNum"] ?? 10.0,
// 物料数量
orderId: json["orderId"] ?? "",
// 单据号
orderType: json["orderType"] ?? "",
// 单据类型
goodsCode: json["goodsCode"] ?? "",
// customerName: json["customerName"] ?? "", // 客户名称
goodsDesc: json["goodsDesc"] ?? "",
// 物料描述
// weight: json["weight"]?.toDouble() ?? 0.0, // 重量
// size: json["size"] ?? "", // 尺寸
// containerNo: json["containerNo"] ?? "",
// 容器号
spare1: json["spare1"] ?? "",
// 备用1
spare2: json["spare2"] ?? "",
// 备用2
unit: json["unit"] ?? "",
status: json["status"] ?? 0,
storageType: json["storageType"] ?? 0,
createPerson: json["createPerson"] ?? "",
remark: json["remark"] ?? "",
createTime: json["createTime"] ?? DateTime.now(),
updateTime: json["updateTime"] ?? DateTime.now(),
weight: json["weight"] ?? 10.0,
size: json["size"] ?? "50",
);
}
// 实现 toJson 方法
Map<String, dynamic> toJson() {
String formattedCreateDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(createTime);
String formattedUpdateDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(updateTime);
return {
"recordId": recordId,
"listId": listId,
"orderType": orderType,
"customerId": customerId,
"orderId": orderId,
"vehicleNo": vehicleNo,
"goodsId": goodsId,
"goodsNum": goodsNum,
"goodsCode": goodsCode,
"goodsDesc": goodsDesc,
"unit": unit,
"spare1": spare1,
"spare2": spare2,
"status": status,
"storageType": storageType,
"createPerson": createPerson,
"remark": remark,
"createTime": formattedCreateDate,
"updateTime": formattedUpdateDate,
"weight": weight,
"customerName": customerName,
"size": size,
"containerNo": containerNo,
};
}
}