删除文件
This commit is contained in:
parent
ed9cc12e36
commit
9f3085b817
@ -1,120 +0,0 @@
|
||||
class KeyOperationRecordEntity {
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
KeyOperationRecordData? data;
|
||||
|
||||
KeyOperationRecordEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
KeyOperationRecordEntity.fromJson(Map<String, dynamic> json) {
|
||||
errorCode = json['errorCode'];
|
||||
description = json['description'];
|
||||
errorMsg = json['errorMsg'];
|
||||
data = json['data'] != null
|
||||
? KeyOperationRecordData.fromJson(json['data'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['errorCode'] = errorCode;
|
||||
data['description'] = description;
|
||||
data['errorMsg'] = errorMsg;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class KeyOperationRecordData {
|
||||
List<KeyRecordDataItem>? itemList;
|
||||
int? pageNo;
|
||||
int? pageSize;
|
||||
int? pages;
|
||||
int? total;
|
||||
|
||||
KeyOperationRecordData(
|
||||
{this.itemList, this.pageNo, this.pageSize, this.pages, this.total});
|
||||
|
||||
KeyOperationRecordData.fromJson(Map<String, dynamic> json) {
|
||||
if (json['list'] != null) {
|
||||
itemList = <KeyRecordDataItem>[];
|
||||
json['list'].forEach((v) {
|
||||
itemList!.add(KeyRecordDataItem.fromJson(v));
|
||||
});
|
||||
}
|
||||
pageNo = json['pageNo'];
|
||||
pageSize = json['pageSize'];
|
||||
pages = json['pages'];
|
||||
total = json['total'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
if (itemList != null) {
|
||||
data['list'] = itemList!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['pageNo'] = pageNo;
|
||||
data['pageSize'] = pageSize;
|
||||
data['pages'] = pages;
|
||||
data['total'] = total;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class KeyRecordDataItem {
|
||||
int? recordId;
|
||||
int? lockId;
|
||||
int? recordType;
|
||||
String? recordTypeName;
|
||||
int? success;
|
||||
String? username;
|
||||
int? lockDate;
|
||||
int? operateDate;
|
||||
String? keyboardPwd;
|
||||
|
||||
KeyRecordDataItem(
|
||||
{this.recordId,
|
||||
this.lockId,
|
||||
this.recordType,
|
||||
this.recordTypeName,
|
||||
this.success,
|
||||
this.username,
|
||||
this.lockDate,
|
||||
this.operateDate,
|
||||
this.keyboardPwd});
|
||||
|
||||
KeyRecordDataItem.fromJson(Map<String, dynamic> json) {
|
||||
recordId = json['recordId'];
|
||||
lockId = json['lockId'];
|
||||
recordType = json['recordType'];
|
||||
json['recordTypeName'] != null
|
||||
? recordTypeName = json['recordTypeName']
|
||||
: "";
|
||||
success = json['success'];
|
||||
json['username'] != null ? username = json['username'] : "";
|
||||
json['lockDate'] != null ? lockDate = json['lockDate'] : "";
|
||||
operateDate = json['operateDate'];
|
||||
json['keyboardPwd'] != null ? keyboardPwd = json['keyboardPwd'] : "";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['recordId'] = recordId;
|
||||
data['lockId'] = lockId;
|
||||
data['recordType'] = recordType;
|
||||
data['recordTypeName'] = recordTypeName;
|
||||
data['success'] = success;
|
||||
if (data['username'] != null) {
|
||||
data['username'] = username;
|
||||
}
|
||||
if (data['lockDate'] != null) {
|
||||
data['lockDate'] = lockDate;
|
||||
}
|
||||
data['operateDate'] = operateDate;
|
||||
data['keyboardPwd'] = keyboardPwd;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,246 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_state.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../../blue/blue_manage.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';
|
||||
import '../../../../../blue/sender_manage.dart';
|
||||
import '../../../../../tools/storage.dart';
|
||||
import '../../../lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart';
|
||||
|
||||
class KeyOperationRecordLogic extends BaseGetXController {
|
||||
final KeyOperationRecordState state = KeyOperationRecordState();
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
// if(reply is SenderReferEventRecordNumberReply) {
|
||||
// _replyReferEventRecordNumber(reply);
|
||||
// }
|
||||
|
||||
if (reply is SenderReferEventRecordTimeReply) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 根据数量查解析数据
|
||||
// Future<void> _replyReferEventRecordNumber(Reply reply) async {
|
||||
// int status = reply.data[2];
|
||||
// switch(status){
|
||||
// case 0x00:
|
||||
// //成功
|
||||
// // _getLockStatus();
|
||||
// break;
|
||||
// case 0x06:
|
||||
// //无权限
|
||||
//
|
||||
// break;
|
||||
// default:
|
||||
// //失败
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 根据时间查解析数据
|
||||
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
if (reply.data[5] > 0) {
|
||||
reply.data.removeRange(0, 6);
|
||||
// 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
||||
var getList = splitList(reply.data, 8);
|
||||
// AppLog.log("getList:$getList");
|
||||
var uploadList = [];
|
||||
for (int i = 0; i < getList.length; i++) {
|
||||
var indexList = getList[i];
|
||||
// AppLog.log("indexList:$indexList");
|
||||
var indexMap = {};
|
||||
indexMap["seq"] = indexList[0].toString();
|
||||
indexMap["user"] = indexList[3].toString();
|
||||
indexMap["pwd"] = indexList[2].toString();
|
||||
indexMap["success"] = "1";
|
||||
indexMap["type"] = indexList[1].toString();
|
||||
|
||||
int value = ((0xff & indexList[(4)]) << 24 |
|
||||
(0xff & indexList[5]) << 16 |
|
||||
(0xff & indexList[6]) << 8 |
|
||||
(0xFF & indexList[7]));
|
||||
// indexMap["date"] = DateTool().dateToYMDHNSString("$value");
|
||||
|
||||
indexMap["date"] = "${value * 1000}";
|
||||
uploadList.add(indexMap);
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询事件记录(页数查询)
|
||||
// Future<void> senderReferEventRecordNumber() async {
|
||||
// BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
// if (state == DeviceConnectionState.connected) {
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.senderReferEventRecordNumberCommand(
|
||||
// keyID:BlueManage().connectDeviceName,
|
||||
// userID:await Storage.getUid(),
|
||||
// logsCount:20,
|
||||
// logsNo:1,
|
||||
// token:getTokenList,
|
||||
// needAuthor:1,
|
||||
// publicKey:getPublicKeyList,
|
||||
// privateKey:getPrivateKeyList,
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime(int time) async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
EasyLoading.show();
|
||||
IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
logsCount: 20,
|
||||
// time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
time: time,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//请求操作记录列表
|
||||
Future<void> mockNetworkDataRequest() async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordList(
|
||||
endDate:'0',
|
||||
keyId:state.keyId.value,
|
||||
keyStatus:'0',
|
||||
lockId:state.lockId.value,
|
||||
operatorUid:'1',
|
||||
pageNo:'1',
|
||||
pageSize:'20',
|
||||
startDate:'0',
|
||||
recordType:'',
|
||||
searchStr:'',
|
||||
timezoneRawOffSet:'',
|
||||
keyboardPwdId:state.keyboardPwdId.value,
|
||||
cardId:state.cardId.value,
|
||||
fingerprintId:state.fingerprintId.value);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.dataList.value = entity.data!.itemList!;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询锁记录最后时间
|
||||
void getLockRecordLastUploadDataTime() async {
|
||||
LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to
|
||||
.getLockRecordLastUploadDataTime(
|
||||
lockId: state.lockId.value.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
senderReferEventRecordTime(entity.data!.operateDate! ~/ 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// 操作记录上传
|
||||
void lockRecordUploadData(List list) async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.lockRecordUploadData(
|
||||
lockId: state.lockId.value.toString(), records: list);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
}
|
||||
|
||||
//清空操作记录
|
||||
void clearOperationRecordRequest() async {
|
||||
KeyOperationRecordEntity entity =
|
||||
await ApiRepository.to.clearOperationRecord('28');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("清除数据成功".tr);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onReady() async {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
_initReplySubscription();
|
||||
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onInit() async {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
getLockRecordLastUploadDataTime();
|
||||
// senderReferEventRecordTime();
|
||||
// senderReferEventRecordNumber();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onClose() async {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart';
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
import 'package:star_lock/tools/titleAppBar.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
|
||||
class KeyOperationRecordPage extends StatefulWidget {
|
||||
const KeyOperationRecordPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<KeyOperationRecordPage> createState() => _KeyOperationRecordPageState();
|
||||
}
|
||||
|
||||
class _KeyOperationRecordPageState extends State<KeyOperationRecordPage> {
|
||||
final logic = Get.put(KeyOperationRecordLogic());
|
||||
final state = Get.find<KeyOperationRecordLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.operatingRecord!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
),
|
||||
body: Obx(() => state.dataList.value.isEmpty
|
||||
? NoData()
|
||||
: _buildMainUI(state.dataList.value)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI(List<KeyRecordDataItem> itemDataList) {
|
||||
return ListView.separated(
|
||||
itemCount: itemDataList.length,
|
||||
itemBuilder: (c, index) {
|
||||
KeyRecordDataItem dataItem = itemDataList[index];
|
||||
int? operateDate = dataItem.operateDate;
|
||||
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(operateDate!);
|
||||
String operateDateStr =
|
||||
'${dateStr.toLocal().toString().substring(0, 16)} ${"开锁".tr}';
|
||||
|
||||
return _electronicKeyItem(operateDateStr, () {});
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _electronicKeyItem(String operateDate, Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
height: 68.h,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 30.w,
|
||||
),
|
||||
Image.asset(
|
||||
'images/icon_recordDate.png',
|
||||
width: 24.w,
|
||||
height: 24.w,
|
||||
color: AppColors.darkGrayTextColor,
|
||||
),
|
||||
SizedBox(
|
||||
width: 20.w,
|
||||
),
|
||||
Text(
|
||||
operateDate,
|
||||
style: TextStyle(color: AppColors.blackColor, fontSize: 20.sp),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
||||
|
||||
class KeyOperationRecordState {
|
||||
var dataList = <KeyRecordDataItem>[].obs;
|
||||
final keyId = ''.obs;
|
||||
final lockId = ''.obs;
|
||||
final keyboardPwdId = ''.obs; //密码ID
|
||||
final cardId = ''.obs; //卡ID
|
||||
final fingerprintId = ''.obs; //指纹ID
|
||||
|
||||
KeyOperationRecordState() {
|
||||
Map map = Get.arguments;
|
||||
if ((map["keyId"] != null)) {
|
||||
keyId.value = map["keyId"];
|
||||
}
|
||||
if ((map["lockId"] != null)) {
|
||||
lockId.value = map["lockId"];
|
||||
}
|
||||
if ((map["keyboardPwdId"] != null)) {
|
||||
keyboardPwdId.value = map["keyboardPwdId"];
|
||||
}
|
||||
if ((map["cardId"] != null)) {
|
||||
cardId.value = map["cardId"];
|
||||
}
|
||||
|
||||
if ((map["fingerprintId"] != null)) {
|
||||
fingerprintId.value = map["fingerprintId"];
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user