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.
|
|
using Shentun.Peis.CustomerOrgGroups;using Shentun.Peis.Models;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Volo.Abp;using Volo.Abp.Domain.Repositories;using Volo.Abp.Domain.Services;
namespace Shentun.Peis.CustomerOrgGroupDetails{ public class CustomerOrgGroupDetailManager : DomainService { private readonly IRepository<CustomerOrgGroupDetail> _repository; private readonly IRepository<CustomerOrgGroup, Guid> _customerOrgGroupRepository; private readonly IRepository<CustomerOrgRegister, Guid> _customerOrgRegisterRepository; private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository; public CustomerOrgGroupDetailManager( IRepository<CustomerOrgGroupDetail> repository, IRepository<CustomerOrg, Guid> customerOrgRepository, IRepository<CustomerOrgGroup, Guid> customerOrgGroupRepository, IRepository<CustomerOrgRegister, Guid> customerOrgRegisterRepository ) { this._repository = repository; this._customerOrgRepository = customerOrgRepository; this._customerOrgGroupRepository = customerOrgGroupRepository; this._customerOrgRegisterRepository = customerOrgRegisterRepository; }
/// <summary>
/// 删除单位分组明细
/// </summary>
/// <param name="CustomerOrgGroupId">单位分组ID</param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
public async Task CheckAndDeleteAsync(Guid CustomerOrgGroupId) {
await CheckCustomerOrgStatus(CustomerOrgGroupId);
var customerOrgGroupDetailList = await _repository.GetListAsync(m => m.CustomerOrgGroupId == CustomerOrgGroupId); if (customerOrgGroupDetailList.Any()) {
//删除单位分组明细
await _repository.DeleteManyAsync(customerOrgGroupDetailList);
} }
/// <summary>
/// 删除组合项目相关的明细
/// </summary>
/// <param name="AsbitemId">组合项目ID</param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
public async Task CheckAndDeleteInAsbitemIdAsync(Guid AsbitemId) { var customerOrgGroupDetailList = await _repository.GetListAsync(m => m.AsbitemId == AsbitemId); if (customerOrgGroupDetailList.Any()) {
//删除组合项目相关的明细
await _repository.DeleteManyAsync(customerOrgGroupDetailList);
}
}
/// <summary>
/// 检查单位状态是否可以使用 未启用和加锁和单位体检次数已完成,不允许操作
/// </summary>
/// <param name="CustomerOrgGroupId">单位分组ID</param>
/// <returns></returns>
private async Task CheckCustomerOrgStatus(Guid CustomerOrgGroupId) { var customerOrgGroup = (from a in await _customerOrgGroupRepository.GetQueryableAsync() join b in await _customerOrgRegisterRepository.GetQueryableAsync() on a.CustomerOrgRegisterId equals b.Id join c in await _customerOrgRepository.GetQueryableAsync() on b.CustomerOrgId equals c.Id where a.Id == CustomerOrgGroupId && (c.IsLock == 'Y' || c.IsActive == 'N' || b.IsComplete == 'Y') select c.DisplayName).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(customerOrgGroup)) { throw new UserFriendlyException($"单位{customerOrgGroup}未启用或者已锁定,无法操作!"); } } }}
|