fix: 1、修改网关模块、远程开锁超时时间为60秒

This commit is contained in:
魏少阳 2024-12-31 13:57:22 +08:00
parent ff1932689a
commit ddf590c321
14 changed files with 109 additions and 101 deletions

View File

@ -606,8 +606,8 @@ class LockDetailLogic extends BaseGetXController {
// //
Future<void> remoteOpenLock() async { Future<void> remoteOpenLock() async {
final LoginEntity entity = await ApiRepository.to final LoginEntity entity = await ApiRepository.to.remoteOpenLock(
.remoteOpenLock(lockId: state.keyInfos.value.lockId.toString()); lockId: state.keyInfos.value.lockId.toString(), timeOut: 60);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast('已开锁'.tr); showToast('已开锁'.tr);
} }

View File

@ -4,7 +4,7 @@ import 'flavors.dart';
import 'main.dart' as runner; import 'main.dart' as runner;
Future<void> main() async { Future<void> main() async {
F.appFlavor = Flavor.xhj; F.appFlavor = Flavor.xhj_pre;
// AppLog.log('local调用了main函数'); // AppLog.log('local调用了main函数');
await runner.main(); await runner.main();
} }

View File

@ -31,7 +31,8 @@ class GatewayConfigurationWifiLogic extends BaseGetXController {
networkName: state.wifiNameTF.text, networkName: state.wifiNameTF.text,
networkMac: state.gatewayModel.wifiMac, networkMac: state.gatewayModel.wifiMac,
version: state.gatewayModel.gatewayVersion, version: state.gatewayModel.gatewayVersion,
gatewayJson: jsonDecode(state.gatewayJson)); gatewayJson: jsonDecode(state.gatewayJson),
timeout: 60);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast('配网成功'.tr, something: () { showToast('配网成功'.tr, something: () {
// eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); // eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
@ -42,7 +43,7 @@ class GatewayConfigurationWifiLogic extends BaseGetXController {
Future<void> getGatewayConfiguration() async { Future<void> getGatewayConfiguration() async {
final GetGatewayConfigurationEntity entity = final GetGatewayConfigurationEntity entity =
await ApiRepository.to.getGatewayConfiguration(); await ApiRepository.to.getGatewayConfiguration(timeout: 60);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.getGatewayConfigurationStr = entity.data ?? ''; state.getGatewayConfigurationStr = entity.data ?? '';
// AppLog.log('state.getGatewayConfigurationStr:${state.getGatewayConfigurationStr}'); // AppLog.log('state.getGatewayConfigurationStr:${state.getGatewayConfigurationStr}');

View File

@ -3,7 +3,6 @@ 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 '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/appRouteObserver.dart';
import '../../../../tools/commonItem.dart'; import '../../../../tools/commonItem.dart';

View File

@ -2,7 +2,6 @@ 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/blue/io_gateway/io_gateway_configuringWifi.dart';
import 'package:star_lock/blue/io_gateway/io_gateway_getWifiList.dart'; import 'package:star_lock/blue/io_gateway/io_gateway_getWifiList.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';

View File

@ -12,7 +12,8 @@ class GatewayConnectionLockListLogic extends BaseGetXController {
Future<GatewayConnectionLockListEntity> Future<GatewayConnectionLockListEntity>
gatewayConnectionLockListDataRequest() async { gatewayConnectionLockListDataRequest() async {
final GatewayConnectionLockListEntity entity = await ApiRepository.to final GatewayConnectionLockListEntity entity = await ApiRepository.to
.gatewayConnectionLockLoadData(gatewayId: state.gatewayId.value); .gatewayConnectionLockLoadData(
gatewayId: state.gatewayId.value, timeout: 60);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.itemDataList.value = entity.data!.list!; state.itemDataList.value = entity.data!.list!;
} }
@ -21,7 +22,7 @@ class GatewayConnectionLockListLogic extends BaseGetXController {
Future<void> gatewayScanDevice() async { Future<void> gatewayScanDevice() async {
final LoginEntity entity = await ApiRepository.to final LoginEntity entity = await ApiRepository.to
.gatewayScanDevice(gatewayId: state.gatewayId.value); .gatewayScanDevice(gatewayId: state.gatewayId.value, timeout: 60);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
gatewayConnectionLockListDataRequest(); gatewayConnectionLockListDataRequest();
} }

View File

@ -49,7 +49,7 @@ class _GatewayConnectionLockListPageState
Obx(() => Expanded( Obx(() => Expanded(
child: state.itemDataList.value.isNotEmpty child: state.itemDataList.value.isNotEmpty
? ListView.builder( ? ListView.builder(
itemCount: 10, itemCount: state.itemDataList.value.length,
itemBuilder: (BuildContext c, int index) { itemBuilder: (BuildContext c, int index) {
final GatewayConnectionLockItemEntity entity = final GatewayConnectionLockItemEntity entity =
state.itemDataList[index]; state.itemDataList[index];

View File

@ -12,7 +12,8 @@ class GatewayDetailLogic extends BaseGetXController {
Future<void> deletGateway(int isForce) async { Future<void> deletGateway(int isForce) async {
final LoginEntity entity = await ApiRepository.to.gatewayDelet( final LoginEntity entity = await ApiRepository.to.gatewayDelet(
gatewayId: state.getewayItemData.value.gatewayId ?? 0, gatewayId: state.getewayItemData.value.gatewayId ?? 0,
isForce: isForce); isForce: isForce,
timeout: 60);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast('删除成功'.tr, something: () { showToast('删除成功'.tr, something: () {
// eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); // eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
@ -27,7 +28,8 @@ class GatewayDetailLogic extends BaseGetXController {
Future<void> updateGateway(String gatewayName) async { Future<void> updateGateway(String gatewayName) async {
final LoginEntity entity = await ApiRepository.to.gatewayUpdate( final LoginEntity entity = await ApiRepository.to.gatewayUpdate(
gatewayId: state.getewayItemData.value.gatewayId ?? 0, gatewayId: state.getewayItemData.value.gatewayId ?? 0,
gatewayName: gatewayName); gatewayName: gatewayName,
timeout: 60);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast('修改成功'.tr, something: () { showToast('修改成功'.tr, something: () {
// eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); // eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));

View File

@ -1,4 +1,3 @@
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import '../../../login/login/entity/LoginEntity.dart'; import '../../../login/login/entity/LoginEntity.dart';
@ -18,9 +17,7 @@ class GatewayListLogic extends BaseGetXController {
pageNo = 1; pageNo = 1;
} }
final GetewayDataEntity entity = await ApiRepository.to.getGatewayListData( final GetewayDataEntity entity = await ApiRepository.to.getGatewayListData(
pageNo: pageNo.toString(), pageNo: pageNo.toString(), pageSize: pageSize, timeout: 60);
pageSize: pageSize,
);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
// //
state.getewayListData.addAll(entity.data!.list!); state.getewayListData.addAll(entity.data!.list!);
@ -51,7 +48,6 @@ class GatewayListLogic extends BaseGetXController {
// @override // @override
// void onInit() { // void onInit() {
// super.onInit(); // super.onInit();
// gatewayDistributionNetwork(); // gatewayDistributionNetwork();
// } // }
}
}

View File

@ -1,20 +1,17 @@
import 'package:star_lock/mine/mineSet/transferGateway/selectGetewayList_entity.dart'; import 'package:star_lock/mine/mineSet/transferGateway/selectGetewayList_entity.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import '../../../network/api_repository.dart'; import '../../../network/api_repository.dart';
import 'selectGetewayList_state.dart'; import 'selectGetewayList_state.dart';
class SelectGetewayListLogic extends BaseGetXController{ class SelectGetewayListLogic extends BaseGetXController {
SelectGetewayListState state = SelectGetewayListState(); SelectGetewayListState state = SelectGetewayListState();
// //
Future<void> getGetewayListData() async{ Future<void> getGetewayListData() async {
final GetewayDataEntity entity = await ApiRepository.to.getGatewayListData( final GetewayDataEntity entity = await ApiRepository.to
pageNo: '1', .getGatewayListData(pageNo: '1', pageSize: '20', timeout: 60);
pageSize: '20' if (entity.errorCode!.codeIsSuccessful) {
);
if(entity.errorCode!.codeIsSuccessful){
state.getewayListData.value = entity.data!.list!; state.getewayListData.value = entity.data!.list!;
} }
} }
@ -25,5 +22,4 @@ class SelectGetewayListLogic extends BaseGetXController{
getGetewayListData(); getGetewayListData();
} }
}
}

View File

@ -1727,21 +1727,23 @@ class ApiProvider extends BaseProvider {
})); }));
// //
Future<Response> getGatewayListData(String pageNo, String pageSize) => post( Future<Response> getGatewayListData(
gatewaykListURL.toUrl, String pageNo, String pageSize, int timeout) =>
jsonEncode({'pageNo': pageNo, 'pageSize': pageSize})); post(gatewaykListURL.toUrl,
jsonEncode({'pageNo': pageNo, 'pageSize': pageSize}),
timeout: timeout);
// //
Future<Response> addGatewayNetwork( Future<Response> addGatewayNetwork(
String gatewayName, String gatewayName,
String gatewayMac, String gatewayMac,
String serialNumber, String serialNumber,
int gatewayType, int gatewayType,
String networkName, String networkName,
String networkMac, String networkMac,
String version, String version,
Map gatewayJson, Map gatewayJson,
) => int timeout) =>
post( post(
addGatewayURL.toUrl, addGatewayURL.toUrl,
jsonEncode({ jsonEncode({
@ -1753,37 +1755,37 @@ class ApiProvider extends BaseProvider {
'networkMac': networkMac, 'networkMac': networkMac,
'version': version, 'version': version,
'gatewayJson': gatewayJson, 'gatewayJson': gatewayJson,
})); }),
timeout: timeout);
// //
Future<Response> deletGateway(int gatewayId, int isForce) => post( Future<Response> deletGateway(int gatewayId, int isForce, int timeout) =>
deletGatewayURL.toUrl, post(
jsonEncode({ deletGatewayURL.toUrl,
'gatewayId': gatewayId, jsonEncode({
'isForce': isForce, 'gatewayId': gatewayId,
})); 'isForce': isForce,
}),
timeout: timeout);
// //
Future<Response> gatewayUpdate( Future<Response> gatewayUpdate(
int gatewayId, int gatewayId, String gatewayName, int timeout) =>
String gatewayName,
) =>
post( post(
updateGatewayURL.toUrl, updateGatewayURL.toUrl,
jsonEncode({ jsonEncode({
'gatewayId': gatewayId, 'gatewayId': gatewayId,
'gatewayName': gatewayName, 'gatewayName': gatewayName,
})); }),
timeout: timeout);
// //
Future<Response> remoteOpenLock( Future<Response> remoteOpenLock(String lockId, int timeOut) => post(
String lockId, remoteOpenLockURL.toUrl,
) => jsonEncode({
post( 'lockId': lockId,
remoteOpenLockURL.toUrl, }),
jsonEncode({ timeout: timeOut);
'lockId': lockId,
}));
// //
Future<Response> transferGatewayConfirmInfoData( Future<Response> transferGatewayConfirmInfoData(
@ -1808,14 +1810,17 @@ class ApiProvider extends BaseProvider {
})); }));
// //
Future<Response> getGatewayConfiguration() => Future<Response> getGatewayConfiguration(int timeout) =>
post(getGatewayConfigURL.toUrl, jsonEncode({})); post(getGatewayConfigURL.toUrl, jsonEncode({}), timeout: timeout);
Future<Response> gatewayConnectionLockListLoadData(int gatewayId) => Future<Response> gatewayConnectionLockListLoadData(
post(gatewayListByLockURL.toUrl, jsonEncode({'gatewayId': gatewayId})); int gatewayId, int timeout) =>
post(gatewayListByLockURL.toUrl, jsonEncode({'gatewayId': gatewayId}),
timeout: timeout);
Future<Response> gatewayScanDevice(int gatewayId) => Future<Response> gatewayScanDevice(int gatewayId, int timeout) =>
post(gatewayScanDeviceURL.toUrl, jsonEncode({'gatewayId': gatewayId})); post(gatewayScanDeviceURL.toUrl, jsonEncode({'gatewayId': gatewayId}),
timeout: timeout);
// //
Future<Response> removeBrokenLockData(List lockIdList) => Future<Response> removeBrokenLockData(List lockIdList) =>

View File

@ -37,6 +37,7 @@ class BaseProvider extends GetConnect with Api {
bool? isUserBaseUrl = true, // 使baseUrl bool? isUserBaseUrl = true, // 使baseUrl
bool? isShowErrMsg = true, // bool? isShowErrMsg = true, //
bool? isShowNetworkErrorMsg = true, // 403 500 bool? isShowNetworkErrorMsg = true, // 403 500
int? timeout = 15,
}) async { }) async {
AppLog.log('post: url:$url body:$body'); AppLog.log('post: url:$url body:$body');
if (isUnShowLoading == false) { if (isUnShowLoading == false) {
@ -47,6 +48,8 @@ class BaseProvider extends GetConnect with Api {
} else { } else {
httpClient.baseUrl = '${F.apiPrefix}/api'; httpClient.baseUrl = '${F.apiPrefix}/api';
} }
httpClient.timeout = timeout!.seconds;
// AppLog.log('timeout:$timeout httpClient.timeout:${httpClient.timeout}');
var res = await super.post(url, body, var res = await super.post(url, body,
contentType: contentType, contentType: contentType,
headers: headers, headers: headers,
@ -78,7 +81,7 @@ class BaseProvider extends GetConnect with Api {
statusText: res.statusText, statusText: res.statusText,
); );
} else {} } else {}
if(isShowNetworkErrorMsg ?? true){ if (isShowNetworkErrorMsg ?? true) {
getDataResult(res.body); getDataResult(res.body);
} }
return res; return res;

View File

@ -1912,22 +1912,24 @@ class ApiRepository {
// //
Future<GetewayDataEntity> getGatewayListData( Future<GetewayDataEntity> getGatewayListData(
{required String pageNo, required String pageSize}) async { {required String pageNo,
final res = await apiProvider.getGatewayListData(pageNo, pageSize); required String pageSize,
required int timeout}) async {
final res = await apiProvider.getGatewayListData(pageNo, pageSize, timeout);
return GetewayDataEntity.fromJson(res.body); return GetewayDataEntity.fromJson(res.body);
} }
// //
Future<LoginEntity> gatewayDistributionNetwork({ Future<LoginEntity> gatewayDistributionNetwork(
required String gatewayName, {required String gatewayName,
required String gatewayMac, required String gatewayMac,
required String serialNumber, required String serialNumber,
required int gatewayType, required int gatewayType,
required String networkName, required String networkName,
required String networkMac, required String networkMac,
required String version, required String version,
required Map gatewayJson, required Map gatewayJson,
}) async { required int timeout}) async {
final res = await apiProvider.addGatewayNetwork( final res = await apiProvider.addGatewayNetwork(
gatewayName, gatewayName,
gatewayMac, gatewayMac,
@ -1936,25 +1938,27 @@ class ApiRepository {
networkName, networkName,
networkMac, networkMac,
version, version,
gatewayJson); gatewayJson,
timeout);
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
} }
// //
Future<LoginEntity> gatewayDelet({ Future<LoginEntity> gatewayDelet(
required int gatewayId, {required int gatewayId,
required int isForce, required int isForce,
}) async { required int timeout}) async {
final res = await apiProvider.deletGateway(gatewayId, isForce); final res = await apiProvider.deletGateway(gatewayId, isForce, timeout);
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
} }
// //
Future<LoginEntity> gatewayUpdate({ Future<LoginEntity> gatewayUpdate(
required int gatewayId, {required int gatewayId,
required String gatewayName, required String gatewayName,
}) async { required int timeout}) async {
final res = await apiProvider.gatewayUpdate(gatewayId, gatewayName); final res =
await apiProvider.gatewayUpdate(gatewayId, gatewayName, timeout);
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
} }
@ -1970,22 +1974,23 @@ class ApiRepository {
// - // -
Future<GatewayConnectionLockListEntity> gatewayConnectionLockLoadData( Future<GatewayConnectionLockListEntity> gatewayConnectionLockLoadData(
{required int gatewayId}) async { {required int gatewayId, required int timeout}) async {
final res = await apiProvider.gatewayConnectionLockListLoadData(gatewayId); final res =
await apiProvider.gatewayConnectionLockListLoadData(gatewayId, timeout);
return GatewayConnectionLockListEntity.fromJson(res.body); return GatewayConnectionLockListEntity.fromJson(res.body);
} }
// - // -
Future<LoginEntity> gatewayScanDevice({ Future<LoginEntity> gatewayScanDevice(
required int gatewayId, {required int gatewayId, required int timeout}) async {
}) async { final res = await apiProvider.gatewayScanDevice(gatewayId, timeout);
final res = await apiProvider.gatewayScanDevice(gatewayId);
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
} }
// //
Future<LoginEntity> remoteOpenLock({required String lockId}) async { Future<LoginEntity> remoteOpenLock(
final res = await apiProvider.remoteOpenLock(lockId); {required String lockId, required int timeOut}) async {
final res = await apiProvider.remoteOpenLock(lockId, timeOut);
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
} }
@ -2000,8 +2005,9 @@ class ApiRepository {
} }
// //
Future<GetGatewayConfigurationEntity> getGatewayConfiguration() async { Future<GetGatewayConfigurationEntity> getGatewayConfiguration(
final res = await apiProvider.getGatewayConfiguration(); {required int timeout}) async {
final res = await apiProvider.getGatewayConfiguration(timeout);
return GetGatewayConfigurationEntity.fromJson(res.body); return GetGatewayConfigurationEntity.fromJson(res.body);
} }

View File

@ -104,7 +104,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# 1.0.85+2024120301完善网关功能 # 1.0.85+2024120301完善网关功能
# 1.0.85+2024120401修复网关问题打包给谢敬调试 # 1.0.85+2024120401修复网关问题打包给谢敬调试
version: 1.0.85+2024121301 version: 1.0.85+2024123102
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'