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.

94 lines
3.8 KiB

2 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
2 years ago
2 years ago
  1. using Shentun.Peis.CustomerOrgGroups;
  2. using Shentun.Peis.Models;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Volo.Abp;
  9. using Volo.Abp.Domain.Repositories;
  10. using Volo.Abp.Domain.Services;
  11. namespace Shentun.Peis.CustomerOrgGroupDetails
  12. {
  13. public class CustomerOrgGroupDetailManager : DomainService
  14. {
  15. private readonly IRepository<CustomerOrgGroupDetail> _repository;
  16. private readonly IRepository<CustomerOrgGroup, Guid> _customerOrgGroupRepository;
  17. private readonly IRepository<CustomerOrgRegister, Guid> _customerOrgRegisterRepository;
  18. private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository;
  19. public CustomerOrgGroupDetailManager(
  20. IRepository<CustomerOrgGroupDetail> repository,
  21. IRepository<CustomerOrg, Guid> customerOrgRepository,
  22. IRepository<CustomerOrgGroup, Guid> customerOrgGroupRepository,
  23. IRepository<CustomerOrgRegister, Guid> customerOrgRegisterRepository
  24. )
  25. {
  26. this._repository = repository;
  27. this._customerOrgRepository = customerOrgRepository;
  28. this._customerOrgGroupRepository = customerOrgGroupRepository;
  29. this._customerOrgRegisterRepository = customerOrgRegisterRepository;
  30. }
  31. /// <summary>
  32. /// 删除单位分组明细
  33. /// </summary>
  34. /// <param name="CustomerOrgGroupId">单位分组ID</param>
  35. /// <returns></returns>
  36. /// <exception cref="UserFriendlyException"></exception>
  37. public async Task CheckAndDeleteAsync(Guid CustomerOrgGroupId)
  38. {
  39. await CheckCustomerOrgStatus(CustomerOrgGroupId);
  40. var customerOrgGroupDetailList = await _repository.GetListAsync(m => m.CustomerOrgGroupId == CustomerOrgGroupId);
  41. if (customerOrgGroupDetailList.Any())
  42. {
  43. //删除单位分组明细
  44. await _repository.DeleteManyAsync(customerOrgGroupDetailList);
  45. }
  46. }
  47. /// <summary>
  48. /// 删除组合项目相关的明细
  49. /// </summary>
  50. /// <param name="AsbitemId">组合项目ID</param>
  51. /// <returns></returns>
  52. /// <exception cref="UserFriendlyException"></exception>
  53. public async Task CheckAndDeleteInAsbitemIdAsync(Guid AsbitemId)
  54. {
  55. var customerOrgGroupDetailList = await _repository.GetListAsync(m => m.AsbitemId == AsbitemId);
  56. if (customerOrgGroupDetailList.Any())
  57. {
  58. //删除组合项目相关的明细
  59. await _repository.DeleteManyAsync(customerOrgGroupDetailList);
  60. }
  61. }
  62. /// <summary>
  63. /// 检查单位状态是否可以使用 未启用和加锁和单位体检次数已完成,不允许操作
  64. /// </summary>
  65. /// <param name="CustomerOrgGroupId">单位分组ID</param>
  66. /// <returns></returns>
  67. private async Task CheckCustomerOrgStatus(Guid CustomerOrgGroupId)
  68. {
  69. var customerOrgGroup = (from a in await _customerOrgGroupRepository.GetQueryableAsync()
  70. join b in await _customerOrgRegisterRepository.GetQueryableAsync() on a.CustomerOrgRegisterId equals b.Id
  71. join c in await _customerOrgRepository.GetQueryableAsync() on b.CustomerOrgId equals c.Id
  72. where a.Id == CustomerOrgGroupId && (c.IsLock == 'Y' || c.IsActive == 'N' || b.IsComplete == 'Y')
  73. select c.DisplayName).FirstOrDefault();
  74. if (!string.IsNullOrWhiteSpace(customerOrgGroup))
  75. {
  76. throw new UserFriendlyException($"单位{customerOrgGroup}未启用或者已锁定,无法操作!");
  77. }
  78. }
  79. }
  80. }