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';
|
2025-02-05 17:56:57 +08:00
|
|
|
|
import 'package:star_lock/app_settings/app_settings.dart';
|
2024-05-24 10:59:48 +08:00
|
|
|
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
|
|
|
|
|
import 'package:star_lock/main/lockDetail/card/addICCard/addICCard_entity.dart';
|
2023-12-13 11:54:34 +08:00
|
|
|
|
import 'package:star_lock/tools/baseGetXController.dart';
|
|
|
|
|
|
|
2025-01-10 19:19:17 +08:00
|
|
|
|
import '../../../../apm/apm_helper.dart';
|
2023-12-13 11:54:34 +08:00
|
|
|
|
import '../../../../blue/blue_manage.dart';
|
2024-04-15 16:30:00 +08:00
|
|
|
|
import '../../../../blue/io_protocol/io_addICCardWithTimeCycleCoercion.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-10-21 16:18:53 +08:00
|
|
|
|
import '../../../../tools/bugly/bugly_tool.dart';
|
2024-04-19 18:13:34 +08:00
|
|
|
|
import '../../../../tools/dateTool.dart';
|
2023-12-13 11:54:34 +08:00
|
|
|
|
import '../../../../tools/eventBusEventManage.dart';
|
|
|
|
|
|
import '../../../../tools/storage.dart';
|
|
|
|
|
|
import 'addICCard_state.dart';
|
|
|
|
|
|
|
2025-01-10 19:19:17 +08:00
|
|
|
|
class AddICCardLogic extends BaseGetXController {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
AddICCardState state = AddICCardState();
|
|
|
|
|
|
|
|
|
|
|
|
// 监听设备返回的数据
|
|
|
|
|
|
late StreamSubscription<Reply> _replySubscription;
|
2025-01-10 19:19:17 +08:00
|
|
|
|
|
2023-12-13 11:54:34 +08:00
|
|
|
|
void _initReplySubscription() {
|
2025-01-10 19:19:17 +08:00
|
|
|
|
_replySubscription =
|
|
|
|
|
|
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
// 添加IC卡开始
|
2025-01-10 19:19:17 +08:00
|
|
|
|
if ((reply is SenderAddICCardWithTimeCycleCoercionReply) &&
|
|
|
|
|
|
(state.ifCurrentScreen.value == true)) {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
_replyAddICCardBegin(reply);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 添加卡确认
|
2025-01-10 19:19:17 +08:00
|
|
|
|
if (reply is SenderAddICCardConfirmationReply) {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
_replyAddICCardConfirmation(reply);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> _replyAddICCardBegin(Reply reply) async {
|
2024-05-24 10:59:48 +08:00
|
|
|
|
final int status = reply.data[2];
|
2024-10-21 16:18:53 +08:00
|
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
|
message: '添加卡开始,解析数据',
|
|
|
|
|
|
detail: '添加卡开始,解析数据 _replyAddICCardBegin:${reply.data}',
|
2025-01-10 19:19:17 +08:00
|
|
|
|
upload: false);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
2025-01-10 19:19:17 +08:00
|
|
|
|
switch (status) {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
case 0x00:
|
2024-04-09 15:21:10 +08:00
|
|
|
|
//成功
|
2025-02-05 17:56:57 +08:00
|
|
|
|
// final List<int> cardNumberList =
|
|
|
|
|
|
// reply.data.sublist(reply.data.length - 2);
|
|
|
|
|
|
// final String cardNumber = listChangInt(cardNumberList).toString();
|
|
|
|
|
|
// // AppLog.log("添加卡号:$cardNumberList cardNumber:$cardNumber");
|
|
|
|
|
|
// state.cardNumber.value = cardNumber.toString();
|
2024-01-18 11:25:56 +08:00
|
|
|
|
cancelBlueConnetctToastTimer();
|
2024-05-07 14:11:49 +08:00
|
|
|
|
|
|
|
|
|
|
state.ifAddState.value = true;
|
2023-12-13 11:54:34 +08:00
|
|
|
|
state.ifConnectScuess.value = true;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 0x06:
|
2024-04-09 15:21:10 +08:00
|
|
|
|
//无权限
|
2025-01-10 19:19:17 +08:00
|
|
|
|
final List<String>? privateKey =
|
|
|
|
|
|
await Storage.getStringList(saveBluePrivateKey);
|
|
|
|
|
|
final List<int> getPrivateKeyList =
|
|
|
|
|
|
changeStringListToIntList(privateKey!);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
2025-01-10 19:19:17 +08:00
|
|
|
|
final List<String>? signKey =
|
|
|
|
|
|
await Storage.getStringList(saveBlueSignKey);
|
2024-05-24 10:59:48 +08:00
|
|
|
|
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
2024-04-15 16:30:00 +08:00
|
|
|
|
|
|
|
|
|
|
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
|
|
|
|
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
2024-05-24 10:59:48 +08:00
|
|
|
|
final List<int> token = reply.data.sublist(5, 9);
|
|
|
|
|
|
final List<String> saveStrList = changeIntListToStringList(token);
|
2023-12-16 11:20:36 +08:00
|
|
|
|
Storage.setStringList(saveBlueToken, saveStrList);
|
2025-04-15 16:01:16 +08:00
|
|
|
|
AppLog.log('添加卡token:$token');
|
2023-12-16 11:20:36 +08:00
|
|
|
|
|
2024-04-16 17:44:38 +08:00
|
|
|
|
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
|
2025-01-10 19:19:17 +08:00
|
|
|
|
keyID: '1',
|
|
|
|
|
|
userID: await Storage.getUid(),
|
|
|
|
|
|
cardNo: 0,
|
|
|
|
|
|
useCountLimit: 0xffff,
|
|
|
|
|
|
operate: 0,
|
|
|
|
|
|
// 0:注册 1:修改 2:删除 3:删除全部
|
|
|
|
|
|
isAdmin: state.isAdministrator.value == '2' ? 1 : 0,
|
|
|
|
|
|
isForce: state.isCoerced.value == '1' ? 1 : 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: token,
|
|
|
|
|
|
isBeforeAddUser: false);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
break;
|
2025-04-15 16:01:16 +08:00
|
|
|
|
case 0xFE:
|
|
|
|
|
|
case 12:
|
|
|
|
|
|
// 管理员已满
|
|
|
|
|
|
state.ifAddState.value = false;
|
|
|
|
|
|
showToast('管理员已满'.tr, something: () {
|
|
|
|
|
|
Get.back();
|
|
|
|
|
|
});
|
|
|
|
|
|
break;
|
2023-12-13 11:54:34 +08:00
|
|
|
|
default:
|
2024-04-09 15:21:10 +08:00
|
|
|
|
//失败
|
2024-05-07 14:11:49 +08:00
|
|
|
|
state.ifAddState.value = false;
|
2023-12-13 11:54:34 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> _replyAddICCardConfirmation(Reply reply) async {
|
2024-05-24 10:59:48 +08:00
|
|
|
|
final int status = reply.data[2];
|
2024-05-07 14:11:49 +08:00
|
|
|
|
state.ifAddState.value = false;
|
2024-10-21 16:18:53 +08:00
|
|
|
|
|
|
|
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
|
message: '添加卡结果,解析数据',
|
|
|
|
|
|
detail: '添加卡结果,解析数据 _replyAddICCardConfirmation:${reply.data}',
|
2024-10-21 17:19:56 +08:00
|
|
|
|
eventStr: '添加卡事件结果',
|
2025-01-10 19:19:17 +08:00
|
|
|
|
upload: true);
|
2024-10-21 16:18:53 +08:00
|
|
|
|
|
2024-10-19 18:26:41 +08:00
|
|
|
|
final String getMobile = (await Storage.getMobile())!;
|
2025-01-10 19:19:17 +08:00
|
|
|
|
switch (status) {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
case 0x00:
|
2024-04-09 15:21:10 +08:00
|
|
|
|
//成功
|
2025-01-10 19:19:17 +08:00
|
|
|
|
ApmHelper.instance.trackEvent('add_card', {
|
|
|
|
|
|
'lock_name': BlueManage().connectDeviceName,
|
|
|
|
|
|
'account':
|
|
|
|
|
|
getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
|
|
|
|
|
'date': DateTool().getNowDateWithType(1),
|
|
|
|
|
|
'add_card_result': '成功',
|
2024-10-19 18:26:41 +08:00
|
|
|
|
});
|
2025-02-05 17:56:57 +08:00
|
|
|
|
AppLog.log('data:${reply.data}');
|
|
|
|
|
|
final List<int> cardNumberList = reply.data.sublist(6, 8);
|
|
|
|
|
|
final String cardNumber = listChangInt(cardNumberList).toString();
|
|
|
|
|
|
state.cardNumber.value = cardNumber.toString();
|
2025-01-10 19:19:17 +08:00
|
|
|
|
switch (reply.data[5]) {
|
2024-05-07 14:11:49 +08:00
|
|
|
|
case 0xff:
|
2025-01-10 19:19:17 +08:00
|
|
|
|
// 注册指纹失败
|
2024-05-24 10:59:48 +08:00
|
|
|
|
showToast('退出添加'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
Get.close(1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 0xFE:
|
2025-04-15 16:01:16 +08:00
|
|
|
|
case 0x12:
|
2025-01-10 19:19:17 +08:00
|
|
|
|
// 管理员已满
|
2024-05-24 10:59:48 +08:00
|
|
|
|
showToast('管理员已满'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
Get.close(1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 0xFD:
|
2025-01-10 19:19:17 +08:00
|
|
|
|
// 用户已满
|
2024-05-24 10:59:48 +08:00
|
|
|
|
showToast('用户已满'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
Get.close(1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 0xFC:
|
2025-01-10 19:19:17 +08:00
|
|
|
|
// 指纹已满
|
2024-05-24 10:59:48 +08:00
|
|
|
|
showToast('锁上面添加卡已满'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
Get.close(1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 0xFB:
|
2025-01-10 19:19:17 +08:00
|
|
|
|
// 指纹已存在
|
2024-05-24 10:59:48 +08:00
|
|
|
|
showToast('卡已存在'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
break;
|
|
|
|
|
|
default:
|
2025-01-10 19:19:17 +08:00
|
|
|
|
// 添加指纹中
|
|
|
|
|
|
// 当前注册数
|
2023-12-13 11:54:34 +08:00
|
|
|
|
addICCardData();
|
2024-05-07 14:11:49 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2023-12-13 11:54:34 +08:00
|
|
|
|
break;
|
|
|
|
|
|
default:
|
2024-04-09 15:21:10 +08:00
|
|
|
|
//失败
|
2025-01-10 19:19:17 +08:00
|
|
|
|
ApmHelper.instance.trackEvent('add_card', {
|
|
|
|
|
|
'lock_name': BlueManage().connectDeviceName,
|
|
|
|
|
|
'account':
|
|
|
|
|
|
getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
|
|
|
|
|
'date': DateTool().getNowDateWithType(1),
|
|
|
|
|
|
'add_card_result': reply.data[2],
|
2024-10-19 18:26:41 +08:00
|
|
|
|
});
|
2023-12-13 11:54:34 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-16 11:20:36 +08:00
|
|
|
|
// 添加卡片
|
2023-12-13 11:54:34 +08:00
|
|
|
|
Future<void> senderAddICCard() async {
|
2024-10-21 16:18:53 +08:00
|
|
|
|
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
|
|
|
|
|
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
|
|
|
|
|
|
2025-01-10 19:19:17 +08:00
|
|
|
|
final List<String>? privateKey =
|
|
|
|
|
|
await Storage.getStringList(saveBluePrivateKey);
|
2024-10-21 16:18:53 +08:00
|
|
|
|
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
|
|
|
|
|
|
|
|
|
|
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
|
|
|
|
|
final List<int> getTokenList = changeStringListToIntList(token!);
|
|
|
|
|
|
|
|
|
|
|
|
final String command = SenderAddICCardWithTimeCycleCoercionCommand(
|
2025-01-10 19:19:17 +08:00
|
|
|
|
keyID: '1',
|
|
|
|
|
|
userID: await Storage.getUid(),
|
|
|
|
|
|
cardNo: 0,
|
|
|
|
|
|
useCountLimit: 0xffff,
|
|
|
|
|
|
operate: 0,
|
|
|
|
|
|
// 0:注册 1:修改 2:删除 3:删除全部
|
|
|
|
|
|
isAdmin: state.isAdministrator.value == '2' ? 1 : 0,
|
|
|
|
|
|
isForce: state.isCoerced.value == '1' ? 1 : 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,
|
2024-10-21 16:18:53 +08:00
|
|
|
|
).toString();
|
|
|
|
|
|
|
|
|
|
|
|
showBlueConnetctToastTimer(action: () async {
|
|
|
|
|
|
final String getMobile = (await Storage.getMobile())!;
|
2025-01-10 19:19:17 +08:00
|
|
|
|
ApmHelper.instance.trackEvent('add_card', {
|
|
|
|
|
|
'lock_name': BlueManage().connectDeviceName,
|
|
|
|
|
|
'account':
|
|
|
|
|
|
getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
|
|
|
|
|
'date': DateTool().getNowDateWithType(1),
|
|
|
|
|
|
'add_card_result': '添加卡超时',
|
2024-10-21 16:18:53 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
|
message: '添加卡超时处理-添加卡失败',
|
2025-01-10 19:19:17 +08:00
|
|
|
|
detail:
|
|
|
|
|
|
'添加卡超时处理,断开连接,添加卡失败--SenderAddICCardWithTimeCycleCoercionCommand:$command',
|
2024-10-21 17:19:56 +08:00
|
|
|
|
eventStr: '添加卡事件超时',
|
2025-01-10 19:19:17 +08:00
|
|
|
|
upload: true);
|
2024-10-21 16:18:53 +08:00
|
|
|
|
|
2024-01-12 19:05:44 +08:00
|
|
|
|
Get.close(1);
|
|
|
|
|
|
});
|
2025-01-10 19:19:17 +08:00
|
|
|
|
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
|
|
|
|
|
(BluetoothConnectionState deviceConnectionState) async {
|
|
|
|
|
|
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
2024-01-12 19:05:44 +08:00
|
|
|
|
cancelBlueConnetctToastTimer();
|
2024-04-15 16:30:00 +08:00
|
|
|
|
|
2024-04-16 17:44:38 +08:00
|
|
|
|
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
|
2025-01-10 19:19:17 +08:00
|
|
|
|
keyID: '1',
|
|
|
|
|
|
userID: await Storage.getUid(),
|
|
|
|
|
|
cardNo: 0,
|
|
|
|
|
|
useCountLimit: 0xffff,
|
|
|
|
|
|
operate: 0,
|
|
|
|
|
|
// 0:注册 1:修改 2:删除 3:删除全部
|
|
|
|
|
|
isAdmin: state.isAdministrator.value == '2' ? 1 : 0,
|
|
|
|
|
|
isForce: state.isCoerced.value == '1' ? 1 : 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,
|
|
|
|
|
|
isBeforeAddUser: false);
|
|
|
|
|
|
} else if (deviceConnectionState ==
|
|
|
|
|
|
BluetoothConnectionState.disconnected) {
|
2024-10-21 16:18:53 +08:00
|
|
|
|
final String getMobile = (await Storage.getMobile())!;
|
2025-01-10 19:19:17 +08:00
|
|
|
|
ApmHelper.instance.trackEvent('add_card', {
|
|
|
|
|
|
'lock_name': BlueManage().connectDeviceName,
|
|
|
|
|
|
'account':
|
|
|
|
|
|
getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
|
|
|
|
|
'date': DateTool().getNowDateWithType(1),
|
|
|
|
|
|
'add_card_result': '添加卡断开连接',
|
2024-10-21 16:18:53 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
|
message: '添加卡超时处理-添加卡失败',
|
2025-01-10 19:19:17 +08:00
|
|
|
|
detail:
|
|
|
|
|
|
'添加卡超时处理,断开连接,添加卡失败--SenderAddICCardWithTimeCycleCoercionCommand:$command',
|
2024-10-21 17:19:56 +08:00
|
|
|
|
eventStr: '添加卡事件断开连接',
|
2025-01-10 19:19:17 +08:00
|
|
|
|
upload: true);
|
2024-10-21 16:18:53 +08:00
|
|
|
|
|
2025-01-10 19:19:17 +08:00
|
|
|
|
if (state.ifCurrentScreen.value == true) {
|
2024-01-12 19:05:44 +08:00
|
|
|
|
showBlueConnetctToast();
|
|
|
|
|
|
}
|
|
|
|
|
|
cancelBlueConnetctToastTimer();
|
|
|
|
|
|
Get.close(1);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-07 14:11:49 +08:00
|
|
|
|
// 取消添加指纹
|
|
|
|
|
|
Future<void> senderCancelAddCardCommand() async {
|
2025-01-10 19:19:17 +08:00
|
|
|
|
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
|
|
|
|
|
(BluetoothConnectionState deviceConnectionState) async {
|
|
|
|
|
|
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
|
|
|
|
|
final List<String>? privateKey =
|
|
|
|
|
|
await Storage.getStringList(saveBluePrivateKey);
|
|
|
|
|
|
final List<int> getPrivateKeyList =
|
|
|
|
|
|
changeStringListToIntList(privateKey!);
|
|
|
|
|
|
|
|
|
|
|
|
final List<String>? signKey =
|
|
|
|
|
|
await Storage.getStringList(saveBlueSignKey);
|
2024-05-24 10:59:48 +08:00
|
|
|
|
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
|
2024-05-24 10:59:48 +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.senderCancelAddCardCommand(
|
2025-01-10 19:19:17 +08:00
|
|
|
|
keyID: '1',
|
|
|
|
|
|
userID: await Storage.getUid(),
|
|
|
|
|
|
needAuthor: 1,
|
|
|
|
|
|
signKey: signKeyDataList,
|
|
|
|
|
|
privateKey: getPrivateKeyList,
|
2024-05-07 14:11:49 +08:00
|
|
|
|
token: getTokenList,
|
|
|
|
|
|
);
|
2025-01-10 19:19:17 +08:00
|
|
|
|
} else if (deviceConnectionState ==
|
|
|
|
|
|
BluetoothConnectionState.disconnected) {
|
|
|
|
|
|
if (state.ifCurrentScreen.value == true) {
|
2024-05-07 14:11:49 +08:00
|
|
|
|
showBlueConnetctToast();
|
|
|
|
|
|
}
|
|
|
|
|
|
cancelBlueConnetctToastTimer();
|
|
|
|
|
|
Get.close(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
2024-05-24 10:59:48 +08:00
|
|
|
|
Future<void> addICCardData() async {
|
|
|
|
|
|
final AddICCardEntity entity = await ApiRepository.to.addICCardData(
|
2023-12-13 11:54:34 +08:00
|
|
|
|
lockId: state.lockId.value.toString(),
|
2024-03-25 15:03:02 +08:00
|
|
|
|
endDate: state.endDate.value,
|
2023-12-13 11:54:34 +08:00
|
|
|
|
cardName: state.cardName.value.toString(),
|
|
|
|
|
|
cardNumber: state.cardNumber.value.toString(),
|
2024-03-25 15:03:02 +08:00
|
|
|
|
cardType: int.parse(state.cardType.value),
|
2023-12-13 11:54:34 +08:00
|
|
|
|
addType: state.addType.value.toString(),
|
2024-03-25 15:03:02 +08:00
|
|
|
|
startDate: state.startDate.value,
|
2023-12-13 11:54:34 +08:00
|
|
|
|
isCoerced: state.isCoerced.value.toString(),
|
|
|
|
|
|
weekDay: state.weekDay.value,
|
2024-04-09 15:21:10 +08:00
|
|
|
|
startTime: int.parse(state.effectiveDateTime.value),
|
|
|
|
|
|
endTime: int.parse(state.failureDateTime.value),
|
2024-05-24 10:59:48 +08:00
|
|
|
|
cardRight: state.isAdministrator.value == '2' ? 1 : 0,
|
2023-12-13 11:54:34 +08:00
|
|
|
|
);
|
|
|
|
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
|
|
|
|
updateIdCardUserNoLoadData(entity.data!.cardId.toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-10 19:19:17 +08:00
|
|
|
|
Future<void> updateIdCardUserNoLoadData(String cardId) async {
|
|
|
|
|
|
final LoginEntity entity =
|
|
|
|
|
|
await ApiRepository.to.updateIdCardUserNoLoadData(
|
2023-12-13 11:54:34 +08:00
|
|
|
|
lockId: state.lockId.value.toString(),
|
|
|
|
|
|
cardId: cardId,
|
|
|
|
|
|
cardUserNo: state.cardNumber.value,
|
|
|
|
|
|
);
|
2025-01-10 19:19:17 +08:00
|
|
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
|
|
|
|
showToast('添加成功'.tr, something: () {
|
|
|
|
|
|
if (state.fromType.value == 2) {
|
2024-04-11 17:06:06 +08:00
|
|
|
|
// 回调指纹号
|
2025-01-10 19:19:17 +08:00
|
|
|
|
eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(
|
|
|
|
|
|
state.cardNumber.value));
|
|
|
|
|
|
} else if (state.fromType.value == 1) {
|
2024-04-11 17:06:06 +08:00
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
|
senderAddICCard();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
void onClose() {
|
|
|
|
|
|
_replySubscription.cancel();
|
|
|
|
|
|
}
|
2025-01-10 19:19:17 +08:00
|
|
|
|
}
|