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.

314 lines
12 KiB

3 years ago
3 years ago
2 years ago
3 years ago
2 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
2 years ago
3 years ago
2 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
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
4 months ago
2 years ago
5 months ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
4 months 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
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Shentun.Peis.HelperDto;
  4. using Shentun.Peis.Models;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Threading.Tasks;
  9. using Volo.Abp;
  10. using Volo.Abp.Application.Dtos;
  11. using Volo.Abp.Application.Services;
  12. using Volo.Abp.Caching;
  13. using Volo.Abp.Domain.Repositories;
  14. using Volo.Abp.Identity;
  15. namespace Shentun.Peis.Asbitems
  16. {
  17. /// <summary>
  18. /// 组合项目设置
  19. /// </summary>
  20. [ApiExplorerSettings(GroupName = "Work")]
  21. [Authorize]
  22. public class AsbitemAppService : CrudAppService<
  23. Asbitem, //The Book entity
  24. AsbitemDto, //Used to show books
  25. Guid, //Primary key of the book entity
  26. PagedAndSortedResultRequestDto, //Used for paging/sorting
  27. CreateAsbitemDto,
  28. UpdateAsbitemDto>
  29. {
  30. private readonly IRepository<IdentityUser, Guid> _userRepository;
  31. private readonly IDistributedCache<Asbitem, Guid> _asbitemCache;
  32. private readonly AsbitemManager _manager;
  33. private readonly IRepository<Item, Guid> _itemRepository;
  34. private readonly IRepository<AsbitemDetail> _asbitemDetailRepository;
  35. private readonly CacheService _cacheService;
  36. public AsbitemAppService(
  37. IRepository<Asbitem, Guid> repository,
  38. IRepository<IdentityUser, Guid> userRepository,
  39. AsbitemManager manager,
  40. IDistributedCache<Asbitem, Guid> asbitemCache,
  41. IRepository<Item, Guid> itemRepository,
  42. IRepository<AsbitemDetail> asbitemDetailRepository,
  43. CacheService cacheService)
  44. : base(repository)
  45. {
  46. _userRepository = userRepository;
  47. _manager = manager;
  48. _asbitemCache = asbitemCache;
  49. _itemRepository = itemRepository;
  50. _asbitemDetailRepository = asbitemDetailRepository;
  51. _cacheService = cacheService;
  52. }
  53. /// <summary>
  54. /// 获取通过主键
  55. /// </summary>
  56. /// <param name="id"></param>
  57. /// <returns></returns>
  58. public override async Task<AsbitemDto> GetAsync(Guid id)
  59. {
  60. var entityDto = await base.GetAsync(id);
  61. entityDto.CreatorName = await _cacheService.GetSurnameAsync(entityDto.CreatorId);
  62. entityDto.LastModifierName = await _cacheService.GetSurnameAsync(entityDto.LastModifierId);
  63. return entityDto;
  64. }
  65. /// <summary>
  66. /// 获取列表 组合项目设置
  67. /// </summary>
  68. /// <param name="input"></param>
  69. /// <returns></returns>
  70. [RemoteService(false)]
  71. public override async Task<PagedResultDto<AsbitemDto>> GetListAsync(PagedAndSortedResultRequestDto input)
  72. {
  73. return await base.GetListAsync(input);
  74. }
  75. /// <summary>
  76. /// 获取列表 整合多条件查询 项目类别、名字、拼音简码、是否只显示启用的数据(默认显示全部)
  77. /// </summary>
  78. /// <param name="input"></param>
  79. /// <returns></returns>
  80. [HttpPost("api/app/asbitem/getasbitemlist")]
  81. public async Task<List<AsbitemDto>> GetAsbitemListAsync(GetAsbitemListDto input)
  82. {
  83. var query = from a in await Repository.GetQueryableAsync()
  84. join b in await _userRepository.GetQueryableAsync() on a.CreatorId equals b.Id into bb
  85. from ab in bb.DefaultIfEmpty()
  86. join c in await _userRepository.GetQueryableAsync() on a.LastModifierId equals c.Id into cc
  87. from ac in cc.DefaultIfEmpty()
  88. select new { a, ab, ac };
  89. if (input.ItemTypeId != null && input.ItemTypeId != Guid.Empty)
  90. {
  91. query = query.Where(m => m.a.ItemTypeId == input.ItemTypeId);
  92. }
  93. if (!string.IsNullOrEmpty(input.AsbitemName))
  94. {
  95. query = query.Where(m => (!string.IsNullOrEmpty(m.a.DisplayName) && m.a.DisplayName.Contains(input.AsbitemName))
  96. || (!string.IsNullOrEmpty(m.a.SimpleCode) && m.a.SimpleCode.Contains(input.AsbitemName)));
  97. }
  98. if (input.IsFilterActive == 'Y')
  99. {
  100. query = query.Where(m => m.a.IsActive == 'Y');
  101. }
  102. var entdto = query.Select(s => new AsbitemDto
  103. {
  104. ClinicalMeaning = s.a.ClinicalMeaning,
  105. ItemTypeId = s.a.ItemTypeId,
  106. CreationTime = s.a.CreationTime,
  107. CreatorId = s.a.CreatorId,
  108. DefaultResult = s.a.DefaultResult,
  109. DeviceTypeId = s.a.DeviceTypeId,
  110. DiagnosisFunction = s.a.DiagnosisFunction,
  111. DisplayName = s.a.DisplayName,
  112. DisplayOrder = s.a.DisplayOrder,
  113. ForSexId = s.a.ForSexId,
  114. MaritalStatusId = s.a.MaritalStatusId,
  115. Id = s.a.Id,
  116. CollectItemTypeId = s.a.CollectItemTypeId,
  117. //InvoiceItemTypeId = s.a.InvoiceItemTypeId,
  118. IsActive = s.a.IsActive,
  119. IsBeforeEat = s.a.IsBeforeEat,
  120. IsCheck = s.a.IsCheck,
  121. IsContinueProcess = s.a.IsContinueProcess,
  122. IsDiagnosisFunction = s.a.IsDiagnosisFunction,
  123. IsItemResultMerger = s.a.IsItemResultMerger,
  124. IsPictureRotate = s.a.IsPictureRotate,
  125. LastModificationTime = s.a.LastModificationTime,
  126. LastModifierId = s.a.LastModifierId,
  127. Price = s.a.Price,
  128. QueueTime = s.a.QueueTime,
  129. ShortName = s.a.ShortName,
  130. SimpleCode = s.a.SimpleCode,
  131. BarcodeMode = s.a.BarcodeMode,
  132. IsWebAppoint = s.a.IsWebAppoint,
  133. DiseaseScreeningTypeId = s.a.DiseaseScreeningTypeId,
  134. Warn = s.a.Warn,
  135. ForPregnantFlag = s.a.ForPregnantFlag,
  136. CriticalValueFunction = s.a.CriticalValueFunction,
  137. FollowUpFunction = s.a.FollowUpFunction,
  138. IsCriticalValueFunction = s.a.IsCriticalValueFunction,
  139. IsFollowUpFunction = s.a.IsFollowUpFunction,
  140. IsPrivacy = s.a.IsPrivacy,
  141. //IsDisablePregnancy = s.a.IsDisablePregnancy,
  142. //IsDisablePreparePregnancy = s.a.IsDisablePreparePregnancy,
  143. CreatorName = s.ab != null ? s.ab.Surname : "",
  144. LastModifierName = s.ac != null ? s.ac.Surname : "",
  145. IsOutsend = s.a.IsOutsend
  146. }).OrderBy(o => o.DisplayOrder).ToList();
  147. return entdto;
  148. }
  149. [HttpPost("api/app/asbitem/GetBasicList")]
  150. public async Task<List<BasicAsbitemDto>> GetBasicListAsync(GetAsbitemListDto input)
  151. {
  152. var query = await Repository.GetQueryableAsync();
  153. if (input.ItemTypeId != null && input.ItemTypeId != Guid.Empty)
  154. {
  155. query = query.Where(m => m.ItemTypeId == input.ItemTypeId);
  156. }
  157. if (!string.IsNullOrEmpty(input.AsbitemName))
  158. {
  159. query = query.Where(m => (!string.IsNullOrEmpty(m.DisplayName) && m.DisplayName.Contains(input.AsbitemName))
  160. || (!string.IsNullOrEmpty(m.SimpleCode) && m.SimpleCode.Contains(input.AsbitemName)));
  161. }
  162. if (input.IsFilterActive == 'Y')
  163. {
  164. query = query.Where(m => m.IsActive == 'Y');
  165. }
  166. var entdto = query.Select(s => new BasicAsbitemDto
  167. {
  168. ClinicalMeaning = s.ClinicalMeaning,
  169. ItemTypeId = s.ItemTypeId,
  170. DisplayName = s.DisplayName,
  171. DisplayOrder = s.DisplayOrder,
  172. ForSexId = s.ForSexId,
  173. Id = s.Id,
  174. IsActive = s.IsActive,
  175. IsBeforeEat = s.IsBeforeEat,
  176. IsCheck = s.IsCheck,
  177. IsItemResultMerger = s.IsItemResultMerger,
  178. Price = s.Price,
  179. ShortName = s.ShortName,
  180. SimpleCode = s.SimpleCode,
  181. ForPregnantFlag = s.ForPregnantFlag,
  182. MaritalStatusId = s.MaritalStatusId,
  183. }).OrderBy(o => o.DisplayOrder).ToList();
  184. return entdto;
  185. }
  186. /// <summary>
  187. /// 创建
  188. /// </summary>
  189. /// <param name="input"></param>
  190. /// <returns></returns>
  191. public override async Task<AsbitemDto> CreateAsync(CreateAsbitemDto input)
  192. {
  193. var createEntity = ObjectMapper.Map<CreateAsbitemDto, Asbitem>(input);
  194. var entity = await _manager.CreateAsync(createEntity);
  195. entity = await Repository.InsertAsync(entity);
  196. _asbitemCache.Set(entity.Id, entity);
  197. var dto = ObjectMapper.Map<Asbitem, AsbitemDto>(entity);
  198. return dto;
  199. }
  200. /// <summary>
  201. /// 更新
  202. /// </summary>
  203. /// <param name="id"></param>
  204. /// <param name="input"></param>
  205. /// <returns></returns>
  206. public override async Task<AsbitemDto> UpdateAsync(Guid id, UpdateAsbitemDto input)
  207. {
  208. var entity = await Repository.GetAsync(id);
  209. var sourceEntity = ObjectMapper.Map<UpdateAsbitemDto, Asbitem>(input);
  210. await _manager.UpdateAsync(sourceEntity, entity);
  211. entity = await Repository.UpdateAsync(entity);
  212. _asbitemCache.Set(entity.Id, entity);
  213. return ObjectMapper.Map<Asbitem, AsbitemDto>(entity);
  214. }
  215. /// <summary>
  216. /// 删除
  217. /// </summary>
  218. /// <param name="id"></param>
  219. /// <returns></returns>
  220. public override async Task DeleteAsync(Guid id)
  221. {
  222. await _manager.CheckAndDeleteAsync(id);
  223. }
  224. /// <summary>
  225. /// 修改排序 置顶,置底
  226. /// </summary>
  227. /// <param name="id">需要修改的ID</param>
  228. /// <param name="SortType">修改方式:1 置顶 2 置底</param>
  229. /// <returns></returns>
  230. [HttpPut("api/app/asbitem/updatemanysort")]
  231. public async Task UpdateManySortAsync(Guid id, int SortType)
  232. {
  233. await _manager.UpdateManySortAsync(id, SortType);
  234. }
  235. /// <summary>
  236. /// 修改排序 拖拽
  237. /// </summary>
  238. /// <param name="input"></param>
  239. /// <returns></returns>
  240. [HttpPut("api/app/asbitem/updatesortmany")]
  241. public async Task UpdateSortManyAsync(UpdateSortManyDto input)
  242. {
  243. await _manager.UpdateSortManyAsync(input);
  244. }
  245. /// <summary>
  246. /// 查询组合项目的子项目名称列表 登记页面用
  247. /// </summary>
  248. /// <returns></returns>
  249. [HttpPost("api/app/Asbitem/GetSimpleAsbitemWithDetails")]
  250. public async Task<List<SimpleAsbitemWithDetailsDto>> GetSimpleAsbitemWithDetailsAsync()
  251. {
  252. var query = from asbtiem in await Repository.GetQueryableAsync()
  253. join asbitemDetail in await _asbitemDetailRepository.GetQueryableAsync() on asbtiem.Id equals asbitemDetail.AsbitemId
  254. join item in await _itemRepository.GetQueryableAsync() on asbitemDetail.ItemId equals item.Id
  255. orderby asbtiem.DisplayOrder, item.DisplayOrder ascending
  256. select new
  257. {
  258. AsbitemId = asbtiem.Id,
  259. ItemName = item.DisplayName
  260. };
  261. var result = query.Select(s => new SimpleAsbitemWithDetailsDto
  262. {
  263. AsbitemId = s.AsbitemId,
  264. ItemName = s.ItemName
  265. }).ToList();
  266. return result;
  267. }
  268. /// <summary>
  269. /// 获取组合项目的缓存信息
  270. /// </summary>
  271. /// <param name="AsbitemId"></param>
  272. /// <returns></returns>
  273. [HttpPost("api/app/Asbitem/GetAsbitemCacheByAsbitemId")]
  274. public async Task<Asbitem> GetAsbitemCacheByAsbitemIdAsync(Guid AsbitemId)
  275. {
  276. //var asbitemEnt = await _cacheService.GetAsbitemAsync(AsbitemId);
  277. var asbitemEnt = await _asbitemCache.GetAsync(AsbitemId);
  278. return asbitemEnt;
  279. }
  280. }
  281. }