告警中心的二级详情页面+信息中心的页面+对接机器人接口
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import '../../domain/entities/drone_station_entity.dart';
|
||||
|
||||
abstract class DroneStationDataSource {
|
||||
Future<List<DroneStationEntity>> getDroneStationList(int siteId);
|
||||
Future<UAVDetailEntity> getUAVDetail(String gatewaySn, String deviceSn);
|
||||
Future<VideoStreamEntity> getVideoStream({
|
||||
required String sn,
|
||||
required String cameraIndex,
|
||||
required String cameraPosition,
|
||||
String qualityType = 'adaptive',
|
||||
int videoExpire = 7200,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:maibu_satabot_v2/core/consts/http_api_consts.dart';
|
||||
import '../datasources/drone_station_datasource.dart';
|
||||
import '../../domain/entities/drone_station_entity.dart';
|
||||
|
||||
class DroneStationDataSourceImpl implements DroneStationDataSource {
|
||||
final Dio dio;
|
||||
|
||||
DroneStationDataSourceImpl(this.dio);
|
||||
|
||||
@override
|
||||
Future<List<DroneStationEntity>> getDroneStationList(int siteId) async {
|
||||
final response = await dio.get(
|
||||
HttpApiConsts.getSiteUAVList,
|
||||
queryParameters: {'siteId': siteId},
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('网络请求失败: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final responseData = response.data;
|
||||
|
||||
if (responseData['code'] != 200) {
|
||||
throw Exception(responseData['msg'] ?? '业务异常');
|
||||
}
|
||||
|
||||
final List<dynamic> rows = responseData['rows'] ?? [];
|
||||
return rows.map((item) => DroneStationEntity.fromJson(item)).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<UAVDetailEntity> getUAVDetail(
|
||||
String gatewaySn,
|
||||
String deviceSn,
|
||||
) async {
|
||||
final response = await dio.get(
|
||||
HttpApiConsts.getUAVState,
|
||||
queryParameters: {'sn': gatewaySn, 'droneSn': deviceSn},
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('网络请求失败: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final responseData = response.data;
|
||||
|
||||
if (responseData['code'] != 200) {
|
||||
throw Exception(responseData['msg'] ?? '业务异常');
|
||||
}
|
||||
|
||||
return UAVDetailEntity.fromJson(responseData['data']);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<VideoStreamEntity> getVideoStream({
|
||||
required String sn,
|
||||
required String cameraIndex,
|
||||
required String cameraPosition,
|
||||
String qualityType = 'adaptive',
|
||||
int videoExpire = 7200,
|
||||
}) async {
|
||||
final response = await dio.post(
|
||||
HttpApiConsts.changeCamera,
|
||||
data: {
|
||||
'sn': sn,
|
||||
'cameraIndex': cameraIndex,
|
||||
'cameraPosition': cameraPosition,
|
||||
'qualityType': qualityType,
|
||||
'videoExpire': videoExpire,
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('网络请求失败: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final responseData = response.data;
|
||||
|
||||
if (responseData['code'] != 200) {
|
||||
throw Exception(responseData['msg'] ?? '业务异常');
|
||||
}
|
||||
|
||||
return VideoStreamEntity.fromJson(responseData['data']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user