feat(registration): merge shelf overview into registration
This commit is contained in:
@@ -46,6 +46,76 @@ class RegistrationResult {
|
||||
RegistrationResult(success: false, errorMessage: message);
|
||||
}
|
||||
|
||||
class PaichaOverviewItem {
|
||||
final String zongpaiNo;
|
||||
final String? workOrderNo;
|
||||
final int quantity;
|
||||
final String? locationCode;
|
||||
final String status;
|
||||
|
||||
PaichaOverviewItem({
|
||||
required this.zongpaiNo,
|
||||
this.workOrderNo,
|
||||
required this.quantity,
|
||||
this.locationCode,
|
||||
required this.status,
|
||||
});
|
||||
|
||||
factory PaichaOverviewItem.fromJson(Map<String, dynamic> json) {
|
||||
return PaichaOverviewItem(
|
||||
zongpaiNo: json['zongpai_no'] as String,
|
||||
workOrderNo: json['work_order_no']?.toString(),
|
||||
quantity: json['quantity'] as int? ?? 0,
|
||||
locationCode: json['location_code']?.toString(),
|
||||
status: json['status']?.toString() ?? 'not_shelved',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PaichaOverviewResult {
|
||||
final bool success;
|
||||
final bool notFound;
|
||||
final String? errorMessage;
|
||||
final String? paichaNo;
|
||||
final int totalCount;
|
||||
final List<PaichaOverviewItem> items;
|
||||
|
||||
PaichaOverviewResult({
|
||||
required this.success,
|
||||
this.notFound = false,
|
||||
this.errorMessage,
|
||||
this.paichaNo,
|
||||
this.totalCount = 0,
|
||||
this.items = const [],
|
||||
});
|
||||
|
||||
factory PaichaOverviewResult.ok(Map<String, dynamic> json) {
|
||||
final items =
|
||||
(json['items'] as List<dynamic>?)
|
||||
?.map(
|
||||
(item) =>
|
||||
PaichaOverviewItem.fromJson(item as Map<String, dynamic>),
|
||||
)
|
||||
.toList() ??
|
||||
[];
|
||||
return PaichaOverviewResult(
|
||||
success: true,
|
||||
paichaNo: json['paicha_no'] as String?,
|
||||
totalCount: json['total_count'] as int? ?? items.length,
|
||||
items: items,
|
||||
);
|
||||
}
|
||||
|
||||
factory PaichaOverviewResult.notFoundResult() => PaichaOverviewResult(
|
||||
success: false,
|
||||
notFound: true,
|
||||
errorMessage: '暂无排产信息',
|
||||
);
|
||||
|
||||
factory PaichaOverviewResult.error(String message) =>
|
||||
PaichaOverviewResult(success: false, errorMessage: message);
|
||||
}
|
||||
|
||||
// === 装箱模块数据类 ===
|
||||
|
||||
/// 箱号内单个总排号明细
|
||||
@@ -290,6 +360,34 @@ class ApiService {
|
||||
}
|
||||
}
|
||||
|
||||
Future<PaichaOverviewResult> fetchPaichaOverview({
|
||||
required String baseUrl,
|
||||
required String zongpaiNo,
|
||||
}) async {
|
||||
final uri = Uri.parse(
|
||||
'$baseUrl/CargoTrace/location/paicha-overview',
|
||||
).replace(queryParameters: {'zongpai_no': zongpaiNo});
|
||||
try {
|
||||
final response = await _client
|
||||
.get(uri, headers: {'Content-Type': 'application/json'})
|
||||
.timeout(timeout);
|
||||
|
||||
switch (response.statusCode) {
|
||||
case 200:
|
||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
return PaichaOverviewResult.ok(body);
|
||||
case 400:
|
||||
return PaichaOverviewResult.error('无效的总排号格式');
|
||||
case 404:
|
||||
return PaichaOverviewResult.notFoundResult();
|
||||
default:
|
||||
return PaichaOverviewResult.error('加载失败,点击重试');
|
||||
}
|
||||
} catch (e) {
|
||||
return PaichaOverviewResult.error('加载失败,点击重试');
|
||||
}
|
||||
}
|
||||
|
||||
/// 查询装箱信息 — GET /CargoTrace/box/info
|
||||
Future<BoxInfoResult> fetchBoxInfo({
|
||||
required String baseUrl,
|
||||
|
||||
Reference in New Issue
Block a user