diff --git a/Admin.Bodk.Customer/CustomerService.cs b/Admin.Bodk.Customer/CustomerService.cs index c08707d..1f5b796 100644 --- a/Admin.Bodk.Customer/CustomerService.cs +++ b/Admin.Bodk.Customer/CustomerService.cs @@ -7,6 +7,8 @@ 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; @@ -28,6 +30,7 @@ public class CustomerService: IDynamicApiController, ITransient /// /// [DisplayName("获取客户列表")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] public async Task> PostCustomerList(CustomerInput input) { return await _customer.AsQueryable() @@ -43,6 +46,7 @@ public class CustomerService: IDynamicApiController, ITransient /// [UnitOfWork] [ApiDescriptionSettings(Name = "Add"), HttpPost] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] [DisplayName("增加客户")] public async Task AddCustomer(CustomerDot input) { diff --git a/Admin.Bodk.Device/Entities/Base.cs b/Admin.Bodk.Device/Entities/Base.cs new file mode 100644 index 0000000..3e263a5 --- /dev/null +++ b/Admin.Bodk.Device/Entities/Base.cs @@ -0,0 +1,40 @@ + +using System.ComponentModel.DataAnnotations; +using Admin.NET.Core; +using Nest; +using SqlSugar; +using Yitter.IdGenerator; + +namespace Admin.Bodk.Device.Entities; +/// +/// 基地列表 +/// +[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; } +} \ No newline at end of file diff --git a/Admin.Bodk.Device/Entities/equipment/SysEquipment.cs b/Admin.Bodk.Device/Entities/Device/Device.cs similarity index 56% rename from Admin.Bodk.Device/Entities/equipment/SysEquipment.cs rename to Admin.Bodk.Device/Entities/Device/Device.cs index 265592d..2028ae7 100644 --- a/Admin.Bodk.Device/Entities/equipment/SysEquipment.cs +++ b/Admin.Bodk.Device/Entities/Device/Device.cs @@ -4,13 +4,13 @@ using Nest; using SqlSugar; using Yitter.IdGenerator; -namespace Admin.Bodk.Device.Entities.equipment; +namespace Admin.Bodk.Device.Entities.Device; /// /// 设备表 /// [SugarTable(null, "设备列表")] [SysTable] -public class SysEquipment: EntityTenant, IRepositorySettings +public class Device: EntityTenant, IRepositorySettings { // 是否主键,是否自增 [SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true, IsIdentity = false)] @@ -18,11 +18,14 @@ public class SysEquipment: EntityTenant, IRepositorySettings [SugarColumn(ColumnDescription = "设备名称", Length = 32)] [Required, MaxLength(32)] - public virtual string? EquipmentName { get; set; } + public virtual string? Name { get; set; } [SugarColumn(ColumnDescription = "设备编号", Length = 32,IsNullable = true)] public virtual string Code { get; set; } + [SugarColumn(ColumnDescription = "设备图片url", Length = 32,IsNullable = true)] + public virtual string PicUrl { get; set; } + [SugarColumn(ColumnDescription = "设备类型", Length = 32)] [Required] public virtual string Type { get; set; } @@ -33,8 +36,20 @@ public class SysEquipment: EntityTenant, IRepositorySettings [SugarColumn(ColumnDescription = "设备状态",IsNullable = true)] public string Status { get; set; } - [SugarColumn(ColumnDescription = "设备位置",IsNullable = true)] - public string Position { get; set; } + [SugarColumn(ColumnDescription = "液氮高度",IsNullable = true)] + public float LiquidNitrogenHeight { get; set; } + + [SugarColumn(ColumnDescription = "温度",IsNullable = true)] + public float Temperature { get; set; } + + [SugarColumn(ColumnDescription = "湿度",IsNullable = true)] + public float Humidity { get; set; } + + [SugarColumn(ColumnDescription = "地址",IsNullable = true)] + public string Address { get; set; } + + [SugarColumn(ColumnDescription = "基地名称",IsNullable = true)] + public string BaseName { get; set; } [SugarColumn(ColumnDescription = "备注",IsNullable = true)] public string Remark { get; set; } diff --git a/Admin.Bodk.Device/Entities/equipment/EquipmentInpt.cs b/Admin.Bodk.Device/Entities/Device/DeviceInpt.cs similarity index 79% rename from Admin.Bodk.Device/Entities/equipment/EquipmentInpt.cs rename to Admin.Bodk.Device/Entities/Device/DeviceInpt.cs index c93acee..f6695cf 100644 --- a/Admin.Bodk.Device/Entities/equipment/EquipmentInpt.cs +++ b/Admin.Bodk.Device/Entities/Device/DeviceInpt.cs @@ -5,12 +5,12 @@ namespace Admin.Bodk.Device.Entities.equipment; /// /// 获取设备分页列表输入参数 /// -public class EquipmentInpt : BasePageInput +public class DeviceInpt : BasePageInput { /// /// 设备名称 /// - public string EquipmentName { get; set; } + public string Name { get; set; } /// /// 主键 @@ -62,7 +62,7 @@ public class EquipmentDto : BaseIdInput /// /// 设备名称 /// - public string EquipmentName { get; set; } + public string Name { get; set; } /// /// 设备编号 @@ -77,7 +77,13 @@ public class EquipmentDto : BaseIdInput /// /// 设备位置 /// - public string Position { get; set; } + public string Address { get; set; } + public float Humidity { get; set; } + public float Temperature { get; set; } + public float LiquidNitrogenHeight { get; set; } + public string BaseName { get; set; } + + public string PicUrl { get; set; } /// @@ -99,5 +105,5 @@ public class EquipmentDto : BaseIdInput /// public DateTime CreateTime { get; set; } - public List TaskChainList { get; set; } + // public List TaskChainList { get; set; } } \ No newline at end of file diff --git a/Admin.Bodk.Device/Entities/equipment/M9.cs b/Admin.Bodk.Device/Entities/Device/M9.cs similarity index 100% rename from Admin.Bodk.Device/Entities/equipment/M9.cs rename to Admin.Bodk.Device/Entities/Device/M9.cs diff --git a/Admin.Bodk.Device/Entities/Dto/Base.cs b/Admin.Bodk.Device/Entities/Dto/Base.cs new file mode 100644 index 0000000..62714e3 --- /dev/null +++ b/Admin.Bodk.Device/Entities/Dto/Base.cs @@ -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 SupportList { get; set; } +} + +public class BaseAddInput +{ + public string Address { get; set; } + public string Name { get; set; } +} \ No newline at end of file diff --git a/Admin.Bodk.Device/Entities/Dto/SupportDto.cs b/Admin.Bodk.Device/Entities/Dto/SupportDto.cs new file mode 100644 index 0000000..c654d7b --- /dev/null +++ b/Admin.Bodk.Device/Entities/Dto/SupportDto.cs @@ -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; } +} \ No newline at end of file diff --git a/Admin.Bodk.Device/Entities/Support.cs b/Admin.Bodk.Device/Entities/Support.cs new file mode 100644 index 0000000..d72daef --- /dev/null +++ b/Admin.Bodk.Device/Entities/Support.cs @@ -0,0 +1,32 @@ + +using System.ComponentModel.DataAnnotations; +using Admin.NET.Core; +using Nest; +using SqlSugar; +using Yitter.IdGenerator; + +namespace Admin.Bodk.Device.Entities; +/// +/// 服务表 +/// +[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; } +} \ No newline at end of file diff --git a/Admin.Bodk.Device/Entities/TaskChain/TaskChain.cs b/Admin.Bodk.Device/Entities/TaskChain/TaskChain.cs index c61c2ad..875daa5 100644 --- a/Admin.Bodk.Device/Entities/TaskChain/TaskChain.cs +++ b/Admin.Bodk.Device/Entities/TaskChain/TaskChain.cs @@ -32,5 +32,5 @@ public class TaskChain: EntityTenant, IRepositorySettings // 导航属性 [SugarColumn(IsIgnore = true)] - public virtual SysEquipment SysEquipment { get; set; } + public virtual Device.Device Device { get; set; } } \ No newline at end of file diff --git a/Admin.Bodk.Device/Services/BaseService.cs b/Admin.Bodk.Device/Services/BaseService.cs new file mode 100644 index 0000000..e74bdea --- /dev/null +++ b/Admin.Bodk.Device/Services/BaseService.cs @@ -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; +/// +/// 基地管理服务 +/// +[ApiDescriptionSettings(Order = 2)] +public class BaseService : IDynamicApiController, ITransient +{ + private readonly SqlSugarRepository _baseRep; + private readonly SqlSugarRepository _supportRep; + public BaseService(SqlSugarRepository baseRep, SqlSugarRepository supportRep) + { + _baseRep = baseRep; + _supportRep = supportRep; + } + /// + /// 获取基地信息列表 + /// + /// + /// + [DisplayName("获取基地信息列表")] + [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] + public async Task> 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().Where(tc => tc.BaseId == u.Id).ToList() + }) + .ToPagedListAsync(input.Page, input.PageSize); + } + + /// + /// 增加基地 + /// + /// + /// + [UnitOfWork] + [ApiDescriptionSettings(Name = "Add"), HttpPost] + [DisplayName("增加客户")] + public async Task AddCustomer(BaseAddInput input) + { + if(input is null) throw Oops.Oh("参数不能为空"); + var customer = input.Adapt(); + var newEquipment = await (_baseRep).AsInsertable(customer).ExecuteReturnEntityAsync(); + return newEquipment.Id; + } +} diff --git a/Admin.Bodk.Device/Services/SysEquipmentService.cs b/Admin.Bodk.Device/Services/DeviceService.cs similarity index 62% rename from Admin.Bodk.Device/Services/SysEquipmentService.cs rename to Admin.Bodk.Device/Services/DeviceService.cs index 4be8831..bf2ca74 100644 --- a/Admin.Bodk.Device/Services/SysEquipmentService.cs +++ b/Admin.Bodk.Device/Services/DeviceService.cs @@ -16,13 +16,13 @@ namespace Admin.Bodk.Device.Services; /// 设备管理服务 /// [ApiDescriptionSettings(Order = 2)] -public class SysEquipmentService : IDynamicApiController, ITransient +public class DeviceService : IDynamicApiController, ITransient { - private readonly SqlSugarRepository _repository; + private readonly SqlSugarRepository _repository; private readonly SqlSugarRepository _taskChainRepository; - public SysEquipmentService(SqlSugarRepository repository, SqlSugarRepository taskChainRepository) + public DeviceService(SqlSugarRepository repository, SqlSugarRepository taskChainRepository) { _repository = repository; _taskChainRepository = taskChainRepository; @@ -34,25 +34,30 @@ public class SysEquipmentService : IDynamicApiController, ITransient /// /// [DisplayName("获取设备列表")] - public async Task> PostEquipmentList(EquipmentInpt input) + public async Task> PostList(DeviceInpt input) { return await _repository.AsQueryable() // .LeftJoin((u, a) => u.Id == a.EquipmentId) - .WhereIF(!string.IsNullOrWhiteSpace(input.EquipmentName), - m => m.EquipmentName != null && m.EquipmentName.Contains(input.EquipmentName)) + .WhereIF(!string.IsNullOrWhiteSpace(input.Name), + m => m.Name != null && m.Name.Contains(input.Name)) .WhereIF(!string.IsNullOrWhiteSpace(input.Type), m => m.Type == input.Type) .Select((u) => new EquipmentDto { Id = u.Id, - EquipmentName = u.EquipmentName, + Name = u.Name, Type = u.Type, - Position = u.Position, + BaseName = u.BaseName, + PicUrl = u.PicUrl, + LiquidNitrogenHeight = u.LiquidNitrogenHeight, + Temperature = u.Temperature, + Humidity = u.Humidity, + Address = u.Address, Remark = u.Remark, Code = u.Code, Ip = u.Ip, Status = u.Status, CreateTime = u.CreateTime, - TaskChainList =SqlFunc.Subqueryable().Where(tc => tc.EquipmentId == u.Id).ToList() + //TaskChainList =SqlFunc.Subqueryable().Where(tc => tc.EquipmentId == u.Id).ToList() }) .ToPagedListAsync(input.Page, input.PageSize); } @@ -68,20 +73,20 @@ public class SysEquipmentService : IDynamicApiController, ITransient public async Task AddEquipment(EquipmentDto input) { if(input is null) throw Oops.Oh("参数不能为空"); - var equipment = input.Adapt(); + var equipment = input.Adapt(); // if( a is double b) // { // Console.WriteLine(b); // } var newEquipment = await _repository.AsInsertable(equipment).ExecuteReturnEntityAsync(); - if (input?.TaskChainList is { Count: > 0 }) - { - foreach (var taskChain in input.TaskChainList) - { - taskChain.EquipmentId = newEquipment.Id; - await _taskChainRepository.AsInsertable(taskChain).ExecuteReturnEntityAsync(); - } - } + // if (input?.TaskChainList is { Count: > 0 }) + // { + // foreach (var taskChain in input.TaskChainList) + // { + // taskChain.EquipmentId = newEquipment.Id; + // await _taskChainRepository.AsInsertable(taskChain).ExecuteReturnEntityAsync(); + // } + // } input.Id = newEquipment.Id; return newEquipment.Id; } @@ -97,16 +102,16 @@ public class SysEquipmentService : IDynamicApiController, ITransient public async Task Update(EquipmentDto input) { _taskChainRepository.AsDeleteable().Where(tc => tc.EquipmentId == input.Id).ExecuteCommand(); - if (input?.TaskChainList is { Count: > 0 }) - { - foreach (var taskChain in input.TaskChainList) - { - taskChain.EquipmentId = input.Id; - await _taskChainRepository.AsInsertable(taskChain).ExecuteReturnEntityAsync(); - } - } - await _repository.AsUpdateable(input.Adapt()) - .UpdateColumns(m => new { m.Type, m.EquipmentName, m.Remark, m.Code }) + // if (input?.TaskChainList is { Count: > 0 }) + // { + // foreach (var taskChain in input.TaskChainList) + // { + // taskChain.EquipmentId = input.Id; + // await _taskChainRepository.AsInsertable(taskChain).ExecuteReturnEntityAsync(); + // } + // } + await _repository.AsUpdateable(input.Adapt()) + .UpdateColumns(m => new { m.Type, m.Name, m.Remark, m.Code }) .ExecuteCommandAsync(); } diff --git a/Admin.Bodk.Device/Services/SupportService.cs b/Admin.Bodk.Device/Services/SupportService.cs new file mode 100644 index 0000000..4608126 --- /dev/null +++ b/Admin.Bodk.Device/Services/SupportService.cs @@ -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; +/// +/// 服务管理 +/// +[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; + } +} \ No newline at end of file diff --git a/Admin.NET.Core/Entity/EntityBase.cs b/Admin.NET.Core/Entity/EntityBase.cs index 529dfe8..f9418fd 100644 --- a/Admin.NET.Core/Entity/EntityBase.cs +++ b/Admin.NET.Core/Entity/EntityBase.cs @@ -1,6 +1,3 @@ -// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 -// -// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 namespace Admin.NET.Core; diff --git a/Admin.NET.Web.Entry/Admin.NET.db b/Admin.NET.Web.Entry/Admin.NET.db index ecc44f8..4d9893e 100644 Binary files a/Admin.NET.Web.Entry/Admin.NET.db and b/Admin.NET.Web.Entry/Admin.NET.db differ diff --git a/identifier.sqlite b/identifier.sqlite new file mode 100644 index 0000000..e69de29