verifyVehicleForOpenGateOnWeighing method
Future<void>
verifyVehicleForOpenGateOnWeighing(
- String eqCode
)
Implementation
Future<void> verifyVehicleForOpenGateOnWeighing(String eqCode) async {
nextEqCode = '';
vehicleImage = '';
selectedEqCode = eqCode;
isOpenGatemanually.value = false;
if (tblTRLoadingTO.value?.vehicleNo == null ||
tblTRLoadingWeighingTO.weighingMachineId == null) {
return;
}
isLoading(true);
bool? vehicleIn;
if (loadingTypeId == 1) {
vehicleIn = (tblTRLoadingTO.value?.statusId ==
LoadingStatusInternalTransferE.loading1stWeighing.value);
} else if (loadingTypeId == 2) {
vehicleIn = (tblTRLoadingTO.value?.statusId ==
LoadingStatusInternalTransferE.unloading1stWeighing.value);
}
final Map<String, dynamic> params = {
'Wbid': tblTRLoadingWeighingTO.weighingMachineId ?? 0,
'IsOpen': true,
'EqCode': eqCode,
'VehicalIn': vehicleIn,
'VehicleNumber': tblTRLoadingTO.value?.vehicleNo?.replaceAll(' ', ''),
// 'VehicleNumber': 'MH03DV9030',
'ModuleId': 23,
'VehicleId': tblTRLoadingTO.value?.idLoading,
'LoadingTypeId': loadingTypeId.value,
'IsManualOpen': false,
'UserId':
int.tryParse(GetIt.I<StorageUtils>().getUserId().toString()) ?? 0
};
try {
final response =
await _apiService.postData(AppUrls.weighingGateEvent, data: params);
isLoading(false);
if (eqCode == 'BBO') {
nextEqCode = 'BBI';
} else {
nextEqCode = 'BBO';
}
if (response.data['Tag'] != null && response.data['Result'] == 1) {
AppUtils.showSnackBar(
'Vehicle No:-${tblTRLoadingTO.value?.vehicleNo} verified');
vehicleImage = "data:image/png;base64,${response.data['Tag']}";
showVerifiedVehicleImageModal();
} else if (response.data['Result'] == 2) {
vehicleImage = "data:image/png;base64,${response.data['Tag']}";
isOpenGatemanually.value = true;
AppUtils.showSnackBar((response.data['DisplayMessage']));
showConfirmationForOpenGate();
}
} catch (error) {
isOpenGatemanually.value = true;
AppUtils.showSnackBar(
'Vehicle No:-${tblTRLoadingTO.value?.vehicleNo} not found on weighing bridge ${tblTRLoadingWeighingTO.machineName}');
showConfirmationForOpenGate();
isLoading(false);
}
}