You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. using Shentun.Peis.Enums;
  2. using Shentun.Peis.Models;
  3. using Shentun.Utilities;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using Volo.Abp.Domain.Repositories;
  10. using Volo.Abp;
  11. using Volo.Abp.Domain.Services;
  12. using Shentun.Peis.HelperDto;
  13. namespace Shentun.Peis.ThirdInterfaces
  14. {
  15. public class ThirdInterfaceManager : DomainService
  16. {
  17. private readonly IRepository<ThirdInterface, Guid> _thirdInterfaceRepository;
  18. public ThirdInterfaceManager(
  19. IRepository<ThirdInterface, Guid> thirdInterfaceRepository
  20. )
  21. {
  22. _thirdInterfaceRepository = thirdInterfaceRepository;
  23. }
  24. /// <summary>
  25. /// 创建
  26. /// </summary>
  27. /// <param name="entity"></param>
  28. /// <returns></returns>
  29. public async Task<ThirdInterface> CreateAsync(
  30. ThirdInterface entity
  31. )
  32. {
  33. Verify(entity);
  34. return new ThirdInterface
  35. {
  36. DisplayName = entity.DisplayName,
  37. DisplayOrder = await EntityHelper.CreateMaxDisplayOrder<ThirdInterface>(_thirdInterfaceRepository),
  38. IsActive = entity.IsActive,
  39. MedicalCenterId = entity.MedicalCenterId,
  40. ParmValue = entity.ParmValue,
  41. ThirdInterfaceType = entity.ThirdInterfaceType
  42. };
  43. }
  44. /// <summary>
  45. /// 更新
  46. /// </summary>
  47. /// <param name="sourceEntity"></param>
  48. /// <param name="targetEntity"></param>
  49. /// <returns></returns>
  50. public void UpdateAsync(
  51. ThirdInterface sourceEntity,
  52. ThirdInterface targetEntity
  53. )
  54. {
  55. DataHelper.CheckEntityIsNull(targetEntity);
  56. Verify(sourceEntity);
  57. if (sourceEntity.DisplayName != targetEntity.DisplayName)
  58. {
  59. targetEntity.DisplayName = sourceEntity.DisplayName;
  60. }
  61. targetEntity.IsActive = sourceEntity.IsActive;
  62. targetEntity.MedicalCenterId = sourceEntity.MedicalCenterId;
  63. targetEntity.ParmValue = sourceEntity.ParmValue;
  64. targetEntity.ThirdInterfaceType = sourceEntity.ThirdInterfaceType;
  65. }
  66. /// <summary>
  67. /// 删除项目时,同步删除项目结果模板( item_result_template)、参考范围(reference_range)、结果匹配(item_result_match)、组合项目包含的项目(asbitem_detail),项目模板明细(ItemTemplateDetail)。
  68. /// </summary>
  69. /// <param name="id"></param>
  70. /// <returns></returns>
  71. /// <exception cref="UserFriendlyException"></exception>
  72. public async Task CheckAndDeleteAsync(Guid id)
  73. {
  74. await _thirdInterfaceRepository.DeleteAsync(id);
  75. }
  76. /// <summary>
  77. /// 修改排序 置顶,置底
  78. /// </summary>
  79. /// <param name="id">需要修改的ID</param>
  80. /// <param name="SortType">修改方式:1 置顶 2 置底</param>
  81. /// <returns></returns>
  82. public async Task UpdateManySortAsync(Guid id, int SortType)
  83. {
  84. await EntityHelper.UpdateManySortAsync(_thirdInterfaceRepository, id, SortType);
  85. }
  86. /// <summary>
  87. /// 修改排序 拖拽
  88. /// </summary>
  89. /// <typeparam name="TEntity"></typeparam>
  90. /// <param name="repository"></param>
  91. /// <param name="input"></param>
  92. /// <returns></returns>
  93. public async Task UpdateSortManyAsync(UpdateSortManyDto input)
  94. {
  95. await EntityHelper.UpdateSortManyAsync(_thirdInterfaceRepository, input);
  96. }
  97. private void Verify(ThirdInterface entity)
  98. {
  99. DataHelper.CheckEntityIsNull(entity);
  100. DataHelper.CheckStringIsNull(entity.DisplayName, "名称");
  101. DataHelper.CheckStringIsNull(entity.ParmValue, "配置参数");
  102. DataHelper.CheckCharIsYOrN(entity.IsActive, "是否启用");
  103. if (entity.ThirdInterfaceType != ThirdInterfaceTypeFlag.LisRequest
  104. && entity.ThirdInterfaceType != ThirdInterfaceTypeFlag.ChargeRequest
  105. && entity.ThirdInterfaceType != ThirdInterfaceTypeFlag.ImportLisResult
  106. && entity.ThirdInterfaceType != ThirdInterfaceTypeFlag.ImportPacsResult)
  107. {
  108. throw new ArgumentException($"接口类型参数为:{entity.ThirdInterfaceType},是无效值");
  109. }
  110. }
  111. }
  112. }