From e9159de04c3995bf929b379bb7fd1b6752b6ad5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Tue, 23 Apr 2024 11:01:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=A1=E3=80=81=E6=8C=87?= =?UTF-8?q?=E7=BA=B9=E3=80=81=E4=BA=BA=E8=84=B8=E9=99=90=E6=97=B6=E8=B7=9F?= =?UTF-8?q?=E5=BE=AA=E7=8E=AF=E4=BF=AE=E6=94=B9=E6=9C=89=E6=95=88=E6=9C=9F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../otherTypeKeyChangeDate_logic.dart | 81 ++-- .../otherTypeKeyChangeDate_page.dart | 14 +- .../otherTypeKeyChangeDate_state.dart | 6 + .../otherTypeKeyChangeValidityDate_logic.dart | 458 ++++++++++++++++-- .../otherTypeKeyChangeValidityDate_page.dart | 38 +- .../otherTypeKeyChangeValidityDate_state.dart | 9 +- .../face/faceDetail/faceDetail_page.dart | 6 +- .../fingerprintDetail_page.dart | 1 + .../lockDetail/lockDetail_logic.dart | 15 - .../lockDetail/lockDetail_page.dart | 3 + 10 files changed, 518 insertions(+), 113 deletions(-) diff --git a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart index 9091685c..25fb4b3d 100644 --- a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart +++ b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart @@ -77,10 +77,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫 isRound:0, // 是否是循环 weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // 周循环 - startDate: state.fingerprintItemData.value.startDate!~/1000, - endDate: state.fingerprintItemData.value.endDate!~/1000, - startTime:DateTool().dateToHNString(state.fingerprintItemData.value.startDate!.toString()), - endTime:DateTool().dateToHNString(state.fingerprintItemData.value.endDate!.toString()), + startDate: state.beginTimeTimestamp.value~/1000, + endDate: state.endTimeTimestamp.value~/1000, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, @@ -124,10 +124,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫 isRound:0, // 是否是循环 weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // 周循环 - startDate: state.fingerprintItemData.value.startDate!~/1000, - endDate: state.fingerprintItemData.value.endDate!~/1000, - startTime:DateTool().dateToHNString(state.fingerprintItemData.value.startDate!.toString()), - endTime:DateTool().dateToHNString(state.fingerprintItemData.value.endDate!.toString()), + startDate: state.beginTimeTimestamp.value~/1000, + endDate: state.endTimeTimestamp.value~/1000, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, @@ -178,10 +178,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫 isRound:0, // 是否是循环 weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // 周循环 - startDate: state.fingerprintItemData.value.startDate!~/1000, - endDate: state.fingerprintItemData.value.endDate!~/1000, - startTime:DateTool().dateToHNString(state.fingerprintItemData.value.startDate!.toString()), - endTime:DateTool().dateToHNString(state.fingerprintItemData.value.endDate!.toString()), + startDate: state.beginTimeTimestamp.value~/1000, + endDate: state.endTimeTimestamp.value~/1000, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, @@ -228,10 +228,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫 isRound:0, // 是否是循环 weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // 周循环 - startDate: state.fingerprintItemData.value.startDate!~/1000, - endDate: state.fingerprintItemData.value.endDate!~/1000, - startTime:DateTool().dateToHNString(state.fingerprintItemData.value.startDate!.toString()), - endTime:DateTool().dateToHNString(state.fingerprintItemData.value.endDate!.toString()), + startDate: state.beginTimeTimestamp.value~/1000, + endDate: state.endTimeTimestamp.value~/1000, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, @@ -279,10 +279,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫 isRound:0, // 是否是循环 weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // 周循环 - startDate: state.fingerprintItemData.value.startDate!~/1000, - endDate: state.fingerprintItemData.value.endDate!~/1000, - startTime:DateTool().dateToHNString(state.fingerprintItemData.value.startDate!.toString()), - endTime:DateTool().dateToHNString(state.fingerprintItemData.value.endDate!.toString()), + startDate: state.beginTimeTimestamp.value~/1000, + endDate: state.endTimeTimestamp.value~/1000, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, @@ -331,10 +331,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫 isRound:0, // 是否是循环 weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // 周循环 - startDate: state.fingerprintItemData.value.startDate!~/1000, - endDate: state.fingerprintItemData.value.endDate!~/1000, - startTime:DateTool().dateToHNString(state.fingerprintItemData.value.startDate!.toString()), - endTime:DateTool().dateToHNString(state.fingerprintItemData.value.endDate!.toString()), + startDate: state.beginTimeTimestamp.value~/1000, + endDate: state.endTimeTimestamp.value~/1000, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, @@ -357,9 +357,9 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(), lockId: state.fingerprintItemData.value.lockId.toString(), weekDay: state.fingerprintItemData.value.weekDay!, - startDate: DateTool().dateToTimestamp(state.beginTime.value, 1).toString(), - endDate: DateTool().dateToTimestamp(state.endTime.value, 1).toString(), - isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1", + startDate: state.beginTimeTimestamp.value.toString(), + endDate: state.endTimeTimestamp.value.toString(), + isCoerced: state.fingerprintItemData.value.isCoerced.toString(), fingerprintName: state.fingerprintItemData.value.fingerprintName!, changeType: "1", startTime: 0, @@ -370,8 +370,8 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ showToast("修改成功".tr, something: (){ eventBus.fire(OtherTypeRefreshListEvent()); Get.back(result: { - "beginTimeTimestamp":DateTool().dateToTimestamp(state.beginTime.value, 1).toString(), - "endTimeTimestamp":DateTool().dateToTimestamp(state.endTime.value, 1).toString(), + "beginTimeTimestamp":state.beginTimeTimestamp.value.toString(), + "endTimeTimestamp":state.endTimeTimestamp.value.toString(), }); }); } @@ -383,9 +383,9 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ cardId: state.fingerprintItemData.value.cardId.toString(), lockId: state.fingerprintItemData.value.lockId.toString(), weekDay: state.fingerprintItemData.value.weekDay!, - startDate: DateTool().dateToTimestamp(state.beginTime.value, 1).toString(), - endDate: DateTool().dateToTimestamp(state.endTime.value, 1).toString(), - isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1", + startDate: state.beginTimeTimestamp.value.toString(), + endDate: state.endTimeTimestamp.value.toString(), + isCoerced: state.fingerprintItemData.value.isCoerced.toString(), cardName: state.fingerprintItemData.value.cardName!, changeType: '1', startTime: 0, @@ -395,8 +395,8 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ if(entity.errorCode!.codeIsSuccessful){ showToast("修改成功".tr, something: (){ Get.back(result: { - "beginTimeTimestamp":DateTool().dateToTimestamp(state.beginTime.value, 1).toString(), - "endTimeTimestamp":DateTool().dateToTimestamp(state.endTime.value, 1).toString(), + "beginTimeTimestamp":state.beginTimeTimestamp.value.toString(), + "endTimeTimestamp":state.endTimeTimestamp.value.toString(), }); eventBus.fire(OtherTypeRefreshListEvent()); }); @@ -408,22 +408,27 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ var entity = await ApiRepository.to.updateFaceValidity( lockId: state.fingerprintItemData.value.lockId!, faceId: state.fingerprintItemData.value.faceId!, - startDate: DateTool().dateToTimestamp(state.beginTime.value, 1), - endDate: DateTool().dateToTimestamp(state.endTime.value, 1), + startDate: state.beginTimeTimestamp.value, + endDate: state.endTimeTimestamp.value, startTime: 0, endTime: 0, faceType: 2, weekDay: state.fingerprintItemData.value.weekDay!, faceName: state.fingerprintItemData.value.faceName!, addType: "1", - isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? 2 : 1, + isCoerced: state.fingerprintItemData.value.isCoerced!, ); if (entity.errorCode!.codeIsSuccessful) { showToast("修改成功", something: () { - Get.back(result: "addScuess"); + Get.back(result: { + "beginTimeTimestamp":state.beginTimeTimestamp.value.toString(), + "endTimeTimestamp":state.endTimeTimestamp.value.toString(), + }); + eventBus.fire(OtherTypeRefreshListEvent()); }); } } + @override void onReady() { // TODO: implement onReady diff --git a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart index ca6d5c47..1d710198 100644 --- a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart +++ b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart @@ -1,4 +1,6 @@ +import 'dart:ffi'; + import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -42,14 +44,14 @@ class _OtherTypeKeyChangeDatePageState extends State style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () { - var beginTimeTimestamp = DateTool().dateToTimestamp(state.beginTime.value, 1); - var endTimeTimestamp = DateTool().dateToTimestamp(state.endTime.value, 1); - if (beginTimeTimestamp > endTimeTimestamp || beginTimeTimestamp == endTimeTimestamp) { + state.beginTimeTimestamp.value = DateTool().dateToTimestamp(state.beginTime.value, 1); + state.endTimeTimestamp.value = DateTool().dateToTimestamp(state.endTime.value, 1); + if (state.beginTimeTimestamp.value > state.endTimeTimestamp.value || state.beginTimeTimestamp.value == state.endTimeTimestamp.value) { logic.showToast("失效时间需大于生效时间".tr); return; } - if (endTimeTimestamp < DateTime.now().millisecondsSinceEpoch) { + if (state.endTimeTimestamp.value < DateTime.now().millisecondsSinceEpoch) { logic.showToast("生效时间需大于当前时间".tr); return; } @@ -63,6 +65,10 @@ class _OtherTypeKeyChangeDatePageState extends State logic.senderAddFingerprint(); break; case 2: + // 遥控 + + break; + case 3: // 人脸 logic.senderAddFace(); break; diff --git a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart index 9b532f74..b0d31bab 100644 --- a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart +++ b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart @@ -8,6 +8,8 @@ class OtherTypeKeyChangeDateState{ var beginTime = "".obs;// 开始时间 var endTime = "".obs;// 结束时间 + var beginTimeTimestamp = 0.obs;// 开始时间 + var endTimeTimestamp = 0.obs;// 结束时间 var pushType = 0.obs;// 0卡 1指纹 2遥控 3人脸 var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 @@ -26,9 +28,13 @@ class OtherTypeKeyChangeDateState{ if(fingerprintItemData.value.startDate == 0 && fingerprintItemData.value.endDate == 0){ beginTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()); endTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()); + beginTimeTimestamp.value = DateTime.now().millisecondsSinceEpoch; + endTimeTimestamp.value = DateTime.now().millisecondsSinceEpoch; }else{ beginTime.value = DateTool().dateToYMDHNString(fingerprintItemData.value.startDate.toString()); endTime.value = DateTool().dateToYMDHNString(fingerprintItemData.value.endDate.toString()); + beginTimeTimestamp.value = fingerprintItemData.value.startDate!; + endTimeTimestamp.value = fingerprintItemData.value.endDate!; } } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart index 387a16d5..fa688688 100644 --- a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart +++ b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart @@ -1,52 +1,381 @@ +import 'dart:async'; +import 'dart:ffi'; + +import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; +import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../blue/io_protocol/io_addFace.dart'; +import '../../../../blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart'; +import '../../../../blue/io_protocol/io_addICCardWithTimeCycleCoercion.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/dateTool.dart'; import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/storage.dart'; import 'otherTypeKeyChangeValidityDate_state.dart'; class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{ OtherTypeKeyChangeValidityDateState state = OtherTypeKeyChangeValidityDateState(); + // 监听设备返回的数据 + late StreamSubscription _replySubscription; + void _initReplySubscription() { + _replySubscription = EventBusManager().eventBus!.on().listen((reply) async { + // 添加卡片开始(重置锁里面所有卡) + if((reply is SenderAddICCardWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) { + _replyAddICCardBegin(reply); + } + + // 添加指纹开始(此处用作修改或者删除指纹) + if((reply is SenderAddFingerprintWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) { + _replyAddFingerprintBegin(reply); + } + + // 添加人脸开始(此处用作修改人脸) + if ((reply is SenderAddFaceReply) && (state.ifCurrentScreen.value == true)) { + _replyAddFaceBegin(reply); + } + }); + } + + // 添加人脸开始 + Future _replyAddFaceBegin(Reply reply) async { + int status = reply.data[2]; + print("status:$status"); + + switch (status) { + case 0x00: + //成功 + Get.log("${reply.commandType!.typeValue} 删除人脸数据解析成功"); + state.sureBtnState.value = 0; + cancelBlueConnetctToastTimer(); + dismissEasyLoading(); + editFaceData(); + break; + case 0x06: + //无权限 + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); + + var token = reply.data.sublist(5, 9); + var saveStrList = changeIntListToStringList(token); + Storage.setStringList(saveBlueToken, saveStrList); + + IoSenderManage.senderAddFaceCommand( + keyID:state.fingerprintItemData.value.cardId!.toString(), + userID:await Storage.getUid(), + faceNo:int.parse(state.fingerprintItemData.value.faceNumber!), + useCountLimit:0xff, + isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫 + isRound:1, // 是否是循环 + weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环 + startDate: state.starDateTimestamp.value~/1000, + endDate: state.endDateTimestamp.value~/1000, + startTime:DateTool().dateToHNString(state.starTimeTimestamp.value.toString()), + endTime:DateTool().dateToHNString(state.endTimeTimestamp.value.toString()), + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, + token: token, + ); + break; + default: + //失败 + break; + } + } + + // 删除/修改人脸信息 + Future senderAddFace() async { + if (state.sureBtnState.value == 1) { + return; + } + state.sureBtnState.value = 1; + + showEasyLoading(); + showBlueConnetctToastTimer(action: () { + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); + BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + if (deviceConnectionState == BluetoothConnectionState.connected) { + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); + + IoSenderManage.senderAddFaceCommand( + keyID:state.fingerprintItemData.value.cardId!.toString(), + userID:await Storage.getUid(), + faceNo:int.parse(state.fingerprintItemData.value.faceNumber!), + useCountLimit:0xff, + isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫 + isRound:1, // 是否是循环 + weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环 + startDate: state.starDateTimestamp.value~/1000, + endDate: state.endDateTimestamp.value~/1000, + startTime:DateTool().dateToHNString(state.starTimeTimestamp.value.toString()), + endTime:DateTool().dateToHNString(state.endTimeTimestamp.value.toString()), + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, + token: getTokenList, + ); + } else if (deviceConnectionState == + BluetoothConnectionState.disconnected) { + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if (state.ifCurrentScreen.value == true) { + showBlueConnetctToast(); + } + } + }); + } + + // 添加卡片开始(此处用作删除卡片) + Future _replyAddICCardBegin(Reply reply) async { + int status = reply.data[2]; + + switch(status){ + case 0x00: + //成功 + Get.log("${reply.commandType!.typeValue} 数据解析成功"); + cancelBlueConnetctToastTimer(); + dismissEasyLoading(); + editICCardData(); + break; + case 0x06: + //无权限 + Get.log("${reply.commandType!.typeValue} 需要鉴权"); + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); + + var token = reply.data.sublist(5, 9); + var saveStrList = changeIntListToStringList(token); + Storage.setStringList(saveBlueToken, saveStrList); + + IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( + keyID:state.fingerprintItemData.value.cardId!.toString(), + userID:await Storage.getUid(), + cardNo:int.parse(state.fingerprintItemData.value.cardNumber!), + useCountLimit:0xff , + isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫 + isRound:1, // 是否是循环 + weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环 + startDate: state.starDateTimestamp.value~/1000, + endDate: state.endDateTimestamp.value~/1000, + startTime:DateTool().dateToHNString(state.starTimeTimestamp.value.toString()), + endTime:DateTool().dateToHNString(state.endTimeTimestamp.value.toString()), + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, + token: token, + ); + break; + default: + //失败 + Get.log("${reply.commandType!.typeValue} 失败"); + break; + } + } + + // 添加指纹开始 + Future _replyAddFingerprintBegin(Reply reply) async { + int status = reply.data[2]; + switch(status){ + case 0x00: + //成功 + Get.log("${reply.commandType!.typeValue} 数据解析成功"); + state.sureBtnState.value = 0; + cancelBlueConnetctToastTimer(); + dismissEasyLoading(); + editFingerprintsData(); + break; + case 0x06: + //无权限 + Get.log("${reply.commandType!.typeValue} 需要鉴权"); + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); + + var token = reply.data.sublist(5, 9); + var saveStrList = changeIntListToStringList(token); + Storage.setStringList(saveBlueToken, saveStrList); + + IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( + keyID:state.fingerprintItemData.value.fingerprintId.toString(), + userID:await Storage.getUid(), + fingerNo:int.parse(state.fingerprintItemData.value.fingerprintNumber!), + useCountLimit:0xff, + isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫 + isRound:1, // 是否是循环 + weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环 + startDate: state.starDateTimestamp.value~/1000, + endDate: state.endDateTimestamp.value~/1000, + startTime:DateTool().dateToHNString(state.starTimeTimestamp.value.toString()), + endTime:DateTool().dateToHNString(state.endTimeTimestamp.value.toString()), + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, + token: token, + ); + break; + default: + //失败 + Get.log("${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, (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!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( + keyID:state.fingerprintItemData.value.fingerprintId.toString(), + userID:await Storage.getUid(), + fingerNo:int.parse(state.fingerprintItemData.value.fingerprintNumber!), + useCountLimit:0xff, + isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫 + isRound:1, // 是否是循环 + weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环 + startDate: state.starDateTimestamp.value~/1000, + endDate: state.endDateTimestamp.value~/1000, + startTime:DateTool().dateToHNString(state.starTimeTimestamp.value.toString()), + endTime:DateTool().dateToHNString(state.endTimeTimestamp.value.toString()), + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, + token: getTokenList, + ); + } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } + } + }); + } + + // 添加卡片 + Future senderAddICCard() async { + if(state.sureBtnState.value == 1){ + return; + } + state.sureBtnState.value = 1; + + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); + BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + if (deviceConnectionState == BluetoothConnectionState.connected){ + + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); + + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + IoSenderManage.senderAddCardWithTimeCycleCoercionCommand( + keyID:state.fingerprintItemData.value.cardId!.toString(), + userID:await Storage.getUid(), + cardNo:int.parse(state.fingerprintItemData.value.cardNumber!), + useCountLimit:0xff , + isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫 + isRound:1, // 是否是循环 + weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环 + startDate: state.starDateTimestamp.value~/1000, + endDate: state.endDateTimestamp.value~/1000, + startTime:DateTool().dateToHNString(state.starTimeTimestamp.value.toString()), + endTime:DateTool().dateToHNString(state.endTimeTimestamp.value.toString()), + needAuthor:1, + signKey:signKeyDataList, + privateKey:getPrivateKeyList, + token: getTokenList, + ); + } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } + } + }); + } + // 修改指纹信息 void editFingerprintsData() async{ - var starDateTimestamp = DateTool().dateToTimestamp(state.starDate.value, 1); - var endDateTimestamp = DateTool().dateToTimestamp(state.endDate.value, 1); - var starTimeTimestamp = DateTool().dateToTimestamp(state.starTime.value, 0); - var endTimeTimestamp = DateTool().dateToTimestamp(state.endTime.value, 0); - - if (starDateTimestamp >= endDateTimestamp) { - showToast("失效日期要大于生效日期".tr); - return; - } - - if (starTimeTimestamp >= endTimeTimestamp) { - showToast("失效时间要大于生效时间".tr); - return; - } var entity = await ApiRepository.to.editFingerprintsData( fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(), lockId: state.fingerprintItemData.value.lockId.toString(), weekDay: state.weekDay.value, - startDate: starDateTimestamp.toString(), - endDate: endDateTimestamp.toString(), - isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1", + startDate: state.starDateTimestamp.value.toString(), + endDate: state.endDateTimestamp.value.toString(), + isCoerced: state.fingerprintItemData.value.isCoerced.toString(), fingerprintName: state.fingerprintItemData.value.fingerprintName!, changeType: "1", - startTime: starTimeTimestamp, - endTime: endTimeTimestamp, + startTime: state.starTimeTimestamp.value, + endTime: state.endTimeTimestamp.value, fingerprintType: state.fingerprintItemData.value.fingerprintType!, ); if(entity.errorCode!.codeIsSuccessful){ showToast("修改成功".tr, something: (){ eventBus.fire(OtherTypeRefreshListEvent()); Get.back(result: { - "starDate":starDateTimestamp.toString(), - "endDate":endDateTimestamp.toString(), - "starTime":starTimeTimestamp.toString(), - "endTime":endTimeTimestamp.toString(), + "starDate":state.starDateTimestamp.value.toString(), + "endDate":state.endDateTimestamp.value.toString(), + "starTime":state.starTimeTimestamp.value.toString(), + "endTime":state.endTimeTimestamp.value.toString(), "validityValue":state.weekDay.value, }); }); @@ -55,45 +384,82 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{ // 编辑iC卡 void editICCardData() async{ - var starDateTimestamp = DateTool().dateToTimestamp(state.starDate.value, 1); - var endDateTimestamp = DateTool().dateToTimestamp(state.endDate.value, 1); - var starTimeTimestamp = DateTool().dateToTimestamp(state.starTime.value, 0); - var endTimeTimestamp = DateTool().dateToTimestamp(state.endTime.value, 0); - - if (starDateTimestamp >= endDateTimestamp) { - showToast("失效日期要大于生效日期".tr); - return; - } - - if (starTimeTimestamp >= endTimeTimestamp) { - showToast("失效时间要大于生效时间".tr); - return; - } var entity = await ApiRepository.to.editICCardData( cardId: state.fingerprintItemData.value.cardId.toString(), lockId: state.fingerprintItemData.value.lockId.toString(), weekDay: state.weekDay.value, - startDate: starDateTimestamp.toString(), - endDate: endDateTimestamp.toString(), - isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1", + startDate: state.starDateTimestamp.value.toString(), + endDate: state.endDateTimestamp.value.toString(), + isCoerced: state.fingerprintItemData.value.isCoerced!.toString(), cardName: state.fingerprintItemData.value.cardName!, changeType: '1', - startTime: starTimeTimestamp, - endTime: endTimeTimestamp, + startTime: state.starTimeTimestamp.value, + endTime: state.endTimeTimestamp.value, cardType: state.fingerprintItemData.value.cardType!, ); if(entity.errorCode!.codeIsSuccessful){ showToast("修改成功".tr, something: (){ eventBus.fire(OtherTypeRefreshListEvent()); Get.back(result: { - "starDate":starDateTimestamp.toString(), - "endDate":endDateTimestamp.toString(), - "starTime":starTimeTimestamp.toString(), - "endTime":endTimeTimestamp.toString(), + "starDate":state.starDateTimestamp.value.toString(), + "endDate":state.endDateTimestamp.value.toString(), + "starTime":state.starTimeTimestamp.value.toString(), + "endTime":state.endTimeTimestamp.value.toString(), "validityValue":state.weekDay.value, }); }); } } + // 修改人脸有效期 + void editFaceData() async { + var entity = await ApiRepository.to.updateFaceValidity( + lockId: state.fingerprintItemData.value.lockId!, + faceId: state.fingerprintItemData.value.faceId!, + startDate: state.starDateTimestamp.value, + endDate: state.endDateTimestamp.value, + startTime: state.starTimeTimestamp.value, + endTime: state.endTimeTimestamp.value, + faceType: 2, + weekDay: state.weekDay.value, + faceName: state.fingerprintItemData.value.faceName!, + addType: "1", + isCoerced: state.fingerprintItemData.value.isCoerced!, + ); + if (entity.errorCode!.codeIsSuccessful) { + showToast("修改成功", something: () { + Get.back(result: { + "starDate":state.starDateTimestamp.value.toString(), + "endDate":state.endDateTimestamp.value.toString(), + "starTime":state.starTimeTimestamp.value.toString(), + "endTime":state.endTimeTimestamp.value.toString(), + "validityValue":state.weekDay.value, + }); + }); + } + } + + @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(); + } + } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart index 8c471ee1..ba01936e 100644 --- a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart +++ b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart @@ -44,10 +44,40 @@ class _OtherTypeKeyChangeValidityDatePageState extends State= state.endDateTimestamp.value) { + logic.showToast("失效日期要大于生效日期".tr); + return; + } + + if (state.starTimeTimestamp.value >= state.endTimeTimestamp.value) { + logic.showToast("失效时间要大于生效时间".tr); + return; + } + + switch (state.pushType.value) { + case 0: + // 卡 + logic.senderAddICCard(); + break; + case 1: + // 指纹 + logic.senderAddFingerprint(); + break; + case 2: + // 遥控 + + break; + case 3: + // 人脸 + logic.senderAddFace(); + break; + default: + break; } }), ), diff --git a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_state.dart b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_state.dart index c8005b9e..b028f15e 100644 --- a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_state.dart +++ b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_state.dart @@ -12,8 +12,15 @@ class OtherTypeKeyChangeValidityDateState{ var starTime = "".obs;// 生效时间 var endTime = "".obs;// 失效时间 - var pushType = 0.obs;// 0卡 1指纹 2遥控 + var starDateTimestamp = 0.obs;// 开始时间 + var endDateTimestamp = 0.obs;// 结束时间 + var starTimeTimestamp = 0.obs;// 生效时间 + var endTimeTimestamp = 0.obs;// 失效时间 + + var pushType = 0.obs;// 0卡 1指纹 2遥控 3人脸 var weekDay = [].obs; + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) OtherTypeKeyChangeValidityDateState() { Map map = Get.arguments; 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 4c026067..91dc1678 100644 --- a/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart +++ b/star_lock/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart @@ -7,14 +7,10 @@ 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/showTipView.dart'; -import '../../../../tools/storage.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; @@ -100,7 +96,7 @@ class _FaceDetailPageState extends State with RouteAware { var data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, arguments: { - "pushType": 0, + "pushType": 3, "fingerprintItemData": state.faceItemData.value, }); if (data != null) { diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart index d60f3e00..4ee6133e 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart @@ -160,6 +160,7 @@ class _FingerprintDetailPageState extends State with Rout Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.additive!.tr, rightTitle: state.adder.value, + isHaveLine: true, action: () { })), diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 117f11e0..c85aeaec 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -360,21 +360,6 @@ class LockDetailLogic extends BaseGetXController { eventBus.fire(RefreshLockDetailInfoDataEvent()); }); - // var listData = AddUserCommand( - // lockID: BlueManage().connectDeviceName, - // authUserID: state.senderUserId.toString(), - // keyID: state.keyInfos.value.keyId.toString(), - // userID: await Storage.getUid(), - // openMode: 1, - // keyType: 0, - // startDate: state.keyInfos.value.startDate!~/10000, - // expireDate: state.keyInfos.value.endDate!~/10000, - // role: state.keyInfos.value.keyRight == 1 ? 1 : 0, - // password: "123456", - // needAuthor: 1, - // publicKey: publicKeyDataList, - // privateKey: getPrivateKeyList, - // token: getTokenList).packageData(); BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { // 私钥 diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 837aff2f..f945def4 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -17,6 +17,7 @@ import '../../../blue/blue_manage.dart'; import '../../../blue/io_tool/io_tool.dart'; import '../../../common/XSConstantMacro/XSConstantMacro.dart'; import '../../../tools/appRouteObserver.dart'; +import '../../../tools/commonDataManage.dart'; import '../../../tools/dateTool.dart'; import '../../../tools/eventBusEventManage.dart'; import '../../../tools/storage.dart'; @@ -85,6 +86,8 @@ class _LockDetailPageState extends State void loadData() { state.keyInfos.value = widget.lockListInfoItemEntity; state.lockUserNo = state.keyInfos.value.lockUserNo!; + CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!;; + if (state.lockUserNo == 0) { state.bottomBtnisEable.value = false; } else {