|
|
|
@ -852,69 +852,25 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 无人机机场设备注册/更新
|
|
|
|
|
/// 无人机状态上报
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<Response<string>> reportDroneStatus(List<AirPortStatusApply> req)
|
|
|
|
|
public async Task<Response<bool>> ReportDroneStatus()
|
|
|
|
|
{
|
|
|
|
|
Response<string> Response = new Response<string>();
|
|
|
|
|
|
|
|
|
|
var handler = new HttpClientHandler();
|
|
|
|
|
// 如果需要忽略服务器证书错误(仅测试环境)
|
|
|
|
|
handler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true;
|
|
|
|
|
using (var client = new HttpClient())
|
|
|
|
|
var droneList = await Repository
|
|
|
|
|
.ChangeRepository<SugarRepositiry<LasaUav>>()
|
|
|
|
|
.AsQueryable()
|
|
|
|
|
.Where(it => it.IsDelete == false)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
foreach (var item in droneList)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string url = configuration.GetSection("DroneDocking:Url").Value + "/droneAirport/reportDroneStatus";
|
|
|
|
|
string x_lc_secret = _helper.getxseret();
|
|
|
|
|
string centercode = "UAV32_LJY2FPMYDE6UDES3P3ZD7V3IKQ";
|
|
|
|
|
string x_token = _helper.GetToken(centercode);
|
|
|
|
|
|
|
|
|
|
// 序列化为 JSON 字符串
|
|
|
|
|
string json = JsonSerializer.Serialize(req);
|
|
|
|
|
|
|
|
|
|
// 转换为字节数组
|
|
|
|
|
byte[] bytes = Encoding.UTF8.GetBytes(json);
|
|
|
|
|
|
|
|
|
|
var encryptedData = _helper.Encrypt(bytes);
|
|
|
|
|
// 创建请求体
|
|
|
|
|
var httpContent = new StringContent(encryptedData, Encoding.UTF8, "application/json");
|
|
|
|
|
|
|
|
|
|
// 添加请求头
|
|
|
|
|
client.DefaultRequestHeaders.Add("x-lc-secret", x_lc_secret);
|
|
|
|
|
client.DefaultRequestHeaders.Add("x-lc-token", x_token);
|
|
|
|
|
|
|
|
|
|
//发送请求
|
|
|
|
|
HttpResponseMessage response = await client.PostAsync(url, httpContent);
|
|
|
|
|
response.EnsureSuccessStatusCode();
|
|
|
|
|
|
|
|
|
|
// 获取响应头中的 x_cl_screte 参数
|
|
|
|
|
string resx_cl_screte = GetHeaderValue(response, "x-lc-secret");
|
|
|
|
|
|
|
|
|
|
// 读取响应内容并反序列化
|
|
|
|
|
string responseBody = await response.Content.ReadAsStringAsync();
|
|
|
|
|
var result = JsonSerializer.Deserialize<ReciveData<string>>(responseBody);
|
|
|
|
|
|
|
|
|
|
//解密数据
|
|
|
|
|
byte[] resbytesx = Convert.FromBase64String(resx_cl_screte);
|
|
|
|
|
byte[] resdatabytes = Convert.FromBase64String(result?.data);
|
|
|
|
|
string data = _helper.Decrypt(resbytesx, resdatabytes);
|
|
|
|
|
|
|
|
|
|
Response.Result = data;
|
|
|
|
|
Response.Message = result.message;
|
|
|
|
|
Response.Code = result.code;
|
|
|
|
|
}
|
|
|
|
|
catch (HttpRequestException e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("\nException Caught!");
|
|
|
|
|
Console.WriteLine("Message :{0} ", e.Message);
|
|
|
|
|
Response.Result = "连接错误";
|
|
|
|
|
}
|
|
|
|
|
var status = await GetDroneStatus(item.Id);
|
|
|
|
|
}
|
|
|
|
|
// todo 获取无人机状态列表
|
|
|
|
|
// todo
|
|
|
|
|
|
|
|
|
|
return Response;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1260,35 +1216,37 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
|
|
|
|
|
{
|
|
|
|
|
RefAsync<int> totalCount = 0;
|
|
|
|
|
var info = await base.Repository.AsQueryable()
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(keyWord), t => t.taskname.Contains(keyWord)||t.bizidname.Contains(keyWord))
|
|
|
|
|
.Select(t=>new DroneDockRes
|
|
|
|
|
{
|
|
|
|
|
id= t.id,
|
|
|
|
|
bizidname= t.bizidname,
|
|
|
|
|
taskname= t.taskname,
|
|
|
|
|
createtime= t.createtime,
|
|
|
|
|
state= t.state,
|
|
|
|
|
datacode= t.datacode,
|
|
|
|
|
deviceid= t.deviceid,
|
|
|
|
|
taskid= t.taskid,
|
|
|
|
|
tasklist = SqlFunc.Subqueryable<DroneDocktaskdetail>().Where(r => r.taskid == t.id).LeftJoin<LasaTask>((r, s) => r.flighttaskid == s.FlightId).ToList((r,s)=> new DetailRes
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(keyWord),
|
|
|
|
|
t => t.taskname.Contains(keyWord) || t.bizidname.Contains(keyWord))
|
|
|
|
|
.Select(t => new DroneDockRes
|
|
|
|
|
{
|
|
|
|
|
id = r.id,
|
|
|
|
|
bsm=r.bsm,
|
|
|
|
|
Status=s.Status,
|
|
|
|
|
bz=r.bz,
|
|
|
|
|
dkbh=r.dkbh,
|
|
|
|
|
dkfw=r.dkfw,
|
|
|
|
|
dklx=r.dklx,
|
|
|
|
|
dkmc=r.dkmc,
|
|
|
|
|
dkmj=r.dkmj,
|
|
|
|
|
flighttaskid=r.flighttaskid,
|
|
|
|
|
taskid=r.taskid,
|
|
|
|
|
xzqdm=r.xzqdm,
|
|
|
|
|
zdkbh=r.zdkbh
|
|
|
|
|
id = t.id,
|
|
|
|
|
bizidname = t.bizidname,
|
|
|
|
|
taskname = t.taskname,
|
|
|
|
|
createtime = t.createtime,
|
|
|
|
|
state = t.state,
|
|
|
|
|
datacode = t.datacode,
|
|
|
|
|
deviceid = t.deviceid,
|
|
|
|
|
taskid = t.taskid,
|
|
|
|
|
tasklist = SqlFunc.Subqueryable<DroneDocktaskdetail>().Where(r => r.taskid == t.id)
|
|
|
|
|
.LeftJoin<LasaTask>((r, s) => r.flighttaskid == s.FlightId).ToList((r, s) => new DetailRes
|
|
|
|
|
{
|
|
|
|
|
id = r.id,
|
|
|
|
|
bsm = r.bsm,
|
|
|
|
|
Status = s.Status,
|
|
|
|
|
bz = r.bz,
|
|
|
|
|
dkbh = r.dkbh,
|
|
|
|
|
dkfw = r.dkfw,
|
|
|
|
|
dklx = r.dklx,
|
|
|
|
|
dkmc = r.dkmc,
|
|
|
|
|
dkmj = r.dkmj,
|
|
|
|
|
flighttaskid = r.flighttaskid,
|
|
|
|
|
taskid = r.taskid,
|
|
|
|
|
xzqdm = r.xzqdm,
|
|
|
|
|
zdkbh = r.zdkbh
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.ToPageListAsync(page, limit, totalCount);
|
|
|
|
|
.ToPageListAsync(page, limit, totalCount);
|
|
|
|
|
return new Response<PageInfo<List<DroneDockRes>>>
|
|
|
|
|
{
|
|
|
|
|
Result = new PageInfo<List<DroneDockRes>>
|
|
|
|
|