diff --git a/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/CreateThirdInterfaceDto.cs b/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/CreateThirdInterfaceDto.cs new file mode 100644 index 0000000..fd3b530 --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/CreateThirdInterfaceDto.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.WebPeis.ThirdInterfaces +{ + public class CreateThirdInterfaceDto + { + /// + /// 名称 + /// + public string ThirdInterfaceName { get; set; } + + /// + /// 接口类型 + /// + public string ThirdInterfaceType { get; set; } + + /// + /// 配置参数 + /// + public string ParmValue { get; set; } + + /// + /// 体检中心ID + /// + public Guid MedicalCenterId { get; set; } + + /// + /// 是否启用 + /// + public char IsActive { get; set; } + + + } +} diff --git a/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/DeleteThirdInterfaceDto.cs b/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/DeleteThirdInterfaceDto.cs new file mode 100644 index 0000000..da72b47 --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/DeleteThirdInterfaceDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.WebPeis.ThirdInterfaces +{ + public class DeleteThirdInterfaceDto + { + public Guid ThirdInterfaceId { get; set; } + } +} diff --git a/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/ThirdInterfaceDto.cs b/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/ThirdInterfaceDto.cs new file mode 100644 index 0000000..8bdea34 --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/ThirdInterfaceDto.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace Shentun.WebPeis.ThirdInterfaces +{ + public class ThirdInterfaceDto : AuditedEntityDtoName + { + public Guid ThirdInterfaceId { get; set; } + /// + /// 名称 + /// + public string ThirdInterfaceName { get; set; } + + /// + /// 接口类型 + /// + public string ThirdInterfaceType { get; set; } + + /// + /// 配置参数 + /// + public string ParmValue { get; set; } + + /// + /// 体检中心ID + /// + public Guid MedicalCenterId { get; set; } + + /// + /// 是否启用 + /// + public char IsActive { get; set; } + + + public int DisplayOrder { get; set; } + + + } +} diff --git a/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/ThirdInterfaceTypeInputDto.cs b/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/ThirdInterfaceTypeInputDto.cs new file mode 100644 index 0000000..4a7537a --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/ThirdInterfaceTypeInputDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.WebPeis.ThirdInterfaces +{ + public class ThirdInterfaceTypeInputDto + { + public string ThirdInterfaceType { get; set; } + } +} diff --git a/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/UpdateThirdInterfaceDto.cs b/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/UpdateThirdInterfaceDto.cs new file mode 100644 index 0000000..948b6f5 --- /dev/null +++ b/src/Shentun.WebPeis.Application.Contracts/ThirdInterfaces/UpdateThirdInterfaceDto.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.WebPeis.ThirdInterfaces +{ + public class UpdateThirdInterfaceDto + { + /// + /// 主键ID + /// + public Guid ThirdInterfaceId { get; set; } + + /// + /// 名称 + /// + public string ThirdInterfaceName { get; set; } + + /// + /// 接口类型 + /// + public string ThirdInterfaceType { get; set; } + + /// + /// 配置参数 + /// + public string ParmValue { get; set; } + + /// + /// 体检中心ID + /// + public Guid MedicalCenterId { get; set; } + + /// + /// 是否启用 + /// + public char IsActive { get; set; } + } +} diff --git a/src/Shentun.WebPeis.Application/ThirdInterfaces/ThirdInterfaceAppService.cs b/src/Shentun.WebPeis.Application/ThirdInterfaces/ThirdInterfaceAppService.cs new file mode 100644 index 0000000..754fb88 --- /dev/null +++ b/src/Shentun.WebPeis.Application/ThirdInterfaces/ThirdInterfaceAppService.cs @@ -0,0 +1,161 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Shentun.WebPeis.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.ObjectMapping; +using Volo.Abp.Users; + +namespace Shentun.WebPeis.ThirdInterfaces +{ + /// + /// 第三方接口 + /// + [ApiExplorerSettings(GroupName = "Work")] + [Authorize] + public class ThirdInterfaceAppService : ApplicationService + { + private readonly IRepository _thirdInterfaceRepository; + private readonly CacheService _cacheService; + private readonly ThirdInterfaceManager _thirdInterfaceManager; + + public ThirdInterfaceAppService( + IRepository thirdInterfaceRepository, + CacheService cacheService, + ThirdInterfaceManager thirdInterfaceManager) + { + _thirdInterfaceRepository = thirdInterfaceRepository; + _cacheService = cacheService; + _thirdInterfaceManager = thirdInterfaceManager; + } + + + /// + /// 查询列表 + /// + /// + [HttpPost("api/app/ThirdInterface/GetList")] + public async Task> GetListAsync() + { + var thirdInterfaceList = await _thirdInterfaceRepository.GetQueryableAsync(); + return thirdInterfaceList.Select(s => new ThirdInterfaceDto + { + CreationTime = s.CreationTime, + CreatorId = s.CreatorId, + ThirdInterfaceName = s.ThirdInterfaceName, + DisplayOrder = s.DisplayOrder, + ThirdInterfaceId = s.ThirdInterfaceId, + IsActive = s.IsActive, + LastModificationTime = s.LastModificationTime, + LastModifierId = s.LastModifierId, + CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result, + LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result, + MedicalCenterId = s.MedicalCenterId, + ParmValue = s.ParmValue, + ThirdInterfaceType = s.ThirdInterfaceType + }).OrderBy(o => o.DisplayOrder).ToList(); + } + + /// + /// 获取第三方接口类型 + /// + /// + /// + [HttpPost("api/app/ThirdInterface/GetListByThirdInterfaceTypeAsync")] + public async Task> GetListByThirdInterfaceTypeAsync(ThirdInterfaceTypeInputDto input) + { + var thirdInterfaceList = (await _thirdInterfaceRepository.GetQueryableAsync() + ).Where(o=>o.ThirdInterfaceType == input.ThirdInterfaceType); + return thirdInterfaceList.Select(s => new ThirdInterfaceDto + { + CreationTime = s.CreationTime, + CreatorId = s.CreatorId, + ThirdInterfaceName = s.ThirdInterfaceName, + DisplayOrder = s.DisplayOrder, + ThirdInterfaceId = s.ThirdInterfaceId, + IsActive = s.IsActive, + LastModificationTime = s.LastModificationTime, + LastModifierId = s.LastModifierId, + CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result, + LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result, + MedicalCenterId = s.MedicalCenterId, + ParmValue = s.ParmValue, + ThirdInterfaceType = s.ThirdInterfaceType + }).OrderBy(o => o.DisplayOrder).ToList(); + } + + /// + /// 创建 + /// + /// + [HttpPost("api/app/ThirdInterface/Create")] + public async Task CreateAsync(CreateThirdInterfaceDto input) + { + var createEntity = ObjectMapper.Map(input); + var entity = await _thirdInterfaceManager.CreateAsync(createEntity); + entity = await _thirdInterfaceRepository.InsertAsync(entity); + var dto = ObjectMapper.Map(entity); + dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId); + dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId); + return dto; + } + + /// + /// 更新 + /// + /// + /// + [HttpPost("api/app/ThirdInterface/Update")] + public async Task UpdateAsync(UpdateThirdInterfaceDto input) + { + var entity = await _thirdInterfaceRepository.GetAsync(o=>o.ThirdInterfaceId == input.ThirdInterfaceId); + var sourceEntity = ObjectMapper.Map(input); + _thirdInterfaceManager.UpdateAsync(sourceEntity, entity); + entity = await _thirdInterfaceRepository.UpdateAsync(entity); + var dto = ObjectMapper.Map(entity); + dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId); + dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId); + return dto; + } + + /// + /// 删除 + /// + /// + /// + [HttpPost("api/app/ThirdInterface/Delete")] + public async Task DeleteAsync(DeleteThirdInterfaceDto input) + { + await _thirdInterfaceManager.CheckAndDeleteAsync(input.ThirdInterfaceId); + } + + + /// + /// 修改排序 置顶,置底 + /// + /// 需要修改的ID + /// 修改方式:1 置顶 2 置底 + /// + [HttpPut("api/app/ThirdInterface/UpdateManySort")] + public async Task UpdateManySortAsync(Guid id, int SortType) + { + await _thirdInterfaceManager.UpdateManySortAsync(id, SortType); + } + + /// + /// 修改排序 拖拽 + /// + /// + /// + [HttpPut("api/app/ThirdInterface/UpdateSortMany")] + public async Task UpdateSortManyAsync(UpdateSortManyDto input) + { + await _thirdInterfaceManager.UpdateSortManyAsync(input); + } + } +} diff --git a/src/Shentun.WebPeis.Application/WebPeisApplicationAutoMapperProfile.cs b/src/Shentun.WebPeis.Application/WebPeisApplicationAutoMapperProfile.cs index d814a31..b2c4044 100644 --- a/src/Shentun.WebPeis.Application/WebPeisApplicationAutoMapperProfile.cs +++ b/src/Shentun.WebPeis.Application/WebPeisApplicationAutoMapperProfile.cs @@ -13,6 +13,7 @@ using Shentun.WebPeis.Nations; using Shentun.WebPeis.OrganizationUnits; using Shentun.WebPeis.Persons; using Shentun.WebPeis.Sexs; +using Shentun.WebPeis.ThirdInterfaces; using Volo.Abp.Identity; namespace Shentun.WebPeis; @@ -78,5 +79,8 @@ public class WebPeisApplicationAutoMapperProfile : Profile .ForMember(d => d.PmStartTime, opt => opt.MapFrom(src => DataHelper.ConvertStringToTimeOnly(src.PmStartTime))) .ForMember(d => d.PmStopTime, opt => opt.MapFrom(src => DataHelper.ConvertStringToTimeOnly(src.PmStopTime))); + CreateMap(); + CreateMap(); + CreateMap(); } } diff --git a/src/Shentun.WebPeis.Domain/ThirdInterfaces/ThirdInterface.cs b/src/Shentun.WebPeis.Domain/ThirdInterfaces/ThirdInterface.cs new file mode 100644 index 0000000..2aa79df --- /dev/null +++ b/src/Shentun.WebPeis.Domain/ThirdInterfaces/ThirdInterface.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.Domain.Entities; +using System.ComponentModel.DataAnnotations; + +namespace Shentun.WebPeis.Models +{ + /// + /// 第三方接口表 + /// + [Table("third_interface")] + public class ThirdInterface : AuditedEntity, IHasConcurrencyStamp, IDisplayOrder + { + public ThirdInterface() { } + public ThirdInterface(Guid id) + { + ThirdInterfaceId = id; + } + public Guid ThirdInterfaceId { get; set; } + /// + /// 名称 + /// + [Column("third_interface_name")] + [StringLength(30)] + public string ThirdInterfaceName { get; set; } + + /// + /// 接口类型 + /// + [Column("third_interface_type")] + [StringLength(2)] + public string ThirdInterfaceType { get; set; } + + /// + /// 配置参数 + /// + [Column("parm_value")] + [StringLength(2000)] + public string ParmValue { get; set; } + + /// + /// 体检中心ID + /// + [Column("medical_center_id")] + public Guid MedicalCenterId { get; set; } + /// + /// 是否启用 + /// + [Column("is_active")] + [StringLength(1)] + public char IsActive { get; set; } + + [Column("display_order")] + public int DisplayOrder { get; set; } + + [Column("concurrency_stamp")] + public string ConcurrencyStamp { get; set; } + + public override object?[] GetKeys() + { + return [ThirdInterfaceId]; + } + } +} diff --git a/src/Shentun.WebPeis.Domain/ThirdInterfaces/ThirdInterfaceManager.cs b/src/Shentun.WebPeis.Domain/ThirdInterfaces/ThirdInterfaceManager.cs new file mode 100644 index 0000000..6fb7794 --- /dev/null +++ b/src/Shentun.WebPeis.Domain/ThirdInterfaces/ThirdInterfaceManager.cs @@ -0,0 +1,141 @@ + +using Shentun.Utilities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; +using Volo.Abp; +using Volo.Abp.Domain.Services; +using System.Reflection; +using Shentun.WebPeis.Models; +using Shentun.WebPeis.Enums; + +namespace Shentun.WebPeis.ThirdInterfaces +{ + public class ThirdInterfaceManager : DomainService + { + private readonly IRepository _thirdInterfaceRepository; + + public ThirdInterfaceManager( + IRepository thirdInterfaceRepository + ) + { + _thirdInterfaceRepository = thirdInterfaceRepository; + } + + /// + /// 创建 + /// + /// + /// + public async Task CreateAsync( + ThirdInterface entity + ) + { + Verify(entity); + + return new ThirdInterface + { + ThirdInterfaceName = entity.ThirdInterfaceName, + DisplayOrder = await EntityHelper.CreateMaxDisplayOrder(_thirdInterfaceRepository), + IsActive = entity.IsActive, + MedicalCenterId = entity.MedicalCenterId, + ParmValue = entity.ParmValue, + ThirdInterfaceType = entity.ThirdInterfaceType + }; + } + /// + /// 更新 + /// + /// + /// + /// + public void UpdateAsync( + ThirdInterface sourceEntity, + ThirdInterface targetEntity + ) + { + DataHelper.CheckEntityIsNull(targetEntity); + Verify(sourceEntity); + if (sourceEntity.ThirdInterfaceName != targetEntity.ThirdInterfaceName) + { + targetEntity.ThirdInterfaceName = sourceEntity.ThirdInterfaceName; + } + + targetEntity.IsActive = sourceEntity.IsActive; + targetEntity.MedicalCenterId = sourceEntity.MedicalCenterId; + targetEntity.ParmValue = sourceEntity.ParmValue; + targetEntity.ThirdInterfaceType = sourceEntity.ThirdInterfaceType; + } + + + /// + /// 删除项目时,同步删除项目结果模板( item_result_template)、参考范围(reference_range)、结果匹配(item_result_match)、组合项目包含的项目(asbitem_detail),项目模板明细(ItemTemplateDetail)。 + /// + /// + /// + /// + public async Task CheckAndDeleteAsync(Guid id) + { + await _thirdInterfaceRepository.DeleteAsync(o=>o.ThirdInterfaceId == id); + } + + + + /// + /// 修改排序 置顶,置底 + /// + /// 需要修改的ID + /// 修改方式:1 置顶 2 置底 + /// + public async Task UpdateManySortAsync(Guid id, int SortType) + { + //await EntityHelper.UpdateManySortAsync(_thirdInterfaceRepository, id, SortType); + } + + + + /// + /// 修改排序 拖拽 + /// + /// + /// + /// + /// + public async Task UpdateSortManyAsync(UpdateSortManyDto input) + { + //await EntityHelper.UpdateSortManyAsync(_thirdInterfaceRepository, input); + + } + + + private void Verify(ThirdInterface entity) + { + DataHelper.CheckEntityIsNull(entity); + DataHelper.CheckStringIsNull(entity.ThirdInterfaceName, "名称"); + DataHelper.CheckStringIsNull(entity.ParmValue, "配置参数"); + DataHelper.CheckCharIsYOrN(entity.IsActive, "是否启用"); + + Type type = typeof(ThirdInterfaceTypeFlag); + //从规定的约束内搜索字段 + //约束有是静态成员,是公共成员,和返回父级的公共静态成员, + //FieldInfo[] fields = type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy); + //if (fields.Where(o=>o.GetValue(null) == entity.ThirdInterfaceType).Count() == 0) + //{ + // throw new ArgumentException($"接口类型参数为:{entity.ThirdInterfaceType},是无效值"); + //} + //if (entity.ThirdInterfaceType != ThirdInterfaceTypeFlag.LisRequest + // && entity.ThirdInterfaceType != ThirdInterfaceTypeFlag.ChargeRequest + // && entity.ThirdInterfaceType != ThirdInterfaceTypeFlag.ImportLisResult + // && entity.ThirdInterfaceType != ThirdInterfaceTypeFlag.ImportPacsResult + // && entity.ThirdInterfaceType != ThirdInterfaceTypeFlag.ImportPatientRegister + // && entity.ThirdInterfaceType != ThirdInterfaceTypeFlag.TranToWebPeis + // && entity.ThirdInterfaceType != ThirdInterfaceTypeFlag.WebAppoint) + //{ + // throw new ArgumentException($"接口类型参数为:{entity.ThirdInterfaceType},是无效值"); + //} + } + } +} diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/ThirdInterfaceConfigure.cs b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/ThirdInterfaceConfigure.cs new file mode 100644 index 0000000..f949a8c --- /dev/null +++ b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/ThirdInterfaceConfigure.cs @@ -0,0 +1,41 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Shentun.Peis.EntityFrameworkCore; +using Shentun.WebPeis.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.TenantManagement; + +namespace Shentun.WebPeis.Configures +{ + public class ThirdInterfaceConfigure : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder entity) + { + entity.ToTable("third_interface", tb => tb.HasComment("第三方接口表")); + entity.Property(t => t.ThirdInterfaceName).HasComment("名称").IsRequired().HasMaxLength(30); + entity.Property(t => t.DisplayOrder).HasComment("显示顺序").IsRequired(); + entity.Property(t => t.ThirdInterfaceType).HasComment("接口类型").IsRequired(); + entity.Property(t => t.IsActive).HasComment("是否启用").IsRequired(); + entity.Property(e => e.ConcurrencyStamp) + .HasMaxLength(40) + .HasColumnName("concurrency_stamp"); + entity.Property(e => e.CreationTime) + .HasColumnType("timestamp(6) without time zone") + .HasColumnName("creation_time"); + entity.Property(e => e.CreatorId).HasColumnName("creator_id"); + entity.Property(e => e.LastModificationTime) + .HasColumnType("timestamp(6) without time zone") + .HasColumnName("last_modification_time"); + entity.Property(e => e.LastModifierId).HasColumnName("last_modifier_id"); + entity.Property(e => e.ThirdInterfaceId) + .IsFixedLength().ValueGeneratedNever() + .HasComment("编号").HasColumnName("third_interface_id"); + + + } + } +} diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/EntityFrameworkCore/WebPeisDbContext.cs b/src/Shentun.WebPeis.EntityFrameworkCore/EntityFrameworkCore/WebPeisDbContext.cs index 087e38d..e8bfaa5 100644 --- a/src/Shentun.WebPeis.EntityFrameworkCore/EntityFrameworkCore/WebPeisDbContext.cs +++ b/src/Shentun.WebPeis.EntityFrameworkCore/EntityFrameworkCore/WebPeisDbContext.cs @@ -232,6 +232,7 @@ public partial class WebPeisDbContext : AbpDbContext, public virtual DbSet DiseaseScreeningTypes { get; set; } public virtual DbSet PrimarykeyBuilders { get; set; } + public virtual DbSet ThirdInterfaces { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { base.OnConfiguring(optionsBuilder);