2023-12-13 11:54:34 +08:00
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
2024-03-18 16:16:51 +08:00
|
|
|
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
2024-04-10 15:59:44 +08:00
|
|
|
|
import 'package:get/get.dart';
|
2024-05-29 09:06:26 +08:00
|
|
|
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
2024-06-03 14:49:29 +08:00
|
|
|
|
import 'package:star_lock/main/lockDetail/fingerprint/fingerprintList/fingerprint_entity.dart';
|
2023-12-13 11:54:34 +08:00
|
|
|
|
import 'package:star_lock/tools/baseGetXController.dart';
|
|
|
|
|
|
import '../../../../blue/blue_manage.dart';
|
2024-04-16 17:44:38 +08:00
|
|
|
|
import '../../../../blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart';
|
2023-12-13 11:54:34 +08:00
|
|
|
|
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';
|
2024-03-25 15:03:02 +08:00
|
|
|
|
import '../../../../tools/dateTool.dart';
|
2023-12-13 11:54:34 +08:00
|
|
|
|
import '../../../../tools/eventBusEventManage.dart';
|
|
|
|
|
|
import '../../../../tools/storage.dart';
|
2024-01-25 17:40:41 +08:00
|
|
|
|
import 'fingerprintListData_entity.dart';
|
2023-12-13 11:54:34 +08:00
|
|
|
|
import 'fingerprintList_state.dart';
|
|
|
|
|
|
|
2024-06-01 17:29:41 +08:00
|
|
|
|
class FingerprintListLogic extends BaseGetXController {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
FingerprintListState state = FingerprintListState();
|
|
|
|
|
|
|
|
|
|
|
|
// 获取解析后的数据
|
|
|
|
|
|
late StreamSubscription<Reply> _replySubscription;
|
|
|
|
|
|
void _initReplySubscription() {
|
2024-06-01 17:29:41 +08:00
|
|
|
|
_replySubscription =
|
|
|
|
|
|
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
// 添加指纹开始(此处用作删除指纹)
|
2024-06-01 17:29:41 +08:00
|
|
|
|
if ((reply is SenderAddFingerprintWithTimeCycleCoercionReply) &&
|
|
|
|
|
|
(state.ifCurrentScreen.value == true)) {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
_replyAddFingerprintBegin(reply);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-29 09:06:26 +08:00
|
|
|
|
// if(reply is SenderQueryingFingerprintStatusReply) {
|
|
|
|
|
|
// // 获取指纹状态
|
|
|
|
|
|
// _replyQueryingFingerprintStatus(reply);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// if(reply is SenderCheckingUserInfoCountReply){
|
|
|
|
|
|
// _replyCheckingUserInfoCount(reply);
|
|
|
|
|
|
// }
|
2023-12-13 11:54:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-12 19:05:44 +08:00
|
|
|
|
// 添加指纹开始---这里用作删除指纹
|
2023-12-13 11:54:34 +08:00
|
|
|
|
Future<void> _replyAddFingerprintBegin(Reply reply) async {
|
2024-05-29 09:06:26 +08:00
|
|
|
|
final int status = reply.data[2];
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
2024-06-01 17:29:41 +08:00
|
|
|
|
switch (status) {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
case 0x00:
|
2024-04-10 15:59:44 +08:00
|
|
|
|
//成功
|
2024-01-18 11:25:56 +08:00
|
|
|
|
cancelBlueConnetctToastTimer();
|
2024-01-12 19:05:44 +08:00
|
|
|
|
dismissEasyLoading();
|
2023-12-13 11:54:34 +08:00
|
|
|
|
deletAllFingerprintsData();
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 0x06:
|
2024-04-10 15:59:44 +08:00
|
|
|
|
//无权限
|
2024-06-01 17:29:41 +08:00
|
|
|
|
final List<String>? privateKey =
|
|
|
|
|
|
await Storage.getStringList(saveBluePrivateKey);
|
|
|
|
|
|
final List<int> getPrivateKeyList =
|
|
|
|
|
|
changeStringListToIntList(privateKey!);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
2024-06-01 17:29:41 +08:00
|
|
|
|
final List<String>? signKey =
|
|
|
|
|
|
await Storage.getStringList(saveBlueSignKey);
|
2024-05-29 09:06:26 +08:00
|
|
|
|
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
2024-04-15 16:30:00 +08:00
|
|
|
|
|
2024-05-29 09:06:26 +08:00
|
|
|
|
final List<int> token = reply.data.sublist(5, 9);
|
|
|
|
|
|
final List<String> saveStrList = changeIntListToStringList(token);
|
2024-05-04 16:53:27 +08:00
|
|
|
|
Storage.setStringList(saveBlueToken, saveStrList);
|
2024-04-16 17:44:38 +08:00
|
|
|
|
|
|
|
|
|
|
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
|
2024-06-01 17:29:41 +08:00
|
|
|
|
keyID: state.deletKeyID,
|
|
|
|
|
|
userID: (await Storage.getUid())!,
|
|
|
|
|
|
fingerNo: state.deletFingerNo,
|
|
|
|
|
|
useCountLimit: 0xffff,
|
|
|
|
|
|
operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部
|
|
|
|
|
|
isAdmin: 0,
|
|
|
|
|
|
isForce: 0, // 是否是胁迫
|
|
|
|
|
|
isRound: 0, // 是否是循环
|
|
|
|
|
|
weekRound: 0, // 周循环
|
|
|
|
|
|
startDate: 0x11223344,
|
|
|
|
|
|
endDate: 0x11223344,
|
|
|
|
|
|
startTime: '0',
|
|
|
|
|
|
endTime: '0',
|
|
|
|
|
|
needAuthor: 1,
|
|
|
|
|
|
signKey: signKeyDataList,
|
|
|
|
|
|
privateKey: getPrivateKeyList,
|
|
|
|
|
|
token: token,
|
|
|
|
|
|
isBeforeAddUser: false);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
break;
|
|
|
|
|
|
default:
|
2024-04-10 15:59:44 +08:00
|
|
|
|
//失败
|
2023-12-13 11:54:34 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取指纹状态
|
2024-05-29 09:06:26 +08:00
|
|
|
|
// Future<void> _replyQueryingFingerprintStatus(Reply reply) async {
|
|
|
|
|
|
// final int status = reply.data[2];
|
|
|
|
|
|
// switch(status){
|
|
|
|
|
|
// case 0x00:
|
|
|
|
|
|
// //成功
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// case 0x06:
|
|
|
|
|
|
// //需要鉴权
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// default:
|
|
|
|
|
|
// //失败
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
|
|
|
|
|
// 获取卡片状态
|
2024-05-29 09:06:26 +08:00
|
|
|
|
// Future<void> _replyReferEventRecordNumber(Reply reply) async {
|
|
|
|
|
|
// final int status = reply.data[2];
|
|
|
|
|
|
// switch(status){
|
|
|
|
|
|
// case 0x00:
|
|
|
|
|
|
// //成功
|
|
|
|
|
|
// // _getLockStatus();
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// case 0x06:
|
|
|
|
|
|
// //无权限
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// case 0x07:
|
|
|
|
|
|
// //无权限
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// case 0x09:
|
|
|
|
|
|
// // 权限校验错误
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// default:
|
|
|
|
|
|
// //失败
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
|
|
|
|
|
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
2024-05-29 09:06:26 +08:00
|
|
|
|
// Future<void> _replyCheckingUserInfoCount(Reply reply) async {
|
|
|
|
|
|
// final int status = reply.data[2];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 用户数量
|
|
|
|
|
|
// final int userNum = reply.data[5];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 指纹数量
|
|
|
|
|
|
// final int fingerNum = reply.data[6];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 密码数量
|
|
|
|
|
|
// final int pwdNum = reply.data[7];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 卡片数量
|
|
|
|
|
|
// final int cardNum = reply.data[8];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 记录数量
|
|
|
|
|
|
// final int logsNum = reply.data[9];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 版本
|
|
|
|
|
|
// final int verNo = reply.data[10];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 最大管理员指纹数量
|
|
|
|
|
|
// final int maxAdminFingerNum = reply.data[11];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 最大用户指纹数量
|
|
|
|
|
|
// final int maxUserFingerNum = reply.data[12];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 最大管理员密码数量
|
|
|
|
|
|
// final int maxAdminPassNum = reply.data[13];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 最大用户密码数量
|
|
|
|
|
|
// final int maxUserPassNum = reply.data[14];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 最大管理员卡片数量
|
|
|
|
|
|
// final int maxAdminCardNum = reply.data[15];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 最大用户卡片数量
|
|
|
|
|
|
// final int maxUserCardNum = reply.data[16];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 序列号
|
|
|
|
|
|
// final List<int> serialNo = reply.data.sublist(17, 21);
|
|
|
|
|
|
//
|
|
|
|
|
|
// switch(status){
|
|
|
|
|
|
// case 0x00:
|
|
|
|
|
|
// //成功
|
|
|
|
|
|
// // _getLockStatus();
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// case 0x06:
|
|
|
|
|
|
// //无权限
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// default:
|
|
|
|
|
|
// //失败
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
|
|
|
|
|
// 获取指纹状态
|
2024-05-29 09:06:26 +08:00
|
|
|
|
// Future<void> senderQueryingFingerprintStatus() async {
|
|
|
|
|
|
// BlueManage().blueSendData(BlueManage().connectDeviceName,(BluetoothConnectionState state) async {
|
|
|
|
|
|
// if (state == BluetoothConnectionState.connected) {
|
|
|
|
|
|
// final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
|
|
|
|
// final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
|
|
|
|
//
|
|
|
|
|
|
// final List<String>? token = await Storage.getStringList(saveBlueToken);
|
|
|
|
|
|
// final List<int> getTokenList = changeStringListToIntList(token!);
|
|
|
|
|
|
//
|
|
|
|
|
|
// final List<String>? publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
|
|
|
|
// final List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
|
|
|
|
|
//
|
|
|
|
|
|
// IoSenderManage.senderQueryingFingerprintStatusCommand(
|
|
|
|
|
|
// keyID:BlueManage().connectDeviceName,
|
|
|
|
|
|
// userID:await Storage.getUid(),
|
|
|
|
|
|
// role:0xff,
|
|
|
|
|
|
// fingerCount:20,
|
|
|
|
|
|
// fingerNo:1,
|
|
|
|
|
|
// token:getTokenList,
|
|
|
|
|
|
// needAuthor:1,
|
|
|
|
|
|
// publicKey:getPublicKeyList,
|
|
|
|
|
|
// privateKey:getPrivateKeyList,
|
|
|
|
|
|
// );
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
|
|
|
|
|
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
2024-05-29 09:06:26 +08:00
|
|
|
|
// Future<void> senderCheckingUserInfoCount() async {
|
|
|
|
|
|
// BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
|
|
|
|
|
// if (state == BluetoothConnectionState.connected) {
|
|
|
|
|
|
// final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
|
|
|
|
// final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
|
|
|
|
//
|
|
|
|
|
|
// final List<String>? token = await Storage.getStringList(saveBlueToken);
|
|
|
|
|
|
// final List<int> getTokenList = changeStringListToIntList(token!);
|
|
|
|
|
|
//
|
|
|
|
|
|
// final List<String>? publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
|
|
|
|
// final List<int> 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,
|
|
|
|
|
|
// );
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
|
|
|
|
|
// 删除指纹
|
2023-12-16 11:20:36 +08:00
|
|
|
|
Future<void> senderAddFingerprint() async {
|
2024-01-12 19:05:44 +08:00
|
|
|
|
showEasyLoading();
|
2024-06-01 17:29:41 +08:00
|
|
|
|
showBlueConnetctToastTimer(action: () {
|
2024-01-12 19:05:44 +08:00
|
|
|
|
dismissEasyLoading();
|
|
|
|
|
|
});
|
2024-06-01 17:29:41 +08:00
|
|
|
|
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
|
|
|
|
|
(BluetoothConnectionState deviceConnectionState) async {
|
|
|
|
|
|
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
2024-04-15 16:30:00 +08:00
|
|
|
|
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
|
|
|
|
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
|
|
|
|
|
|
2024-06-01 17:29:41 +08:00
|
|
|
|
final List<String>? signKey =
|
|
|
|
|
|
await Storage.getStringList(saveBlueSignKey);
|
2024-05-29 09:06:26 +08:00
|
|
|
|
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
2024-06-01 17:29:41 +08:00
|
|
|
|
final List<String>? privateKey =
|
|
|
|
|
|
await Storage.getStringList(saveBluePrivateKey);
|
|
|
|
|
|
final List<int> getPrivateKeyList =
|
|
|
|
|
|
changeStringListToIntList(privateKey!);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
2024-05-29 09:06:26 +08:00
|
|
|
|
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
|
|
|
|
|
final List<int> getTokenList = changeStringListToIntList(token!);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
2024-04-16 17:44:38 +08:00
|
|
|
|
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
|
2024-06-01 17:29:41 +08:00
|
|
|
|
keyID: state.deletKeyID,
|
|
|
|
|
|
userID: (await Storage.getUid())!,
|
|
|
|
|
|
fingerNo: state.deletFingerNo,
|
|
|
|
|
|
useCountLimit: 0xffff,
|
|
|
|
|
|
operate: state.isDeletAll == true ? 3 : 2, // 0:注册 1:修改 2:删除 3:删除全部
|
|
|
|
|
|
isAdmin: 0,
|
|
|
|
|
|
isForce: 0, // 是否是胁迫
|
|
|
|
|
|
isRound: 0, // 是否是循环
|
|
|
|
|
|
weekRound: 0, // 周循环
|
|
|
|
|
|
startDate: 0x11223344,
|
|
|
|
|
|
endDate: 0x11223344,
|
|
|
|
|
|
startTime: '0',
|
|
|
|
|
|
endTime: '0',
|
|
|
|
|
|
needAuthor: 1,
|
|
|
|
|
|
signKey: signKeyDataList,
|
|
|
|
|
|
privateKey: getPrivateKeyList,
|
|
|
|
|
|
token: getTokenList,
|
|
|
|
|
|
isBeforeAddUser: false);
|
|
|
|
|
|
} else if (deviceConnectionState ==
|
|
|
|
|
|
BluetoothConnectionState.disconnected) {
|
2024-01-12 19:05:44 +08:00
|
|
|
|
dismissEasyLoading();
|
|
|
|
|
|
cancelBlueConnetctToastTimer();
|
2024-06-01 17:29:41 +08:00
|
|
|
|
if (state.ifCurrentScreen.value == true) {
|
2024-01-12 19:05:44 +08:00
|
|
|
|
showBlueConnetctToast();
|
|
|
|
|
|
}
|
2023-12-13 11:54:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-06-01 17:29:41 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* //请求密码钥匙列表
|
|
|
|
|
|
Future<PasswordKeyListEntity> mockNetworkDataRequest(
|
|
|
|
|
|
{required bool isRefresh}) async {
|
|
|
|
|
|
// 如果是下拉刷新,清空已有数据
|
|
|
|
|
|
if (isRefresh) {
|
|
|
|
|
|
state.itemDataList.clear();
|
|
|
|
|
|
pageNo = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
final PasswordKeyListEntity entity = await ApiRepository.to.passwordKeyList(
|
|
|
|
|
|
state.keyInfo.value.keyStatus.toString(),
|
|
|
|
|
|
state.keyInfo.value.lockId.toString(),
|
|
|
|
|
|
pageNo.toString(),
|
|
|
|
|
|
pageSize.toString(),
|
|
|
|
|
|
state.searchController.text);
|
|
|
|
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
|
|
|
|
// 更新数据列表
|
|
|
|
|
|
state.itemDataList.addAll(entity.data!.itemList!);
|
|
|
|
|
|
// 更新页码
|
|
|
|
|
|
pageNo++;
|
|
|
|
|
|
}
|
|
|
|
|
|
return entity;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
|
|
|
|
|
// 获取指纹列表
|
2024-12-04 13:55:58 +08:00
|
|
|
|
Future<FingerprintListDataEntity> getFingerprintsListData(
|
|
|
|
|
|
{required bool isRefresh}) async {
|
2024-06-01 17:29:41 +08:00
|
|
|
|
// 如果是下拉刷新,清空已有数据
|
|
|
|
|
|
if (isRefresh) {
|
|
|
|
|
|
state.fingerprintItemListData.clear();
|
|
|
|
|
|
pageNo = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
final FingerprintListDataEntity entity =
|
|
|
|
|
|
await ApiRepository.to.getFingerprintsListData(
|
2023-12-13 11:54:34 +08:00
|
|
|
|
lockId: state.lockId.value.toString(),
|
2024-01-25 17:40:41 +08:00
|
|
|
|
pageNo: pageNo.toString(),
|
|
|
|
|
|
pageSize: pageSize.toString(),
|
2023-12-13 11:54:34 +08:00
|
|
|
|
searchStr: state.searchController.text,
|
|
|
|
|
|
);
|
2024-06-01 17:29:41 +08:00
|
|
|
|
// if (entity.errorCode!.codeIsSuccessful) {
|
|
|
|
|
|
// if (pageNo == 1) {
|
|
|
|
|
|
// state.fingerprintItemListData.value = entity.data!.list!;
|
|
|
|
|
|
// pageNo++;
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// if (entity.data!.list!.isNotEmpty) {
|
|
|
|
|
|
// state.fingerprintItemListData.value.addAll(entity.data!.list!);
|
|
|
|
|
|
// pageNo++;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
|
|
|
|
// 更新数据列表
|
|
|
|
|
|
state.fingerprintItemListData.addAll(entity.data!.list!);
|
|
|
|
|
|
// 更新页码
|
|
|
|
|
|
pageNo++;
|
2023-12-13 11:54:34 +08:00
|
|
|
|
}
|
2024-06-01 17:29:41 +08:00
|
|
|
|
|
2024-01-25 17:40:41 +08:00
|
|
|
|
return entity;
|
2023-12-13 11:54:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 重置所有的指纹
|
2024-06-01 17:29:41 +08:00
|
|
|
|
Future<void> deletAllFingerprintsData() async {
|
2024-05-29 09:06:26 +08:00
|
|
|
|
String fingerprintId = '';
|
|
|
|
|
|
String type = '1';
|
2024-06-01 17:29:41 +08:00
|
|
|
|
if (state.isDeletAll == false) {
|
2023-12-16 11:20:36 +08:00
|
|
|
|
fingerprintId = state.deletKeyID;
|
2024-05-29 09:06:26 +08:00
|
|
|
|
type = '0';
|
2023-12-14 11:14:56 +08:00
|
|
|
|
}
|
2024-05-29 09:06:26 +08:00
|
|
|
|
final LoginEntity entity = await ApiRepository.to.deletFingerprintsData(
|
2023-12-14 11:14:56 +08:00
|
|
|
|
fingerprintId: fingerprintId,
|
2023-12-13 11:54:34 +08:00
|
|
|
|
lockId: state.lockId.value.toString(),
|
2023-12-16 11:20:36 +08:00
|
|
|
|
type: type,
|
2024-06-01 17:29:41 +08:00
|
|
|
|
deleteType: '1');
|
|
|
|
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
|
|
|
|
if (state.isDeletAll == false) {
|
|
|
|
|
|
showToast('删除成功'.tr, something: () {
|
|
|
|
|
|
getFingerprintsListData(isRefresh: true);
|
2024-03-19 18:04:51 +08:00
|
|
|
|
});
|
2024-06-01 17:29:41 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
showToast('重置成功'.tr, something: () {
|
|
|
|
|
|
getFingerprintsListData(isRefresh: true);
|
2024-03-19 18:04:51 +08:00
|
|
|
|
});
|
2023-12-16 11:20:36 +08:00
|
|
|
|
}
|
2023-12-13 11:54:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 监听修改完详情之后刷新列表
|
|
|
|
|
|
late StreamSubscription _teamEvent;
|
|
|
|
|
|
void _initRefreshAction() {
|
2024-06-01 17:29:41 +08:00
|
|
|
|
_teamEvent = eventBus
|
|
|
|
|
|
.on<OtherTypeRefreshListEvent>()
|
|
|
|
|
|
.listen((OtherTypeRefreshListEvent event) {
|
|
|
|
|
|
getFingerprintsListData(isRefresh: true);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-01 17:29:41 +08:00
|
|
|
|
String getKeyType(FingerprintItemData fingerprintItemData) {
|
2024-04-02 17:30:44 +08:00
|
|
|
|
// fingerprintStatus 1:正常 2:失效
|
2024-06-01 17:29:41 +08:00
|
|
|
|
String keyTypeStr = ''; //
|
2024-04-02 17:30:44 +08:00
|
|
|
|
// (fingerprintItemData.fingerprintType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : ""
|
2024-06-01 17:29:41 +08:00
|
|
|
|
if (fingerprintItemData.fingerprintStatus == 1) {
|
|
|
|
|
|
if (fingerprintItemData.startDate! >
|
|
|
|
|
|
DateTime.now().millisecondsSinceEpoch) {
|
2024-05-29 09:06:26 +08:00
|
|
|
|
keyTypeStr = '未生效'.tr;
|
2024-04-02 17:30:44 +08:00
|
|
|
|
}
|
2024-06-01 17:29:41 +08:00
|
|
|
|
} else if (fingerprintItemData.fingerprintStatus == 2) {
|
2024-05-29 09:06:26 +08:00
|
|
|
|
keyTypeStr = '已失效'.tr;
|
2024-04-02 17:30:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
return keyTypeStr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-01 17:29:41 +08:00
|
|
|
|
String getKeyDateType(FingerprintItemData fingerprintItemData) {
|
|
|
|
|
|
String keyDateTypeStr = ''; // 永久:1;限时2,单次3,循环:4
|
|
|
|
|
|
if (fingerprintItemData.fingerprintType! == 1) {
|
|
|
|
|
|
keyDateTypeStr =
|
|
|
|
|
|
"${DateTool().dateToYMDHNString(fingerprintItemData.createDate.toString())} ${"永久".tr}";
|
|
|
|
|
|
} else if (fingerprintItemData.fingerprintType! == 2) {
|
|
|
|
|
|
keyDateTypeStr =
|
2024-12-04 13:55:58 +08:00
|
|
|
|
'${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} ${'限时'.tr}';
|
2024-06-01 17:29:41 +08:00
|
|
|
|
} else if (fingerprintItemData.fingerprintType! == 4) {
|
|
|
|
|
|
keyDateTypeStr =
|
2024-12-04 13:55:58 +08:00
|
|
|
|
'${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} ${'循环'.tr}';
|
2024-03-25 15:03:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
return keyDateTypeStr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-03 14:49:29 +08:00
|
|
|
|
//刷新单条信息
|
2024-12-04 13:55:58 +08:00
|
|
|
|
Future<void> refreshIndividualKeys({required int fingerprintId}) async {
|
2024-06-03 14:49:29 +08:00
|
|
|
|
final FingerprintEntity entity =
|
2024-12-04 13:55:58 +08:00
|
|
|
|
await ApiRepository.to.getFingerprintsData(fingerprintId);
|
2024-06-03 14:49:29 +08:00
|
|
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
2024-12-04 13:55:58 +08:00
|
|
|
|
final int index = state.fingerprintItemListData.indexWhere(
|
|
|
|
|
|
(FingerprintItemData item) => item.fingerprintId == fingerprintId);
|
2024-06-03 14:49:29 +08:00
|
|
|
|
state.fingerprintItemListData.removeAt(index);
|
|
|
|
|
|
state.fingerprintItemListData.insert(index, entity.data!);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-13 11:54:34 +08:00
|
|
|
|
@override
|
|
|
|
|
|
Future<void> onReady() async {
|
|
|
|
|
|
super.onReady();
|
|
|
|
|
|
|
|
|
|
|
|
// 获取是否是演示模式 演示模式不获取接口
|
2024-06-01 17:29:41 +08:00
|
|
|
|
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
|
|
|
|
|
if (isDemoMode == false) {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
_initReplySubscription();
|
|
|
|
|
|
|
|
|
|
|
|
_initRefreshAction();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Future<void> onInit() async {
|
|
|
|
|
|
super.onInit();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Future<void> onClose() async {
|
|
|
|
|
|
super.onClose();
|
|
|
|
|
|
|
2024-06-01 17:29:41 +08:00
|
|
|
|
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
|
|
|
|
|
if (isDemoMode == false) {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
_replySubscription.cancel();
|
|
|
|
|
|
_teamEvent.cancel();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-01 17:29:41 +08:00
|
|
|
|
}
|