1,新增锁电量更新接口
2,新增修改锁名称接口
This commit is contained in:
parent
7e208b5985
commit
8c8d8a62b9
@ -1,6 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.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/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||||
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
import '../../../../appRouters.dart';
|
import '../../../../appRouters.dart';
|
||||||
import '../../../../app_settings/app_colors.dart';
|
import '../../../../app_settings/app_colors.dart';
|
||||||
@ -55,6 +58,21 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//请求电子钥匙列表
|
||||||
|
Future<List<ElectronicKeyListItem>> mockNetworkDataRequest() async {
|
||||||
|
ElectronicKeyListEntity entity = await ApiRepository.to
|
||||||
|
.electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0');
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
print("电子钥匙列表成功:${entity.data?.itemList}");
|
||||||
|
}
|
||||||
|
if (entity.data != null) {
|
||||||
|
return entity.data!.itemList;
|
||||||
|
} else {
|
||||||
|
List<ElectronicKeyListItem> dataList = [];
|
||||||
|
return dataList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildMainUI() {
|
Widget _buildMainUI() {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: 5,
|
itemCount: 5,
|
||||||
|
|||||||
@ -140,11 +140,11 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
|||||||
} else if (indexEntity.keyType == 2) {
|
} else if (indexEntity.keyType == 2) {
|
||||||
//永久
|
//永久
|
||||||
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||||
useDateStr = '${dateStr.toLocal().toString()} 永久';
|
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久';
|
||||||
} else if (indexEntity.keyType == 3) {
|
} else if (indexEntity.keyType == 3) {
|
||||||
//单次
|
//单次
|
||||||
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||||
useDateStr = '${dateStr.toLocal().toString()} 单次';
|
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次';
|
||||||
} else if (indexEntity.keyType == 4) {
|
} else if (indexEntity.keyType == 4) {
|
||||||
//循环
|
//循环
|
||||||
useDateStr = '循环';
|
useDateStr = '循环';
|
||||||
|
|||||||
@ -30,53 +30,59 @@ class _KeyOperationRecordPageState extends State<KeyOperationRecordPage> {
|
|||||||
backgroundColor: AppColors.mainColor,
|
backgroundColor: AppColors.mainColor,
|
||||||
),
|
),
|
||||||
body: FutureBuilder<List<KeyRecordDataItem>>(
|
body: FutureBuilder<List<KeyRecordDataItem>>(
|
||||||
// future: mockNetworkDataRequest(),
|
future: mockNetworkDataRequest(),
|
||||||
builder: (BuildContext context,
|
builder: (BuildContext context,
|
||||||
AsyncSnapshot<List<KeyRecordDataItem>> snapshot) {
|
AsyncSnapshot<List<KeyRecordDataItem>> snapshot) {
|
||||||
//请求结束
|
//请求结束
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
if (snapshot.hasError) {
|
if (snapshot.hasError) {
|
||||||
//请求失败
|
//请求失败
|
||||||
return const Text('请求失败');
|
return const Text('请求失败');
|
||||||
} else {
|
} else {
|
||||||
//请求成功
|
//请求成功
|
||||||
final List<KeyRecordDataItem> itemData = snapshot.data!;
|
final List<KeyRecordDataItem> itemDataList = snapshot.data!;
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: _buildMainUI()),
|
Expanded(child: _buildMainUI(itemDataList)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//请求未结束 显示loading
|
//请求未结束 显示loading
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//请求操作记录列表
|
//请求操作记录列表
|
||||||
Future<List<KeyRecordDataItem>?> mockNetworkDataRequest() async {
|
Future<List<KeyRecordDataItem>> mockNetworkDataRequest() async {
|
||||||
KeyOperationRecordEntity entity = (await ApiRepository.to
|
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||||
.lockRecordList('0', '63', '0', '28', '1', '1', '20', '0', '', '', ''));
|
.lockRecordList('0', '63', '0', '28', '1', '1', '20', '0', '', '', '');
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
print("操作记录列表成功:${entity.data?.itemList}");
|
print("操作记录列表成功:${entity.data?.itemList}");
|
||||||
}
|
}
|
||||||
if (entity.data != null) {
|
final data = entity.data;
|
||||||
return entity.data!.itemList;
|
if (data != null) {
|
||||||
|
return data.itemList!;
|
||||||
} else {
|
} else {
|
||||||
List<KeyRecordDataItem> dataList = [];
|
List<KeyRecordDataItem> dataList = [];
|
||||||
return dataList;
|
return dataList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildMainUI() {
|
Widget _buildMainUI(List<KeyRecordDataItem> itemDataList) {
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
itemCount: 5,
|
itemCount: 5,
|
||||||
itemBuilder: (c, index) {
|
itemBuilder: (c, index) {
|
||||||
return _electronicKeyItem('images/icon_recordDate.png', "张三",
|
KeyRecordDataItem dataItem = itemDataList[index];
|
||||||
"2023.6.21 11.15", "2023.6.21 11.15", () {});
|
int? operateDate = dataItem.operateDate;
|
||||||
|
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(operateDate!);
|
||||||
|
String operateDateStr =
|
||||||
|
'${dateStr.toLocal().toString().substring(0, 16)} 开锁';
|
||||||
|
|
||||||
|
return _electronicKeyItem(operateDateStr, () {});
|
||||||
},
|
},
|
||||||
separatorBuilder: (BuildContext context, int index) {
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
return const Divider(
|
return const Divider(
|
||||||
@ -87,8 +93,7 @@ class _KeyOperationRecordPageState extends State<KeyOperationRecordPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle,
|
Widget _electronicKeyItem(String operateDate, Function() action) {
|
||||||
String beginTime, String endTime, Function() action) {
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: action,
|
onTap: action,
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -100,7 +105,7 @@ class _KeyOperationRecordPageState extends State<KeyOperationRecordPage> {
|
|||||||
width: 30.w,
|
width: 30.w,
|
||||||
),
|
),
|
||||||
Image.asset(
|
Image.asset(
|
||||||
lockTypeIcon,
|
'images/icon_recordDate.png',
|
||||||
width: 24.w,
|
width: 24.w,
|
||||||
height: 24.w,
|
height: 24.w,
|
||||||
color: AppColors.darkGrayTextColor,
|
color: AppColors.darkGrayTextColor,
|
||||||
@ -109,7 +114,7 @@ class _KeyOperationRecordPageState extends State<KeyOperationRecordPage> {
|
|||||||
width: 20.w,
|
width: 20.w,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'2023-07-29 14:50:33 开锁',
|
operateDate,
|
||||||
style: TextStyle(color: AppColors.blackColor, fontSize: 20.sp),
|
style: TextStyle(color: AppColors.blackColor, fontSize: 20.sp),
|
||||||
),
|
),
|
||||||
SizedBox(width: 20.h),
|
SizedBox(width: 20.h),
|
||||||
|
|||||||
@ -198,11 +198,11 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
|||||||
} else if (indexEntity.keyType == 2) {
|
} else if (indexEntity.keyType == 2) {
|
||||||
//永久
|
//永久
|
||||||
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||||
useDateStr = '${dateStr.toLocal().toString()} 永久';
|
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久';
|
||||||
} else if (indexEntity.keyType == 3) {
|
} else if (indexEntity.keyType == 3) {
|
||||||
//单次
|
//单次
|
||||||
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||||
useDateStr = '${dateStr.toLocal().toString()} 单次';
|
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次';
|
||||||
} else if (indexEntity.keyType == 4) {
|
} else if (indexEntity.keyType == 4) {
|
||||||
//循环
|
//循环
|
||||||
useDateStr = '循环';
|
useDateStr = '循环';
|
||||||
|
|||||||
@ -269,6 +269,7 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//发送钥匙请求
|
||||||
Future<void> sendElectronicKeyRequest() async {
|
Future<void> sendElectronicKeyRequest() async {
|
||||||
String getFailureDateTime = '0';
|
String getFailureDateTime = '0';
|
||||||
String getEffectiveDateTime = '0';
|
String getEffectiveDateTime = '0';
|
||||||
@ -301,7 +302,7 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
|
|||||||
'0',
|
'0',
|
||||||
getEffectiveDateTime, []);
|
getEffectiveDateTime, []);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
// print('发送电子钥匙成功');
|
print('发送电子钥匙成功');
|
||||||
_isSendSuccess = true;
|
_isSendSuccess = true;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
|
|||||||
leftTitel: TranslationLoader.lanKeys!.lockNumber!.tr,
|
leftTitel: TranslationLoader.lanKeys!.lockNumber!.tr,
|
||||||
rightTitle: "MCBN0c_8f3106",
|
rightTitle: "MCBN0c_8f3106",
|
||||||
allHeight: 70.h,
|
allHeight: 70.h,
|
||||||
isHaveLine: false),
|
isHaveLine: true),
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: "MAC/ID",
|
leftTitel: "MAC/ID",
|
||||||
rightTitle: "53:66:9F:06:31:8F/9418481",
|
rightTitle: "53:66:9F:06:31:8F/9418481",
|
||||||
|
|||||||
@ -2,6 +2,10 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.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/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||||
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
import 'package:star_lock/tools/toast.dart';
|
||||||
|
|
||||||
import '../../../../../app_settings/app_colors.dart';
|
import '../../../../../app_settings/app_colors.dart';
|
||||||
import '../../../../../tools/tf_loginInput.dart';
|
import '../../../../../tools/tf_loginInput.dart';
|
||||||
@ -25,6 +29,16 @@ class _EditLockNamePageState extends State<EditLockNamePage> {
|
|||||||
_changeLockNameController.text = "MCBN0c_8f3106";
|
_changeLockNameController.text = "MCBN0c_8f3106";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//修改锁名称请求
|
||||||
|
Future<void> modifyKeyNameRequest() async {
|
||||||
|
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||||
|
.modifyKeyName('63', '28', _changeLockNameController.text, '0');
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
print("修改锁名称成功啦啦啦啦啦");
|
||||||
|
Toast.show(msg: "修改成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -39,7 +53,9 @@ class _EditLockNamePageState extends State<EditLockNamePage> {
|
|||||||
TranslationLoader.lanKeys!.sure!.tr,
|
TranslationLoader.lanKeys!.sure!.tr,
|
||||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||||
),
|
),
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
modifyKeyNameRequest();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.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/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||||
|
import 'package:star_lock/network/api_repository.dart';
|
||||||
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
import 'package:star_lock/tools/toast.dart';
|
||||||
|
|
||||||
import '../../../../../app_settings/app_colors.dart';
|
import '../../../../../app_settings/app_colors.dart';
|
||||||
import '../../../../../tools/submitBtn.dart';
|
import '../../../../../tools/submitBtn.dart';
|
||||||
@ -17,6 +21,16 @@ class UploadElectricQuantityPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _UploadElectricQuantityPageState
|
class _UploadElectricQuantityPageState
|
||||||
extends State<UploadElectricQuantityPage> {
|
extends State<UploadElectricQuantityPage> {
|
||||||
|
//电量更新请求
|
||||||
|
Future<void> uploadElectricQuantityRequest() async {
|
||||||
|
KeyOperationRecordEntity entity =
|
||||||
|
await ApiRepository.to.uploadElectricQuantity('100', '28');
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
print("锁电量更新成功啦啦啦啦啦");
|
||||||
|
Toast.show(msg: "锁电量更新成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -61,7 +75,9 @@ class _UploadElectricQuantityPageState
|
|||||||
fontSize: 32.sp,
|
fontSize: 32.sp,
|
||||||
// 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: () {
|
||||||
|
uploadElectricQuantityRequest();
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|||||||
@ -17,4 +17,5 @@ abstract class Api {
|
|||||||
final String keyOperationRecordURL = '/lockRecords/list'; //电子钥匙操作记录
|
final String keyOperationRecordURL = '/lockRecords/list'; //电子钥匙操作记录
|
||||||
final String uploadElectricQuantityURL =
|
final String uploadElectricQuantityURL =
|
||||||
'/room/uploadElectricQuantity'; //锁电量更新
|
'/room/uploadElectricQuantity'; //锁电量更新
|
||||||
|
final String modifyKeyNameURL = '/key/modifyKeyName'; //修改锁名称
|
||||||
}
|
}
|
||||||
|
|||||||
@ -164,6 +164,21 @@ class ApiProvider extends BaseProvider {
|
|||||||
'lockId': lockId,
|
'lockId': lockId,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
Future<Response> modifyKeyName(
|
||||||
|
String keyId,
|
||||||
|
String lockId,
|
||||||
|
String keyName,
|
||||||
|
String operatorUid,
|
||||||
|
) =>
|
||||||
|
post(
|
||||||
|
modifyKeyNameURL.toUrl,
|
||||||
|
jsonEncode({
|
||||||
|
'keyId': keyId,
|
||||||
|
'lockId': lockId,
|
||||||
|
'keyName': keyName,
|
||||||
|
'operatorUid': operatorUid,
|
||||||
|
}));
|
||||||
|
|
||||||
Future<Response> resetElectronicKey(String lockId, String operatorUid) =>
|
Future<Response> resetElectronicKey(String lockId, String operatorUid) =>
|
||||||
post(resetElectronicKeyURL.toUrl,
|
post(resetElectronicKeyURL.toUrl,
|
||||||
jsonEncode({'lockId': lockId, 'operatorUid': operatorUid}));
|
jsonEncode({'lockId': lockId, 'operatorUid': operatorUid}));
|
||||||
|
|||||||
@ -53,7 +53,7 @@ class BaseProvider extends GetConnect with Api {
|
|||||||
statusText: res.statusText,
|
statusText: res.statusText,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
print('得到的数据======>$res');
|
print('得到的数据======>${res.bodyString}');
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -168,4 +168,24 @@ class ApiRepository {
|
|||||||
timezoneRawOffSet);
|
timezoneRawOffSet);
|
||||||
return KeyOperationRecordEntity.fromJson(res.body);
|
return KeyOperationRecordEntity.fromJson(res.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//锁电量更新
|
||||||
|
Future<KeyOperationRecordEntity> uploadElectricQuantity(
|
||||||
|
String electricQuantity, String lockId) async {
|
||||||
|
final res =
|
||||||
|
await apiProvider.uploadElectricQuantity(electricQuantity, lockId);
|
||||||
|
return KeyOperationRecordEntity.fromJson(res.body);
|
||||||
|
}
|
||||||
|
|
||||||
|
//锁名称修改
|
||||||
|
Future<KeyOperationRecordEntity> modifyKeyName(
|
||||||
|
String keyId,
|
||||||
|
String lockId,
|
||||||
|
String keyName,
|
||||||
|
String operatorUid,
|
||||||
|
) async {
|
||||||
|
final res =
|
||||||
|
await apiProvider.modifyKeyName(keyId, lockId, keyName, operatorUid);
|
||||||
|
return KeyOperationRecordEntity.fromJson(res.body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user