修改操作记录bug--没有时间显示问题
This commit is contained in:
parent
66a27c00b2
commit
327a78e829
@ -1,7 +1,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
|
||||
@ -26,16 +26,17 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
|
||||
if (reply is SenderReferEventRecordTimeReply && state.ifCurrentScreen.value == true) {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if (reply is SenderReferEventRecordTimeReply &&
|
||||
state.ifCurrentScreen.value == true) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 根据时间查解析数据
|
||||
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||
cancelBlueConnetctToastTimer();
|
||||
int status = reply.data[2];
|
||||
switch (status) {
|
||||
@ -47,7 +48,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
if (dataLength > 0) {
|
||||
reply.data.removeRange(0, 7);
|
||||
// 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
||||
if(reply.data.length < 17){
|
||||
if (reply.data.length < 17) {
|
||||
return;
|
||||
}
|
||||
var getList = splitList(reply.data, 17);
|
||||
@ -59,27 +60,27 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
var indexMap = {};
|
||||
indexMap["type"] = indexList[0].toString();
|
||||
|
||||
if(indexList[0] == 2){
|
||||
if (indexList[0] == 2) {
|
||||
var passwordData = indexList.sublist(7, 17);
|
||||
var password = utf8String(passwordData);
|
||||
indexMap["user"] = password.toString();
|
||||
}else{
|
||||
int userNo = (indexList[1]*255) + indexList[2];
|
||||
} else {
|
||||
int userNo = (indexList[1] * 255) + indexList[2];
|
||||
indexMap["user"] = userNo.toString();
|
||||
}
|
||||
|
||||
indexMap["success"] = "1";
|
||||
|
||||
int time = ((0xff & indexList[(3)]) << 24 |
|
||||
(0xff & indexList[4]) << 16 |
|
||||
(0xff & indexList[5]) << 8 |
|
||||
(0xFF & indexList[6]));
|
||||
(0xff & indexList[4]) << 16 |
|
||||
(0xff & indexList[5]) << 8 |
|
||||
(0xFF & indexList[6]));
|
||||
indexMap["date"] = "${time * 1000}";
|
||||
uploadList.add(indexMap);
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
|
||||
if(dataLength == state.logCountPage){
|
||||
if (dataLength == state.logCountPage) {
|
||||
state.ifHaveNext = true;
|
||||
}
|
||||
}
|
||||
@ -97,10 +98,11 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionStateState) async {
|
||||
if (connectionStateState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -122,10 +124,11 @@ class DoorLockLogLogic 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();
|
||||
}
|
||||
}
|
||||
@ -141,9 +144,16 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
pageSize: int.parse(pageSize),
|
||||
startDate: state.startDate.value,
|
||||
endDate: state.endDate.value);
|
||||
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.lockLogItemList.value = entity.data!.itemList!;
|
||||
if (pageNo == 1) {
|
||||
state.lockLogItemList.value = entity.data!.itemList!;
|
||||
pageNo++;
|
||||
} else {
|
||||
if (entity.data!.itemList!.isNotEmpty) {
|
||||
state.lockLogItemList.addAll(entity.data!.itemList!);
|
||||
pageNo++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,15 +162,18 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
void _getDoorLockLogListRefreshUIAction() {
|
||||
_getDoorLockLogListRefreshUIEvent =
|
||||
eventBus.on<DoorLockLogListRefreshUI>().listen((event) {
|
||||
state.currentSelectDate.value = event.getDoorLockLogTime;
|
||||
// 设置startDate为当天的0点
|
||||
state.startDate.value = DateTime(event.getDoorLockLogTime.year,
|
||||
event.getDoorLockLogTime.month, event.getDoorLockLogTime.day)
|
||||
state.startDate.value = DateTime(
|
||||
state.currentSelectDate.value.year,
|
||||
state.currentSelectDate.value.month,
|
||||
state.currentSelectDate.value.day)
|
||||
.millisecondsSinceEpoch;
|
||||
// 设置endDate为下一天的0点,然后减去1毫秒
|
||||
state.endDate.value = (DateTime(
|
||||
event.getDoorLockLogTime.year,
|
||||
event.getDoorLockLogTime.month,
|
||||
event.getDoorLockLogTime.day + 1)
|
||||
state.currentSelectDate.value.year,
|
||||
state.currentSelectDate.value.month,
|
||||
state.currentSelectDate.value.day + 1)
|
||||
.subtract(const Duration(milliseconds: 1)))
|
||||
.millisecondsSinceEpoch;
|
||||
|
||||
@ -186,9 +199,9 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
.lockRecordUploadData(
|
||||
lockId: state.keyInfos.value.lockId.toString(), records: list);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if(state.ifHaveNext == true){
|
||||
if (state.ifHaveNext == true) {
|
||||
getLockRecordLastUploadDataTime();
|
||||
}else{
|
||||
} else {
|
||||
pageNo = 1;
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ 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/EasyRefreshTool.dart';
|
||||
import 'package:star_lock/tools/advancedCalendar/src/widget.dart';
|
||||
import 'package:star_lock/tools/menuItem/xsDropDownWidget.dart';
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
@ -52,7 +53,17 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
||||
endIndent: 30.w,
|
||||
),
|
||||
eventDropDownWidget(),
|
||||
Expanded(child: Obx(() => timeLineView(state.lockLogItemList)))
|
||||
Expanded(
|
||||
child: EasyRefreshTool(
|
||||
onRefresh: () {
|
||||
logic.pageNo = 1;
|
||||
logic.mockNetworkDataRequest();
|
||||
},
|
||||
onLoad: () {
|
||||
logic.mockNetworkDataRequest();
|
||||
},
|
||||
child: Obx(() => timeLineView(state.lockLogItemList)),
|
||||
))
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -81,19 +92,34 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> with RouteAware {
|
||||
highlightColor: Colors.yellow,
|
||||
disabledColor: Colors.grey,
|
||||
),
|
||||
child: AdvancedCalendar(
|
||||
controller: state.calendarControllerCustom,
|
||||
events: state.events,
|
||||
weekLineHeight: 48.0,
|
||||
startWeekDay: 1,
|
||||
innerDot: true,
|
||||
keepLineSize: true,
|
||||
calendarTextStyle: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w400,
|
||||
height: 1.3125,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
AdvancedCalendar(
|
||||
controller: state.calendarControllerCustom,
|
||||
events: state.events,
|
||||
weekLineHeight: 48.0,
|
||||
startWeekDay: 1,
|
||||
innerDot: true,
|
||||
keepLineSize: true,
|
||||
calendarTextStyle: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w400,
|
||||
height: 1.3125,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 8.0,
|
||||
right: 8.0,
|
||||
child: Obx(() => Text(
|
||||
'${state.currentSelectDate.value.year}年${state.currentSelectDate.value.month}月',
|
||||
style: theme.textTheme.titleMedium!.copyWith(
|
||||
fontSize: 16,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -17,8 +17,15 @@ class DoorLockLogState {
|
||||
DateTime(2024, 10, 10),
|
||||
];
|
||||
|
||||
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;
|
||||
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;
|
||||
@ -50,6 +57,7 @@ class DoorLockLogState {
|
||||
var operateDate = 0; // 按日期查询消息记录的时间戳
|
||||
var ifHaveNext = false; // 页码
|
||||
var logCountPage = 10; // 蓝牙记录一页多少个
|
||||
var currentSelectDate = DateTime.now().obs; // 当前选择的日期
|
||||
|
||||
DoorLockLogState() {
|
||||
keyInfos.value = Get.arguments["keyInfo"];
|
||||
|
||||
@ -15,8 +15,7 @@ class Header extends StatelessWidget {
|
||||
this.todayStyle,
|
||||
}) : super(key: key);
|
||||
|
||||
static final _dateFormatter = DateFormat().add_yMMMM();
|
||||
// static final _dateFormatter = DateFormat('MM月dd日', 'zh_CN');
|
||||
static final _dateFormatter = DateFormat.yM('zh_CN');
|
||||
final DateTime monthDate;
|
||||
final EdgeInsetsGeometry margin;
|
||||
final VoidCallback? onPressed;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user