From a65891cfa65df396c10620763c8f4396af1210a0 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 13 May 2024 15:01:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=94=81=E9=92=A5?= =?UTF-8?q?=E5=8C=99=E8=BF=87=E6=9C=9F=E7=9A=84=E5=8A=A8=E7=94=BB=E5=92=8C?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/images/lan/lan_en.json | 3 +- star_lock/images/lan/lan_keys.json | 3 +- star_lock/images/lan/lan_zh.json | 4 +- .../lockDetail/lockDetail_logic.dart | 106 +++++++++++------- 4 files changed, 71 insertions(+), 45 deletions(-) diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index f674371d..7531b863 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -839,5 +839,6 @@ "固件版本": "Firmware version", "手动升级": "Manual upgrade", "设备连接中...": "Device Connecting...", - "升级过程中无法开锁,请先开锁后再升级": "The lock cannot be unlocked during the upgrade, please unlock the lock before upgrading" + "升级过程中无法开锁,请先开锁后再升级": "The lock cannot be unlocked during the upgrade, please unlock the lock before upgrading", + "钥匙无效": "The key is invalid" } diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index e8d93bfa..06581865 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -867,5 +867,6 @@ "固件版本": "固件版本", "手动升级": "手动升级", "设备连接中...": "设备连接中...", - "升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级" + "升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级", + "钥匙无效": "钥匙无效" } diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index 951ad37d..c8d99705 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -837,5 +837,7 @@ "固件版本": "固件版本", "手动升级": "手动升级", "设备连接中...": "设备连接中...", - "升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级" + "升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级", + "钥匙无效": "钥匙无效" + } diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 441778ec..841c9f38 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -32,7 +32,8 @@ class LockDetailLogic extends BaseGetXController { // 监听设备返回的数据 void initReplySubscription() { - state.replySubscription = EventBusManager().eventBus!.on().listen((reply) async { + state.replySubscription = + EventBusManager().eventBus!.on().listen((reply) async { // 开门 if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) { _replyOpenLock(reply); @@ -88,7 +89,7 @@ class LockDetailLogic extends BaseGetXController { state.electricQuantity.value = power; // 备用电量 - if(state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1){ + if (state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1) { int powerStandby = reply.data[9]; state.electricQuantityStandby.value = powerStandby; } @@ -132,8 +133,19 @@ class LockDetailLogic extends BaseGetXController { cancelBlueConnetctToastTimer(); }); break; + case 0x0d: + // 正在开锁中... + showToast('钥匙无效'.tr); + state.openLockBtnState.value = 0; + state.openDoorBtnisUneable.value = false; + state.animationController!.stop(); + cancelBlueConnetctToastTimer(); + break; default: //失败 + state.openLockBtnState.value = 0; + state.openDoorBtnisUneable.value = false; + state.animationController!.stop(); cancelBlueConnetctToastTimer(); break; } @@ -170,7 +182,7 @@ class LockDetailLogic extends BaseGetXController { if (dataLength > 0) { reply.data.removeRange(0, 7); // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 - if(reply.data.length < 17){ + if (reply.data.length < 17) { return; } var getList = splitList(reply.data, 17); @@ -182,29 +194,29 @@ class LockDetailLogic extends BaseGetXController { var indexMap = {}; indexMap["type"] = indexList[0].toString(); - if(indexList[0] == 2){ + if (indexList[0] == 2) { var passwordData = reply.data.sublist(7, 17); var password = utf8String(passwordData); indexMap["user"] = password.toString(); - }else{ - int userNo = (indexList[1]*255) + indexList[2]; + } else { + int userNo = (indexList[1] * 255) + indexList[2]; indexMap["user"] = userNo.toString(); } indexMap["success"] = "1"; int time = ((0xff & indexList[(3)]) << 24 | - (0xff & indexList[4]) << 16 | - (0xff & indexList[5]) << 8 | - (0xFF & indexList[6])); + (0xff & indexList[4]) << 16 | + (0xff & indexList[5]) << 8 | + (0xFF & indexList[6])); indexMap["date"] = "${time * 1000}"; uploadList.add(indexMap); } lockRecordUploadData(uploadList); - if(dataLength == state.logCountPage){ + if (dataLength == state.logCountPage) { senderReferEventRecordTime(); - }else{ + } else { await BlueManage().disconnect(); } } @@ -348,7 +360,9 @@ class LockDetailLogic extends BaseGetXController { var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); - BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { + BlueManage() + .bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, + (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { IoSenderManage.senderOpenLock( keyID: BlueManage().connectDeviceName, @@ -374,13 +388,15 @@ class LockDetailLogic extends BaseGetXController { }); } - // 查询事件记录(时间查询) Future senderReferEventRecordTime() async { - showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: () { - BlueManage().disconnect(); - }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + showBlueConnetctToastTimer( + isShowBlueConnetctToast: false, + action: () { + BlueManage().disconnect(); + }); + BlueManage().bludSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -407,27 +423,30 @@ class LockDetailLogic extends BaseGetXController { } // 从服务器获取锁的时间 开锁时传入 - void getServerDatetime() async{ + void getServerDatetime() async { var entity = await ApiRepository.to.getServerDatetimeData(); - if(entity.errorCode!.codeIsSuccessful){ - state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; + if (entity.errorCode!.codeIsSuccessful) { + state.differentialTime = entity.data!.date! ~/ 1000 - + DateTime.now().millisecondsSinceEpoch ~/ 1000; // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); } } - int getUTCNetTime(){ - return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime; + int getUTCNetTime() { + return DateTime.now().millisecondsSinceEpoch ~/ 1000 + + state.differentialTime; } // 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口 void getLockNetToken() async { - LockNetTokenEntity entity = await ApiRepository.to.getLockNetToken(lockId: state.keyInfos.value.lockId.toString()); + LockNetTokenEntity entity = await ApiRepository.to + .getLockNetToken(lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { state.lockNetToken = entity.data!.token!.toString(); AppLog.log("从服务器获取联网token:${state.lockNetToken}"); openDoorAction(); - }else{ - showToast("网络访问失败,请检查网络是否正常".tr, something: (){ + } else { + showToast("网络访问失败,请检查网络是否正常".tr, something: () { state.openLockBtnState.value = 0; state.animationController!.forward(); cancelBlueConnetctToastTimer(); @@ -439,11 +458,12 @@ class LockDetailLogic extends BaseGetXController { //电量更新请求 Future uploadElectricQuantityRequest() async { - KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity( - electricQuantity:state.electricQuantity.value.toString(), - electricQuantityStandby: state.electricQuantityStandby.value.toString(), - lockId: state.keyInfos.value.lockId.toString() - ); + KeyOperationRecordEntity entity = await ApiRepository.to + .uploadElectricQuantity( + electricQuantity: state.electricQuantity.value.toString(), + electricQuantityStandby: + state.electricQuantityStandby.value.toString(), + lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { SchedulerBinding.instance.addPostFrameCallback((_) { eventBus.fire(RefreshLockListInfoDataEvent()); @@ -488,8 +508,9 @@ class LockDetailLogic extends BaseGetXController { lockId: state.keyInfos.value.lockId.toString(), records: list); if (entity.errorCode!.codeIsSuccessful) { // mockNetworkDataRequest(); - AppLog.log("state.keyInfos.value.keyType:${state.keyInfos.value.keyType}"); - if(state.keyInfos.value.keyType == XSConstantMacro.keyTypeOnce){ + AppLog.log( + "state.keyInfos.value.keyType:${state.keyInfos.value.keyType}"); + if (state.keyInfos.value.keyType == XSConstantMacro.keyTypeOnce) { // 单次删除 deletKeyData(); } @@ -499,9 +520,7 @@ class LockDetailLogic extends BaseGetXController { // 普通用户或者授权管理员删除钥匙 void deletKeyData() async { var entity = await ApiRepository.to.deleteElectronicKey( - keyId:state.keyInfos.value.keyId.toString(), - includeUnderlings: 0 - ); + keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0); if (entity.errorCode!.codeIsSuccessful) { BlueManage().connectDeviceMacAddress = ""; SchedulerBinding.instance.addPostFrameCallback((_) { @@ -511,21 +530,24 @@ class LockDetailLogic extends BaseGetXController { } } - /// 锁设置里面开启关闭考勤刷新锁详情 void initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus state.lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = - eventBus.on().listen((event) { + eventBus + .on() + .listen((event) { if (event.type == 0) { // 0考勤 state.isAttendance.value = int.parse(event.setResult); - state.keyInfos.value.lockSetting!.attendance = int.parse(event.setResult); + state.keyInfos.value.lockSetting!.attendance = + int.parse(event.setResult); } else if (event.type == 1) { // 1 开锁时是否需联网 state.isOpenLockNeedOnline.value = int.parse(event.setResult); - state.keyInfos.value.lockSetting!.appUnlockOnline = int.parse(event.setResult); - state.lockNetToken = "";// 改变开锁时是否联网状态的时候清空token + state.keyInfos.value.lockSetting!.appUnlockOnline = + int.parse(event.setResult); + state.lockNetToken = ""; // 改变开锁时是否联网状态的时候清空token } else if (event.type == 2) { // 2 常开模式 state.isOpenPassageMode.value = int.parse(event.setResult); @@ -557,7 +579,8 @@ class LockDetailLogic extends BaseGetXController { state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) { - text = "${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}"; + text = + "${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}"; } else { text = state.isOpenPassageMode.value == 1 ? "常开模式启动!长按闭锁".tr @@ -582,5 +605,4 @@ class LockDetailLogic extends BaseGetXController { await PermissionDialog.request(Permission.location); await PermissionDialog.requestBluetooth(); } - }