diff --git a/star_lock/images/main/icon_addFace_step1.png b/star_lock/images/main/icon_addFace_step1.png new file mode 100644 index 00000000..7affaf46 Binary files /dev/null and b/star_lock/images/main/icon_addFace_step1.png differ diff --git a/star_lock/images/main/icon_addFace_step2.png b/star_lock/images/main/icon_addFace_step2.png new file mode 100644 index 00000000..81f03981 Binary files /dev/null and b/star_lock/images/main/icon_addFace_step2.png differ diff --git a/star_lock/images/main/icon_main_addFace.png b/star_lock/images/main/icon_main_addFace.png deleted file mode 100644 index a2b7a96b..00000000 Binary files a/star_lock/images/main/icon_main_addFace.png and /dev/null differ diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index dddf16fc..7339874a 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -6,6 +6,7 @@ import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendReceiver/massSendReceiver_page.dart'; +import 'package:star_lock/main/lockDetail/face/faceDetail/faceDetail_page.dart'; import 'package:star_lock/main/lockDetail/lcokSet/addFamily/addFamily_page.dart'; import 'package:star_lock/main/lockDetail/lcokSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_page.dart'; import 'package:star_lock/main/lockDetail/lcokSet/catEyeSet/catEyeSet/catEyeSet_page.dart'; @@ -378,7 +379,7 @@ abstract class Routers { static const openDoorDirectionPage = '/openDoorDirectionPage'; //开门方向设置 static const catEyeWorkModePage = '/catEyeWorkModePage'; //猫眼工作模式 static const msgNotificationPage = '/msgNotificationPage'; //消息提醒 - static const addFaceTipPage = '/addFaceTipPage'; //添加人脸 + static const addFacePage = '/addFacePage'; //添加人脸 static const nDaysUnopenedPage = '/nDaysUnopenedPage'; //N天未开门 static const notificationModePage = '/notificationModePage'; //提醒方式 static const openDoorNotifyPage = '/openDoorNotifyPage'; //家人到家 @@ -411,6 +412,8 @@ abstract class Routers { static const fingerprintDetailPage = '/FingerprintDetailPage'; // 指纹详情 static const faceList = '/FaceList'; // 人脸列表 static const addFaceTypeManagePage = '/AddFaceTypeManagePage'; // 添加人脸 + static const faceDetailPage = '/faceDetailPage'; // 人脸详情 + static const passwordKeyDetailChangeDatePage = '/passwordKeyDetailChangeDatePage'; //密码更改时间 static const realTimePicturePage = '/realTimePicturePage'; //实时监控画面 @@ -937,7 +940,7 @@ abstract class AppRouters { GetPage( name: Routers.msgNotificationPage, page: () => const MsgNotificationPage()), - GetPage(name: Routers.addFaceTipPage, page: () => const AddFaceTipPage()), + GetPage(name: Routers.addFacePage, page: () => const AddFacePage()), GetPage( name: Routers.nDaysUnopenedPage, page: () => const NDaysUnopenedPage()), GetPage( @@ -1013,6 +1016,7 @@ abstract class AppRouters { name: Routers.catEyeCustomModePage, page: () => const CatEyeCustomModePage()), GetPage(name: Routers.videoSlotPage, page: (() => const VideoSlotPage())), - GetPage(name: Routers.liveVideoPage, page: (() => const LiveVideoPage())) + GetPage(name: Routers.liveVideoPage, page: (() => const LiveVideoPage())), + GetPage(name: Routers.faceDetailPage, page: (() => const FaceDetailPage())), ]; } diff --git a/star_lock/lib/blue/io_protocol/io_addFace.dart b/star_lock/lib/blue/io_protocol/io_addFace.dart new file mode 100644 index 00000000..6ce9f1fd --- /dev/null +++ b/star_lock/lib/blue/io_protocol/io_addFace.dart @@ -0,0 +1,153 @@ +import 'dart:convert'; + +import '../io_tool/io_tool.dart'; +import '../sm4Encipher/sm4.dart'; +import '../io_reply.dart'; +import '../io_sender.dart'; +import '../io_type.dart'; +import 'package:crypto/crypto.dart' as crypto; + +///TODO:添加人脸 +/* +备注: +删除单个人脸规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 +**/ +class SenderAddFaceCommand extends SenderProtocol { + String? keyID; + String? userID; + int? faceNo; + int? useCountLimit; + List? token; + int? startTime; + int? endTime; + int? needAuthor; + List? publicKey; + List? privateKey; + + SenderAddFaceCommand({ + this.keyID, + this.userID, + this.faceNo, + this.useCountLimit, + this.token, + this.startTime, + this.endTime, + this.needAuthor, + this.publicKey, + this.privateKey, + }) : super(CommandType.generalExtendedCommond); + + @override + List messageDetail() { + List data = []; + List subData = []; + List ebcData = []; + + // 指令类型 + int type = commandType!.typeValue; + double typeDouble = type / 256; + int type1 = typeDouble.toInt(); + int type2 = type % 256; + data.add(type1); + data.add(type2); + + // 子命令类型--注册人脸开始 + data.add(81); + + // keyID 40 + int keyIDLength = utf8.encode(keyID!).length; + // print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); + subData.addAll(utf8.encode(keyID!)); + subData = getFixedLengthList(subData, 40 - keyIDLength); + + //userID 20 + int userIDLength = utf8.encode(userID!).length; + // print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}"); + subData.addAll(utf8.encode(userID!)); + subData = getFixedLengthList(subData, 20 - userIDLength); + + // PwdNo + subData.add(faceNo!); + + // UseCountLimit + subData.add(useCountLimit!); + + // token + subData.addAll(token!); + + // startTime 4 + subData.add((startTime! & 0xff000000) >> 24); + subData.add((startTime! & 0xff0000) >> 16); + subData.add((startTime! & 0xff00) >> 8); + subData.add((startTime! & 0xff)); + + // endTime 4 + subData.add((endTime! & 0xff000000) >> 24); + subData.add((endTime! & 0xff0000) >> 16); + subData.add((endTime! & 0xff00) >> 8); + subData.add((endTime! & 0xff)); + + if (needAuthor == 0) { + //AuthCodeLen 1 + subData.add(0); + } else { + List authCodeData = []; + + //authUserID + authCodeData.addAll(utf8.encode(userID!)); + + //KeyID + authCodeData.addAll(utf8.encode(keyID!)); + + //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 + authCodeData.addAll(token!); + + authCodeData.addAll(publicKey!); + + print("${commandType!.typeValue}-authCodeData:$authCodeData"); + + // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode + var authCode = crypto.md5.convert(authCodeData); + + subData.add(authCode.bytes.length); + subData.addAll(authCode.bytes); + } + + data.add(subData.length); + data.addAll(subData); + + if ((data.length % 16) != 0) { + int add = (16 - data.length % 16); + for (int i = 0; i < add; i++) { + data.add(0); + } + } + print("${commandType!.typeName} SM4Data:$data"); + // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 + ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); + return ebcData; + } +} + +class SenderAddFaceReply extends Reply { + SenderAddFaceReply.parseData(CommandType commandType, List dataDetail) + : super.parseData(commandType, dataDetail) { + data = dataDetail; + } +} + +class SenderAddFaceProcessReply extends Reply { + SenderAddFaceProcessReply.parseData( + CommandType commandType, List dataDetail) + : super.parseData(commandType, dataDetail) { + data = dataDetail; + } +} + +class SenderAddFaceConfirmationReply extends Reply { + SenderAddFaceConfirmationReply.parseData( + CommandType commandType, List dataDetail) + : super.parseData(commandType, dataDetail) { + data = dataDetail; + } +} diff --git a/star_lock/lib/blue/io_protocol/io_queryingFaceStatus.dart b/star_lock/lib/blue/io_protocol/io_queryingFaceStatus.dart new file mode 100644 index 00000000..6f72416d --- /dev/null +++ b/star_lock/lib/blue/io_protocol/io_queryingFaceStatus.dart @@ -0,0 +1,118 @@ +//TODO:查询指纹状态 +import 'dart:convert'; + +import '../io_reply.dart'; +import '../io_sender.dart'; +import '../io_tool/io_tool.dart'; +import '../io_type.dart'; +import '../sm4Encipher/sm4.dart'; +import 'package:crypto/crypto.dart' as crypto; + +class SenderQueryingFaceStatusCommand extends SenderProtocol { + String? keyID; + String? userID; + int? role; + int? fingerCount; + int? fingerNo; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; + + SenderQueryingFaceStatusCommand({ + this.keyID, + this.userID, + this.role, + this.fingerCount, + this.fingerNo, + this.token, + this.needAuthor, + this.publicKey, + this.privateKey, + }) : super(CommandType.generalExtendedCommond); + + @override + List messageDetail() { + List data = []; + List subData = []; + List ebcData = []; + + // 指令类型 + int type = commandType!.typeValue; + double typeDouble = type / 256; + int type1 = typeDouble.toInt(); + int type2 = type % 256; + data.add(type1); + data.add(type2); + + // 子命令类型--查询人脸状态 + data.add(80); + + // keyID 40 + int keyIDLength = utf8.encode(keyID!).length; + subData.addAll(utf8.encode(keyID!)); + subData = getFixedLengthList(subData, 40 - keyIDLength); + + //userID 20 + int userIDLength = utf8.encode(userID!).length; + subData.addAll(utf8.encode(userID!)); + subData = getFixedLengthList(subData, 20 - userIDLength); + + // role + subData.add(role!); + + // fingerCount + subData.add(fingerCount!); + + // FingerNo + subData.add(fingerNo!); + + if (needAuthor == 0) { + //AuthCodeLen 1 + subData.add(0); + } else { + List authCodeData = []; + + //authUserID + authCodeData.addAll(utf8.encode(userID!)); + + //KeyID + authCodeData.addAll(utf8.encode(keyID!)); + + //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 + authCodeData.addAll(token!); + + authCodeData.addAll(publicKey!); + + print("${commandType!.typeValue}-authCodeData:$authCodeData"); + + // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode + var authCode = crypto.md5.convert(authCodeData); + + subData.add(authCode.bytes.length); + subData.addAll(authCode.bytes); + } + + data.add(subData.length); + data.addAll(subData); + + if ((data.length % 16) != 0) { + int add = (16 - data.length % 16); + for (int i = 0; i < add; i++) { + data.add(0); + } + } + print("${commandType!.typeName} SM4Data:$data"); + // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 + ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); + return ebcData; + } +} + +class SenderQueryingFaceStatusReply extends Reply { + SenderQueryingFaceStatusReply.parseData( + CommandType commandType, List dataDetail) + : super.parseData(commandType, dataDetail) { + data = dataDetail; + } +} diff --git a/star_lock/lib/blue/reciver_data.dart b/star_lock/lib/blue/reciver_data.dart index 1a87e517..7665d9d8 100644 --- a/star_lock/lib/blue/reciver_data.dart +++ b/star_lock/lib/blue/reciver_data.dart @@ -1,14 +1,14 @@ - - import 'dart:convert'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:star_lock/blue/blue_manage.dart'; +import 'package:star_lock/blue/io_protocol/io_addFace.dart'; import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart'; import 'package:star_lock/blue/io_protocol/io_deletUser.dart'; import 'package:star_lock/blue/io_protocol/io_editUser.dart'; import 'package:star_lock/blue/io_protocol/io_factoryDataReset.dart'; import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart'; +import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart'; import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart'; import 'package:star_lock/blue/io_protocol/io_readSupportFunctionsNoParameters.dart'; import 'package:star_lock/blue/io_protocol/io_readSupportFunctionsWithParameters.dart'; @@ -44,29 +44,31 @@ import 'io_tool/manager_event_bus.dart'; import 'sm4Encipher/sm4.dart'; class CommandReciverManager { - static void appDataReceive(List data) async { ///解析数据 - if(data.isEmpty){ + if (data.isEmpty) { return; } int dataSize = data.length; // 当小于包头加起来13个字节 - if(dataSize < 13){ + if (dataSize < 13) { return; } - print("appDataReceiveData:$data"); // &&(data[4] == 0x11) - if((data[0] == 0xEF)&&(data[1] == 0x01)&&(data[2] == 0xEE)&&(data[3] == 0x02)){ - var tmpType = (data[7] & 0x0f);// 包标识 + print("appDataReceiveData:$data"); // &&(data[4] == 0x11) + if ((data[0] == 0xEF) && + (data[1] == 0x01) && + (data[2] == 0xEE) && + (data[3] == 0x02)) { + var tmpType = (data[7] & 0x0f); // 包标识 // print("temType:$tmpType"); - var dataLen = data[8] * 256 + data[9];// 高16位用来指示后面数据块内容的长度 - var oriLen = data[10] * 256 + data[11];// 低16位用来指示数据加密前的原长度 + var dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度 + var oriLen = data[10] * 256 + data[11]; // 低16位用来指示数据加密前的原长度 // print("dataLen:$dataLen oriLen:$oriLen"); // List dataList = []; List oriDataList = []; - switch(tmpType){ + switch (tmpType) { case 0: //不加密 // for (var i = 0; i < oriLen ; i++) { // oriDataList.add(data[12 + i]); @@ -84,7 +86,9 @@ class CommandReciverManager { // 解密 // String key = SM4.createHexKey(key: IoManager().getCurrentDeviceLockId); - oriDataList = SM4.decrypt(getDataList, key: utf8.encode(BlueManage().connectDeviceName), mode: SM4CryptoMode.ECB); + oriDataList = SM4.decrypt(getDataList, + key: utf8.encode(BlueManage().connectDeviceName), + mode: SM4CryptoMode.ECB); oriDataList = oriDataList.sublist(0, oriLen); // print("SM4 oriDataList:$oriDataList"); break; @@ -98,11 +102,11 @@ class CommandReciverManager { // print("getPrivateKeyList$getPrivateKeyList"); // 解密 - oriDataList = SM4.decrypt(getDataList, key: getPrivateKeyList, mode: SM4CryptoMode.ECB); + oriDataList = SM4.decrypt(getDataList, + key: getPrivateKeyList, mode: SM4CryptoMode.ECB); oriDataList = oriDataList.sublist(0, oriLen); print("SM4 oriDataList:$oriDataList"); break; - } parseData(oriDataList).then((value) { EasyLoading.dismiss(); @@ -113,14 +117,14 @@ class CommandReciverManager { } static Future parseData(List data) async { - if(data.isNotEmpty){ + if (data.isNotEmpty) { var cmd = data[0] * 256 + data[1]; - CommandType commandType = ExtensionCommandType.getCommandType(cmd); + CommandType commandType = ExtensionCommandType.getCommandType(cmd); await IoManager().increaseCommandIndex(); // data.removeRange(0, 2); // print("111111data cmd:$cmd commandType:$commandType data:$data"); var reply; - switch(commandType) { + switch (commandType) { case CommandType.getLockPublicKey: { reply = GetPublicKeyReply.parseData(commandType, data); @@ -180,17 +184,19 @@ class CommandReciverManager { { // 子命令类型 int subType = data[3]; - switch(subType){ + switch (subType) { case 2: { // 修改管理员密码 - reply = ChangeAdministratorPasswordReply.parseData(commandType, data); + reply = ChangeAdministratorPasswordReply.parseData( + commandType, data); } break; case 3: { // 设置开锁密码 - reply = SenderCustomPasswordsReply.parseData(commandType, data); + reply = + SenderCustomPasswordsReply.parseData(commandType, data); } break; case 4: @@ -202,13 +208,15 @@ class CommandReciverManager { case 15: { // 查询用户、指纹、密码、卡片数量(用于判断是否同步) - reply = SenderCheckingUserInfoCountReply.parseData(commandType, data); + reply = SenderCheckingUserInfoCountReply.parseData( + commandType, data); } break; case 20: { // 查询卡片状态 - reply = SenderCheckingCardStatusReply.parseData(commandType, data); + reply = SenderCheckingCardStatusReply.parseData( + commandType, data); } break; case 21: @@ -220,43 +228,50 @@ class CommandReciverManager { case 22: { // 注册卡片确认 - reply = SenderAddICCardConfirmationReply.parseData(commandType, data); + reply = SenderAddICCardConfirmationReply.parseData( + commandType, data); } break; case 30: { // 查询指纹状态 - reply = SenderQueryingFingerprintStatusReply.parseData(commandType, data); + reply = SenderQueryingFingerprintStatusReply.parseData( + commandType, data); } break; case 31: { // 注册指纹开始 - reply = SenderAddFingerprintReply.parseData(commandType, data); + reply = + SenderAddFingerprintReply.parseData(commandType, data); } break; case 32: { // 注册指纹确认 - reply = SenderAddFingerprintConfirmationReply.parseData(commandType, data); + reply = SenderAddFingerprintConfirmationReply.parseData( + commandType, data); } break; case 33: { // 注册指纹过程 - reply = SenderAddFingerprintProcessReply.parseData(commandType, data); + reply = SenderAddFingerprintProcessReply.parseData( + commandType, data); } break; case 40: { // 事件查询记录 - reply = SenderReferEventRecordNumberReply.parseData(commandType, data); + reply = SenderReferEventRecordNumberReply.parseData( + commandType, data); } break; case 41: { // 事件查询记录 - reply = SenderReferEventRecordTimeReply.parseData(commandType, data); + reply = SenderReferEventRecordTimeReply.parseData( + commandType, data); } break; // case 50: @@ -268,55 +283,92 @@ class CommandReciverManager { case 51: { // wifi配网结果 - reply = SenderConfiguringWifiReply.parseData(commandType, data); + reply = + SenderConfiguringWifiReply.parseData(commandType, data); } break; case 60: { // 注册胁迫密码 - reply = SenderAddStressPasswordReply.parseData(commandType, data); + reply = + SenderAddStressPasswordReply.parseData(commandType, data); } break; case 61: { // 注册胁迫卡片 - reply = SenderAddStressICCardReply.parseData(commandType, data); + reply = + SenderAddStressICCardReply.parseData(commandType, data); } break; case 62: { // 注册胁迫指纹 - reply = SenderAddStressFingerprintReply.parseData(commandType, data); + reply = SenderAddStressFingerprintReply.parseData( + commandType, data); } break; case 70: { // 设置支持功能(不带参数)启用/禁用 - reply = SetSupportFunctionsNoParametersReply.parseData(commandType, data); + reply = SetSupportFunctionsNoParametersReply.parseData( + commandType, data); } break; case 71: { // 读取支持功能(不带参数)启用/禁用状态 - reply = ReadSupportFunctionsNoParametersReply.parseData(commandType, data); + reply = ReadSupportFunctionsNoParametersReply.parseData( + commandType, data); } break; case 72: { // 设置支持功能(带参数) - reply = SetSupportFunctionsWithParametersReply.parseData(commandType, data); + reply = SetSupportFunctionsWithParametersReply.parseData( + commandType, data); } break; case 73: { // 读取支持功能(带参数)参数 - reply = ReadSupportFunctionsWithParametersReply.parseData(commandType, data); + reply = ReadSupportFunctionsWithParametersReply.parseData( + commandType, data); } break; case 74: { // 读取管理员密码 - reply = SenderReadAdminPasswordReply.parseData(commandType, data); + reply = + SenderReadAdminPasswordReply.parseData(commandType, data); + } + break; + case 80: + { + // 查询人脸状态 + reply = SenderQueryingFaceStatusReply.parseData( + commandType, data); + } + break; + case 81: + { + // 注册人脸开始 + reply = SenderAddFaceReply.parseData(commandType, data); + } + break; + case 82: + { + // 注册人脸确认 + reply = SenderAddFaceConfirmationReply.parseData( + commandType, data); + } + break; + + case 83: + { + // 注册人脸过程 + reply = + SenderAddFaceProcessReply.parseData(commandType, data); } break; } @@ -326,5 +378,4 @@ class CommandReciverManager { return reply; } } - -} \ No newline at end of file +} diff --git a/star_lock/lib/blue/sender_manage.dart b/star_lock/lib/blue/sender_manage.dart index 32cc168c..50021afa 100644 --- a/star_lock/lib/blue/sender_manage.dart +++ b/star_lock/lib/blue/sender_manage.dart @@ -1,9 +1,10 @@ - +import 'package:star_lock/blue/io_protocol/io_addFace.dart'; import 'package:star_lock/blue/io_protocol/io_addICCard.dart'; import 'package:star_lock/blue/io_protocol/io_addStressICCard.dart'; import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart'; import 'package:star_lock/blue/io_protocol/io_deletUser.dart'; import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart'; +import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart'; import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart'; import 'io_protocol/io_addFingerprint.dart'; @@ -33,50 +34,53 @@ import 'io_protocol/io_transferPermissions.dart'; import 'sender_data.dart'; class IoSenderManage { - //todo:获取公钥 - static void getPublicKey({String? lockId ,CommandSendCallBack? callBack}) { - CommandSenderManager().managerSendData(command: GetPublicKeyCommand( + static void getPublicKey({String? lockId, CommandSendCallBack? callBack}) { + CommandSenderManager().managerSendData( + command: GetPublicKeyCommand( lockID: lockId, - ), callBack:callBack); + ), + callBack: callBack); } //todo:获取私钥 - static void getPrivateKey({ - String? lockId, - String? keyID, // 钥匙ID - String? authUserID,// 钥匙授权人ID - int? nowTime, - List? publicKeyData, - int? needAuthor, - CommandSendCallBack? callBack}) { - CommandSenderManager().managerSendData(command: GetPrivateKeyCommand( - lockID: lockId, - keyID: keyID, - authUserID: authUserID, - nowTime: nowTime, - publicKeyData:publicKeyData, - needAuthor: needAuthor, - ), callBack:callBack); + static void getPrivateKey( + {String? lockId, + String? keyID, // 钥匙ID + String? authUserID, // 钥匙授权人ID + int? nowTime, + List? publicKeyData, + int? needAuthor, + CommandSendCallBack? callBack}) { + CommandSenderManager().managerSendData( + command: GetPrivateKeyCommand( + lockID: lockId, + keyID: keyID, + authUserID: authUserID, + nowTime: nowTime, + publicKeyData: publicKeyData, + needAuthor: needAuthor, + ), + callBack: callBack); } //todo:添加用户 - static void senderAddUser({ - String? lockID, - String? authUserID, - String? keyID, - String? userID, - int? openMode, - int? keyType, - int? startDate, - int? expireDate, - int? role, - String? password, - int? needAuthor, - List? publicKey, - List? privateKey, - List? token, - CommandSendCallBack? callBack}) { + static void senderAddUser( + {String? lockID, + String? authUserID, + String? keyID, + String? userID, + int? openMode, + int? keyType, + int? startDate, + int? expireDate, + int? role, + String? password, + int? needAuthor, + List? publicKey, + List? privateKey, + List? token, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: AddUserCommand( lockID: lockID, @@ -92,27 +96,27 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - token: token - ), callBack:callBack); + token: token), + callBack: callBack); } //todo:修改用户 - static void senderEditUser({ - String? lockID, - String? authUserID, - String? keyID, - String? userID, - int? openMode, - int? keyType, - int? startDate, - int? expireDate, - int? role, - String? password, - int? needAuthor, - List? publicKey, - List? privateKey, - List? token, - CommandSendCallBack? callBack}) { + static void senderEditUser( + {String? lockID, + String? authUserID, + String? keyID, + String? userID, + int? openMode, + int? keyType, + int? startDate, + int? expireDate, + int? role, + String? password, + int? needAuthor, + List? publicKey, + List? privateKey, + List? token, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: EditUserCommand( lockID: lockID, @@ -128,46 +132,46 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - token: token - ), callBack:callBack); + token: token), + callBack: callBack); } //todo:删除 - static void deletUser({ - String? lockID, - String? authUserID, - String? keyID, - String? delUserID, - int? needAuthor, - List? publicKey, - List? privateKey, - List? token, - CommandSendCallBack? callBack}) { + static void deletUser( + {String? lockID, + String? authUserID, + String? keyID, + String? delUserID, + int? needAuthor, + List? publicKey, + List? privateKey, + List? token, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: DeletUserCommand( lockID: lockID, authUserID: authUserID, keyID: keyID, - delUserID:delUserID, + delUserID: delUserID, needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - token: token - ), callBack:callBack); + token: token), + callBack: callBack); } //todo:开锁 - static void senderOpenLock({ - String? keyID, - String? userID, - int? openMode, - int? openTime, - String? onlineToken, - List? token, - int? needAuthor, - List? signKey, - List? privateKey, - CommandSendCallBack? callBack}) { + static void senderOpenLock( + {String? keyID, + String? userID, + int? openMode, + int? openTime, + String? onlineToken, + List? token, + int? needAuthor, + List? signKey, + List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: OpenLockCommand( keyID: keyID, @@ -179,49 +183,52 @@ class IoSenderManage { needAuthor: needAuthor, signKey: signKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:获取锁状态 - static void senderGetLockStatu({ - String? lockID, - String? userID, - List? privateKey, - CommandSendCallBack? callBack}) { + static void senderGetLockStatu( + {String? lockID, + String? userID, + List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: GetLockStatuCommand( lockID: lockID, userID: userID, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:获取星锁状态信息 - static void senderGetStarLockStatuInfo({ - String? lockID, - String? userID, - List? privateKey, - CommandSendCallBack? callBack}) { + static void senderGetStarLockStatuInfo( + {String? lockID, + String? userID, + List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: GetStarLockStatuInfoCommand( lockID: lockID, userID: userID, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:转移权限 - static void senderTransferPermissions({ - required String? lockID, - required String? authUserID, - required String? keyID, - required String? oldUserID, - required String? newUserID, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - required List? token, - CommandSendCallBack? callBack}) { + static void senderTransferPermissions( + {required String? lockID, + required String? authUserID, + required String? keyID, + required String? oldUserID, + required String? newUserID, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + required List? token, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: TransferPermissionsCommand( lockID: lockID, @@ -232,20 +239,20 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - token: token - ), callBack:callBack); + token: token), + callBack: callBack); } //todo:恢复出厂设置 - static void senderFactoryDataReset({ - required String? lockID, - required String? userID, - required String? keyID, - required List? publicKey, - required List? privateKey, - required List? token, - required int? needAuthor, - CommandSendCallBack? callBack}) { + static void senderFactoryDataReset( + {required String? lockID, + required String? userID, + required String? keyID, + required List? publicKey, + required List? privateKey, + required List? token, + required int? needAuthor, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: FactoryDataResetCommand( lockID: lockID, @@ -254,60 +261,30 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - token: token - ), callBack:callBack); + token: token), + callBack: callBack); } //todo:设置开锁密码 - static void senderCustomPasswordsCommand({ - required String? keyID, - required String? userID, - required int? pwdNo, - required String? pwd, - required int? useCountLimit, - required List? token, - required int? startTime, - required int? endTime, - required int? needAuthor, - required List? signKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void senderCustomPasswordsCommand( + {required String? keyID, + required String? userID, + required int? pwdNo, + required String? pwd, + required int? useCountLimit, + required List? token, + required int? startTime, + required int? endTime, + required int? needAuthor, + required List? signKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderCustomPasswordsCommand( - keyID: keyID, - userID: userID, - pwdNo: pwdNo, - pwd:pwd, - useCountLimit: useCountLimit, - token: token, - startTime: startTime, - endTime: endTime, - needAuthor: needAuthor, - signKey: signKey, - privateKey: privateKey, - ), callBack:callBack); - } - - //todo:修改管理员密码 - static void changeAdministratorPasswordCommand({ - required String? keyID, - required String? userID, - required int? pwdNo, - required String? pwd, - required int? useCountLimit, - required List? token, - required int? startTime, - required int? endTime, - required int? needAuthor, - required List? signKey, - required List? privateKey, - CommandSendCallBack? callBack}) { - CommandSenderManager().managerSendData( - command: ChangeAdministratorPasswordCommand( keyID: keyID, userID: userID, pwdNo: pwdNo, - pwd:pwd, + pwd: pwd, useCountLimit: useCountLimit, token: token, startTime: startTime, @@ -315,22 +292,54 @@ class IoSenderManage { needAuthor: needAuthor, signKey: signKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); + } + + //todo:修改管理员密码 + static void changeAdministratorPasswordCommand( + {required String? keyID, + required String? userID, + required int? pwdNo, + required String? pwd, + required int? useCountLimit, + required List? token, + required int? startTime, + required int? endTime, + required int? needAuthor, + required List? signKey, + required List? privateKey, + CommandSendCallBack? callBack}) { + CommandSenderManager().managerSendData( + command: ChangeAdministratorPasswordCommand( + keyID: keyID, + userID: userID, + pwdNo: pwdNo, + pwd: pwd, + useCountLimit: useCountLimit, + token: token, + startTime: startTime, + endTime: endTime, + needAuthor: needAuthor, + signKey: signKey, + privateKey: privateKey, + ), + callBack: callBack); } //todo:添加指纹开始 - static void senderAddFingerprintCommand({ - required String? keyID, - required String? userID, - required int? fingerNo, - required int? useCountLimit, - required List? token, - required int? startTime, - required int? endTime, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void senderAddFingerprintCommand( + {required String? keyID, + required String? userID, + required int? fingerNo, + required int? useCountLimit, + required List? token, + required int? startTime, + required int? endTime, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderAddFingerprintCommand( keyID: keyID, @@ -343,22 +352,23 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:添加卡开始 - static void senderAddICCardCommand({ - required String? keyID, - required String? userID, - required int? cardNo, - required int? useCountLimit, - required List? token, - required int? startTime, - required int? endTime, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void senderAddICCardCommand( + {required String? keyID, + required String? userID, + required int? cardNo, + required int? useCountLimit, + required List? token, + required int? startTime, + required int? endTime, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderAddICCardCommand( keyID: keyID, @@ -371,19 +381,49 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); + } + + //todo:添加人脸开始 + static void senderAddFaceCommand( + {required String? keyID, + required String? userID, + required int? faceNo, + required int? useCountLimit, + required List? token, + required int? startTime, + required int? endTime, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { + CommandSenderManager().managerSendData( + command: SenderAddFaceCommand( + keyID: keyID, + userID: userID, + faceNo: faceNo, + useCountLimit: useCountLimit, + token: token, + startTime: startTime, + endTime: endTime, + needAuthor: needAuthor, + publicKey: publicKey, + privateKey: privateKey, + ), + callBack: callBack); } //todo:校验时间 - static void senderTimingCommand({ - required String? lockID, - required String? userID, - required int? nowTime, - required List? token, - required int? needAuthor, - required List? signKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void senderTimingCommand( + {required String? lockID, + required String? userID, + required int? nowTime, + required List? token, + required int? needAuthor, + required List? signKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: TimingCommand( lockID: lockID, @@ -393,7 +433,8 @@ class IoSenderManage { needAuthor: needAuthor, signKey: signKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:自动落锁 - 废弃 @@ -419,16 +460,16 @@ class IoSenderManage { // } //todo:事件记录(页数查询) - static void senderReferEventRecordNumberCommand({ - required String? keyID, - required String? userID, - required int? logsCount, - required int? logsNo, - required List? token, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void senderReferEventRecordNumberCommand( + {required String? keyID, + required String? userID, + required int? logsCount, + required int? logsNo, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderReferEventRecordNumberCommand( keyID: keyID, @@ -439,20 +480,21 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:事件记录(时间查询) - static void senderReferEventRecordTimeCommand({ - required String? keyID, - required String? userID, - required int? logsCount, - required int? time, - required List? token, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void senderReferEventRecordTimeCommand( + {required String? keyID, + required String? userID, + required int? logsCount, + required int? time, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderReferEventRecordTimeCommand( keyID: keyID, @@ -463,21 +505,22 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:查询指纹状态 - static void senderQueryingFingerprintStatusCommand({ - required String? keyID, - required String? userID, - required int? role, - required int? fingerCount, - required int? fingerNo, - required List? token, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void senderQueryingFingerprintStatusCommand( + {required String? keyID, + required String? userID, + required int? role, + required int? fingerCount, + required int? fingerNo, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderQueryingFingerprintStatusCommand( keyID: keyID, @@ -489,21 +532,22 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:查询卡片状态 - static void senderCheckingCardStatusCommand({ - required String? keyID, - required String? userID, - required int? role, - required int? cardCount, - required int? cardNo, - required List? token, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void senderCheckingCardStatusCommand( + {required String? keyID, + required String? userID, + required int? role, + required int? cardCount, + required int? cardNo, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderCheckingCardStatusCommand( keyID: keyID, @@ -515,20 +559,48 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); + } + + //todo:查询人脸状态 + static void senderQueryingFaceStatusCommand( + {required String? keyID, + required String? userID, + required int? role, + required int? fingerCount, + required int? fingerNo, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { + CommandSenderManager().managerSendData( + command: SenderQueryingFaceStatusCommand( + keyID: keyID, + userID: userID, + role: role, + fingerCount: fingerCount, + fingerNo: fingerNo, + token: token, + needAuthor: needAuthor, + publicKey: publicKey, + privateKey: privateKey, + ), + callBack: callBack); } //todo:查询用户、指纹、密码、卡片数量(用于判断是否同步) - static void senderCheckingUserInfoCountCommand({ - required String? keyID, - required String? userID, - required int? role, - required int? nowTime, - required List? token, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void senderCheckingUserInfoCountCommand( + {required String? keyID, + required String? userID, + required int? role, + required int? nowTime, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderCheckingUserInfoCountCommand( keyID: keyID, @@ -539,24 +611,25 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:配置wifi - static void senderConfiguringWifiCommand({ - required String? keyID, - required String? userID, - required String? ssid, - required String? password, - required int? numberOfServers, - required List? listOfServers, - required int? numberOfPhone, - required List? listOfPhone, - required List? token, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void senderConfiguringWifiCommand( + {required String? keyID, + required String? userID, + required String? ssid, + required String? password, + required int? numberOfServers, + required List? listOfServers, + required int? numberOfPhone, + required List? listOfPhone, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderConfiguringWifiCommand( keyID: keyID, @@ -571,86 +644,87 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:添加胁迫指纹 - static void senderAddStressFingerprintCommand({ - required String? keyID, - required String? userID, - required int? fingerNo, - required int? fingerType, - required int? useCountLimit, - required List? token, - required int? startTime, - required int? endTime, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - required List? signKey, - CommandSendCallBack? callBack}) { + static void senderAddStressFingerprintCommand( + {required String? keyID, + required String? userID, + required int? fingerNo, + required int? fingerType, + required int? useCountLimit, + required List? token, + required int? startTime, + required int? endTime, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + required List? signKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderAddStressFingerprintCommand( - keyID: keyID, - userID: userID, - fingerNo: fingerNo, - fingerType: fingerType, - useCountLimit: useCountLimit, - token: token, - startTime: startTime, - endTime: endTime, - needAuthor: needAuthor, - publicKey: publicKey, - privateKey: privateKey, - signKey: signKey - ), callBack:callBack); + keyID: keyID, + userID: userID, + fingerNo: fingerNo, + fingerType: fingerType, + useCountLimit: useCountLimit, + token: token, + startTime: startTime, + endTime: endTime, + needAuthor: needAuthor, + publicKey: publicKey, + privateKey: privateKey, + signKey: signKey), + callBack: callBack); } //todo:添加胁迫卡片 - static void senderAddStressICCardCommand({ - required String? keyID, - required String? userID, - required int? icCardNo, - required int? cardType, - required int? useCountLimit, - required List? token, - required int? startTime, - required int? endTime, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - required List? signKey, - CommandSendCallBack? callBack}) { + static void senderAddStressICCardCommand( + {required String? keyID, + required String? userID, + required int? icCardNo, + required int? cardType, + required int? useCountLimit, + required List? token, + required int? startTime, + required int? endTime, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + required List? signKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderAddStressICCardCommand( - keyID: keyID, - userID: userID, - icCardNo: icCardNo, - cardType: cardType, - useCountLimit: useCountLimit, - token: token, - startTime: startTime, - endTime: endTime, - needAuthor: needAuthor, - publicKey: publicKey, - privateKey: privateKey, - signKey: signKey - ), callBack:callBack); + keyID: keyID, + userID: userID, + icCardNo: icCardNo, + cardType: cardType, + useCountLimit: useCountLimit, + token: token, + startTime: startTime, + endTime: endTime, + needAuthor: needAuthor, + publicKey: publicKey, + privateKey: privateKey, + signKey: signKey), + callBack: callBack); } //todo:添加胁迫密码 - static void senderAddStressPasswordCommand({ - required String? keyID, - required String? userID, - required int? passwordNo, - required int? useCountLimit, - required List? token, - required int? startTime, - required int? endTime, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void senderAddStressPasswordCommand( + {required String? keyID, + required String? userID, + required int? passwordNo, + required int? useCountLimit, + required List? token, + required int? startTime, + required int? endTime, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderAddStressPasswordCommand( keyID: keyID, @@ -663,19 +737,20 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:读取支持功能(不带参数)启用/禁用 - static void readSupportFunctionsNoParametersCommand({ - required String? keyID, - required String? userID, - required int? featureBit, - required List? token, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void readSupportFunctionsNoParametersCommand( + {required String? keyID, + required String? userID, + required int? featureBit, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: ReadSupportFunctionsNoParametersCommand( keyID: keyID, @@ -685,43 +760,45 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:设置支持功能(不带参数)启用/禁用 - static void setSupportFunctionsNoParametersCommand({ - required String? keyID, - required String? userID, - required int? featureBit, - required int? featureEnable, - required List? token, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void setSupportFunctionsNoParametersCommand( + {required String? keyID, + required String? userID, + required int? featureBit, + required int? featureEnable, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SetSupportFunctionsNoParametersCommand( keyID: keyID, userID: userID, featureBit: featureBit, - featureEnable:featureEnable, + featureEnable: featureEnable, token: token, needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:读取支持功能(带参数)启用/禁用 - static void readSupportFunctionsWithParametersCommand({ - required String? keyID, - required String? userID, - required int? featureBit, - required List? token, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void readSupportFunctionsWithParametersCommand( + {required String? keyID, + required String? userID, + required int? featureBit, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: ReadSupportFunctionsWithParametersCommand( keyID: keyID, @@ -731,47 +808,49 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:设置支持功能(带参数)启用/禁用 - static void setSupportFunctionsWithParametersCommand({ - required String? keyID, - required String? userID, - required int? featureBit, - required int? featureParaLength, - required List? featureData, - required List? token, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void setSupportFunctionsWithParametersCommand( + {required String? keyID, + required String? userID, + required int? featureBit, + required int? featureParaLength, + required List? featureData, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SetSupportFunctionsWithParametersCommand( keyID: keyID, userID: userID, featureBit: featureBit, - featureParaLength:featureParaLength, - featureData:featureData, + featureParaLength: featureParaLength, + featureData: featureData, token: token, needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } //todo:读取管理员密码 - static void senderReadAdminPasswordCommand({ - required String? keyID, - required String? userID, - required int? role, - required int? pwdNum, - required int? pwdNo, - required List? token, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - CommandSendCallBack? callBack}) { + static void senderReadAdminPasswordCommand( + {required String? keyID, + required String? userID, + required int? role, + required int? pwdNum, + required int? pwdNo, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderReadAdminPasswordCommand( keyID: keyID, @@ -783,7 +862,7 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, - ), callBack:callBack); + ), + callBack: callBack); } - -} \ No newline at end of file +} diff --git a/star_lock/lib/main/lockDetail/face/addFace/addFace_entity.dart b/star_lock/lib/main/lockDetail/face/addFace/addFace_entity.dart new file mode 100644 index 00000000..e69de29b diff --git a/star_lock/lib/main/lockDetail/face/addFace/addFace_logic.dart b/star_lock/lib/main/lockDetail/face/addFace/addFace_logic.dart new file mode 100644 index 00000000..a991f631 --- /dev/null +++ b/star_lock/lib/main/lockDetail/face/addFace/addFace_logic.dart @@ -0,0 +1,294 @@ +import 'dart:async'; + +import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/blue/io_protocol/io_addFace.dart'; +import 'package:star_lock/blue/io_type.dart'; +import 'package:star_lock/main/lockDetail/face/addFace/addFace_state.dart'; +import 'package:star_lock/tools/eventBusEventManage.dart'; + +import '../../../../../blue/blue_manage.dart'; +import '../../../../../blue/io_reply.dart'; +import '../../../../../blue/io_tool/io_tool.dart'; +import '../../../../../blue/io_tool/manager_event_bus.dart'; +import '../../../../../blue/sender_manage.dart'; +import '../../../../../network/api_repository.dart'; +import '../../../../../tools/baseGetXController.dart'; +import '../../../../../tools/storage.dart'; + +class AddFaceLogic extends BaseGetXController { + final AddFaceState state = AddFaceState(); + + // 监听设备返回的数据 + late StreamSubscription _replySubscription; + void _initReplySubscription() { + _replySubscription = + EventBusManager().eventBus!.on().listen((reply) async { + // 添加指纹开始 + if (reply is SenderAddFaceReply) { + _replyAddFaceBegin(reply); + } + + // 添加指纹过程 + if (reply is SenderAddFaceProcessReply) { + _replyAddFaceProcess(reply); + } + + // 添加指纹确认 + if (reply is SenderAddFaceConfirmationReply) { + _replyAddFaceConfirmation(reply); + } + }); + } + + Future _replyAddFaceBegin(Reply reply) async { + int status = reply.data[2]; + print("status:$status"); + + switch (status) { + case 0x00: + //成功 + print("${reply.commandType!.typeValue} 人脸开始数据解析成功"); + state.ifConnectScuess.value = true; + + // 最大图片数 + state.maxRegCount.value = reply.data[10]; + print("人脸开始state.maxRegCount.value:${state.maxRegCount.value}"); + // state.fingerprintNumber.value = reply.data.last.toString(); + break; + case 0x06: + //无权限 + print("${reply.commandType!.typeValue} 需要鉴权"); + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + var token = reply.data.sublist(5, 9); + var saveStrList = changeIntListToStringList(token); + print("_replyAddFaceReplyToken:$token"); + Storage.setStringList(saveBlueToken, saveStrList); + + IoSenderManage.senderAddFaceCommand( + keyID: "1", + userID: await Storage.getUid(), + faceNo: 1, + useCountLimit: 0xff, + // startTime:0x11223344, + // endTime:0x11223344, + startTime: state.startDate.value ~/ 1000, + endTime: state.endDate.value ~/ 1000, + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + token: token, + ); + break; + case 0x07: + //无权限 + print("${reply.commandType!.typeValue} 用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType!.typeValue} 权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType!.typeValue} 失败"); + + break; + } + } + + Future _replyAddFaceProcess(Reply reply) async { + int status = reply.data[2]; + print("33 status:$status"); + + switch (status) { + case 0x00: + //成功 + print("${reply.commandType!.typeValue} 注册人脸过程数据解析成功"); + if (reply.data[5] == 255) { + // 注册指纹失败 + print("${reply.commandType!.typeValue} 注册人脸过程失败"); + showToast("添加失败"); + Get.close(2); + } else { + // state.addFaceProcessNumber.value++; + + // 当前注册数 + state.regIndex.value = reply.data[6]; + print("state.regIndex.value:${state.regIndex.value}"); + } + break; + case 0x06: + //需要权限 + + break; + case 0x07: + //无权限 + print("${reply.commandType!.typeValue} 用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType!.typeValue} 权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType!.typeValue} 注册人脸过程default失败"); + + break; + } + } + + Future _replyAddFaceConfirmation(Reply reply) async { + int status = reply.data[2]; + print("status:$status"); + + switch (status) { + case 0x00: + //成功 + print("${reply.commandType!.typeValue} 人脸确认数据解析成功"); + // print("添加人脸确认成功,调用添加指纹接口"); + if (state.faceNumber.value == (reply.data[6]).toString()) { + return; + } else { + state.faceNumber.value = (reply.data[6]).toString(); + } + addFaceData(); + break; + case 0x06: + //需要权限 + + break; + case 0x07: + //无权限 + print("${reply.commandType!.typeValue} 用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType!.typeValue} 权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType!.typeValue} 人脸确认default失败"); + + break; + } + } + + // 添加人脸开始 + Future senderAddFace() async { + showBlueConnetctToastTimer(action: () { + Get.close(1); + }); + BlueManage().bludSendData(BlueManage().connectDeviceName, + (DeviceConnectionState deviceConnectionState) async { + if (deviceConnectionState == DeviceConnectionState.connected) { + cancelBlueConnetctToastTimer(); + var publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + print( + "openDoorTokenPubToken:$getTokenList state.startDate.value:${state.startDate.value}"); + + IoSenderManage.senderAddFaceCommand( + keyID: "1", + userID: await Storage.getUid(), + faceNo: 1, + useCountLimit: 0xff, + // startTime:0x11223344, + // endTime:0x11223344, + startTime: state.startDate.value ~/ 1000, + endTime: state.endDate.value ~/ 1000, + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList, + ); + } else if (deviceConnectionState == DeviceConnectionState.disconnected) { + if (state.ifCurrentScreen.value == true) { + showBlueConnetctToast(); + } + cancelBlueConnetctToastTimer(); + Get.close(1); + } + }); + } + + // 添加人脸 + void addFaceData() async { + var entity = await ApiRepository.to.addFaceData( + lockId: state.lockId.value, + faceName: state.faceName.value, + faceNumber: state.faceNumber.value, + faceType: state.faceType.value, + startDate: state.startDate.value, + endDate: state.endDate.value, + featureData: state.featureData.value, + addType: state.addType.value, + cyclicConfig: state.cyclicConfig.value, + ); + + if (entity.errorCode!.codeIsSuccessful) { + // Toast.show(msg: "添加成功"); + updateFaceUserNoLoadData(entity.data!.fingerprintId.toString()); + } + } + + // 更新人脸用户账号 + void updateFaceUserNoLoadData(String faceId) async { + var entity = await ApiRepository.to.updateFaceUserNoLoadData( + faceId: faceId, + lockId: state.lockId.value.toString(), + faceUserNo: state.faceNumber.value, + ); + if (entity.errorCode!.codeIsSuccessful) { + showToast("添加成功"); + if (state.fromType.value == 2) { + // 回调人脸号 + eventBus + .fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(faceId)); + } else if (state.fromType.value == 1) { + eventBus.fire(OtherTypeRefreshListEvent()); + } + Get.close(2); + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + + _initReplySubscription(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); +//开始添加后发送指令 + // senderAddFace(); + } + + @override + void onClose() { + // TODO: implement onClose + super.onClose(); + + _replySubscription.cancel(); + } +} diff --git a/star_lock/lib/main/lockDetail/face/addFace/addFace_page.dart b/star_lock/lib/main/lockDetail/face/addFace/addFace_page.dart index a6a390e9..c0e363d5 100644 --- a/star_lock/lib/main/lockDetail/face/addFace/addFace_page.dart +++ b/star_lock/lib/main/lockDetail/face/addFace/addFace_page.dart @@ -1,39 +1,40 @@ import 'package:flutter/material.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/face/addFace/addFace_logic.dart'; -import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/submitBtn.dart'; import '../../../../../tools/titleAppBar.dart'; import '../../../../../translations/trans_lib.dart'; -class AddFaceTipPage extends StatefulWidget { - const AddFaceTipPage({Key? key}) : super(key: key); +class AddFacePage extends StatefulWidget { + const AddFacePage({Key? key}) : super(key: key); @override - State createState() => _AddFaceTipPageState(); + State createState() => _AddFacePageState(); } -class _AddFaceTipPageState extends State { +class _AddFacePageState extends State { + final logic = Get.put(AddFaceLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: TitleAppBar( - barTitle: "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}", + barTitle: + "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}", haveBack: true, backgroundColor: AppColors.mainColor), body: ListView( - // mainAxisAlignment: MainAxisAlignment.center, - // crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( height: 50.h, ), Image.asset( - 'images/main/icon_main_addFace.png', + 'images/main/icon_addFace_step1.png', width: 100.w, height: 457.h, fit: BoxFit.fitHeight, @@ -48,9 +49,8 @@ class _AddFaceTipPageState extends State { children: [ Expanded( child: Text( - "请单人正对门锁,距离一个成年人手臂长度(约0.6米).\n保持脸部无遮挡,露出五官", - // TranslationLoader.lanKeys!.lightTouchScreenTip!.tr, - textAlign: TextAlign.center, + "请单人正对门锁,距离一个成年人手臂长度\n(约0.6米)。\n保持脸部无遮挡,露出五官。", + textAlign: TextAlign.left, maxLines: null, style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600), @@ -62,15 +62,32 @@ class _AddFaceTipPageState extends State { SizedBox( height: 120.h, ), - Container( - padding: EdgeInsets.only(left: 20.w, right: 20.w), - child: SubmitBtn( - btnName: "开始添加", //TranslationLoader.lanKeys!.next!.tr, - borderRadius: 20.w, - onClick: () { - EasyLoading.showToast("请确保在设备附近,设备未被连接,设备已打开", duration: 2000.milliseconds); - }), - ), + Obx( + () => state.isClickAddFace.value == false + ? Container( + padding: EdgeInsets.only(left: 20.w, right: 20.w), + child: SubmitBtn( + btnName: + "准备好了,开始添加", //TranslationLoader.lanKeys!.next!.tr, + borderRadius: 20.w, + onClick: () { + state.isClickAddFace.value = true; + logic.senderAddFace(); + }), + ) + : Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '正在录入中...', + style: TextStyle( + color: AppColors.darkGrayTextColor, + fontSize: 22.sp), + textAlign: TextAlign.center, + ) + ], + ), + ) ], ), ); diff --git a/star_lock/lib/main/lockDetail/face/addFace/addFace_state.dart b/star_lock/lib/main/lockDetail/face/addFace/addFace_state.dart new file mode 100644 index 00000000..37d0b763 --- /dev/null +++ b/star_lock/lib/main/lockDetail/face/addFace/addFace_state.dart @@ -0,0 +1,35 @@ +import 'package:get/get.dart'; + +class AddFaceState { + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + + var ifConnectScuess = false.obs; + var maxRegCount = 0.obs; // 最大注册次数 + var regIndex = 0.obs; // 当前注册次数 + + var faceNumber = "".obs; + + final lockId = 0.obs; + final endDate = 0.obs; + final addType = "".obs; + final faceName = "".obs; + final faceType = 0.obs; + final startDate = 0.obs; + final cyclicConfig = [].obs; + final fromType = 1.obs; + final featureData = ''.obs; + final isClickAddFace = false.obs; + + AddFaceState() { + Map map = Get.arguments; + lockId.value = map["lockId"]; + endDate.value = map["endDate"]; + addType.value = map["addType"]; + faceName.value = map["faceName"]; + faceType.value = map["faceType"]; + startDate.value = map["startDate"]; + lockId.value = map["lockId"]; + cyclicConfig.value = map["cyclicConfig"]; + fromType.value = map["fromType"]; + } +} diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart index cb0d1ffd..3f4536e3 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart @@ -1,8 +1,96 @@ - +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/face/addFaceType/addFaceType_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; -import 'addFaceType_state.dart'; +import '../../../../appRouters.dart'; +import '../../../../network/api_repository.dart'; -class AddFaceTypeLogic extends BaseGetXController{ +class AddFaceTypeLogic extends BaseGetXController { AddFaceTypeState state = AddFaceTypeState(); -} \ No newline at end of file + // 添加指纹 + void addFaceData() async { + var faceType = 0; // 永久:1;限时2,单次3,循环:4 + var startDate = ""; + var endDate = ""; + if (state.seletType.value == "0") { + faceType = 1; + startDate = "0"; + endDate = "0"; + } else if (state.seletType.value == "1") { + faceType = 2; + if (state.beginTimeTimestamp.value.isEmpty) { + showToast("请选择开始时间"); + return; + } + if (state.endTimeTimestamp.value.isEmpty) { + showToast("请选择结束时间"); + return; + } + + // if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){ + // Toast.show(msg: "生效时间要大于当前时间"); + // return; + // } + + if (int.parse(state.beginTimeTimestamp.value) >= + int.parse(state.endTimeTimestamp.value)) { + showToast("失效时间要大于生效时间"); + return; + } + + startDate = state.beginTimeTimestamp.value; + endDate = state.endTimeTimestamp.value; + } else if (state.seletType.value == "2") { + if (state.effectiveDateTime.value <= 0) { + showToast("请选择生效时间"); + return; + } + if (state.failureDateTime.value <= 0) { + showToast("请选择失效时间"); + return; + } + + if (state.weekdaysList.value.isEmpty) { + showToast("请选择有效日"); + return; + } + + // if(DateTime.now().millisecondsSinceEpoch >= state.effectiveDateTime.value){ + // Toast.show(msg: "生效时间要大于当前时间"); + // return; + // } + + if (state.effectiveDateTime.value >= state.failureDateTime.value) { + showToast("失效时间要大于生效时间"); + return; + } + startDate = state.effectiveDateTime.value.toString(); + endDate = state.failureDateTime.value.toString(); + faceType = 4; + } + + // 人脸 + Get.toNamed(Routers.addFacePage, arguments: { + "lockId": state.lockId.value, + "endDate": int.parse(endDate), + "addType": "1", + "faceName": state.nameController.text, + "faceNumber": "123456", + "faceType": faceType, + "startDate": int.parse(startDate), + "cyclicConfig": state.weekdaysList.value, + "fromType": state.fromType.value, + }); + } + + // 校验指纹名字是否重复 + void checkFaceNameDuplicated(String faceName) async { + var entity = await ApiRepository.to.checkFaceNameDuplicatedData( + lockId: state.lockId.value.toString(), + faceName: faceName, + ); + if (entity.errorCode!.codeIsSuccessful) { + addFaceData(); + } + } +} diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart index 6a16b593..e6b1e4fd 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart @@ -181,8 +181,7 @@ class _AddFaceTypePageState extends State { logic.showToast("请输入姓名"); return; } - - Get.toNamed(Routers.addFaceTipPage); + logic.checkFaceNameDuplicated(state.nameController.text); } else { // Get.toNamed(Routers.seletLockTypePage); logic.showToast("演示模式"); @@ -293,19 +292,4 @@ class _AddFaceTypePageState extends State { ), ); } - - //isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹 - CupertinoSwitch _isStressFingerprint() { - return CupertinoSwitch( - activeColor: CupertinoColors.activeBlue, - trackColor: CupertinoColors.systemGrey5, - thumbColor: CupertinoColors.white, - value: true, - onChanged: (value) { - setState(() { - // state.isStressFingerprint.value = value; - }); - }, - ); - } } diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart index ea1ddc6c..b2b59331 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart @@ -1,16 +1,25 @@ - import 'package:flutter/material.dart'; import 'package:get/get.dart'; -class AddFaceTypeState{ - var beginTime = "".obs;// 开始时间 - var endTime = "".obs;// 结束时间 - var beginTimeTimestamp = "".obs;// 开始时间时间戳 - var endTimeTimestamp = "".obs;// 结束时间时间戳 +class AddFaceTypeState { + final lockId = 0.obs; + final seletType = "0".obs; // 0永久 1显示 2循环 + final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + final isStressFingerprint = false.obs; - var effectiveDateTime = 0.obs;// 生效时间 - var failureDateTime = 0.obs;// 失效时间 + var beginTime = "".obs; // 开始时间 + var endTime = "".obs; // 结束时间 + var beginTimeTimestamp = "".obs; // 开始时间时间戳 + var endTimeTimestamp = "".obs; // 结束时间时间戳 + + var effectiveDateTime = 0.obs; // 生效时间 + var failureDateTime = 0.obs; // 失效时间 var weekdaysList = [].obs; final TextEditingController nameController = TextEditingController(); -} \ No newline at end of file + AddFaceTypeState() { + Map map = Get.arguments; + lockId.value = map["lockId"]; + fromType.value = map["fromType"]; + } +} diff --git a/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart b/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart new file mode 100644 index 00000000..709887f5 --- /dev/null +++ b/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart @@ -0,0 +1,193 @@ +import 'dart:async'; + +import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/blue/io_type.dart'; +import 'package:star_lock/main/lockDetail/face/faceDetail/faceDetail_state.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../blue/io_protocol/io_addFingerprint.dart'; +import '../../../../blue/io_reply.dart'; +import '../../../../blue/io_tool/io_tool.dart'; +import '../../../../blue/io_tool/manager_event_bus.dart'; +import '../../../../blue/sender_manage.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/storage.dart'; + +class FaceDetailLogic extends BaseGetXController { + FaceDetailState state = FaceDetailState(); + + // 获取解析后的数据 + late StreamSubscription _replySubscription; + void _initReplySubscription() { + _replySubscription = + EventBusManager().eventBus!.on().listen((reply) { + // 添加指纹开始(此处用作删除指纹) + if ((reply is SenderAddFingerprintReply)) { + _replyAddFingerprintBegin(reply); + } + }); + } + + // 添加指纹开始 + Future _replyAddFingerprintBegin(Reply reply) async { + int status = reply.data[2]; + print("status:$status"); + + switch (status) { + case 0x00: + //成功 + print("${reply.commandType!.typeValue} 数据解析成功"); + state.sureBtnState.value = 0; + cancelBlueConnetctToastTimer(); + dismissEasyLoading(); + deletFingerprintsData(); + break; + case 0x06: + //无权限 + print("${reply.commandType!.typeValue} 需要鉴权"); + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + String? userID = await Storage.getUid(); + IoSenderManage.senderAddFingerprintCommand( + keyID: state.keyId.value.toString(), + userID: userID, + fingerNo: int.parse(state.typeNumber.value), + useCountLimit: 0, + startTime: state.effectiveDateTime.value, + endTime: state.failureDateTime.value, + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList, + ); + break; + case 0x07: + //无权限 + print("${reply.commandType!.typeValue} 用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType!.typeValue} 权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType!.typeValue} 失败"); + + break; + } + } + + // 删除指纹 + Future senderAddFingerprint() async { + if (state.sureBtnState.value == 1) { + return; + } + state.sureBtnState.value = 1; + + showEasyLoading(); + showBlueConnetctToastTimer(action: () { + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); + BlueManage().bludSendData(BlueManage().connectDeviceName, + (DeviceConnectionState deviceConnectionState) async { + if (deviceConnectionState == DeviceConnectionState.connected) { + var publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + String? userID = await Storage.getUid(); + + IoSenderManage.senderAddFingerprintCommand( + keyID: state.keyId.value.toString(), + userID: userID, + fingerNo: int.parse(state.typeNumber.value), + useCountLimit: 0, + startTime: state.effectiveDateTime.value, + endTime: state.failureDateTime.value, + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList, + ); + } else if (deviceConnectionState == DeviceConnectionState.disconnected) { + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if (state.ifCurrentScreen.value == true) { + showBlueConnetctToast(); + } + } + }); + } + + // 删除指纹 + void deletFingerprintsData() async { + var entity = await ApiRepository.to.deletFingerprintsData( + fingerprintId: state.faceItemData.value.faceId.toString(), + lockId: state.faceItemData.value.lockId.toString(), + type: "0", + deleteType: "1"); + if (entity.errorCode!.codeIsSuccessful) { + showToast("删除成功", something: () { + Get.back(result: "addScuess"); + }); + } + } + + // 编辑指纹 + void editFingerprintsData() async { + var entity = await ApiRepository.to.editFingerprintsData( + fingerprintId: state.keyId.value.toString(), + lockId: state.faceItemData.value.lockId.toString(), + weekDay: state.weekDay.value, + startDate: state.effectiveDateTime.value.toString(), + endDate: state.failureDateTime.value.toString(), + isCoerced: state.isStressFingerprint.value ? "2" : "1", + fingerprintName: state.changeNameController.text, + changeType: "1", + ); + if (entity.errorCode!.codeIsSuccessful) { + showToast("修改成功", something: () { + Get.back(result: "addScuess"); + }); + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + + _initReplySubscription(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + } + + @override + void onClose() { + // TODO: implement onClose + super.onClose(); + + _replySubscription.cancel(); + } +} diff --git a/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart b/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart index e69de29b..26023d6a 100644 --- a/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart +++ b/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart @@ -0,0 +1,374 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/face/faceDetail/faceDetail_logic.dart'; + +import '../../../../appRouters.dart'; +import '../../../../app_settings/app_colors.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../tools/appRouteObserver.dart'; +import '../../../../tools/commonItem.dart'; +import '../../../../tools/dateTool.dart'; +import '../../../../tools/showIosTipView.dart'; +import '../../../../tools/showTFView.dart'; +import '../../../../tools/submitBtn.dart'; +import '../../../../tools/titleAppBar.dart'; +import '../../../../translations/trans_lib.dart'; + +class FaceDetailPage extends StatefulWidget { + const FaceDetailPage({Key? key}) : super(key: key); + + @override + State createState() => _FingerprintDetailPageState(); +} + +class _FingerprintDetailPageState extends State + with RouteAware { + final logic = Get.put(FaceDetailLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: "指纹详情", + haveBack: true, + backgroundColor: AppColors.mainColor, + // actionsList: [ + // TextButton( + // child: Text(TranslationLoader.lanKeys!.share!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp),), + // onPressed: () { + // + // }, + // ), + // ], + ), + body: Column( + children: [ + Obx(() => CommonItem( + leftTitel: + "${TranslationLoader.lanKeys!.fingerprint!.tr}${TranslationLoader.lanKeys!.number!.tr}", + rightTitle: state.typeNumber.value, + isHaveDirection: false, + isHaveLine: true)), + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.name!.tr, + rightTitle: state.typeName.value, + isHaveDirection: true, + isHaveLine: true, + action: () { + showCupertinoAlertDialog(context); + })), + Obx(() => Visibility( + visible: (state.keyType.value == 4 || state.keyType.value == 2) + ? true + : false, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, + allHeight: 70.h, + // rightTitle:"2023.09.19 11:27\n2023.09.25 11:27", + rightTitle: state.keyType.value == 1 + ? "永久" + : "${DateTool().dateToYMDHNString(state.effectiveDateTime.value.toString())}\n${DateTool().dateToYMDHNString(state.failureDateTime.value.toString())}", + isHaveDirection: true, + isHaveLine: true, + action: () async { + // switch(state.type.value){ + // case 0: + // // 卡 + // + // break; + // case 1: + // 当是指纹的时候 + if (state.keyType.value == 2) { + // 限时 + var data = await Get.toNamed( + Routers.otherTypeKeyChangeDatePage, + arguments: { + "fingerprintItemData": state.faceItemData.value, + "pushType": 1, + }); + if (data != null) { + setState(() { + state.effectiveDateTime.value = + data["beginTimeTimestamp"]; + state.failureDateTime.value = + data["endTimeTimestamp"]; + }); + } + } else if (state.keyType.value == 4) { + // 循环 + var data = await Get.toNamed( + Routers.otherTypeKeyChangeValidityDatePage, + arguments: { + "fingerprintItemData": state.faceItemData.value, + }); + if (data != null) { + setState(() { + state.effectiveDateTime.value = + data["beginTimeTimestamp"]; + state.failureDateTime.value = + data["endTimeTimestamp"]; + state.weekDay.value = data["weekDay"]; + }); + } + } + }))), + Obx(() => Visibility( + visible: state.keyType.value == 4 ? true : false, + child: Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr, + rightTitle: state.weekDay.value.join(','), + isHaveDirection: true, + action: () async { + // 当是指纹的时候 + var data = await Get.toNamed( + Routers.otherTypeKeyChangeValidityDatePage, + arguments: { + "fingerprintItemData": state.faceItemData.value, + }); + if (data != null) { + setState(() { + state.effectiveDateTime.value = + data["beginTimeTimestamp"]; + state.failureDateTime.value = data["endTimeTimestamp"]; + state.weekDay.value = data["weekDay"]; + }); + } + })))), + Container(height: 10.h), + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.additive!.tr, + rightTitle: state.adder.value, + isHaveLine: true, + action: () {})), + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.addTime!.tr, + rightTitle: + DateTool().dateToYMDHNString(state.addTime.value.toString()), + action: () {})), + SizedBox(height: 10.h), + + Container(height: 10.h), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.operatingRecord!.tr, + rightTitle: "", + isHaveDirection: true, + action: () { + // 人脸 + Get.toNamed(Routers.keyOperationRecordPage, arguments: { + 'lockId': state.faceItemData.value.lockId.toString(), + 'faceId': state.faceItemData.value.faceId.toString() + }); + }), + // SizedBox(height: 40.h), + // addControlsBtn(type), + SizedBox(height: 30.h), + SubmitBtn( + btnName: TranslationLoader.lanKeys!.delete!.tr, + isDelete: true, + borderRadius: 20.w, + margin: EdgeInsets.only( + left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), + padding: EdgeInsets.only(top: 25.w, bottom: 25.w), + onClick: () { + showIosTipViewDialog(context); + }), + ], + ), + ); + } + + // Widget addControlsBtn(int type) { + // List widgetList = []; + // List> routerList = []; + // //卡详情 + // if (type == 0) { + // routerList.add({ + // 'btnTitle': '设置密码', + // 'routerName': Routers.passwordKeyDetailPage, + // 'type': 9 + // }); + // routerList.add({ + // 'btnTitle': '设置指纹', + // 'routerName': Routers.otherTypeKeyManagePage, + // 'type': 1 + // }); + // routerList.add({ + // 'btnTitle': '设置遥控', + // 'routerName': Routers.otherTypeKeyManagePage, + // 'type': 2 + // }); + // } else if (type == 1) { + // //指纹详情 + // routerList.add({ + // 'btnTitle': '设置密码', + // 'routerName': Routers.passwordKeyDetailPage, + // 'type': 9 + // }); + // routerList.add({ + // 'btnTitle': '设置卡', + // 'routerName': Routers.otherTypeKeyManagePage, + // 'type': 0 + // }); + // routerList.add({ + // 'btnTitle': '设置遥控', + // 'routerName': Routers.otherTypeKeyManagePage, + // 'type': 2 + // }); + // } else if (type == 2) { + // //遥控详情 + // routerList.add({ + // 'btnTitle': '设置密码', + // 'routerName': Routers.passwordKeyDetailPage, + // 'type': 9 + // }); + // routerList.add({ + // 'btnTitle': '设置卡', + // 'routerName': Routers.otherTypeKeyManagePage, + // 'type': 0 + // }); + // routerList.add({ + // 'btnTitle': '设置指纹', + // 'routerName': Routers.otherTypeKeyManagePage, + // 'type': 1 + // }); + // } + // + // for (int i = 0; i < routerList.length; i++) { + // widgetList.add(SizedBox( + // width: ScreenUtil().screenWidth - 40.w, + // height: 60.h, + // child: OutlinedButton( + // style: OutlinedButton.styleFrom( + // // backgroundColor: Colors.white, + // side: BorderSide(width: 1, color: AppColors.mainColor)), + // onPressed: () { + // if (routerList[i]['type'] == 9) { + // Navigator.pushNamed(context, Routers.passwordKeyManagePage); + // } else { + // Navigator.pushNamed(context, Routers.otherTypeKeyManagePage, + // arguments: routerList[i]['type']); + // } + // }, + // child: Text( + // routerList[i]['btnTitle'], + // style: TextStyle(color: AppColors.mainColor, fontSize: 24.sp), + // )), + // )); + // + // widgetList.add( + // SizedBox( + // height: 10.h, + // ), + // ); + // } + // + // return Column( + // children: widgetList, + // ); + // } + + void showCupertinoAlertDialog(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return ShowTFView( + title: + "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}", + tipTitle: "", + controller: state.changeNameController, + sureClick: () { + if (state.changeNameController.text.isEmpty) { + logic.showToast("请输入姓名"); + return; + } + Get.back(); + // 指纹 + logic.editFingerprintsData(); + }, + cancelClick: () { + Get.back(); + }, + ); + }); + } + + void showIosTipViewDialog(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return ShowIosTipView( + title: "提示", + tipTitle: "确定要删除吗?", + sureClick: () { + Get.back(); + // 指纹 + logic.senderAddFingerprint(); + }, + cancelClick: () { + Get.back(); + }, + ); + }); + } + + @override + void didChangeDependencies() { + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + // TODO: implement dispose + /// 取消路由订阅 + AppRouteObserver().routeObserver.unsubscribe(this); + super.dispose(); + } + + /// 从上级界面进入 当前界面即将出现 + @override + void didPush() { + super.didPush(); + print("lockSet===didPush"); + state.ifCurrentScreen.value = true; + } + + /// 返回上一个界面 当前界面即将消失 + @override + void didPop() { + super.didPop(); + print("lockSet===didPop"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + + /// 从下级返回 当前界面即将出现 + @override + void didPopNext() { + super.didPopNext(); + print("lockSet===didPopNext"); + state.ifCurrentScreen.value = true; + } + + /// 进入下级界面 当前界面即将消失 + @override + void didPushNext() { + super.didPushNext(); + print("lockSet===didPushNext"); + logic.cancelBlueConnetctToastTimer(); + if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + BlueManage().stopScan(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } +} diff --git a/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_state.dart b/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_state.dart new file mode 100644 index 00000000..d631d6db --- /dev/null +++ b/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_state.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/face/faceList/faceListData_entity.dart'; + +class FaceDetailState { + final faceItemData = FaceItemData().obs; + + final TextEditingController changeNameController = TextEditingController(); + + final typeNumber = "".obs; // 指纹号 + final typeName = "".obs; // 指纹名字 + var effectiveDateTime = 0.obs; // 生效时间 + var failureDateTime = 0.obs; // 失效时间 + final keyType = 0.obs; // 永久:1;限时2,单次3,循环:4 + var weekDay = [].obs; // 有效日 + var adder = "".obs; // 添加者 + var addTime = 0.obs; // 添加时间 + var keyId = 0.obs; + + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs; // 0普通状态(可用) 1连接中(不可用) + + final isStressFingerprint = false.obs; + FaceDetailState() { + Map map = Get.arguments; + faceItemData.value = map["faceItemData"]; + keyId.value = faceItemData.value.faceId!; + typeNumber.value = faceItemData.value.faceNumber!; + typeName.value = faceItemData.value.faceName!; + changeNameController.text = typeName.value; + effectiveDateTime.value = faceItemData.value.startDate!; + failureDateTime.value = faceItemData.value.endDate!; + keyType.value = faceItemData.value.faceType!; + adder.value = faceItemData.value.senderUsername!; + addTime.value = faceItemData.value.createDate!; + weekDay.value = faceItemData.value.cyclicConfig!; + } +} diff --git a/star_lock/lib/main/lockDetail/face/faceList/faceListData_entity.dart b/star_lock/lib/main/lockDetail/face/faceList/faceListData_entity.dart new file mode 100644 index 00000000..942f823c --- /dev/null +++ b/star_lock/lib/main/lockDetail/face/faceList/faceListData_entity.dart @@ -0,0 +1,131 @@ +class FaceListDataEntity { + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + FaceListDataEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + FaceListDataEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? Data.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + List? list; + int? pageNo; + int? pageSize; + int? pages; + int? total; + + Data({this.list, this.pageNo, this.pageSize, this.pages, this.total}); + + Data.fromJson(Map json) { + if (json['list'] != null) { + list = []; + json['list'].forEach((v) { + list!.add(FaceItemData.fromJson(v)); + }); + } + pageNo = json['pageNo']; + pageSize = json['pageSize']; + pages = json['pages']; + total = json['total']; + } + + Map toJson() { + final Map data = {}; + if (list != null) { + data['list'] = list!.map((v) => v.toJson()).toList(); + } + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + data['pages'] = pages; + data['total'] = total; + return data; + } +} + +class FaceItemData { + int? lockId; + int? faceId; + String? faceName; + String? faceNumber; + int? startDate; + int? endDate; + int? status; + int? addType; + int? faceType; + List? cyclicConfig; + String? featureData; + int? createDate; + String? senderUsername; + String? validTimeStr; + + FaceItemData( + {this.lockId, + this.faceId, + this.faceName, + this.faceNumber, + this.startDate, + this.endDate, + this.status, + this.addType, + this.faceType, + this.cyclicConfig, + this.featureData, + this.createDate, + this.senderUsername, + this.validTimeStr}); + + FaceItemData.fromJson(Map json) { + lockId = json['lockId']; + faceId = json['faceId']; + faceName = json['faceName']; + faceNumber = json['faceNumber']; + startDate = json['startDate']; + endDate = json['endDate']; + status = json['status']; + addType = json['addType']; + faceType = json['faceType']; + cyclicConfig = json['cyclicConfig']; + featureData = json['featureData']; + createDate = json['createDate']; + senderUsername = json['senderUsername']; + validTimeStr = json['validTimeStr']; + } + + Map toJson() { + final Map data = {}; + data['lockId'] = lockId; + data['faceId'] = faceId; + data['faceName'] = faceName; + data['faceNumber'] = faceNumber; + data['startDate'] = startDate; + data['endDate'] = endDate; + data['status'] = status; + data['addType'] = addType; + data['faceType'] = faceType; + data['cyclicConfig'] = cyclicConfig; + data['featureData'] = featureData; + data['createDate'] = createDate; + data['senderUsername'] = senderUsername; + data['validTimeStr'] = validTimeStr; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/face/faceList/faceList_logic.dart b/star_lock/lib/main/lockDetail/face/faceList/faceList_logic.dart index 00cff678..6d04677c 100644 --- a/star_lock/lib/main/lockDetail/face/faceList/faceList_logic.dart +++ b/star_lock/lib/main/lockDetail/face/faceList/faceList_logic.dart @@ -1,8 +1,427 @@ +import 'dart:async'; +import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; +import 'package:star_lock/blue/io_protocol/io_addFace.dart'; +import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart'; +import 'package:star_lock/blue/io_type.dart'; +import 'package:star_lock/main/lockDetail/face/faceList/faceList_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; -import 'faceList_state.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../blue/io_protocol/io_checkingUserInfoCount.dart'; +import '../../../../blue/io_reply.dart'; +import '../../../../blue/io_tool/io_tool.dart'; +import '../../../../blue/io_tool/manager_event_bus.dart'; +import '../../../../blue/sender_manage.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/storage.dart'; -class FaceListLogic extends BaseGetXController{ +class FaceListLogic extends BaseGetXController { FaceListState state = FaceListState(); -} \ No newline at end of file + // 获取解析后的数据 + late StreamSubscription _replySubscription; + void _initReplySubscription() { + _replySubscription = + EventBusManager().eventBus!.on().listen((reply) { + // 添加人脸开始(此处用作删除人脸) + if ((reply is SenderAddFaceReply) && (state.isDeletFaceData == true)) { + _replyAddFaceBegin(reply); + } + + if (reply is SenderQueryingFaceStatusReply) { + // 获取人脸状态 + _replyQueryingFaceStatus(reply); + } + + if (reply is SenderCheckingUserInfoCountReply) { + _replyCheckingUserInfoCount(reply); + } + }); + } + + // 添加人脸开始---这里用作删除人脸 + Future _replyAddFaceBegin(Reply reply) async { + int status = reply.data[2]; + print("status:$status"); + + switch (status) { + case 0x00: + //成功 + print("${reply.commandType!.typeValue} list人脸数据解析成功"); + state.isDeletFaceData = false; + cancelBlueConnetctToastTimer(); + dismissEasyLoading(); + deletAllFacesData(); + break; + case 0x06: + //无权限 + print("${reply.commandType!.typeValue} 需要鉴权"); + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + IoSenderManage.senderAddFaceCommand( + keyID: state.deletKeyID, + userID: state.deletUserID, + faceNo: state.deletFaceNo, + useCountLimit: 0, + startTime: 0x11223344, + endTime: 0x11223344, + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList, + ); + break; + case 0x07: + //无权限 + print("${reply.commandType!.typeValue} 用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType!.typeValue} 权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType!.typeValue} list人脸失败"); + + break; + } + } + + // 获取人脸状态 + Future _replyQueryingFaceStatus(Reply reply) async { + int status = reply.data[2]; + + switch (status) { + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + // _getLockStatus(); + break; + case 0x06: + //无权限 + print("${reply.commandType}需要鉴权"); + + break; + case 0x07: + //无权限 + print("${reply.commandType}用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType}权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType}失败"); + + break; + } + } + + // 获取卡片状态 + Future _replyReferEventRecordNumber(Reply reply) async { + int status = reply.data[2]; + switch (status) { + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + // _getLockStatus(); + break; + case 0x06: + //无权限 + print("${reply.commandType}需要鉴权"); + + break; + case 0x07: + //无权限 + print("${reply.commandType}用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType}权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType}失败"); + + break; + } + } + + // 查询用户、指纹、密码、卡片数量(用于判断是否同步) + Future _replyCheckingUserInfoCount(Reply reply) async { + int status = reply.data[2]; + + // 用户数量 + int userNum = reply.data[5]; + // print("userNum:$userNum"); + + // 指纹数量 + int fingerNum = reply.data[6]; + // print("fingerNum:$fingerNum"); + + // 密码数量 + int pwdNum = reply.data[7]; + + // 卡片数量 + int cardNum = reply.data[8]; + + // 记录数量 + int logsNum = reply.data[9]; + + // 版本 + int verNo = reply.data[10]; + + // 最大管理员指纹数量 + int maxAdminFingerNum = reply.data[11]; + + // 最大用户指纹数量 + int maxUserFingerNum = reply.data[12]; + + // 最大管理员密码数量 + int maxAdminPassNum = reply.data[13]; + + // 最大用户密码数量 + int maxUserPassNum = reply.data[14]; + + // 最大管理员卡片数量 + int maxAdminCardNum = reply.data[15]; + + // 最大用户卡片数量 + int maxUserCardNum = reply.data[16]; + + // 序列号 + var serialNo = reply.data.sublist(17, 21); + print("serialNo:$serialNo"); + + switch (status) { + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + // _getLockStatus(); + break; + case 0x06: + //无权限 + print("${reply.commandType}需要鉴权"); + + break; + case 0x07: + //无权限 + print("${reply.commandType}用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType}权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType}失败"); + + break; + } + } + + // 获取人脸状态 + Future senderQueryingFaceStatus() async { + BlueManage().bludSendData(BlueManage().connectDeviceName, + (DeviceConnectionState state) async { + if (state == DeviceConnectionState.connected) { + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List getPublicKeyList = changeStringListToIntList(publicKey!); + + IoSenderManage.senderQueryingFaceStatusCommand( + keyID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + role: 0xff, + fingerCount: 20, + fingerNo: 1, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList, + ); + } + }); + } + + // 查询用户、指纹、密码、卡片数量(用于判断是否同步) + Future senderCheckingUserInfoCount() async { + BlueManage().bludSendData(BlueManage().connectDeviceName, + (DeviceConnectionState state) async { + if (state == DeviceConnectionState.connected) { + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List getPublicKeyList = changeStringListToIntList(publicKey!); + + IoSenderManage.senderCheckingUserInfoCountCommand( + keyID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + role: 0xff, + nowTime: DateTime.now().millisecondsSinceEpoch ~/ 1000, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList, + ); + } + }); + } + + // 删除人脸 + Future senderAddFace() async { + showEasyLoading(); + showBlueConnetctToastTimer(action: () { + dismissEasyLoading(); + }); + BlueManage().bludSendData(BlueManage().connectDeviceName, + (DeviceConnectionState deviceConnectionState) async { + if (deviceConnectionState == DeviceConnectionState.connected) { + var publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + IoSenderManage.senderAddFaceCommand( + keyID: state.deletKeyID, + userID: state.deletUserID, + faceNo: state.deletFaceNo, + useCountLimit: 0, + startTime: 0x11223344, + endTime: 0x11223344, + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList, + ); + } else if (deviceConnectionState == DeviceConnectionState.disconnected) { + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + if (state.ifCurrentScreen.value == true) { + showBlueConnetctToast(); + } + } + }); + } + + // 获取人脸列表 + void getFaceListData() async { + var entity = await ApiRepository.to.getFaceListData( + lockId: state.lockId.value.toString(), + pageNo: '1', + pageSize: '20', + searchStr: state.searchController.text, + ); + if (entity.errorCode!.codeIsSuccessful) { + state.faceItemListData.value = entity.data!.list!; + } + } + + // 重置所有的人脸 + void deletAllFacesData() async { + var fingerprintId = ""; + var type = "1"; + if (state.isDeletAll == false) { + fingerprintId = state.deletKeyID; + type = "0"; + } + print("delet fingerprintId $fingerprintId"); + var entity = await ApiRepository.to.deletFingerprintsData( + fingerprintId: fingerprintId, + lockId: state.lockId.value.toString(), + type: type, + deleteType: "1"); + if (entity.errorCode!.codeIsSuccessful) { + if (state.isDeletAll == false) { + showToast("删除成功"); + } else { + showToast("重置成功"); + } + + state.isDeletFaceData = false; + getFaceListData(); + } + } + + // 监听修改完详情之后刷新列表 + late StreamSubscription _teamEvent; + void _initRefreshAction() { + _teamEvent = eventBus.on().listen((event) { + getFaceListData(); + }); + } + + @override + Future onReady() async { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + // 获取是否是演示模式 演示模式不获取接口 + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + // print("aaaaaaa:$isDemoMode"); + if (isDemoMode == false) { + _initReplySubscription(); + + _initRefreshAction(); + + getFaceListData(); + } + } + + @override + Future onInit() async { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + // senderQueryingFingerprintStatus(); + // senderCheckingCardStatus(); + + // senderCheckingUserInfoCount(); + } + } + + @override + Future onClose() async { + // TODO: implement onClose + super.onClose(); + + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + _replySubscription.cancel(); + _teamEvent.cancel(); + } + } +} diff --git a/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart b/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart index be012428..f516c027 100644 --- a/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart +++ b/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart @@ -1,8 +1,10 @@ - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/face/faceList/faceListData_entity.dart'; +import 'package:star_lock/tools/keySearchWidget.dart'; +import 'package:star_lock/tools/left_slide_actions.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -53,86 +55,99 @@ class _FaceListState extends State { ), body: Column( children: [ - _searchWidget(), + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { + logic.getFaceListData(); + }, + ), SizedBox( height: 20.h, ), Expanded(child: _buildMainUI()), AddBottomWhiteBtn( btnName: - '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.face!.tr}', + '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.face!.tr}', onClick: () async { var data = - await Get.toNamed(Routers.addFaceTypeManagePage); + await Get.toNamed(Routers.addFaceTypeManagePage, arguments: { + "lockId": state.lockId.value, + "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + }); if (data != null) { - // 遥控添加 - + logic.getFaceListData(); } }, ), - SizedBox( - height: 64.h, - ) + SizedBox(height: 64.h) ], ), ); } - Widget _searchWidget() { - return Container( - height: 60.h, - margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), - decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(5)), - child: TextField( - //输入框一行 - maxLines: 1, - controller: state.searchController, - autofocus: false, - onChanged: (value) { - print("onChanged:$value"); - }, - onEditingComplete: () { - print("onEditingComplete:"); - }, - onSubmitted: (value) { - // 调用遥控列表 - - }, - decoration: InputDecoration( - //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only( - top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), - hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, - hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), - //不需要输入框下划线 - border: InputBorder.none, - //左边图标设置 - icon: Padding( - padding: EdgeInsets.only( - top: 20.h, bottom: 20.h, right: 20.w, left: 10.w), - child: Image.asset( - 'images/main/icon_main_search.png', - width: 40.w, - height: 40.w, - ), - ), - ), - ), - ); - } - Widget _buildMainUI() { - String typeImgName = 'images/icon_card.png'; - - return const NoData(); + { + return Obx(() => state.faceItemListData.value.isNotEmpty + ? ListView.separated( + itemCount: state.faceItemListData.value.length, + itemBuilder: (c, index) { + FaceItemData getFaceItemData = + state.faceItemListData.value[index]; + // 人脸 + if (index < state.faceItemListData.value.length) { + return LeftSlideActions( + key: Key(getFaceItemData.faceName!), + actionsWidth: 60, + actions: [ + _buildDeleteBtn(getFaceItemData), + ], + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(1)), + ), + child: _keyItem( + 'images/icon_fingerprint.png', + getFaceItemData.faceName!, + (getFaceItemData.faceType! != 1) + ? (getFaceItemData.endDate! < + DateTime.now().millisecondsSinceEpoch + ? "已失效" + : "") + : "", + getFaceItemData.validTimeStr!, + // fingerprintItemData.fingerprintType! == 1 + // ? "永久" + // : "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}", + () async { + var data = + await Get.toNamed(Routers.faceDetailPage, arguments: { + "faceItemData": getFaceItemData, + }); + if (data != null) { + logic.getFaceListData(); + } + }), + ); + } + return const SizedBox.shrink(); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + ) + : const NoData()); + } } - Widget _buildDeleteBtn(String idStr) { + Widget _buildDeleteBtn(FaceItemData faceItemData) { return GestureDetector( onTap: () { // 省略: 弹出是否删除的确认对话框。 - showIosTipViewDialog(context, idStr); + state.deletKeyID = faceItemData.faceId.toString(); + state.deletFaceNo = int.parse(faceItemData.faceNumber!); + showIosTipViewDialog(context); }, child: Container( width: 60, @@ -151,7 +166,7 @@ class _FaceListState extends State { ); } - void showIosTipViewDialog(BuildContext context, String keyId) { + void showIosTipViewDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { @@ -159,8 +174,11 @@ class _FaceListState extends State { title: "提示", tipTitle: "确定要删除吗?", sureClick: () async { - // 遥控删除 - + Get.back(); + state.isDeletFaceData = true; + state.isDeletAll = false; + state.deletUserID = (await Storage.getUid())!; + logic.senderAddFace(); }, cancelClick: () { Get.back(); @@ -170,8 +188,8 @@ class _FaceListState extends State { ); } - Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String showTime, - Function() action) { + Widget _keyItem(String lockTypeIcon, String lockTypeTitle, + String ifInvalidation, String showTime, Function() action) { return GestureDetector( onTap: action, child: Container( @@ -192,24 +210,26 @@ class _FaceListState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Row( - mainAxisAlignment: MainAxisAlignment.start, + // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(lockTypeTitle, style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor)), + Expanded(child: Container()), + Text(ifInvalidation, + style: TextStyle(fontSize: 22.sp, color: Colors.red)), + SizedBox(width: 10.w), ], ), SizedBox(height: 5.h), - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text(showTime, - style: TextStyle( - fontSize: 18.sp, - color: AppColors.placeholderTextColor)), - ], - ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text(showTime, + style: TextStyle( + fontSize: 18.sp, + color: AppColors.placeholderTextColor)), + ], ), SizedBox(width: 20.h), ], @@ -222,13 +242,13 @@ class _FaceListState extends State { ); } - void showDeletAlertDialog(BuildContext context,) { + void showDeletAlertDialog(BuildContext context) { showCupertinoDialog( context: context, builder: (context) { return CupertinoAlertDialog( title: const Text("提示"), - content: const Text('重置后信息都会清除哦,确认要重置吗?'), + content: const Text('重置后,该锁的人脸都将被删除哦,确认要重置吗?'), actions: [ CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.cancel!.tr), @@ -239,8 +259,13 @@ class _FaceListState extends State { CupertinoDialogAction( child: Text(TranslationLoader.lanKeys!.sure!.tr), onPressed: () { - // 遥控重置 - + Navigator.pop(context); + state.isDeletFaceData = true; + state.isDeletAll = true; + state.deletKeyID = "1"; + state.deletUserID = "DeleteAll!@#"; + state.deletFaceNo = 255; + logic.senderAddFace(); }, ), ], diff --git a/star_lock/lib/main/lockDetail/face/faceList/faceList_state.dart b/star_lock/lib/main/lockDetail/face/faceList/faceList_state.dart index be495903..4f3f072e 100644 --- a/star_lock/lib/main/lockDetail/face/faceList/faceList_state.dart +++ b/star_lock/lib/main/lockDetail/face/faceList/faceList_state.dart @@ -1,6 +1,24 @@ - import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/face/faceList/faceListData_entity.dart'; -class FaceListState{ +class FaceListState { final TextEditingController searchController = TextEditingController(); -} \ No newline at end of file + final lockId = 0.obs; + + // 因为删除跟添加人脸用的同一个协议 所以这里用做判断 + var isDeletFaceData = false; + var isDeletAll = false; + var deletKeyID = ""; + var deletUserID = "DeleteAll!@#"; + var deletFaceNo = 0; + + final faceItemListData = [].obs; + + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + + FaceListState() { + Map map = Get.arguments; + lockId.value = map["lockId"]; + } +} diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 68145668..1276b0d9 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -105,6 +105,11 @@ abstract class Api { final String checkFingerprintNameURL = '/fingerprint/checkFingerprintName'; // 校验指纹名字是否存在 + final String getFaceListURL = '/face/list'; // 人脸列表 + final String addFaceURL = '/face/add'; // 添加人脸 + final String checkFaceNameURL = '/face/checkFaceName'; // 校验人脸名称是否重复 + final String updateFaceUserNoURL = '/face/updateFaceUserNo'; // 更新人脸用户序号 + final String getICCardListURL = '/identityCard/list'; // IC卡列表 final String addICCardURL = '/identityCard/add'; // 添加IC卡 final String editICCardURL = '/identityCard/update'; // 编辑IC卡 diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 7cdd771f..5877e0a9 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -169,9 +169,9 @@ class ApiProvider extends BaseProvider { })); Future modifyKeyName( - String keyId, - String lockId, - String keyName, + String keyId, + String lockId, + String keyName, ) => post( modifyKeyNameURL.toUrl, @@ -261,7 +261,7 @@ class ApiProvider extends BaseProvider { 'lockId': lockId, 'records': records, }), - isUnShowLoading:true); + isUnShowLoading: true); // 查询锁记录最后时间 Future getLockRecordLastUploadDataTime(String lockId) => post( @@ -346,10 +346,7 @@ class ApiProvider extends BaseProvider { // 删除拥有的当前钥匙 Future deletOwnerKeyInfo(String lockId, String keyId) => post( deleteElectronicKeyURL.toUrl, - jsonEncode({ - 'lockId': lockId, - 'keyId': keyId - })); + jsonEncode({'lockId': lockId, 'keyId': keyId})); // 检查账户密码 Future checkLoginPassword(String password) => post( @@ -477,9 +474,9 @@ class ApiProvider extends BaseProvider { // 删除组 Future deleteGroup(int groupId) => post( lockDeletGroupURL.toUrl, - jsonEncode({ - 'groupId': groupId, - })); + jsonEncode({ + 'groupId': groupId, + })); // 锁分组里面添加锁 Future lockGroupAddLock(List lockIds, int groupId) => post( @@ -555,7 +552,8 @@ class ApiProvider extends BaseProvider { /// 锁设置模块 // 自动闭锁 - Future setAutoUnlockLoadData(int lockId, int autoLock, int autoLockSecond) => + Future setAutoUnlockLoadData( + int lockId, int autoLock, int autoLockSecond) => post( updateLockSettingUrl.toUrl, jsonEncode({ @@ -565,7 +563,8 @@ class ApiProvider extends BaseProvider { })); // 锁声音 - Future setLockSoundData(int lockId, int lockSound, int lockSoundVolume) => + Future setLockSoundData( + int lockId, int lockSound, int lockSoundVolume) => post( updateLockSettingUrl.toUrl, jsonEncode({ @@ -575,18 +574,16 @@ class ApiProvider extends BaseProvider { })); // 防撬报警 - Future setBurglarAlarmData( - int lockId, int antiPrySwitch) => - post( - updateLockSettingUrl.toUrl, - jsonEncode({ - 'lockId': lockId, - 'antiPrySwitch': antiPrySwitch, - })); + Future setBurglarAlarmData(int lockId, int antiPrySwitch) => post( + updateLockSettingUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + 'antiPrySwitch': antiPrySwitch, + })); // 开门方向 Future setOpenDoorDirectionData( - int lockId, int openDirectionValue) => + int lockId, int openDirectionValue) => post( updateLockSettingUrl.toUrl, jsonEncode({ @@ -595,7 +592,8 @@ class ApiProvider extends BaseProvider { })); // 远程开锁 - Future remoteUnlockingOpenOrCloseLoadData(int lockId, int remoteUnlock) => + Future remoteUnlockingOpenOrCloseLoadData( + int lockId, int remoteUnlock) => post( updateLockSettingUrl.toUrl, jsonEncode({ @@ -604,22 +602,20 @@ class ApiProvider extends BaseProvider { })); // 重置键 - Future setResetButtonData(int lockId, int resetSwitch) => - post( - updateLockSettingUrl.toUrl, - jsonEncode({ - 'lockId': lockId, - 'resetSwitch': resetSwitch, - })); + Future setResetButtonData(int lockId, int resetSwitch) => post( + updateLockSettingUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + 'resetSwitch': resetSwitch, + })); // 设置考勤 - Future setCheckInData(int lockId, int resetSwitch) => - post( - updateLockSettingUrl.toUrl, - jsonEncode({ - 'lockId': lockId, - 'attendance': resetSwitch, - })); + Future setCheckInData(int lockId, int resetSwitch) => post( + updateLockSettingUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + 'attendance': resetSwitch, + })); // 设置开锁时是否需联网 Future setOpenLockNeedOnlineData(int lockId, int appUnlockOnline) => @@ -631,16 +627,16 @@ class ApiProvider extends BaseProvider { })); // 设置标记房态 - Future setRoomStatusData(int lockId, int roomStatus) => - post( - setRoomStatusURL.toUrl, - jsonEncode({ - 'lockId': lockId, - 'roomStatus': roomStatus, - })); + Future setRoomStatusData(int lockId, int roomStatus) => post( + setRoomStatusURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'roomStatus': roomStatus, + })); // 设置常开模式 - Future setNormallyModeData(int lockId, int passageMode, List passageModeConfig) => + Future setNormallyModeData( + int lockId, int passageMode, List passageModeConfig) => post( updateLockSettingUrl.toUrl, jsonEncode({ @@ -657,13 +653,12 @@ class ApiProvider extends BaseProvider { })); // 设置管理员开锁密码 - Future setAdminPasswordData(int lockId, String adminPwd) => - post( - updateLockSettingUrl.toUrl, - jsonEncode({ - 'lockId': lockId, - 'adminPwd': adminPwd, - })); + Future setAdminPasswordData(int lockId, String adminPwd) => post( + updateLockSettingUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + 'adminPwd': adminPwd, + })); // 获取服务器当前时间 Future getServerDatetimeLoadData(String lockId) => post( @@ -703,9 +698,9 @@ class ApiProvider extends BaseProvider { })); Future updateLockName( - String lockId, - String lockName, - ) => + String lockId, + String lockName, + ) => post( updateLockNameURL.toUrl, jsonEncode({ @@ -741,8 +736,10 @@ class ApiProvider extends BaseProvider { })); // 获取开锁提醒 - Future setLockPickingReminderData(int lockId, int unlockReminderPush) => - post(updateLockSettingUrl.toUrl, + Future setLockPickingReminderData( + int lockId, int unlockReminderPush) => + post( + updateLockSettingUrl.toUrl, jsonEncode({ 'lockId': lockId, 'unlockReminderPush': unlockReminderPush, @@ -1015,15 +1012,62 @@ class ApiProvider extends BaseProvider { // 校验指纹名字是否重复 Future checkFingerprintNameDuplicatedData( - String lockId, - String fingerprintName) => + String lockId, String fingerprintName) => + post(checkFingerprintNameURL.toUrl, + jsonEncode({'lockId': lockId, 'fingerprintName': fingerprintName})); + + // 获取人脸列表 + Future getFaceListData( + String lockId, String pageNo, String pageSize, String searchStr) => post( - checkFingerprintNameURL.toUrl, + getFaceListURL.toUrl, jsonEncode({ 'lockId': lockId, - 'fingerprintName': fingerprintName + 'pageNo': pageNo, + 'pageSize': pageSize, + 'searchStr': searchStr, })); + // 添加人脸 + Future addFaceData( + int lockId, + String faceName, + String faceNumber, + int faceType, + int startDate, + int endDate, + String featureData, + String addType, + List cyclicConfig, + ) => + post( + addFaceURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'faceName': faceName, + 'faceNumber': faceNumber, + 'faceType': faceType, + 'startDate': startDate, + 'endDate': endDate, + 'featureData': featureData, + 'addType': addType, + 'cyclicConfig': cyclicConfig, + })); + + // 校验人脸名字是否重复 + Future checkFaceNameDuplicatedData( + String lockId, String faceName) => + post(checkFaceNameURL.toUrl, + jsonEncode({'lockId': lockId, 'faceName': faceName})); + + // 更新人脸用户序号 + Future updateFaceUserNoLoadData( + String faceId, String lockId, String faceUserNo) => + post( + updateFaceUserNoURL.toUrl, + jsonEncode( + {'faceId': faceId, 'lockId': lockId, 'faceUserNo': faceUserNo})); + // 获取IC卡列表 Future getICCardListData( String lockId, String pageNo, String pageSize, String searchStr) => @@ -1063,8 +1107,15 @@ class ApiProvider extends BaseProvider { })); // 编辑ICCard - Future editICCardData(String lockId, String cardId, String cardName, - String startDate, String endDate, String isCoerced, List weekDay, String changeType) => + Future editICCardData( + String lockId, + String cardId, + String cardName, + String startDate, + String endDate, + String isCoerced, + List weekDay, + String changeType) => post( editICCardURL.toUrl, jsonEncode({ @@ -1100,14 +1151,9 @@ class ApiProvider extends BaseProvider { // 校验卡名字是否重复 Future checkCardNameDuplicatedData( - String lockId, - String cardName) => - post( - checkCardNameURL.toUrl, - jsonEncode({ - 'lockId': lockId, - 'cardName': cardName - })); + String lockId, String cardName) => + post(checkCardNameURL.toUrl, + jsonEncode({'lockId': lockId, 'cardName': cardName})); // 获取转移锁锁列表 Future getTransferLockListData() => @@ -1179,12 +1225,11 @@ class ApiProvider extends BaseProvider { 'searchStr': searchStr })); - Future deletLockUser(int uid) => - post( - deletLockUserURL.toUrl, - jsonEncode({ - 'uid': uid, - })); + Future deletLockUser(int uid) => post( + deletLockUserURL.toUrl, + jsonEncode({ + 'uid': uid, + })); Future keyListByUser(String pageNo, String pageSize, String uid) => post(keyListByUserURL.toUrl, @@ -1227,14 +1272,9 @@ class ApiProvider extends BaseProvider { Future userSettingsInfo() => post(userSettingsInfoURL.toUrl, jsonEncode({})); - Future canSendKey( - String endDate, List lockIdList) => - post( - canSendKeyURL.toUrl, - jsonEncode({ - 'endDate': endDate, - 'lockIdList': lockIdList - })); + Future canSendKey(String endDate, List lockIdList) => post( + canSendKeyURL.toUrl, + jsonEncode({'endDate': endDate, 'lockIdList': lockIdList})); Future batchSendKey( String endDate, @@ -1381,7 +1421,8 @@ class ApiProvider extends BaseProvider { jsonEncode({"questionAndAnswerList": questionAndAnswerList})); // 获取上传文件的upToken 再调用updateUserInfo - Future getUpToken(String module, String typeKey, String type, String filename, int size) => + Future getUpToken(String module, String typeKey, String type, + String filename, int size) => post( getUpTokenURL.toUrl, jsonEncode({ @@ -1392,7 +1433,8 @@ class ApiProvider extends BaseProvider { })); // 文件上传 - Future uploadFile(String url, dynamic boay) => post(url, boay, isUnUploadFile: false, contentType:'multipart/form-data'); + Future uploadFile(String url, dynamic boay) => post(url, boay, + isUnUploadFile: false, contentType: 'multipart/form-data'); //获取解绑手机号Token Future unbindPhoneToken(String verificationCode) => post( diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index c5c3a563..bc9eba53 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -4,6 +4,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyO import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; +import 'package:star_lock/main/lockDetail/face/faceList/faceListData_entity.dart'; import 'package:star_lock/main/lockDetail/lcokSet/basicInformation/basicInformation/KeyDetailEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; @@ -217,7 +218,8 @@ class ApiRepository { } //操作记录上传 - Future lockRecordUploadData({required String lockId, required List records}) async { + Future lockRecordUploadData( + {required String lockId, required List records}) async { final res = await apiProvider.lockRecordUploadData(lockId, records); return KeyOperationRecordEntity.fromJson(res.body); } @@ -236,22 +238,23 @@ class ApiRepository { } // 更新锁用户NO - Future updateLockUserNo({required String keyId, required String lockUserNo}) async { + Future updateLockUserNo( + {required String keyId, required String lockUserNo}) async { final res = await apiProvider.updateLockUserNo(keyId, lockUserNo); return LockNetTokenEntity.fromJson(res.body); } // 绑定蓝牙管理员 Future bindingBlueAdmin( - { required String lockAlias, - required Map position, - required Map bluetooth, - required Map lockInfo, - required String lockUserNo, - required String pwdTimestamp, - required String featureValue, - required String featureSettingValue, - required List featureSettingParams}) async { + {required String lockAlias, + required Map position, + required Map bluetooth, + required Map lockInfo, + required String lockUserNo, + required String pwdTimestamp, + required String featureValue, + required String featureSettingValue, + required List featureSettingParams}) async { final res = await apiProvider.bindingBlueAdmin( lockAlias, position, @@ -275,24 +278,17 @@ class ApiRepository { //锁名称修改 Future modifyKeyName( - { - required String keyId, - required String lockId, - required String keyName - }) async { - final res = - await apiProvider.modifyKeyName(keyId, lockId, keyName); + {required String keyId, + required String lockId, + required String keyName}) async { + final res = await apiProvider.modifyKeyName(keyId, lockId, keyName); return KeyOperationRecordEntity.fromJson(res.body); } //修改锁名(新) Future updateLockName( - { - required String lockId, - required String lockName - }) async { - final res = - await apiProvider.updateLockName(lockId, lockName); + {required String lockId, required String lockName}) async { + final res = await apiProvider.updateLockName(lockId, lockName); return KeyOperationRecordEntity.fromJson(res.body); } @@ -373,7 +369,8 @@ class ApiRepository { } // 检查账户密码 - Future checkLoginPassword({required String password}) async { + Future checkLoginPassword( + {required String password}) async { final res = await apiProvider.checkLoginPassword(password); return LockListInfoEntity.fromJson(res.body); } @@ -463,10 +460,8 @@ class ApiRepository { } // 编辑锁名字 - Future editLockGroupRequest({ - required int groupId, - required String groupName - }) async { + Future editLockGroupRequest( + {required int groupId, required String groupName}) async { final res = await apiProvider.editLockGroupRequest(groupId, groupName); return MassSendLockGroupListEntity.fromJson(res.body); } @@ -486,29 +481,21 @@ class ApiRepository { //删除锁分组 Future deleteGroup(int groupId) async { - final res = - await apiProvider.deleteGroup(groupId); + final res = await apiProvider.deleteGroup(groupId); return MassSendLockGroupListEntity.fromJson(res.body); } //锁分组里面添加锁 Future lockGroupAddLock( - { - required List lockIds, - required int groupId - }) async { - final res = - await apiProvider.lockGroupAddLock(lockIds, groupId); + {required List lockIds, required int groupId}) async { + final res = await apiProvider.lockGroupAddLock(lockIds, groupId); return MassSendLockGroupListEntity.fromJson(res.body); } //锁分组里面删除锁 Future lockGroupDeletLock( - { - required List lockIds - }) async { - final res = - await apiProvider.lockGroupDeletLock(lockIds); + {required List lockIds}) async { + final res = await apiProvider.lockGroupDeletLock(lockIds); return MassSendLockGroupListEntity.fromJson(res.body); } @@ -590,8 +577,8 @@ class ApiRepository { required int autoLock, required int autoLockSecond, }) async { - final res = - await apiProvider.setAutoUnlockLoadData(lockId, autoLock, autoLockSecond); + final res = await apiProvider.setAutoUnlockLoadData( + lockId, autoLock, autoLockSecond); return LoginEntity.fromJson(res.body); } @@ -602,7 +589,7 @@ class ApiRepository { required int lockSoundVolume, }) async { final res = - await apiProvider.setLockSoundData(lockId, lockSound, lockSoundVolume); + await apiProvider.setLockSoundData(lockId, lockSound, lockSoundVolume); return LoginEntity.fromJson(res.body); } @@ -611,8 +598,7 @@ class ApiRepository { required int lockId, required int antiPrySwitch, }) async { - final res = - await apiProvider.setBurglarAlarmData(lockId, antiPrySwitch); + final res = await apiProvider.setBurglarAlarmData(lockId, antiPrySwitch); return LoginEntity.fromJson(res.body); } @@ -649,7 +635,8 @@ class ApiRepository { required int lockId, required int appUnlockOnline, }) async { - final res = await apiProvider.setOpenLockNeedOnlineData(lockId, appUnlockOnline); + final res = + await apiProvider.setOpenLockNeedOnlineData(lockId, appUnlockOnline); return LoginEntity.fromJson(res.body); } @@ -659,7 +646,7 @@ class ApiRepository { required int openDirectionValue, }) async { final res = - await apiProvider.setOpenDoorDirectionData(lockId, openDirectionValue); + await apiProvider.setOpenDoorDirectionData(lockId, openDirectionValue); return LoginEntity.fromJson(res.body); } @@ -678,8 +665,8 @@ class ApiRepository { required int passageMode, required List passageModeConfig, }) async { - final res = - await apiProvider.setNormallyModeData(lockId, passageMode, passageModeConfig); + final res = await apiProvider.setNormallyModeData( + lockId, passageMode, passageModeConfig); return LoginEntity.fromJson(res.body); } @@ -785,10 +772,8 @@ class ApiRepository { } //群发电子钥匙检查 - Future canSendKey( - String endDate, List lockIdList) async { - final res = - await apiProvider.canSendKey(endDate, lockIdList); + Future canSendKey(String endDate, List lockIdList) async { + final res = await apiProvider.canSendKey(endDate, lockIdList); return KeyDetailEntity.fromJson(res.body); } @@ -928,7 +913,8 @@ class ApiRepository { required int lockId, required int unlockReminderPush, }) async { - final res = await apiProvider.setLockPickingReminderData(lockId, unlockReminderPush); + final res = await apiProvider.setLockPickingReminderData( + lockId, unlockReminderPush); return LoginEntity.fromJson(res.body); } @@ -1168,13 +1154,58 @@ class ApiRepository { // 校验指纹名字是否重复 Future checkFingerprintNameDuplicatedData( - {required String lockId, - required String fingerprintName}) async { + {required String lockId, required String fingerprintName}) async { final res = await apiProvider.checkFingerprintNameDuplicatedData( lockId, fingerprintName); return LoginEntity.fromJson(res.body); } + // 获取人脸列表 + Future getFaceListData({ + required String lockId, + required String pageNo, + required String pageSize, + required String searchStr, + }) async { + final res = + await apiProvider.getFaceListData(lockId, pageNo, pageSize, searchStr); + return FaceListDataEntity.fromJson(res.body); + } + + // 添加人脸 + Future addFaceData({ + required int lockId, + required String faceName, + required String faceNumber, + required int faceType, + required int startDate, + required int endDate, + required String featureData, + required String addType, + required List cyclicConfig, + }) async { + final res = await apiProvider.addFaceData(lockId, faceName, faceNumber, + faceType, startDate, endDate, featureData, addType, cyclicConfig); + return AddFingerprintEntity.fromJson(res.body); + } + + // 校验人脸名字是否重复 + Future checkFaceNameDuplicatedData( + {required String lockId, required String faceName}) async { + final res = await apiProvider.checkFaceNameDuplicatedData(lockId, faceName); + return LoginEntity.fromJson(res.body); + } + + // 更新人脸用户序号 + Future updateFaceUserNoLoadData( + {required String faceId, + required String lockId, + required String faceUserNo}) async { + final res = + await apiProvider.updateFaceUserNoLoadData(faceId, lockId, faceUserNo); + return LoginEntity.fromJson(res.body); + } + // 获取Ic卡列表 Future getICCardListData({ required String lockId, @@ -1214,8 +1245,8 @@ class ApiRepository { required String isCoerced, required List weekDay, required String changeType}) async { - final res = await apiProvider.editICCardData( - lockId, cardId, cardName, startDate, endDate, isCoerced, weekDay, changeType); + final res = await apiProvider.editICCardData(lockId, cardId, cardName, + startDate, endDate, isCoerced, weekDay, changeType); return LoginEntity.fromJson(res.body); } @@ -1242,10 +1273,8 @@ class ApiRepository { // 校验卡名字是否重复 Future checkCardNameDuplicatedData( - {required String lockId, - required String cardName}) async { - final res = await apiProvider.checkCardNameDuplicatedData( - lockId, cardName); + {required String lockId, required String cardName}) async { + final res = await apiProvider.checkCardNameDuplicatedData(lockId, cardName); return LoginEntity.fromJson(res.body); } @@ -1391,24 +1420,21 @@ class ApiRepository { //上传头像 先获取upToken 再调用updateUserInfo Future getUpToken( - { - required String module, - required String typeKey, - required String type, - required String filename, - required int size - } - ) async { - final res = await apiProvider.getUpToken(module, typeKey, type, filename, size); + {required String module, + required String typeKey, + required String type, + required String filename, + required int size}) async { + final res = + await apiProvider.getUpToken(module, typeKey, type, filename, size); return MinePersonGetUploadFileInfoEntity.fromJson(res.body); } // 文件上传 - Future uploadFile( - { - required String url, - required dynamic body, - }) async { + Future uploadFile({ + required String url, + required dynamic body, + }) async { final res = await apiProvider.uploadFile(url, body); return LoginEntity.fromJson(res.body); } diff --git a/star_lock/lib/network/response_interceptor_log.dart b/star_lock/lib/network/response_interceptor_log.dart index 6b7a5e43..58552bea 100644 --- a/star_lock/lib/network/response_interceptor_log.dart +++ b/star_lock/lib/network/response_interceptor_log.dart @@ -4,7 +4,8 @@ import 'package:get/get.dart'; import 'package:get/get_connect/http/src/request/request.dart'; FutureOr responseLogInterceptor(Request request, Response response) { - Get.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.body} ${response.headers}'); + Get.log( + 'HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString} ${response.headers}'); EasyLoading.dismiss(animation: true); return response; } diff --git a/star_lock/lib/tools/xs_aliyunPush.dart b/star_lock/lib/tools/xs_aliyunPush.dart index 4114ab5c..c2675a61 100644 --- a/star_lock/lib/tools/xs_aliyunPush.dart +++ b/star_lock/lib/tools/xs_aliyunPush.dart @@ -16,29 +16,29 @@ class XSAliyunPushProvider { } Future _onNotification(Map message) async { - print('onNotification: $message'); + // print('onNotification: $message'); } Future _onAndroidNotificationReceivedInApp( Map message) async { - print('onAndroidNotificationReceivedInApp: $message'); + // print('onAndroidNotificationReceivedInApp: $message'); } Future _onMessage(Map message) async { - print('onMessage: $message'); + // print('onMessage: $message'); } Future _onNotificationOpened(Map message) async { - print('onNotificationOpened: $message'); + // print('onNotificationOpened: $message'); } Future _onNotificationRemoved(Map message) async { - print('onNotificationRemoved: $message'); + // print('onNotificationRemoved: $message'); } Future _onAndroidNotificationClickedWithNoAction( Map message) async { - print('onAndroidNotificationClickedWithNoAction: $message'); + // print('onAndroidNotificationClickedWithNoAction: $message'); } Future _onIOSChannelOpened(Map message) async {} @@ -86,7 +86,7 @@ class XSAliyunPushProvider { // Toast.show(msg: "初始化推送成功"); } else { String errorMsg = initResult['errorMsg']; - print('初始化推送失败,原因为:$errorMsg'); + // print('初始化推送失败,原因为:$errorMsg'); // Toast.show(msg: '初始化推送失败, errorMsg: $errorMsg.}'); } }); @@ -106,7 +106,7 @@ class XSAliyunPushProvider { } else { String errorMsg = initResult['errorMsg']; // Toast.show(msg: '初始化辅助通道成功, errorMsg: $errorMsg'); - print("初始化辅助通道失败,原因为:$errorMsg"); + // print("初始化辅助通道失败,原因为:$errorMsg"); } });