feat: enhance boxing module with box mode support and fix Android build
- Add box_mode parameter to box submission API for one-to-one/one-to-many/many-to-one modes - Allow re-scan override in one2one mode without clearing state - Improve duplicate detection messages per boxing mode - Disable Kotlin incremental compilation to fix cross-drive build failure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,11 +15,14 @@ class RegistrationResult {
|
||||
this.duplicateInfo,
|
||||
});
|
||||
|
||||
factory RegistrationResult.ok() =>
|
||||
RegistrationResult(success: true);
|
||||
factory RegistrationResult.ok() => RegistrationResult(success: true);
|
||||
|
||||
factory RegistrationResult.duplicate(Map<String, dynamic> info) =>
|
||||
RegistrationResult(success: false, isDuplicate: true, duplicateInfo: info);
|
||||
RegistrationResult(
|
||||
success: false,
|
||||
isDuplicate: true,
|
||||
duplicateInfo: info,
|
||||
);
|
||||
|
||||
factory RegistrationResult.error(String message) =>
|
||||
RegistrationResult(success: false, errorMessage: message);
|
||||
@@ -50,7 +53,8 @@ class BoxDetailData {
|
||||
BoxDetailData({required this.boxNo, required this.items});
|
||||
|
||||
factory BoxDetailData.fromJson(Map<String, dynamic> json) {
|
||||
final items = (json['items'] as List<dynamic>?)
|
||||
final items =
|
||||
(json['items'] as List<dynamic>?)
|
||||
?.map((i) => BoxItemData.fromJson(i as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[];
|
||||
@@ -81,7 +85,8 @@ class BoxInfoResult {
|
||||
});
|
||||
|
||||
factory BoxInfoResult.ok(Map<String, dynamic> json) {
|
||||
final boxes = (json['existing_boxes'] as List<dynamic>?)
|
||||
final boxes =
|
||||
(json['existing_boxes'] as List<dynamic>?)
|
||||
?.map((b) => BoxDetailData.fromJson(b as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[];
|
||||
@@ -144,7 +149,7 @@ class ApiService {
|
||||
final Duration timeout;
|
||||
|
||||
ApiService({http.Client? client, this.timeout = const Duration(seconds: 5)})
|
||||
: _client = client ?? http.Client();
|
||||
: _client = client ?? http.Client();
|
||||
|
||||
/// Submit a shelf registration (上架登记).
|
||||
Future<RegistrationResult> registerLocation({
|
||||
@@ -177,7 +182,10 @@ class ApiService {
|
||||
return RegistrationResult.duplicate(body);
|
||||
default:
|
||||
final body = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
final msg = body['message'] ?? body['error'] ?? 'Unknown error (${response.statusCode})';
|
||||
final msg =
|
||||
body['message'] ??
|
||||
body['error'] ??
|
||||
'Unknown error (${response.statusCode})';
|
||||
return RegistrationResult.error(msg.toString());
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -190,9 +198,9 @@ class ApiService {
|
||||
required String baseUrl,
|
||||
required String zongpaiNo,
|
||||
}) async {
|
||||
final uri = Uri.parse('$baseUrl/CargoTrace/box/info').replace(
|
||||
queryParameters: {'zongpai_no': zongpaiNo},
|
||||
);
|
||||
final uri = Uri.parse(
|
||||
'$baseUrl/CargoTrace/box/info',
|
||||
).replace(queryParameters: {'zongpai_no': zongpaiNo});
|
||||
try {
|
||||
final response = await _client
|
||||
.get(uri, headers: {'Content-Type': 'application/json'})
|
||||
@@ -220,6 +228,7 @@ class ApiService {
|
||||
required String zongpaiNo,
|
||||
required int boxNo,
|
||||
required int quantity,
|
||||
required String boxMode,
|
||||
}) async {
|
||||
final uri = Uri.parse('$baseUrl/CargoTrace/box');
|
||||
try {
|
||||
@@ -231,6 +240,7 @@ class ApiService {
|
||||
'zongpai_no': zongpaiNo,
|
||||
'box_no': boxNo,
|
||||
'quantity': quantity,
|
||||
'box_mode': boxMode,
|
||||
}),
|
||||
)
|
||||
.timeout(timeout);
|
||||
|
||||
Reference in New Issue
Block a user