diff --git a/star_lock/lib/main/lockDetail/iris/addIris/addIris_logic.dart b/star_lock/lib/main/lockDetail/iris/addIris/addIris_logic.dart index 4404283e..4020fd9e 100644 --- a/star_lock/lib/main/lockDetail/iris/addIris/addIris_logic.dart +++ b/star_lock/lib/main/lockDetail/iris/addIris/addIris_logic.dart @@ -20,261 +20,6 @@ import '../../../../../tools/storage.dart'; class AddIrisLogic 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, - (BluetoothConnectionState deviceConnectionState) async { - if (deviceConnectionState == BluetoothConnectionState.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}"); - 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, - token: getTokenList, - ); - } else if (deviceConnectionState == - BluetoothConnectionState.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, - faceRight: state.isAdministrator.value == true ? 1 : 0, - ); - - if (entity.errorCode!.codeIsSuccessful) { - // Toast.show(msg: "添加成功"); - print('更新人脸用户账号成功了么1'); - updateFaceUserNoLoadData(entity.data!.faceId!); - } - } - - // 更新人脸用户账号 - void updateFaceUserNoLoadData(int faceId) async { - var entity = await ApiRepository.to.updateFaceUserNo( - faceId: faceId, - lockId: state.lockId.value, - faceUserNo: state.faceNumber.value, - ); - if (entity.errorCode!.codeIsSuccessful) { - print('更新人脸用户账号成功了么2'); - showToast("添加成功"); - if (state.fromType.value == 2) { - // 回调人脸号 - eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent( - state.faceNumber.value)); - } else if (state.fromType.value == 1) { - eventBus.fire(OtherTypeRefreshListEvent()); - } - Get.close(2); - } - } - @override void onReady() { // TODO: implement onReady diff --git a/star_lock/lib/main/lockDetail/iris/addIris/addIris_page.dart b/star_lock/lib/main/lockDetail/iris/addIris/addIris_page.dart index 552898ae..72787529 100644 --- a/star_lock/lib/main/lockDetail/iris/addIris/addIris_page.dart +++ b/star_lock/lib/main/lockDetail/iris/addIris/addIris_page.dart @@ -72,7 +72,6 @@ class _AddIrisPageState extends State { borderRadius: 20.w, onClick: () { state.isClickAddFace.value = true; - logic.senderAddFace(); }), ) : Row(