fix: 调整蓝牙开锁后直接同步上传卡片、密码、指纹人脸
This commit is contained in:
parent
393ee9d2bc
commit
4d60ea4535
@ -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
@ -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
Loading…
x
Reference in New Issue
Block a user