Browse Source

增加测试接口

master
肖正 4 months ago
parent
commit
110d69b339
  1. 4
      Admin.Bodk.Customer/CustomerService.cs
  2. 40
      Admin.Bodk.Device/Entities/Base.cs
  3. 25
      Admin.Bodk.Device/Entities/Device/Device.cs
  4. 16
      Admin.Bodk.Device/Entities/Device/DeviceInpt.cs
  5. 0
      Admin.Bodk.Device/Entities/Device/M9.cs
  6. 29
      Admin.Bodk.Device/Entities/Dto/Base.cs
  7. 64
      Admin.Bodk.Device/Entities/Dto/SupportDto.cs
  8. 32
      Admin.Bodk.Device/Entities/Support.cs
  9. 2
      Admin.Bodk.Device/Entities/TaskChain/TaskChain.cs
  10. 69
      Admin.Bodk.Device/Services/BaseService.cs
  11. 61
      Admin.Bodk.Device/Services/DeviceService.cs
  12. 92
      Admin.Bodk.Device/Services/SupportService.cs
  13. 3
      Admin.NET.Core/Entity/EntityBase.cs
  14. BIN
      Admin.NET.Web.Entry/Admin.NET.db
  15. 0
      identifier.sqlite

4
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
/// <param name="input"></param>
/// <returns></returns>
[DisplayName("获取客户列表")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)]
public async Task<SqlSugarPagedList<Entities.Customer>> PostCustomerList(CustomerInput input)
{
return await _customer.AsQueryable()
@ -43,6 +46,7 @@ public class CustomerService: IDynamicApiController, ITransient
/// <returns></returns>
[UnitOfWork]
[ApiDescriptionSettings(Name = "Add"), HttpPost]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)]
[DisplayName("增加客户")]
public async Task<long> AddCustomer(CustomerDot input)
{

40
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;
/// <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; }
}

25
Admin.Bodk.Device/Entities/equipment/SysEquipment.cs → 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;
/// <summary>
/// 设备表
/// </summary>
[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; }

16
Admin.Bodk.Device/Entities/equipment/EquipmentInpt.cs → Admin.Bodk.Device/Entities/Device/DeviceInpt.cs

@ -5,12 +5,12 @@ namespace Admin.Bodk.Device.Entities.equipment;
/// <summary>
/// 获取设备分页列表输入参数
/// </summary>
public class EquipmentInpt : BasePageInput
public class DeviceInpt : BasePageInput
{
/// <summary>
/// 设备名称
/// </summary>
public string EquipmentName { get; set; }
public string Name { get; set; }
/// <summary>
/// 主键
@ -62,7 +62,7 @@ public class EquipmentDto : BaseIdInput
/// <summary>
/// 设备名称
/// </summary>
public string EquipmentName { get; set; }
public string Name { get; set; }
/// <summary>
/// 设备编号
@ -77,7 +77,13 @@ public class EquipmentDto : BaseIdInput
/// <summary>
/// 设备位置
/// </summary>
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; }
/// <summary>
@ -99,5 +105,5 @@ public class EquipmentDto : BaseIdInput
/// </summary>
public DateTime CreateTime { get; set; }
public List<TaskChain.TaskChain> TaskChainList { get; set; }
// public List<TaskChain.TaskChain> TaskChainList { get; set; }
}

0
Admin.Bodk.Device/Entities/equipment/M9.cs → Admin.Bodk.Device/Entities/Device/M9.cs

29
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<Support> SupportList { get; set; }
}
public class BaseAddInput
{
public string Address { get; set; }
public string Name { get; set; }
}

64
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; }
}

32
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;
/// <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; }
}

2
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; }
}

69
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;
/// <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;
}
}

61
Admin.Bodk.Device/Services/SysEquipmentService.cs → Admin.Bodk.Device/Services/DeviceService.cs

@ -16,13 +16,13 @@ namespace Admin.Bodk.Device.Services;
/// 设备管理服务
/// </summary>
[ApiDescriptionSettings(Order = 2)]
public class SysEquipmentService : IDynamicApiController, ITransient
public class DeviceService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<SysEquipment> _repository;
private readonly SqlSugarRepository<Entities.Device.Device> _repository;
private readonly SqlSugarRepository<TaskChain> _taskChainRepository;
public SysEquipmentService(SqlSugarRepository<SysEquipment> repository, SqlSugarRepository<TaskChain> taskChainRepository)
public DeviceService(SqlSugarRepository<Entities.Device.Device> repository, SqlSugarRepository<TaskChain> taskChainRepository)
{
_repository = repository;
_taskChainRepository = taskChainRepository;
@ -34,25 +34,30 @@ public class SysEquipmentService : IDynamicApiController, ITransient
/// <param name="input"></param>
/// <returns></returns>
[DisplayName("获取设备列表")]
public async Task<SqlSugarPagedList<EquipmentDto>> PostEquipmentList(EquipmentInpt input)
public async Task<SqlSugarPagedList<EquipmentDto>> PostList(DeviceInpt input)
{
return await _repository.AsQueryable()
// .LeftJoin<TaskChain.TaskChain>((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<TaskChain>().Where(tc => tc.EquipmentId == u.Id).ToList()
//TaskChainList =SqlFunc.Subqueryable<TaskChain>().Where(tc => tc.EquipmentId == u.Id).ToList()
})
.ToPagedListAsync(input.Page, input.PageSize);
}
@ -68,20 +73,20 @@ public class SysEquipmentService : IDynamicApiController, ITransient
public async Task<long> AddEquipment(EquipmentDto input)
{
if(input is null) throw Oops.Oh("参数不能为空");
var equipment = input.Adapt<SysEquipment>();
var equipment = input.Adapt<Entities.Device.Device>();
// 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<SysEquipment>())
.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<Entities.Device.Device>())
.UpdateColumns(m => new { m.Type, m.Name, m.Remark, m.Code })
.ExecuteCommandAsync();
}

92
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;
/// <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;
}
}

3
Admin.NET.Core/Entity/EntityBase.cs

@ -1,6 +1,3 @@
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
//
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
namespace Admin.NET.Core;

BIN
Admin.NET.Web.Entry/Admin.NET.db

Binary file not shown.

0
identifier.sqlite

Loading…
Cancel
Save