Merge branch 'master' of gitee.com:starlock-cn/app-starlock

This commit is contained in:
Daisy 2024-04-30 16:32:02 +08:00
commit 8d34a727f8
12 changed files with 114 additions and 57 deletions

View File

@ -41,7 +41,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
}
GetMaterialApp _initMaterialApp() => GetMaterialApp(
enableLog: false,
// enableLog: false,
title: F.navTitle,
navigatorObservers: [AppRouteObserver().routeObserver],
translations: TranslationMessage(),

View File

@ -1,4 +1,5 @@
import 'package:flutter/foundation.dart';
import 'package:get/get.dart';
import 'dart:io';
import 'package:star_lock/debug/debug_console.dart';
@ -20,7 +21,7 @@ class AppLog {
msg = '----->>> $msg';
}
DebugConsole.info(msg);
print(msg);
Get.log(msg);
}
}

View File

@ -69,6 +69,7 @@ class LockDetailLogic extends BaseGetXController {
case 0x00:
//
// _showFullScreenOverlay(Get.context!);
cancelBlueConnetctToastTimer();
state.iSClosedUnlockSuccessfulPopup.value = true;
if (state.closedUnlockSuccessfulTimer != null) {
@ -86,7 +87,14 @@ class LockDetailLogic extends BaseGetXController {
int power = reply.data[7];
state.electricQuantity.value = power;
cancelBlueConnetctToastTimer();
//
if(state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1){
int powerStandby = reply.data[9];
state.electricQuantityStandby.value = powerStandby;
}
//
uploadElectricQuantityRequest();
getLockRecordLastUploadDataTime();
state.openLockBtnState.value = 0;
@ -431,6 +439,20 @@ class LockDetailLogic extends BaseGetXController {
}
}
//
Future<void> uploadElectricQuantityRequest() async {
KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity(
electricQuantity:state.electricQuantity.value.toString(),
electricQuantityStandby: state.electricQuantityStandby.value.toString(),
lockId: state.keyInfos.value.lockId.toString()
);
if (entity.errorCode!.codeIsSuccessful) {
SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent());
});
}
}
// NO
// void _updateLockUserNo() async {
// LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo(

View File

@ -529,30 +529,33 @@ class _LockDetailPageState extends State<LockDetailPage>
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FlavorsImg(
child: Image.asset(
showElectricIcon(state.electricQuantity.value),
width: 30.w,
height: 24.w),
),
SizedBox(width: 2.w),
Text("--%",
style: TextStyle(
fontSize: 18.sp,
color: AppColors.darkGrayTextColor)),
SizedBox(width: 2.w),
FlavorsImg(
child: Icon(
Icons.info, // 使 warning
color: AppColors.mainColor, //
size: 25.w, // 30
Visibility(
visible: state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FlavorsImg(
child: Image.asset(
showElectricIcon(state.electricQuantityStandby.value),
width: 30.w,
height: 24.w),
),
),
SizedBox(width: 20.w),
],
SizedBox(width: 2.w),
Text("${state.electricQuantityStandby.value}%",
style: TextStyle(
fontSize: 18.sp,
color: AppColors.darkGrayTextColor)),
SizedBox(width: 2.w),
FlavorsImg(
child: Icon(
Icons.info, // 使 warning
color: AppColors.mainColor, //
size: 25.w, // 30
),
),
SizedBox(width: 20.w),
],
),
),
],
))

View File

