新增门锁日志页面接口数据与UI的逻辑处理
This commit is contained in:
parent
3d342be9fe
commit
41ee8d062f
77
star_lock/assets/DoorLockLogEntity.json
Normal file
77
star_lock/assets/DoorLockLogEntity.json
Normal file
@ -0,0 +1,77 @@
|
||||
{
|
||||
"errorCode": 0,
|
||||
"description": "success",
|
||||
"errorMsg": "success",
|
||||
"data": {
|
||||
"list": [{
|
||||
"recordId": 42672,
|
||||
"lockId": 1744,
|
||||
"lockAlias": "T9A_d7d74b2f66b8",
|
||||
"recordType": 130,
|
||||
"recordTypeName": "防拆报警",
|
||||
"username": "",
|
||||
"operateDate": 1705852800000,
|
||||
"imagesUrl": null,
|
||||
"videoUrl": null,
|
||||
"headUrl": "",
|
||||
"userid": ""
|
||||
},
|
||||
{
|
||||
"recordId": 42660,
|
||||
"lockId": 1744,
|
||||
"lockAlias": "T9A_d7d74b2f66b8",
|
||||
"recordType": 220,
|
||||
"recordTypeName": "逗留检测",
|
||||
"username": "",
|
||||
"operateDate": 1706494730335,
|
||||
"imagesUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706494718\/54c5044a-93bd-466d-a123-e1face292841.jpg",
|
||||
"videoUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706494718\/08a2b732-536b-4f06-9d20-778fdf94f137.mp4",
|
||||
"headUrl": "",
|
||||
"userid": ""
|
||||
},
|
||||
{
|
||||
"recordId": 42659,
|
||||
"lockId": 1744,
|
||||
"lockAlias": "T9A_d7d74b2f66b8",
|
||||
"recordType": 220,
|
||||
"recordTypeName": "逗留检测",
|
||||
"username": "",
|
||||
"operateDate": 1706494672036,
|
||||
"imagesUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706494660\/d85dcea0-c402-4f68-8664-5641a0feabe3.jpg",
|
||||
"videoUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706494660\/f3de0384-63f8-4177-9611-d8c43707afce.mp4",
|
||||
"headUrl": "",
|
||||
"userid": ""
|
||||
},
|
||||
{
|
||||
"recordId": 42658,
|
||||
"lockId": 1744,
|
||||
"lockAlias": "T9A_d7d74b2f66b8",
|
||||
"recordType": 130,
|
||||
"recordTypeName": "防拆报警",
|
||||
"username": "",
|
||||
"operateDate": 1706493793884,
|
||||
"imagesUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706493778\/f43ec840-ddaa-4d94-b759-7ae4384edd8f.jpg",
|
||||
"videoUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706493778\/b4a90c5c-d86f-4995-8365-d7e21a67a48d.mp4",
|
||||
"headUrl": "",
|
||||
"userid": ""
|
||||
},
|
||||
{
|
||||
"recordId": 42657,
|
||||
"lockId": 1744,
|
||||
"lockAlias": "T9A_d7d74b2f66b8",
|
||||
"recordType": 130,
|
||||
"recordTypeName": "防拆报警",
|
||||
"username": "",
|
||||
"operateDate": 1706493715812,
|
||||
"imagesUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706493702\/928c2b1d-1cd4-4d7f-9e61-e9315f8c4547.jpg",
|
||||
"videoUrl": "http:\/\/oss-pre-starlock.star-lock.cn\/starchart\/T9A_d7d74b2f66b8-1706493702\/29e8b8e4-cd79-436d-a384-3e50dacf5cc8.mp4",
|
||||
"headUrl": "",
|
||||
"userid": ""
|
||||
}
|
||||
],
|
||||
"pageNo": 1,
|
||||
"pageSize": 5,
|
||||
"pages": 4,
|
||||
"total": 18
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,119 @@
|
||||
class DoorLockLogEntity {
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
Data? data;
|
||||
|
||||
DoorLockLogEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
DoorLockLogEntity.fromJson(Map<String, dynamic> json) {
|
||||
errorCode = json['errorCode'];
|
||||
description = json['description'];
|
||||
errorMsg = json['errorMsg'];
|
||||
data = json['data'] != null ? Data.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 Data {
|
||||
List<DoorLockLogDataItem>? itemList;
|
||||
int? pageNo;
|
||||
int? pageSize;
|
||||
int? pages;
|
||||
int? total;
|
||||
|
||||
Data({this.itemList, this.pageNo, this.pageSize, this.pages, this.total});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
if (json['list'] != null) {
|
||||
itemList = <DoorLockLogDataItem>[];
|
||||
json['list'].forEach((v) {
|
||||
itemList!.add(DoorLockLogDataItem.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 DoorLockLogDataItem {
|
||||
int? recordId;
|
||||
int? lockId;
|
||||
String? lockAlias;
|
||||
int? recordType;
|
||||
String? recordTypeName;
|
||||
String? username;
|
||||
int? operateDate;
|
||||
String? imagesUrl;
|
||||
String? videoUrl;
|
||||
String? headUrl;
|
||||
String? userid;
|
||||
|
||||
DoorLockLogDataItem(
|
||||
{this.recordId,
|
||||
this.lockId,
|
||||
this.lockAlias,
|
||||
this.recordType,
|
||||
this.recordTypeName,
|
||||
this.username,
|
||||
this.operateDate,
|
||||
this.imagesUrl,
|
||||
this.videoUrl,
|
||||
this.headUrl,
|
||||
this.userid});
|
||||
|
||||
DoorLockLogDataItem.fromJson(Map<String, dynamic> json) {
|
||||
recordId = json['recordId'];
|
||||
lockId = json['lockId'];
|
||||
lockAlias = json['lockAlias'];
|
||||
recordType = json['recordType'];
|
||||
recordTypeName = json['recordTypeName'];
|
||||
username = json['username'];
|
||||
operateDate = json['operateDate'];
|
||||
imagesUrl = json['imagesUrl'];
|
||||
videoUrl = json['videoUrl'];
|
||||
headUrl = json['headUrl'];
|
||||
userid = json['userid'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['recordId'] = recordId;
|
||||
data['lockId'] = lockId;
|
||||
data['lockAlias'] = lockAlias;
|
||||
data['recordType'] = recordType;
|
||||
data['recordTypeName'] = recordTypeName;
|
||||
data['username'] = username;
|
||||
data['operateDate'] = operateDate;
|
||||
data['imagesUrl'] = imagesUrl;
|
||||
data['videoUrl'] = videoUrl;
|
||||
data['headUrl'] = headUrl;
|
||||
data['userid'] = userid;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,10 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart';
|
||||
import 'package:star_lock/tools/eventBusEventManage.dart';
|
||||
@ -186,16 +189,17 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
|
||||
//请求操作记录列表(门锁日志)
|
||||
void mockNetworkDataRequest() async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to.lockEventList(
|
||||
DoorLockLogEntity entity = await ApiRepository.to.lockEventList(
|
||||
lockId: state.keyInfos.value.lockId!,
|
||||
lockEventType: state.dropdownValue.value,
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
startDate: state.startDate.value,
|
||||
endDate: state.endDate.value);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("操作记录列表成功:${entity.data?.itemList}");
|
||||
state.lockOperatingRecordListData.value = entity.data!.itemList!;
|
||||
|
||||
if (state.lockLogEntity.value.errorCode!.codeIsSuccessful) {
|
||||
print("操作记录列表成功:${state.lockLogEntity.value.data?.itemList}");
|
||||
state.lockLogItemList.value = state.lockLogEntity.value.data!.itemList!;
|
||||
} else {}
|
||||
}
|
||||
|
||||
@ -259,35 +263,26 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
_initReplySubscription();
|
||||
// _initReplySubscription();
|
||||
|
||||
mockNetworkDataRequest();
|
||||
_getDoorLockLogListRefreshUIAction();
|
||||
// mockNetworkDataRequest();
|
||||
// _getDoorLockLogListRefreshUIAction();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onInit() async {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
// getLockRecordLastUploadDataTime();
|
||||
getLockRecordLastUploadDataTime();
|
||||
// senderReferEventRecordTime();
|
||||
// senderReferEventRecordNumber();
|
||||
}
|
||||
|
||||
DateTime now = DateTime.now();
|
||||
// 设置startDate为当天的0点
|
||||
state.startDate.value =
|
||||
DateTime(now.year, now.month, now.day).millisecondsSinceEpoch;
|
||||
// 设置endDate为下一天的0点,然后减去1毫秒
|
||||
state.endDate.value = (DateTime(now.year, now.month, now.day + 1)
|
||||
.subtract(const Duration(milliseconds: 1)))
|
||||
.millisecondsSinceEpoch;
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@ -302,4 +297,15 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
_getDoorLockLogListRefreshUIEvent?.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
//测试方法,得到真实数据后删除
|
||||
testReadJsonData() async {
|
||||
// 读取JSON文件
|
||||
String jsonString =
|
||||
await rootBundle.loadString('assets/DoorLockLogEntity.json');
|
||||
|
||||
// 解析JSON数据并转换为实体对象
|
||||
Map<String, dynamic> jsonData = json.decode(jsonString);
|
||||
state.lockLogEntity.value = DoorLockLogEntity.fromJson(jsonData);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_logic.dart';
|
||||
import 'package:star_lock/tools/advancedCalendar/src/widget.dart';
|
||||
import 'package:star_lock/tools/menuItem/xsDropDownWidget.dart';
|
||||
@ -66,15 +67,7 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> {
|
||||
endIndent: 30.w,
|
||||
),
|
||||
eventDropDownWidget(),
|
||||
// Expanded(child: timeLineView())
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemBuilder: (context, index) {
|
||||
return timeLineView();
|
||||
},
|
||||
itemCount: state.lockOperatingRecordListData.value.length,
|
||||
),
|
||||
),
|
||||
Expanded(child: Obx(() => timeLineView(state.lockLogItemList.value)))
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -131,7 +124,6 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> {
|
||||
items: state.getDropDownItemList,
|
||||
value: state.dropdownTitle.value,
|
||||
valueChanged: (value) {
|
||||
print('dropdownValue选中了$value');
|
||||
state.dropdownValue.value = int.parse(value);
|
||||
logic.mockNetworkDataRequest();
|
||||
})),
|
||||
@ -141,64 +133,89 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> {
|
||||
}
|
||||
|
||||
//时间轴组件
|
||||
Widget timeLineView() {
|
||||
Widget timeLineView(List<DoorLockLogDataItem> timelineDataList) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 20.h, top: 20.h),
|
||||
//给contain设置一个10像素的圆角
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white, borderRadius: BorderRadius.circular(16.w)),
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16.w),
|
||||
),
|
||||
child: Timeline.tileBuilder(
|
||||
builder: TimelineTileBuilder.fromStyle(
|
||||
contentsAlign: ContentsAlign.basic,
|
||||
contentsBuilder: (context, index) => Padding(
|
||||
padding: EdgeInsets.only(left: 20.w, top: 20.h),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('09:30 有人出现在门口',
|
||||
itemCount: timelineDataList.length,
|
||||
contentsBuilder: (context, index) {
|
||||
DoorLockLogDataItem timelineData = timelineDataList[index];
|
||||
DateTime dateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(timelineData.operateDate!);
|
||||
String formattedTime =
|
||||
'${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}';
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(left: 20.w, top: 20.h),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'$formattedTime ${timelineData.recordTypeName}',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 24.sp,
|
||||
fontWeight: FontWeight.w600)),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(Routers.videoLogDetailPage);
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
Image(
|
||||
image: const AssetImage(
|
||||
'images/main/icon_lockDetail_monitoringvoiceFrist.png'),
|
||||
width: 260.w,
|
||||
height: 260.h,
|
||||
),
|
||||
//在图片上添加一个三角视频图标
|
||||
Positioned(
|
||||
top: 200.h,
|
||||
left: 10.w,
|
||||
child: Image(
|
||||
image: const AssetImage(
|
||||
'images/main/icon_lockLog_play.png'),
|
||||
width: 24.w,
|
||||
height: 20.w,
|
||||
),
|
||||
),
|
||||
],
|
||||
color: Colors.black,
|
||||
fontSize: 24.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
itemCount: 10,
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(Routers.videoLogDetailPage);
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
if (timelineData.imagesUrl != null)
|
||||
// Image.network(
|
||||
// timelineData.imagesUrl!,
|
||||
// width: 260.w,
|
||||
// height: 260.h,
|
||||
// )
|
||||
Image(
|
||||
image: const AssetImage(
|
||||
'images/main/icon_lockDetail_monitoringvoiceFrist.png'),
|
||||
width: 260.w,
|
||||
height: 260.h,
|
||||
)
|
||||
else
|
||||
Container(),
|
||||
Positioned(
|
||||
top: 200.h,
|
||||
left: 10.w,
|
||||
child: Image(
|
||||
image: const AssetImage(
|
||||
'images/main/icon_lockLog_play.png'),
|
||||
width: 24.w,
|
||||
height: 20.w,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
theme: TimelineThemeData(
|
||||
nodePosition: 0.04, //居左侧距离
|
||||
connectorTheme: const ConnectorThemeData(
|
||||
thickness: 1.0, color: AppColors.greyLineColor, indent: 0.5),
|
||||
thickness: 1.0,
|
||||
color: AppColors.greyLineColor,
|
||||
indent: 0.5,
|
||||
),
|
||||
indicatorTheme: const IndicatorThemeData(
|
||||
size: 8.0, color: AppColors.greyLineColor, position: 0.07),
|
||||
size: 8.0,
|
||||
color: AppColors.greyLineColor,
|
||||
position: 0.7,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||
import 'package:star_lock/tools/advancedCalendar/src/controller.dart';
|
||||
import 'package:star_lock/tools/menuItem/dropDownItem.dart';
|
||||
|
||||
import '../../lockMian/entity/lockListInfo_entity.dart';
|
||||
import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
|
||||
class DoorLockLogState {
|
||||
final lockLogEntity = DoorLockLogEntity().obs;
|
||||
final keyInfos = LockListInfoItemEntity().obs;
|
||||
final lockOperatingRecordListData = <KeyRecordDataItem>[].obs;
|
||||
final lockLogItemList = <DoorLockLogDataItem>[].obs;
|
||||
final calendarControllerToday = AdvancedCalendarController.today();
|
||||
final calendarControllerCustom = AdvancedCalendarController.today();
|
||||
final events = <DateTime>[
|
||||
@ -16,8 +17,15 @@ class DoorLockLogState {
|
||||
DateTime(2024, 10, 10),
|
||||
];
|
||||
|
||||
final startDate = 0.obs;
|
||||
final endDate = 0.obs;
|
||||
final startDate =
|
||||
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day)
|
||||
.millisecondsSinceEpoch
|
||||
.obs;
|
||||
final endDate = (DateTime(
|
||||
DateTime.now().year, DateTime.now().month, DateTime.now().day + 1)
|
||||
.subtract(const Duration(milliseconds: 1)))
|
||||
.millisecondsSinceEpoch
|
||||
.obs;
|
||||
|
||||
var dropdownTitle = '全部事件'.obs;
|
||||
var dropdownValue = XSConstantMacro.lockEventTypeAll.obs;
|
||||
|
||||
@ -160,10 +160,10 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
)))),
|
||||
Positioned(
|
||||
child: Obx(() => GestureDetector(
|
||||
onTap: (){
|
||||
logic.getStarLockStatus();
|
||||
},
|
||||
child: Row(
|
||||
onTap: () {
|
||||
logic.getStarLockStatus();
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Image.asset(
|
||||
@ -184,7 +184,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
SizedBox(width: 20.w),
|
||||
],
|
||||
),
|
||||
)))
|
||||
)))
|
||||
],
|
||||
),
|
||||
SizedBox(height: 30.h),
|
||||
@ -391,6 +391,10 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
'照明', state.bottomBtnisUneable.value, () {}));
|
||||
|
||||
// 照明
|
||||
showWidgetArr.add(bottomItem('images/main/icon_lockDetail_illuminator.png',
|
||||
'门磁', state.bottomBtnisUneable.value, () {}));
|
||||
|
||||
// 门磁
|
||||
showWidgetArr.add(bottomItem('images/main/icon_lockDetail_illuminator.png',
|
||||
'开门器', state.bottomBtnisUneable.value, () {}));
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
@ -17,18 +16,19 @@ import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
import 'lockOperatingRecordGetLastRecordTime_entity.dart';
|
||||
import 'lockOperatingRecord_state.dart';
|
||||
|
||||
class LockOperatingRecordLogic extends BaseGetXController{
|
||||
class LockOperatingRecordLogic extends BaseGetXController {
|
||||
LockOperatingRecordState state = LockOperatingRecordState();
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
// if(reply is SenderReferEventRecordNumberReply) {
|
||||
// _replyReferEventRecordNumber(reply);
|
||||
// }
|
||||
|
||||
if(reply is SenderReferEventRecordTimeReply) {
|
||||
if (reply is SenderReferEventRecordTimeReply) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
}
|
||||
});
|
||||
@ -69,17 +69,17 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
// 根据时间查解析数据
|
||||
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
if(reply.data[5] > 0){
|
||||
if (reply.data[5] > 0) {
|
||||
reply.data.removeRange(0, 6);
|
||||
// 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
||||
var getList = splitList(reply.data, 8);
|
||||
print("getList:$getList");
|
||||
var uploadList = [];
|
||||
for(int i = 0; i<getList.length; i++){
|
||||
for (int i = 0; i < getList.length; i++) {
|
||||
var indexList = getList[i];
|
||||
print("indexList:$indexList");
|
||||
var indexMap = {};
|
||||
@ -90,13 +90,13 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
indexMap["type"] = indexList[1].toString();
|
||||
|
||||
int value = ((0xff & indexList[(4)]) << 24 |
|
||||
(0xff & indexList[5]) << 16 |
|
||||
(0xff & indexList[6]) << 8 |
|
||||
(0xFF & indexList[7]));
|
||||
(0xff & indexList[5]) << 16 |
|
||||
(0xff & indexList[6]) << 8 |
|
||||
(0xFF & indexList[7]));
|
||||
// indexMap["date"] = DateTool().dateToYMDHNSString("$value");
|
||||
// print("value:${DateTool().dateToYMDHNSString("$value")}");
|
||||
|
||||
indexMap["date"] = "${value*1000}";
|
||||
indexMap["date"] = "${value * 1000}";
|
||||
uploadList.add(indexMap);
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
@ -155,7 +155,8 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime(int time) async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -168,15 +169,15 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
|
||||
EasyLoading.show();
|
||||
IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
keyID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
logsCount:20,
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
logsCount: 20,
|
||||
// time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
time: time,
|
||||
token:getTokenList,
|
||||
needAuthor:1,
|
||||
publicKey:getPublicKeyList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -202,25 +203,24 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
print("操作记录列表成功:${entity.data?.itemList}");
|
||||
state.lockOperatingRecordListData.value = entity.data!.itemList!;
|
||||
}else{
|
||||
|
||||
}
|
||||
} else {}
|
||||
}
|
||||
|
||||
// 查询锁记录最后时间
|
||||
void getLockRecordLastUploadDataTime() async {
|
||||
LockOperatingRecordGetLastRecordTimeEntity entity =
|
||||
await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString());
|
||||
LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to
|
||||
.getLockRecordLastUploadDataTime(
|
||||
lockId: state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
senderReferEventRecordTime(entity.data!.operateDate!~/1000);
|
||||
senderReferEventRecordTime(entity.data!.operateDate! ~/ 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// 操作记录上传
|
||||
void lockRecordUploadData(List list) async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordUploadData(
|
||||
lockId: state.keyInfos.value.lockId.toString(),
|
||||
records: list);
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.lockRecordUploadData(
|
||||
lockId: state.keyInfos.value.lockId.toString(), records: list);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
@ -229,7 +229,7 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
//清空操作记录
|
||||
void clearOperationRecordRequest() async {
|
||||
KeyOperationRecordEntity entity =
|
||||
await ApiRepository.to.clearOperationRecord('28');
|
||||
await ApiRepository.to.clearOperationRecord('28');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("清除数据成功");
|
||||
}
|
||||
@ -242,8 +242,8 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
print("onReady()");
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
_initReplySubscription();
|
||||
|
||||
mockNetworkDataRequest();
|
||||
@ -257,8 +257,8 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
print("onInit()");
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
getLockRecordLastUploadDataTime();
|
||||
// senderReferEventRecordTime();
|
||||
// senderReferEventRecordNumber();
|
||||
@ -271,10 +271,9 @@ class LockOperatingRecordLogic extends BaseGetXController{
|
||||
super.onClose();
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,19 +179,19 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
arguments: {'lockSetInfoData': state.lockSetInfoData.value});
|
||||
}),
|
||||
SizedBox(height: 10.h),
|
||||
// 门磁
|
||||
Obx(() => Visibility(
|
||||
visible: state.lockFeature.value.doorStatus == 1 ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.doorMagneticPage);
|
||||
// Toast.show(msg: "功能暂未开放");
|
||||
}))),
|
||||
//by DaisyWu 田总:移至锁详情配件区
|
||||
// 门磁
|
||||
// Obx(() => Visibility(
|
||||
// visible: state.lockFeature.value.doorStatus == 1 ? true : false,
|
||||
// child: CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr,
|
||||
// rightTitle: "",
|
||||
// isHaveLine: true,
|
||||
// isHaveDirection: true,
|
||||
// action: () {
|
||||
// Get.toNamed(Routers.doorMagneticPage);
|
||||
// // Toast.show(msg: "功能暂未开放");
|
||||
// }))),
|
||||
// // 无线键盘
|
||||
// Obx(() => Visibility(
|
||||
// visible: state.lockFeature.value.wirelessKeyboard == 1 ? true : false,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserListEntity.dart';
|
||||
@ -218,7 +219,7 @@ class ApiRepository {
|
||||
}
|
||||
|
||||
//门锁事件日志
|
||||
Future<KeyOperationRecordEntity> lockEventList({
|
||||
Future<DoorLockLogEntity> lockEventList({
|
||||
required int lockId,
|
||||
required int lockEventType,
|
||||
required int pageNo,
|
||||
@ -234,7 +235,7 @@ class ApiRepository {
|
||||
startDate,
|
||||
endDate,
|
||||
);
|
||||
return KeyOperationRecordEntity.fromJson(res.body);
|
||||
return DoorLockLogEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
//操作记录上传
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user