From 3096eb41efec8d9e0f913f1c6aa98537e5f4feff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Tue, 11 Jun 2024 14:03:48 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E5=A4=8D=E5=BC=80=E9=94=81?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E4=B8=8A=E4=BC=A0=E8=AE=B0=E5=BD=95=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E9=97=AE=E9=A2=98=202=E3=80=81=E8=B7=9F=E9=99=88?= =?UTF-8?q?=E6=99=BA=E8=AE=A8=E8=AE=BA=E6=95=B0=E6=8D=AE=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=88=86=E9=A1=B5=E9=97=AE=E9=A2=98=203?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0=E9=94=81=E7=94=B5?= =?UTF-8?q?=E9=87=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 8196 -> 8196 bytes .../lockDetail/lockDetail_logic.dart | 16 ++-- .../lockOperatingRecord_logic.dart | 70 +++++++++--------- .../uploadElectricQuantity_entity.dart | 43 +++++++++++ .../uploadElectricQuantity_logic.dart | 54 +++++++------- .../uploadElectricQuantity_page.dart | 2 +- .../uploadElectricQuantity_state.dart | 2 +- .../lockSet/lockTime/lockTime_logic.dart | 50 ++++++++++--- .../lockSet/lockTime/lockTime_page.dart | 12 +-- .../lockSet/lockTime/lockTime_state.dart | 1 - .../lockSet/uploadData/uploadData_logic.dart | 10 +++ .../passwordKey_perpetual_page.dart | 3 +- lib/network/api_repository.dart | 5 +- 13 files changed, 175 insertions(+), 93 deletions(-) create mode 100644 lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_entity.dart diff --git a/.DS_Store b/.DS_Store index 2e1f43b30d6f6ee3763f1adbbe77a14a8a743420..4b155f0ab01776fdffe0af67d2832ff00e7700f3 100755 GIT binary patch delta 1016 zcmZp1XmOa}&nUJrU^hRb*k&F9N#@C~1xq*8&r9XxRCWjeiNpXg2ZJ_)BZDtP7(+Hg6~jb^xeO~Ab~Bt{xXbXK;U^pe zqc)=nqb;L7qX%OkV-RC9V+La;V;00nCPoO&APc3T6l3vZPthxz*(JWQO#UMhI~vo& IJEkuJ08|DN2mk;8 delta 100 zcmZp1XmOa}&nUVvU^hRb=w==PNoL0Flivsys)<)un;M(wC>WX5>L^rO8X4#)n3x*X z)^c))D(hPZ#b@W_=H+)z-X|>2*tPkda1G;RXYnH&3tlm9W|#QJGWnlK3`F2LBLD^M BA;$m! diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index cd588530..133bce35 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -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> 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 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 passwordData = reply.data.sublist(7, 17); + final List 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 uploadElectricQuantityRequest() async { - final KeyOperationRecordEntity entity = await ApiRepository.to + final UploadElectricQuantityEntity entity = await ApiRepository.to .uploadElectricQuantity( electricQuantity: state.electricQuantity.value.toString(), electricQuantityStandby: diff --git a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart index b3abc8b5..0e30ab29 100755 --- a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart +++ b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart @@ -23,7 +23,7 @@ class LockOperatingRecordLogic extends BaseGetXController { // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((reply) { + _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) { if (reply is SenderReferEventRecordTimeReply) { _replyReferEventRecordTime(reply); } @@ -33,12 +33,12 @@ class LockOperatingRecordLogic extends BaseGetXController { // 根据时间查解析数据 Future _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> 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 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 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 getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); - var publicKey = await Storage.getStringList(saveBluePublicKey); - List getPublicKeyList = changeStringListToIntList(publicKey!); + final List? publicKey = await Storage.getStringList(saveBluePublicKey); + final List getPublicKeyList = changeStringListToIntList(publicKey!); IoSenderManage.senderReferEventRecordTimeCommand( keyID: BlueManage().connectDeviceName, @@ -131,7 +131,7 @@ class LockOperatingRecordLogic extends BaseGetXController { //请求操作记录列表 Future 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(); diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_entity.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_entity.dart new file mode 100644 index 00000000..31a2613c --- /dev/null +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_entity.dart @@ -0,0 +1,43 @@ +class UploadElectricQuantityEntity { + + UploadElectricQuantityEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + UploadElectricQuantityEntity.fromJson(Map 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 toJson() { + final Map data = {}; + 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 json) { + electricQuantityDate = json['electricQuantityDate']; + } + int? electricQuantityDate; + + Map toJson() { + final Map data = {}; + data['electricQuantityDate'] = electricQuantityDate; + return data; + } +} \ No newline at end of file diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart index ea72be85..11be080d 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart @@ -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 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 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 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() { diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart index f4328633..6d6fd4ff 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart @@ -94,7 +94,7 @@ class _UploadElectricQuantityPageState extends State // 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(); }), ], ), diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart index fbc3a9b6..2a49df8c 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart @@ -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时间 } \ No newline at end of file diff --git a/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart b/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart index c38607c6..1e16f15d 100755 --- a/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart +++ b/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart @@ -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? privateKey = await Storage.getStringList(saveBluePrivateKey); + // final List getPrivateKeyList = changeStringListToIntList(privateKey!); + // + // final List? token = await Storage.getStringList(saveBlueToken); + // final List getTokenList = changeStringListToIntList(token!); + // + // final List? signKey = await Storage.getStringList(saveBlueSignKey); + // final List 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 getServerDatetime() async{ + Future 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 diff --git a/lib/main/lockDetail/lockSet/lockTime/lockTime_page.dart b/lib/main/lockDetail/lockSet/lockTime/lockTime_page.dart index b2ab732d..5122a776 100755 --- a/lib/main/lockDetail/lockSet/lockTime/lockTime_page.dart +++ b/lib/main/lockDetail/lockSet/lockTime/lockTime_page.dart @@ -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 with RouteAware{ - final logic = Get.put(LockTimeLogic()); - final state = Get.find().state; + final LockTimeLogic logic = Get.put(LockTimeLogic()); + final LockTimeState state = Get.find().state; @override Widget build(BuildContext context) { @@ -33,13 +33,13 @@ class _LockTimePageState extends State with RouteAware{ body: Container( padding: EdgeInsets.all(30.w), child: Column( - children: [ + children: [ SizedBox( height: 50.h, ), Obx(() => Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text(state.dateTime.value, style: TextStyle( fontSize: 26.sp, color: AppColors.blackColor)), @@ -56,7 +56,7 @@ class _LockTimePageState extends State with RouteAware{ padding: EdgeInsets.only(top: 20.w, bottom: 20.w), onClick: () { // logic.sendTiming(); - logic.getServerDatetime(); + logic.getServerDatetime(true); // logic.sendTiming(); }), SizedBox( diff --git a/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart b/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart index 5d012cdf..93be3938 100755 --- a/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart +++ b/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart @@ -10,7 +10,6 @@ class LockTimeState{// 0普通状态(可用) 1连接中(不可用) } Rx lockSetInfoData = LockSetInfoData().obs; RxString dateTime = ''.obs; - int differentialTime = 0; RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 RxInt sureBtnState = 0.obs; diff --git a/lib/main/lockDetail/lockSet/uploadData/uploadData_logic.dart b/lib/main/lockDetail/lockSet/uploadData/uploadData_logic.dart index 28aa0f8e..d439337b 100644 --- a/lib/main/lockDetail/lockSet/uploadData/uploadData_logic.dart +++ b/lib/main/lockDetail/lockSet/uploadData/uploadData_logic.dart @@ -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 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 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 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 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 token = reply.data.sublist(3, 7); updataLockPalmVeinList(token, state.uploadPalmVeinPage); }else{ diff --git a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index bbde119d..917bae6a 100755 --- a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -93,8 +93,7 @@ class _PasswordKeyPerpetualPageState extends State TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), keyBottomWidget( - '密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。' - .tr) + '密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。'.tr) ], ), ); diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 43dce014..e67709a8 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -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 uploadElectricQuantity( + Future 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); } //锁名称修改