From a8fc401da4e47c265cf9448e7b70f22bca135ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Tue, 30 Apr 2024 14:46:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=93=8D=E4=BD=9C=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../doorLockLog/doorLockLog_logic.dart | 38 ++++++++++------- .../lockDetail/lockDetail_logic.dart | 40 ++++++++++-------- .../lockDetail/lockDetail_page.dart | 2 +- .../automaticBlocking_logic.dart | 1 + .../lockMian/entity/lockListInfo_entity.dart | 6 ++- .../mine/addLock/saveLock/saveLock_logic.dart | 41 ++++++++++++------- .../mine/addLock/saveLock/saveLock_page.dart | 6 +-- .../mine/addLock/saveLock/saveLock_state.dart | 2 +- .../lib/network/request_interceptor_log.dart | 4 +- .../lib/network/response_interceptor_log.dart | 2 +- 10 files changed, 86 insertions(+), 56 deletions(-) diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index 970a4300..77bcc9e8 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -9,6 +9,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyO import 'package:star_lock/main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; +import '../../../app_settings/app_settings.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_protocol/io_referEventRecordTime.dart'; import '../../../blue/io_reply.dart'; @@ -66,33 +67,40 @@ class DoorLockLogLogic extends BaseGetXController { switch (status) { case 0x00: //成功 - var dataLength = reply.data[5]; + int dataLength = (reply.data[5] << 8) + reply.data[6]; + AppLog.log("dataLength:$dataLength"); + // var dataLength = reply.data[5]; if (dataLength > 0) { - reply.data.removeRange(0, 6); + reply.data.removeRange(0, 7); // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 - if(reply.data.length < 8){ + if(reply.data.length < 17){ return; } - var getList = splitList(reply.data, 8); + var getList = splitList(reply.data, 17); // AppLog.log("getList:$getList"); var uploadList = []; for (int i = 0; i < getList.length; i++) { var indexList = getList[i]; // AppLog.log("indexList:$indexList"); var indexMap = {}; - indexMap["seq"] = indexList[0].toString(); - indexMap["user"] = indexList[3].toString(); - indexMap["pwd"] = indexList[2].toString(); + indexMap["type"] = indexList[0].toString(); + + 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]; + indexMap["user"] = userNo.toString(); + } + indexMap["success"] = "1"; - indexMap["type"] = indexList[1].toString(); - int value = ((0xff & indexList[(4)]) << 24 | - (0xff & indexList[5]) << 16 | - (0xff & indexList[6]) << 8 | - (0xFF & indexList[7])); - // indexMap["date"] = DateTool().dateToYMDHNSString("$value"); - - indexMap["date"] = "${value * 1000}"; + int time = ((0xff & indexList[(3)]) << 24 | + (0xff & indexList[4]) << 16 | + (0xff & indexList[5]) << 8 | + (0xFF & indexList[6])); + indexMap["date"] = "${time * 1000}"; uploadList.add(indexMap); } lockRecordUploadData(uploadList); diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index b8b88f52..6cb1639d 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -160,33 +160,39 @@ class LockDetailLogic extends BaseGetXController { switch (status) { case 0x00: //成功 - var dataLength = reply.data[5]; + int dataLength = (reply.data[5] << 8) + reply.data[6]; + AppLog.log("dataLength:$dataLength"); if (dataLength > 0) { - reply.data.removeRange(0, 6); + reply.data.removeRange(0, 7); // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 - var getList = splitList(reply.data, 8); - if(reply.data.length < 8){ - await BlueManage().disconnect(); - cancelBlueConnetctToastTimer(); + if(reply.data.length < 17){ return; } + var getList = splitList(reply.data, 17); + // AppLog.log("getList:$getList"); var uploadList = []; for (int i = 0; i < getList.length; i++) { var indexList = getList[i]; + // AppLog.log("indexList:$indexList"); var indexMap = {}; - indexMap["seq"] = indexList[0].toString(); - indexMap["user"] = indexList[3].toString(); - indexMap["pwd"] = indexList[2].toString(); + indexMap["type"] = indexList[0].toString(); + + 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]; + indexMap["user"] = userNo.toString(); + } + indexMap["success"] = "1"; - indexMap["type"] = indexList[1].toString(); - int value = ((0xff & indexList[(4)]) << 24 | - (0xff & indexList[5]) << 16 | - (0xff & indexList[6]) << 8 | - (0xFF & indexList[7])); - // indexMap["date"] = DateTool().dateToYMDHNSString("$value"); - - indexMap["date"] = "${value * 1000}"; + int time = ((0xff & indexList[(3)]) << 24 | + (0xff & indexList[4]) << 16 | + (0xff & indexList[5]) << 8 | + (0xFF & indexList[6])); + indexMap["date"] = "${time * 1000}"; uploadList.add(indexMap); } lockRecordUploadData(uploadList); diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 24315b49..8eebe5e1 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -1035,7 +1035,7 @@ class _LockDetailPageState extends State }), ); - if (state.keyInfos.value.lockFeature!.d3Face == 1) { + if (state.keyInfos.value.lockFeature!.isSupportCatEye == 1) { //视频日志 endWiddget.add(bottomItem( 'images/main/icon_lockDetail_videoLog.png', diff --git a/star_lock/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart b/star_lock/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart index 8883773e..d253c197 100644 --- a/star_lock/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart @@ -100,6 +100,7 @@ class AutomaticBlockingLogic extends BaseGetXController{ //无权限 break; default: + state.sureBtnState.value = 0; break; } } diff --git a/star_lock/lib/main/lockMian/entity/lockListInfo_entity.dart b/star_lock/lib/main/lockMian/entity/lockListInfo_entity.dart index 042d2fcf..e448e11f 100644 --- a/star_lock/lib/main/lockMian/entity/lockListInfo_entity.dart +++ b/star_lock/lib/main/lockMian/entity/lockListInfo_entity.dart @@ -289,6 +289,7 @@ class LockFeature { int? d3Face; int? bluetoothRemoteControl; int? videoIntercom; + int? isSupportCatEye; LockFeature( {this.password, this.icCard, @@ -298,7 +299,8 @@ class LockFeature { this.isSupportIris, this.d3Face, this.bluetoothRemoteControl, - this.videoIntercom}); + this.videoIntercom, + this.isSupportCatEye}); LockFeature.fromJson(Map json) { password = json['password']; @@ -310,6 +312,7 @@ class LockFeature { d3Face = json['d3Face']; bluetoothRemoteControl = json['bluetoothRemoteControl']; videoIntercom = json['videoIntercom']; + isSupportCatEye = json['isSupportCatEye']; } Map toJson() { @@ -323,6 +326,7 @@ class LockFeature { data['d3Face'] = d3Face; data['bluetoothRemoteControl'] = bluetoothRemoteControl; data['videoIntercom'] = videoIntercom; + data['isSupportCatEye'] = isSupportCatEye; return data; } } diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index b09bfb46..b3f68f1e 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -86,16 +86,9 @@ class SaveLockLogic extends BaseGetXController { token: token, isBeforeAddUser: true); break; - case 0x07: - //无权限 - dismissEasyLoading(); - break; - case 0x09: - // 权限校验错误 - dismissEasyLoading(); - break; default: //失败 + state.sureBtnState.value = 0; dismissEasyLoading(); break; } @@ -112,7 +105,7 @@ class SaveLockLogic extends BaseGetXController { switch (status) { case 0x00: //成功 - dismissEasyLoading(); + state.sureBtnState.value = 0; addLockAdminPassword(true); break; case 0x06: @@ -138,6 +131,8 @@ class SaveLockLogic extends BaseGetXController { token: token); break; default: + state.sureBtnState.value = 0; + dismissEasyLoading(); break; } } @@ -186,10 +181,15 @@ class SaveLockLogic extends BaseGetXController { // 添加用户 Future addUserConnectBlue() async { // 进来之后首先连接 - showEasyLoading(); + if(state.sureBtnState.value == 1){ + return; + } + state.sureBtnState.value = 1; + + showTitleEasyLoading("添加锁进行中 1/2"); showBlueConnetctToastTimer(action: (){ dismissEasyLoading(); - state.saveBtnIsUsable.value = true; + state.sureBtnState.value = 0; }); BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected){ @@ -226,7 +226,7 @@ class SaveLockLogic extends BaseGetXController { } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); - state.saveBtnIsUsable.value = true; + state.sureBtnState.value = 0; if(state.ifCurrentScreen.value == true){ showBlueConnetctToast(); } @@ -240,6 +240,8 @@ class SaveLockLogic extends BaseGetXController { var number = rng.nextInt(900000) + 100000; // 生成 100000 到 999999 之间的随机整数 state.adminPassword = number.toString(); state.adminPasswordTF.text = number.toString(); + + showTitleEasyLoading("添加锁进行中 2/2"); BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { var signKey = await Storage.getStringList(saveBlueSignKey); @@ -264,6 +266,12 @@ class SaveLockLogic extends BaseGetXController { signKey: signKeyDataList, privateKey: getPrivateKeyList, token: getTokenList); + } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + dismissEasyLoading(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } } }, isAddEquipment: true); } @@ -350,12 +358,14 @@ class SaveLockLogic extends BaseGetXController { ); if (entity.errorCode!.codeIsSuccessful) { state.lockId = entity.data!.lockId!; - eventBus.fire(RefreshLockListInfoDataEvent()); - senderCustomPasswords(); + // eventBus.fire(RefreshLockListInfoDataEvent()); + await senderCustomPasswords(); // BlueManage().disconnect(BlueManage().connectDeviceMacAddress); // eventBus.fire(RefreshLockListInfoDataEvent()); // Get.close(state.isFromMap == 1 ? 5 : 6); + }else{ + state.sureBtnState.value = 0; } } @@ -369,7 +379,8 @@ class SaveLockLogic extends BaseGetXController { // if(isAddLockAdminPassword == true){ // showDeletPasswordAlertDialog(); // }else{ - backAction(); + eventBus.fire(RefreshLockListInfoDataEvent()); + backAction(); // } } } diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_page.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_page.dart index 9e68d2cd..4db7b1d6 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_page.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_page.dart @@ -109,9 +109,6 @@ class _SaveLockPageState extends State with RouteAware { bottom: 25.w ), onClick: (){ - if(state.saveBtnIsUsable.value == false){ - return; - } logic.addUserConnectBlue(); } ), @@ -153,8 +150,10 @@ class _SaveLockPageState extends State with RouteAware { super.didPop(); BlueManage().stopScan(); + logic.dismissEasyLoading(); state.ifCurrentScreen.value = false; logic.cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; } /// 从下级返回 当前界面即将出现 @@ -170,6 +169,7 @@ class _SaveLockPageState extends State with RouteAware { void didPushNext() { super.didPushNext(); + state.sureBtnState.value = 0; state.ifCurrentScreen.value = false; logic.cancelBlueConnetctToastTimer(); } diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_state.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_state.dart index bf1c6584..affd16e0 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_state.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_state.dart @@ -20,7 +20,7 @@ class SaveLockState { var isFromMap = 0; // 0:不是从地图界面进入 1:从地图界面进入 var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 - var saveBtnIsUsable = true.obs; // 保存按钮是否可用 + var sureBtnState = 0.obs;// 0可点击 1 不可点击 // 管理员密码 var adminPasswordTF = TextEditingController(); diff --git a/star_lock/lib/network/request_interceptor_log.dart b/star_lock/lib/network/request_interceptor_log.dart index 65fbc184..cfd24ef5 100644 --- a/star_lock/lib/network/request_interceptor_log.dart +++ b/star_lock/lib/network/request_interceptor_log.dart @@ -4,7 +4,7 @@ import 'package:get/get_connect/http/src/request/request.dart'; import 'package:star_lock/app_settings/app_settings.dart'; FutureOr requestLogInterceptor(Request request) async { - AppLog.log('GET HTTP REQUEST \n${request.url} \n${request.headers} ${request.toString()} '); - AppLog.log(request.headers.toString()); + // AppLog.log('GET HTTP REQUEST \n${request.url} \n${request.headers} ${request.toString()} '); + // AppLog.log(request.headers.toString()); return request; } diff --git a/star_lock/lib/network/response_interceptor_log.dart b/star_lock/lib/network/response_interceptor_log.dart index cc5c5bb5..85890536 100644 --- a/star_lock/lib/network/response_interceptor_log.dart +++ b/star_lock/lib/network/response_interceptor_log.dart @@ -5,7 +5,7 @@ import 'package:get/get_connect/http/src/request/request.dart'; import 'package:star_lock/app_settings/app_settings.dart'; FutureOr responseLogInterceptor(Request request, Response response) { - print('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString} ${response.headers}'); + AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString}'); // \n ${response.headers} EasyLoading.dismiss(animation: true); return response; }