@ -22,6 +22,7 @@ class LockDetailState {
var isAttendance = 0.obs; //
var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网
var electricQuantity = 0.obs; //
var electricQuantityStandby = 0.obs; //
var isOpenPassageMode = 0.obs; //
var lockAlias = "".obs; //

View File

@ -21,10 +21,12 @@ class UploadElectricQuantityLogic extends BaseGetXController {
final UploadElectricQuantityState state = UploadElectricQuantityState();
//
Future<void> uploadElectricQuantityRequest(String electricQuantity) async {
KeyOperationRecordEntity entity = await ApiRepository.to
.uploadElectricQuantity(
electricQuantity, state.lockSetInfoData.value.lockId.toString());
Future<void> uploadElectricQuantityRequest(String electricQuantity, String electricQuantityStandby) async {
KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity(
electricQuantity:electricQuantity,
electricQuantityStandby: electricQuantityStandby,
lockId: state.lockSetInfoData.value.lockId.toString()
);
if (entity.errorCode!.codeIsSuccessful) {
showToast("锁电量更新成功".tr, something: () {
eventBus
@ -95,13 +97,15 @@ class UploadElectricQuantityLogic extends BaseGetXController {
//
var battRemCap = reply.data[132];
state.lockSetInfoData.value.lockBasicInfo!.electricQuantity =
battRemCap;
state.uploadElectricQuantityDate.value =
DateTime.now().millisecondsSinceEpoch;
state.lockSetInfoData.value.lockBasicInfo!.electricQuantityDate =
DateTime.now().millisecondsSinceEpoch;
uploadElectricQuantityRequest(battRemCap.toString());
state.lockSetInfoData.value.lockBasicInfo!.electricQuantity = battRemCap;
//
var battRemCapStandby = reply.data[133];
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;
case 0x06:
//

View File

@ -55,20 +55,23 @@ class _UploadElectricQuantityPageState extends State<UploadElectricQuantityPage>
children: [
Expanded(
child: Text(
"${"电池1".tr}:${TranslationLoader.lanKeys!.electricQuantity!.tr}:${state.lockBasicInfo!.value.electricQuantity ?? ""}%",
"${"电池1".tr}:${TranslationLoader.lanKeys!.electricQuantity!.tr}:${state.lockBasicInfo.value.electricQuantity ?? ""}%",
style: TextStyle(fontSize: 20.sp),
)),
],
)),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: Text(
"${"电池2".tr}:${TranslationLoader.lanKeys!.electricQuantity!.tr}:--%",
style: TextStyle(fontSize: 20.sp),
)),
],
Visibility(
visible: state.lockSetInfoData.value.lockFeature!.isSupportBackupBattery == 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: Text(
"${"电池2".tr}:${TranslationLoader.lanKeys!.electricQuantity!.tr}:${state.lockBasicInfo.value.electricQuantityStandby ?? ""}%",
style: TextStyle(fontSize: 20.sp),
)),
],
),
),
SizedBox(height: 10.h),
Obx(() => Row(

View File

@ -145,6 +145,7 @@ class LockFeature {
int? motorTorsion;
int? stayWarn;
int? abnormalWarn;
int? isSupportBackupBattery; // 0: 1:
LockFeature({
this.password,
@ -200,6 +201,7 @@ class LockFeature {
this.motorTorsion,
this.stayWarn,
this.abnormalWarn,
this.isSupportBackupBattery,
});
LockFeature.fromJson(Map<String, dynamic> json) {
@ -256,6 +258,7 @@ class LockFeature {
motorTorsion = json['motorTorsion'];
stayWarn = json['stayWarn'];
abnormalWarn = json['abnormalWarn'];
isSupportBackupBattery = json['isSupportBackupBattery'];
}
Map<String, dynamic> toJson() {
@ -313,6 +316,7 @@ class LockFeature {
data['motorTorsion'] = motorTorsion;
data['stayWarn'] = stayWarn;
data['abnormalWarn'] = abnormalWarn;
data['isSupportBackupBattery'] = isSupportBackupBattery;
return data;
}
}
@ -323,6 +327,7 @@ class LockBasicInfo {
int? keyId;
String? model;
int? electricQuantity;
int? electricQuantityStandby;
int? indate;
int? isLockOwner;
String? lockAlias;
@ -349,6 +354,7 @@ class LockBasicInfo {
this.keyId,
this.model,
this.electricQuantity,
this.electricQuantityStandby,
this.indate,
this.isLockOwner,
this.lockAlias,
@ -375,6 +381,7 @@ class LockBasicInfo {
keyId = json['keyId'];
model = json['model'];
electricQuantity = json['electricQuantity'];
electricQuantityStandby = json['electricQuantityStandby'];
indate = json['indate'];
isLockOwner = json['isLockOwner'];
lockAlias = json['lockAlias'];
@ -408,6 +415,7 @@ class LockBasicInfo {
data['keyId'] = keyId;
data['model'] = model;
data['electricQuantity'] = electricQuantity;
data['electricQuantityStandby'] = electricQuantityStandby;
data['indate'] = indate;
data['isLockOwner'] = isLockOwner;
data['lockAlias'] = lockAlias;

View File

@ -290,6 +290,7 @@ class LockFeature {
int? bluetoothRemoteControl;
int? videoIntercom;
int? isSupportCatEye;
int? isSupportBackupBattery;
LockFeature(
{this.password,
this.icCard,
@ -300,7 +301,8 @@ class LockFeature {
this.d3Face,
this.bluetoothRemoteControl,
this.videoIntercom,
this.isSupportCatEye});
this.isSupportCatEye,
this.isSupportBackupBattery});
LockFeature.fromJson(Map<String, dynamic> json) {
password = json['password'];
@ -313,6 +315,7 @@ class LockFeature {
bluetoothRemoteControl = json['bluetoothRemoteControl'];
videoIntercom = json['videoIntercom'];
isSupportCatEye = json['isSupportCatEye'];
isSupportBackupBattery = json['isSupportBackupBattery'];
}
Map<String, dynamic> toJson() {
@ -327,6 +330,7 @@ class LockFeature {
data['bluetoothRemoteControl'] = bluetoothRemoteControl;
data['videoIntercom'] = videoIntercom;
data['isSupportCatEye'] = isSupportCatEye;
data['isSupportBackupBattery'] = isSupportBackupBattery;
return data;
}
}

View File

@ -190,13 +190,18 @@ class NearbyLockLogic extends BaseGetXController {
state.lockInfo["electricQuantity"] = battRemCap;
AppLog.log("电池剩余电量 battRemCap:$battRemCap");
//
var battRemCapStandby = reply.data[133];
state.lockInfo["electricQuantityStandby"] = battRemCapStandby;
AppLog.log("电池剩余电量 battRemCap:$battRemCap");
//
var restoreCounter = reply.data.sublist(133, 135);
var restoreCounter = reply.data.sublist(134, 136);
state.lockInfo["restoreCount"] = restoreCounter[0] * 256 + restoreCounter[1];
AppLog.log("重置次数 restoreCounter:${restoreCounter[0] * 256 + restoreCounter[1]}");
//
var restoreDate = reply.data.sublist(135, 139);
var restoreDate = reply.data.sublist(136, 140);
int restoreDateValue = ((0xff & restoreDate[(0)]) << 24 |
(0xff & restoreDate[1]) << 16 |
(0xff & restoreDate[2]) << 8 |
@ -206,13 +211,13 @@ class NearbyLockLogic extends BaseGetXController {
AppLog.log("重置时间 restoreDateValue:$restoreDateValue");
//
var icPartNo = reply.data.sublist(139, 149);
var icPartNo = reply.data.sublist(140, 150);
var icPartNoStr = utf8String(icPartNo);
state.lockInfo["icPartNo"] = icPartNoStr;
AppLog.log("主控芯片型号 icPartNoStr:$icPartNoStr");
//
var indate = reply.data.sublist(149, 153);
var indate = reply.data.sublist(150, 154);
int indateValue = ((0xff & indate[(0)]) << 24 |
(0xff & indate[1]) << 16 |
(0xff & indate[2]) << 8 |
@ -222,14 +227,14 @@ class NearbyLockLogic extends BaseGetXController {
AppLog.log("有效时间 indateValue:$indateValue");
// mac地址
var macAddress = reply.data.sublist(153, 173);
var macAddress = reply.data.sublist(154, 174);
var macAddressStr = utf8String(macAddress);
state.lockInfo["mac"] = macAddressStr;
AppLog.log("mac地址 macAddressStr:$macAddressStr");
var index = 173;
var index = 174;
//
var featureValueLength = reply.data[173];
var featureValueLength = reply.data[174];
AppLog.log("锁特征值字符串长度 featureValueLength:$featureValueLength");
// ()

View File

@ -169,12 +169,14 @@ class ApiProvider extends BaseProvider {
Future<Response> uploadElectricQuantity(
String electricQuantity,
String electricQuantityStandby,
String lockId,
) =>
post(
uploadElectricQuantityURL.toUrl,
jsonEncode({
'electricQuantity': electricQuantity,
'electricQuantityStandby': electricQuantityStandby,
'lockId': lockId,
}));

View File

@ -317,9 +317,13 @@ class ApiRepository {
//
Future<KeyOperationRecordEntity> uploadElectricQuantity(
String electricQuantity, String lockId) async {
{
String? electricQuantity,
String? electricQuantityStandby,
String? lockId
}) async {
final res =
await apiProvider.uploadElectricQuantity(electricQuantity, lockId);
await apiProvider.uploadElectricQuantity(electricQuantity!, electricQuantityStandby!, lockId!);
return KeyOperationRecordEntity.fromJson(res.body);
}