1、修复开锁之后上传记录密码问题
2、跟陈智讨论数据上传问题,修复数据上传分页问题 3、修复更新锁电量问题
This commit is contained in:
parent
a8c6cb5977
commit
3096eb41ef
@ -29,6 +29,7 @@ import '../../../tools/storage.dart';
|
|||||||
import '../../../translations/trans_lib.dart';
|
import '../../../translations/trans_lib.dart';
|
||||||
import '../lockOperatingRecord/keyOperationRecord_entity.dart';
|
import '../lockOperatingRecord/keyOperationRecord_entity.dart';
|
||||||
import '../lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart';
|
import '../lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart';
|
||||||
|
import '../lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_entity.dart';
|
||||||
import 'lockDetail_state.dart';
|
import 'lockDetail_state.dart';
|
||||||
import 'lockNetToken_entity.dart';
|
import 'lockNetToken_entity.dart';
|
||||||
|
|
||||||
@ -195,7 +196,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
final int dataLength = (reply.data[5] << 8) + reply.data[6];
|
final int dataLength = (reply.data[5] << 8) + reply.data[6];
|
||||||
// AppLog.log("dataLength:$dataLength");
|
AppLog.log('dataLength:$dataLength');
|
||||||
if (dataLength > 0) {
|
if (dataLength > 0) {
|
||||||
reply.data.removeRange(0, 7);
|
reply.data.removeRange(0, 7);
|
||||||
// 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面
|
// 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面
|
||||||
@ -203,17 +204,18 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final List<List<int>> getList = splitList(reply.data, 17);
|
final List<List<int>> getList = splitList(reply.data, 17);
|
||||||
// AppLog.log("getList:$getList");
|
AppLog.log('getList:$getList');
|
||||||
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");
|
AppLog.log('indexList:$indexList');
|
||||||
final Map indexMap = {};
|
final Map indexMap = {};
|
||||||
indexMap['type'] = indexList[0].toString();
|
indexMap['type'] = indexList[0].toString();
|
||||||
int operateDate = 0;
|
int operateDate = 0;
|
||||||
if (indexList[0] == 2) {
|
if (indexList[0] == 2) {
|
||||||
final List<int> passwordData = reply.data.sublist(7, 17);
|
final List<int> passwordData = indexList.sublist(7, 17);
|
||||||
final String password = utf8String(passwordData);
|
final String password = utf8String(passwordData);
|
||||||
|
AppLog.log('passwordData:$passwordData password:$password');
|
||||||
indexMap['user'] = password.toString();
|
indexMap['user'] = password.toString();
|
||||||
} else {
|
} else {
|
||||||
final int userNo = (indexList[1] * 256) + indexList[2];
|
final int userNo = (indexList[1] * 256) + indexList[2];
|
||||||
@ -222,10 +224,10 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
|
|
||||||
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]);
|
||||||
operateDate = time * 1000;
|
operateDate = time * 1000;
|
||||||
indexMap['date'] = '$operateDate';
|
indexMap['date'] = '$operateDate';
|
||||||
uploadList.add(indexMap);
|
uploadList.add(indexMap);
|
||||||
@ -384,7 +386,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
|
|
||||||
//电量更新请求
|
//电量更新请求
|
||||||
Future<void> uploadElectricQuantityRequest() async {
|
Future<void> uploadElectricQuantityRequest() async {
|
||||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
final UploadElectricQuantityEntity entity = await ApiRepository.to
|
||||||
.uploadElectricQuantity(
|
.uploadElectricQuantity(
|
||||||
electricQuantity: state.electricQuantity.value.toString(),
|
electricQuantity: state.electricQuantity.value.toString(),
|
||||||
electricQuantityStandby:
|
electricQuantityStandby:
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
// 获取解析后的数据
|
// 获取解析后的数据
|
||||||
late StreamSubscription<Reply> _replySubscription;
|
late StreamSubscription<Reply> _replySubscription;
|
||||||
void _initReplySubscription() {
|
void _initReplySubscription() {
|
||||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||||
if (reply is SenderReferEventRecordTimeReply) {
|
if (reply is SenderReferEventRecordTimeReply) {
|
||||||
_replyReferEventRecordTime(reply);
|
_replyReferEventRecordTime(reply);
|
||||||
}
|
}
|
||||||
@ -33,12 +33,12 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
// 根据时间查解析数据
|
// 根据时间查解析数据
|
||||||
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
int status = reply.data[2];
|
final int status = reply.data[2];
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
int dataLength = (reply.data[5] << 8) + reply.data[6];
|
final int dataLength = (reply.data[5] << 8) + reply.data[6];
|
||||||
AppLog.log("dataLength:$dataLength");
|
AppLog.log('dataLength:$dataLength');
|
||||||
// var dataLength = reply.data[5];
|
// var dataLength = reply.data[5];
|
||||||
if (dataLength > 0) {
|
if (dataLength > 0) {
|
||||||
reply.data.removeRange(0, 7);
|
reply.data.removeRange(0, 7);
|
||||||
@ -46,32 +46,32 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
if(reply.data.length < 17){
|
if(reply.data.length < 17){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var getList = splitList(reply.data, 17);
|
final List<List<int>> getList = splitList(reply.data, 17);
|
||||||
AppLog.log("getList:$getList");
|
AppLog.log('getList:$getList');
|
||||||
var uploadList = [];
|
final List uploadList = [];
|
||||||
for (int i = 0; i < getList.length; i++) {
|
for (int i = 0; i < getList.length; i++) {
|
||||||
var indexList = getList[i];
|
final List<int> indexList = getList[i];
|
||||||
AppLog.log("indexList:$indexList");
|
AppLog.log('indexList:$indexList');
|
||||||
var indexMap = {};
|
final Map indexMap = {};
|
||||||
indexMap["type"] = indexList[0].toString();
|
indexMap['type'] = indexList[0].toString();
|
||||||
|
|
||||||
if(indexList[0] == 2){
|
if(indexList[0] == 2){
|
||||||
var passwordData = indexList.sublist(7, 17);
|
final List<int> passwordData = indexList.sublist(7, 17);
|
||||||
var password = utf8String(passwordData);
|
final String password = utf8String(passwordData);
|
||||||
AppLog.log("password:$password passwordData:$passwordData");
|
AppLog.log('password:$password passwordData:$passwordData');
|
||||||
indexMap["user"] = password;
|
indexMap['user'] = password;
|
||||||
}else{
|
}else{
|
||||||
int userNo = (indexList[1]*256) + indexList[2];
|
final int userNo = (indexList[1]*256) + indexList[2];
|
||||||
indexMap["user"] = userNo.toString();
|
indexMap['user'] = userNo.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
indexMap["success"] = "1";
|
indexMap['success'] = '1';
|
||||||
|
|
||||||
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]);
|
||||||
indexMap["date"] = "${time * 1000}";
|
indexMap['date'] = '${time * 1000}';
|
||||||
uploadList.add(indexMap);
|
uploadList.add(indexMap);
|
||||||
}
|
}
|
||||||
lockRecordUploadData(uploadList);
|
lockRecordUploadData(uploadList);
|
||||||
@ -99,14 +99,14 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
});
|
});
|
||||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async {
|
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async {
|
||||||
if (connectionStateState == BluetoothConnectionState.connected) {
|
if (connectionStateState == BluetoothConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
var token = await Storage.getStringList(saveBlueToken);
|
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||||
List<int> getTokenList = changeStringListToIntList(token!);
|
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
final List<String>? publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
final List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||||
|
|
||||||
IoSenderManage.senderReferEventRecordTimeCommand(
|
IoSenderManage.senderReferEventRecordTimeCommand(
|
||||||
keyID: BlueManage().connectDeviceName,
|
keyID: BlueManage().connectDeviceName,
|
||||||
@ -131,7 +131,7 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
|
|
||||||
//请求操作记录列表
|
//请求操作记录列表
|
||||||
Future<KeyOperationRecordEntity> mockNetworkDataRequest() async {
|
Future<KeyOperationRecordEntity> mockNetworkDataRequest() async {
|
||||||
KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordList(
|
final KeyOperationRecordEntity entity = await ApiRepository.to.lockRecordList(
|
||||||
lockId:CommonDataManage().currentKeyInfo.lockId.toString(),
|
lockId:CommonDataManage().currentKeyInfo.lockId.toString(),
|
||||||
pageNo:pageNo.toString(),
|
pageNo:pageNo.toString(),
|
||||||
recordType:'',
|
recordType:'',
|
||||||
@ -161,7 +161,7 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 查询锁记录最后时间
|
// 查询锁记录最后时间
|
||||||
void getLockRecordLastUploadDataTime() async {
|
void getLockRecordLastUploadDataTime() async {
|
||||||
LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to
|
final LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to
|
||||||
.getLockRecordLastUploadDataTime(
|
.getLockRecordLastUploadDataTime(
|
||||||
lockId: CommonDataManage().currentKeyInfo.lockId.toString());
|
lockId: CommonDataManage().currentKeyInfo.lockId.toString());
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
@ -172,7 +172,7 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 操作记录上传
|
// 操作记录上传
|
||||||
void lockRecordUploadData(List list) async {
|
void lockRecordUploadData(List list) async {
|
||||||
KeyOperationRecordEntity entity = await ApiRepository.to
|
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 (entity.errorCode!.codeIsSuccessful) {
|
||||||
if(state.ifHaveNext == true){
|
if(state.ifHaveNext == true){
|
||||||
@ -186,9 +186,9 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
|
|
||||||
//清空操作记录
|
//清空操作记录
|
||||||
void clearOperationRecordRequest() async {
|
void clearOperationRecordRequest() async {
|
||||||
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) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
showToast("清除数据成功", something: (){
|
showToast('清除数据成功', something: (){
|
||||||
pageNo = 1;
|
pageNo = 1;
|
||||||
mockNetworkDataRequest();
|
mockNetworkDataRequest();
|
||||||
});
|
});
|
||||||
@ -201,7 +201,7 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
super.onReady();
|
super.onReady();
|
||||||
|
|
||||||
// 获取是否是演示模式 演示模式不获取接口
|
// 获取是否是演示模式 演示模式不获取接口
|
||||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||||
if (isDemoMode == false) {
|
if (isDemoMode == false) {
|
||||||
// _initReplySubscription();
|
// _initReplySubscription();
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
super.onInit();
|
super.onInit();
|
||||||
|
|
||||||
// 获取是否是演示模式 演示模式不获取接口
|
// 获取是否是演示模式 演示模式不获取接口
|
||||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||||
if (isDemoMode == false) {
|
if (isDemoMode == false) {
|
||||||
getLockRecordLastUploadDataTime();
|
getLockRecordLastUploadDataTime();
|
||||||
// senderReferEventRecordTime();
|
// senderReferEventRecordTime();
|
||||||
@ -230,7 +230,7 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
|||||||
super.onClose();
|
super.onClose();
|
||||||
|
|
||||||
//获取是否是演示模式 演示模式不获取接口
|
//获取是否是演示模式 演示模式不获取接口
|
||||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||||
if (isDemoMode == false) {
|
if (isDemoMode == false) {
|
||||||
_replySubscription.cancel();
|
_replySubscription.cancel();
|
||||||
// _getDoorLockLogListRefreshUIEvent?.cancel();
|
// _getDoorLockLogListRefreshUIEvent?.cancel();
|
||||||
|
|||||||
@ -0,0 +1,43 @@
|
|||||||
|
class UploadElectricQuantityEntity {
|
||||||
|
|
||||||
|
UploadElectricQuantityEntity(
|
||||||
|
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||||
|
|
||||||
|
UploadElectricQuantityEntity.fromJson(Map<String, dynamic> json) {
|
||||||
|
errorCode = json['errorCode'];
|
||||||
|
description = json['description'];
|
||||||
|
errorMsg = json['errorMsg'];
|
||||||
|
data = json['data'] != null ? Data.fromJson(json['data']) : null;
|
||||||
|
}
|
||||||
|
int? errorCode;
|
||||||
|
String? description;
|
||||||
|
String? errorMsg;
|
||||||
|
Data? data;
|
||||||
|
|
||||||
|
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 {
|
||||||
|
|
||||||
|
Data({this.electricQuantityDate});
|
||||||
|
|
||||||
|
Data.fromJson(Map<String, dynamic> json) {
|
||||||
|
electricQuantityDate = json['electricQuantityDate'];
|
||||||
|
}
|
||||||
|
int? electricQuantityDate;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['electricQuantityDate'] = electricQuantityDate;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,10 +1,9 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
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/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart';
|
|
||||||
|
|
||||||
import '../../../../../app_settings/app_settings.dart';
|
|
||||||
import '../../../../../blue/blue_manage.dart';
|
import '../../../../../blue/blue_manage.dart';
|
||||||
import '../../../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
import '../../../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
||||||
import '../../../../../blue/io_reply.dart';
|
import '../../../../../blue/io_reply.dart';
|
||||||
@ -13,10 +12,10 @@ import '../../../../../blue/io_tool/manager_event_bus.dart';
|
|||||||
import '../../../../../blue/sender_manage.dart';
|
import '../../../../../blue/sender_manage.dart';
|
||||||
import '../../../../../network/api_repository.dart';
|
import '../../../../../network/api_repository.dart';
|
||||||
import '../../../../../tools/baseGetXController.dart';
|
import '../../../../../tools/baseGetXController.dart';
|
||||||
import '../../../../../tools/dateTool.dart';
|
|
||||||
import '../../../../../tools/eventBusEventManage.dart';
|
import '../../../../../tools/eventBusEventManage.dart';
|
||||||
import '../../../../../tools/storage.dart';
|
import '../../../../../tools/storage.dart';
|
||||||
import '../../../lockOperatingRecord/keyOperationRecord_entity.dart';
|
|
||||||
|
import 'uploadElectricQuantity_entity.dart';
|
||||||
import 'uploadElectricQuantity_state.dart';
|
import 'uploadElectricQuantity_state.dart';
|
||||||
|
|
||||||
class UploadElectricQuantityLogic extends BaseGetXController {
|
class UploadElectricQuantityLogic extends BaseGetXController {
|
||||||
@ -25,13 +24,16 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
|||||||
//电量更新请求
|
//电量更新请求
|
||||||
Future<void> uploadElectricQuantityRequest(
|
Future<void> uploadElectricQuantityRequest(
|
||||||
String electricQuantity, String electricQuantityStandby) async {
|
String electricQuantity, String electricQuantityStandby) async {
|
||||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
final UploadElectricQuantityEntity entity = await ApiRepository.to
|
||||||
.uploadElectricQuantity(
|
.uploadElectricQuantity(
|
||||||
electricQuantity: electricQuantity,
|
electricQuantity: electricQuantity,
|
||||||
electricQuantityStandby: electricQuantityStandby,
|
electricQuantityStandby: electricQuantityStandby,
|
||||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||||
isUnShowLoading: false);
|
isUnShowLoading: false);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
state.uploadElectricQuantityDate.value = entity.data!.electricQuantityDate!;
|
||||||
|
state.lockSetInfoData.value.lockBasicInfo!.electricQuantityDate = state.uploadElectricQuantityDate.value;
|
||||||
|
|
||||||
showToast('锁电量更新成功'.tr, something: () {
|
showToast('锁电量更新成功'.tr, something: () {
|
||||||
eventBus
|
eventBus
|
||||||
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||||
@ -64,8 +66,8 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
|||||||
IoSenderManage.senderGetStarLockStatuInfo(
|
IoSenderManage.senderGetStarLockStatuInfo(
|
||||||
lockID: BlueManage().connectDeviceName,
|
lockID: BlueManage().connectDeviceName,
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
utcTimeStamp: state.serverTime,
|
utcTimeStamp: 0,
|
||||||
unixTimeStamp: getLocalTime(),
|
unixTimeStamp: 0,
|
||||||
isBeforeAddUser: false,
|
isBeforeAddUser: false,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
@ -114,10 +116,6 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
|||||||
state.lockSetInfoData.value.lockBasicInfo!.electricQuantityStandby =
|
state.lockSetInfoData.value.lockBasicInfo!.electricQuantityStandby =
|
||||||
battRemCapStandby;
|
battRemCapStandby;
|
||||||
|
|
||||||
state.uploadElectricQuantityDate.value =
|
|
||||||
DateTime.now().millisecondsSinceEpoch;
|
|
||||||
state.lockSetInfoData.value.lockBasicInfo!.electricQuantityDate =
|
|
||||||
DateTime.now().millisecondsSinceEpoch;
|
|
||||||
uploadElectricQuantityRequest(
|
uploadElectricQuantityRequest(
|
||||||
battRemCap.toString(), battRemCapStandby.toString());
|
battRemCap.toString(), battRemCapStandby.toString());
|
||||||
break;
|
break;
|
||||||
@ -130,8 +128,8 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
|||||||
IoSenderManage.senderGetStarLockStatuInfo(
|
IoSenderManage.senderGetStarLockStatuInfo(
|
||||||
lockID: BlueManage().connectDeviceName,
|
lockID: BlueManage().connectDeviceName,
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
utcTimeStamp: state.serverTime,
|
utcTimeStamp: 0,
|
||||||
unixTimeStamp: getLocalTime(),
|
unixTimeStamp: 0,
|
||||||
isBeforeAddUser: false,
|
isBeforeAddUser: false,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
@ -143,21 +141,21 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从服务器获取锁的时间 开锁时传入
|
// // 从服务器获取锁的时间 开锁时传入
|
||||||
Future<void> getServerDatetime() async {
|
// Future<void> getServerDatetime() async {
|
||||||
final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(isUnShowLoading:false);
|
// final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(isUnShowLoading:false);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
// if (entity.errorCode!.codeIsSuccessful) {
|
||||||
state.serverTime = entity.data!.date! ~/ 1000;
|
// state.serverTime = entity.data!.date! ~/ 1000;
|
||||||
getStarLockStatus();
|
// getStarLockStatus();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
int getLocalTime(){
|
// int getLocalTime(){
|
||||||
final DateTime now = DateTime.now();
|
// final DateTime now = DateTime.now();
|
||||||
final Duration timeZoneOffset = now.timeZoneOffset;
|
// final Duration timeZoneOffset = now.timeZoneOffset;
|
||||||
AppLog.log('timeZoneOffset.inSeconds:$timeZoneOffset.inSeconds');
|
// AppLog.log('timeZoneOffset.inSeconds:$timeZoneOffset.inSeconds');
|
||||||
return state.serverTime + timeZoneOffset.inSeconds;
|
// return state.serverTime + timeZoneOffset.inSeconds;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
|
|||||||
@ -94,7 +94,7 @@ class _UploadElectricQuantityPageState extends State<UploadElectricQuantityPage>
|
|||||||
// margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w),
|
// margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w),
|
||||||
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
||||||
onClick: () {
|
onClick: () {
|
||||||
logic.getServerDatetime();
|
logic.getStarLockStatus();
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -23,5 +23,5 @@ class UploadElectricQuantityState {// 0普通状态可用 1不可用
|
|||||||
RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||||
RxInt sureBtnState = 0.obs;
|
RxInt sureBtnState = 0.obs;
|
||||||
|
|
||||||
int serverTime = 0;// 服务器时间即UTC+0时间
|
// int serverTime = 0;// 服务器时间即UTC+0时间
|
||||||
}
|
}
|
||||||
@ -64,8 +64,8 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
IoSenderManage.senderGetStarLockStatuInfo(
|
IoSenderManage.senderGetStarLockStatuInfo(
|
||||||
lockID: BlueManage().connectDeviceName,
|
lockID: BlueManage().connectDeviceName,
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
utcTimeStamp: 0,
|
utcTimeStamp: state.serverTime,
|
||||||
unixTimeStamp: 0,
|
unixTimeStamp: getLocalTime(),
|
||||||
isBeforeAddUser: false,
|
isBeforeAddUser: false,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
@ -82,7 +82,7 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
switch(status){
|
switch(status){
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
final String dataEime = DateTool().dateToYMDHNString('${state.differentialTime}');
|
final String dataEime = DateTool().dateToYMDHNString('${state.serverTime}');
|
||||||
state.dateTime.value = dataEime;
|
state.dateTime.value = dataEime;
|
||||||
|
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
@ -92,6 +92,24 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
//无权限
|
//无权限
|
||||||
|
// final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
// final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
//
|
||||||
|
// final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||||
|
// final List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
//
|
||||||
|
// final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||||
|
// final List<int> getSignKeyList = changeStringListToIntList(signKey!);
|
||||||
|
//
|
||||||
|
// IoSenderManage.senderTimingCommand(
|
||||||
|
// lockID:BlueManage().connectDeviceName,
|
||||||
|
// userID:await Storage.getUid(),
|
||||||
|
// nowTime: state.serverTime,
|
||||||
|
// token:getTokenList,
|
||||||
|
// needAuthor:1,
|
||||||
|
// signKey:getSignKeyList,
|
||||||
|
// privateKey:getPrivateKeyList,
|
||||||
|
// );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -124,7 +142,7 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
IoSenderManage.senderTimingCommand(
|
IoSenderManage.senderTimingCommand(
|
||||||
lockID:BlueManage().connectDeviceName,
|
lockID:BlueManage().connectDeviceName,
|
||||||
userID:await Storage.getUid(),
|
userID:await Storage.getUid(),
|
||||||
nowTime: state.differentialTime,
|
nowTime: state.serverTime,
|
||||||
token:getTokenList,
|
token:getTokenList,
|
||||||
needAuthor:1,
|
needAuthor:1,
|
||||||
signKey:getSignKeyList,
|
signKey:getSignKeyList,
|
||||||
@ -156,8 +174,8 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
IoSenderManage.senderGetStarLockStatuInfo(
|
IoSenderManage.senderGetStarLockStatuInfo(
|
||||||
lockID: BlueManage().connectDeviceName,
|
lockID: BlueManage().connectDeviceName,
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
utcTimeStamp: 0,
|
utcTimeStamp: state.serverTime,
|
||||||
unixTimeStamp: 0,
|
unixTimeStamp: getLocalTime(),
|
||||||
isBeforeAddUser: false,
|
isBeforeAddUser: false,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
@ -182,15 +200,26 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 从服务器获取锁的时间 开锁时传入
|
// 从服务器获取锁的时间 开锁时传入
|
||||||
Future<void> getServerDatetime() async{
|
Future<void> getServerDatetime(bool isSendTime) async{
|
||||||
final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(isUnShowLoading:false);
|
final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(isUnShowLoading:false);
|
||||||
if(entity.errorCode!.codeIsSuccessful){
|
if(entity.errorCode!.codeIsSuccessful){
|
||||||
state.differentialTime = entity.data!.date! ~/ 1000;
|
state.serverTime = entity.data!.date! ~/ 1000;
|
||||||
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
|
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
|
||||||
sendTiming();
|
if(isSendTime == false){
|
||||||
|
getStarLockStatus();
|
||||||
|
}else{
|
||||||
|
sendTiming();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getLocalTime(){
|
||||||
|
final DateTime now = DateTime.now();
|
||||||
|
final Duration timeZoneOffset = now.timeZoneOffset;
|
||||||
|
AppLog.log('timeZoneOffset.inSeconds:$timeZoneOffset.inSeconds');
|
||||||
|
return state.serverTime + timeZoneOffset.inSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
super.onReady();
|
super.onReady();
|
||||||
@ -199,7 +228,8 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// getLockTimeFromGateway();
|
// getLockTimeFromGateway();
|
||||||
|
|
||||||
getStarLockStatus();
|
getServerDatetime(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/lockSet/lockTime/lockTime_state.dart';
|
||||||
|
|
||||||
import '../../../../app_settings/app_colors.dart';
|
import '../../../../app_settings/app_colors.dart';
|
||||||
import '../../../../blue/blue_manage.dart';
|
|
||||||
import '../../../../tools/appRouteObserver.dart';
|
import '../../../../tools/appRouteObserver.dart';
|
||||||
import '../../../../tools/submitBtn.dart';
|
import '../../../../tools/submitBtn.dart';
|
||||||
import '../../../../tools/titleAppBar.dart';
|
import '../../../../tools/titleAppBar.dart';
|
||||||
@ -19,8 +19,8 @@ class LockTimePage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LockTimePageState extends State<LockTimePage> with RouteAware{
|
class _LockTimePageState extends State<LockTimePage> with RouteAware{
|
||||||
final logic = Get.put(LockTimeLogic());
|
final LockTimeLogic logic = Get.put(LockTimeLogic());
|
||||||
final state = Get.find<LockTimeLogic>().state;
|
final LockTimeState state = Get.find<LockTimeLogic>().state;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -33,13 +33,13 @@ class _LockTimePageState extends State<LockTimePage> with RouteAware{
|
|||||||
body: Container(
|
body: Container(
|
||||||
padding: EdgeInsets.all(30.w),
|
padding: EdgeInsets.all(30.w),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: <Widget>[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 50.h,
|
height: 50.h,
|
||||||
),
|
),
|
||||||
Obx(() => Row(
|
Obx(() => Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: <Widget>[
|
||||||
Text(state.dateTime.value,
|
Text(state.dateTime.value,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 26.sp, color: AppColors.blackColor)),
|
fontSize: 26.sp, color: AppColors.blackColor)),
|
||||||
@ -56,7 +56,7 @@ class _LockTimePageState extends State<LockTimePage> with RouteAware{
|
|||||||
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
||||||
onClick: () {
|
onClick: () {
|
||||||
// logic.sendTiming();
|
// logic.sendTiming();
|
||||||
logic.getServerDatetime();
|
logic.getServerDatetime(true);
|
||||||
// logic.sendTiming();
|
// logic.sendTiming();
|
||||||
}),
|
}),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
|||||||
@ -10,7 +10,6 @@ class LockTimeState{// 0普通状态(可用) 1连接中(不可用)
|
|||||||
}
|
}
|
||||||
Rx<LockSetInfoData> lockSetInfoData = LockSetInfoData().obs;
|
Rx<LockSetInfoData> lockSetInfoData = LockSetInfoData().obs;
|
||||||
RxString dateTime = ''.obs;
|
RxString dateTime = ''.obs;
|
||||||
int differentialTime = 0;
|
|
||||||
|
|
||||||
RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||||
RxInt sureBtnState = 0.obs;
|
RxInt sureBtnState = 0.obs;
|
||||||
|
|||||||
@ -73,6 +73,8 @@ class UploadDataLogic extends BaseGetXController{
|
|||||||
state.uploadPasswordDataList.addAll(reply.data.sublist(9, reply.data.length));
|
state.uploadPasswordDataList.addAll(reply.data.sublist(9, reply.data.length));
|
||||||
if(dataLength == 10){
|
if(dataLength == 10){
|
||||||
// 当数据是10的时候继续请求
|
// 当数据是10的时候继续请求
|
||||||
|
state.uploadPasswordPage = state.uploadPasswordPage + 1;
|
||||||
|
|
||||||
final List<int> token = reply.data.sublist(3, 7);
|
final List<int> token = reply.data.sublist(3, 7);
|
||||||
updataLockPasswordList(token, state.uploadPasswordPage);
|
updataLockPasswordList(token, state.uploadPasswordPage);
|
||||||
}else{
|
}else{
|
||||||
@ -119,6 +121,8 @@ class UploadDataLogic extends BaseGetXController{
|
|||||||
state.uploadCardDataList.addAll(reply.data.sublist(9, reply.data.length));
|
state.uploadCardDataList.addAll(reply.data.sublist(9, reply.data.length));
|
||||||
if(dataLength == 10){
|
if(dataLength == 10){
|
||||||
// 当数据是10的时候继续请求
|
// 当数据是10的时候继续请求
|
||||||
|
state.uploadCardPage = state.uploadCardPage + 1;
|
||||||
|
|
||||||
final List<int> token = reply.data.sublist(3, 7);
|
final List<int> token = reply.data.sublist(3, 7);
|
||||||
updataLockCardList(token, state.uploadCardPage);
|
updataLockCardList(token, state.uploadCardPage);
|
||||||
}else{
|
}else{
|
||||||
@ -163,6 +167,8 @@ class UploadDataLogic extends BaseGetXController{
|
|||||||
state.uploadFingerprintDataList.addAll(reply.data.sublist(9, reply.data.length));
|
state.uploadFingerprintDataList.addAll(reply.data.sublist(9, reply.data.length));
|
||||||
if(dataLength == 10){
|
if(dataLength == 10){
|
||||||
// 当数据是10的时候继续请求
|
// 当数据是10的时候继续请求
|
||||||
|
state.uploadFingerprintPage = state.uploadFingerprintPage + 1;
|
||||||
|
|
||||||
final List<int> token = reply.data.sublist(3, 7);
|
final List<int> token = reply.data.sublist(3, 7);
|
||||||
updataLockFingerprintList(token, state.uploadFingerprintPage);
|
updataLockFingerprintList(token, state.uploadFingerprintPage);
|
||||||
}else{
|
}else{
|
||||||
@ -207,6 +213,8 @@ class UploadDataLogic extends BaseGetXController{
|
|||||||
state.uploadFaceDataList.addAll(reply.data.sublist(9, reply.data.length));
|
state.uploadFaceDataList.addAll(reply.data.sublist(9, reply.data.length));
|
||||||
if(dataLength == 10){
|
if(dataLength == 10){
|
||||||
// 当数据是10的时候继续请求
|
// 当数据是10的时候继续请求
|
||||||
|
state.uploadFacePage = state.uploadFacePage + 1;
|
||||||
|
|
||||||
final List<int> token = reply.data.sublist(3, 7);
|
final List<int> token = reply.data.sublist(3, 7);
|
||||||
updataLockFaceList(token, state.uploadFacePage);
|
updataLockFaceList(token, state.uploadFacePage);
|
||||||
}else{
|
}else{
|
||||||
@ -251,6 +259,8 @@ class UploadDataLogic extends BaseGetXController{
|
|||||||
state.uploadPalmVeinDataList.addAll(reply.data.sublist(9, reply.data.length));
|
state.uploadPalmVeinDataList.addAll(reply.data.sublist(9, reply.data.length));
|
||||||
if(dataLength == 10){
|
if(dataLength == 10){
|
||||||
// 当数据是10的时候继续请求
|
// 当数据是10的时候继续请求
|
||||||
|
state.uploadPalmVeinPage = state.uploadPalmVeinPage + 1;
|
||||||
|
|
||||||
final List<int> token = reply.data.sublist(3, 7);
|
final List<int> token = reply.data.sublist(3, 7);
|
||||||
updataLockPalmVeinList(token, state.uploadPalmVeinPage);
|
updataLockPalmVeinList(token, state.uploadPalmVeinPage);
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@ -93,8 +93,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
|
|||||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||||
state.nameController),
|
state.nameController),
|
||||||
keyBottomWidget(
|
keyBottomWidget(
|
||||||
'密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。'
|
'密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。'.tr)
|
||||||
.tr)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -59,6 +59,7 @@ import '../main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/che
|
|||||||
import '../main/lockDetail/fingerprint/addFingerprint/addFingerprint_entity.dart';
|
import '../main/lockDetail/fingerprint/addFingerprint/addFingerprint_entity.dart';
|
||||||
import '../main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
import '../main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||||
import '../main/lockDetail/lockOperatingRecord/keyOperationRecord_entity.dart';
|
import '../main/lockDetail/lockOperatingRecord/keyOperationRecord_entity.dart';
|
||||||
|
import '../main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_entity.dart';
|
||||||
import '../main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifiEntity.dart';
|
import '../main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifiEntity.dart';
|
||||||
import '../main/lockDetail/lockSet/lockSet/checkingInInfoData_entity.dart';
|
import '../main/lockDetail/lockSet/lockSet/checkingInInfoData_entity.dart';
|
||||||
import '../main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
|
import '../main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
|
||||||
@ -340,14 +341,14 @@ class ApiRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//锁电量更新
|
//锁电量更新
|
||||||
Future<KeyOperationRecordEntity> uploadElectricQuantity(
|
Future<UploadElectricQuantityEntity> uploadElectricQuantity(
|
||||||
{required String? electricQuantity,
|
{required String? electricQuantity,
|
||||||
required String? electricQuantityStandby,
|
required String? electricQuantityStandby,
|
||||||
required String? lockId,
|
required String? lockId,
|
||||||
required bool? isUnShowLoading}) async {
|
required bool? isUnShowLoading}) async {
|
||||||
final res = await apiProvider.uploadElectricQuantity(
|
final res = await apiProvider.uploadElectricQuantity(
|
||||||
electricQuantity!, electricQuantityStandby!, lockId!, isUnShowLoading!);
|
electricQuantity!, electricQuantityStandby!, lockId!, isUnShowLoading!);
|
||||||
return KeyOperationRecordEntity.fromJson(res.body);
|
return UploadElectricQuantityEntity.fromJson(res.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
//锁名称修改
|
//锁名称修改
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user