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-04-26 15:38:59 +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';
|
2024-10-19 18:26:41 +08:00
|
|
|
|
import 'package:umeng_common_sdk/umeng_common_sdk.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';
|
|
|
|
|
|
|
|
|
|
|
|
class AddICCardLogic extends BaseGetXController{
|
|
|
|
|
|
AddICCardState state = AddICCardState();
|
|
|
|
|
|
|
|
|
|
|
|
// 监听设备返回的数据
|
|
|
|
|
|
late StreamSubscription<Reply> _replySubscription;
|
|
|
|
|
|
void _initReplySubscription() {
|
2024-05-24 10:59:48 +08:00
|
|
|
|
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
// 添加IC卡开始
|
2024-04-16 17:44:38 +08:00
|
|
|
|
if((reply is SenderAddICCardWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) {
|
2023-12-13 11:54:34 +08:00
|
|
|
|
_replyAddICCardBegin(reply);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 添加卡确认
|
|
|
|
|
|
if(reply is SenderAddICCardConfirmationReply) {
|
|
|
|
|
|
_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}',
|
|
|
|
|
|
upload: false
|
|
|
|
|
|
);
|
2023-12-13 11:54:34 +08:00
|
|
|
|
|
|
|
|
|
|
switch(status){
|
|
|
|
|
|
case 0x00:
|
2024-04-09 15:21:10 +08:00
|
|
|
|
//成功
|
2024-05-24 10:59:48 +08:00
|
|
|
|
final List<int> cardNumberList = reply.data.sublist(reply.data.length - 2);
|
|
|
|
|
|
final String cardNumber = listChangInt(cardNumberList).toString();
|
2024-05-04 16:53:27 +08:00
|
|
|
|
// AppLog.log("添加卡号:$cardNumberList cardNumber:$cardNumber");
|
2024-05-03 18:31:15 +08:00
|
|
|
|
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
|
|
|
|
//无权限
|
2024-05-24 10:59:48 +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-24 10:59:48 +08:00
|
|
|
|
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
|
|
|
|
|
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);
|
2024-08-21 14:12:15 +08:00
|
|
|
|
// AppLog.log('添加卡token:$token');
|
2023-12-16 11:20:36 +08:00
|
|
|
|
|
2024-04-16 17:44:38 +08:00
|
|
|
|
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
|
2024-05-24 10:59:48 +08:00
|
|
|
|
keyID:'1',
|
2023-12-13 11:54:34 +08:00
|
|
|
|
userID:await Storage.getUid(),
|
2024-05-04 16:53:27 +08:00
|
|
|
|
cardNo:0,
|
|
|
|
|
|
useCountLimit:0xffff,
|
|
|
|
|
|
operate:0, // 0:注册 1:修改 2:删除 3:删除全部
|
2024-05-24 10:59:48 +08:00
|
|
|
|
isAdmin:state.isAdministrator.value == '2' ? 1 : 0,
|
2024-05-29 14:31:38 +08:00
|
|
|
|
isForce:state.isCoerced.value == '1' ? 1 : 0, // 是否是胁迫
|
2024-05-24 10:59:48 +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-16 17:44:38 +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: token,
|
2024-05-29 09:06:26 +08:00
|
|
|
|
isBeforeAddUser: false
|
2023-12-13 11:54:34 +08:00
|
|
|
|
);
|
|
|
|
|
|
break;
|
|
|
|
|
|
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: '添加卡事件结果',
|
2024-10-21 16:18:53 +08:00
|
|
|
|
upload: true
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2024-10-19 18:26:41 +08:00
|
|
|
|
final String getMobile = (await Storage.getMobile())!;
|
2023-12-13 11:54:34 +08:00
|
|
|
|
switch(status){
|
|
|
|
|
|
case 0x00:
|
2024-04-09 15:21:10 +08:00
|
|
|
|
//成功
|
2024-10-19 18:26:41 +08:00
|
|
|
|
UmengCommonSdk.onEvent('add_card', {
|
|
|
|
|
|
'lock_name':BlueManage().connectDeviceName,
|
|
|
|
|
|
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
|
|
|
|
|
'date':DateTool().getNowDateWithType(1),
|
|
|
|
|
|
'add_card_result':'成功',
|
|
|
|
|
|
});
|
2024-05-07 14:11:49 +08:00
|
|
|
|
switch(reply.data[5]){
|
|
|
|
|
|
case 0xff:
|
|
|
|
|
|
// 注册指纹失败
|
2024-05-24 10:59:48 +08:00
|
|
|
|
showToast('退出添加'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
Get.close(1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 0xFE:
|
|
|
|
|
|
// 管理员已满
|
2024-05-24 10:59:48 +08:00
|
|
|
|
showToast('管理员已满'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
Get.close(1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 0xFD:
|
|
|
|
|
|
// 用户已满
|
2024-05-24 10:59:48 +08:00
|
|
|
|
showToast('用户已满'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
Get.close(1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 0xFC:
|
|
|
|
|
|
// 指纹已满
|
2024-05-24 10:59:48 +08:00
|
|
|
|
showToast('锁上面添加卡已满'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
Get.close(1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 0xFB:
|
|
|
|
|
|
// 指纹已存在
|
2024-05-24 10:59:48 +08:00
|
|
|
|
showToast('卡已存在'.tr);
|
2024-05-07 14:11:49 +08:00
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
// 添加指纹中
|
|
|
|
|
|
// 当前注册数
|
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
|
|
|
|
//失败
|
2024-10-19 18:26:41 +08:00
|
|
|
|
UmengCommonSdk.onEvent('add_card', {
|
|
|
|
|
|
'lock_name':BlueManage().connectDeviceName,
|
|
|
|
|
|
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
|
|
|
|
|
'date':DateTool().getNowDateWithType(1),
|
|
|
|
|
|
'add_card_result':reply.data[2],
|
|
|
|
|
|
});
|
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!);
|
|
|
|
|
|
|
|
|
|
|
|
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 String command = SenderAddICCardWithTimeCycleCoercionCommand(
|
|
|
|
|
|
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,
|
|
|
|
|
|
).toString();
|
|
|
|
|
|
|
|
|
|
|
|
showBlueConnetctToastTimer(action: () async {
|
|
|
|
|
|
final String getMobile = (await Storage.getMobile())!;
|
|
|
|
|
|
UmengCommonSdk.onEvent('add_card', {
|
|
|
|
|
|
'lock_name':BlueManage().connectDeviceName,
|
|
|
|
|
|
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
|
|
|
|
|
'date':DateTool().getNowDateWithType(1),
|
|
|
|
|
|
'add_card_result':'添加卡超时',
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
|
message: '添加卡超时处理-添加卡失败',
|
|
|
|
|
|
detail: '添加卡超时处理,断开连接,添加卡失败--SenderAddICCardWithTimeCycleCoercionCommand:$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-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(
|
2024-05-24 10:59:48 +08:00
|
|
|
|
keyID:'1',
|
2023-12-13 11:54:34 +08:00
|
|
|
|
userID:await Storage.getUid(),
|
2024-05-04 16:53:27 +08:00
|
|
|
|
cardNo:0,
|
|
|
|
|
|
useCountLimit:0xffff,
|
|
|
|
|
|
operate:0, // 0:注册 1:修改 2:删除 3:删除全部
|
2024-05-24 10:59:48 +08:00
|
|
|
|
isAdmin:state.isAdministrator.value == '2' ? 1 : 0,
|
2024-05-29 14:31:38 +08:00
|
|
|
|
isForce:state.isCoerced.value == '1' ? 1 : 0, // 是否是胁迫
|
2024-05-24 10:59:48 +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_card', {
|
|
|
|
|
|
'lock_name':BlueManage().connectDeviceName,
|
|
|
|
|
|
'account':getMobile.isNotEmpty ? getMobile : (await Storage.getEmail())!,
|
|
|
|
|
|
'date':DateTool().getNowDateWithType(1),
|
|
|
|
|
|
'add_card_result':'添加卡断开连接',
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
BuglyTool.uploadException(
|
|
|
|
|
|
message: '添加卡超时处理-添加卡失败',
|
|
|
|
|
|
detail: '添加卡超时处理,断开连接,添加卡失败--SenderAddICCardWithTimeCycleCoercionCommand:$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> senderCancelAddCardCommand() 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-24 10:59:48 +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-24 10:59:48 +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-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(
|
2024-05-24 10:59:48 +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-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());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-24 10:59:48 +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,
|
|
|
|
|
|
);
|
|
|
|
|
|
if(entity.errorCode!.codeIsSuccessful){
|
2024-05-24 10:59:48 +08:00
|
|
|
|
showToast('添加成功'.tr, something:(){
|
2024-04-11 17:06:06 +08:00
|
|
|
|
if(state.fromType.value == 2){
|
|
|
|
|
|
// 回调指纹号
|
|
|
|
|
|
eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(state.cardNumber.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();
|
|
|
|
|
|
|
|
|
|
|
|
senderAddICCard();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
void onClose() {
|
|
|
|
|
|
_replySubscription.cancel();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|