|
@@ -1,6 +1,7 @@
|
|
|
#!/usr/bin/env python3
|
|
|
# -*- coding: utf-8 -*-
|
|
|
from fastapi import APIRouter, Request, Depends,Query,HTTPException
|
|
|
+from typing import Union
|
|
|
from database import get_db
|
|
|
from sqlalchemy.orm import Session
|
|
|
from sqlalchemy import case,or_
|
|
@@ -19,75 +20,82 @@ router = APIRouter()
|
|
|
# 获取无人机清单
|
|
|
@router.get('/roughTimeStatus')
|
|
|
async def roughTimeStatus(
|
|
|
- db: Session = Depends(get_db),
|
|
|
- body = Depends(remove_xss_json)
|
|
|
+ area: str = '',
|
|
|
+ keyword: str = '',
|
|
|
+ time: str = '',
|
|
|
+ mode: str = '',
|
|
|
+ type: str = '',
|
|
|
+ status: str = '',
|
|
|
+ db: Session = Depends(get_db)
|
|
|
):
|
|
|
- return {
|
|
|
- "code": 200,
|
|
|
- "data": [{
|
|
|
- "id": "1789142529854193666",
|
|
|
- "thirdPartformUavId": "1581F6Q8D241H00C5JV9", # 第三方平台无人机id【sn】
|
|
|
- "thirdPartformUId": "c7bc9cccbfac41cbbb0161dcdc010be3", #第三方平台唯一标识
|
|
|
- "uavName": "归湖镇无人机机库",
|
|
|
- "addressLongitude": 116.578580000, # 经度
|
|
|
- "addressLatitude": 23.763168000, # 纬度
|
|
|
- "realtimeStatus": 1,
|
|
|
- "thirdPullStreamAddress":
|
|
|
- "rtmp:#120.198.33.20:11935/drsUav/1581F6Q8D241H00C5JV9", # 第三方拉流地址
|
|
|
- "mediaPullStreamAddress":
|
|
|
- "https:#wrj.gdgov.cn:443/live/1789142529854193666.flv", # 流媒体拉流地址
|
|
|
- "popStreamAddress":
|
|
|
- "rtmp:#210.76.85.75:13101/live/1789142529854193666?token=4cf310ac3578",
|
|
|
- "constructionModel": 2, # 建设模式 0-财政资金采购 (硬件) 1-财政资金采购 (服务) 2-社会面资源 3-示范地区补点
|
|
|
- "dispatchResponseTime": 0, # 调度响应时间 0-半小时内 1-1小时内 2-2小时内 3-4小时内 4-8小时内 5-24小时内 6-24小时外
|
|
|
- "orgId": "1677658408929521666",
|
|
|
- "orgName": "广东泰一高新技术发展有限公司",
|
|
|
- "orgTypeId": "6",
|
|
|
- "uavBrand": "AIRace",
|
|
|
- "uavModel": "开拓者无人机",
|
|
|
- "residentAddress": "广东省潮州市潮安区归湖镇龙溪村",
|
|
|
- "timestamp": 1728614706923,
|
|
|
- "thirdName": "", # 第三方名称
|
|
|
- "flyingTime": None, # 飞行时长
|
|
|
- "height": None, # 高度
|
|
|
- "flyingDistance": None, # 飞行距离
|
|
|
- "horizontalSpeed": None, # 水平速度
|
|
|
- "verticalSpeed": None, # 垂直速度
|
|
|
- "battery": None, # 电池电量
|
|
|
- "workRadius": 3, # 工作半径
|
|
|
- "optName": None, # 无人机联系人
|
|
|
- "phone": None, # 无人机联系方式
|
|
|
- "addressAreaId": "445103115208", # 无人机所属区域编码
|
|
|
- "altitude": None, # 海拔高度
|
|
|
- "pitchAngle": None, # 俯仰⻆
|
|
|
- "yawAngle": None, # 偏航⻆
|
|
|
- "hangarStatus": None, # 机库状态,机库⽆⼈机必填 :0-离线、1-待命中、2-管制中、3-维护中
|
|
|
- "nestOutMediaPullStreamAddress":
|
|
|
- "https://wrj.gdgov.cn:443/live/1789142529854193666:nest.flv", # 机舱外流媒体拉流地址
|
|
|
- "nestOutMediaPullType": "rtmp", # 机舱外流媒体拉流拉流方式:rtmp、rtsp、flv、gb28181
|
|
|
- "nestOutMediaChangeType": "1", # 机巢外部视频流媒体网络类型/是否需要转换类型 (0 否 1 是)
|
|
|
- "thirdNestOutPullStreamAddress":
|
|
|
- "rtmp://120.198.33.20:11935/drsUav/7CTDM1600B5H66", # 第三方平台机巢外部视频拉流地址
|
|
|
- "uavFlyRoute": None, # 无人机当前航线
|
|
|
- "path": {
|
|
|
- "uavBaseInfoId": None,
|
|
|
- "createTime": None,
|
|
|
- "updateTime": None,
|
|
|
- "path": None
|
|
|
- },
|
|
|
- "nestStatus": 1, # 第三方机库的状态 0-离线、1-待命中、2-管制中、3-维护中、4-执行任务
|
|
|
- "convertCode": 1, # 第三方机库的状态 0-离线、1-待命中、2-飞行中、3-管制中、4-维护中、5-执行任务
|
|
|
- "isHangarControl": 1 # 配置机巢/机库/基站控制 0-否 1-是
|
|
|
- }],
|
|
|
- "msg": "操作成功"
|
|
|
- }
|
|
|
-
|
|
|
try:
|
|
|
+ print('area:', area)
|
|
|
+ print('keyword:', keyword)
|
|
|
+ print('time:', time)
|
|
|
+ print('mode:', mode)
|
|
|
+ print('type:', type)
|
|
|
+ print('status:', status)
|
|
|
+
|
|
|
+ fly_data = WRJApi.flyUavInfo()
|
|
|
+
|
|
|
data = WRJApi.roughTimeStatus()
|
|
|
+ area_code = ''
|
|
|
+ status_list = status.split(',')
|
|
|
+ if area != '':
|
|
|
+ row = db.query(GovdataArea).filter(GovdataArea.id == int(area)).first()
|
|
|
+ area_code = row.area_code.rstrip('0')
|
|
|
+
|
|
|
+ convertDict = { "0": "离线", "1": "待命", "2": "飞行中", "3": "管制中", "4": "维护中", "5": "执行任务" }
|
|
|
+
|
|
|
+ wrj_list = []
|
|
|
+ for n in data:
|
|
|
+ if area_code != '' and n['addressAreaId'].startswith(area_code) == False:
|
|
|
+ continue
|
|
|
+
|
|
|
+ if keyword != '' and n['uavName'].find(keyword) == -1:
|
|
|
+ continue
|
|
|
+
|
|
|
+ # 调度响应时间 0-半小时内 1-1小时内 2-2小时内 3-4小时内 4-8小时内 5-24小时内 6-24小时外
|
|
|
+ if time != '' and n['dispatchResponseTime'] != int(time):
|
|
|
+ continue
|
|
|
+
|
|
|
+ # 建设模式 0-财政资金采购 (硬件) 1-财政资金采购 (服务) 2-社会面资源 3-示范地区补点
|
|
|
+ if time != '' and n['constructionModel'] != int(mode):
|
|
|
+ continue
|
|
|
+
|
|
|
+ # "isHangarControl": 1 // 配置机巢/机库/基站控制 0-否 1-是
|
|
|
+ if type != '' and n['isHangarControl'] != int(type):
|
|
|
+ continue
|
|
|
+
|
|
|
+ # "convertCode": null, // // 第三方机库的状态 0-离线、1-待命中、2-飞行中、3-管制中、4-维护中、5-执行任务
|
|
|
+ if str(n['convertCode']) not in status_list:
|
|
|
+ continue
|
|
|
+
|
|
|
+ n['status_text'] = convertDict[str(n['convertCode'])]
|
|
|
+
|
|
|
+ item = {
|
|
|
+ "id": n['id'],
|
|
|
+ "drone_name": n['uavName'],
|
|
|
+ "status": n['convertCode'],
|
|
|
+ "status_text": n['status_text'],
|
|
|
+ "fly_url": n['mediaPullStreamAddress'] if n['mediaPullStreamAddress'] is not None else "", # 飞机视频流
|
|
|
+ "nest_url": n['nestOutMediaPullStreamAddress'] if n['nestOutMediaPullStreamAddress'] is not None else "", # 机巢视频流
|
|
|
+ }
|
|
|
+
|
|
|
+ if str(n['convertCode']) == '1':
|
|
|
+ fly_info = get_fly_info(n['id'], fly_data)
|
|
|
+ if fly_info is not None:
|
|
|
+ item = item.update(fly_info)
|
|
|
+ wrj_list.append(item)
|
|
|
+
|
|
|
+ print(wrj_list)
|
|
|
+
|
|
|
return {
|
|
|
"code": 200,
|
|
|
"msg": "操作成功",
|
|
|
- "data": data
|
|
|
+ "data": {
|
|
|
+ "list": wrj_list
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
except Exception as e:
|
|
@@ -96,6 +104,23 @@ async def roughTimeStatus(
|
|
|
"msg": "操作失败"
|
|
|
}
|
|
|
|
|
|
+def get_fly_info(id: str, data: list):
|
|
|
+ for n in data:
|
|
|
+ if n['id'] == id:
|
|
|
+ return {
|
|
|
+ "lng": n['lng'],
|
|
|
+ "lat": n['lat'],
|
|
|
+ "windSpeed": n['windSpeed'],
|
|
|
+ "nestSeed": n['nestSpeed'],
|
|
|
+ "temperature": n['temperature'],
|
|
|
+ "environmentTemperature": n['environmentTemperature'],
|
|
|
+ "batteryPerce": n['batteryPerce'],
|
|
|
+ "rainFall": n['rainFall']
|
|
|
+ }
|
|
|
+
|
|
|
+ return None
|
|
|
+
|
|
|
+
|
|
|
# 获取飞行中无人机清单
|
|
|
@router.get('/flyUavInfo')
|
|
|
async def flyUavInfo(
|