添加开锁之后数据上传
This commit is contained in:
parent
3b9e2b1224
commit
e494bbf2c7
@ -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 {
|
||||||
|
|||||||
@ -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; // 下次认证时间
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user