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.

146 lines
5.2 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. using AutoMapper.Internal.Mappers;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Shentun.Peis.Diagnosises;
  4. using Shentun.Peis.AsbitemDetails;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using Volo.Abp.Application.Services;
  11. using Volo.Abp.Domain.Repositories;
  12. using Volo.Abp.Identity;
  13. using Microsoft.EntityFrameworkCore;
  14. using Shentun.Peis.Items;
  15. using Volo.Abp;
  16. using Shentun.Peis.Models;
  17. using Microsoft.AspNetCore.Authorization;
  18. namespace Shentun.Peis.AsbitemDetails
  19. {
  20. /// <summary>
  21. /// 组合项目包含的小项目
  22. /// </summary>
  23. [ApiExplorerSettings(GroupName = "Work")]
  24. [Authorize]
  25. public class AsbitemDetailAppService : ApplicationService
  26. {
  27. private readonly IRepository<AsbitemDetail> _repository;
  28. private readonly IRepository<IdentityUser, Guid> _userRepository;
  29. private readonly AsbitemDetailManager _manager;
  30. private readonly CacheService _cacheService;
  31. public AsbitemDetailAppService(
  32. IRepository<AsbitemDetail> repository,
  33. IRepository<IdentityUser, Guid> userRepository,
  34. AsbitemDetailManager manager,
  35. CacheService cacheService
  36. )
  37. {
  38. this._repository = repository;
  39. this._userRepository = userRepository;
  40. this._manager = manager;
  41. _cacheService = cacheService;
  42. }
  43. /// <summary>
  44. /// 创建
  45. /// </summary>
  46. /// <param name="input"></param>
  47. /// <returns></returns>
  48. [RemoteService(false)]
  49. public async Task<AsbitemDetailDto> CreateAsync(CreateAsbitemDetailDto input)
  50. {
  51. var createEntity = ObjectMapper.Map<CreateAsbitemDetailDto, AsbitemDetail>(input);
  52. var entity = await _repository.InsertAsync(createEntity);
  53. var dto = ObjectMapper.Map<AsbitemDetail, AsbitemDetailDto>(entity);
  54. return dto;
  55. }
  56. /// <summary>
  57. /// 批量创建 先删除
  58. /// </summary>
  59. /// <param name="input"></param>
  60. /// <returns></returns>
  61. [HttpPost("api/app/asbitemdetail/createasbitemdetailmany")]
  62. public async Task CreateAsbitemDetailManyAsync(CreateAsbitemDetailDto input)
  63. {
  64. await _manager.CheckAndDeleteAsync(input.AsbitemId);
  65. if (input.Details.Any())
  66. {
  67. List<AsbitemDetail> asbitemDetails = new List<AsbitemDetail>();
  68. foreach (var details in input.Details)
  69. {
  70. var entity = new AsbitemDetail
  71. {
  72. AsbitemId = input.AsbitemId,
  73. ItemId = details.ItemId
  74. };
  75. asbitemDetails.Add(_manager.CreateAsync(entity));
  76. }
  77. if (asbitemDetails.Count > 0)
  78. {
  79. await _repository.InsertManyAsync(asbitemDetails);
  80. }
  81. }
  82. }
  83. /// <summary>
  84. /// 获取列表 组合项目包含的小项目
  85. /// </summary>
  86. /// <param name="input"></param>
  87. /// <returns></returns>
  88. public async Task<List<ItemDto>> GetAsbitemDetailInItemAsync(AsbitemDetailInItemDto input)
  89. {
  90. var entlist = (await _repository.GetQueryableAsync()).Include(x => x.Item).ThenInclude(x => x.ItemType)
  91. .Where(m => m.AsbitemId == input.AsbitemId)
  92. .OrderBy(o => o.Item.ItemType.DisplayOrder).ThenBy(o => o.Item.DisplayOrder);
  93. var entdto = entlist.Select(s => new ItemDto
  94. {
  95. CreationTime = s.Item.CreationTime,
  96. CreatorId = s.Item.CreatorId,
  97. DisplayName = s.Item.DisplayName,
  98. DisplayOrder = s.Item.DisplayOrder,
  99. Id = s.Item.Id,
  100. ItemTypeId = s.Item.ItemTypeId,
  101. LastModificationTime = s.Item.LastModificationTime,
  102. LastModifierId = s.Item.LastModifierId,
  103. SimpleCode = s.Item.SimpleCode,
  104. CalculationFunction = s.Item.CalculationFunction,
  105. DefaultResult = s.Item.DefaultResult,
  106. DiagnosisFunction = s.Item.DiagnosisFunction,
  107. EnglishShortName = s.Item.EnglishShortName,
  108. InputCheck = s.Item.InputCheck,
  109. IsActive = s.Item.IsActive,
  110. IsCalculationItem = s.Item.IsCalculationItem,
  111. IsContinueProcess = s.Item.IsContinueProcess,
  112. IsDiagnosisFunction = s.Item.IsDiagnosisFunction,
  113. IsNameIntoSummary = s.Item.IsNameIntoSummary,
  114. IsProduceSummary = s.Item.IsProduceSummary,
  115. Price = s.Item.Price,
  116. PriceItemId = s.Item.PriceItemId,
  117. ReferenceRangeTypeFlag = s.Item.ReferenceRangeTypeFlag,
  118. ResultTemplateTypeFlag = s.Item.ResultTemplateTypeFlag,
  119. UnitId = s.Item.UnitId,
  120. CreatorName = _cacheService.GetSurnameAsync(s.Item.CreatorId).Result,
  121. LastModifierName = _cacheService.GetSurnameAsync(s.Item.LastModifierId).Result
  122. }).ToList();
  123. return entdto;
  124. }
  125. }
  126. }