diff --git a/OpenAuth.App/ServiceApp/ManageApp.cs b/OpenAuth.App/ServiceApp/ManageApp.cs index 63467fd..acb2901 100644 --- a/OpenAuth.App/ServiceApp/ManageApp.cs +++ b/OpenAuth.App/ServiceApp/ManageApp.cs @@ -282,13 +282,22 @@ namespace OpenAuth.App.ServiceApp /// /// /// - public async Task>> GetWorkspaceList(string key) + public async Task>> GetWorkspaceList(int isjoin,string key,int state,string order= "\"CreateTime\" desc") { RefAsync totalCount = 0; using (var db = UnitWork.CreateContext()) { + var userid = _auth.GetCurrentUser().User.Id; + List ids=new List(); + if (isjoin == 1) + { + ids=db.LasaSpaceUser.AsQueryable().Where(r=>r.UserId== userid)?.Select(r => r.WorkSpaceId).ToList(); + } var list = await db.LasaWorkspace.AsQueryable() .WhereIF(!string.IsNullOrEmpty(key), a => a.WorkspaceName.Contains(key)) + .WhereIF(state != 0, a => a.Sate == state) + .WhereIF(isjoin == 1, a => ids.Contains(a.Id)) + .WhereIF(isjoin == 2, a => !ids.Contains(a.Id)) .LeftJoin((a, u) => a.CreateId == u.Id) .Select((a, u) => new { @@ -299,9 +308,12 @@ namespace OpenAuth.App.ServiceApp a.CreateTime, a.CreateId, u.Account, - u.Name - }) + u.Name, + UserNames = SqlFunc.Subqueryable().Where(r => r.WorkSpaceId == a.Id).LeftJoin((r, s) => r.UserId == s.Id).SelectStringJoin((r, s) => s.Name, ",") + }).MergeTable() + .OrderBy(order) .ToListAsync(); + return new Response> { Result = list @@ -469,6 +481,21 @@ namespace OpenAuth.App.ServiceApp } } + //归档项目 + public async Task> CompleteWorkspace(string id) + { + using (var db = UnitWork.CreateContext()) + { + await db.LasaWorkspace.UpdateAsync(u => new LasaWorkspace + { + Sate = 2 + }, u => u.Id == id); + if (db.Commit()) + return new Response { Result = true, Message = "归档成功" }; + else + return new Response { Result = false, Message = "归档失败" }; + } + } #endregion public async Task ExecuteFlyTask(string taskId) diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs index 06bd4fc..58005e0 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/AirportMaintenanceController.cs @@ -71,5 +71,274 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers return result; } + + /// + /// 切换相机 + /// + /// + [HttpPost] + public async Task> ExchangeCamera(string camera,int position,string videoId) + { + Response response = new Response(); + try + { + + var topicRequest = $"thing/product/8UUXN5400A079H/services"; + var requestData = new + { + bid = Guid.NewGuid().ToString(), + method = "live_camera_change", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + camera_position = position, + video_id = "8UUXN5400A079H/165-0-7/normal-0" + } + }; + string payload = JsonSerializer.Serialize(requestData); + await _mqttClientManager.PublishAsync(topicRequest, payload); + + var topicRequest1 = $"thing/product/8UUXN5400A079H/services_reply"; + var requestData1 = new + { + bid = Guid.NewGuid().ToString(), + method = "live_camera_change", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + result = 0 + } + }; + string payload1 = JsonSerializer.Serialize(requestData1); + await _mqttClientManager.PublishAsync(topicRequest1, payload1); + + response.Result = 1; + + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.Message; + } + return response; ; + + } + + + + /// + /// 设置直播镜头 + /// + /// + [HttpPost] + public async Task> SetCamera(string cameraType, string videoId) + { + Response response = new Response(); + try + { + + var topicRequest = $"thing/product/8UUXN5400A079H/services"; + var requestData = new + { + bid = Guid.NewGuid().ToString(), + method = "live_lens_change", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + video_type = cameraType, + video_id = "8UUXN5400A079H/165-0-7/normal-0" + } + }; + string payload = JsonSerializer.Serialize(requestData); + await _mqttClientManager.PublishAsync(topicRequest, payload); + + var topicRequest1 = $"thing/product/8UUXN5400A079H/services_reply"; + var requestData1 = new + { + bid = Guid.NewGuid().ToString(), + method = "live_lens_change", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + result = 0 + } + }; + string payload1 = JsonSerializer.Serialize(requestData1); + await _mqttClientManager.PublishAsync(topicRequest1, payload1); + + response.Result = 1; + + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.Message; + } + return response; + + } + + + /// + /// 设置直播清晰度 + /// + /// + [HttpPost] + public async Task> SetCameraVideo(int videoQuality, string videoId) + { + Response response = new Response(); + try + { + + var topicRequest = $"thing/product/8UUXN5400A079H/services"; + var requestData = new + { + bid = Guid.NewGuid().ToString(), + method = "live_set_quality", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + video_quality = videoQuality, + video_id = "8UUXN5400A079H/165-0-7/normal-0" + } + }; + string payload = JsonSerializer.Serialize(requestData); + await _mqttClientManager.PublishAsync(topicRequest, payload); + + var topicRequest1 = $"thing/product/8UUXN5400A079H/services_reply"; + var requestData1 = new + { + bid = Guid.NewGuid().ToString(), + method = "live_set_quality", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + result = 0 + } + }; + string payload1 = JsonSerializer.Serialize(requestData1); + await _mqttClientManager.PublishAsync(topicRequest1, payload1); + + response.Result = 1; + + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.Message; + } + return response; + + } + + + /// + /// 停止直播 + /// + /// + [HttpPost] + public async Task> EndLive( string videoId) + { + Response response = new Response(); + try + { + + var topicRequest = $"thing/product/8UUXN5400A079H/services"; + var requestData = new + { + bid = Guid.NewGuid().ToString(), + method = "live_stop_push", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + + video_id = "8UUXN5400A079H/165-0-7/normal-0" + } + }; + string payload = JsonSerializer.Serialize(requestData); + await _mqttClientManager.PublishAsync(topicRequest, payload); + + var topicRequest1 = $"thing/product/8UUXN5400A079H/services_reply"; + var requestData1 = new + { + bid = Guid.NewGuid().ToString(), + method = "live_start_push", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + result = 0 + } + }; + string payload1 = JsonSerializer.Serialize(requestData1); + await _mqttClientManager.PublishAsync(topicRequest1, payload1); + + response.Result = 1; + + + + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.Message; + } + return response; + + } + + + + /// + /// 开始直播 + /// + /// + [HttpPost] + public async Task> StartLive(string videoId,int urlType,string url,int quality) + { + Response response = new Response(); + try + { + + var topicRequest = $"thing/product/8UUXN5400A079H/services"; + var requestData = new + { + bid = Guid.NewGuid().ToString(), + method = "live_start_push", + tid = Guid.NewGuid().ToString(), + timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + data = new + { + url_type = urlType, + url = url, + video_quality = quality, + video_id = "8UUXN5400A079H/165-0-7/normal-0" + } + }; + string payload = JsonSerializer.Serialize(requestData); + await _mqttClientManager.PublishAsync(topicRequest, payload); + + + + response.Result = 1; + + + + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.Message; + } + return response; + + } } } diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs index 87e20f5..90f1597 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/ManageController.cs @@ -294,15 +294,18 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers /// /// 获取项目列表 /// - /// + /// 是否是已加入的项目(0全部,1加入,2未加入) + /// 项目名称筛选 + /// 状态(0全部,1进行中,2已归档) + /// 排序 /// [HttpGet] - public async Task>> GetWorkspaceList(string key) + public async Task>> GetWorkspaceList(int isjoin, string key, int state, string order = "\"CreateTime\" desc") { var result = new Response>(); try { - result = await _app.GetWorkspaceList(key); + result = await _app.GetWorkspaceList(isjoin,key,state,order); } catch (Exception ex) { @@ -343,6 +346,15 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers return await _app.DeleteWorkspace(id); } + /// + /// 归档项目 + /// + /// + [HttpPost] + public async Task> CompleteWorkspace(string id) + { + return await _app.CompleteWorkspace(id); + } /// /// 获取机场列表,添加项目使用 ///