Compare commits
2 Commits
66bdb8944b
...
8b785fc9d2
Author | SHA1 | Date |
---|---|---|
anerx | 8b785fc9d2 | 3 months ago |
anerx | 2f0a5ae0a0 | 3 months ago |
52 changed files with 1312 additions and 448 deletions
@ -0,0 +1,13 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net8.0</TargetFramework> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Admin.NET.Core\Admin.NET.Core.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
@ -0,0 +1,117 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using System.ComponentModel; |
|||
using Admin.NET.Bodk.Cells.Entities; |
|||
using Admin.NET.Bodk.Cells.Models; |
|||
using Admin.NET.Core; |
|||
using Furion.DatabaseAccessor; |
|||
using Furion.DependencyInjection; |
|||
using Furion.DynamicApiController; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace Admin.NET.Bodk.Cells; |
|||
|
|||
[ApiDescriptionSettings(Groups = new[] { "Bodk Groups" }, Name = "Cell", Description = "细胞服务")] |
|||
public class CellService : IDynamicApiController, ITransient |
|||
{ |
|||
private readonly SqlSugarRepository<CellEntity> _repository; |
|||
|
|||
private readonly UserManager _userManager; |
|||
|
|||
public CellService(SqlSugarRepository<CellEntity> repository, UserManager userManager) |
|||
{ |
|||
_repository = repository; |
|||
_userManager = userManager; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
[ApiDescriptionSettings(Name = "GetList"), HttpPost] |
|||
[DisplayName("GetList")] |
|||
public async Task<SqlSugarPagedList<Cell>> GetList(CellQueryInput queryInput) |
|||
{ |
|||
return await _repository.AsQueryable() |
|||
.WhereIF(!string.IsNullOrWhiteSpace(queryInput.BoxBarCode), |
|||
m => queryInput.BoxBarCode != null && m.BoxBarCode.Contains(queryInput.BoxBarCode)) |
|||
.WhereIF(!string.IsNullOrWhiteSpace(queryInput.TubeBarcode), |
|||
m => queryInput.TubeBarcode != null && m.BoxBarCode.Contains(queryInput.TubeBarcode)) |
|||
.WhereIF(queryInput.CustomerId is not null, m => m.CustomerId == queryInput.CustomerId) |
|||
.WhereIF(queryInput.DeviceId is not null, m => m.DeviceId == queryInput.DeviceId) |
|||
.WhereIF(queryInput.CellType is not null, m => m.CellType == queryInput.CellType) |
|||
.Where(m => _userManager.OrgId == m.OrgId) |
|||
.Select<Models.Cell>((u) => new Models.Cell() |
|||
{ |
|||
Id = u.Id, |
|||
TubeBarcode = u.TubeBarcode, |
|||
BoxBarCode = u.BoxBarCode, |
|||
CellType = u.CellType, |
|||
CustomerId = u.CustomerId, |
|||
DeviceId = u.DeviceId, |
|||
Circle = u.Circle, |
|||
Column = u.Column, |
|||
Layer = u.Layer, |
|||
DepositTime = u.DepositTime, |
|||
ExpirationTime = u.ExpirationTime, |
|||
Activity = u.Activity, |
|||
Density = u.Density, |
|||
Capacity = u.Capacity |
|||
}) |
|||
.ToPagedListAsync(queryInput.Page, queryInput.PageSize); |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
[ApiDescriptionSettings(Name = "Add"), HttpPost] |
|||
[DisplayName("Add")] |
|||
public async Task<long?> AddCell(CellInput input) |
|||
{ |
|||
return await _repository.InsertReturnBigIdentityAsync(new CellEntity() |
|||
{ |
|||
TubeBarcode = input.TubeBarcode, |
|||
BoxBarCode = input.BoxBarCode, |
|||
CellType = input.CellType, |
|||
CustomerId = input.CustomerId, |
|||
DeviceId = input.DeviceId, |
|||
Circle = input.Circle, |
|||
Column = input.Column, |
|||
Layer = input.Layer, |
|||
DepositTime = input.DepositTime, |
|||
ExpirationTime = input.ExpirationTime, |
|||
Activity = input.Activity, |
|||
Density = input.Density, |
|||
Capacity = input.Capacity |
|||
}); |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
[ApiDescriptionSettings(Name = "Update"), HttpPost] |
|||
[DisplayName("Update")] |
|||
public async Task UpdateCell(CellInput input) |
|||
{ |
|||
await _repository.UpdateAsync(new CellEntity() |
|||
{ |
|||
Id = input.Id, |
|||
TubeBarcode = input.TubeBarcode, |
|||
BoxBarCode = input.BoxBarCode, |
|||
CellType = input.CellType, |
|||
CustomerId = input.CustomerId, |
|||
DeviceId = input.DeviceId, |
|||
Circle = input.Circle, |
|||
Column = input.Column, |
|||
Layer = input.Layer, |
|||
DepositTime = input.DepositTime, |
|||
ExpirationTime = input.ExpirationTime, |
|||
Activity = input.Activity, |
|||
Density = input.Density, |
|||
Capacity = input.Capacity |
|||
}); |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
[ApiDescriptionSettings(Name = "Delete"), HttpPost] |
|||
[DisplayName("Delete")] |
|||
public async Task DeleteCell(long? id) |
|||
{ |
|||
await _repository.DeleteByIdAsync(id); |
|||
} |
|||
} |
@ -0,0 +1,46 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Core; |
|||
using SqlSugar; |
|||
|
|||
namespace Admin.NET.Bodk.Cells.Entities; |
|||
|
|||
[SugarTable("bodk_cell")] |
|||
public class CellEntity : EntityBase |
|||
{ |
|||
public long CustomerId { get; set; } |
|||
|
|||
public CellType CellType { get; set; } |
|||
|
|||
public long DeviceId { get; set; } |
|||
|
|||
public int Circle { get; set; } |
|||
|
|||
public int Column { get; set; } |
|||
|
|||
public int Layer { get; set; } |
|||
|
|||
public string BoxBarCode { get; set; } |
|||
|
|||
public string TubeBarcode { get; set; } |
|||
|
|||
public DateTime DepositTime { get; set; } |
|||
|
|||
public DateTime ExpirationTime { get; set; } |
|||
|
|||
public float Activity { get; set; } |
|||
|
|||
public string Density { get; set; } |
|||
|
|||
public float Capacity { get; set; } |
|||
|
|||
public long OrgId { get; set; } |
|||
} |
|||
|
|||
public enum CellType |
|||
{ |
|||
Immune, |
|||
Stem |
|||
} |
@ -0,0 +1,80 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Bodk.Cells.Entities; |
|||
using Admin.NET.Core; |
|||
|
|||
namespace Admin.NET.Bodk.Cells.Models; |
|||
|
|||
public class CellQueryInput : BasePageInput |
|||
{ |
|||
public long? CustomerId { get; set; } |
|||
|
|||
public CellType? CellType { get; set; } |
|||
|
|||
public long? DeviceId { get; set; } |
|||
|
|||
public string? BoxBarCode { get; set; } |
|||
|
|||
public string? TubeBarcode { get; set; } |
|||
} |
|||
|
|||
public class CellInput : BaseIdInput |
|||
{ |
|||
public long CustomerId { get; set; } |
|||
|
|||
public CellType CellType { get; set; } |
|||
|
|||
public long DeviceId { get; set; } |
|||
|
|||
public int Circle { get; set; } |
|||
|
|||
public int Column { get; set; } |
|||
|
|||
public int Layer { get; set; } |
|||
|
|||
public string BoxBarCode { get; set; } |
|||
|
|||
public string TubeBarcode { get; set; } |
|||
|
|||
public DateTime DepositTime { get; set; } |
|||
|
|||
public DateTime ExpirationTime { get; set; } |
|||
|
|||
public float Activity { get; set; } |
|||
|
|||
public string Density { get; set; } |
|||
|
|||
public float Capacity { get; set; } |
|||
} |
|||
|
|||
public class Cell |
|||
{ |
|||
public long Id { get; set; } |
|||
public long CustomerId { get; set; } |
|||
|
|||
public CellType CellType { get; set; } |
|||
|
|||
public long DeviceId { get; set; } |
|||
|
|||
public int Circle { get; set; } |
|||
|
|||
public int Column { get; set; } |
|||
|
|||
public int Layer { get; set; } |
|||
|
|||
public string BoxBarCode { get; set; } |
|||
|
|||
public string TubeBarcode { get; set; } |
|||
|
|||
public DateTime DepositTime { get; set; } |
|||
|
|||
public DateTime ExpirationTime { get; set; } |
|||
|
|||
public float Activity { get; set; } |
|||
|
|||
public string Density { get; set; } |
|||
|
|||
public float Capacity { get; set; } |
|||
} |
@ -1,19 +0,0 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
namespace Admin.NET.Bodk.Core.Devices; |
|||
|
|||
public interface IDevice |
|||
{ |
|||
long? Id { get; } |
|||
DeviceType Type { get; } |
|||
|
|||
string SerialNumber { get; } |
|||
|
|||
object Summary { get; } |
|||
|
|||
public long? ProjectId { get; } |
|||
|
|||
string Name { get; } |
|||
} |
@ -0,0 +1,69 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Bodk.Core.Entities; |
|||
using Admin.NET.Core; |
|||
using Admin.NET.Core.Service; |
|||
using Furion.DynamicApiController; |
|||
using SqlSugar; |
|||
|
|||
namespace Admin.NET.Bodk.Core; |
|||
|
|||
public abstract class ServiceBase(UserManager userManager, SysOrgService sysOrgService, SysUserService sysUserService) |
|||
: IDynamicApiController |
|||
{ |
|||
protected readonly UserManager UserManager = userManager; |
|||
|
|||
protected readonly SysOrgService SysOrgService = sysOrgService; |
|||
|
|||
protected async Task<ISugarQueryable<T>> GetDataOutOfOrg<T>(ISugarQueryable<T> queryable, long orgId = 0) |
|||
where T : OrgEntityBase |
|||
{ |
|||
var userOrgIdList = await SysOrgService.GetUserOrgIdList(); |
|||
List<long>? orgList; |
|||
if (orgId > 0) // 指定机构查询时
|
|||
{ |
|||
orgList = await SysOrgService.GetChildIdListWithSelfById(orgId); |
|||
orgList = UserManager.SuperAdmin ? orgList : orgList.Where(u => userOrgIdList.Contains(u)).ToList(); |
|||
} |
|||
else // 各管理员只能看到自己机构下的用户列表
|
|||
{ |
|||
orgList = UserManager.SuperAdmin ? null : userOrgIdList; |
|||
} |
|||
|
|||
return queryable.WhereIF(orgList != null, u => orgList != null && orgList.Contains(u.OrgId)); |
|||
} |
|||
|
|||
//新增前置步骤
|
|||
protected async Task<T> AddBefore<T>(T entity) where T : EntityBase |
|||
{ |
|||
var user = await sysUserService.GetBaseInfo(); |
|||
entity.CreateUser = user; |
|||
entity.CreateTime = DateTime.Now; |
|||
entity.CreateUserName = user.NickName; |
|||
entity.CreateUserId = user.Id; |
|||
return entity; |
|||
} |
|||
|
|||
protected async Task<T> AddOrgBefore<T>(T entity) where T : OrgEntityBase |
|||
{ |
|||
var user = await sysUserService.GetBaseInfo(); |
|||
entity.CreateUser = user; |
|||
entity.CreateTime = DateTime.Now; |
|||
entity.CreateUserName = user.NickName; |
|||
entity.CreateUserId = user.Id; |
|||
entity.OrgId = UserManager.OrgId; |
|||
return entity; |
|||
} |
|||
|
|||
protected async Task<T> UpdateBefore<T>(T entity) where T : EntityBase |
|||
{ |
|||
var user = await sysUserService.GetBaseInfo(); |
|||
entity.UpdateUser = user; |
|||
entity.UpdateTime = DateTime.Now; |
|||
entity.UpdateUserName = user.NickName; |
|||
entity.UpdateUserId = user.Id; |
|||
return entity; |
|||
} |
|||
} |
@ -0,0 +1,56 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using System.ComponentModel.DataAnnotations; |
|||
using Admin.NET.Bodk.Customer.Entities; |
|||
using Admin.NET.Core; |
|||
|
|||
namespace Admin.NET.Bodk.Customer.Models; |
|||
|
|||
public class QueryCustomerInput : BasePageInput |
|||
{ |
|||
public long? Id { get; set; } |
|||
public string? Name { get; set; } |
|||
|
|||
public string? IdCard { get; set; } |
|||
|
|||
public string? Phone { get; set; } |
|||
} |
|||
|
|||
public class AddCustomerInput |
|||
{ |
|||
[Required(ErrorMessage = "客户姓名不能为空")] public string Name { get; set; } |
|||
|
|||
[Required(ErrorMessage = "客户身份证号不能为空")] |
|||
public string IdCard { get; set; } |
|||
|
|||
[Required(ErrorMessage = "客户手机号码不能为空")] |
|||
public string Phone { get; set; } |
|||
|
|||
[Required(ErrorMessage = "客户性别不能为空")] public bool IsMale { get; set; } |
|||
|
|||
public string? ImageUrl { get; set; } |
|||
|
|||
public string? VoiceUrl { get; set; } |
|||
} |
|||
|
|||
public class UpdateCustomerInput : BaseIdInput |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public string IdCard { get; set; } |
|||
|
|||
public string Phone { get; set; } |
|||
|
|||
public bool IsMale { get; set; } |
|||
|
|||
public string? ImageUrl { get; set; } |
|||
|
|||
public string? VoiceUrl { get; set; } |
|||
} |
|||
|
|||
public class Customer : CustomerEntity |
|||
{ |
|||
public new List<long>? OrgIds = null; |
|||
} |
@ -0,0 +1,79 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using System.ComponentModel; |
|||
using Admin.NET.Bodk.Core; |
|||
using Admin.NET.Bodk.Device.Entities; |
|||
using Admin.NET.Bodk.Device.Models; |
|||
using Admin.NET.Core; |
|||
using Admin.NET.Core.Service; |
|||
using Furion.DependencyInjection; |
|||
using Furion.FriendlyException; |
|||
using Mapster; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using NewLife.Caching; |
|||
|
|||
namespace Admin.NET.Bodk.Device; |
|||
|
|||
[ApiDescriptionSettings(Groups = new[] { "Bodk Groups" }, Name = "Device", Description = "设备服务")] |
|||
public class DeviceService( |
|||
UserManager userManager, |
|||
SysOrgService sysOrgService, |
|||
SysUserService sysUserService, |
|||
SqlSugarRepository<DeviceEntity> repository, |
|||
ICache cache) |
|||
: ServiceBase(userManager, sysOrgService, sysUserService), ITransient |
|||
{ |
|||
[ApiDescriptionSettings(Name = "Page"), HttpPost] |
|||
[DisplayName("获取设备分页列表")] |
|||
public async Task<SqlSugarPagedList<DeviceOutput>> Page(DeviceQueryInput queryInput) |
|||
{ |
|||
var queryable = await GetDataOutOfOrg(repository.AsQueryable()); |
|||
return await queryable.WhereIF(!string.IsNullOrWhiteSpace(queryInput.SerialNumber), |
|||
u => queryInput.SerialNumber != null && u.SerialNumber.Contains(queryInput.SerialNumber)) |
|||
.WhereIF(!string.IsNullOrWhiteSpace(queryInput.Name), |
|||
u => queryInput.Name != null && u.Name.Contains(queryInput.Name)) |
|||
.WhereIF(!string.IsNullOrWhiteSpace(queryInput.Name), |
|||
u => queryInput.Name != null && u.Name.Contains(queryInput.Name)) |
|||
.WhereIF(queryInput.Id is not null, u => u.Id == queryInput.Id) |
|||
.WhereIF(queryInput.DeviceType is not null, u => u.DeviceType == queryInput.DeviceType) |
|||
.Select(u => u.Adapt<DeviceOutput>()) |
|||
.Mapper(u => u.Online = cache.Get<bool>($"bodk:device:{u.SerialNumber}:summary:online")) |
|||
.WhereIF(queryInput.Online is not null, u => u.Online == queryInput.Online) |
|||
.ToPagedListAsync(queryInput.Page, queryInput.PageSize); |
|||
} |
|||
|
|||
[ApiDescriptionSettings(Name = "Add"), HttpPost] |
|||
[DisplayName("新增设备")] |
|||
public async Task<long> AddDevice(AddDeviceInput input) |
|||
{ |
|||
var isExist = await repository.AsQueryable().AnyAsync(u => u.SerialNumber == input.SerialNumber); |
|||
if (isExist) throw Oops.Oh(ErrorCodeEnum.Device1000); |
|||
var entity = input.Adapt<DeviceEntity>(); |
|||
entity.OrgId = UserManager.OrgId; |
|||
return await repository.InsertReturnBigIdentityAsync(entity); |
|||
} |
|||
|
|||
[ApiDescriptionSettings(Name = "Update"), HttpPost] |
|||
[DisplayName("更新设备")] |
|||
public async Task UpdateDevice(UpdateDeviceInput input) |
|||
{ |
|||
var isExist = await repository.AsQueryable().AnyAsync(u => u.Id == input.Id); |
|||
if (!isExist) throw Oops.Oh("要更新的设备不存在"); |
|||
var entity = await repository.GetByIdAsync(input.Id); |
|||
entity.DeviceType = input.DeviceType ?? entity.DeviceType; |
|||
entity.Name = input.Name ?? entity.Name; |
|||
entity.OrgId = input.OrgId ?? entity.OrgId; |
|||
await repository.UpdateAsync(entity); |
|||
} |
|||
|
|||
[ApiDescriptionSettings(Name = "Delete"), HttpPost] |
|||
[DisplayName("删除设备")] |
|||
public async Task DeleteDevice(long id) |
|||
{ |
|||
var isExist = await repository.AsQueryable().AnyAsync(u => u.Id == id); |
|||
if (!isExist) throw Oops.Oh("要删除的设备不存在"); |
|||
await repository.DeleteByIdAsync(id); |
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Bodk.Core.Entities; |
|||
using Admin.NET.Core; |
|||
using SqlSugar; |
|||
|
|||
namespace Admin.NET.Bodk.Device.Entities; |
|||
|
|||
[SugarTable("bodk_device")] |
|||
public class DeviceEntity : OrgEntityBase |
|||
{ |
|||
|
|||
public DeviceType DeviceType { get; set; } |
|||
|
|||
public string SerialNumber { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
} |
|||
|
|||
public enum DeviceType |
|||
{ |
|||
M9 = 1, |
|||
Agv = 2, |
|||
|
|||
//离心机
|
|||
Lidar = 3, |
|||
|
|||
//培养箱
|
|||
Plate = 4, |
|||
|
|||
//工业机器人
|
|||
Robot = 5, |
|||
} |
@ -0,0 +1,43 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using System.ComponentModel.DataAnnotations; |
|||
using Admin.NET.Bodk.Device.Entities; |
|||
using Admin.NET.Core; |
|||
|
|||
namespace Admin.NET.Bodk.Device.Models; |
|||
|
|||
public class DeviceQueryInput : BasePageInput |
|||
{ |
|||
public long? Id { get; set; } |
|||
|
|||
public string? SerialNumber { get; set; } |
|||
|
|||
public DeviceType? DeviceType { get; set; } |
|||
|
|||
public string? Name { get; set; } |
|||
|
|||
public bool? Online { get; set; } |
|||
} |
|||
|
|||
public class AddDeviceInput : DeviceEntity |
|||
{ |
|||
} |
|||
|
|||
public class UpdateDeviceInput |
|||
{ |
|||
[Required(ErrorMessage = "更新时,设备Id不能为空")] |
|||
public long Id { get; set; } |
|||
|
|||
public long? OrgId { get; set; } |
|||
|
|||
public string? Name { get; set; } |
|||
|
|||
public DeviceType? DeviceType { get; set; } |
|||
} |
|||
|
|||
public class DeviceOutput : DeviceEntity |
|||
{ |
|||
public bool Online { get; set; } |
|||
} |
@ -0,0 +1,27 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Core; |
|||
using SqlSugar; |
|||
|
|||
namespace Admin.NET.Bodk.Genetic.Entities; |
|||
|
|||
[SugarTable("bodk_genetic_item_test_result")] |
|||
public class GeneticItemTestResultEntity : EntityBase |
|||
{ |
|||
public long GeneticTestResultId { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
public float Growth { get; set; } |
|||
|
|||
public float AverageRiskScore { get; set; } |
|||
|
|||
public float RiskScore { get; set; } |
|||
|
|||
public int RiskLevel { get; set; } |
|||
|
|||
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "TEXT")] |
|||
public List<Genetic.Models.Genetic>? Genetics { get; set; } |
|||
} |
@ -0,0 +1,159 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using System.ComponentModel; |
|||
using Admin.NET.Bodk.Genetic.Entities; |
|||
using Admin.NET.Bodk.Genetic.Models; |
|||
using Admin.NET.Core; |
|||
using Furion.DatabaseAccessor; |
|||
using Furion.DependencyInjection; |
|||
using Furion.DynamicApiController; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Nest; |
|||
using SqlSugar; |
|||
|
|||
namespace Admin.NET.Bodk.Genetic; |
|||
|
|||
[ApiDescriptionSettings(Groups = new[] { "Bodk Groups" }, Name = "Genetic", Description = "基因检测服务")] |
|||
public class GeneticTestService : IDynamicApiController, ITransient |
|||
{ |
|||
private readonly SqlSugarRepository<GeneticTestResultEntity> _resultRepository; |
|||
|
|||
private readonly SqlSugarRepository<GeneticItemTestResultEntity> _itemRepository; |
|||
|
|||
public GeneticTestService(SqlSugarRepository<GeneticTestResultEntity> resultRepository, |
|||
SqlSugarRepository<GeneticItemTestResultEntity> itemRepository) |
|||
{ |
|||
_resultRepository = resultRepository; |
|||
_itemRepository = itemRepository; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
[ApiDescriptionSettings(Name = "GetList"), HttpPost] |
|||
[DisplayName("GetList")] |
|||
public async Task<SqlSugarPagedList<GeneticTestResultOutput>> GetList(GeneticTestResultQueryInput queryInput) |
|||
{ |
|||
return await _resultRepository.AsQueryable() |
|||
.WhereIF(!string.IsNullOrWhiteSpace(queryInput.Code), |
|||
m => queryInput.Code != null && m.Code.Contains(queryInput.Code)) |
|||
.WhereIF(!string.IsNullOrWhiteSpace(queryInput.Barcode), |
|||
m => queryInput.Barcode != null && m.Code.Contains(queryInput.Barcode)) |
|||
.WhereIF(queryInput.CustomerId is not null, m => m.CustomerId == queryInput.CustomerId) |
|||
.WhereIF(queryInput.Status is not null, |
|||
m => m.Status == queryInput.Status) |
|||
.Select<GeneticTestResultOutput>((u) => new Models.GeneticTestResultOutput() |
|||
{ |
|||
Id = u.Id, |
|||
CustomerId = u.CustomerId, |
|||
Code = u.Code, |
|||
Status = u.Status, |
|||
Barcode = u.Barcode, |
|||
GenerationTime = u.GenerationTime, |
|||
CollectionTime = u.CollectionTime, |
|||
CreateTime = u.CreateTime, |
|||
CreateUserId = u.CreateUserId, |
|||
CreateUserName = u.CreateUserName, |
|||
UpdateTime = u.UpdateTime, |
|||
UpdateUserId = u.UpdateUserId, |
|||
UpdateUserName = u.UpdateUserName, |
|||
TestType = u.TestType, |
|||
IsDelete = u.IsDelete |
|||
}) |
|||
.Mapper(r => |
|||
{ |
|||
r.Items = _itemRepository.AsQueryable().Where(i => i.GeneticTestResultId == r.Id) |
|||
.Select(i => new GeneticItemOutput() |
|||
{ |
|||
RiskLevel = i.RiskLevel, |
|||
CreateUserId = i.CreateUserId, |
|||
CreateUserName = i.CreateUserName, |
|||
CreateTime = i.CreateTime, |
|||
UpdateUserId = i.UpdateUserId, |
|||
UpdateUserName = i.UpdateUserName, |
|||
UpdateTime = i.UpdateTime, |
|||
GeneticTestResultId = i.GeneticTestResultId, |
|||
IsDelete = i.IsDelete, |
|||
RiskScore = i.RiskScore, |
|||
Growth = i.Growth, |
|||
AverageRiskScore = i.AverageRiskScore, |
|||
Genetics = i.Genetics, |
|||
Name = i.Name |
|||
}).ToList(); |
|||
}) |
|||
.ToPagedListAsync(queryInput.Page, queryInput.PageSize); |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
[ApiDescriptionSettings(Name = "Add"), HttpPost] |
|||
[DisplayName("Add")] |
|||
public async Task<long?> AddGeneticTestResult(GeneticTestResultInput input) |
|||
{ |
|||
var id = await _resultRepository.InsertReturnSnowflakeIdAsync(new GeneticTestResultEntity() |
|||
{ |
|||
CustomerId = input.CustomerId, |
|||
Code = input.Code, |
|||
Status = input.Status, |
|||
Barcode = input.Barcode, |
|||
GenerationTime = input.GenerationTime, |
|||
CollectionTime = input.CollectionTime, |
|||
TestType = input.TestType |
|||
}); |
|||
if (input.Items is not null) |
|||
{ |
|||
await _itemRepository.InsertRangeAsync(input.Items.Select(i => new GeneticItemTestResultEntity() |
|||
{ |
|||
Name = i.Name, |
|||
RiskScore = i.RiskScore, |
|||
RiskLevel = i.RiskLevel, |
|||
AverageRiskScore = i.AverageRiskScore, |
|||
Genetics = i.Genetics, |
|||
Growth = i.Growth, |
|||
GeneticTestResultId = id |
|||
}).ToArray()); |
|||
} |
|||
|
|||
return id; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
[ApiDescriptionSettings(Name = "Update"), HttpPost] |
|||
[DisplayName("Update")] |
|||
public async Task UpdateGeneticTestResult(GeneticTestResultUpdateInput input) |
|||
{ |
|||
await _resultRepository.UpdateAsync(new GeneticTestResultEntity() |
|||
{ |
|||
Id = input.Id, |
|||
CustomerId = input.CustomerId, |
|||
Code = input.Code, |
|||
Status = input.Status, |
|||
Barcode = input.Barcode, |
|||
GenerationTime = input.GenerationTime, |
|||
TestType = input.TestType, |
|||
CollectionTime = input.CollectionTime |
|||
}); |
|||
if (input.Items is not null) |
|||
{ |
|||
await _itemRepository.DeleteAsync(i => i.GeneticTestResultId == input.Id); |
|||
await _itemRepository.InsertRangeAsync(input.Items.Select(i => new GeneticItemTestResultEntity() |
|||
{ |
|||
Name = i.Name, |
|||
RiskScore = i.RiskScore, |
|||
RiskLevel = i.RiskLevel, |
|||
AverageRiskScore = i.AverageRiskScore, |
|||
Genetics = i.Genetics, |
|||
Growth = i.Growth, |
|||
GeneticTestResultId =input.Id |
|||
}).ToArray()); |
|||
} |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
[ApiDescriptionSettings(Name = "Delete"), HttpPost] |
|||
[DisplayName("Delete")] |
|||
public async Task DeleteGeneticTestResult(long? id) |
|||
{ |
|||
await _resultRepository.DeleteByIdAsync(id); |
|||
await _itemRepository.DeleteAsync(i => i.GeneticTestResultId == id); |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
namespace Admin.NET.Bodk.Genetic.Models; |
|||
|
|||
public class Genetic |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public string Postion { get; set; } |
|||
|
|||
public bool Risk { get; set; } |
|||
|
|||
public string Type { get; set; } |
|||
|
|||
public string Description { get; set; } |
|||
} |
@ -0,0 +1,26 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Bodk.Genetic.Entities; |
|||
|
|||
namespace Admin.NET.Bodk.Genetic.Models; |
|||
|
|||
public class GeneticItemOutput : GeneticItemTestResultEntity |
|||
{ |
|||
} |
|||
|
|||
public class GeneticItemInput |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public float Growth { get; set; } |
|||
|
|||
public float AverageRiskScore { get; set; } |
|||
|
|||
public float RiskScore { get; set; } |
|||
|
|||
public int RiskLevel { get; set; } |
|||
|
|||
public List<Genetic>? Genetics { get; set; } |
|||
} |
@ -0,0 +1,62 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Bodk.Genetic.Entities; |
|||
using Admin.NET.Core; |
|||
|
|||
namespace Admin.NET.Bodk.Genetic.Models; |
|||
|
|||
public class GeneticTestResultQueryInput : BasePageInput |
|||
{ |
|||
public long? CustomerId { get; set; } |
|||
|
|||
public string? Code { get; set; } |
|||
|
|||
public string? Barcode { get; set; } |
|||
|
|||
public GeneticTestStatus? Status { get; set; } |
|||
} |
|||
|
|||
public class GeneticTestResultInput |
|||
{ |
|||
public long CustomerId { get; set; } |
|||
|
|||
public string Code { get; set; } |
|||
|
|||
public string Barcode { get; set; } |
|||
|
|||
public string TestType { get; set; } |
|||
|
|||
public GeneticTestStatus Status { get; set; } |
|||
|
|||
public DateTime GenerationTime { get; set; } |
|||
|
|||
public DateTime CollectionTime { get; set; } |
|||
|
|||
public List<GeneticItemInput>? Items { get; set; } |
|||
} |
|||
|
|||
public class GeneticTestResultUpdateInput : BaseIdInput |
|||
{ |
|||
public long CustomerId { get; set; } |
|||
|
|||
public string Code { get; set; } |
|||
|
|||
public string Barcode { get; set; } |
|||
|
|||
public string TestType { get; set; } |
|||
|
|||
public GeneticTestStatus Status { get; set; } |
|||
|
|||
public DateTime GenerationTime { get; set; } |
|||
|
|||
public DateTime CollectionTime { get; set; } |
|||
|
|||
public List<GeneticItemInput>? Items { get; set; } |
|||
} |
|||
|
|||
public class GeneticTestResultOutput : GeneticTestResultEntity |
|||
{ |
|||
public List<GeneticItemOutput>? Items { get; set; } |
|||
} |
@ -1,87 +0,0 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using System.ComponentModel; |
|||
using Admin.NET.Bodk.Project.Entities; |
|||
using Admin.NET.Bodk.Project.Models; |
|||
using Admin.NET.Core; |
|||
using Furion.DependencyInjection; |
|||
using Furion.DynamicApiController; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace Admin.NET.Bodk.Project.Controllers; |
|||
|
|||
[ApiDescriptionSettings(GroupName = "Bodk Groups", Description = "项目接口服务")] |
|||
public class ProjectController : IDynamicApiController, ITransient |
|||
{ |
|||
private readonly SqlSugarRepository<ProjectEntity> _repository; |
|||
|
|||
public ProjectController(SqlSugarRepository<ProjectEntity> repository) |
|||
{ |
|||
_repository = repository; |
|||
} |
|||
|
|||
[ApiDescriptionSettings(Name = "GetList"), HttpPost] |
|||
[DisplayName("获取项目列表")] |
|||
public async Task<SqlSugarPagedList<Project.Models.Project>> GetList(ProjectQueryInput input) |
|||
{ |
|||
return await _repository.AsQueryable() |
|||
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), |
|||
m => input.Name != null && m.Name.Contains(input.Name)) |
|||
.WhereIF(input.Id is not null, m => m.Id == input.Id) |
|||
.WhereIF(!string.IsNullOrWhiteSpace(input.Manager), |
|||
m => input.Manager != null && m.Manager.Contains(input.Manager)) |
|||
.WhereIF(!string.IsNullOrWhiteSpace(input.Phone), |
|||
m => input.Phone != null && m.Phone.Contains(input.Phone)) |
|||
.WhereIF(!string.IsNullOrWhiteSpace(input.Position), |
|||
m => input.Position != null && m.Position.Contains(input.Position)) |
|||
.WhereIF(input.IsDeleted is not null, |
|||
m => m.IsDelete == input.IsDeleted) |
|||
.Select<Models.Project>((u) => new Models.Project() |
|||
{ |
|||
Id = u.Id, |
|||
Name = u.Name, |
|||
Manager = u.Manager, |
|||
Position = u.Position, |
|||
Phone = u.Phone, |
|||
IsDeleted = u.IsDelete, |
|||
CreateTime = u.CreateTime, |
|||
}) |
|||
.ToPagedListAsync(input.Page, input.PageSize); |
|||
} |
|||
|
|||
[ApiDescriptionSettings(Name = "Add"), HttpPost] |
|||
[DisplayName("新增项目")] |
|||
public async Task AddProject(ProjectInput project) |
|||
{ |
|||
await _repository.InsertAsync(new ProjectEntity() |
|||
{ |
|||
Name = project.Name, |
|||
Position = project.Position, |
|||
Manager = project.Manager, |
|||
Phone = project.Phone |
|||
}); |
|||
} |
|||
|
|||
[ApiDescriptionSettings(Name = "Delete"), HttpPost] |
|||
[DisplayName("删除项目")] |
|||
public async Task DeleteProject(long id) |
|||
{ |
|||
var project = await _repository.GetSingleAsync(d => d.Id == id); |
|||
project.IsDelete = true; |
|||
await _repository.UpdateAsync(project); |
|||
} |
|||
|
|||
[ApiDescriptionSettings(Name = "Update"), HttpPost] |
|||
[DisplayName("修改项目")] |
|||
public async Task UpdateProject(ProjectInput projectInput) |
|||
{ |
|||
var project = await _repository.GetSingleAsync(d => d.Id == projectInput.Id); |
|||
project.Manager = projectInput.Manager; |
|||
project.Name = projectInput.Name; |
|||
project.Phone = projectInput.Phone; |
|||
project.Position = projectInput.Position; |
|||
await _repository.UpdateAsync(project); |
|||
} |
|||
} |
@ -0,0 +1,14 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Core; |
|||
using SqlSugar; |
|||
|
|||
namespace Admin.NET.Bodk.Project.Entities; |
|||
|
|||
[SugarTable("bodk_org_area_ext")] |
|||
public class AreaExtEntity : EntityBase |
|||
{ |
|||
public long OrgId { get; set; } |
|||
} |
@ -0,0 +1,19 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Core; |
|||
using SqlSugar; |
|||
|
|||
namespace Admin.NET.Bodk.Project.Entities; |
|||
|
|||
[SugarTable("bodk_org_station_ext")] |
|||
public class StationExtEntity : EntityBase |
|||
{ |
|||
public long FactoryId { get; set; } |
|||
|
|||
public long OrgId { get; set; } |
|||
|
|||
[SugarColumn(IsArray = true, ColumnDataType = "long", Length = 1000, IsNullable = true)] |
|||
public long[]? ServiceIds { get; set; } |
|||
} |
@ -0,0 +1,16 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Core; |
|||
|
|||
namespace Admin.NET.Bodk.Project.Entities; |
|||
|
|||
public class StationServiceEntity : EntityBase |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public string Icon { get; set; } |
|||
|
|||
public string Description { get; set; } |
|||
} |
@ -1,50 +0,0 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Core; |
|||
|
|||
namespace Admin.NET.Bodk.Project.Models; |
|||
|
|||
public class Project |
|||
{ |
|||
public long? Id { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
public string Position { get; set; } |
|||
|
|||
public string Manager { get; set; } |
|||
|
|||
public string Phone { get; set; } |
|||
|
|||
public bool IsDeleted { get; set; } |
|||
|
|||
public DateTime CreateTime { get; set; } |
|||
} |
|||
|
|||
public class ProjectQueryInput : BasePageInput |
|||
{ |
|||
public long? Id { get; set; } |
|||
|
|||
public string? Name { get; set; } |
|||
|
|||
public string? Position { get; set; } |
|||
|
|||
public string? Manager { get; set; } |
|||
|
|||
public string? Phone { get; set; } |
|||
|
|||
public bool? IsDeleted { get; set; } |
|||
} |
|||
|
|||
public class ProjectInput : BaseIdInput |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public string Position { get; set; } |
|||
|
|||
public string Manager { get; set; } |
|||
|
|||
public string Phone { get; set; } |
|||
} |
@ -0,0 +1,12 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Core; |
|||
|
|||
namespace Admin.NET.Bodk.Project.Models; |
|||
|
|||
public class StationOutput : SysOrg |
|||
{ |
|||
public List<StationServiceOutput>? Services { get; set; } |
|||
} |
@ -0,0 +1,21 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
namespace Admin.NET.Bodk.Project.Models; |
|||
|
|||
public class StationServiceOutput |
|||
{ |
|||
public long Id { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
public string Icon { get; set; } |
|||
|
|||
public string Description { get; set; } |
|||
} |
|||
|
|||
public class AddStationServiceInput |
|||
{ |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|||
//
|
|||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|||
|
|||
using Admin.NET.Bodk.Core; |
|||
using Admin.NET.Core; |
|||
using Admin.NET.Core.Service; |
|||
|
|||
namespace Admin.NET.Bodk.Project; |
|||
|
|||
public class ProjectService(UserManager userManager, SysOrgService sysOrgService, SysUserService sysUserService) |
|||
: ServiceBase(userManager, sysOrgService, sysUserService) |
|||
{ |
|||
} |
Binary file not shown.
Loading…
Reference in new issue