1. 航线文件夹创建

2. 航线文件夹删除
3. 航线文件夹树形结构返回
main
陈伟 2 months ago
parent eb2b85b51f
commit 96758ef8c5

@ -59,12 +59,12 @@ namespace OpenAuth.App.ServiceApp
using (var db = UnitWork.CreateContext())
{
var list = await db.LasaDronePort.AsQueryable().Includes(a => a.UavList)
.LeftJoin<LasaSpaceDevice>((a,b)=>a.Id==b.DeviceId)
.LeftJoin<LasaSpaceDevice>((a, b) => a.Id == b.DeviceId)
.Where(a => a.IsDelete == false)
.WhereIF(!string.IsNullOrEmpty(sn), (a, b) => a.Sn == sn)
.WhereIF(!string.IsNullOrEmpty(type), (a, b) => a.TypeId == type)
.WhereIF(!string.IsNullOrEmpty(workspaceid), (a, b) => b.WorkSpaceId == workspaceid)
.Select((a,b)=>new LasaDronePort
.Select((a, b) => new LasaDronePort
{
Id = a.Id,
Name = a.Name,
@ -182,12 +182,12 @@ namespace OpenAuth.App.ServiceApp
{
var list = await db.LasaUav.AsQueryable()
.LeftJoin<LasaDronePort>((a, b) => a.PId == b.Id)
.LeftJoin<LasaSpaceDevice>((a, b,c) => b.Id == c.DeviceId)
.LeftJoin<LasaSpaceDevice>((a, b, c) => b.Id == c.DeviceId)
.Where((a, b, c) => a.IsDelete == false)
.WhereIF(!string.IsNullOrEmpty(sn), (a, b, c) => a.Sn == sn)
.WhereIF(!string.IsNullOrEmpty(type), (a, b, c) => a.TypeId == type)
.WhereIF(!string.IsNullOrEmpty(workspaceid), (a, b, c) => c.WorkSpaceId == workspaceid)
.Select<dynamic>((a, b,c) => new
.Select<dynamic>((a, b, c) => new
{
id = a.Id,
name = a.Name,
@ -460,6 +460,7 @@ namespace OpenAuth.App.ServiceApp
JsonConvert.SerializeObject(cancelTaskRequest));
}
}
var flag = await db.LasaTask.DeleteAsync(it => it.Id == id);
var taskId = task.Id;
var mediaFileList = await db.LasaMediaFile.AsQueryable()
@ -499,7 +500,7 @@ namespace OpenAuth.App.ServiceApp
using (var db = UnitWork.CreateContext())
{
var list = await db.LasaAirLine.AsQueryable().LeftJoin<LasaUav>((a, b) => a.UavId == b.Id)
.WhereIF(!string.IsNullOrEmpty(req.UavTypeId),(a,b) => b.TypeId == req.UavTypeId)
.WhereIF(!string.IsNullOrEmpty(req.UavTypeId), (a, b) => b.TypeId == req.UavTypeId)
.WhereIF(!string.IsNullOrEmpty(req.key), a => a.AirLineName.Contains(req.key))
.WhereIF(!string.IsNullOrEmpty(req.AirLineName), a => a.AirLineName.Contains(req.AirLineName))
.WhereIF(!string.IsNullOrEmpty(req.AirLineType), a => a.AirLineType.Equals(req.AirLineType))
@ -1251,7 +1252,8 @@ namespace OpenAuth.App.ServiceApp
{
list = list.Where(r => r.WorkSpaceId == workspaceid).ToList();
}
if (type!=null && list.Count > 0)
if (type != null && list.Count > 0)
{
list = list.Where(r => r.Type == type).ToList();
}
@ -1400,5 +1402,89 @@ namespace OpenAuth.App.ServiceApp
}
#endregion
public async Task<Response<bool>> CreateAirLoneFolder(string folderName, string parentId)
{
LasaLineFolder folder = new LasaLineFolder()
{
Id = Guid.NewGuid().ToString(),
Path = folderName,
ParentId = parentId,
CreateTime = DateTime.Now
};
if (!string.IsNullOrEmpty(parentId))
{
var parent = await Repository
.ChangeRepository<SugarRepositiry<LasaLineFolder>>()
.GetByIdAsync(parentId);
folder.Ancestor = Path.Combine(parent.Ancestor, folderName);
}
else
{
folder.Ancestor = folderName;
}
return new Response<bool>()
{
Result = await Repository
.ChangeRepository<SugarRepositiry<LasaLineFolder>>()
.InsertAsync(folder)
};
}
public async Task<Response<bool>> DeleteAirLineFolder(string folderId)
{
var folder = await Repository
.ChangeRepository<SugarRepositiry<LasaLineFolder>>()
.GetByIdAsync(folderId);
var ancestor = folder.Ancestor;
// 删除文件夹记录
var x = await Repository.ChangeRepository<SugarRepositiry<LasaLineFolder>>().DeleteByIdAsync(folderId);
// 删除该文件夹下的航线记录
var y = await Repository
.ChangeRepository<SugarRepositiry<LasaAirLine>>()
.DeleteAsync(r => r.WPML.Contains(ancestor));
return new Response<bool>()
{
Result = x && y
};
}
public async Task<Response<List<LasaLineFolder>>> ListAirLineFolder()
{
var nodes = await Repository.ChangeRepository<SugarRepositiry<LasaLineFolder>>()
.AsQueryable().ToListAsync();
return new Response<List<LasaLineFolder>>()
{
Result = BuildFolderTree(nodes)
};
}
public List<LasaLineFolder> BuildFolderTree(List<LasaLineFolder> folders)
{
var folderMap = folders.ToDictionary(f => f.Id, f => new LasaLineFolder
{
Id = f.Id,
Path = f.Path,
Ancestor = f.Ancestor,
Children = new List<LasaLineFolder>()
});
var rootNodes = new List<LasaLineFolder>();
foreach (var folder in folders)
{
if (string.IsNullOrEmpty(folder.ParentId))
{
rootNodes.Add(folderMap[folder.Id]);
}
else if (folderMap.TryGetValue(folder.ParentId, out var parentNode))
{
parentNode.Children.Add(folderMap[folder.Id]);
}
}
return rootNodes;
}
}
}

@ -0,0 +1,18 @@
using SqlSugar;
namespace OpenAuth.Repository.Domain;
[SugarTable("lasa_linefolder")]
public class LasaLineFolder
{
[SugarColumn(IsPrimaryKey = true)]
public string Id {get; set;}
public string Path {get; set;}
public string Ancestor {get; set;}
public string ParentId {get; set;}
public DateTime? CreateTime {get; set;}
[SugarColumn(IsIgnore = true)]
public List<LasaLineFolder> Children { get; set; }
}

@ -1,9 +1,6 @@
using System.Text;
using DocumentFormat.OpenXml.Math;
using Infrastructure;
using Infrastructure.CloudSdk.wayline;
using Infrastructure.Extensions;
using Infrastructure.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
@ -257,6 +254,32 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
#region 航线管理
// todo 创建文件夹
// todo 删除文件夹
// todo 文件夹列表
[HttpPost]
public async Task<Response<bool>> CreateAirLoneFolder(string folderName, string parentId)
{
return await _app.CreateAirLoneFolder(folderName, parentId);
}
/// <summary>
/// 删除文件夹及文件夹航线
/// </summary>
/// <param name="folderId"></param>
/// <returns></returns>
[HttpPost]
public async Task<Response<bool>> DeleteAirLineFolder(string folderId)
{
return await _app.DeleteAirLineFolder(folderId);
}
[HttpGet]
public async Task<Response<List<LasaLineFolder>>> ListAirLineFolder()
{
return await _app.ListAirLineFolder();
}
/// <summary>
/// 获取航线列表
/// </summary>

Loading…
Cancel
Save