fix: 1、取消锁详情进入操作记录界面就从锁上面拉取记录功能。2、修复操作记录频繁调用接口bug
This commit is contained in:
parent
ad0c0a2e5f
commit
ab1ab37cbd
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:star_lock/app_settings/app_settings.dart';
|
import 'package:star_lock/app_settings/app_settings.dart';
|
||||||
|
|
||||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||||
@ -47,6 +48,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
upload: true
|
upload: true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
state.isLockReceiveResponse = true;
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
final int status = reply.data[2];
|
final int status = reply.data[2];
|
||||||
|
|
||||||
@ -86,8 +88,8 @@ 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]);
|
||||||
final operateDate = time * 1000;
|
final int operateDate = time * 1000;
|
||||||
final serverTime = state.currentDate;
|
final int serverTime = state.currentDate;
|
||||||
if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(
|
if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(
|
||||||
DateTime.fromMillisecondsSinceEpoch(serverTime*1000))) {
|
DateTime.fromMillisecondsSinceEpoch(serverTime*1000))) {
|
||||||
// AppLog.log('operateDate:$operateDate state.currentDate:${state.currentDate}');
|
// AppLog.log('operateDate:$operateDate state.currentDate:${state.currentDate}');
|
||||||
@ -110,6 +112,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//失败
|
//失败
|
||||||
|
dismissEasyLoading();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +141,8 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
).toString();
|
).toString();
|
||||||
|
|
||||||
showBlueConnetctToastTimer(isShowBlueConnetctToast:false, action: () async {
|
showEasyLoading();
|
||||||
|
showBlueConnetctToastTimer(isShowBlueConnetctToast:true, action: () async {
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
|
|
||||||
final String getMobile = (await Storage.getMobile())!;
|
final String getMobile = (await Storage.getMobile())!;
|
||||||
@ -155,6 +159,9 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
eventStr: '查询锁记录事件超时',
|
eventStr: '查询锁记录事件超时',
|
||||||
upload: true
|
upload: true
|
||||||
);
|
);
|
||||||
|
if(state.isLockReceiveResponse == false){
|
||||||
|
dismissEasyLoading();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async {
|
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async {
|
||||||
if (connectionStateState == BluetoothConnectionState.connected) {
|
if (connectionStateState == BluetoothConnectionState.connected) {
|
||||||
@ -180,6 +187,9 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
} else if (connectionStateState == BluetoothConnectionState.disconnected) {
|
} else if (connectionStateState == BluetoothConnectionState.disconnected) {
|
||||||
|
if (state.ifCurrentScreen.value == true) {
|
||||||
|
showBlueConnetctToast();
|
||||||
|
}
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
|
|
||||||
final String getMobile = (await Storage.getMobile())!;
|
final String getMobile = (await Storage.getMobile())!;
|
||||||
@ -225,19 +235,18 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
|
|
||||||
/// 刷新门锁日志列表
|
/// 刷新门锁日志列表
|
||||||
StreamSubscription? _getDoorLockLogListRefreshUIEvent;
|
StreamSubscription? _getDoorLockLogListRefreshUIEvent;
|
||||||
|
|
||||||
void _getDoorLockLogListRefreshUIAction() {
|
void _getDoorLockLogListRefreshUIAction() {
|
||||||
_getDoorLockLogListRefreshUIEvent = eventBus
|
_getDoorLockLogListRefreshUIEvent = eventBus.on<DoorLockLogListRefreshUI>().listen((DoorLockLogListRefreshUI event) {
|
||||||
.on<DoorLockLogListRefreshUI>()
|
|
||||||
.listen((DoorLockLogListRefreshUI event) {
|
|
||||||
state.currentSelectDate.value = event.getDoorLockLogTime;
|
state.currentSelectDate.value = event.getDoorLockLogTime;
|
||||||
// 设置startDate为当天的0点
|
|
||||||
|
// 设置startDate为当天的0点
|
||||||
state.startDate.value = DateTime(
|
state.startDate.value = DateTime(
|
||||||
state.currentSelectDate.value.year,
|
state.currentSelectDate.value.year,
|
||||||
state.currentSelectDate.value.month,
|
state.currentSelectDate.value.month,
|
||||||
state.currentSelectDate.value.day)
|
state.currentSelectDate.value.day)
|
||||||
.millisecondsSinceEpoch;
|
.millisecondsSinceEpoch;
|
||||||
// 设置endDate为下一天的0点,然后减去1毫秒
|
|
||||||
|
// 设置endDate为下一天的0点,然后减去1毫秒
|
||||||
state.endDate.value = DateTime(
|
state.endDate.value = DateTime(
|
||||||
state.currentSelectDate.value.year,
|
state.currentSelectDate.value.year,
|
||||||
state.currentSelectDate.value.month,
|
state.currentSelectDate.value.month,
|
||||||
@ -246,7 +255,6 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
.millisecondsSinceEpoch;
|
.millisecondsSinceEpoch;
|
||||||
|
|
||||||
pageNo = 1;
|
pageNo = 1;
|
||||||
AppLog.log('_getDoorLockLogListRefreshUIAction');
|
|
||||||
mockNetworkDataRequest(isRefresh: true);
|
mockNetworkDataRequest(isRefresh: true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -275,6 +283,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
final String getMobile = (await Storage.getMobile())!;
|
final String getMobile = (await Storage.getMobile())!;
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
if (state.ifHaveNext == true) {
|
if (state.ifHaveNext == true) {
|
||||||
|
showEasyLoading();
|
||||||
getLockRecordLastUploadDataTime();
|
getLockRecordLastUploadDataTime();
|
||||||
} else {
|
} else {
|
||||||
UmengCommonSdk.onEvent('check_doorLockLog', {
|
UmengCommonSdk.onEvent('check_doorLockLog', {
|
||||||
@ -285,6 +294,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
});
|
});
|
||||||
mockNetworkDataRequest(isRefresh: true);
|
mockNetworkDataRequest(isRefresh: true);
|
||||||
}
|
}
|
||||||
|
dismissEasyLoading();
|
||||||
}else{
|
}else{
|
||||||
UmengCommonSdk.onEvent('check_doorLockLog', {
|
UmengCommonSdk.onEvent('check_doorLockLog', {
|
||||||
'lockName':state.keyInfos.value.lockName!,
|
'lockName':state.keyInfos.value.lockName!,
|
||||||
@ -292,6 +302,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
'date':DateTool().getNowDateWithType(1),
|
'date':DateTool().getNowDateWithType(1),
|
||||||
'open_lock_result':'上传数据接口失败',
|
'open_lock_result':'上传数据接口失败',
|
||||||
});
|
});
|
||||||
|
dismissEasyLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +342,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
if (isDemoMode == false) {
|
if (isDemoMode == false) {
|
||||||
mockNetworkDataRequest(isRefresh: true);
|
mockNetworkDataRequest(isRefresh: true);
|
||||||
|
|
||||||
getLockRecordLastUploadDataTime();
|
// getLockRecordLastUploadDataTime();
|
||||||
_initReplySubscription();
|
_initReplySubscription();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
@ -19,7 +20,6 @@ import 'package:timelines/timelines.dart';
|
|||||||
import '../../../app_settings/app_colors.dart';
|
import '../../../app_settings/app_colors.dart';
|
||||||
import '../../../tools/appRouteObserver.dart';
|
import '../../../tools/appRouteObserver.dart';
|
||||||
import '../../../tools/titleAppBar.dart';
|
import '../../../tools/titleAppBar.dart';
|
||||||
import '../../../translations/trans_lib.dart';
|
|
||||||
|
|
||||||
class DoorLockLogPage extends StatefulWidget {
|
class DoorLockLogPage extends StatefulWidget {
|
||||||
const DoorLockLogPage({Key? key}) : super(key: key);
|
const DoorLockLogPage({Key? key}) : super(key: key);
|
||||||
@ -88,7 +88,7 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
|||||||
body: Column(
|
body: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: <Widget>[
|
||||||
topAdvancedCalendarWidget(),
|
topAdvancedCalendarWidget(),
|
||||||
Divider(
|
Divider(
|
||||||
height: 1,
|
height: 1,
|
||||||
@ -124,6 +124,7 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
|||||||
switch (value) {
|
switch (value) {
|
||||||
case '读取记录':
|
case '读取记录':
|
||||||
{
|
{
|
||||||
|
state.isLockReceiveResponse = false;
|
||||||
logic.getLockRecordLastUploadDataTime();
|
logic.getLockRecordLastUploadDataTime();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -177,7 +178,7 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
|||||||
disabledColor: Colors.grey,
|
disabledColor: Colors.grey,
|
||||||
),
|
),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: <Widget>[
|
||||||
AdvancedCalendar(
|
AdvancedCalendar(
|
||||||
controller: state.calendarControllerCustom,
|
controller: state.calendarControllerCustom,
|
||||||
events: state.events,
|
events: state.events,
|
||||||
@ -338,7 +339,6 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
// TODO: implement didChangeDependencies
|
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
|
|
||||||
/// 路由订阅
|
/// 路由订阅
|
||||||
@ -347,7 +347,6 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
// TODO: implement dispose
|
|
||||||
/// 取消路由订阅
|
/// 取消路由订阅
|
||||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@ -365,7 +364,9 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
|||||||
void didPop() {
|
void didPop() {
|
||||||
super.didPop();
|
super.didPop();
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.cancelBlueConnetctToastTimer();
|
||||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
if (EasyLoading.isShow) {
|
||||||
|
EasyLoading.dismiss(animation: true);
|
||||||
|
}
|
||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -67,4 +67,5 @@ class DoorLockLogState {
|
|||||||
bool ifHaveNext = false; // 页码
|
bool ifHaveNext = false; // 页码
|
||||||
int logCountPage = 10; // 蓝牙记录一页多少个
|
int logCountPage = 10; // 蓝牙记录一页多少个
|
||||||
Rx<DateTime> currentSelectDate = DateTime.now().obs;
|
Rx<DateTime> currentSelectDate = DateTime.now().obs;
|
||||||
|
bool isLockReceiveResponse = false; // 是否收到回复
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,129 +21,129 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
LockOperatingRecordState state = LockOperatingRecordState();
|
LockOperatingRecordState state = LockOperatingRecordState();
|
||||||
|
|
||||||
// 获取解析后的数据
|
// 获取解析后的数据
|
||||||
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) {
|
||||||
if (reply is SenderReferEventRecordTimeReply) {
|
// if (reply is SenderReferEventRecordTimeReply) {
|
||||||
_replyReferEventRecordTime(reply);
|
// _replyReferEventRecordTime(reply);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 根据时间查解析数据
|
// 根据时间查解析数据
|
||||||
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];
|
||||||
if (dataLength > 0) {
|
// if (dataLength > 0) {
|
||||||
reply.data.removeRange(0, 7);
|
// reply.data.removeRange(0, 7);
|
||||||
// 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
// // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
||||||
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();
|
||||||
|
//
|
||||||
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');
|
||||||
|
//
|
||||||
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);
|
||||||
indexMap['password'] = password.toString();
|
// indexMap['password'] = password.toString();
|
||||||
AppLog.log('passwordpasswordpassword:$password');
|
// AppLog.log('passwordpasswordpassword:$password');
|
||||||
|
//
|
||||||
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]);
|
||||||
final operateDate = time * 1000;
|
// final operateDate = time * 1000;
|
||||||
final serverTime = state.currentDate;
|
// final serverTime = state.currentDate;
|
||||||
if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(
|
// if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(
|
||||||
DateTime.fromMillisecondsSinceEpoch(serverTime*1000))) {
|
// DateTime.fromMillisecondsSinceEpoch(serverTime*1000))) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
indexMap['date'] = '$operateDate';
|
// indexMap['date'] = '$operateDate';
|
||||||
uploadList.add(indexMap);
|
// uploadList.add(indexMap);
|
||||||
}
|
// }
|
||||||
if (dataLength == state.logCountPage) {
|
// if (dataLength == state.logCountPage) {
|
||||||
state.ifHaveNext = true;
|
// state.ifHaveNext = true;
|
||||||
} else {
|
// } else {
|
||||||
state.ifHaveNext = false;
|
// state.ifHaveNext = false;
|
||||||
}
|
// }
|
||||||
lockRecordUploadData(uploadList);
|
// lockRecordUploadData(uploadList);
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
case 0x06:
|
// case 0x06:
|
||||||
//无权限 需要鉴权
|
// //无权限 需要鉴权
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
//失败
|
// //失败
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 查询事件记录(时间查询)
|
// 查询事件记录(时间查询)
|
||||||
Future<void> senderReferEventRecordTime() async {
|
// Future<void> senderReferEventRecordTime() async {
|
||||||
showEasyLoading();
|
// showEasyLoading();
|
||||||
showBlueConnetctToastTimer(action: () {
|
// showBlueConnetctToastTimer(action: () {
|
||||||
dismissEasyLoading();
|
// dismissEasyLoading();
|
||||||
});
|
// });
|
||||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
// BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||||
(BluetoothConnectionState connectionStateState) async {
|
// (BluetoothConnectionState connectionStateState) async {
|
||||||
if (connectionStateState == BluetoothConnectionState.connected) {
|
// if (connectionStateState == 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,
|
||||||
currentDate: state.currentDate,
|
// currentDate: state.currentDate,
|
||||||
token: getTokenList,
|
// token: getTokenList,
|
||||||
needAuthor: 1,
|
// needAuthor: 1,
|
||||||
publicKey: getPublicKeyList,
|
// publicKey: getPublicKeyList,
|
||||||
privateKey: getPrivateKeyList,
|
// privateKey: getPrivateKeyList,
|
||||||
);
|
// );
|
||||||
} else if (connectionStateState ==
|
// } else if (connectionStateState ==
|
||||||
BluetoothConnectionState.disconnected) {
|
// BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
// dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
// cancelBlueConnetctToastTimer();
|
||||||
if (state.ifCurrentScreen.value == true) {
|
// if (state.ifCurrentScreen.value == true) {
|
||||||
showBlueConnetctToast();
|
// showBlueConnetctToast();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
//请求操作记录列表
|
//请求操作记录列表
|
||||||
Future<KeyOperationRecordEntity> mockNetworkDataRequest() async {
|
Future<KeyOperationRecordEntity> mockNetworkDataRequest() async {
|
||||||
@ -180,48 +180,48 @@ class LockOperatingRecordLogic 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: 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;
|
||||||
senderReferEventRecordTime();
|
// senderReferEventRecordTime();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 操作记录上传
|
// 操作记录上传
|
||||||
Future<void> lockRecordUploadData(List list) async {
|
// Future<void> lockRecordUploadData(List list) async {
|
||||||
if(list.isEmpty){
|
// if(list.isEmpty){
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
// final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||||
.lockRecordUploadData(
|
// .lockRecordUploadData(
|
||||||
lockId: CommonDataManage().currentKeyInfo.lockId.toString(),
|
// lockId: CommonDataManage().currentKeyInfo.lockId.toString(),
|
||||||
records: list);
|
// 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();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
//清空操作记录
|
//清空操作记录
|
||||||
Future<void> clearOperationRecordRequest() async {
|
// Future<void> clearOperationRecordRequest() async {
|
||||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
// final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||||
.clearOperationRecord(
|
// .clearOperationRecord(
|
||||||
CommonDataManage().currentKeyInfo.lockId.toString());
|
// CommonDataManage().currentKeyInfo.lockId.toString());
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
// if (entity.errorCode!.codeIsSuccessful) {
|
||||||
showToast('清除数据成功', something: () {
|
// showToast('清除数据成功', something: () {
|
||||||
pageNo = 1;
|
// pageNo = 1;
|
||||||
mockNetworkDataRequest();
|
// mockNetworkDataRequest();
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onReady() async {
|
Future<void> onReady() async {
|
||||||
@ -244,10 +244,10 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
// 获取是否是演示模式 演示模式不获取接口
|
// 获取是否是演示模式 演示模式不获取接口
|
||||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||||
if (isDemoMode == false) {
|
if (isDemoMode == false) {
|
||||||
getLockRecordLastUploadDataTime();
|
// getLockRecordLastUploadDataTime();
|
||||||
// senderReferEventRecordTime();
|
// senderReferEventRecordTime();
|
||||||
// senderReferEventRecordNumber();
|
// senderReferEventRecordNumber();
|
||||||
_initReplySubscription();
|
// _initReplySubscription();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
//获取是否是演示模式 演示模式不获取接口
|
//获取是否是演示模式 演示模式不获取接口
|
||||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||||
if (isDemoMode == false) {
|
if (isDemoMode == false) {
|
||||||
_replySubscription.cancel();
|
// _replySubscription.cancel();
|
||||||
// _getDoorLockLogListRefreshUIEvent?.cancel();
|
// _getDoorLockLogListRefreshUIEvent?.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart';
|
||||||
|
|
||||||
import '../../../app_settings/app_colors.dart';
|
import '../../../app_settings/app_colors.dart';
|
||||||
import '../../../tools/EasyRefreshTool.dart';
|
import '../../../tools/EasyRefreshTool.dart';
|
||||||
@ -25,11 +27,11 @@ class LockOperatingRecordPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with RouteAware{
|
class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with RouteAware{
|
||||||
final logic = Get.put(LockOperatingRecordLogic());
|
final LockOperatingRecordLogic logic = Get.put(LockOperatingRecordLogic());
|
||||||
final state = Get.find<LockOperatingRecordLogic>().state;
|
final LockOperatingRecordState state = Get.find<LockOperatingRecordLogic>().state;
|
||||||
|
|
||||||
Future<void> getHttpData() async {
|
Future<void> getHttpData() async {
|
||||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||||
if (isDemoMode == false) {
|
if (isDemoMode == false) {
|
||||||
logic.mockNetworkDataRequest().then((KeyOperationRecordEntity value){
|
logic.mockNetworkDataRequest().then((KeyOperationRecordEntity value){
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
@ -85,7 +87,7 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
|||||||
getHttpData();
|
getHttpData();
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: <Widget>[
|
||||||
// (CommonDataManage().currentKeyInfo.isLockOwner == 1 ||
|
// (CommonDataManage().currentKeyInfo.isLockOwner == 1 ||
|
||||||
// CommonDataManage().currentKeyInfo.keyRight == 1)
|
// CommonDataManage().currentKeyInfo.keyRight == 1)
|
||||||
// ? Column(
|
// ? Column(
|
||||||
@ -120,13 +122,13 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
|||||||
return Obx(() => state.lockOperatingRecordListData.value.isNotEmpty
|
return Obx(() => state.lockOperatingRecordListData.value.isNotEmpty
|
||||||
? ListView.separated(
|
? ListView.separated(
|
||||||
itemCount: state.lockOperatingRecordListData.length,
|
itemCount: state.lockOperatingRecordListData.length,
|
||||||
itemBuilder: (c, index) {
|
itemBuilder: (BuildContext c, int index) {
|
||||||
KeyRecordDataItem dataItem =
|
final KeyRecordDataItem dataItem =
|
||||||
state.lockOperatingRecordListData[index];
|
state.lockOperatingRecordListData[index];
|
||||||
int? operateDate = dataItem.operateDate;
|
final int? operateDate = dataItem.operateDate;
|
||||||
DateTime dateStr =
|
final DateTime dateStr =
|
||||||
DateTime.fromMillisecondsSinceEpoch(operateDate!);
|
DateTime.fromMillisecondsSinceEpoch(operateDate!);
|
||||||
String operateDateStr =
|
final String operateDateStr =
|
||||||
'${dateStr.toLocal().toString().substring(0, 16)} ';
|
'${dateStr.toLocal().toString().substring(0, 16)} ';
|
||||||
// return _operatingRecordItem(getTypeIcon(dataItem.recordType!),
|
// return _operatingRecordItem(getTypeIcon(dataItem.recordType!),
|
||||||
// dataItem.recordTypeName!, operateDateStr, () {});
|
// dataItem.recordTypeName!, operateDateStr, () {});
|
||||||
@ -181,7 +183,7 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
|||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: <Widget>[
|
||||||
Icon(Icons.access_time, size: 35.w),
|
Icon(Icons.access_time, size: 35.w),
|
||||||
SizedBox(width: 10.w,),
|
SizedBox(width: 10.w,),
|
||||||
Text(
|
Text(
|
||||||
@ -196,7 +198,7 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
|||||||
child:Container(
|
child:Container(
|
||||||
margin: EdgeInsets.only(bottom: 3.w),
|
margin: EdgeInsets.only(bottom: 3.w),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: <Widget>[
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
userNameStr,
|
userNameStr,
|
||||||
@ -273,43 +275,40 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
|||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Future _openModalBottomSheet() async {
|
// Future _openModalBottomSheet() async {
|
||||||
showModalBottomSheet(
|
// showModalBottomSheet(
|
||||||
context: context,
|
// context: context,
|
||||||
shape: RoundedRectangleBorder(
|
// shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadiusDirectional.circular(10)),
|
// borderRadius: BorderRadiusDirectional.circular(10)),
|
||||||
builder: (BuildContext context) {
|
// builder: (BuildContext context) {
|
||||||
return AlertBottomWidget(
|
// return AlertBottomWidget(
|
||||||
topTitle: '',
|
// topTitle: '',
|
||||||
// items: const ['读取记录', '清空记录', '导出记录'],
|
// // items: const ['读取记录', '清空记录', '导出记录'],
|
||||||
items: const ['清空记录'],
|
// items: const ['清空记录'],
|
||||||
chooseCallback: (value) {
|
// chooseCallback: (value) {
|
||||||
int getSelectIndex = value;
|
// int getSelectIndex = value;
|
||||||
// if (getSelectIndex == 0) {
|
// // if (getSelectIndex == 0) {
|
||||||
// logic.mockNetworkDataRequest();
|
// // logic.mockNetworkDataRequest();
|
||||||
// } else if (getSelectIndex == 1) {
|
// // } else if (getSelectIndex == 1) {
|
||||||
// logic.clearOperationRecordRequest();
|
// // logic.clearOperationRecordRequest();
|
||||||
// }
|
// // }
|
||||||
if (getSelectIndex == 0) {
|
// if (getSelectIndex == 0) {
|
||||||
logic.clearOperationRecordRequest();
|
// logic.clearOperationRecordRequest();
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
// TODO: implement didChangeDependencies
|
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
|
|
||||||
/// 路由订阅
|
/// 路由订阅
|
||||||
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
// TODO: implement dispose
|
|
||||||
/// 取消路由订阅
|
/// 取消路由订阅
|
||||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@ -327,7 +326,9 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
|||||||
void didPop() {
|
void didPop() {
|
||||||
super.didPop();
|
super.didPop();
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.cancelBlueConnetctToastTimer();
|
||||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
if (EasyLoading.isShow) {
|
||||||
|
EasyLoading.dismiss(animation: true);
|
||||||
|
}
|
||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +344,9 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> with
|
|||||||
void didPushNext() {
|
void didPushNext() {
|
||||||
super.didPushNext();
|
super.didPushNext();
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.cancelBlueConnetctToastTimer();
|
||||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
if (EasyLoading.isShow) {
|
||||||
|
EasyLoading.dismiss(animation: true);
|
||||||
|
}
|
||||||
state.ifCurrentScreen.value = false;
|
state.ifCurrentScreen.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -232,8 +232,7 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
|
|||||||
child: ValueListenableBuilder<DateTime>(
|
child: ValueListenableBuilder<DateTime>(
|
||||||
valueListenable: _controller,
|
valueListenable: _controller,
|
||||||
builder: (_, selectedDate, __) {
|
builder: (_, selectedDate, __) {
|
||||||
AppLog.log('****selectedDate: $selectedDate');
|
// AppLog.log('****selectedDate: $selectedDate');
|
||||||
eventBus.fire(DoorLockLogListRefreshUI(selectedDate));
|
|
||||||
return Stack(
|
return Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -252,6 +251,7 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
_monthViewCurrentPage.value = pageIndex;
|
_monthViewCurrentPage.value = pageIndex;
|
||||||
|
AppLog.log('调用onPageChanged');
|
||||||
},
|
},
|
||||||
controller: _monthPageController,
|
controller: _monthPageController,
|
||||||
physics: _animationController.value == 1.0
|
physics: _animationController.value == 1.0
|
||||||
@ -389,6 +389,8 @@ class _AdvancedCalendarState extends State<AdvancedCalendar>
|
|||||||
|
|
||||||
void _handleDateChanged(DateTime date) {
|
void _handleDateChanged(DateTime date) {
|
||||||
_controller.value = date;
|
_controller.value = date;
|
||||||
|
AppLog.log('点击日期了');
|
||||||
|
eventBus.fire(DoorLockLogListRefreshUI(date));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleFinishDrag() async {
|
void _handleFinishDrag() async {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user