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) {
final LockListInfoEntity entity = await ApiRepository.to
.deletOwnerKeyData(lockId: state.keyInfos.value.lockId.toString(), keyId: state.keyInfos.value!.keyId.toString(), includeUnderlings: 0);
final LockListInfoEntity entity = await ApiRepository.to.deletOwnerKeyData(
lockId: state.keyInfos.value.lockId.toString(),
keyId: state.keyInfos.value!.keyId.toString(),
includeUnderlings: 0);
if (entity.errorCode!.codeIsSuccessful) {
AppLog.log("删除成功");
}
@ -408,9 +410,13 @@ class LockDetailLogic extends BaseGetXController {
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;
if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(DateTime.fromMillisecondsSinceEpoch(getUTCNetTime() * 1000))) {
if (DateTime.fromMillisecondsSinceEpoch(operateDate)
.isAfter(DateTime.fromMillisecondsSinceEpoch(getUTCNetTime() * 1000))) {
continue;
}
@ -483,11 +489,13 @@ class LockDetailLogic extends BaseGetXController {
resetOpenDoorState();
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) {
BuglyTool.uploadException(message: '蓝牙连接成功', detail: '蓝牙连接成功,发送开锁指令--OpenLockCommand:$command', upload: false);
// FlutterBuglyPlugin.reportException(exceptionName: '蓝牙连接成功', reason: '蓝牙连接成功,发送开锁指令');
@ -504,7 +512,8 @@ class LockDetailLogic extends BaseGetXController {
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
cancelBlueConnetctToastTimer();
BuglyTool.uploadException(message: '蓝牙连接失败-开锁失败', detail: '蓝牙连接失败,断开连接, 开锁失败--OpenLockCommand:$command', upload: true);
BuglyTool.uploadException(
message: '蓝牙连接失败-开锁失败', detail: '蓝牙连接失败,断开连接, 开锁失败--OpenLockCommand:$command', upload: true);
final String getMobile = (await Storage.getMobile())!;
ApmHelper.instance.trackEvent('open_lock', {
'lock_name': state.keyInfos.value.lockName!,
@ -526,7 +535,7 @@ class LockDetailLogic extends BaseGetXController {
//便
closeLuckStatus();
cancelBlueConnetctToastTimer();
await BlueManage().disconnect();
// await BlueManage().disconnect();
}
// ()
@ -679,8 +688,9 @@ class LockDetailLogic extends BaseGetXController {
///
void initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() {
// eventBus
state.lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent =
eventBus.on<LockSetChangeSetRefreshLockDetailWithType>().listen((LockSetChangeSetRefreshLockDetailWithType event) {
state.lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus
.on<LockSetChangeSetRefreshLockDetailWithType>()
.listen((LockSetChangeSetRefreshLockDetailWithType event) {
if (event.type == 0) {
// 0
state.isAttendance.value = int.parse(event.setResult);
@ -795,8 +805,9 @@ class LockDetailLogic extends BaseGetXController {
void onInit() {
super.onInit();
state.LockSetChangeSetRefreshLockDetailWithTypeSubscription =
eventBus.on<LockSetChangeSetRefreshLockDetailWithType>().listen((LockSetChangeSetRefreshLockDetailWithType event) {
state.LockSetChangeSetRefreshLockDetailWithTypeSubscription = eventBus
.on<LockSetChangeSetRefreshLockDetailWithType>()
.listen((LockSetChangeSetRefreshLockDetailWithType event) {
//
if (event.type == 1) {
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 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 {
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!,
uploadType: uploadType,
recordType: recordType,
records: records,
isUnShowLoading: true,
isShowNetworkErrorMsg: false,
);
if (entity.errorCode!.codeIsSuccessful) {
if (uploadType == 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;
}
}
//
if (uploadType == 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;
}
}
}
@ -1109,6 +1090,7 @@ class LockDetailLogic extends BaseGetXController {
});
} else {
state.indexCount.value = state.indexCount.value + 1;
print('到达上传锁卡,${state.uploadCardDataList}');
_lockDataUpload(uploadType: 2, recordType: 3, records: state.uploadCardDataList);
}
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.timeout = timeout!.seconds;
// AppLog.log('timeout:$timeout httpClient.timeout:${httpClient.timeout}');
var res = await super.post(url, body,
contentType: contentType,
headers: headers,
query: query,
decoder: decoder,
uploadProgress: uploadProgress);
debugPrint("====1===$url---> ${res.bodyString}");
contentType: contentType, headers: headers, query: query, decoder: decoder, uploadProgress: uploadProgress);
if (EasyLoading.isShow && !isUnShowLoading!) {
await EasyLoading.dismiss(animation: true);
}
debugPrint("===2====$url---> ${res.bodyString}");
if (res.body == null) {
// EasyLoading.showToast("Network Error!", duration: 2000.milliseconds);
if (res.statusCode == null && isShowErrMsg!) {
EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr,
duration: 2000.milliseconds);
EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr, duration: 2000.milliseconds);
// EasyLoading.showToast("Network Error!", duration: 2000.milliseconds);
}
var rs = {
'errorMsg': 'Network Error!',
'errorCode': -1,
'data': null,
'description': '表示成功或是。'
};
var rs = {'errorMsg': 'Network Error!', 'errorCode': -1, 'data': null, 'description': '表示成功或是。'};
return Response(
request: res.request,
statusCode: -1,
@ -84,6 +74,7 @@ class BaseProvider extends GetConnect with Api {
statusText: res.statusText,
);
} else {}
print('isShowNetworkErrorMsg:${isShowNetworkErrorMsg}');
if (isShowNetworkErrorMsg ?? true) {
getDataResult(res.body);
}
@ -111,25 +102,15 @@ class BaseProvider extends GetConnect with Api {
} else {
httpClient.baseUrl = '${F.apiPrefix}/api';
}
var res = await super.get(url,
contentType: contentType,
headers: headers,
query: query,
decoder: decoder);
var res = await super.get(url, contentType: contentType, headers: headers, query: query, decoder: decoder);
if (EasyLoading.isShow && !isUnShowLoading!) {
await EasyLoading.dismiss(animation: true);
}
if (res.body == null) {
if (res.statusCode == null && isShowErrMsg!) {
EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr,
duration: 2000.milliseconds);
EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr, duration: 2000.milliseconds);
}
var rs = {
'errorMsg': 'Network Error!',
'errorCode': -1,
'data': null,
'description': '表示成功或是。'
};
var rs = {'errorMsg': 'Network Error!', 'errorCode': -1, 'data': null, 'description': '表示成功或是。'};
return Response(
request: res.request,
statusCode: -1,
@ -166,8 +147,7 @@ class BaseProvider extends GetConnect with Api {
EasyLoading.showToast('数据不存在'.tr, duration: 2000.milliseconds);
break;
case 434: //
ShowTipView()
.showSureBtnTipsAlert(tipsText: T['errorMsg'], sureText: '');
ShowTipView().showSureBtnTipsAlert(tipsText: T['errorMsg'], sureText: '');
break;
}
}

File diff suppressed because it is too large Load Diff