添加开锁之后数据上传

This commit is contained in:
魏少阳 2024-09-14 16:43:27 +08:00
parent 3b9e2b1224
commit e494bbf2c7
2 changed files with 121 additions and 115 deletions

View File

@ -18,6 +18,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 +29,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';
@ -48,10 +50,10 @@ class LockDetailLogic extends BaseGetXController {
} }
// //
// 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:
// //
@ -252,71 +254,71 @@ 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'; indexMap['date'] = '$operateDate';
// uploadList.add(indexMap); uploadList.add(indexMap);
//
// if (i == getList.length - 1) { if (i == getList.length - 1) {
// // //
// state.operateDate = operateDate; state.operateDate = operateDate;
// } }
// } }
// lockRecordUploadData(uploadList); lockRecordUploadData(uploadList);
//
// if (dataLength == state.logCountPage) { if (dataLength == state.logCountPage) {
// senderReferEventRecordTime(); senderReferEventRecordTime();
// } else { } else {
// await blueManageDisconnect(); await blueManageDisconnect();
// } }
// } }
// break; break;
// case 0x06: case 0x06:
// // //
// blueManageDisconnect(); blueManageDisconnect();
// break; break;
// default: default:
// blueManageDisconnect(); blueManageDisconnect();
// break; break;
// } }
// } }
// //
Future<void> openDoorAction() async { Future<void> openDoorAction() async {
@ -372,42 +374,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 +468,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 {

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; //