diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index ed3e6cdd..5513864a 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -25,6 +25,7 @@ class DoorLockLogLogic extends BaseGetXController { // 获取解析后的数据 late StreamSubscription _replySubscription; + void _initReplySubscription() { _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) { @@ -75,7 +76,12 @@ class DoorLockLogLogic extends BaseGetXController { (0xff & indexList[4]) << 16 | (0xff & indexList[5]) << 8 | (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); } if (dataLength == state.logCountPage) { @@ -102,16 +108,19 @@ class DoorLockLogLogic extends BaseGetXController { showBlueConnetctToastTimer(action: () { dismissEasyLoading(); }); - BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState connectionStateState) async { if (connectionStateState == BluetoothConnectionState.connected) { - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); final List getPrivateKeyList = changeStringListToIntList(privateKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); - final List? publicKey = await Storage.getStringList(saveBluePublicKey); + final List? publicKey = + await Storage.getStringList(saveBluePublicKey); final List getPublicKeyList = changeStringListToIntList(publicKey!); @@ -163,6 +172,7 @@ class DoorLockLogLogic extends BaseGetXController { /// 刷新门锁日志列表 StreamSubscription? _getDoorLockLogListRefreshUIEvent; + void _getDoorLockLogListRefreshUIAction() { _getDoorLockLogListRefreshUIEvent = eventBus .on() @@ -195,7 +205,8 @@ class DoorLockLogLogic extends BaseGetXController { if (entity.errorCode!.codeIsSuccessful) { state.operateDate = entity.data!.operateDate! ~/ 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(); } } diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 62961bf3..331599ef 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; 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 '../../../blue/blue_manage.dart'; import '../../../blue/io_protocol/io_openLock.dart'; +import '../../../blue/io_protocol/io_referEventRecordTime.dart'; import '../../../blue/io_reply.dart'; import '../../../blue/io_tool/io_tool.dart'; import '../../../blue/io_tool/manager_event_bus.dart'; @@ -28,6 +28,7 @@ import '../../../tools/commonDataManage.dart'; import '../../../tools/eventBusEventManage.dart'; import '../../../tools/storage.dart'; import '../lockOperatingRecord/keyOperationRecord_entity.dart'; +import '../lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; import '../lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_entity.dart'; import 'lockDetail_state.dart'; import 'lockNetToken_entity.dart'; @@ -41,17 +42,18 @@ class LockDetailLogic extends BaseGetXController { // 监听设备返回的数据 void initReplySubscription() { - state.replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) async { + state.replySubscription = + EventBusManager().eventBus!.on().listen((Reply reply) async { // 开门 if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) { _replyOpenLock(reply); } // 开完锁之后上传记录 - // if (reply is SenderReferEventRecordTimeReply && - // state.ifCurrentScreen.value == true) { - // _replyReferEventRecordTime(reply); - // } + if (reply is SenderReferEventRecordTimeReply && + state.ifCurrentScreen.value == true) { + _replyReferEventRecordTime(reply); + } }); } @@ -94,7 +96,7 @@ class LockDetailLogic extends BaseGetXController { state.animationController!.stop(); //锁数据更新 - // getLockRecordLastUploadDataTime(); + getLockRecordLastUploadDataTime(); break; case 0x06: //无权限 @@ -177,7 +179,9 @@ class LockDetailLogic extends BaseGetXController { } } - Future loadData({ required LockListInfoItemEntity lockListInfoItemEntity,required bool isOnlyOneData}) async { + Future loadData( + {required LockListInfoItemEntity lockListInfoItemEntity, + required bool isOnlyOneData}) async { state.keyInfos.value = lockListInfoItemEntity; CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!; CommonDataManage().initUserNo = state.keyInfos.value.initUserNo!; @@ -185,7 +189,8 @@ class LockDetailLogic extends BaseGetXController { 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.keyStatusExpired || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted || @@ -201,37 +206,37 @@ class LockDetailLogic extends BaseGetXController { state.senderUserId = state.keyInfos.value.senderUserId!; state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!; state.isOpenLockNeedOnline.value = - state.keyInfos.value.lockSetting!.appUnlockOnline!; + state.keyInfos.value.lockSetting!.appUnlockOnline!; state.electricQuantity.value = state.keyInfos.value.electricQuantity!; state.isOpenPassageMode.value = state.keyInfos.value.passageMode!; state.lockAlias.value = state.keyInfos.value.lockAlias!; Storage.setString(saveLockAlias, state.lockAlias.value); BlueManage().connectDeviceName = - state.keyInfos.value.bluetooth!.bluetoothDeviceName!; + state.keyInfos.value.bluetooth!.bluetoothDeviceName!; final List publicKeyData = - state.keyInfos.value.bluetooth!.publicKey!.cast(); + state.keyInfos.value.bluetooth!.publicKey!.cast(); final List saveStrList = changeIntListToStringList(publicKeyData); Storage.setStringList(saveBluePublicKey, saveStrList); // 私钥 final List privateKeyData = - state.keyInfos.value.bluetooth!.privateKey!.cast(); + state.keyInfos.value.bluetooth!.privateKey!.cast(); final List savePrivateKeyList = - changeIntListToStringList(privateKeyData); + changeIntListToStringList(privateKeyData); Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); // signKey final List signKeyData = - state.keyInfos.value.bluetooth!.signKey!.cast(); + state.keyInfos.value.bluetooth!.signKey!.cast(); final List saveSignKeyList = changeIntListToStringList(signKeyData); Storage.setStringList(saveBlueSignKey, saveSignKeyList); final bool ifHaveKey = await Storage.ifHaveKey(saveBlueToken); if (!ifHaveKey) { final List saveTokenList = - changeIntListToStringList([0, 0, 0, 0]); + changeIntListToStringList([0, 0, 0, 0]); Storage.setStringList(saveBlueToken, saveTokenList); } } @@ -252,71 +257,77 @@ class LockDetailLogic extends BaseGetXController { } // 根据时间查解析数据 - // Future _replyReferEventRecordTime(Reply reply) async { - // final int status = reply.data[2]; - // switch (status) { - // case 0x00: - // //成功 - // final int dataLength = (reply.data[5] << 8) + reply.data[6]; - // AppLog.log('dataLength:$dataLength'); - // if (dataLength > 0) { - // reply.data.removeRange(0, 7); - // // 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面 - // if (reply.data.length < 17) { - // return; - // } - // final List> getList = splitList(reply.data, 17); - // AppLog.log('getList:$getList'); - // final List uploadList = []; - // for (int i = 0; i < getList.length; i++) { - // final List indexList = getList[i]; - // AppLog.log('indexList:$indexList'); - // final Map indexMap = {}; - // indexMap['type'] = indexList[0].toString(); - // int operateDate = 0; - // // if (indexList[0] == 2) { - // final List passwordData = indexList.sublist(7, 17); - // final String password = utf8String(passwordData); - // AppLog.log('passwordData:$passwordData password:$password'); - // indexMap['user'] = password.toString(); - // // } else { - // // final int userNo = (indexList[1] * 256) + indexList[2]; - // // indexMap['user'] = userNo.toString(); - // // } - // - // indexMap['success'] = '1'; - // - // final int time = (0xff & indexList[3]) << 24 | - // (0xff & indexList[4]) << 16 | - // (0xff & indexList[5]) << 8 | - // (0xFF & indexList[6]); - // operateDate = time * 1000; - // indexMap['date'] = '$operateDate'; - // uploadList.add(indexMap); - // - // if (i == getList.length - 1) { - // //设置最后的时间戳 - // state.operateDate = operateDate; - // } - // } - // lockRecordUploadData(uploadList); - // - // if (dataLength == state.logCountPage) { - // senderReferEventRecordTime(); - // } else { - // await blueManageDisconnect(); - // } - // } - // break; - // case 0x06: - // //无权限 - // blueManageDisconnect(); - // break; - // default: - // blueManageDisconnect(); - // break; - // } - // } + Future _replyReferEventRecordTime(Reply reply) async { + final int status = reply.data[2]; + switch (status) { + case 0x00: + //成功 + final int dataLength = (reply.data[5] << 8) + reply.data[6]; + AppLog.log('dataLength:$dataLength'); + if (dataLength > 0) { + reply.data.removeRange(0, 7); + // 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面 + if (reply.data.length < 17) { + return; + } + final List> getList = splitList(reply.data, 17); + AppLog.log('getList:$getList'); + final List uploadList = []; + for (int i = 0; i < getList.length; i++) { + final List indexList = getList[i]; + AppLog.log('indexList:$indexList'); + final Map indexMap = {}; + indexMap['type'] = indexList[0].toString(); + int operateDate = 0; + // if (indexList[0] == 2) { + final List passwordData = indexList.sublist(7, 17); + final String password = utf8String(passwordData); + AppLog.log('passwordData:$passwordData password:$password'); + indexMap['user'] = password.toString(); + // } else { + // final int userNo = (indexList[1] * 256) + indexList[2]; + // indexMap['user'] = userNo.toString(); + // } + + indexMap['success'] = '1'; + + final int time = (0xff & indexList[3]) << 24 | + (0xff & indexList[4]) << 16 | + (0xff & indexList[5]) << 8 | + (0xFF & indexList[6]); + operateDate = time * 1000; + if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter( + DateTime.fromMillisecondsSinceEpoch(getUTCNetTime() * 1000))) { + continue; + } + + indexMap['date'] = '$operateDate'; + uploadList.add(indexMap); + + if (i == getList.length - 1) { + //设置最后的时间戳 + + state.operateDate = operateDate; + } + } + lockRecordUploadData(uploadList); + + if (dataLength == state.logCountPage) { + senderReferEventRecordTime(); + } else { + await blueManageDisconnect(); + } + } + break; + case 0x06: + //无权限 + blueManageDisconnect(); + break; + default: + blueManageDisconnect(); + break; + } + } // 点击开门事件 Future openDoorAction() async { @@ -372,42 +383,43 @@ class LockDetailLogic extends BaseGetXController { } // 查询事件记录(时间查询) - // void senderReferEventRecordTime() { - // showBlueConnetctToastTimer( - // isShowBlueConnetctToast: false, - // action: () { - // blueManageDisconnect(); - // }); - // BlueManage().blueSendData(BlueManage().connectDeviceName, - // (BluetoothConnectionState connectionState) async { - // if (connectionState == BluetoothConnectionState.connected) { - // final List? privateKey = - // await Storage.getStringList(saveBluePrivateKey); - // final List getPrivateKeyList = - // changeStringListToIntList(privateKey!); - // - // final List? token = await Storage.getStringList(saveBlueToken); - // final List getTokenList = changeStringListToIntList(token!); - // - // final List? publicKey = - // await Storage.getStringList(saveBluePublicKey); - // final List getPublicKeyList = - // changeStringListToIntList(publicKey!); - // - // IoSenderManage.senderReferEventRecordTimeCommand( - // keyID: BlueManage().connectDeviceName, - // userID: await Storage.getUid(), - // logsCount: state.logCountPage, - // // time:DateTime.now().millisecondsSinceEpoch~/1000, - // time: state.operateDate, - // token: getTokenList, - // needAuthor: 1, - // publicKey: getPublicKeyList, - // privateKey: getPrivateKeyList, - // ); - // } - // }); - // } + void senderReferEventRecordTime() { + showBlueConnetctToastTimer( + isShowBlueConnetctToast: false, + action: () { + blueManageDisconnect(); + }); + BlueManage().blueSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState connectionState) async { + if (connectionState == BluetoothConnectionState.connected) { + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); + + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); + + final List? publicKey = + await Storage.getStringList(saveBluePublicKey); + final List getPublicKeyList = + changeStringListToIntList(publicKey!); + + IoSenderManage.senderReferEventRecordTimeCommand( + keyID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + logsCount: state.logCountPage, + // time:DateTime.now().millisecondsSinceEpoch~/1000, + time: state.operateDate, + currentDate: state.currentDate, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList, + ); + } + }); + } // 从服务器获取锁的时间 开锁时传入 Future getServerDatetime() async { @@ -465,15 +477,16 @@ class LockDetailLogic extends BaseGetXController { } // 查询锁记录最后时间 - // Future getLockRecordLastUploadDataTime() async { - // final LockOperatingRecordGetLastRecordTimeEntity entity = - // await ApiRepository.to.getLockRecordLastUploadDataTime( - // lockId: state.keyInfos.value.lockId.toString()); - // if (entity.errorCode!.codeIsSuccessful) { - // state.operateDate = entity.data!.operateDate! ~/ 1000; - // senderReferEventRecordTime(); - // } - // } + Future getLockRecordLastUploadDataTime() async { + final LockOperatingRecordGetLastRecordTimeEntity entity = + await ApiRepository.to.getLockRecordLastUploadDataTime( + lockId: state.keyInfos.value.lockId.toString()); + if (entity.errorCode!.codeIsSuccessful) { + state.operateDate = entity.data!.operateDate! ~/ 1000; + state.currentDate = entity.data!.currentDate! ~/ 1000; + senderReferEventRecordTime(); + } + } // 操作记录上传 Future lockRecordUploadData(List list) async { @@ -493,13 +506,14 @@ class LockDetailLogic extends BaseGetXController { // 电子钥匙开锁成功上报 Future lockReportLockSuccessfullyUploadData() async { - final KeyOperationRecordEntity entity = await ApiRepository.to.lockReportLockSuccessfullyUploadData( - lockId: state.keyInfos.value.lockId ?? 0, - keyId: state.keyInfos.value.keyId ?? 0 - ); + final KeyOperationRecordEntity entity = await ApiRepository.to + .lockReportLockSuccessfullyUploadData( + lockId: state.keyInfos.value.lockId ?? 0, + keyId: state.keyInfos.value.keyId ?? 0); if (entity.errorCode!.codeIsSuccessful) { // 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) { // 单次删除 deletKeyData(); @@ -608,7 +622,6 @@ class LockDetailLogic extends BaseGetXController { getServerDatetime(); await PermissionDialog.request(Permission.location); await PermissionDialog.requestBluetooth(); - } @override diff --git a/lib/main/lockDetail/lockDetail/lockDetail_state.dart b/lib/main/lockDetail/lockDetail/lockDetail_state.dart index df604a3a..5e168524 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_state.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_state.dart @@ -50,6 +50,8 @@ class LockDetailState { RxInt currentPage = 0.obs; int operateDate = 0; // 按日期查询消息记录的时间戳 + int currentDate = 0; // 当前服务器UTC毫秒时间戳 + int logCountPage = 10; // 蓝牙记录一页多少个 RxInt nextAuthTime = 0.obs; // 下次认证时间 diff --git a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart index 12ac7f80..59a5d42e 100755 --- a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart +++ b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart @@ -22,8 +22,10 @@ class LockOperatingRecordLogic extends BaseGetXController { // 获取解析后的数据 late StreamSubscription _replySubscription; + void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) { + _replySubscription = + EventBusManager().eventBus!.on().listen((Reply reply) { if (reply is SenderReferEventRecordTimeReply) { _replyReferEventRecordTime(reply); } @@ -31,12 +33,12 @@ class LockOperatingRecordLogic extends BaseGetXController { } // 根据时间查解析数据 - Future _replyReferEventRecordTime(Reply reply) async { + Future _replyReferEventRecordTime(Reply reply) async { cancelBlueConnetctToastTimer(); final int status = reply.data[2]; switch (status) { case 0x00: - //成功 + //成功 final int dataLength = (reply.data[5] << 8) + reply.data[6]; AppLog.log('dataLength:$dataLength'); // var dataLength = reply.data[5]; @@ -56,7 +58,6 @@ class LockOperatingRecordLogic extends BaseGetXController { indexMap['type'] = indexList[0].toString(); - final int userNo = (indexList[1] * 256) + indexList[2]; indexMap['user'] = userNo.toString(); AppLog.log('userNouserNouserNouserNo:$userNo'); @@ -69,10 +70,15 @@ class LockOperatingRecordLogic extends BaseGetXController { indexMap['success'] = '1'; final int time = (0xff & indexList[3]) << 24 | - (0xff & indexList[4]) << 16 | - (0xff & indexList[5]) << 8 | - (0xFF & indexList[6]); - indexMap['date'] = '${time * 1000}'; + (0xff & indexList[4]) << 16 | + (0xff & indexList[5]) << 8 | + (0xFF & indexList[6]); + final operateDate = time * 1000; + if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter( + DateTime.fromMillisecondsSinceEpoch(state.currentDate))) { + continue; + } + indexMap['date'] = '$operateDate'; uploadList.add(indexMap); } if (dataLength == state.logCountPage) { @@ -84,11 +90,11 @@ class LockOperatingRecordLogic extends BaseGetXController { } break; case 0x06: - //无权限 需要鉴权 + //无权限 需要鉴权 break; default: - //失败 + //失败 break; } } @@ -96,19 +102,24 @@ class LockOperatingRecordLogic extends BaseGetXController { // 查询事件记录(时间查询) Future senderReferEventRecordTime() async { showEasyLoading(); - showBlueConnetctToastTimer(action: (){ + showBlueConnetctToastTimer(action: () { dismissEasyLoading(); }); - BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async { + BlueManage().blueSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState connectionStateState) async { if (connectionStateState == BluetoothConnectionState.connected) { - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - final List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = + changeStringListToIntList(privateKey!); final List? token = await Storage.getStringList(saveBlueToken); final List getTokenList = changeStringListToIntList(token!); - final List? publicKey = await Storage.getStringList(saveBluePublicKey); - final List getPublicKeyList = changeStringListToIntList(publicKey!); + final List? publicKey = + await Storage.getStringList(saveBluePublicKey); + final List getPublicKeyList = + changeStringListToIntList(publicKey!); IoSenderManage.senderReferEventRecordTimeCommand( keyID: BlueManage().connectDeviceName, @@ -122,10 +133,11 @@ class LockOperatingRecordLogic extends BaseGetXController { publicKey: getPublicKeyList, privateKey: getPrivateKeyList, ); - } else if (connectionStateState == BluetoothConnectionState.disconnected) { + } else if (connectionStateState == + BluetoothConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } } @@ -134,29 +146,31 @@ class LockOperatingRecordLogic extends BaseGetXController { //请求操作记录列表 Future mockNetworkDataRequest() async { - final KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordList( - lockId:CommonDataManage().currentKeyInfo.lockId.toString(), - pageNo:pageNo.toString(), - recordType:'', - searchStr:'', - startDate:'', - endDate:'', - keyboardPwdId: state.type == 1 ? state.idStr : '', - cardId: state.type == 2 ? state.idStr : '', - fingerprintId: state.type == 3 ? state.idStr : '', - keyId: state.type == 5 ? state.idStr : '', - faceId: state.type == 4 ? state.idStr : '', - remoteId:state.type == 6 ? state.idStr : '', - palmVeinId:state.type == 7 ? state.idStr : '', - pageSize:pageSize, - ); + final KeyOperationRecordEntity entity = + await ApiRepository.to.lockRecordList( + lockId: CommonDataManage().currentKeyInfo.lockId.toString(), + pageNo: pageNo.toString(), + recordType: '', + searchStr: '', + startDate: '', + endDate: '', + keyboardPwdId: state.type == 1 ? state.idStr : '', + cardId: state.type == 2 ? state.idStr : '', + fingerprintId: state.type == 3 ? state.idStr : '', + keyId: state.type == 5 ? state.idStr : '', + faceId: state.type == 4 ? state.idStr : '', + remoteId: state.type == 6 ? state.idStr : '', + palmVeinId: state.type == 7 ? state.idStr : '', + pageSize: pageSize, + ); if (entity.errorCode!.codeIsSuccessful) { if (pageNo == 1) { state.lockOperatingRecordListData.value = entity.data!.itemList!; pageNo++; } else { if (entity.data!.itemList!.isNotEmpty) { - state.lockOperatingRecordListData.value.addAll(entity.data!.itemList!); + state.lockOperatingRecordListData.value + .addAll(entity.data!.itemList!); pageNo++; } } @@ -166,9 +180,9 @@ class LockOperatingRecordLogic extends BaseGetXController { // 查询锁记录最后时间 Future getLockRecordLastUploadDataTime() async { - final LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to - .getLockRecordLastUploadDataTime( - lockId: CommonDataManage().currentKeyInfo.lockId.toString()); + final LockOperatingRecordGetLastRecordTimeEntity entity = + await ApiRepository.to.getLockRecordLastUploadDataTime( + lockId: CommonDataManage().currentKeyInfo.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { state.operateDate = entity.data!.operateDate! ~/ 1000; state.currentDate = entity.data!.currentDate! ~/ 1000; @@ -179,11 +193,13 @@ class LockOperatingRecordLogic extends BaseGetXController { // 操作记录上传 Future lockRecordUploadData(List list) async { 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(state.ifHaveNext == true){ + if (state.ifHaveNext == true) { getLockRecordLastUploadDataTime(); - }else{ + } else { pageNo = 1; mockNetworkDataRequest(); } @@ -192,9 +208,11 @@ class LockOperatingRecordLogic extends BaseGetXController { //清空操作记录 Future 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) { - showToast('清除数据成功', something: (){ + showToast('清除数据成功', something: () { pageNo = 1; mockNetworkDataRequest(); });