using System.ComponentModel; using Admin.Bodk.Device.Entities.Dto; using Admin.Bodk.Device.Entities.equipment; using Admin.NET.Core; using Furion.DatabaseAccessor; using Furion.DependencyInjection; using Furion.DynamicApiController; using Furion.FriendlyException; using Mapster; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; namespace Admin.Bodk.Device.Services; /// /// 服务管理 /// [ApiDescriptionSettings(Order = 2)] public class SupportService: IDynamicApiController, ITransient { private readonly SqlSugarRepository _baseRep; private readonly SqlSugarRepository _supportRep; public SupportService(SqlSugarRepository baseRep, SqlSugarRepository supportRep) { _baseRep = baseRep; _supportRep = supportRep; } /// /// 获取检测信息列表 /// /// /// [DisplayName("获取检测信息列表")] [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] public async Task> PostGetDetectionList(BaseInput input) { List items = new List(); items.Add( new SupportOutput() {State="检测中",Name = "检测1",DetectionServiceId = "dd123323",DetectionServiceType=0}); items.Add( new SupportOutput() {State="已完成",Name = "检测2",DetectionServiceId = "dd1233213",DetectionServiceType=1}); items.Add( new SupportOutput() {State="已完成",Name = "检测3",DetectionServiceId = "dd1233213",DetectionServiceType=1}); return new SqlSugarPagedList() { Page = 1, PageSize = 20, Items = items, Total = 3 }; } /// /// 获取细胞服务列表 /// /// /// [DisplayName("获取细胞服务列表")] [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] public async Task> PostGetCellList(BaseInput input) { List items = new List(); items.Add( new CellOutput() {Activity="51%",Temperature = -192.5, Humidity = "12.1%", Density="20个/ml", Capacity="200ml", Type= 1, Location="松山湖",LastOperationTime=null, DeviceInfo=new DeviceInfo() { DeviceId=23223232,PicUrl="",LiquidNitrogenHeight=302,Temperature=-195.2, Humidity="10%",Address="广东省东莞市科技二路与科技一路交叉口西北角宏远·新智汇1栋", Name="M9_01",CellBaseInfo=new CellBaseInfo(){BaseName="松山湖",BaseId=13545} } }); return new SqlSugarPagedList() { Page = 1, PageSize = 20, Items = items, Total = 3 }; } /// /// 增加服务 /// /// /// [UnitOfWork] [ApiDescriptionSettings(Name = "Add"), HttpPost] [DisplayName("增加服务")] public async Task AddSupport(SupportAddInput input) { if(input is null) throw Oops.Oh("参数不能为空"); var equipment = input.Adapt(); var newEquipment = await _supportRep.AsInsertable(equipment).ExecuteReturnEntityAsync(); // if (input?.TaskChainList is { Count: > 0 }) // { // foreach (var taskChain in input.TaskChainList) // { // taskChain.EquipmentId = newEquipment.Id; // await _taskChainRepository.AsInsertable(taskChain).ExecuteReturnEntityAsync(); // } // } return newEquipment.Id; } }