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';
|
2023-12-13 11:54:34 +08:00
|
|
|
import 'package:get/get.dart';
|
2024-10-21 16:18:53 +08:00
|
|
|
import 'package:star_lock/app_settings/app_settings.dart';
|
2024-05-29 09:06:26 +08:00
|
|
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
|
|
|
|
import 'package:star_lock/main/lockDetail/fingerprint/addFingerprint/addFingerprint_entity.dart';
|
2024-04-19 18:13:34 +08:00
|
|
|
import 'package:star_lock/tools/dateTool.dart';
|
2024-10-21 16:18:53 +08:00
|
|
|
import 'package:umeng_common_sdk/umeng_common_sdk.dart';
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
|
|
|
import '../../../../../blue/blue_manage.dart';
|
|
|
|
|
import '../../../../../blue/io_reply.dart';
|
|
|
|
|
import '../../../../../blue/io_tool/io_tool.dart';
|
|
|
|
|
import '../../../../../blue/io_tool/manager_event_bus.dart';
|
|
|
|
|
import '../../../../../blue/sender_manage.dart';
|
|
|
|
|
import '../../../../../network/api_repository.dart';
|
|
|
|
|
import '../../../../../tools/baseGetXController.dart';
|
|
|
|
|
import '../../../../../tools/eventBusEventManage.dart';
|
|
|
|
|
import '../../../../../tools/storage.dart';
|
2024-04-15 16:30:00 +08:00
|
|
|
import '../../../../blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart';
|
2024-10-21 16:18:53 +08:00
|
|
|
import '../../../../tools/bugly/bugly_tool.dart';
|
2023-12-13 11:54:34 +08:00
|
|
|
import 'addFingerprint_state.dart';
|
|
|
|
|
|
|
|
|
|
class AddFingerprintLogic extends BaseGetXController {
|
|
|
|
|
final AddFingerprintState state = AddFingerprintState();
|
|
|
|
|
|
|
|
|
|
// 监听设备返回的数据
|
|
|
|
|
late StreamSubscription<Reply> _replySubscription;
|
|
|
|
|
void _initReplySubscription() {
|
2024-05-29 09:06:26 +08:00
|
|
|
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
2023-12-13 11:54:34 +08:00
|
|
|
// 添加指纹开始
|
2024-05-03 18:31:15 +08:00
|
|
|
if((reply is SenderAddFingerprintWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) {
|
2023-12-13 11:54:34 +08:00
|
|
|
_replyAddFingerprintBegin(reply);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加指纹过程
|
|
|
|
|
if(reply is SenderAddFingerprintProcessReply) {
|
|
|
|
|
_replyAddFingerprintProcess(reply);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加指纹确认
|
|
|
|
|
if(reply is SenderAddFingerprintConfirmationReply) {
|
|
|
|
|
_replyAddFingerprintConfirmation(reply);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _replyAddFingerprintBegin(Reply reply) async {
|
2024-10-21 16:18:53 +08:00
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
message: '添加指纹开始,解析数据',
|
|
|
|
|
detail: '添加指纹开始,解析数据 _replyAddFingerprintBegin:${reply.data}',
|
|
|
|
|
upload: false
|
|
|
|
|
);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
2024-10-21 16:18:53 +08:00
|
|
|
final int status = reply.data[2];
|
2023-12-13 11:54:34 +08:00
|
|
|
switch(status){
|
|
|
|
|
case 0x00:
|
2024-04-10 15:59:44 +08:00
|
|
|
//成功
|
2023-12-13 11:54:34 +08:00
|
|
|
state.ifConnectScuess.value = true;
|
2024-05-07 14:11:49 +08:00
|
|
|
state.ifAddState.value = true;
|
|
|
|
|
cancelBlueConnetctToastTimer();
|
2024-01-12 19:05:44 +08:00
|
|
|
|
|
|
|
|
// 最大图片数
|
2024-05-04 16:53:27 +08:00
|
|
|
state.maxRegCount.value = reply.data[11];
|
2024-04-26 15:38:59 +08:00
|
|
|
// AppLog.log("state.maxRegCount.value:${state.maxRegCount.value}");
|
2023-12-16 11:20:36 +08:00
|
|
|
// state.fingerprintNumber.value = reply.data.last.toString();
|
2023-12-13 11:54:34 +08:00
|
|
|
break;
|
|
|
|
|
case 0x06:
|
2024-04-10 15:59:44 +08:00
|
|
|
//无权限
|
2024-05-29 09:06:26 +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>? signKey = await Storage.getStringList(saveBlueSignKey);
|
|
|
|
|
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
2023-12-13 11:54:34 +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);
|
2023-12-13 17:38:50 +08:00
|
|
|
Storage.setStringList(saveBlueToken, saveStrList);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
2024-04-15 16:30:00 +08:00
|
|
|
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
|
2024-05-29 09:06:26 +08:00
|
|
|
keyID:'1',
|
2023-12-13 11:54:34 +08:00
|
|
|
userID:await Storage.getUid(),
|
2024-05-04 16:53:27 +08:00
|
|
|
fingerNo:0,
|
|
|
|
|
useCountLimit:0xffff,
|
2024-05-30 09:27:29 +08:00
|
|
|
isForce:state.isCoerced.value == '1' ? 1 : 0, // 是否是胁迫
|
2024-05-29 09:06:26 +08:00
|
|
|
isAdmin: state.isAdministrator.value == '2' ? 1 : 0,
|
2024-05-04 16:53:27 +08:00
|
|
|
operate: 0,
|
2024-05-29 09:06:26 +08:00
|
|
|
isRound:state.selectType.value == '2' ? 1: 0, // 是否是循环
|
2024-04-22 11:16:37 +08:00
|
|
|
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环
|
2024-04-15 16:30:00 +08:00
|
|
|
startDate: int.parse(state.startDate.value)~/1000,
|
|
|
|
|
endDate: int.parse(state.endDate.value)~/1000,
|
2024-04-19 18:13:34 +08:00
|
|
|
startTime:DateTool().dateToHNString(state.effectiveDateTime.value),
|
|
|
|
|
endTime:DateTool().dateToHNString(state.failureDateTime.value),
|
2023-12-13 11:54:34 +08:00
|
|
|
needAuthor:1,
|
2024-04-15 16:30:00 +08:00
|
|
|
signKey:signKeyDataList,
|
2023-12-13 11:54:34 +08:00
|
|
|
privateKey:getPrivateKeyList,
|
2023-12-13 17:38:50 +08:00
|
|
|
token: token,
|
2024-05-29 09:06:26 +08:00
|
|
|
isBeforeAddUser: false
|
2023-12-13 11:54:34 +08:00
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2024-04-10 15:59:44 +08:00
|
|
|
//失败
|
2024-05-07 14:11:49 +08:00
|
|
|
state.ifAddState.value = false;
|
2024-08-21 14:12:15 +08:00
|
|
|
showToast('添加指纹失败'.tr, something: (){
|
2024-04-07 14:03:59 +08:00
|
|
|
Get.back();
|
|
|
|
|
});
|
2023-12-13 11:54:34 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _replyAddFingerprintProcess(Reply reply) async {
|
2024-10-21 16:18:53 +08:00
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
message: '添加指纹过程,解析数据',
|
|
|
|
|
detail: '添加指纹过程,解析数据 _replyAddFingerprintProcess:${reply.data}',
|
|
|
|
|
upload: false
|
|
|
|
|
);
|
2024-05-29 09:06:26 +08:00
|
|
|
final int status = reply.data[2];
|
2023-12-13 11:54:34 +08:00
|
|
|
switch(status){
|
|
|
|
|
case 0x00:
|
|
|
|
|
//成功
|
2024-05-07 14:11:49 +08:00
|
|
|
switch(reply.data[5]){
|
|
|
|
|
case 0xff:
|
|
|
|
|
// 注册指纹失败
|
2024-05-29 09:06:26 +08:00
|
|
|
showToast('退出添加'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
state.ifAddState.value = false;
|
|
|
|
|
Get.close(1);
|
|
|
|
|
break;
|
|
|
|
|
case 0xFE:
|
|
|
|
|
// 管理员已满
|
2024-05-29 09:06:26 +08:00
|
|
|
showToast('管理员已满'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
state.ifAddState.value = false;
|
|
|
|
|
Get.close(1);
|
|
|
|
|
break;
|
|
|
|
|
case 0xFD:
|
|
|
|
|
// 用户已满
|
2024-05-29 09:06:26 +08:00
|
|
|
showToast('用户已满'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
state.ifAddState.value = false;
|
|
|
|
|
Get.close(1);
|
|
|
|
|
break;
|
|
|
|
|
case 0xFC:
|
|
|
|
|
// 指纹已满
|
2024-05-29 09:06:26 +08:00
|
|
|
showToast('锁上面添加指纹已满'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
state.ifAddState.value = false;
|
|
|
|
|
Get.close(1);
|
|
|
|
|
break;
|
|
|
|
|
case 0xFB:
|
|
|
|
|
// 指纹已存在
|
2024-05-29 09:06:26 +08:00
|
|
|
showToast('指纹已存在'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
state.ifAddState.value = false;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// 添加指纹中
|
|
|
|
|
// 当前注册数
|
|
|
|
|
state.regIndex.value = reply.data[6];
|
|
|
|
|
// AppLog.log("当前注册数 state.regIndex.value:${state.regIndex.value}");
|
|
|
|
|
break;
|
2023-12-13 11:54:34 +08:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
//失败
|
2024-05-07 14:11:49 +08:00
|
|
|
state.ifAddState.value = false;
|
2023-12-13 11:54:34 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _replyAddFingerprintConfirmation(Reply reply) async {
|
2024-05-29 09:06:26 +08:00
|
|
|
final int status = reply.data[2];
|
2024-10-21 16:18:53 +08:00
|
|
|
final String getMobile = (await Storage.getMobile())!;
|
2023-12-13 11:54:34 +08:00
|
|
|
switch(status){
|
|
|
|
|
case 0x00:
|
|
|
|
|
//成功
|
2024-05-04 16:53:27 +08:00
|
|
|
// var fingerprintNum = listChangInt(reply.data.sublist(9, 11)).toString();
|
2024-10-21 16:18:53 +08:00
|
|
|
UmengCommonSdk.onEvent('add_fingerprint', {
|
|
|
|
|
'lock_name':BlueManage().connectDeviceName,
|
|
|
|
|
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
|
|
|
|
'date':DateTool().getNowDateWithType(1),
|
|
|
|
|
'add_fingerprint_result':'成功',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
message: '添加指纹确认结果,解析数据',
|
|
|
|
|
detail: '添加指纹确认结果,解析数据 _replyAddFingerprintConfirmation:${reply.data}',
|
|
|
|
|
upload: false
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final List<int> fingerprintList = reply.data.sublist(reply.data.length - 2);
|
|
|
|
|
final String fingerprintNum = listChangInt(fingerprintList).toString();
|
|
|
|
|
state.regIndex.value++;
|
2024-05-03 18:31:15 +08:00
|
|
|
if(state.fingerprintNumber.value == fingerprintNum){
|
2024-01-16 10:41:08 +08:00
|
|
|
return;
|
|
|
|
|
}else{
|
2024-05-03 18:31:15 +08:00
|
|
|
state.fingerprintNumber.value = fingerprintNum;
|
2024-01-16 10:41:08 +08:00
|
|
|
}
|
2024-04-15 16:30:00 +08:00
|
|
|
// if(state.isCoerced.value == "1"){
|
2024-05-03 18:31:15 +08:00
|
|
|
// 调用添加指纹接口
|
2024-05-07 14:11:49 +08:00
|
|
|
state.ifAddState.value = false;
|
|
|
|
|
addFingerprintsData();
|
2024-04-15 16:30:00 +08:00
|
|
|
// }else{
|
|
|
|
|
// // 如果是胁迫指纹在 添加完之后以后再调用添加胁迫指纹的
|
|
|
|
|
// senderAddStressFingerprint();
|
|
|
|
|
// }
|
2023-12-13 11:54:34 +08:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
//失败
|
2024-10-21 16:18:53 +08:00
|
|
|
UmengCommonSdk.onEvent('add_fingerprint', {
|
|
|
|
|
'lock_name':BlueManage().connectDeviceName,
|
|
|
|
|
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
|
|
|
|
'date':DateTool().getNowDateWithType(1),
|
|
|
|
|
'add_fingerprint_result':'失败-${reply.data}',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
message: '添加指纹确认结果,解析数据',
|
2024-10-21 17:19:56 +08:00
|
|
|
detail: '添加指纹确认结果蓝牙返回失败结果,解析数据 _replyAddFingerprintConfirmation:${reply.data}',
|
|
|
|
|
eventStr: '添加指纹事件蓝牙返回失败结果',
|
2024-10-21 16:18:53 +08:00
|
|
|
upload: true
|
|
|
|
|
);
|
2024-05-07 14:11:49 +08:00
|
|
|
state.ifAddState.value = false;
|
2023-12-13 11:54:34 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加指纹开始
|
|
|
|
|
Future<void> senderAddFingerprint() async {
|
2024-10-21 16:18:53 +08:00
|
|
|
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
|
|
|
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
|
|
|
|
|
|
|
|
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
|
|
|
|
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
|
|
|
|
|
|
|
|
|
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
|
|
|
|
final List<int> getTokenList = changeStringListToIntList(token!);
|
|
|
|
|
|
|
|
|
|
final String command = SenderAddFingerprintWithTimeCycleCoercionCommand(
|
|
|
|
|
keyID:'1',
|
|
|
|
|
userID:await Storage.getUid(),
|
|
|
|
|
fingerNo:0,
|
|
|
|
|
useCountLimit:0xffff,
|
|
|
|
|
isForce:state.isCoerced.value == '1' ? 1 : 0, // 是否是胁迫
|
|
|
|
|
isAdmin: state.isAdministrator.value == '2' ? 1 : 0,
|
|
|
|
|
operate: 0,
|
|
|
|
|
isRound:state.selectType.value == '2' ? 1: 0, // 是否是循环
|
|
|
|
|
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环
|
|
|
|
|
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,
|
|
|
|
|
).toString();
|
|
|
|
|
|
|
|
|
|
showBlueConnetctToastTimer(action: () async {
|
|
|
|
|
final String getMobile = (await Storage.getMobile())!;
|
|
|
|
|
UmengCommonSdk.onEvent('add_fingerprint', {
|
|
|
|
|
'lock_name':BlueManage().connectDeviceName,
|
|
|
|
|
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
|
|
|
|
'date':DateTool().getNowDateWithType(1),
|
|
|
|
|
'add_fingerprint_result':'超时',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
message: '添加指纹超时处理-添加指纹失败',
|
|
|
|
|
detail: '添加指纹超时处理,断开连接,添加指纹失败--SenderAddFingerprintWithTimeCycleCoercionCommand:$command',
|
2024-10-21 17:19:56 +08:00
|
|
|
eventStr: '添加指纹事件超时',
|
2024-10-21 16:18:53 +08:00
|
|
|
upload: true
|
|
|
|
|
);
|
2024-01-12 19:05:44 +08:00
|
|
|
Get.close(1);
|
|
|
|
|
});
|
2024-05-21 15:33:06 +08:00
|
|
|
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
2024-03-18 16:16:51 +08:00
|
|
|
if (deviceConnectionState == BluetoothConnectionState.connected){
|
2024-05-29 09:06:26 +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>? signKey = await Storage.getStringList(saveBlueSignKey);
|
|
|
|
|
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
2024-04-15 16:30:00 +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-15 16:30:00 +08:00
|
|
|
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
|
2024-05-29 09:06:26 +08:00
|
|
|
keyID:'1',
|
2023-12-13 11:54:34 +08:00
|
|
|
userID:await Storage.getUid(),
|
2024-05-04 16:53:27 +08:00
|
|
|
fingerNo:0,
|
|
|
|
|
useCountLimit:0xffff,
|
2024-05-30 09:27:29 +08:00
|
|
|
isForce:state.isCoerced.value == '1' ? 1 : 0, // 是否是胁迫
|
2024-05-29 09:06:26 +08:00
|
|
|
isAdmin: state.isAdministrator.value == '2' ? 1 : 0,
|
2024-05-04 16:53:27 +08:00
|
|
|
operate: 0,
|
2024-05-29 09:06:26 +08:00
|
|
|
isRound:state.selectType.value == '2' ? 1: 0, // 是否是循环
|
2024-04-22 11:16:37 +08:00
|
|
|
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环
|
2024-04-15 16:30:00 +08:00
|
|
|
startDate: int.parse(state.startDate.value)~/1000,
|
|
|
|
|
endDate: int.parse(state.endDate.value)~/1000,
|
2024-04-19 18:13:34 +08:00
|
|
|
startTime:DateTool().dateToHNString(state.effectiveDateTime.value),
|
|
|
|
|
endTime:DateTool().dateToHNString(state.failureDateTime.value),
|
2023-12-13 11:54:34 +08:00
|
|
|
needAuthor:1,
|
2024-04-15 16:30:00 +08:00
|
|
|
signKey:signKeyDataList,
|
2023-12-13 11:54:34 +08:00
|
|
|
privateKey:getPrivateKeyList,
|
|
|
|
|
token: getTokenList,
|
2024-05-29 09:06:26 +08:00
|
|
|
isBeforeAddUser: false
|
2023-12-13 11:54:34 +08:00
|
|
|
);
|
2024-03-18 16:16:51 +08:00
|
|
|
}else if (deviceConnectionState == BluetoothConnectionState.disconnected){
|
2024-10-21 16:18:53 +08:00
|
|
|
final String getMobile = (await Storage.getMobile())!;
|
|
|
|
|
UmengCommonSdk.onEvent('add_fingerprint', {
|
|
|
|
|
'lock_name':BlueManage().connectDeviceName,
|
|
|
|
|
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
|
|
|
|
'date':DateTool().getNowDateWithType(1),
|
|
|
|
|
'add_fingerprint_result':'断开',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
message: '添加指纹断开连接-添加指纹失败',
|
|
|
|
|
detail: '添加指纹断开连接-添加指纹失败--SenderAddFingerprintWithTimeCycleCoercionCommand:$command',
|
2024-10-21 17:19:56 +08:00
|
|
|
eventStr: '添加指纹事件断开连接',
|
2024-10-21 16:18:53 +08:00
|
|
|
upload: true
|
|
|
|
|
);
|
|
|
|
|
|
2024-01-12 19:05:44 +08:00
|
|
|
if(state.ifCurrentScreen.value == true){
|
|
|
|
|
showBlueConnetctToast();
|
|
|
|
|
}
|
|
|
|
|
cancelBlueConnetctToastTimer();
|
|
|
|
|
Get.close(1);
|
2023-12-13 11:54:34 +08:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-07 14:11:49 +08:00
|
|
|
// 取消添加指纹
|
|
|
|
|
Future<void> senderCancelAddFingerprintCommand() async {
|
2024-05-21 15:33:06 +08:00
|
|
|
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
2024-05-07 14:11:49 +08:00
|
|
|
if (deviceConnectionState == BluetoothConnectionState.connected){
|
2024-05-29 09:06:26 +08:00
|
|
|
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
|
|
|
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
2024-05-29 09:06:26 +08:00
|
|
|
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
|
|
|
|
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
2024-05-29 09:06:26 +08:00
|
|
|
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
|
|
|
|
final List<int> getTokenList = changeStringListToIntList(token!);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
|
|
|
|
IoSenderManage.senderCancelAddFingerprintCommand(
|
2024-05-29 09:06:26 +08:00
|
|
|
keyID:'1',
|
2024-05-07 14:11:49 +08:00
|
|
|
userID:await Storage.getUid(),
|
|
|
|
|
needAuthor:1,
|
|
|
|
|
signKey:signKeyDataList,
|
|
|
|
|
privateKey:getPrivateKeyList,
|
|
|
|
|
token: getTokenList,
|
|
|
|
|
);
|
|
|
|
|
}else if (deviceConnectionState == BluetoothConnectionState.disconnected){
|
|
|
|
|
if(state.ifCurrentScreen.value == true){
|
|
|
|
|
showBlueConnetctToast();
|
|
|
|
|
}
|
|
|
|
|
cancelBlueConnetctToastTimer();
|
|
|
|
|
Get.close(1);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
|
|
|
// 添加指纹
|
2024-05-29 09:06:26 +08:00
|
|
|
Future<void> addFingerprintsData() async{
|
|
|
|
|
final AddFingerprintEntity entity = await ApiRepository.to.addFingerprintsData(
|
2023-12-13 11:54:34 +08:00
|
|
|
lockId: state.lockId.value.toString(),
|
|
|
|
|
endDate: state.endDate.value,
|
|
|
|
|
addType:state.addType.value,
|
|
|
|
|
fingerprintName: state.fingerprintName.value,
|
2024-01-16 10:41:08 +08:00
|
|
|
fingerprintNumber: state.fingerprintNumber.value,
|
2023-12-13 11:54:34 +08:00
|
|
|
fingerprintType: state.fingerprintType.value,
|
|
|
|
|
isCoerced: state.isCoerced.value,
|
|
|
|
|
startDate: state.startDate.value,
|
|
|
|
|
weekDay: state.weekDay.value,
|
2024-05-29 09:06:26 +08:00
|
|
|
fingerRight:state.isAdministrator.value == '2' ? 1 : 0,
|
2024-03-25 15:03:02 +08:00
|
|
|
startTime: int.parse(state.effectiveDateTime.value),
|
|
|
|
|
endTime: int.parse(state.failureDateTime.value),
|
2023-12-13 11:54:34 +08:00
|
|
|
);
|
|
|
|
|
if(entity.errorCode!.codeIsSuccessful){
|
2024-01-16 10:41:08 +08:00
|
|
|
updateFingerprintUserNoLoadData(entity.data!.fingerprintId.toString());
|
2024-10-21 16:18:53 +08:00
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
message: '添加指纹调用接口成功',
|
2024-10-21 17:19:56 +08:00
|
|
|
detail: '添加指纹调用接口成功',
|
|
|
|
|
eventStr: '添加指纹事件用接口成功',
|
2024-10-21 16:18:53 +08:00
|
|
|
upload: true
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
updateFingerprintUserNoLoadData(entity.data!.fingerprintId.toString());
|
|
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
message: '添加指纹调用接口失败',
|
|
|
|
|
detail: '添加指纹调用接口添加指纹调用接口失败 - ${entity.errorMsg}',
|
2024-10-21 17:19:56 +08:00
|
|
|
eventStr: '添加指纹事件接口失败',
|
2024-10-21 16:18:53 +08:00
|
|
|
upload: true
|
|
|
|
|
);
|
2023-12-13 11:54:34 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新指纹用户账号
|
2024-05-29 09:06:26 +08:00
|
|
|
Future<void> updateFingerprintUserNoLoadData(String fingerprintId) async{
|
|
|
|
|
final LoginEntity entity = await ApiRepository.to.updateFingerprintUserNoLoadData(
|
2023-12-13 11:54:34 +08:00
|
|
|
fingerprintId: fingerprintId,
|
|
|
|
|
lockId: state.lockId.value.toString(),
|
2024-01-16 10:41:08 +08:00
|
|
|
fingerprintUserNo: state.fingerprintNumber.value,
|
2023-12-13 11:54:34 +08:00
|
|
|
);
|
|
|
|
|
if(entity.errorCode!.codeIsSuccessful){
|
2024-05-29 09:06:26 +08:00
|
|
|
showToast('添加成功'.tr, something: (){
|
2024-04-10 15:59:44 +08:00
|
|
|
if(state.fromType.value == 2){
|
|
|
|
|
// 回调指纹号
|
|
|
|
|
eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(state.fingerprintNumber.value));
|
|
|
|
|
}else if(state.fromType.value == 1){
|
|
|
|
|
eventBus.fire(OtherTypeRefreshListEvent());
|
|
|
|
|
}
|
|
|
|
|
Get.close(2);
|
|
|
|
|
});
|
2023-12-13 11:54:34 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onReady() {
|
|
|
|
|
super.onReady();
|
|
|
|
|
|
|
|
|
|
_initReplySubscription();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onInit() {
|
|
|
|
|
super.onInit();
|
|
|
|
|
|
|
|
|
|
senderAddFingerprint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onClose() {
|
|
|
|
|
super.onClose();
|
|
|
|
|
|
|
|
|
|
_replySubscription.cancel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|