fix: 锁记录同步时,单条记录解析失败直接跳过,继续解析后续记录,并重置时间线.
This commit is contained in:
parent
16dc021943
commit
12dcd5984a
@ -3,6 +3,7 @@ import 'dart:async';
|
|||||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/apm/apm_helper.dart';
|
import 'package:star_lock/apm/apm_helper.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';
|
||||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
|
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
|
||||||
@ -68,34 +69,38 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
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");
|
try {
|
||||||
final Map indexMap = {};
|
// AppLog.log("indexList:$indexList");
|
||||||
indexMap['type'] = indexList[0].toString();
|
final Map indexMap = {};
|
||||||
|
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 int operateDate = time * 1000;
|
final int operateDate = time * 1000;
|
||||||
final int 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}');
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
indexMap['date'] = '$operateDate';
|
||||||
|
uploadList.add(indexMap);
|
||||||
|
} catch (e) {
|
||||||
|
AppLog.log('操作记录:$indexList,解析失败,跳过该跳记录,进行下一条记录解析。');
|
||||||
}
|
}
|
||||||
indexMap['date'] = '$operateDate';
|
|
||||||
uploadList.add(indexMap);
|
|
||||||
}
|
}
|
||||||
if (dataLength == state.logCountPage) {
|
if (dataLength == state.logCountPage) {
|
||||||
state.ifHaveNext = true;
|
state.ifHaveNext = true;
|
||||||
@ -246,6 +251,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
|||||||
|
|
||||||
/// 刷新门锁日志列表
|
/// 刷新门锁日志列表
|
||||||
StreamSubscription? _getDoorLockLogListRefreshUIEvent;
|
StreamSubscription? _getDoorLockLogListRefreshUIEvent;
|
||||||
|
|
||||||
void _getDoorLockLogListRefreshUIAction() {
|
void _getDoorLockLogListRefreshUIAction() {
|
||||||
_getDoorLockLogListRefreshUIEvent = eventBus
|
_getDoorLockLogListRefreshUIEvent = eventBus
|
||||||
.on<DoorLockLogListRefreshUI>()
|
.on<DoorLockLogListRefreshUI>()
|
||||||
|
|||||||
@ -296,38 +296,43 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
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');
|
try {
|
||||||
final Map indexMap = {};
|
AppLog.log('indexList:$indexList');
|
||||||
indexMap['type'] = indexList[0].toString();
|
final Map indexMap = {};
|
||||||
|
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]);
|
||||||
int operateDate = time * 1000;
|
int operateDate = time * 1000;
|
||||||
if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(
|
if (DateTime.fromMillisecondsSinceEpoch(operateDate).isAfter(
|
||||||
DateTime.fromMillisecondsSinceEpoch(getUTCNetTime() * 1000))) {
|
DateTime.fromMillisecondsSinceEpoch(
|
||||||
continue;
|
getUTCNetTime() * 1000))) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
indexMap['date'] = '$operateDate';
|
indexMap['date'] = '$operateDate';
|
||||||
uploadList.add(indexMap);
|
uploadList.add(indexMap);
|
||||||
|
|
||||||
if (i == getList.length - 1) {
|
if (i == getList.length - 1) {
|
||||||
//设置最后的时间戳
|
//设置最后的时间戳
|
||||||
|
|
||||||
state.operateDate = operateDate;
|
state.operateDate = operateDate;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
AppLog.log('操作记录:$indexList,解析失败,跳过该跳记录,进行下一条记录解析。');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lockRecordUploadData(uploadList);
|
lockRecordUploadData(uploadList);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user