Merge branch 'master' of gitee.com:starlock-cn/app-starlock
This commit is contained in:
commit
73ffd5a221
@ -77,10 +77,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫
|
||||
isRound:0, // 是否是循环
|
||||
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // 周循环
|
||||
startDate: state.fingerprintItemData.value.startDate!~/1000,
|
||||
endDate: state.fingerprintItemData.value.endDate!~/1000,
|
||||
startTime:DateTool().dateToHNString(state.fingerprintItemData.value.startDate!.toString()),
|
||||
endTime:DateTool().dateToHNString(state.fingerprintItemData.value.endDate!.toString()),
|
||||
startDate: state.beginTimeTimestamp.value~/1000,
|
||||
endDate: state.endTimeTimestamp.value~/1000,
|
||||
startTime:"0",
|
||||
endTime:"0",
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -124,10 +124,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫
|
||||
isRound:0, // 是否是循环
|
||||
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // 周循环
|
||||
startDate: state.fingerprintItemData.value.startDate!~/1000,
|
||||
endDate: state.fingerprintItemData.value.endDate!~/1000,
|
||||
startTime:DateTool().dateToHNString(state.fingerprintItemData.value.startDate!.toString()),
|
||||
endTime:DateTool().dateToHNString(state.fingerprintItemData.value.endDate!.toString()),
|
||||
startDate: state.beginTimeTimestamp.value~/1000,
|
||||
endDate: state.endTimeTimestamp.value~/1000,
|
||||
startTime:"0",
|
||||
endTime:"0",
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -178,10 +178,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫
|
||||
isRound:0, // 是否是循环
|
||||
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // 周循环
|
||||
startDate: state.fingerprintItemData.value.startDate!~/1000,
|
||||
endDate: state.fingerprintItemData.value.endDate!~/1000,
|
||||
startTime:DateTool().dateToHNString(state.fingerprintItemData.value.startDate!.toString()),
|
||||
endTime:DateTool().dateToHNString(state.fingerprintItemData.value.endDate!.toString()),
|
||||
startDate: state.beginTimeTimestamp.value~/1000,
|
||||
endDate: state.endTimeTimestamp.value~/1000,
|
||||
startTime:"0",
|
||||
endTime:"0",
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -228,10 +228,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫
|
||||
isRound:0, // 是否是循环
|
||||
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // 周循环
|
||||
startDate: state.fingerprintItemData.value.startDate!~/1000,
|
||||
endDate: state.fingerprintItemData.value.endDate!~/1000,
|
||||
startTime:DateTool().dateToHNString(state.fingerprintItemData.value.startDate!.toString()),
|
||||
endTime:DateTool().dateToHNString(state.fingerprintItemData.value.endDate!.toString()),
|
||||
startDate: state.beginTimeTimestamp.value~/1000,
|
||||
endDate: state.endTimeTimestamp.value~/1000,
|
||||
startTime:"0",
|
||||
endTime:"0",
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -279,10 +279,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫
|
||||
isRound:0, // 是否是循环
|
||||
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // 周循环
|
||||
startDate: state.fingerprintItemData.value.startDate!~/1000,
|
||||
endDate: state.fingerprintItemData.value.endDate!~/1000,
|
||||
startTime:DateTool().dateToHNString(state.fingerprintItemData.value.startDate!.toString()),
|
||||
endTime:DateTool().dateToHNString(state.fingerprintItemData.value.endDate!.toString()),
|
||||
startDate: state.beginTimeTimestamp.value~/1000,
|
||||
endDate: state.endTimeTimestamp.value~/1000,
|
||||
startTime:"0",
|
||||
endTime:"0",
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -331,10 +331,10 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫
|
||||
isRound:0, // 是否是循环
|
||||
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.fingerprintItemData.value.weekDay!), // 周循环
|
||||
startDate: state.fingerprintItemData.value.startDate!~/1000,
|
||||
endDate: state.fingerprintItemData.value.endDate!~/1000,
|
||||
startTime:DateTool().dateToHNString(state.fingerprintItemData.value.startDate!.toString()),
|
||||
endTime:DateTool().dateToHNString(state.fingerprintItemData.value.endDate!.toString()),
|
||||
startDate: state.beginTimeTimestamp.value~/1000,
|
||||
endDate: state.endTimeTimestamp.value~/1000,
|
||||
startTime:"0",
|
||||
endTime:"0",
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -357,9 +357,9 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.fingerprintItemData.value.weekDay!,
|
||||
startDate: DateTool().dateToTimestamp(state.beginTime.value, 1).toString(),
|
||||
endDate: DateTool().dateToTimestamp(state.endTime.value, 1).toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
startDate: state.beginTimeTimestamp.value.toString(),
|
||||
endDate: state.endTimeTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced.toString(),
|
||||
fingerprintName: state.fingerprintItemData.value.fingerprintName!,
|
||||
changeType: "1",
|
||||
startTime: 0,
|
||||
@ -370,8 +370,8 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
showToast("修改成功".tr, something: (){
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
Get.back(result: {
|
||||
"beginTimeTimestamp":DateTool().dateToTimestamp(state.beginTime.value, 1).toString(),
|
||||
"endTimeTimestamp":DateTool().dateToTimestamp(state.endTime.value, 1).toString(),
|
||||
"beginTimeTimestamp":state.beginTimeTimestamp.value.toString(),
|
||||
"endTimeTimestamp":state.endTimeTimestamp.value.toString(),
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -383,9 +383,9 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
cardId: state.fingerprintItemData.value.cardId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.fingerprintItemData.value.weekDay!,
|
||||
startDate: DateTool().dateToTimestamp(state.beginTime.value, 1).toString(),
|
||||
endDate: DateTool().dateToTimestamp(state.endTime.value, 1).toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
startDate: state.beginTimeTimestamp.value.toString(),
|
||||
endDate: state.endTimeTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced.toString(),
|
||||
cardName: state.fingerprintItemData.value.cardName!,
|
||||
changeType: '1',
|
||||
startTime: 0,
|
||||
@ -395,8 +395,8 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
showToast("修改成功".tr, something: (){
|
||||
Get.back(result: {
|
||||
"beginTimeTimestamp":DateTool().dateToTimestamp(state.beginTime.value, 1).toString(),
|
||||
"endTimeTimestamp":DateTool().dateToTimestamp(state.endTime.value, 1).toString(),
|
||||
"beginTimeTimestamp":state.beginTimeTimestamp.value.toString(),
|
||||
"endTimeTimestamp":state.endTimeTimestamp.value.toString(),
|
||||
});
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
});
|
||||
@ -408,22 +408,27 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
|
||||
var entity = await ApiRepository.to.updateFaceValidity(
|
||||
lockId: state.fingerprintItemData.value.lockId!,
|
||||
faceId: state.fingerprintItemData.value.faceId!,
|
||||
startDate: DateTool().dateToTimestamp(state.beginTime.value, 1),
|
||||
endDate: DateTool().dateToTimestamp(state.endTime.value, 1),
|
||||
startDate: state.beginTimeTimestamp.value,
|
||||
endDate: state.endTimeTimestamp.value,
|
||||
startTime: 0,
|
||||
endTime: 0,
|
||||
faceType: 2,
|
||||
weekDay: state.fingerprintItemData.value.weekDay!,
|
||||
faceName: state.fingerprintItemData.value.faceName!,
|
||||
addType: "1",
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? 2 : 1,
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced!,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("修改成功", something: () {
|
||||
Get.back(result: "addScuess");
|
||||
Get.back(result: {
|
||||
"beginTimeTimestamp":state.beginTimeTimestamp.value.toString(),
|
||||
"endTimeTimestamp":state.endTimeTimestamp.value.toString(),
|
||||
});
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
@ -42,14 +44,14 @@ class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage>
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () {
|
||||
var beginTimeTimestamp = DateTool().dateToTimestamp(state.beginTime.value, 1);
|
||||
var endTimeTimestamp = DateTool().dateToTimestamp(state.endTime.value, 1);
|
||||
if (beginTimeTimestamp > endTimeTimestamp || beginTimeTimestamp == endTimeTimestamp) {
|
||||
state.beginTimeTimestamp.value = DateTool().dateToTimestamp(state.beginTime.value, 1);
|
||||
state.endTimeTimestamp.value = DateTool().dateToTimestamp(state.endTime.value, 1);
|
||||
if (state.beginTimeTimestamp.value > state.endTimeTimestamp.value || state.beginTimeTimestamp.value == state.endTimeTimestamp.value) {
|
||||
logic.showToast("失效时间需大于生效时间".tr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (endTimeTimestamp < DateTime.now().millisecondsSinceEpoch) {
|
||||
if (state.endTimeTimestamp.value < DateTime.now().millisecondsSinceEpoch) {
|
||||
logic.showToast("生效时间需大于当前时间".tr);
|
||||
return;
|
||||
}
|
||||
@ -63,6 +65,10 @@ class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage>
|
||||
logic.senderAddFingerprint();
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
break;
|
||||
case 3:
|
||||
// 人脸
|
||||
logic.senderAddFace();
|
||||
break;
|
||||
|
||||
@ -8,6 +8,8 @@ class OtherTypeKeyChangeDateState{
|
||||
|
||||
var beginTime = "".obs;// 开始时间
|
||||
var endTime = "".obs;// 结束时间
|
||||
var beginTimeTimestamp = 0.obs;// 开始时间
|
||||
var endTimeTimestamp = 0.obs;// 结束时间
|
||||
|
||||
var pushType = 0.obs;// 0卡 1指纹 2遥控 3人脸
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
@ -26,9 +28,13 @@ class OtherTypeKeyChangeDateState{
|
||||
if(fingerprintItemData.value.startDate == 0 && fingerprintItemData.value.endDate == 0){
|
||||
beginTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString());
|
||||
endTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString());
|
||||
beginTimeTimestamp.value = DateTime.now().millisecondsSinceEpoch;
|
||||
endTimeTimestamp.value = DateTime.now().millisecondsSinceEpoch;
|
||||
}else{
|
||||
beginTime.value = DateTool().dateToYMDHNString(fingerprintItemData.value.startDate.toString());
|
||||
endTime.value = DateTool().dateToYMDHNString(fingerprintItemData.value.endDate.toString());
|
||||
beginTimeTimestamp.value = fingerprintItemData.value.startDate!;
|
||||
endTimeTimestamp.value = fingerprintItemData.value.endDate!;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,52 +1,381 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.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_addFace.dart';
|
||||
import '../../../../blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart';
|
||||
import '../../../../blue/io_protocol/io_addICCardWithTimeCycleCoercion.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/dateTool.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import 'otherTypeKeyChangeValidityDate_state.dart';
|
||||
|
||||
class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
|
||||
OtherTypeKeyChangeValidityDateState state = OtherTypeKeyChangeValidityDateState();
|
||||
|
||||
// 监听设备返回的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 添加卡片开始(重置锁里面所有卡)
|
||||
if((reply is SenderAddICCardWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) {
|
||||
_replyAddICCardBegin(reply);
|
||||
}
|
||||
|
||||
// 添加指纹开始(此处用作修改或者删除指纹)
|
||||
if((reply is SenderAddFingerprintWithTimeCycleCoercionReply) && (state.ifCurrentScreen.value == true)) {
|
||||
_replyAddFingerprintBegin(reply);
|
||||
}
|
||||
|
||||
// 添加人脸开始(此处用作修改人脸)
|
||||
if ((reply is SenderAddFaceReply) && (state.ifCurrentScreen.value == true)) {
|
||||
_replyAddFaceBegin(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加人脸开始
|
||||
Future<void> _replyAddFaceBegin(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
Get.log("${reply.commandType!.typeValue} 删除人脸数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
editFaceData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderAddFaceCommand(
|
||||
keyID:state.fingerprintItemData.value.cardId!.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
faceNo:int.parse(state.fingerprintItemData.value.faceNumber!),
|
||||
useCountLimit:0xff,
|
||||
isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫
|
||||
isRound:1, // 是否是循环
|
||||
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环
|
||||
startDate: state.starDateTimestamp.value~/1000,
|
||||
endDate: state.endDateTimestamp.value~/1000,
|
||||
startTime:DateTool().dateToHNString(state.starTimeTimestamp.value.toString()),
|
||||
endTime:DateTool().dateToHNString(state.endTimeTimestamp.value.toString()),
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: token,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除/修改人脸信息
|
||||
Future<void> senderAddFace() async {
|
||||
if (state.sureBtnState.value == 1) {
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
IoSenderManage.senderAddFaceCommand(
|
||||
keyID:state.fingerprintItemData.value.cardId!.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
faceNo:int.parse(state.fingerprintItemData.value.faceNumber!),
|
||||
useCountLimit:0xff,
|
||||
isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫
|
||||
isRound:1, // 是否是循环
|
||||
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环
|
||||
startDate: state.starDateTimestamp.value~/1000,
|
||||
endDate: state.endDateTimestamp.value~/1000,
|
||||
startTime:DateTool().dateToHNString(state.starTimeTimestamp.value.toString()),
|
||||
endTime:DateTool().dateToHNString(state.endTimeTimestamp.value.toString()),
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
} else if (deviceConnectionState ==
|
||||
BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加卡片开始(此处用作删除卡片)
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
Get.log("${reply.commandType!.typeValue} 数据解析成功");
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
editICCardData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
Get.log("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
|
||||
keyID:state.fingerprintItemData.value.cardId!.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
cardNo:int.parse(state.fingerprintItemData.value.cardNumber!),
|
||||
useCountLimit:0xff ,
|
||||
isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫
|
||||
isRound:1, // 是否是循环
|
||||
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环
|
||||
startDate: state.starDateTimestamp.value~/1000,
|
||||
endDate: state.endDateTimestamp.value~/1000,
|
||||
startTime:DateTool().dateToHNString(state.starTimeTimestamp.value.toString()),
|
||||
endTime:DateTool().dateToHNString(state.endTimeTimestamp.value.toString()),
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: token,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
Get.log("${reply.commandType!.typeValue} 失败");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加指纹开始
|
||||
Future<void> _replyAddFingerprintBegin(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
Get.log("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
editFingerprintsData();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
Get.log("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
|
||||
keyID:state.fingerprintItemData.value.fingerprintId.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:int.parse(state.fingerprintItemData.value.fingerprintNumber!),
|
||||
useCountLimit:0xff,
|
||||
isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫
|
||||
isRound:1, // 是否是循环
|
||||
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环
|
||||
startDate: state.starDateTimestamp.value~/1000,
|
||||
endDate: state.endDateTimestamp.value~/1000,
|
||||
startTime:DateTool().dateToHNString(state.starTimeTimestamp.value.toString()),
|
||||
endTime:DateTool().dateToHNString(state.endTimeTimestamp.value.toString()),
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: token,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
Get.log("${reply.commandType!.typeValue} 失败");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除指纹
|
||||
Future<void> senderAddFingerprint() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand(
|
||||
keyID:state.fingerprintItemData.value.fingerprintId.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:int.parse(state.fingerprintItemData.value.fingerprintNumber!),
|
||||
useCountLimit:0xff,
|
||||
isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫
|
||||
isRound:1, // 是否是循环
|
||||
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环
|
||||
startDate: state.starDateTimestamp.value~/1000,
|
||||
endDate: state.endDateTimestamp.value~/1000,
|
||||
startTime:DateTool().dateToHNString(state.starTimeTimestamp.value.toString()),
|
||||
endTime:DateTool().dateToHNString(state.endTimeTimestamp.value.toString()),
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加卡片
|
||||
Future<void> senderAddICCard() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected){
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddCardWithTimeCycleCoercionCommand(
|
||||
keyID:state.fingerprintItemData.value.cardId!.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
cardNo:int.parse(state.fingerprintItemData.value.cardNumber!),
|
||||
useCountLimit:0xff ,
|
||||
isForce:state.fingerprintItemData.value.isCoerced, // 是否是胁迫
|
||||
isRound:1, // 是否是循环
|
||||
weekRound:DateTool().accordingTheCycleIntoTheCorrespondingNumber(state.weekDay.value), // 周循环
|
||||
startDate: state.starDateTimestamp.value~/1000,
|
||||
endDate: state.endDateTimestamp.value~/1000,
|
||||
startTime:DateTool().dateToHNString(state.starTimeTimestamp.value.toString()),
|
||||
endTime:DateTool().dateToHNString(state.endTimeTimestamp.value.toString()),
|
||||
needAuthor:1,
|
||||
signKey:signKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 修改指纹信息
|
||||
void editFingerprintsData() async{
|
||||
var starDateTimestamp = DateTool().dateToTimestamp(state.starDate.value, 1);
|
||||
var endDateTimestamp = DateTool().dateToTimestamp(state.endDate.value, 1);
|
||||
var starTimeTimestamp = DateTool().dateToTimestamp(state.starTime.value, 0);
|
||||
var endTimeTimestamp = DateTool().dateToTimestamp(state.endTime.value, 0);
|
||||
|
||||
if (starDateTimestamp >= endDateTimestamp) {
|
||||
showToast("失效日期要大于生效日期".tr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (starTimeTimestamp >= endTimeTimestamp) {
|
||||
showToast("失效时间要大于生效时间".tr);
|
||||
return;
|
||||
}
|
||||
var entity = await ApiRepository.to.editFingerprintsData(
|
||||
fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.weekDay.value,
|
||||
startDate: starDateTimestamp.toString(),
|
||||
endDate: endDateTimestamp.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
startDate: state.starDateTimestamp.value.toString(),
|
||||
endDate: state.endDateTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced.toString(),
|
||||
fingerprintName: state.fingerprintItemData.value.fingerprintName!,
|
||||
changeType: "1",
|
||||
startTime: starTimeTimestamp,
|
||||
endTime: endTimeTimestamp,
|
||||
startTime: state.starTimeTimestamp.value,
|
||||
endTime: state.endTimeTimestamp.value,
|
||||
fingerprintType: state.fingerprintItemData.value.fingerprintType!,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
showToast("修改成功".tr, something: (){
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
Get.back(result: {
|
||||
"starDate":starDateTimestamp.toString(),
|
||||
"endDate":endDateTimestamp.toString(),
|
||||
"starTime":starTimeTimestamp.toString(),
|
||||
"endTime":endTimeTimestamp.toString(),
|
||||
"starDate":state.starDateTimestamp.value.toString(),
|
||||
"endDate":state.endDateTimestamp.value.toString(),
|
||||
"starTime":state.starTimeTimestamp.value.toString(),
|
||||
"endTime":state.endTimeTimestamp.value.toString(),
|
||||
"validityValue":state.weekDay.value,
|
||||
});
|
||||
});
|
||||
@ -55,45 +384,82 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
|
||||
|
||||
// 编辑iC卡
|
||||
void editICCardData() async{
|
||||
var starDateTimestamp = DateTool().dateToTimestamp(state.starDate.value, 1);
|
||||
var endDateTimestamp = DateTool().dateToTimestamp(state.endDate.value, 1);
|
||||
var starTimeTimestamp = DateTool().dateToTimestamp(state.starTime.value, 0);
|
||||
var endTimeTimestamp = DateTool().dateToTimestamp(state.endTime.value, 0);
|
||||
|
||||
if (starDateTimestamp >= endDateTimestamp) {
|
||||
showToast("失效日期要大于生效日期".tr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (starTimeTimestamp >= endTimeTimestamp) {
|
||||
showToast("失效时间要大于生效时间".tr);
|
||||
return;
|
||||
}
|
||||
var entity = await ApiRepository.to.editICCardData(
|
||||
cardId: state.fingerprintItemData.value.cardId.toString(),
|
||||
lockId: state.fingerprintItemData.value.lockId.toString(),
|
||||
weekDay: state.weekDay.value,
|
||||
startDate: starDateTimestamp.toString(),
|
||||
endDate: endDateTimestamp.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1",
|
||||
startDate: state.starDateTimestamp.value.toString(),
|
||||
endDate: state.endDateTimestamp.value.toString(),
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced!.toString(),
|
||||
cardName: state.fingerprintItemData.value.cardName!,
|
||||
changeType: '1',
|
||||
startTime: starTimeTimestamp,
|
||||
endTime: endTimeTimestamp,
|
||||
startTime: state.starTimeTimestamp.value,
|
||||
endTime: state.endTimeTimestamp.value,
|
||||
cardType: state.fingerprintItemData.value.cardType!,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
showToast("修改成功".tr, something: (){
|
||||
eventBus.fire(OtherTypeRefreshListEvent());
|
||||
Get.back(result: {
|
||||
"starDate":starDateTimestamp.toString(),
|
||||
"endDate":endDateTimestamp.toString(),
|
||||
"starTime":starTimeTimestamp.toString(),
|
||||
"endTime":endTimeTimestamp.toString(),
|
||||
"starDate":state.starDateTimestamp.value.toString(),
|
||||
"endDate":state.endDateTimestamp.value.toString(),
|
||||
"starTime":state.starTimeTimestamp.value.toString(),
|
||||
"endTime":state.endTimeTimestamp.value.toString(),
|
||||
"validityValue":state.weekDay.value,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 修改人脸有效期
|
||||
void editFaceData() async {
|
||||
var entity = await ApiRepository.to.updateFaceValidity(
|
||||
lockId: state.fingerprintItemData.value.lockId!,
|
||||
faceId: state.fingerprintItemData.value.faceId!,
|
||||
startDate: state.starDateTimestamp.value,
|
||||
endDate: state.endDateTimestamp.value,
|
||||
startTime: state.starTimeTimestamp.value,
|
||||
endTime: state.endTimeTimestamp.value,
|
||||
faceType: 2,
|
||||
weekDay: state.weekDay.value,
|
||||
faceName: state.fingerprintItemData.value.faceName!,
|
||||
addType: "1",
|
||||
isCoerced: state.fingerprintItemData.value.isCoerced!,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("修改成功", something: () {
|
||||
Get.back(result: {
|
||||
"starDate":state.starDateTimestamp.value.toString(),
|
||||
"endDate":state.endDateTimestamp.value.toString(),
|
||||
"starTime":state.starTimeTimestamp.value.toString(),
|
||||
"endTime":state.endTimeTimestamp.value.toString(),
|
||||
"validityValue":state.weekDay.value,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -44,10 +44,40 @@ class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeV
|
||||
child: SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.save!.tr,
|
||||
onClick: () {
|
||||
if (state.pushType.value == 0) {
|
||||
logic.editICCardData();
|
||||
} else if (state.pushType.value == 1) {
|
||||
logic.editFingerprintsData();
|
||||
state.starDateTimestamp.value = DateTool().dateToTimestamp(state.starDate.value, 1);
|
||||
state.endDateTimestamp.value = DateTool().dateToTimestamp(state.endDate.value, 1);
|
||||
state.starTimeTimestamp.value = DateTool().dateToTimestamp(state.starTime.value, 0);
|
||||
state.endTimeTimestamp.value = DateTool().dateToTimestamp(state.endTime.value, 0);
|
||||
|
||||
if (state.starDateTimestamp.value >= state.endDateTimestamp.value) {
|
||||
logic.showToast("失效日期要大于生效日期".tr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.starTimeTimestamp.value >= state.endTimeTimestamp.value) {
|
||||
logic.showToast("失效时间要大于生效时间".tr);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (state.pushType.value) {
|
||||
case 0:
|
||||
// 卡
|
||||
logic.senderAddICCard();
|
||||
break;
|
||||
case 1:
|
||||
// 指纹
|
||||
logic.senderAddFingerprint();
|
||||
break;
|
||||
case 2:
|
||||
// 遥控
|
||||
|
||||
break;
|
||||
case 3:
|
||||
// 人脸
|
||||
logic.senderAddFace();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}),
|
||||
),
|
||||
|
||||
@ -12,8 +12,15 @@ class OtherTypeKeyChangeValidityDateState{
|
||||
var starTime = "".obs;// 生效时间
|
||||
var endTime = "".obs;// 失效时间
|
||||
|
||||
var pushType = 0.obs;// 0卡 1指纹 2遥控
|
||||
var starDateTimestamp = 0.obs;// 开始时间
|
||||
var endDateTimestamp = 0.obs;// 结束时间
|
||||
var starTimeTimestamp = 0.obs;// 生效时间
|
||||
var endTimeTimestamp = 0.obs;// 失效时间
|
||||
|
||||
var pushType = 0.obs;// 0卡 1指纹 2遥控 3人脸
|
||||
var weekDay = [].obs;
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
OtherTypeKeyChangeValidityDateState() {
|
||||
Map map = Get.arguments;
|
||||
|
||||
@ -7,14 +7,10 @@ import 'package:star_lock/main/lockDetail/face/faceDetail/faceDetail_logic.dart'
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/dateTool.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/showTFView.dart';
|
||||
import '../../../../tools/showTipView.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
@ -100,7 +96,7 @@ class _FaceDetailPageState extends State<FaceDetailPage> with RouteAware {
|
||||
var data = await Get.toNamed(
|
||||
Routers.otherTypeKeyChangeValidityDatePage,
|
||||
arguments: {
|
||||
"pushType": 0,
|
||||
"pushType": 3,
|
||||
"fingerprintItemData": state.faceItemData.value,
|
||||
});
|
||||
if (data != null) {
|
||||
|
||||
@ -160,6 +160,7 @@ class _FingerprintDetailPageState extends State<FingerprintDetailPage> with Rout
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.additive!.tr,
|
||||
rightTitle: state.adder.value,
|
||||
isHaveLine: true,
|
||||
action: () {
|
||||
|
||||
})),
|
||||
|
||||
@ -360,21 +360,6 @@ class LockDetailLogic extends BaseGetXController {
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
|
||||
// var listData = AddUserCommand(
|
||||
// lockID: BlueManage().connectDeviceName,
|
||||
// authUserID: state.senderUserId.toString(),
|
||||
// keyID: state.keyInfos.value.keyId.toString(),
|
||||
// userID: await Storage.getUid(),
|
||||
// openMode: 1,
|
||||
// keyType: 0,
|
||||
// startDate: state.keyInfos.value.startDate!~/10000,
|
||||
// expireDate: state.keyInfos.value.endDate!~/10000,
|
||||
// role: state.keyInfos.value.keyRight == 1 ? 1 : 0,
|
||||
// password: "123456",
|
||||
// needAuthor: 1,
|
||||
// publicKey: publicKeyDataList,
|
||||
// privateKey: getPrivateKeyList,
|
||||
// token: getTokenList).packageData();
|
||||
BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
// 私钥
|
||||
|
||||
@ -17,6 +17,7 @@ import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import '../../../tools/appRouteObserver.dart';
|
||||
import '../../../tools/commonDataManage.dart';
|
||||
import '../../../tools/dateTool.dart';
|
||||
import '../../../tools/eventBusEventManage.dart';
|
||||
import '../../../tools/storage.dart';
|
||||
@ -85,6 +86,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
void loadData() {
|
||||
state.keyInfos.value = widget.lockListInfoItemEntity;
|
||||
state.lockUserNo = state.keyInfos.value.lockUserNo!;
|
||||
CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!;;
|
||||
|
||||
if (state.lockUserNo == 0) {
|
||||
state.bottomBtnisEable.value = false;
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user