Merge branch 'master' of https://gitee.com/weishaoyang/star_lock
This commit is contained in:
commit
8385d6470b
@ -69,6 +69,7 @@ import 'main/lockDetail/lcokSet/wirelessKeyboard/seletWirelessKeyboard/seletWire
|
||||
import 'main/lockDetail/lcokSet/wirelessKeyboard/wirelessKeyboardList/wirelessKeyboard_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/addFingerprint/addFingerprint/addFingerprint_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/addFingerprint/addFingerprintTip/addFingerprintTip_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/addICCard/addICCard_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart';
|
||||
import 'main/lockDetail/otherTypeKey/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart';
|
||||
import 'mine/about/about_page.dart';
|
||||
@ -167,6 +168,7 @@ abstract class Routers {
|
||||
|
||||
static const addFingerprintTipPage = '/AddFingerprintTipPage'; // 添加指纹提示
|
||||
static const addFingerprintPage = '/AddFingerprintPage'; // 添加指纹
|
||||
static const addICCardPage = '/AddICCardPage'; // 添加卡
|
||||
|
||||
static const authorizedAdminListPage = '/AuthorizedAdminListPage'; // 授权管理员列表
|
||||
static const authorizedAdminDetailPage =
|
||||
@ -786,6 +788,9 @@ abstract class AppRouters {
|
||||
page: () => const OtherTypeKeyChangeDatePage()),
|
||||
GetPage(
|
||||
name: Routers.otherTypeKeyChangeValidityDatePage,
|
||||
page: () => const OtherTypeKeyChangeValidityDatePage())
|
||||
page: () => const OtherTypeKeyChangeValidityDatePage()),
|
||||
GetPage(
|
||||
name: Routers.addICCardPage,
|
||||
page: () => const AddICCardPage())
|
||||
];
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ import '../io_sender.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
//TODO:设置自定义密码
|
||||
///TODO:添加指纹
|
||||
/*
|
||||
备注:
|
||||
删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
||||
|
||||
147
star_lock/lib/blue/io_protocol/io_addICCard.dart
Normal file
147
star_lock/lib/blue/io_protocol/io_addICCard.dart
Normal file
@ -0,0 +1,147 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
|
||||
///TODO:设置自定义密码
|
||||
/*
|
||||
备注:
|
||||
删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
||||
**/
|
||||
class SenderAddICCardCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? cardNo;
|
||||
int? useCountLimit;
|
||||
List<int>? token;
|
||||
int? startTime;
|
||||
int? endTime;
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
SenderAddICCardCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.cardNo,
|
||||
this.useCountLimit,
|
||||
this.token,
|
||||
this.startTime,
|
||||
this.endTime,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
List<int> subData = [];
|
||||
List<int> ebcData = [];
|
||||
|
||||
// 指令类型
|
||||
int type = commandType!.typeValue;
|
||||
double typeDouble = type / 256;
|
||||
int type1 = typeDouble.toInt();
|
||||
int type2 = type % 256;
|
||||
data.add(type1);
|
||||
data.add(type2);
|
||||
|
||||
// 子命令类型
|
||||
data.add(21);
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
// print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}");
|
||||
subData.addAll(utf8.encode(keyID!));
|
||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||
|
||||
//userID 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
// print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}");
|
||||
subData.addAll(utf8.encode(userID!));
|
||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||
|
||||
// PwdNo
|
||||
subData.add(cardNo!);
|
||||
|
||||
// UseCountLimit
|
||||
subData.add(0xff);
|
||||
|
||||
// token
|
||||
subData.addAll(token!);
|
||||
|
||||
// startTime 4
|
||||
subData.add((startTime! & 0xff000000) >> 24);
|
||||
subData.add((startTime! & 0xff0000) >> 16);
|
||||
subData.add((startTime! & 0xff00) >> 8);
|
||||
subData.add((startTime! & 0xff));
|
||||
|
||||
// endTime 4
|
||||
subData.add((endTime! & 0xff000000) >> 24);
|
||||
subData.add((endTime! & 0xff0000) >> 16);
|
||||
subData.add((endTime! & 0xff00) >> 8);
|
||||
subData.add((endTime! & 0xff));
|
||||
|
||||
if(needAuthor == 0){
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
|
||||
print("${commandType!.typeValue}-authCodeData:$authCodeData");
|
||||
|
||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||
var authCode = crypto.md5.convert(authCodeData);
|
||||
|
||||
subData.add(authCode.bytes.length);
|
||||
subData.addAll(authCode.bytes);
|
||||
}
|
||||
|
||||
data.add(subData.length);
|
||||
data.addAll(subData);
|
||||
|
||||
if ((data.length % 16) != 0) {
|
||||
int add = (16 - data.length % 16);
|
||||
for (int i = 0; i < add; i++) {
|
||||
data.add(0);
|
||||
}
|
||||
}
|
||||
print("${commandType!.typeName} SM4Data:$data");
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
}
|
||||
|
||||
class SenderAddICCardReply extends Reply {
|
||||
SenderAddICCardReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
}
|
||||
}
|
||||
|
||||
class SenderAddICCardConfirmationReply extends Reply {
|
||||
SenderAddICCardConfirmationReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
}
|
||||
}
|
||||
139
star_lock/lib/blue/io_protocol/io_addStressFingerprint.dart
Normal file
139
star_lock/lib/blue/io_protocol/io_addStressFingerprint.dart
Normal file
@ -0,0 +1,139 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
///TODO:添加胁迫指纹
|
||||
/*
|
||||
备注:
|
||||
删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
||||
**/
|
||||
class SenderAddStressFingerprintCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? fingerNo;
|
||||
int? useCountLimit;
|
||||
List<int>? token;
|
||||
int? startTime;
|
||||
int? endTime;
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
SenderAddStressFingerprintCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.fingerNo,
|
||||
this.useCountLimit,
|
||||
this.token,
|
||||
this.startTime,
|
||||
this.endTime,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
List<int> subData = [];
|
||||
List<int> ebcData = [];
|
||||
|
||||
// 指令类型
|
||||
int type = commandType!.typeValue;
|
||||
double typeDouble = type / 256;
|
||||
int type1 = typeDouble.toInt();
|
||||
int type2 = type % 256;
|
||||
data.add(type1);
|
||||
data.add(type2);
|
||||
|
||||
// 子命令类型
|
||||
data.add(62);
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
// print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}");
|
||||
subData.addAll(utf8.encode(keyID!));
|
||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||
|
||||
//userID 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
// print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}");
|
||||
subData.addAll(utf8.encode(userID!));
|
||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||
|
||||
// PwdNo
|
||||
subData.add(fingerNo!);
|
||||
|
||||
// UseCountLimit
|
||||
subData.add(0xff);
|
||||
|
||||
// token
|
||||
subData.addAll(token!);
|
||||
|
||||
// startTime 4
|
||||
subData.add((startTime! & 0xff000000) >> 24);
|
||||
subData.add((startTime! & 0xff0000) >> 16);
|
||||
subData.add((startTime! & 0xff00) >> 8);
|
||||
subData.add((startTime! & 0xff));
|
||||
|
||||
// endTime 4
|
||||
subData.add((endTime! & 0xff000000) >> 24);
|
||||
subData.add((endTime! & 0xff0000) >> 16);
|
||||
subData.add((endTime! & 0xff00) >> 8);
|
||||
subData.add((endTime! & 0xff));
|
||||
|
||||
if(needAuthor == 0){
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
|
||||
print("${commandType!.typeValue}-authCodeData:$authCodeData");
|
||||
|
||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||
var authCode = crypto.md5.convert(authCodeData);
|
||||
|
||||
subData.add(authCode.bytes.length);
|
||||
subData.addAll(authCode.bytes);
|
||||
}
|
||||
|
||||
data.add(subData.length);
|
||||
data.addAll(subData);
|
||||
|
||||
if ((data.length % 16) != 0) {
|
||||
int add = (16 - data.length % 16);
|
||||
for (int i = 0; i < add; i++) {
|
||||
data.add(0);
|
||||
}
|
||||
}
|
||||
print("${commandType!.typeName} SM4Data:$data");
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
}
|
||||
|
||||
class SenderAddStressFingerprintReply extends Reply {
|
||||
SenderAddStressFingerprintReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
}
|
||||
}
|
||||
139
star_lock/lib/blue/io_protocol/io_addStressICCard.dart
Normal file
139
star_lock/lib/blue/io_protocol/io_addStressICCard.dart
Normal file
@ -0,0 +1,139 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
///TODO:添加胁迫卡片
|
||||
/*
|
||||
备注:
|
||||
删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
||||
**/
|
||||
class SenderAddStressICCardCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? icCardNo;
|
||||
int? useCountLimit;
|
||||
List<int>? token;
|
||||
int? startTime;
|
||||
int? endTime;
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
SenderAddStressICCardCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.icCardNo,
|
||||
this.useCountLimit,
|
||||
this.token,
|
||||
this.startTime,
|
||||
this.endTime,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
List<int> subData = [];
|
||||
List<int> ebcData = [];
|
||||
|
||||
// 指令类型
|
||||
int type = commandType!.typeValue;
|
||||
double typeDouble = type / 256;
|
||||
int type1 = typeDouble.toInt();
|
||||
int type2 = type % 256;
|
||||
data.add(type1);
|
||||
data.add(type2);
|
||||
|
||||
// 子命令类型
|
||||
data.add(62);
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
// print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}");
|
||||
subData.addAll(utf8.encode(keyID!));
|
||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||
|
||||
//userID 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
// print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}");
|
||||
subData.addAll(utf8.encode(userID!));
|
||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||
|
||||
// PwdNo
|
||||
subData.add(icCardNo!);
|
||||
|
||||
// UseCountLimit
|
||||
subData.add(0xff);
|
||||
|
||||
// token
|
||||
subData.addAll(token!);
|
||||
|
||||
// startTime 4
|
||||
subData.add((startTime! & 0xff000000) >> 24);
|
||||
subData.add((startTime! & 0xff0000) >> 16);
|
||||
subData.add((startTime! & 0xff00) >> 8);
|
||||
subData.add((startTime! & 0xff));
|
||||
|
||||
// endTime 4
|
||||
subData.add((endTime! & 0xff000000) >> 24);
|
||||
subData.add((endTime! & 0xff0000) >> 16);
|
||||
subData.add((endTime! & 0xff00) >> 8);
|
||||
subData.add((endTime! & 0xff));
|
||||
|
||||
if(needAuthor == 0){
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
|
||||
print("${commandType!.typeValue}-authCodeData:$authCodeData");
|
||||
|
||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||
var authCode = crypto.md5.convert(authCodeData);
|
||||
|
||||
subData.add(authCode.bytes.length);
|
||||
subData.addAll(authCode.bytes);
|
||||
}
|
||||
|
||||
data.add(subData.length);
|
||||
data.addAll(subData);
|
||||
|
||||
if ((data.length % 16) != 0) {
|
||||
int add = (16 - data.length % 16);
|
||||
for (int i = 0; i < add; i++) {
|
||||
data.add(0);
|
||||
}
|
||||
}
|
||||
print("${commandType!.typeName} SM4Data:$data");
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
}
|
||||
|
||||
class SenderAddStressICCardReply extends Reply {
|
||||
SenderAddStressICCardReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
}
|
||||
}
|
||||
139
star_lock/lib/blue/io_protocol/io_addStressPassword.dart
Normal file
139
star_lock/lib/blue/io_protocol/io_addStressPassword.dart
Normal file
@ -0,0 +1,139 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
///TODO:添加胁迫密码
|
||||
/*
|
||||
备注:
|
||||
删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
||||
**/
|
||||
class SenderAddStressPasswordCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? passwordNo;
|
||||
int? useCountLimit;
|
||||
List<int>? token;
|
||||
int? startTime;
|
||||
int? endTime;
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
SenderAddStressPasswordCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.passwordNo,
|
||||
this.useCountLimit,
|
||||
this.token,
|
||||
this.startTime,
|
||||
this.endTime,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
List<int> subData = [];
|
||||
List<int> ebcData = [];
|
||||
|
||||
// 指令类型
|
||||
int type = commandType!.typeValue;
|
||||
double typeDouble = type / 256;
|
||||
int type1 = typeDouble.toInt();
|
||||
int type2 = type % 256;
|
||||
data.add(type1);
|
||||
data.add(type2);
|
||||
|
||||
// 子命令类型
|
||||
data.add(62);
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
// print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}");
|
||||
subData.addAll(utf8.encode(keyID!));
|
||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||
|
||||
//userID 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
// print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}");
|
||||
subData.addAll(utf8.encode(userID!));
|
||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||
|
||||
// PwdNo
|
||||
subData.add(passwordNo!);
|
||||
|
||||
// UseCountLimit
|
||||
subData.add(0xff);
|
||||
|
||||
// token
|
||||
subData.addAll(token!);
|
||||
|
||||
// startTime 4
|
||||
subData.add((startTime! & 0xff000000) >> 24);
|
||||
subData.add((startTime! & 0xff0000) >> 16);
|
||||
subData.add((startTime! & 0xff00) >> 8);
|
||||
subData.add((startTime! & 0xff));
|
||||
|
||||
// endTime 4
|
||||
subData.add((endTime! & 0xff000000) >> 24);
|
||||
subData.add((endTime! & 0xff0000) >> 16);
|
||||
subData.add((endTime! & 0xff00) >> 8);
|
||||
subData.add((endTime! & 0xff));
|
||||
|
||||
if(needAuthor == 0){
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
|
||||
print("${commandType!.typeValue}-authCodeData:$authCodeData");
|
||||
|
||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||
var authCode = crypto.md5.convert(authCodeData);
|
||||
|
||||
subData.add(authCode.bytes.length);
|
||||
subData.addAll(authCode.bytes);
|
||||
}
|
||||
|
||||
data.add(subData.length);
|
||||
data.addAll(subData);
|
||||
|
||||
if ((data.length % 16) != 0) {
|
||||
int add = (16 - data.length % 16);
|
||||
for (int i = 0; i < add; i++) {
|
||||
data.add(0);
|
||||
}
|
||||
}
|
||||
print("${commandType!.typeName} SM4Data:$data");
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
}
|
||||
|
||||
class SenderAddStressPasswordReply extends Reply {
|
||||
SenderAddStressPasswordReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,10 @@ import 'package:star_lock/blue/io_protocol/io_transferPermissions.dart';
|
||||
|
||||
import '../tools/storage.dart';
|
||||
import 'io_protocol/io_addFingerprint.dart';
|
||||
import 'io_protocol/io_addICCard.dart';
|
||||
import 'io_protocol/io_addStressFingerprint.dart';
|
||||
import 'io_protocol/io_addStressICCard.dart';
|
||||
import 'io_protocol/io_addStressPassword.dart';
|
||||
import 'io_protocol/io_addUser.dart';
|
||||
import 'io_protocol/io_automaticPadlock.dart';
|
||||
import 'io_protocol/io_checkingCardStatus.dart';
|
||||
@ -188,6 +192,18 @@ class CommandReciverManager {
|
||||
reply = SenderCheckingCardStatusReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 21:
|
||||
{
|
||||
// 注册卡片开始
|
||||
reply = SenderAddICCardReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 22:
|
||||
{
|
||||
// 注册卡片确认
|
||||
reply = SenderAddICCardConfirmationReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 30:
|
||||
{
|
||||
// 查询指纹状态
|
||||
@ -224,6 +240,24 @@ class CommandReciverManager {
|
||||
reply = SenderConfiguringWifiReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 60:
|
||||
{
|
||||
// 注册胁迫密码
|
||||
reply = SenderAddStressPasswordReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 61:
|
||||
{
|
||||
// 注册胁迫卡片
|
||||
reply = SenderAddStressICCardReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 62:
|
||||
{
|
||||
// 注册胁迫指纹
|
||||
reply = SenderAddStressFingerprintReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
|
||||
import 'package:star_lock/blue/io_protocol/io_addICCard.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_addStressICCard.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
|
||||
|
||||
import 'io_protocol/io_addFingerprint.dart';
|
||||
import 'io_protocol/io_addStressFingerprint.dart';
|
||||
import 'io_protocol/io_addStressPassword.dart';
|
||||
import 'io_protocol/io_addUser.dart';
|
||||
import 'io_protocol/io_automaticPadlock.dart';
|
||||
import 'io_protocol/io_checkingCardStatus.dart';
|
||||
@ -289,6 +293,34 @@ class IoSenderManage {
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:添加指纹开始
|
||||
static void senderAddICCardCommand({
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? cardNo,
|
||||
required int? useCountLimit,
|
||||
required List<int>? token,
|
||||
required int? startTime,
|
||||
required int? endTime,
|
||||
required int? needAuthor,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderAddICCardCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
cardNo: cardNo,
|
||||
useCountLimit: useCountLimit,
|
||||
token: token,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:校验时间
|
||||
static void senderTimingCommand({
|
||||
required String? lockID,
|
||||
@ -484,4 +516,89 @@ class IoSenderManage {
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:添加胁迫指纹
|
||||
static void senderAddStressFingerprintCommand({
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? fingerNo,
|
||||
required int? useCountLimit,
|
||||
required List<int>? token,
|
||||
required int? startTime,
|
||||
required int? endTime,
|
||||
required int? needAuthor,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderAddStressFingerprintCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
fingerNo: fingerNo,
|
||||
useCountLimit: useCountLimit,
|
||||
token: token,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:添加胁迫卡片
|
||||
static void senderAddStressICCardCommand({
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? icCardNo,
|
||||
required int? useCountLimit,
|
||||
required List<int>? token,
|
||||
required int? startTime,
|
||||
required int? endTime,
|
||||
required int? needAuthor,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderAddStressICCardCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
icCardNo: icCardNo,
|
||||
useCountLimit: useCountLimit,
|
||||
token: token,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:添加胁迫密码
|
||||
static void senderAddStressPasswordCommand({
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? passwordNo,
|
||||
required int? useCountLimit,
|
||||
required List<int>? token,
|
||||
required int? startTime,
|
||||
required int? endTime,
|
||||
required int? needAuthor,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderAddStressPasswordCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
passwordNo: passwordNo,
|
||||
useCountLimit: useCountLimit,
|
||||
token: token,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
}
|
||||
@ -108,27 +108,27 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.addFingerprintProcessNumber.value++;
|
||||
print("state.addFingerprintProcessNumber.value:${state.addFingerprintProcessNumber.value}");
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
//需要权限
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
@ -146,27 +146,27 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
print("添加指纹确认成功,调用添加指纹接口");
|
||||
Get.close(3);
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
addFingerprintsData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
//需要权限
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
@ -222,6 +222,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 更新指纹用户账号
|
||||
void updateFingerprintUserNoLoadData(String fingerprintId) async{
|
||||
var entity = await ApiRepository.to.updateFingerprintUserNoLoadData(
|
||||
fingerprintId: fingerprintId,
|
||||
@ -253,6 +254,8 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,215 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.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_addICCard.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_manager.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/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'addICCard_state.dart';
|
||||
|
||||
class AddICCardLogic extends BaseGetXController{
|
||||
AddICCardState state = AddICCardState();
|
||||
|
||||
// 监听设备返回的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 添加IC卡开始
|
||||
if(reply is SenderAddICCardReply) {
|
||||
_replyAddICCardBegin(reply);
|
||||
}
|
||||
|
||||
// 添加卡确认
|
||||
if(reply is SenderAddICCardConfirmationReply) {
|
||||
_replyAddICCardConfirmation(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddFingerprintReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.ifConnectScuess.value = true;
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
useCountLimit:0xff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: token,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _replyAddICCardConfirmation(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddFingerprintReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
addICCardData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加卡片开始
|
||||
Future<void> senderAddICCard() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderAddICCardCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
cardNo:1,
|
||||
useCountLimit:1,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void addICCardData() async {
|
||||
var entity = await ApiRepository.to.addICCardData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
endDate: state.endDate.value.toString(),
|
||||
cardName: state.cardName.value.toString(),
|
||||
cardNumber: state.cardNumber.value.toString(),
|
||||
cardType: state.cardType.value.toString(),
|
||||
addType: state.addType.value.toString(),
|
||||
startDate: state.startDate.value.toString(),
|
||||
isCoerced: state.isCoerced.value.toString(),
|
||||
weekDay: state.weekDay.value,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Toast.show(msg: "添加成功");
|
||||
updateIdCardUserNoLoadData("0");
|
||||
}
|
||||
}
|
||||
|
||||
void updateIdCardUserNoLoadData(String cardId) async{
|
||||
var entity = await ApiRepository.to.updateIdCardUserNoLoadData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
cardId: cardId,
|
||||
cardUserNo: "0",
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "添加成功");
|
||||
Get.close(3);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
|
||||
senderAddICCard();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
import 'addICCard_logic.dart';
|
||||
|
||||
class AddICCardPage extends StatefulWidget {
|
||||
const AddICCardPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddICCardPage> createState() => _AddICCardPageState();
|
||||
}
|
||||
|
||||
class _AddICCardPageState extends State<AddICCardPage> {
|
||||
final logic = Get.put(AddICCardLogic());
|
||||
final state = Get.find<AddICCardLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: "${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: 420.h),
|
||||
CupertinoActivityIndicator(radius: 25.h,),
|
||||
SizedBox(height: 120.h),
|
||||
Container(
|
||||
width: 1.sw,
|
||||
height: 50.h,
|
||||
// padding: EdgeInsets.only(left: 30.w, right: 30.w, top: 10.h, bottom: 10.h),
|
||||
margin: EdgeInsets.only(left: 15.w, right: 15.w, top: 10.h, bottom: 10.h),
|
||||
// color: AppColors.blackColor,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.blackColor,
|
||||
borderRadius: BorderRadius.circular(10.w),
|
||||
),
|
||||
child: Center(child: Text("尝试连接设备...", style:TextStyle(color: Colors.white, fontSize: 24.sp))),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddICCardState{
|
||||
var ifConnectScuess = false.obs;
|
||||
var addFingerprintProcessNumber = 0.obs;
|
||||
final lockId = 0.obs;
|
||||
final endDate = "".obs;
|
||||
final addType = "".obs;
|
||||
final cardName = "".obs;
|
||||
final cardNumber = "".obs;
|
||||
final cardType = "".obs;
|
||||
final isCoerced = "".obs;
|
||||
final startDate = "".obs;
|
||||
final weekDay = [].obs;
|
||||
|
||||
AddICCardState() {
|
||||
Map map = Get.arguments;
|
||||
lockId.value = map["lockId"];
|
||||
endDate.value = map["endDate"];
|
||||
addType.value = map["addType"];
|
||||
cardName.value = map["cardName"];
|
||||
cardNumber.value = map["cardNumber"];
|
||||
cardType.value = map["cardType"];
|
||||
isCoerced.value = map["isCoerced"];
|
||||
startDate.value = map["startDate"];
|
||||
lockId.value = map["lockId"];
|
||||
weekDay.value = map["weekDay"];
|
||||
}
|
||||
}
|
||||
@ -72,57 +72,68 @@ class OtherTypeAddKeyLogic extends BaseGetXController {
|
||||
fingerprintType = 4;
|
||||
}
|
||||
|
||||
// if(state.fromType.value == 1){
|
||||
// Get.toNamed(Routers.addFingerprintTipPage, arguments: {
|
||||
// "lockId": state.lockId.value,
|
||||
// "endDate": endDate,
|
||||
// "addType": "1",
|
||||
// "fingerprintName": state.nameController.text,
|
||||
// "fingerprintNumber": "123456",
|
||||
// "fingerprintType": fingerprintType.toString(),
|
||||
// "isCoerced": state.isStressFingerprint.value ? "1" : "2",
|
||||
// "startDate": startDate,
|
||||
// "weekDay": state.weekdaysList.value,
|
||||
// });
|
||||
// }
|
||||
|
||||
switch (state.fromType.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
var entity = await ApiRepository.to.addICCardData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
endDate: endDate,
|
||||
cardName: state.nameController.text,
|
||||
cardNumber: (Random().nextInt(100000000) + 10000000).floor().toString(),
|
||||
cardType: fingerprintType.toString(),
|
||||
addType:"1",
|
||||
startDate: startDate,
|
||||
isCoerced: state.isStressFingerprint.value ? "1" : "2",
|
||||
weekDay: state.weekdaysList.value,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "添加成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
Get.toNamed(Routers.addICCardPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"endDate": endDate,
|
||||
"addType": "1",
|
||||
"cardName": state.nameController.text,
|
||||
"cardNumber": (Random().nextInt(100000000) + 10000000).floor().toString(),
|
||||
"cardType": fingerprintType.toString(),
|
||||
"isCoerced": state.isStressFingerprint.value ? "1" : "2",
|
||||
"startDate": startDate,
|
||||
"weekDay": state.weekdaysList.value,
|
||||
});
|
||||
|
||||
// var entity = await ApiRepository.to.addICCardData(
|
||||
// lockId: state.lockId.value.toString(),
|
||||
// endDate: endDate,
|
||||
// cardName: state.nameController.text,
|
||||
// cardNumber: (Random().nextInt(100000000) + 10000000).floor().toString(),
|
||||
// cardType: fingerprintType.toString(),
|
||||
// addType:"1",
|
||||
// startDate: startDate,
|
||||
// isCoerced: state.isStressFingerprint.value ? "1" : "2",
|
||||
// weekDay: state.weekdaysList.value,
|
||||
// );
|
||||
// if(entity.errorCode!.codeIsSuccessful){
|
||||
// Toast.show(msg: "添加成功");
|
||||
// Get.back(result: "addScuess");
|
||||
// }
|
||||
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
var entity = await ApiRepository.to.addFingerprintsData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
endDate: endDate,
|
||||
addType:"1",
|
||||
fingerprintName: state.nameController.text,
|
||||
fingerprintNumber: (Random().nextInt(100000000) + 10000000).floor().toString(),
|
||||
fingerprintType: fingerprintType.toString(),
|
||||
isCoerced: state.isStressFingerprint.value ? "1" : "2",
|
||||
startDate: startDate,
|
||||
weekDay: state.weekdaysList.value,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
Toast.show(msg: "添加成功");
|
||||
Get.back(result: "addScuess");
|
||||
}
|
||||
Get.toNamed(Routers.addFingerprintTipPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"endDate": endDate,
|
||||
"addType": "1",
|
||||
"fingerprintName": state.nameController.text,
|
||||
"fingerprintNumber": "123456",
|
||||
"fingerprintType": fingerprintType.toString(),
|
||||
"isCoerced": state.isStressFingerprint.value ? "1" : "2",
|
||||
"startDate": startDate,
|
||||
"weekDay": state.weekdaysList.value,
|
||||
});
|
||||
|
||||
// var entity = await ApiRepository.to.addFingerprintsData(
|
||||
// lockId: state.lockId.value.toString(),
|
||||
// endDate: endDate,
|
||||
// addType:"1",
|
||||
// fingerprintName: state.nameController.text,
|
||||
// fingerprintNumber: (Random().nextInt(100000000) + 10000000).floor().toString(),
|
||||
// fingerprintType: fingerprintType.toString(),
|
||||
// isCoerced: state.isStressFingerprint.value ? "1" : "2",
|
||||
// startDate: startDate,
|
||||
// weekDay: state.weekdaysList.value,
|
||||
// );
|
||||
// if(entity.errorCode!.codeIsSuccessful){
|
||||
// Toast.show(msg: "添加成功");
|
||||
// Get.back(result: "addScuess");
|
||||
// }
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
@ -87,6 +87,7 @@ abstract class Api {
|
||||
final String addICCardURL = '/identityCard/add'; // 添加IC卡
|
||||
final String editICCardURL = '/identityCard/update'; // 编辑IC卡
|
||||
final String deleteICCardURL = '/identityCard/delete'; // 删除IC卡
|
||||
final String updateICCardUserNoURL = '/identityCard/updatePwdUserNo'; // 更新ic卡用户序号
|
||||
|
||||
final String getKeyDetailURL = '/key/get'; //获取单把钥匙详情信息
|
||||
final String lockUserListURL = '/keyUser/listKeyUser'; //锁用户列表
|
||||
|
||||
@ -926,6 +926,20 @@ class ApiProvider extends BaseProvider {
|
||||
'deleteType': deleteType
|
||||
}));
|
||||
|
||||
// 更新ICCard序号
|
||||
Future<Response> updateIdCardUserNoLoadData(
|
||||
String cardId,
|
||||
String lockId,
|
||||
String cardUserNo) =>
|
||||
post(
|
||||
updateICCardUserNoURL.toUrl,
|
||||
jsonEncode({
|
||||
'cardId': cardId,
|
||||
'lockId': lockId,
|
||||
'cardUserNo': cardUserNo
|
||||
})
|
||||
);
|
||||
|
||||
Future<Response> listLockByGroup(String type, String keyGroupId) => post(
|
||||
listLockByGroupURL.toUrl,
|
||||
jsonEncode({'type': type, 'keyGroupId': keyGroupId}));
|
||||
|
||||
@ -992,4 +992,17 @@ class ApiRepository {
|
||||
await apiProvider.deletIcCardData(cardId, lockId, type, deleteType);
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 更新ICCard用户序号
|
||||
Future<LoginEntity> updateIdCardUserNoLoadData(
|
||||
{
|
||||
required String lockId,
|
||||
required String cardId,
|
||||
required String cardUserNo
|
||||
}) async {
|
||||
final res =
|
||||
await apiProvider.updateIdCardUserNoLoadData(lockId, cardId, cardUserNo);
|
||||
return LoginEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user