操控平台后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
4.0 KiB

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;
/// <summary>
/// 服务管理
/// </summary>
[ApiDescriptionSettings(Order = 2)]
public class SupportService: IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<Entities.Base> _baseRep;
private readonly SqlSugarRepository<Entities.Support> _supportRep;
public SupportService(SqlSugarRepository<Entities.Base> baseRep, SqlSugarRepository<Entities.Support> supportRep)
{
_baseRep = baseRep;
_supportRep = supportRep;
}
/// <summary>
/// 获取检测信息列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[DisplayName("获取检测信息列表")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)]
public async Task<SqlSugarPagedList<SupportOutput>> PostGetDetectionList(BaseInput input)
{
List<SupportOutput> items = new List<SupportOutput>();
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<SupportOutput>() { Page = 1, PageSize = 20, Items = items, Total = 3 };
}
/// <summary>
/// 获取细胞服务列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[DisplayName("获取细胞服务列表")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)]
public async Task<SqlSugarPagedList<CellOutput>> PostGetCellList(BaseInput input)
{
List<CellOutput> items = new List<CellOutput>();
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<CellOutput>() { Page = 1, PageSize = 20, Items = items, Total = 3 };
}
/// <summary>
/// 增加服务
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[UnitOfWork]
[ApiDescriptionSettings(Name = "Add"), HttpPost]
[DisplayName("增加服务")]
public async Task<long> AddSupport(SupportAddInput input)
{
if(input is null) throw Oops.Oh("参数不能为空");
var equipment = input.Adapt<Entities.Support>();
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;
}
}