From 1258ce63240506f06ca7f550e1a703e7f0116753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Sat, 20 Apr 2024 17:50:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=BA=E8=84=B8=E3=80=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BA=BA=E8=84=B8=E6=96=B0=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/blue/blue_manage.dart | 7 +- .../lib/blue/io_protocol/io_addFace.dart | 74 +++++-- .../io_addFaceWithTimeCycleCoercion.dart | 188 ++++++++++++++++++ star_lock/lib/blue/sender_manage.dart | 30 ++- .../authorizedAdmin_logic.dart | 32 +-- .../card/addICCard/addICCard_state.dart | 1 - .../card/cardDetail/cardDetail_logic.dart | 7 +- .../electronicKeyDetail_logic.dart | 4 +- .../electronicKeyDetail_state.dart | 2 +- .../face/addFace/addFace_logic.dart | 99 +++++---- .../face/addFace/addFace_state.dart | 25 ++- .../face/addFaceType/addFaceType_logic.dart | 19 +- .../face/addFaceType/addFaceType_page.dart | 5 +- .../face/faceDetail/faceDetail_logic.dart | 68 ++++--- .../face/faceList/faceList_logic.dart | 117 ++++++++--- .../face/faceList/faceList_page.dart | 173 +++++++++------- .../fingerprintDetail_logic.dart | 9 +- .../iris/irisList/irisList_logic.dart | 108 +++++----- .../palm/palmList/palmList_logic.dart | 108 +++++----- star_lock/lib/network/api_provider.dart | 4 +- star_lock/lib/network/api_repository.dart | 4 +- 21 files changed, 730 insertions(+), 354 deletions(-) create mode 100644 star_lock/lib/blue/io_protocol/io_addFaceWithTimeCycleCoercion.dart diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index a8fa4c12..996ebb9f 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -245,9 +245,9 @@ class BlueManage { // if (scanResult.device.advName.isEmpty) { // return; // } - // Get.log("scanResult.device.advName:${scanResult.device.advName}" - // " scanResult.advertisementData.serviceUuids:${scanResult.advertisementData.serviceUuids}" - // " rssi:${scanResult.rssi}"); + Get.log("scanResult.device.advName:${scanResult.device.advName}" + " scanResult.advertisementData.serviceUuids:${scanResult.advertisementData.serviceUuids}" + " rssi:${scanResult.rssi}"); if (((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "") @@ -328,6 +328,7 @@ class BlueManage { //判断列表里面有设备则不开启扫描 bool isExistDevice = scanDevices.any((element) => element.device.platformName == connectDeviceName || element.advertisementData.advName == connectDeviceName); if (isAddEquipment == false && isExistDevice == false) { + // startScan(10, (scanDevices){ startScanSingle(deviceName, 10, (List scanDevices) { print("扫描到的设备:$scanDevices"); devicesList = scanDevices; diff --git a/star_lock/lib/blue/io_protocol/io_addFace.dart b/star_lock/lib/blue/io_protocol/io_addFace.dart index dfdc821b..0545d938 100644 --- a/star_lock/lib/blue/io_protocol/io_addFace.dart +++ b/star_lock/lib/blue/io_protocol/io_addFace.dart @@ -19,11 +19,16 @@ class SenderAddFaceCommand extends SenderProtocol { String? userID; int? faceNo; int? useCountLimit; + int? isForce; List? token; - int? startTime; - int? endTime; + int? isRound; + int? weekRound; + int? startDate; + int? endDate; + String? startTime; + String? endTime; int? needAuthor; - List? publicKey; + List? signKey; List? privateKey; SenderAddFaceCommand({ @@ -31,11 +36,16 @@ class SenderAddFaceCommand extends SenderProtocol { this.userID, this.faceNo, this.useCountLimit, + this.isForce, this.token, + this.isRound, + this.weekRound, + this.startDate, + this.endDate, this.startTime, this.endTime, this.needAuthor, - this.publicKey, + this.signKey, this.privateKey, }) : super(CommandType.generalExtendedCommond); @@ -53,7 +63,7 @@ class SenderAddFaceCommand extends SenderProtocol { data.add(type1); data.add(type2); - // 子命令类型--注册人脸开始 + // 子命令类型 data.add(81); // keyID 40 @@ -68,43 +78,69 @@ class SenderAddFaceCommand extends SenderProtocol { subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); - // PwdNo + // fingerNo subData.add(faceNo!); // UseCountLimit subData.add(useCountLimit!); + // isForce + subData.add(isForce!); + // token subData.addAll(token!); + // isRound + subData.add(isRound!); + + // weekRound + subData.add(weekRound!); + + // startDate 4 + subData.add((startDate! & 0xff000000) >> 24); + subData.add((startDate! & 0xff0000) >> 16); + subData.add((startDate! & 0xff00) >> 8); + subData.add((startDate! & 0xff)); + + // endDate 4 + subData.add((endDate! & 0xff000000) >> 24); + subData.add((endDate! & 0xff0000) >> 16); + subData.add((endDate! & 0xff00) >> 8); + subData.add((endDate! & 0xff)); + // startTime 4 - subData.add((startTime! & 0xff000000) >> 24); - subData.add((startTime! & 0xff0000) >> 16); - subData.add((startTime! & 0xff00) >> 8); - subData.add((startTime! & 0xff)); + List startTimeList = [0,0,0,0]; + if(startTime!.contains(":")){ + List getStartTimeList = startTime!.split(":"); + startTimeList[2] = int.parse(getStartTimeList[0]); + startTimeList[3] = int.parse(getStartTimeList[1]); + } + subData.addAll(startTimeList); // endTime 4 - subData.add((endTime! & 0xff000000) >> 24); - subData.add((endTime! & 0xff0000) >> 16); - subData.add((endTime! & 0xff00) >> 8); - subData.add((endTime! & 0xff)); + List endTimeList = [0,0,0,0]; + if(endTime!.contains(":")){ + List getendTimeList = endTime!.split(":"); + endTimeList[2] = int.parse(getendTimeList[0]); + endTimeList[3] = int.parse(getendTimeList[1]); + } + subData.addAll(endTimeList); - if (needAuthor == 0) { + if(needAuthor == 0){ //AuthCodeLen 1 subData.add(0); } else { List authCodeData = []; + //KeyID + authCodeData.addAll(utf8.encode(keyID!)); //authUserID authCodeData.addAll(utf8.encode(userID!)); - //KeyID - authCodeData.addAll(utf8.encode(keyID!)); - //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 authCodeData.addAll(token!); - authCodeData.addAll(publicKey!); + authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); diff --git a/star_lock/lib/blue/io_protocol/io_addFaceWithTimeCycleCoercion.dart b/star_lock/lib/blue/io_protocol/io_addFaceWithTimeCycleCoercion.dart new file mode 100644 index 00000000..47a3d867 --- /dev/null +++ b/star_lock/lib/blue/io_protocol/io_addFaceWithTimeCycleCoercion.dart @@ -0,0 +1,188 @@ + +import '../io_sender.dart'; +import '../io_type.dart'; + +///TODO:添加人脸 +/* +备注: +删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 +**/ +// class SenderAddFaceWithTimeCycleCoercionCommand extends SenderProtocol { +// +// String? keyID; +// String? userID; +// int? fingerNo; +// int? useCountLimit; +// int? isForce; +// List? token; +// int? isRound; +// int? weekRound; +// int? startDate; +// int? endDate; +// String? startTime; +// String? endTime; +// int? needAuthor; +// List? signKey; +// List? privateKey; +// +// SenderAddFaceWithTimeCycleCoercionCommand({ +// this.keyID, +// this.userID, +// this.fingerNo, +// this.useCountLimit, +// this.isForce, +// this.token, +// this.isRound, +// this.weekRound, +// this.startDate, +// this.endDate, +// this.startTime, +// this.endTime, +// this.needAuthor, +// this.signKey, +// 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(36); +// +// // 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); +// +// // fingerNo +// subData.add(fingerNo!); +// +// // UseCountLimit +// subData.add(useCountLimit!); +// +// // isForce +// subData.add(isForce!); +// +// // token +// subData.addAll(token!); +// +// // isRound +// subData.add(isRound!); +// +// // weekRound +// subData.add(weekRound!); +// +// // startDate 4 +// subData.add((startDate! & 0xff000000) >> 24); +// subData.add((startDate! & 0xff0000) >> 16); +// subData.add((startDate! & 0xff00) >> 8); +// subData.add((startDate! & 0xff)); +// +// // endDate 4 +// subData.add((endDate! & 0xff000000) >> 24); +// subData.add((endDate! & 0xff0000) >> 16); +// subData.add((endDate! & 0xff00) >> 8); +// subData.add((endDate! & 0xff)); +// +// // startTime 4 +// List startTimeList = [0,0,0,0]; +// if(startTime!.contains(":")){ +// List getStartTimeList = startTime!.split(":"); +// startTimeList[2] = int.parse(getStartTimeList[0]); +// startTimeList[3] = int.parse(getStartTimeList[1]); +// } +// subData.addAll(startTimeList); +// +// // endTime 4 +// List endTimeList = [0,0,0,0]; +// if(endTime!.contains(":")){ +// List getendTimeList = endTime!.split(":"); +// endTimeList[2] = int.parse(getendTimeList[0]); +// endTimeList[3] = int.parse(getendTimeList[1]); +// } +// subData.addAll(endTimeList); +// +// if(needAuthor == 0){ +// //AuthCodeLen 1 +// subData.add(0); +// } else { +// List authCodeData = []; +// //KeyID +// authCodeData.addAll(utf8.encode(keyID!)); +// +// //authUserID +// authCodeData.addAll(utf8.encode(userID!)); +// +// //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 +// authCodeData.addAll(token!); +// +// authCodeData.addAll(signKey!); +// +// // 把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); +// } +// } +// +// Get.log("${commandType!.typeName} SM4Data:$data"); +// // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 +// ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); +// return ebcData; +// } +// } +// +// class SenderAddFingerprintWithTimeCycleCoercionReply extends Reply { +// SenderAddFingerprintWithTimeCycleCoercionReply.parseData(CommandType commandType, List dataDetail) +// : super.parseData(commandType, dataDetail) { +// data = dataDetail; +// int status = data[2]; +// errorWithStstus(status); +// } +// } +// +// class SenderAddFingerprintProcessReply extends Reply { +// SenderAddFingerprintProcessReply.parseData(CommandType commandType, List dataDetail) +// : super.parseData(commandType, dataDetail) { +// data = dataDetail; +// int status = data[2]; +// errorWithStstus(status); +// } +// } +// +// class SenderAddFingerprintConfirmationReply extends Reply { +// SenderAddFingerprintConfirmationReply.parseData(CommandType commandType, List dataDetail) +// : super.parseData(commandType, dataDetail) { +// data = dataDetail; +// int status = data[2]; +// errorWithStstus(status); +// } +// } \ 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 4cb3214a..95292dba 100644 --- a/star_lock/lib/blue/sender_manage.dart +++ b/star_lock/lib/blue/sender_manage.dart @@ -469,15 +469,20 @@ class IoSenderManage { //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, + required String? userID, + required int? faceNo, + required int? useCountLimit, + required int? isForce, + required List? token, + required int? isRound, + required int? weekRound, + required int? startDate, + required int? endDate, + required String? startTime, + required String? endTime, + required int? needAuthor, + required List? signKey, + required List? privateKey, CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderAddFaceCommand( @@ -485,11 +490,16 @@ class IoSenderManage { userID: userID, faceNo: faceNo, useCountLimit: useCountLimit, + isForce: isForce, token: token, + isRound: isRound, + weekRound: weekRound, + startDate: startDate, + endDate: endDate, startTime: startTime, endTime: endTime, needAuthor: needAuthor, - publicKey: publicKey, + signKey: signKey, privateKey: privateKey, ), callBack: callBack); diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart index 04152599..3747472d 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart @@ -1,12 +1,9 @@ import 'dart:async'; -import 'package:flutter/cupertino.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; -import 'package:star_lock/appRouters.dart'; import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/tools/dateTool.dart'; -import 'package:star_lock/translations/trans_lib.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_reply.dart'; @@ -33,21 +30,20 @@ class AuthorizedAdminLogic extends BaseGetXController { if (reply is TransferPermissionsReply) { var token = reply.data.sublist(2, 6); var saveStrList = changeIntListToStringList(token); - print("_replyFactoryDataResetKeyToken:$token"); + Get.log("_replyFactoryDataResetKeyToken:$token"); Storage.setStringList(saveBlueToken, saveStrList); int status = reply.data[6]; - print("status:$status"); + Get.log("status:$status"); switch (status) { case 0x00: //成功 - print("${reply.commandType!.typeValue} 数据解析成功"); - + Get.log("${reply.commandType!.typeValue} 数据解析成功"); break; case 0x06: //无权限 - print("${reply.commandType!.typeValue} 需要鉴权"); + Get.log("${reply.commandType!.typeValue} 需要鉴权"); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -67,25 +63,7 @@ class AuthorizedAdminLogic extends BaseGetXController { privateKey: getPrivateKeyList, token: getTokenList); break; - case 0x07: - //无权限 - print("${reply.commandType!.typeValue} 用户无权限"); - - break; - case 0x09: - // 权限校验错误 - print("${reply.commandType!.typeValue} 权限校验错误"); - - break; - case 0x14: - // 权限校验错误 - print("${reply.commandType!.typeValue} 用户已存在"); - - break; default: - //失败 - print("${reply.commandType!.typeValue} 失败"); - break; } } @@ -289,7 +267,7 @@ class AuthorizedAdminLogic extends BaseGetXController { endTime: int.parse(endTime), isOnlyManageSelf: state.onlyManageYouCreatesUser.value ? 1 : 0); if (entity.errorCode!.codeIsSuccessful) { - print('发送电子钥匙成功'); + Get.log('发送电子钥匙成功'); state.isCreateUser.value = false; state.isSendSuccess.value = true; // Toast.show(msg: "添加成功"); diff --git a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_state.dart b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_state.dart index 674352bd..8a116132 100644 --- a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_state.dart +++ b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_state.dart @@ -33,7 +33,6 @@ class AddICCardState{ isAdministrator.value = map["isAdministrator"]; print("isAdministrator.value isAdministrator.value:${isAdministrator.value}"); startDate.value = map["startDate"]; - lockId.value = map["lockId"]; weekDay.value = map["weekDay"]; fromType.value = map["fromType"]; effectiveDateTime.value = map["effectiveTime"]; diff --git a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart index 7c88484f..5dc23a22 100644 --- a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart @@ -56,8 +56,9 @@ class CardDetailLogic extends BaseGetXController{ // var publicKey = await Storage.getStringList(saveBluePublicKey); // List publicKeyDataList = changeStringListToIntList(publicKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + var token = reply.data.sublist(5, 9); + var saveStrList = changeIntListToStringList(token); + Storage.setStringList(saveBlueToken, saveStrList); IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( keyID:state.keyId.value.toString(), @@ -74,7 +75,7 @@ class CardDetailLogic extends BaseGetXController{ needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, - token: getTokenList, + token: token, ); break; default: diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart index 5dbf04c9..032c9ede 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart @@ -48,8 +48,8 @@ class ElectronicKeyDetailLogic extends BaseGetXController { keyType:state.itemData.value.keyType!, startTime:int.parse(state.starTime.value), endTime:int.parse(state.endTime.value), - isOnlyManageSelf: state.onlyManageYouCreatesUser.value ? 1 : 0, - remoteEnable: state.isRemoteUnlock.value ? 1 : 2); + isOnlyManageSelf: state.onlyManageYouCreatesUser.value == true ? 1 : 0, + remoteEnable: state.isRemoteUnlock.value == true ? 1 : 2); if (entity.errorCode!.codeIsSuccessful) { showToast("修改成功".tr, something: () { eventBus.fire(ElectronicKeyListRefreshUI()); diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart index 2691572d..3bc57ed2 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart @@ -30,7 +30,7 @@ class ElectronicKeyDetailState { changeNameController.text = itemData.value.keyName!; keyName.value = itemData.value.keyName!; - isRemoteUnlock.value = itemData.value.remoteEnable! == 2 ? false : true; + isRemoteUnlock.value = itemData.value.remoteEnable! == 1 ? true : false; onlyManageYouCreatesUser.value = itemData.value.isOnlyManageSelf! == 0 ? false : true; starDate.value = itemData.value.startDate!.toString(); diff --git a/star_lock/lib/main/lockDetail/face/addFace/addFace_logic.dart b/star_lock/lib/main/lockDetail/face/addFace/addFace_logic.dart index 325bad91..b5ed0a44 100644 --- a/star_lock/lib/main/lockDetail/face/addFace/addFace_logic.dart +++ b/star_lock/lib/main/lockDetail/face/addFace/addFace_logic.dart @@ -1,6 +1,5 @@ import 'dart:async'; -// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; import 'package:star_lock/blue/io_protocol/io_addFace.dart'; @@ -16,6 +15,7 @@ import '../../../../../blue/sender_manage.dart'; import '../../../../../network/api_repository.dart'; import '../../../../../tools/baseGetXController.dart'; import '../../../../../tools/storage.dart'; +import '../../../../tools/dateTool.dart'; class AddFaceLogic extends BaseGetXController { final AddFaceState state = AddFaceState(); @@ -44,7 +44,7 @@ class AddFaceLogic extends BaseGetXController { Future _replyAddFaceBegin(Reply reply) async { int status = reply.data[2]; - print("status:$status"); + print("_replyAddFaceBegin status:$status"); switch (status) { case 0x00: @@ -59,30 +59,42 @@ class AddFaceLogic extends BaseGetXController { break; case 0x06: //无权限 - print("${reply.commandType!.typeValue} 需要鉴权"); + var weekStr = "00000000"; + print("state.weekDay.value:${state.weekDay.value}"); + for (var day in state.weekDay.value) { + int index = day % 7; // 将周日的索引转换为 0 + weekStr = '${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}'; + } + // 倒序 weekStr + weekStr = weekStr.split('').reversed.join(''); + int weekRound = int.parse(weekStr, radix: 2); + // print("weekStrweekStrweekStr:$weekStr weekRound:$weekRound"); + + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); + 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, + keyID:"1", + userID:await Storage.getUid(), + faceNo:state.isAdministrator.value == "2" ? 254 : 1, + useCountLimit:0xff, + isForce:state.isCoerced.value == "2" ? 1 : 0, // 是否是胁迫 + isRound:state.selectType.value == "2" ? 1: 0, // 是否是循环 + weekRound:weekRound, // 周循环 + startDate: int.parse(state.startDate.value)~/1000, + endDate: int.parse(state.endDate.value)~/1000, + startTime:DateTool().dateToHNString(state.effectiveDateTime.value), + endTime:DateTool().dateToHNString(state.failureDateTime.value), + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, token: token, ); break; @@ -194,8 +206,19 @@ class AddFaceLogic extends BaseGetXController { (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { cancelBlueConnetctToastTimer(); - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + var weekStr = "00000000"; + print("state.weekDay.value:${state.weekDay.value}"); + for (var day in state.weekDay.value) { + int index = day % 7; // 将周日的索引转换为 0 + weekStr = '${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}'; + } + // 倒序 weekStr + weekStr = weekStr.split('').reversed.join(''); + int weekRound = int.parse(weekStr, radix: 2); + // print("weekStrweekStrweekStr:$weekStr weekRound:$weekRound"); + + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -204,21 +227,23 @@ class AddFaceLogic extends BaseGetXController { List getTokenList = changeStringListToIntList(token!); print( "openDoorTokenPubToken:$getTokenList state.startDate.value:${state.startDate.value}"); - print( - "限时人脸开始时间:${state.startDate.value ~/ 1000} 限时人脸结束时间:${state.endDate.value ~/ 1000}"); + // print("限时人脸开始时间:${state.startDate.value ~/ 1000} 限时人脸结束时间:${state.endDate.value ~/ 1000}"); IoSenderManage.senderAddFaceCommand( - keyID: "1", - userID: await Storage.getUid(), - faceNo: state.isAdministrator.value == true ? 254 : 1, - useCountLimit: 0xff, - // startTime:0x11223344, - // endTime:0x11223344, - startTime: state.startDate.value ~/ 1000, - endTime: state.endDate.value ~/ 1000, - needAuthor: 1, - publicKey: publicKeyDataList, - privateKey: getPrivateKeyList, + keyID:"1", + userID:await Storage.getUid(), + faceNo:state.isAdministrator.value == "2" ? 254 : 1, + useCountLimit:0xff, + isForce:state.isCoerced.value == "2" ? 1 : 0, // 是否是胁迫 + isRound:state.selectType.value == "2" ? 1: 0, // 是否是循环 + weekRound:weekRound, // 周循环 + startDate: int.parse(state.startDate.value)~/1000, + endDate: int.parse(state.endDate.value)~/1000, + startTime:DateTool().dateToHNString(state.effectiveDateTime.value), + endTime:DateTool().dateToHNString(state.failureDateTime.value), + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, token: getTokenList, ); } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { @@ -238,12 +263,12 @@ class AddFaceLogic extends BaseGetXController { faceName: state.faceName.value, faceNumber: state.faceNumber.value, faceType: state.faceType.value, - startDate: state.startDate.value, - endDate: state.endDate.value, + startDate: int.parse(state.startDate.value), + endDate: int.parse(state.endDate.value), featureData: state.featureData.value, addType: state.addType.value, - cyclicConfig: state.cyclicConfig.value, - faceRight: state.isAdministrator.value == true ? 1 : 0, + weekDay: state.weekDay.value, + faceRight: state.isAdministrator.value == "2" ? 1 : 0, ); if (entity.errorCode!.codeIsSuccessful) { diff --git a/star_lock/lib/main/lockDetail/face/addFace/addFace_state.dart b/star_lock/lib/main/lockDetail/face/addFace/addFace_state.dart index db600559..abea9978 100644 --- a/star_lock/lib/main/lockDetail/face/addFace/addFace_state.dart +++ b/star_lock/lib/main/lockDetail/face/addFace/addFace_state.dart @@ -10,16 +10,22 @@ class AddFaceState { var faceNumber = "".obs; final lockId = 0.obs; - final endDate = 0.obs; + final endDate = "".obs; final addType = "".obs; final faceName = "".obs; final faceType = 0.obs; - final startDate = 0.obs; - final cyclicConfig = [].obs; - final fromType = 1.obs; + // final cyclicConfig = [].obs; final featureData = ''.obs; final isClickAddFace = false.obs; - final isAdministrator = false.obs; + + final isCoerced = "".obs; + final isAdministrator = "".obs; + final startDate = "".obs; + final weekDay = [].obs; + final fromType = 0.obs; + final effectiveDateTime = "".obs;// 生效时间 + final failureDateTime = "".obs;// 失效时间 + final selectType = "0".obs;// 0永久 1显示 2循环 AddFaceState() { Map map = Get.arguments; @@ -30,8 +36,15 @@ class AddFaceState { faceType.value = map["faceType"]; startDate.value = map["startDate"]; lockId.value = map["lockId"]; - cyclicConfig.value = map["cyclicConfig"]; + weekDay.value = map["cyclicConfig"]; fromType.value = map["fromType"]; isAdministrator.value = map["isAdministrator"]; + print("isAdministrator.value isAdministrator.value:${isAdministrator.value}"); + startDate.value = map["startDate"]; + // weekDay.value = map["weekDay"]; + fromType.value = map["fromType"]; + effectiveDateTime.value = map["effectiveTime"]; + failureDateTime.value = map["failureTime"]; + selectType.value = map["selectType"]; } } 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 3d66e39a..d02c47c9 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart @@ -52,28 +52,27 @@ class AddFaceTypeLogic extends BaseGetXController { showToast("请选择有效期".tr); return; } - startDate = - DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); + startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); - startTime = DateTool() - .dateToTimestamp(state.effectiveDateTime.value, 0) - .toString(); - endTime = - DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString(); + startTime = DateTool().dateToTimestamp(state.effectiveDateTime.value, 0).toString(); + endTime = DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString(); faceType = 4; } // 人脸 Get.toNamed(Routers.addFacePage, arguments: { "lockId": state.lockId.value, - "endDate": int.parse(endDate), + "endDate": endDate, "addType": "1", "faceName": state.nameController.text, "faceNumber": "123456", "faceType": faceType, - "startDate": int.parse(startDate), + "startDate": startDate, "cyclicConfig": state.weekdaysList.value, "fromType": state.fromType.value, - "isAdministrator": state.isAdministrator.value, + "isAdministrator": state.isAdministrator.value == false ? "1" : "2", + "effectiveTime": startTime, + "failureTime": endTime, + "selectType": state.selectType.value, }); } 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 2b3bf38e..fd5d2787 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart @@ -121,7 +121,7 @@ class _AddFaceTypePageState extends State { String titleStr, String rightTitle, TextEditingController controller) { return Column( children: [ - Container(height: 10.h), + // Container(height: 10.h), CommonItem( leftTitel: titleStr, rightTitle: "", @@ -172,8 +172,7 @@ class _AddFaceTypePageState extends State { isHaveDirection: true, isHaveLine: true, action: () async { - var result = - await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { 'validityValue': state.weekdaysList.value, 'starDate': state.beginTime.value, 'endDate': state.endTime.value, diff --git a/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart b/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart index 05352a33..9b28945f 100644 --- a/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart @@ -65,24 +65,32 @@ class FaceDetailLogic extends BaseGetXController { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + // var publicKey = await Storage.getStringList(saveBluePublicKey); + // List publicKeyDataList = changeStringListToIntList(publicKey!); + + var token = reply.data.sublist(5, 9); + var saveStrList = changeIntListToStringList(token); + Storage.setStringList(saveBlueToken, saveStrList); - String? userID = await Storage.getUid(); IoSenderManage.senderAddFaceCommand( - keyID: state.keyId.value.toString(), - userID: userID, - faceNo: int.parse(state.typeNumber.value), - useCountLimit: 0, - startTime: int.parse(state.startDate.value), - endTime: int.parse(state.endDate.value), - needAuthor: 1, - publicKey: publicKeyDataList, - privateKey: getPrivateKeyList, - token: getTokenList, + keyID:state.keyId.value.toString(), + userID:await Storage.getUid(), + faceNo:int.parse(state.typeNumber.value), + useCountLimit:0, + isForce:0, // 是否是胁迫 + isRound:0, // 是否是循环 + weekRound:0, // 周循环 + startDate: 0x11223344, + endDate: 0x11223344, + startTime:"0", + endTime:"0", + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, + token: token, ); break; case 0x07: @@ -118,8 +126,8 @@ class FaceDetailLogic extends BaseGetXController { BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + // var publicKey = await Storage.getStringList(saveBluePublicKey); + // List publicKeyDataList = changeStringListToIntList(publicKey!); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -127,18 +135,24 @@ class FaceDetailLogic extends BaseGetXController { var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); - String? userID = await Storage.getUid(); + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); IoSenderManage.senderAddFaceCommand( - keyID: state.keyId.value.toString(), - userID: userID, - faceNo: int.parse(state.typeNumber.value), - useCountLimit: 0, - startTime: int.parse(state.startDate.value), - endTime: int.parse(state.endDate.value), - needAuthor: 1, - publicKey: publicKeyDataList, - privateKey: getPrivateKeyList, + keyID:state.keyId.value.toString(), + userID:await Storage.getUid(), + faceNo:int.parse(state.typeNumber.value), + useCountLimit:0, + isForce:0, // 是否是胁迫 + isRound:0, // 是否是循环 + weekRound:0, // 周循环 + startDate: 0x11223344, + endDate: 0x11223344, + startTime:"0", + endTime:"0", + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, token: getTokenList, ); } else if (deviceConnectionState == 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 c99cf332..4766fe57 100644 --- a/star_lock/lib/main/lockDetail/face/faceList/faceList_logic.dart +++ b/star_lock/lib/main/lockDetail/face/faceList/faceList_logic.dart @@ -2,6 +2,7 @@ import 'dart:async'; // import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; +import 'package:get/get.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'; @@ -14,8 +15,10 @@ 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/dateTool.dart'; import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; +import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart'; class FaceListLogic extends BaseGetXController { FaceListState state = FaceListState(); @@ -65,24 +68,43 @@ class FaceListLogic extends BaseGetXController { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + var token = reply.data.sublist(5, 9); + var saveStrList = changeIntListToStringList(token); + Storage.setStringList(saveBlueToken, saveStrList); 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, + keyID:state.deletKeyID, + userID:state.deletUserID, + faceNo:state.deletFaceNo, + useCountLimit:0, + isForce:0, // 是否是胁迫 + isRound:0, // 是否是循环 + weekRound:0, // 周循环 + startDate: 0x11223344, + endDate: 0x11223344, + startTime:"0", + endTime:"0", + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, + token: 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: //无权限 @@ -308,8 +330,9 @@ class FaceListLogic extends BaseGetXController { BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -318,17 +341,35 @@ class FaceListLogic extends BaseGetXController { 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, + keyID:state.deletKeyID, + userID:state.deletUserID, + faceNo:state.deletFaceNo, + useCountLimit:0, + isForce:0, // 是否是胁迫 + isRound:0, // 是否是循环 + weekRound:0, // 周循环 + startDate: 0x11223344, + endDate: 0x11223344, + startTime:"0", + endTime:"0", + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, token: getTokenList, ); + + // 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 == BluetoothConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); @@ -391,6 +432,32 @@ class FaceListLogic extends BaseGetXController { } } + String getKeyType(FingerprintItemData fingerprintItemData){ + // fingerprintStatus 1:正常 2:失效 + var keyTypeStr = "";// + if(fingerprintItemData.status == 1){ + if(fingerprintItemData.startDate! > DateTime.now().millisecondsSinceEpoch){ + keyTypeStr = "未生效".tr; + } + + }else if(fingerprintItemData.status == 2){ + keyTypeStr = "已失效".tr; + } + return keyTypeStr; + } + + String getKeyDateType(FingerprintItemData fingerprintItemData){ + var keyDateTypeStr = "";// 永久:1;限时2,单次3,循环:4 + if(fingerprintItemData.faceType! == 1){ + keyDateTypeStr = "${DateTool().dateToYMDHNString(fingerprintItemData.createDate.toString())} 永久"; + }else if(fingerprintItemData.faceType! == 2){ + keyDateTypeStr = "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时"; + }else if(fingerprintItemData.faceType! == 4){ + keyDateTypeStr = "${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环"; + } + return keyDateTypeStr; + } + // 监听修改完详情之后刷新列表 late StreamSubscription _teamEvent; void _initRefreshAction() { 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 f2d79311..39b4ac16 100644 --- a/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart +++ b/star_lock/lib/main/lockDetail/face/faceList/faceList_page.dart @@ -5,6 +5,7 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart'; import 'package:star_lock/tools/keySearchWidget.dart'; import 'package:star_lock/tools/left_slide_actions.dart'; +import 'package:star_lock/tools/showTipView.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -44,7 +45,15 @@ class _FaceListPageState extends State { onPressed: () async { var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - showDeletAlertDialog(context); + // showDeletAlertDialog(context); + ShowTipView().showIosTipWithContentDialog("重置后,该锁的人脸都将被删除哦,确认要重置吗?", () async { + state.isDeletFaceData = true; + state.isDeletAll = true; + state.deletKeyID = "1"; + state.deletUserID = "DeleteAll!@#"; + state.deletFaceNo = 255; + logic.senderAddFace(); + }); } else { // Get.toNamed(Routers.selectLockTypePage); logic.showToast("演示模式"); @@ -91,8 +100,7 @@ class _FaceListPageState extends State { ? ListView.separated( itemCount: state.faceItemListData.value.length, itemBuilder: (c, index) { - FingerprintItemData getFaceItemData = - state.faceItemListData.value[index]; + FingerprintItemData getFaceItemData = state.faceItemListData.value[index]; // 人脸 if (index < state.faceItemListData.value.length) { return LeftSlideActions( @@ -107,19 +115,15 @@ class _FaceListPageState extends State { child: _keyItem( 'images/icon_face.png', getFaceItemData.faceName!, - (getFaceItemData.faceType! != 1) - ? (getFaceItemData.endDate! < - DateTime.now().millisecondsSinceEpoch - ? "已失效" - : "") - : "", - getFaceItemData.validTimeStr!, + logic.getKeyType(getFaceItemData), + logic.getKeyDateType(getFaceItemData), + // (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: { + var data = await Get.toNamed(Routers.faceDetailPage, arguments: { "faceItemData": getFaceItemData, }); if (data != null) { @@ -147,7 +151,13 @@ class _FaceListPageState extends State { // 省略: 弹出是否删除的确认对话框。 state.deletKeyID = faceItemData.faceId.toString(); state.deletFaceNo = int.parse(faceItemData.faceNumber!); - showIosTipViewDialog(context); + ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, () async { + state.isDeletFaceData = true; + state.isDeletAll = false; + state.deletUserID = (await Storage.getUid())!; + logic.senderAddFace(); + }); + // showIosTipViewDialog(context); }, child: Container( width: 60, @@ -166,27 +176,27 @@ class _FaceListPageState extends State { ); } - void showIosTipViewDialog(BuildContext context) { - showDialog( - context: context, - builder: (BuildContext context) { - return ShowIosTipView( - title: "提示", - tipTitle: "确定要删除吗?", - sureClick: () async { - Get.back(); - state.isDeletFaceData = true; - state.isDeletAll = false; - state.deletUserID = (await Storage.getUid())!; - logic.senderAddFace(); - }, - cancelClick: () { - Get.back(); - }, - ); - }, - ); - } + // void showIosTipViewDialog(BuildContext context) { + // showDialog( + // context: context, + // builder: (BuildContext context) { + // return ShowIosTipView( + // title: "提示", + // tipTitle: "确定要删除吗?", + // sureClick: () async { + // Get.back(); + // state.isDeletFaceData = true; + // state.isDeletAll = false; + // state.deletUserID = (await Storage.getUid())!; + // logic.senderAddFace(); + // }, + // cancelClick: () { + // Get.back(); + // }, + // ); + // }, + // ); + // } Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String ifInvalidation, String showTime, Function() action) { @@ -212,10 +222,22 @@ class _FaceListPageState extends State { Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(lockTypeTitle, - style: TextStyle( - fontSize: 24.sp, color: AppColors.blackColor)), - Expanded(child: Container()), + SizedBox( + width: 1.sw - 110.w - 100.w, + child: Row( + children: [ + Flexible( + child: Text( + lockTypeTitle, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor) + ), + ), + + ], + ), + ), Text(ifInvalidation, style: TextStyle(fontSize: 22.sp, color: Colors.red)), SizedBox(width: 10.w), @@ -225,10 +247,14 @@ class _FaceListPageState extends State { Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - Text(showTime, - style: TextStyle( - fontSize: 18.sp, - color: AppColors.placeholderTextColor)), + Flexible( + child: Text(showTime, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 18.sp, + color: AppColors.placeholderTextColor)), + ), ], ), SizedBox(width: 20.h), @@ -242,35 +268,36 @@ class _FaceListPageState extends State { ); } - void showDeletAlertDialog(BuildContext context) { - showCupertinoDialog( - context: context, - builder: (context) { - return CupertinoAlertDialog( - title: const Text("提示"), - content: const Text('重置后,该锁的人脸都将被删除哦,确认要重置吗?'), - actions: [ - CupertinoDialogAction( - child: Text(TranslationLoader.lanKeys!.cancel!.tr), - onPressed: () { - Navigator.pop(context); - }, - ), - 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(); - }, - ), - ], - ); - }, - ); - } + // void showDeletAlertDialog(BuildContext context) { + // showCupertinoDialog( + // context: context, + // builder: (context) { + // return CupertinoAlertDialog( + // title: const Text("提示"), + // content: const Text('重置后,该锁的人脸都将被删除哦,确认要重置吗?'), + // actions: [ + // CupertinoDialogAction( + // child: Text(TranslationLoader.lanKeys!.cancel!.tr), + // onPressed: () { + // Navigator.pop(context); + // }, + // ), + // 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/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart index 0cb7ec9d..649f4d07 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart @@ -35,8 +35,6 @@ class FingerprintDetailLogic extends BaseGetXController{ Future _replyAddFingerprintBegin(Reply reply) async { int status = reply.data[2]; - // Get.log("status:$status"); - switch(status){ case 0x00: //成功 @@ -58,8 +56,9 @@ class FingerprintDetailLogic extends BaseGetXController{ // var publicKey = await Storage.getStringList(saveBluePublicKey); // List publicKeyDataList = changeStringListToIntList(publicKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + var token = reply.data.sublist(5, 9); + var saveStrList = changeIntListToStringList(token); + Storage.setStringList(saveBlueToken, saveStrList); IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( keyID:state.keyId.value.toString(), @@ -76,7 +75,7 @@ class FingerprintDetailLogic extends BaseGetXController{ needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, - token: getTokenList, + token: token, ); break; default: diff --git a/star_lock/lib/main/lockDetail/iris/irisList/irisList_logic.dart b/star_lock/lib/main/lockDetail/iris/irisList/irisList_logic.dart index 4e02d739..68820df4 100644 --- a/star_lock/lib/main/lockDetail/iris/irisList/irisList_logic.dart +++ b/star_lock/lib/main/lockDetail/iris/irisList/irisList_logic.dart @@ -64,24 +64,29 @@ class IrisListLogic extends BaseGetXController { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); 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, - ); + // IoSenderManage.senderAddFaceCommand( + // keyID:state.deletKeyID, + // userID:state.deletUserID, + // faceNo:state.deletFaceNo, + // useCountLimit:0, + // isForce:0, // 是否是胁迫 + // isRound:0, // 是否是循环 + // weekRound:0, // 周循环 + // startDate: 0x11223344, + // endDate: 0x11223344, + // startTime:"0", + // endTime:"0", + // needAuthor:1, + // signKey:signKeyDataList, + // privateKey:getPrivateKeyList, + // token: getTokenList, + // ); break; case 0x07: //无权限 @@ -245,17 +250,17 @@ class IrisListLogic extends BaseGetXController { var publicKey = await Storage.getStringList(saveBluePublicKey); List getPublicKeyList = changeStringListToIntList(publicKey!); - IoSenderManage.senderQueryingFaceStatusCommand( - keyID: BlueManage().connectDeviceName, - userID: await Storage.getUid(), - role: 0xff, - faceCount: 20, - faceNo: 1, - token: getTokenList, - needAuthor: 1, - publicKey: getPublicKeyList, - privateKey: getPrivateKeyList, - ); + // IoSenderManage.senderQueryingFaceStatusCommand( + // keyID: BlueManage().connectDeviceName, + // userID: await Storage.getUid(), + // role: 0xff, + // faceCount: 20, + // faceNo: 1, + // token: getTokenList, + // needAuthor: 1, + // publicKey: getPublicKeyList, + // privateKey: getPrivateKeyList, + // ); } }); } @@ -274,16 +279,16 @@ class IrisListLogic extends BaseGetXController { 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, - ); + // IoSenderManage.senderCheckingUserInfoCountCommand( + // keyID: BlueManage().connectDeviceName, + // userID: await Storage.getUid(), + // role: 0xff, + // nowTime: DateTime.now().millisecondsSinceEpoch ~/ 1000, + // token: getTokenList, + // needAuthor: 1, + // publicKey: getPublicKeyList, + // privateKey: getPrivateKeyList, + // ); } }); } @@ -297,8 +302,8 @@ class IrisListLogic extends BaseGetXController { BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -306,18 +311,23 @@ class IrisListLogic extends BaseGetXController { 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, - ); + // IoSenderManage.senderAddFaceCommand( + // keyID:state.deletKeyID, + // userID:state.deletUserID, + // faceNo:state.deletFaceNo, + // useCountLimit:0, + // isForce:0, // 是否是胁迫 + // isRound:0, // 是否是循环 + // weekRound:0, // 周循环 + // startDate: 0x11223344, + // endDate: 0x11223344, + // startTime:"0", + // endTime:"0", + // needAuthor:1, + // signKey:signKeyDataList, + // privateKey:getPrivateKeyList, + // token: getTokenList, + // ); } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { dismissEasyLoading(); diff --git a/star_lock/lib/main/lockDetail/palm/palmList/palmList_logic.dart b/star_lock/lib/main/lockDetail/palm/palmList/palmList_logic.dart index 7188ac16..d08330e3 100644 --- a/star_lock/lib/main/lockDetail/palm/palmList/palmList_logic.dart +++ b/star_lock/lib/main/lockDetail/palm/palmList/palmList_logic.dart @@ -64,24 +64,29 @@ class PalmListLogic extends BaseGetXController { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); 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, - ); + // IoSenderManage.senderAddFaceCommand( + // keyID:state.deletKeyID, + // userID:state.deletUserID, + // faceNo:state.deletFaceNo, + // useCountLimit:0, + // isForce:0, // 是否是胁迫 + // isRound:0, // 是否是循环 + // weekRound:0, // 周循环 + // startDate: 0x11223344, + // endDate: 0x11223344, + // startTime:"0", + // endTime:"0", + // needAuthor:1, + // signKey:signKeyDataList, + // privateKey:getPrivateKeyList, + // token: getTokenList, + // ); break; case 0x07: //无权限 @@ -255,17 +260,17 @@ class PalmListLogic extends BaseGetXController { var publicKey = await Storage.getStringList(saveBluePublicKey); List getPublicKeyList = changeStringListToIntList(publicKey!); - IoSenderManage.senderQueryingFaceStatusCommand( - keyID: BlueManage().connectDeviceName, - userID: await Storage.getUid(), - role: 0xff, - faceCount: 20, - faceNo: 1, - token: getTokenList, - needAuthor: 1, - publicKey: getPublicKeyList, - privateKey: getPrivateKeyList, - ); + // IoSenderManage.senderQueryingFaceStatusCommand( + // keyID: BlueManage().connectDeviceName, + // userID: await Storage.getUid(), + // role: 0xff, + // faceCount: 20, + // faceNo: 1, + // token: getTokenList, + // needAuthor: 1, + // publicKey: getPublicKeyList, + // privateKey: getPrivateKeyList, + // ); } }); } @@ -284,16 +289,16 @@ class PalmListLogic extends BaseGetXController { 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, - ); + // IoSenderManage.senderCheckingUserInfoCountCommand( + // keyID: BlueManage().connectDeviceName, + // userID: await Storage.getUid(), + // role: 0xff, + // nowTime: DateTime.now().millisecondsSinceEpoch ~/ 1000, + // token: getTokenList, + // needAuthor: 1, + // publicKey: getPublicKeyList, + // privateKey: getPrivateKeyList, + // ); } }); } @@ -307,8 +312,8 @@ class PalmListLogic extends BaseGetXController { BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -316,18 +321,23 @@ class PalmListLogic extends BaseGetXController { 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, - ); + // IoSenderManage.senderAddFaceCommand( + // keyID:state.deletKeyID, + // userID:state.deletUserID, + // faceNo:state.deletFaceNo, + // useCountLimit:0, + // isForce:0, // 是否是胁迫 + // isRound:0, // 是否是循环 + // weekRound:0, // 周循环 + // startDate: 0x11223344, + // endDate: 0x11223344, + // startTime:"0", + // endTime:"0", + // needAuthor:1, + // signKey:signKeyDataList, + // privateKey:getPrivateKeyList, + // token: getTokenList, + // ); } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { dismissEasyLoading(); diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 1ca0a5cf..6eae8992 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -1176,7 +1176,7 @@ class ApiProvider extends BaseProvider { int endDate, String featureData, String addType, - List cyclicConfig, + List weekDay, int faceRight, ) => post( @@ -1190,7 +1190,7 @@ class ApiProvider extends BaseProvider { 'endDate': endDate, 'featureData': featureData, 'addType': addType, - 'cyclicConfig': cyclicConfig, + 'weekDay': weekDay, 'faceRight': faceRight })); diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index c640d067..6ca76a26 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -1348,7 +1348,7 @@ class ApiRepository { required int endDate, required String featureData, required String addType, - required List cyclicConfig, + required List weekDay, required int faceRight}) async { final res = await apiProvider.addFaceData( lockId, @@ -1359,7 +1359,7 @@ class ApiRepository { endDate, featureData, addType, - cyclicConfig, + weekDay, faceRight); return AddFaceEntity.fromJson(res.body); }