肖正
4 months ago
19 changed files with 684 additions and 331 deletions
@ -0,0 +1,40 @@ |
|||
|
|||
using System.ComponentModel.DataAnnotations; |
|||
using Admin.NET.Core; |
|||
using Nest; |
|||
using SqlSugar; |
|||
using Yitter.IdGenerator; |
|||
|
|||
namespace Admin.Bodk.Device.Entities; |
|||
/// <summary>
|
|||
/// 基地列表
|
|||
/// </summary>
|
|||
[SugarTable(null, "基地列表")] |
|||
[SysTable] |
|||
public class Base: EntityBaseId, IRepositorySettings |
|||
{ |
|||
// 是否主键,是否自增
|
|||
[SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true, IsIdentity = false)] |
|||
public long Id { get; set; } = YitIdHelper.NextId(); |
|||
|
|||
[SugarColumn(ColumnDescription = "基地名称", Length = 32)] |
|||
[Required, MaxLength(32)] |
|||
public virtual string? Name { get; set; } |
|||
|
|||
[SugarColumn(ColumnDescription = "地址")] |
|||
[Required] |
|||
public virtual string? Address { get; set; } |
|||
|
|||
[SugarColumn(ColumnDescription = "电话",IsNullable = true)] |
|||
public int Phone { get; set; } |
|||
|
|||
[SugarColumn(ColumnDescription = "是否可冻存",IsNullable = true)] |
|||
public bool CanFrozen { get; set; } |
|||
[SugarColumn(ColumnDescription = "是否可使用",IsNullable = true)] |
|||
public int CanUse { get; set; } |
|||
[SugarColumn(ColumnDescription = "是否可检测",IsNullable = true)] |
|||
public int CanDetection { get; set; } |
|||
|
|||
[SugarColumn(ColumnDescription = "描述",IsNullable = true)] |
|||
public string Remark { get; set; } |
|||
} |
@ -0,0 +1,29 @@ |
|||
using Admin.NET.Core; |
|||
|
|||
namespace Admin.Bodk.Device.Entities.Dto; |
|||
|
|||
public class Base |
|||
{ |
|||
|
|||
} |
|||
public class BaseInput : BasePageInput |
|||
{ |
|||
|
|||
} |
|||
public class BaseOutput |
|||
{ |
|||
public long Id { get; set; } |
|||
public string Name { get; set; } |
|||
public string Address { get; set; } |
|||
public string Remark { get; set; } |
|||
public int Phone { get; set; } |
|||
public DateTime CreateTime { get; set; } |
|||
|
|||
public List<Support> SupportList { get; set; } |
|||
} |
|||
|
|||
public class BaseAddInput |
|||
{ |
|||
public string Address { get; set; } |
|||
public string Name { get; set; } |
|||
} |
@ -0,0 +1,64 @@ |
|||
|
|||
using Admin.NET.Core; |
|||
|
|||
namespace Admin.Bodk.Device.Entities.Dto; |
|||
|
|||
public class SupportDto |
|||
{ |
|||
|
|||
} |
|||
|
|||
public class SupportInput : BasePageInput |
|||
{ |
|||
|
|||
} |
|||
public class SupportAddInput |
|||
{ |
|||
public string Name { get; set; } |
|||
} |
|||
|
|||
public class SupportOutput |
|||
{ |
|||
public string State { get; set; } |
|||
public string Name { get; set; } |
|||
public string DetectionServiceId { get; set; } |
|||
public int DetectionServiceType { get; set; } |
|||
} |
|||
|
|||
public class CellOutput |
|||
{ |
|||
public string Activity { get; set; } |
|||
public double Temperature { get; set; } |
|||
public string Humidity { get; set; } |
|||
public string Density { get; set; } |
|||
public string Capacity { get; set; } |
|||
public int Type { get; set; } |
|||
public string Location { get; set; } |
|||
public DateTime? LastOperationTime { get; set; } |
|||
public DeviceInfo DeviceInfo { get; set; } |
|||
} |
|||
|
|||
public class DeviceInfo |
|||
{ |
|||
public long DeviceId { get; set; } |
|||
public string PicUrl { get; set; } |
|||
public float LiquidNitrogenHeight { get; set; } |
|||
public double Temperature { get; set; } |
|||
public string Humidity { get; set; } |
|||
public string Address { get; set; } |
|||
public string Name { get; set; } |
|||
public CellBaseInfo CellBaseInfo { get; set; } |
|||
} |
|||
|
|||
public class CellBaseInfo |
|||
{ |
|||
public string BaseName { get; set; } |
|||
public long BaseId { get; set; } |
|||
} |
|||
|
|||
public class SupportBaseOutput |
|||
{ |
|||
public long Id { get; set; } |
|||
public string Name { get; set; } |
|||
public DateTime CreateTime { get; set; } |
|||
} |
@ -0,0 +1,32 @@ |
|||
|
|||
using System.ComponentModel.DataAnnotations; |
|||
using Admin.NET.Core; |
|||
using Nest; |
|||
using SqlSugar; |
|||
using Yitter.IdGenerator; |
|||
|
|||
namespace Admin.Bodk.Device.Entities; |
|||
/// <summary>
|
|||
/// 服务表
|
|||
/// </summary>
|
|||
[SugarTable(null, "服务表")] |
|||
[SysTable] |
|||
public class Support: EntityBaseId, IRepositorySettings |
|||
{ |
|||
// 是否主键,是否自增
|
|||
[SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true, IsIdentity = false)] |
|||
public long Id { get; set; } = YitIdHelper.NextId(); |
|||
|
|||
[SugarColumn(ColumnDescription = "服务名称", Length = 32)] |
|||
[Required, MaxLength(32)] |
|||
public virtual string? Name { get; set; } |
|||
|
|||
[SugarColumn(ColumnDescription = "基地ID",IsNullable = true)] |
|||
public long BaseId { get; set; } |
|||
[SugarColumn(ColumnDescription = "描述",IsNullable = true)] |
|||
public string Remark { get; set; } |
|||
|
|||
// 导航属性
|
|||
[SugarColumn(IsIgnore = true)] |
|||
public virtual Base Base { get; set; } |
|||
} |
@ -0,0 +1,69 @@ |
|||
|
|||
using System.ComponentModel; |
|||
using Admin.Bodk.Device.Entities; |
|||
using Admin.Bodk.Device.Entities.Dto; |
|||
using Admin.Bodk.Device.Entities.equipment; |
|||
using Admin.Bodk.Device.Entities.TaskChain; |
|||
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 SqlSugar; |
|||
|
|||
namespace Admin.Bodk.Device.Services; |
|||
/// <summary>
|
|||
/// 基地管理服务
|
|||
/// </summary>
|
|||
[ApiDescriptionSettings(Order = 2)] |
|||
public class BaseService : IDynamicApiController, ITransient |
|||
{ |
|||
private readonly SqlSugarRepository<Entities.Base> _baseRep; |
|||
private readonly SqlSugarRepository<Entities.Support> _supportRep; |
|||
public BaseService(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<BaseOutput>> PostList(BaseInput input) |
|||
{ |
|||
return await _baseRep.AsQueryable() |
|||
.Select((u) => new BaseOutput |
|||
{ |
|||
Id = u.Id, |
|||
Name = u.Name, |
|||
Address = u.Address, |
|||
Remark = u.Remark, |
|||
Phone = u.Phone, |
|||
SupportList =SqlFunc.Subqueryable<Support>().Where(tc => tc.BaseId == u.Id).ToList() |
|||
}) |
|||
.ToPagedListAsync(input.Page, input.PageSize); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 增加基地
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
[UnitOfWork] |
|||
[ApiDescriptionSettings(Name = "Add"), HttpPost] |
|||
[DisplayName("增加客户")] |
|||
public async Task<long> AddCustomer(BaseAddInput input) |
|||
{ |
|||
if(input is null) throw Oops.Oh("参数不能为空"); |
|||
var customer = input.Adapt<Entities.Base>(); |
|||
var newEquipment = await (_baseRep).AsInsertable(customer).ExecuteReturnEntityAsync(); |
|||
return newEquipment.Id; |
|||
} |
|||
} |
@ -0,0 +1,92 @@ |
|||
|
|||
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; |
|||
} |
|||
} |
Binary file not shown.
Loading…
Reference in new issue