fix: 调整蓝牙开锁后直接同步上传卡片、密码、指纹人脸

This commit is contained in:
liyi 2025-09-12 10:21:07 +08:00
parent 393ee9d2bc
commit 4d60ea4535
4 changed files with 796 additions and 1642 deletions

View File

@ -155,8 +155,10 @@ class LockDetailLogic extends BaseGetXController {
} }
// //
if (state.keyInfos.value.keyType == 3) { if (state.keyInfos.value.keyType == 3) {
final LockListInfoEntity entity = await ApiRepository.to final LockListInfoEntity entity = await ApiRepository.to.deletOwnerKeyData(
.deletOwnerKeyData(lockId: state.keyInfos.value.lockId.toString(), keyId: state.keyInfos.value!.keyId.toString(), includeUnderlings: 0); lockId: state.keyInfos.value.lockId.toString(),
keyId: state.keyInfos.value!.keyId.toString(),
includeUnderlings: 0);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
AppLog.log("删除成功"); AppLog.log("删除成功");
} }
@ -408,9 +410,13 @@ class LockDetailLogic extends BaseGetXController {
indexMap['success'] = '1'; indexMap['success'] = '1';
final int time = (0xff & indexList[3]) << 24 | (0xff & indexList[4]) << 16 | (0xff & indexList[5]) << 8 | (0xFF & indexList[6]); final int time = (0xff & indexList[3]) << 24 |
(0xff & indexList[4]) << 16 |
(0xff & indexList[5]) << 8 |
(0xFF & indexList[6]);
int operateDate = time * 1000; int operateDate = time * 1000;
if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(DateTime.fromMillisecondsSinceEpoch(getUTCNetTime() * 1000))) { if (DateTime.fromMillisecondsSinceEpoch(operateDate)
.isAfter(DateTime.fromMillisecondsSinceEpoch(getUTCNetTime() * 1000))) {
continue; continue;
} }
@ -483,11 +489,13 @@ class LockDetailLogic extends BaseGetXController {
resetOpenDoorState(); resetOpenDoorState();
blueManageDisconnect(); blueManageDisconnect();
BuglyTool.uploadException(message: '开门超时处理-开锁失败', detail: '开门超时,断开连接,开锁失败--OpenLockCommand:$command', upload: true); BuglyTool.uploadException(
message: '开门超时处理-开锁失败', detail: '开门超时,断开连接,开锁失败--OpenLockCommand:$command', upload: true);
}, },
); );
BlueManage().blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { BlueManage().blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
BuglyTool.uploadException(message: '蓝牙连接成功', detail: '蓝牙连接成功,发送开锁指令--OpenLockCommand:$command', upload: false); BuglyTool.uploadException(message: '蓝牙连接成功', detail: '蓝牙连接成功,发送开锁指令--OpenLockCommand:$command', upload: false);
// FlutterBuglyPlugin.reportException(exceptionName: '蓝牙连接成功', reason: '蓝牙连接成功,发送开锁指令'); // FlutterBuglyPlugin.reportException(exceptionName: '蓝牙连接成功', reason: '蓝牙连接成功,发送开锁指令');
@ -504,7 +512,8 @@ class LockDetailLogic extends BaseGetXController {
); );
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) { } else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
BuglyTool.uploadException(message: '蓝牙连接失败-开锁失败', detail: '蓝牙连接失败,断开连接, 开锁失败--OpenLockCommand:$command', upload: true); BuglyTool.uploadException(
message: '蓝牙连接失败-开锁失败', detail: '蓝牙连接失败,断开连接, 开锁失败--OpenLockCommand:$command', upload: true);
final String getMobile = (await Storage.getMobile())!; final String getMobile = (await Storage.getMobile())!;
ApmHelper.instance.trackEvent('open_lock', { ApmHelper.instance.trackEvent('open_lock', {
'lock_name': state.keyInfos.value.lockName!, 'lock_name': state.keyInfos.value.lockName!,
@ -526,7 +535,7 @@ class LockDetailLogic extends BaseGetXController {
//便 //便
closeLuckStatus(); closeLuckStatus();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
await BlueManage().disconnect(); // await BlueManage().disconnect();
} }
// () // ()
@ -679,8 +688,9 @@ class LockDetailLogic extends BaseGetXController {
/// ///
void initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() { void initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() {
// eventBus // eventBus
state.lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = state.lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus
eventBus.on<LockSetChangeSetRefreshLockDetailWithType>().listen((LockSetChangeSetRefreshLockDetailWithType event) { .on<LockSetChangeSetRefreshLockDetailWithType>()
.listen((LockSetChangeSetRefreshLockDetailWithType event) {
if (event.type == 0) { if (event.type == 0) {
// 0 // 0
state.isAttendance.value = int.parse(event.setResult); state.isAttendance.value = int.parse(event.setResult);
@ -795,8 +805,9 @@ class LockDetailLogic extends BaseGetXController {
void onInit() { void onInit() {
super.onInit(); super.onInit();
state.LockSetChangeSetRefreshLockDetailWithTypeSubscription = state.LockSetChangeSetRefreshLockDetailWithTypeSubscription = eventBus
eventBus.on<LockSetChangeSetRefreshLockDetailWithType>().listen((LockSetChangeSetRefreshLockDetailWithType event) { .on<LockSetChangeSetRefreshLockDetailWithType>()
.listen((LockSetChangeSetRefreshLockDetailWithType event) {
// //
if (event.type == 1) { if (event.type == 1) {
state.isOpenLockNeedOnline.value = int.parse(event.setResult); state.isOpenLockNeedOnline.value = int.parse(event.setResult);
@ -812,7 +823,8 @@ class LockDetailLogic extends BaseGetXController {
} }
}); });
state.DetailLockInfo = eventBus.on<PassCurrentLockInformationEvent>().listen((PassCurrentLockInformationEvent event) { state.DetailLockInfo =
eventBus.on<PassCurrentLockInformationEvent>().listen((PassCurrentLockInformationEvent event) {
// //
final lockSettingInfo = event.lockSetInfoData.lockSettingInfo; final lockSettingInfo = event.lockSetInfoData.lockSettingInfo;
final lockBasicInfo = event.lockSetInfoData.lockBasicInfo; final lockBasicInfo = event.lockSetInfoData.lockBasicInfo;
@ -865,79 +877,48 @@ class LockDetailLogic extends BaseGetXController {
// //
Future<void> _lockDataUpload({required int uploadType, required int recordType, required List records}) async { Future<void> _lockDataUpload({required int uploadType, required int recordType, required List records}) async {
if (records.length == 0) return; //
final LoginEntity entity = await ApiRepository.to.lockDataUpload( print('uploadType:${uploadType} recordType:${recordType} records:${records}');
// records是否为空都继续执行
await ApiRepository.to.lockDataUpload(
lockId: CommonDataManage().currentKeyInfo.lockId!, lockId: CommonDataManage().currentKeyInfo.lockId!,
uploadType: uploadType, uploadType: uploadType,
recordType: recordType, recordType: recordType,
records: records, records: records,
isUnShowLoading: true, isUnShowLoading: true,
isShowNetworkErrorMsg: false,
); );
if (entity.errorCode!.codeIsSuccessful) { //
if (uploadType == 1) { if (uploadType == 1) {
// 1 // 1
state.indexCount.value = 0;
} else {
// 2
switch (recordType) {
case 2:
//
_handleGetLockCardData();
break;
case 3:
// IC卡上传成功
_handleGetLockFingerprintData();
break;
case 4:
//
_handleGetLockFaceData();
break;
case 5:
//
_handleGetLockPalmVeinData();
break;
case 6:
//
_handleGetLockRemoteControlData();
break;
default:
break;
}
}
} else {
if (uploadType == 1) {
// 1
// state.indexCount.value = 0;
// state.sureBtnState.value = 0;
// showToast('上传成功'.tr);
} else {
// 2
switch (recordType) {
case 2:
//
_handleGetLockCardData();
break;
case 3:
// IC卡上传成功
_handleGetLockFingerprintData();
break;
case 4:
//
_handleGetLockFaceData();
break;
case 5:
//
_handleGetLockPalmVeinData();
break;
case 6:
//
_handleGetLockRemoteControlData();
break;
default:
break;
}
}
state.indexCount.value = 0; state.indexCount.value = 0;
} else {
// 2
switch (recordType) {
case 2:
//
_handleGetLockCardData();
break;
case 3:
// IC卡上传成功
_handleGetLockFingerprintData();
break;
case 4:
//
_handleGetLockFaceData();
break;
case 5:
//
_handleGetLockPalmVeinData();
break;
case 6:
//
_handleGetLockRemoteControlData();
break;
default:
break;
}
} }
} }
@ -1109,6 +1090,7 @@ class LockDetailLogic extends BaseGetXController {
}); });
} else { } else {
state.indexCount.value = state.indexCount.value + 1; state.indexCount.value = state.indexCount.value + 1;
print('到达上传锁卡,${state.uploadCardDataList}');
_lockDataUpload(uploadType: 2, recordType: 3, records: state.uploadCardDataList); _lockDataUpload(uploadType: 2, recordType: 3, records: state.uploadCardDataList);
} }
break; break;

File diff suppressed because it is too large Load Diff

View File

@ -50,31 +50,21 @@ class BaseProvider extends GetConnect with Api {
httpClient.baseUrl = '${F.apiPrefix}/api'; httpClient.baseUrl = '${F.apiPrefix}/api';
} }
httpClient.timeout = timeout!.seconds; httpClient.timeout = timeout!.seconds;
// AppLog.log('timeout:$timeout httpClient.timeout:${httpClient.timeout}');
var res = await super.post(url, body, var res = await super.post(url, body,
contentType: contentType, contentType: contentType, headers: headers, query: query, decoder: decoder, uploadProgress: uploadProgress);
headers: headers,
query: query,
decoder: decoder,
uploadProgress: uploadProgress);
debugPrint("====1===$url---> ${res.bodyString}");
if (EasyLoading.isShow && !isUnShowLoading!) { if (EasyLoading.isShow && !isUnShowLoading!) {
await EasyLoading.dismiss(animation: true); await EasyLoading.dismiss(animation: true);
} }
debugPrint("===2====$url---> ${res.bodyString}");
if (res.body == null) { if (res.body == null) {
// EasyLoading.showToast("Network Error!", duration: 2000.milliseconds); // EasyLoading.showToast("Network Error!", duration: 2000.milliseconds);
if (res.statusCode == null && isShowErrMsg!) { if (res.statusCode == null && isShowErrMsg!) {
EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr, EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr, duration: 2000.milliseconds);
duration: 2000.milliseconds);
// EasyLoading.showToast("Network Error!", duration: 2000.milliseconds); // EasyLoading.showToast("Network Error!", duration: 2000.milliseconds);
} }
var rs = { var rs = {'errorMsg': 'Network Error!', 'errorCode': -1, 'data': null, 'description': '表示成功或是。'};
'errorMsg': 'Network Error!',
'errorCode': -1,
'data': null,
'description': '表示成功或是。'
};
return Response( return Response(
request: res.request, request: res.request,
statusCode: -1, statusCode: -1,
@ -84,6 +74,7 @@ class BaseProvider extends GetConnect with Api {
statusText: res.statusText, statusText: res.statusText,
); );
} else {} } else {}
print('isShowNetworkErrorMsg:${isShowNetworkErrorMsg}');
if (isShowNetworkErrorMsg ?? true) { if (isShowNetworkErrorMsg ?? true) {
getDataResult(res.body); getDataResult(res.body);
} }
@ -111,25 +102,15 @@ class BaseProvider extends GetConnect with Api {
} else { } else {
httpClient.baseUrl = '${F.apiPrefix}/api'; httpClient.baseUrl = '${F.apiPrefix}/api';
} }
var res = await super.get(url, var res = await super.get(url, contentType: contentType, headers: headers, query: query, decoder: decoder);
contentType: contentType,
headers: headers,
query: query,
decoder: decoder);
if (EasyLoading.isShow && !isUnShowLoading!) { if (EasyLoading.isShow && !isUnShowLoading!) {
await EasyLoading.dismiss(animation: true); await EasyLoading.dismiss(animation: true);
} }
if (res.body == null) { if (res.body == null) {
if (res.statusCode == null && isShowErrMsg!) { if (res.statusCode == null && isShowErrMsg!) {
EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr, EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr, duration: 2000.milliseconds);
duration: 2000.milliseconds);
} }
var rs = { var rs = {'errorMsg': 'Network Error!', 'errorCode': -1, 'data': null, 'description': '表示成功或是。'};
'errorMsg': 'Network Error!',
'errorCode': -1,
'data': null,
'description': '表示成功或是。'
};
return Response( return Response(
request: res.request, request: res.request,
statusCode: -1, statusCode: -1,
@ -166,8 +147,7 @@ class BaseProvider extends GetConnect with Api {
EasyLoading.showToast('数据不存在'.tr, duration: 2000.milliseconds); EasyLoading.showToast('数据不存在'.tr, duration: 2000.milliseconds);
break; break;
case 434: // case 434: //
ShowTipView() ShowTipView().showSureBtnTipsAlert(tipsText: T['errorMsg'], sureText: '');
.showSureBtnTipsAlert(tipsText: T['errorMsg'], sureText: '');
break; break;
} }
} }

File diff suppressed because it is too large Load Diff