Merge branch 'optimized_startup_wei' into develop

This commit is contained in:
Liuyf 2024-09-18 10:28:56 +08:00
commit 70b178a4b9
4 changed files with 224 additions and 180 deletions

View File

@ -25,6 +25,7 @@ class DoorLockLogLogic extends BaseGetXController {
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = _replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) { EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
@ -75,7 +76,12 @@ class DoorLockLogLogic extends BaseGetXController {
(0xff & indexList[4]) << 16 | (0xff & indexList[4]) << 16 |
(0xff & indexList[5]) << 8 | (0xff & indexList[5]) << 8 |
(0xFF & indexList[6]); (0xFF & indexList[6]);
indexMap['date'] = '${time * 1000}'; final operateDate = time * 1000;
if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(
DateTime.fromMillisecondsSinceEpoch(state.currentDate))) {
continue;
}
indexMap['date'] = '$operateDate';
uploadList.add(indexMap); uploadList.add(indexMap);
} }
if (dataLength == state.logCountPage) { if (dataLength == state.logCountPage) {
@ -102,16 +108,19 @@ class DoorLockLogLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: () { showBlueConnetctToastTimer(action: () {
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async { BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionStateState) async {
if (connectionStateState == BluetoothConnectionState.connected) { if (connectionStateState == BluetoothConnectionState.connected) {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!); changeStringListToIntList(privateKey!);
final List<String>? token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
final List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
final List<String>? publicKey = await Storage.getStringList(saveBluePublicKey); final List<String>? publicKey =
await Storage.getStringList(saveBluePublicKey);
final List<int> getPublicKeyList = final List<int> getPublicKeyList =
changeStringListToIntList(publicKey!); changeStringListToIntList(publicKey!);
@ -163,6 +172,7 @@ class DoorLockLogLogic extends BaseGetXController {
/// ///
StreamSubscription? _getDoorLockLogListRefreshUIEvent; StreamSubscription? _getDoorLockLogListRefreshUIEvent;
void _getDoorLockLogListRefreshUIAction() { void _getDoorLockLogListRefreshUIAction() {
_getDoorLockLogListRefreshUIEvent = eventBus _getDoorLockLogListRefreshUIEvent = eventBus
.on<DoorLockLogListRefreshUI>() .on<DoorLockLogListRefreshUI>()
@ -195,7 +205,8 @@ class DoorLockLogLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.operateDate = entity.data!.operateDate! ~/ 1000; state.operateDate = entity.data!.operateDate! ~/ 1000;
state.currentDate = entity.data!.currentDate! ~/ 1000; state.currentDate = entity.data!.currentDate! ~/ 1000;
AppLog.log('entity.data!.currentDate!:${entity.data!.currentDate!} currentDate:${state.currentDate}'); AppLog.log(
'entity.data!.currentDate!:${entity.data!.currentDate!} currentDate:${state.currentDate}');
senderReferEventRecordTime(); senderReferEventRecordTime();
} }
} }

View File

@ -1,4 +1,3 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
@ -18,6 +17,7 @@ import 'package:star_lock/widget/permission/permission_dialog.dart';
import '../../../app_settings/app_settings.dart'; import '../../../app_settings/app_settings.dart';
import '../../../blue/blue_manage.dart'; import '../../../blue/blue_manage.dart';
import '../../../blue/io_protocol/io_openLock.dart'; import '../../../blue/io_protocol/io_openLock.dart';
import '../../../blue/io_protocol/io_referEventRecordTime.dart';
import '../../../blue/io_reply.dart'; import '../../../blue/io_reply.dart';
import '../../../blue/io_tool/io_tool.dart'; import '../../../blue/io_tool/io_tool.dart';
import '../../../blue/io_tool/manager_event_bus.dart'; import '../../../blue/io_tool/manager_event_bus.dart';
@ -28,6 +28,7 @@ import '../../../tools/commonDataManage.dart';
import '../../../tools/eventBusEventManage.dart'; import '../../../tools/eventBusEventManage.dart';
import '../../../tools/storage.dart'; import '../../../tools/storage.dart';
import '../lockOperatingRecord/keyOperationRecord_entity.dart'; import '../lockOperatingRecord/keyOperationRecord_entity.dart';
import '../lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart';
import '../lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_entity.dart'; import '../lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_entity.dart';
import 'lockDetail_state.dart'; import 'lockDetail_state.dart';
import 'lockNetToken_entity.dart'; import 'lockNetToken_entity.dart';
@ -41,17 +42,18 @@ class LockDetailLogic extends BaseGetXController {
// //
void initReplySubscription() { void initReplySubscription() {
state.replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async { state.replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
// //
if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) { if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) {
_replyOpenLock(reply); _replyOpenLock(reply);
} }
// //
// if (reply is SenderReferEventRecordTimeReply && if (reply is SenderReferEventRecordTimeReply &&
// state.ifCurrentScreen.value == true) { state.ifCurrentScreen.value == true) {
// _replyReferEventRecordTime(reply); _replyReferEventRecordTime(reply);
// } }
}); });
} }
@ -94,7 +96,7 @@ class LockDetailLogic extends BaseGetXController {
state.animationController!.stop(); state.animationController!.stop();
// //
// getLockRecordLastUploadDataTime(); getLockRecordLastUploadDataTime();
break; break;
case 0x06: case 0x06:
// //
@ -177,7 +179,9 @@ class LockDetailLogic extends BaseGetXController {
} }
} }
Future<void> loadData({ required LockListInfoItemEntity lockListInfoItemEntity,required bool isOnlyOneData}) async { Future<void> loadData(
{required LockListInfoItemEntity lockListInfoItemEntity,
required bool isOnlyOneData}) async {
state.keyInfos.value = lockListInfoItemEntity; state.keyInfos.value = lockListInfoItemEntity;
CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!; CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!;
CommonDataManage().initUserNo = state.keyInfos.value.initUserNo!; CommonDataManage().initUserNo = state.keyInfos.value.initUserNo!;
@ -185,7 +189,8 @@ class LockDetailLogic extends BaseGetXController {
state.lockUserNo = state.keyInfos.value.lockUserNo!; state.lockUserNo = state.keyInfos.value.lockUserNo!;
if (state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusWaitIneffective || if (state.keyInfos.value.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted ||
@ -201,37 +206,37 @@ class LockDetailLogic extends BaseGetXController {
state.senderUserId = state.keyInfos.value.senderUserId!; state.senderUserId = state.keyInfos.value.senderUserId!;
state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!; state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!;
state.isOpenLockNeedOnline.value = state.isOpenLockNeedOnline.value =
state.keyInfos.value.lockSetting!.appUnlockOnline!; state.keyInfos.value.lockSetting!.appUnlockOnline!;
state.electricQuantity.value = state.keyInfos.value.electricQuantity!; state.electricQuantity.value = state.keyInfos.value.electricQuantity!;
state.isOpenPassageMode.value = state.keyInfos.value.passageMode!; state.isOpenPassageMode.value = state.keyInfos.value.passageMode!;
state.lockAlias.value = state.keyInfos.value.lockAlias!; state.lockAlias.value = state.keyInfos.value.lockAlias!;
Storage.setString(saveLockAlias, state.lockAlias.value); Storage.setString(saveLockAlias, state.lockAlias.value);
BlueManage().connectDeviceName = BlueManage().connectDeviceName =
state.keyInfos.value.bluetooth!.bluetoothDeviceName!; state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
final List<int> publicKeyData = final List<int> publicKeyData =
state.keyInfos.value.bluetooth!.publicKey!.cast<int>(); state.keyInfos.value.bluetooth!.publicKey!.cast<int>();
final List<String> saveStrList = changeIntListToStringList(publicKeyData); final List<String> saveStrList = changeIntListToStringList(publicKeyData);
Storage.setStringList(saveBluePublicKey, saveStrList); Storage.setStringList(saveBluePublicKey, saveStrList);
// //
final List<int> privateKeyData = final List<int> privateKeyData =
state.keyInfos.value.bluetooth!.privateKey!.cast<int>(); state.keyInfos.value.bluetooth!.privateKey!.cast<int>();
final List<String> savePrivateKeyList = final List<String> savePrivateKeyList =
changeIntListToStringList(privateKeyData); changeIntListToStringList(privateKeyData);
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
// signKey // signKey
final List<int> signKeyData = final List<int> signKeyData =
state.keyInfos.value.bluetooth!.signKey!.cast<int>(); state.keyInfos.value.bluetooth!.signKey!.cast<int>();
final List<String> saveSignKeyList = changeIntListToStringList(signKeyData); final List<String> saveSignKeyList = changeIntListToStringList(signKeyData);
Storage.setStringList(saveBlueSignKey, saveSignKeyList); Storage.setStringList(saveBlueSignKey, saveSignKeyList);
final bool ifHaveKey = await Storage.ifHaveKey(saveBlueToken); final bool ifHaveKey = await Storage.ifHaveKey(saveBlueToken);
if (!ifHaveKey) { if (!ifHaveKey) {
final List<String> saveTokenList = final List<String> saveTokenList =
changeIntListToStringList(<int>[0, 0, 0, 0]); changeIntListToStringList(<int>[0, 0, 0, 0]);
Storage.setStringList(saveBlueToken, saveTokenList); Storage.setStringList(saveBlueToken, saveTokenList);
} }
} }
@ -252,71 +257,77 @@ class LockDetailLogic extends BaseGetXController {
} }
// //
// Future<void> _replyReferEventRecordTime(Reply reply) async { Future<void> _replyReferEventRecordTime(Reply reply) async {
// final int status = reply.data[2]; final int status = reply.data[2];
// switch (status) { switch (status) {
// case 0x00: case 0x00:
// // //
// final int dataLength = (reply.data[5] << 8) + reply.data[6]; final int dataLength = (reply.data[5] << 8) + reply.data[6];
// AppLog.log('dataLength:$dataLength'); AppLog.log('dataLength:$dataLength');
// if (dataLength > 0) { if (dataLength > 0) {
// reply.data.removeRange(0, 7); reply.data.removeRange(0, 7);
// // 17 // 17
// if (reply.data.length < 17) { if (reply.data.length < 17) {
// return; return;
// } }
// final List<List<int>> getList = splitList(reply.data, 17); final List<List<int>> getList = splitList(reply.data, 17);
// AppLog.log('getList:$getList'); AppLog.log('getList:$getList');
// final List uploadList = []; final List uploadList = [];
// for (int i = 0; i < getList.length; i++) { for (int i = 0; i < getList.length; i++) {
// final List<int> indexList = getList[i]; final List<int> indexList = getList[i];
// AppLog.log('indexList:$indexList'); AppLog.log('indexList:$indexList');
// final Map indexMap = {}; final Map indexMap = {};
// indexMap['type'] = indexList[0].toString(); indexMap['type'] = indexList[0].toString();
// int operateDate = 0; int operateDate = 0;
// // if (indexList[0] == 2) { // if (indexList[0] == 2) {
// final List<int> passwordData = indexList.sublist(7, 17); final List<int> passwordData = indexList.sublist(7, 17);
// final String password = utf8String(passwordData); final String password = utf8String(passwordData);
// AppLog.log('passwordData:$passwordData password:$password'); AppLog.log('passwordData:$passwordData password:$password');
// indexMap['user'] = password.toString(); indexMap['user'] = password.toString();
// // } else { // } else {
// // final int userNo = (indexList[1] * 256) + indexList[2]; // final int userNo = (indexList[1] * 256) + indexList[2];
// // indexMap['user'] = userNo.toString(); // indexMap['user'] = userNo.toString();
// // } // }
//
// indexMap['success'] = '1'; indexMap['success'] = '1';
//
// final int time = (0xff & indexList[3]) << 24 | final int time = (0xff & indexList[3]) << 24 |
// (0xff & indexList[4]) << 16 | (0xff & indexList[4]) << 16 |
// (0xff & indexList[5]) << 8 | (0xff & indexList[5]) << 8 |
// (0xFF & indexList[6]); (0xFF & indexList[6]);
// operateDate = time * 1000; operateDate = time * 1000;
// indexMap['date'] = '$operateDate'; if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(
// uploadList.add(indexMap); DateTime.fromMillisecondsSinceEpoch(getUTCNetTime() * 1000))) {
// continue;
// if (i == getList.length - 1) { }
// //
// state.operateDate = operateDate; indexMap['date'] = '$operateDate';
// } uploadList.add(indexMap);
// }
// lockRecordUploadData(uploadList); if (i == getList.length - 1) {
// //
// if (dataLength == state.logCountPage) {
// senderReferEventRecordTime(); state.operateDate = operateDate;
// } else { }
// await blueManageDisconnect(); }
// } lockRecordUploadData(uploadList);
// }
// break; if (dataLength == state.logCountPage) {
// case 0x06: senderReferEventRecordTime();
// // } else {
// blueManageDisconnect(); await blueManageDisconnect();
// break; }
// default: }
// blueManageDisconnect(); break;
// break; case 0x06:
// } //
// } blueManageDisconnect();
break;
default:
blueManageDisconnect();
break;
}
}
// //
Future<void> openDoorAction() async { Future<void> openDoorAction() async {
@ -372,42 +383,43 @@ class LockDetailLogic extends BaseGetXController {
} }
// () // ()
// void senderReferEventRecordTime() { void senderReferEventRecordTime() {
// showBlueConnetctToastTimer( showBlueConnetctToastTimer(
// isShowBlueConnetctToast: false, isShowBlueConnetctToast: false,
// action: () { action: () {
// blueManageDisconnect(); blueManageDisconnect();
// }); });
// BlueManage().blueSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
// (BluetoothConnectionState connectionState) async { (BluetoothConnectionState connectionState) async {
// if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
// final List<String>? privateKey = final List<String>? privateKey =
// await Storage.getStringList(saveBluePrivateKey); await Storage.getStringList(saveBluePrivateKey);
// final List<int> getPrivateKeyList = final List<int> getPrivateKeyList =
// changeStringListToIntList(privateKey!); changeStringListToIntList(privateKey!);
//
// final List<String>? token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
// final List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
//
// final List<String>? publicKey = final List<String>? publicKey =
// await Storage.getStringList(saveBluePublicKey); await Storage.getStringList(saveBluePublicKey);
// final List<int> getPublicKeyList = final List<int> getPublicKeyList =
// changeStringListToIntList(publicKey!); changeStringListToIntList(publicKey!);
//
// IoSenderManage.senderReferEventRecordTimeCommand( IoSenderManage.senderReferEventRecordTimeCommand(
// keyID: BlueManage().connectDeviceName, keyID: BlueManage().connectDeviceName,
// userID: await Storage.getUid(), userID: await Storage.getUid(),
// logsCount: state.logCountPage, logsCount: state.logCountPage,
// // time:DateTime.now().millisecondsSinceEpoch~/1000, // time:DateTime.now().millisecondsSinceEpoch~/1000,
// time: state.operateDate, time: state.operateDate,
// token: getTokenList, currentDate: state.currentDate,
// needAuthor: 1, token: getTokenList,
// publicKey: getPublicKeyList, needAuthor: 1,
// privateKey: getPrivateKeyList, publicKey: getPublicKeyList,
// ); privateKey: getPrivateKeyList,
// } );
// }); }
// } });
}
// //
Future<void> getServerDatetime() async { Future<void> getServerDatetime() async {
@ -465,15 +477,16 @@ class LockDetailLogic extends BaseGetXController {
} }
// //
// Future<void> getLockRecordLastUploadDataTime() async { Future<void> getLockRecordLastUploadDataTime() async {
// final LockOperatingRecordGetLastRecordTimeEntity entity = final LockOperatingRecordGetLastRecordTimeEntity entity =
// await ApiRepository.to.getLockRecordLastUploadDataTime( await ApiRepository.to.getLockRecordLastUploadDataTime(
// lockId: state.keyInfos.value.lockId.toString()); lockId: state.keyInfos.value.lockId.toString());
// if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
// state.operateDate = entity.data!.operateDate! ~/ 1000; state.operateDate = entity.data!.operateDate! ~/ 1000;
// senderReferEventRecordTime(); state.currentDate = entity.data!.currentDate! ~/ 1000;
// } senderReferEventRecordTime();
// } }
}
// //
Future<void> lockRecordUploadData(List list) async { Future<void> lockRecordUploadData(List list) async {
@ -493,13 +506,14 @@ class LockDetailLogic extends BaseGetXController {
// //
Future<void> lockReportLockSuccessfullyUploadData() async { Future<void> lockReportLockSuccessfullyUploadData() async {
final KeyOperationRecordEntity entity = await ApiRepository.to.lockReportLockSuccessfullyUploadData( final KeyOperationRecordEntity entity = await ApiRepository.to
lockId: state.keyInfos.value.lockId ?? 0, .lockReportLockSuccessfullyUploadData(
keyId: state.keyInfos.value.keyId ?? 0 lockId: state.keyInfos.value.lockId ?? 0,
); keyId: state.keyInfos.value.keyId ?? 0);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
// mockNetworkDataRequest(); // mockNetworkDataRequest();
AppLog.log('state.keyInfos.value.keyType:${state.keyInfos.value.keyType}'); AppLog.log(
'state.keyInfos.value.keyType:${state.keyInfos.value.keyType}');
if (state.keyInfos.value.keyType == XSConstantMacro.keyTypeOnce) { if (state.keyInfos.value.keyType == XSConstantMacro.keyTypeOnce) {
// //
deletKeyData(); deletKeyData();
@ -608,7 +622,6 @@ class LockDetailLogic extends BaseGetXController {
getServerDatetime(); getServerDatetime();
await PermissionDialog.request(Permission.location); await PermissionDialog.request(Permission.location);
await PermissionDialog.requestBluetooth(); await PermissionDialog.requestBluetooth();
} }
@override @override

View File

@ -50,6 +50,8 @@ class LockDetailState {
RxInt currentPage = 0.obs; RxInt currentPage = 0.obs;
int operateDate = 0; // int operateDate = 0; //
int currentDate = 0; // UTC毫秒时间戳
int logCountPage = 10; // int logCountPage = 10; //
RxInt nextAuthTime = 0.obs; // RxInt nextAuthTime = 0.obs; //

View File

@ -22,8 +22,10 @@ class LockOperatingRecordLogic extends BaseGetXController {
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) { _replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
if (reply is SenderReferEventRecordTimeReply) { if (reply is SenderReferEventRecordTimeReply) {
_replyReferEventRecordTime(reply); _replyReferEventRecordTime(reply);
} }
@ -31,12 +33,12 @@ class LockOperatingRecordLogic extends BaseGetXController {
} }
// //
Future<void> _replyReferEventRecordTime(Reply reply) async { Future<void> _replyReferEventRecordTime(Reply reply) async {
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
final int status = reply.data[2]; final int status = reply.data[2];
switch (status) { switch (status) {
case 0x00: case 0x00:
// //
final int dataLength = (reply.data[5] << 8) + reply.data[6]; final int dataLength = (reply.data[5] << 8) + reply.data[6];
AppLog.log('dataLength:$dataLength'); AppLog.log('dataLength:$dataLength');
// var dataLength = reply.data[5]; // var dataLength = reply.data[5];
@ -56,7 +58,6 @@ class LockOperatingRecordLogic extends BaseGetXController {
indexMap['type'] = indexList[0].toString(); indexMap['type'] = indexList[0].toString();
final int userNo = (indexList[1] * 256) + indexList[2]; final int userNo = (indexList[1] * 256) + indexList[2];
indexMap['user'] = userNo.toString(); indexMap['user'] = userNo.toString();
AppLog.log('userNouserNouserNouserNo:$userNo'); AppLog.log('userNouserNouserNouserNo:$userNo');
@ -69,10 +70,15 @@ class LockOperatingRecordLogic extends BaseGetXController {
indexMap['success'] = '1'; indexMap['success'] = '1';
final int time = (0xff & indexList[3]) << 24 | final int time = (0xff & indexList[3]) << 24 |
(0xff & indexList[4]) << 16 | (0xff & indexList[4]) << 16 |
(0xff & indexList[5]) << 8 | (0xff & indexList[5]) << 8 |
(0xFF & indexList[6]); (0xFF & indexList[6]);
indexMap['date'] = '${time * 1000}'; final operateDate = time * 1000;
if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(
DateTime.fromMillisecondsSinceEpoch(state.currentDate))) {
continue;
}
indexMap['date'] = '$operateDate';
uploadList.add(indexMap); uploadList.add(indexMap);
} }
if (dataLength == state.logCountPage) { if (dataLength == state.logCountPage) {
@ -84,11 +90,11 @@ class LockOperatingRecordLogic extends BaseGetXController {
} }
break; break;
case 0x06: case 0x06:
// //
break; break;
default: default:
// //
break; break;
} }
} }
@ -96,19 +102,24 @@ class LockOperatingRecordLogic extends BaseGetXController {
// () // ()
Future<void> senderReferEventRecordTime() async { Future<void> senderReferEventRecordTime() async {
showEasyLoading(); showEasyLoading();
showBlueConnetctToastTimer(action: (){ showBlueConnetctToastTimer(action: () {
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async { BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionStateState) async {
if (connectionStateState == BluetoothConnectionState.connected) { if (connectionStateState == BluetoothConnectionState.connected) {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey =
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
final List<String>? token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
final List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
final List<String>? publicKey = await Storage.getStringList(saveBluePublicKey); final List<String>? publicKey =
final List<int> getPublicKeyList = changeStringListToIntList(publicKey!); await Storage.getStringList(saveBluePublicKey);
final List<int> getPublicKeyList =
changeStringListToIntList(publicKey!);
IoSenderManage.senderReferEventRecordTimeCommand( IoSenderManage.senderReferEventRecordTimeCommand(
keyID: BlueManage().connectDeviceName, keyID: BlueManage().connectDeviceName,
@ -122,10 +133,11 @@ class LockOperatingRecordLogic extends BaseGetXController {
publicKey: getPublicKeyList, publicKey: getPublicKeyList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
); );
} else if (connectionStateState == BluetoothConnectionState.disconnected) { } else if (connectionStateState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading(); dismissEasyLoading();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
if(state.ifCurrentScreen.value == true){ if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast(); showBlueConnetctToast();
} }
} }
@ -134,29 +146,31 @@ class LockOperatingRecordLogic extends BaseGetXController {
// //
Future<KeyOperationRecordEntity> mockNetworkDataRequest() async { Future<KeyOperationRecordEntity> mockNetworkDataRequest() async {
final KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordList( final KeyOperationRecordEntity entity =
lockId:CommonDataManage().currentKeyInfo.lockId.toString(), await ApiRepository.to.lockRecordList(
pageNo:pageNo.toString(), lockId: CommonDataManage().currentKeyInfo.lockId.toString(),
recordType:'', pageNo: pageNo.toString(),
searchStr:'', recordType: '',
startDate:'', searchStr: '',
endDate:'', startDate: '',
keyboardPwdId: state.type == 1 ? state.idStr : '', endDate: '',
cardId: state.type == 2 ? state.idStr : '', keyboardPwdId: state.type == 1 ? state.idStr : '',
fingerprintId: state.type == 3 ? state.idStr : '', cardId: state.type == 2 ? state.idStr : '',
keyId: state.type == 5 ? state.idStr : '', fingerprintId: state.type == 3 ? state.idStr : '',
faceId: state.type == 4 ? state.idStr : '', keyId: state.type == 5 ? state.idStr : '',
remoteId:state.type == 6 ? state.idStr : '', faceId: state.type == 4 ? state.idStr : '',
palmVeinId:state.type == 7 ? state.idStr : '', remoteId: state.type == 6 ? state.idStr : '',
pageSize:pageSize, palmVeinId: state.type == 7 ? state.idStr : '',
); pageSize: pageSize,
);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
if (pageNo == 1) { if (pageNo == 1) {
state.lockOperatingRecordListData.value = entity.data!.itemList!; state.lockOperatingRecordListData.value = entity.data!.itemList!;
pageNo++; pageNo++;
} else { } else {
if (entity.data!.itemList!.isNotEmpty) { if (entity.data!.itemList!.isNotEmpty) {
state.lockOperatingRecordListData.value.addAll(entity.data!.itemList!); state.lockOperatingRecordListData.value
.addAll(entity.data!.itemList!);
pageNo++; pageNo++;
} }
} }
@ -166,9 +180,9 @@ class LockOperatingRecordLogic extends BaseGetXController {
// //
Future<void> getLockRecordLastUploadDataTime() async { Future<void> getLockRecordLastUploadDataTime() async {
final LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to final LockOperatingRecordGetLastRecordTimeEntity entity =
.getLockRecordLastUploadDataTime( await ApiRepository.to.getLockRecordLastUploadDataTime(
lockId: CommonDataManage().currentKeyInfo.lockId.toString()); lockId: CommonDataManage().currentKeyInfo.lockId.toString());
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.operateDate = entity.data!.operateDate! ~/ 1000; state.operateDate = entity.data!.operateDate! ~/ 1000;
state.currentDate = entity.data!.currentDate! ~/ 1000; state.currentDate = entity.data!.currentDate! ~/ 1000;
@ -179,11 +193,13 @@ class LockOperatingRecordLogic extends BaseGetXController {
// //
Future<void> lockRecordUploadData(List list) async { Future<void> lockRecordUploadData(List list) async {
final KeyOperationRecordEntity entity = await ApiRepository.to final KeyOperationRecordEntity entity = await ApiRepository.to
.lockRecordUploadData(lockId: CommonDataManage().currentKeyInfo.lockId.toString(), records: list); .lockRecordUploadData(
lockId: CommonDataManage().currentKeyInfo.lockId.toString(),
records: list);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
if(state.ifHaveNext == true){ if (state.ifHaveNext == true) {
getLockRecordLastUploadDataTime(); getLockRecordLastUploadDataTime();
}else{ } else {
pageNo = 1; pageNo = 1;
mockNetworkDataRequest(); mockNetworkDataRequest();
} }
@ -192,9 +208,11 @@ class LockOperatingRecordLogic extends BaseGetXController {
// //
Future<void> clearOperationRecordRequest() async { Future<void> clearOperationRecordRequest() async {
final KeyOperationRecordEntity entity = await ApiRepository.to.clearOperationRecord(CommonDataManage().currentKeyInfo.lockId.toString()); final KeyOperationRecordEntity entity = await ApiRepository.to
.clearOperationRecord(
CommonDataManage().currentKeyInfo.lockId.toString());
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast('清除数据成功', something: (){ showToast('清除数据成功', something: () {
pageNo = 1; pageNo = 1;
mockNetworkDataRequest(); mockNetworkDataRequest();
}); });