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