diff --git a/src/Shentun.Peis.Application/CommonCharTypes/CommonCharTypeAppService.cs b/src/Shentun.Peis.Application/CommonCharTypes/CommonCharTypeAppService.cs index 1dd28eb..7c3a452 100644 --- a/src/Shentun.Peis.Application/CommonCharTypes/CommonCharTypeAppService.cs +++ b/src/Shentun.Peis.Application/CommonCharTypes/CommonCharTypeAppService.cs @@ -13,6 +13,7 @@ using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; using Volo.Abp.Identity; using Microsoft.AspNetCore.Authorization; +using Volo.Abp; namespace Shentun.Peis.CommonCharTypes { @@ -48,13 +49,18 @@ namespace Shentun.Peis.CommonCharTypes /// public override async Task GetAsync(Guid id) { - return await base.GetAsync(id); + var userList = await _userRepository.GetListAsync(); + var entityDto = await base.GetAsync(id); + entityDto.CreatorName = EntityHelper.GetUserNameNoSql(userList, entityDto.CreatorId); + entityDto.LastModifierName = EntityHelper.GetUserNameNoSql(userList, entityDto.CreatorId); + return entityDto; } /// /// 获取列表 常用字符类别 /// /// /// + [RemoteService(false)] public override async Task> GetListAsync(PagedAndSortedResultRequestDto input) { return await base.GetListAsync(input); @@ -135,16 +141,7 @@ namespace Shentun.Peis.CommonCharTypes return base.DeleteAsync(id); } - /// - /// 修改排序 相邻之间 - /// - /// 需要修改的ID - /// 目标ID - [HttpPut("api/app/commonchartype/updatesort")] - public async Task UpdateSortAsync(Guid id, Guid targetid) - { - await _manager.UpdateSortAsync(id, targetid); - } + /// /// 修改排序 置顶,置底 diff --git a/src/Shentun.Peis.Application/CommonChars/CommonCharAppService.cs b/src/Shentun.Peis.Application/CommonChars/CommonCharAppService.cs index 167ebae..03c2690 100644 --- a/src/Shentun.Peis.Application/CommonChars/CommonCharAppService.cs +++ b/src/Shentun.Peis.Application/CommonChars/CommonCharAppService.cs @@ -14,6 +14,7 @@ using Volo.Abp.Domain.Repositories; using Volo.Abp.Identity; using Microsoft.EntityFrameworkCore; using Microsoft.AspNetCore.Authorization; +using Volo.Abp; namespace Shentun.Peis.CommonChars { @@ -49,13 +50,18 @@ namespace Shentun.Peis.CommonChars /// public override async Task GetAsync(Guid id) { - return await base.GetAsync(id); + var userList = await _userRepository.GetListAsync(); + var entityDto = await base.GetAsync(id); + entityDto.CreatorName = EntityHelper.GetUserNameNoSql(userList, entityDto.CreatorId); + entityDto.LastModifierName = EntityHelper.GetUserNameNoSql(userList, entityDto.CreatorId); + return entityDto; } /// /// 获取列表 常用字符 遗弃 /// /// /// + [RemoteService(false)] public override async Task> GetListAsync(PagedAndSortedResultRequestDto input) { return await base.GetListAsync(input); @@ -145,16 +151,7 @@ namespace Shentun.Peis.CommonChars return base.DeleteAsync(id); } - /// - /// 修改排序 相邻之间 - /// - /// 需要修改的ID - /// 目标ID - [HttpPut("api/app/commonchar/updatesort")] - public async Task UpdateSortAsync(Guid id, Guid targetid) - { - await _manager.UpdateSortAsync(id, targetid); - } + /// /// 修改排序 置顶,置底 diff --git a/src/Shentun.Peis.Application/CustomerOrgGroupDetails/CustomerOrgGroupDetailAppService.cs b/src/Shentun.Peis.Application/CustomerOrgGroupDetails/CustomerOrgGroupDetailAppService.cs index aa21a32..a1311e0 100644 --- a/src/Shentun.Peis.Application/CustomerOrgGroupDetails/CustomerOrgGroupDetailAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgGroupDetails/CustomerOrgGroupDetailAppService.cs @@ -32,10 +32,11 @@ namespace Shentun.Peis.CustomerOrgGroupDetails private readonly ICustomerOrgGroupDetailRepository _customerOrgGroupRepository; private readonly CustomerOrgGroupDetailManager _manager; + public CustomerOrgGroupDetailAppService( ICustomerOrgGroupDetailRepository customerOrgGroupRepository, CustomerOrgGroupDetailManager manager - ) + ) { this._customerOrgGroupRepository = customerOrgGroupRepository; this._manager = manager; @@ -63,6 +64,7 @@ namespace Shentun.Peis.CustomerOrgGroupDetails [HttpPost("api/app/customerorggroupdetail/createcustomerorggroupdetailmany")] public async Task CreateCustomerOrgGroupDetailManyAsync(CreateCustomerOrgGroupDetailDto input) { + await _manager.CheckAndDeleteAsync(input.CustomerOrgGroupId); if (input.details.Any()) @@ -103,5 +105,7 @@ namespace Shentun.Peis.CustomerOrgGroupDetails return entdto; } + + } } diff --git a/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs b/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs index 2fc5384..9e50288 100644 --- a/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs @@ -192,16 +192,7 @@ namespace Shentun.Peis.CustomerOrgGroups await _manager.CheckAndDeleteAsync(id); } - /// - /// 修改排序 相邻之间 - /// - /// 需要修改的ID - /// 目标ID - [HttpPut("api/app/customerorggroup/updatesort")] - public async Task UpdateSortAsync(Guid id, Guid targetid) - { - await _manager.UpdateSortAsync(id, targetid); - } + /// /// 修改排序 置顶,置底 diff --git a/src/Shentun.Peis.Application/CustomerOrgRegisters/CustomerOrgRegisterAppService.cs b/src/Shentun.Peis.Application/CustomerOrgRegisters/CustomerOrgRegisterAppService.cs index 715bde3..ff70b29 100644 --- a/src/Shentun.Peis.Application/CustomerOrgRegisters/CustomerOrgRegisterAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgRegisters/CustomerOrgRegisterAppService.cs @@ -135,6 +135,7 @@ namespace Shentun.Peis.CustomerOrgRegisters { var CustomerOrgParenId = EntityHelper.GetParentNoSql(await _customerOrgRepository.GetListAsync(), CustomerOrgId); //获取一级单位ID var entity = await _manager.CreateAsync(CustomerOrgParenId); + entity = await Repository.InsertAsync(entity); var dto = ObjectMapper.Map(entity); return dto; } @@ -212,7 +213,7 @@ namespace Shentun.Peis.CustomerOrgRegisters CustomerOrgId = s.CustomerOrgId, CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId), LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId) - }).OrderBy(o=>o.MedicalTimes).ToList(); + }).OrderBy(o => o.MedicalTimes).ToList(); return entdto; diff --git a/src/Shentun.Peis.Application/CustomerOrgTypes/CustomerOrgTypeAppService.cs b/src/Shentun.Peis.Application/CustomerOrgTypes/CustomerOrgTypeAppService.cs index 4add637..548fae9 100644 --- a/src/Shentun.Peis.Application/CustomerOrgTypes/CustomerOrgTypeAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgTypes/CustomerOrgTypeAppService.cs @@ -55,15 +55,11 @@ namespace Shentun.Peis.CustomerOrgTypes /// public override async Task GetAsync(Guid id) { - var entity = await Repository.FindAsync(o => o.Id == id); - //throw new Exception("标准异常测试"); - //throw new BusinessException("业务异常测试"); - //throw new UserFriendlyException("友好异常测试"); - //throw new EntityNotFoundException("未发现实体异常测试"); - //return null; - if (entity == null) - return null; - return ObjectMapper.Map(entity); + var userList = await _userRepository.GetListAsync(); + var entityDto = await base.GetAsync(id); + entityDto.CreatorName = EntityHelper.GetUserNameNoSql(userList, entityDto.CreatorId); + entityDto.LastModifierName = EntityHelper.GetUserNameNoSql(userList, entityDto.CreatorId); + return entityDto; } /// @@ -160,17 +156,7 @@ namespace Shentun.Peis.CustomerOrgTypes - /// - /// 修改排序 相邻之间 - /// - /// 需要修改的ID - /// 目标ID - [HttpPut("api/app/customerorgtype/updatesort")] - [RemoteService(false)] - public async Task UpdateSortAsync(Guid id, Guid targetid) - { - await _manager.UpdateSortAsync(id, targetid); - } + /// /// 修改排序 置顶,置底 diff --git a/src/Shentun.Peis.Domain/CommonCharTypes/CommonCharTypeManager.cs b/src/Shentun.Peis.Domain/CommonCharTypes/CommonCharTypeManager.cs index cc472a2..77ba5f3 100644 --- a/src/Shentun.Peis.Domain/CommonCharTypes/CommonCharTypeManager.cs +++ b/src/Shentun.Peis.Domain/CommonCharTypes/CommonCharTypeManager.cs @@ -62,16 +62,7 @@ namespace Shentun.Peis.CommonCharTypes } - - /// - /// 修改排序 相邻之间 - /// - /// 需要修改的ID - /// 目标ID - public async Task UpdateSortAsync(Guid id, Guid targetid) - { - await EntityHelper.UpdateSort(_repository, id, targetid); - } + /// /// 修改排序 置顶,置底 diff --git a/src/Shentun.Peis.Domain/CommonChars/CommonCharManager.cs b/src/Shentun.Peis.Domain/CommonChars/CommonCharManager.cs index eec3755..c4e20ad 100644 --- a/src/Shentun.Peis.Domain/CommonChars/CommonCharManager.cs +++ b/src/Shentun.Peis.Domain/CommonChars/CommonCharManager.cs @@ -79,15 +79,7 @@ namespace Shentun.Peis.CommonChars - /// - /// 修改排序 相邻之间 - /// - /// 需要修改的ID - /// 目标ID - public async Task UpdateSortAsync(Guid id, Guid targetid) - { - await EntityHelper.UpdateSort(_repository, id, targetid); - } + /// /// 修改排序 置顶,置底 diff --git a/src/Shentun.Peis.Domain/CustomerOrgGroupDetails/CustomerOrgGroupDetailManager.cs b/src/Shentun.Peis.Domain/CustomerOrgGroupDetails/CustomerOrgGroupDetailManager.cs index 6677b0b..cb9b3d9 100644 --- a/src/Shentun.Peis.Domain/CustomerOrgGroupDetails/CustomerOrgGroupDetailManager.cs +++ b/src/Shentun.Peis.Domain/CustomerOrgGroupDetails/CustomerOrgGroupDetailManager.cs @@ -14,12 +14,20 @@ namespace Shentun.Peis.CustomerOrgGroupDetails public class CustomerOrgGroupDetailManager : DomainService { private readonly IRepository _repository; - + private readonly IRepository _customerOrgGroupRepository; + private readonly IRepository _customerOrgRegisterRepository; + private readonly IRepository _customerOrgRepository; public CustomerOrgGroupDetailManager( - IRepository repository + IRepository repository, + IRepository customerOrgRepository, + IRepository customerOrgGroupRepository, + IRepository customerOrgRegisterRepository ) { this._repository = repository; + this._customerOrgRepository = customerOrgRepository; + this._customerOrgGroupRepository = customerOrgGroupRepository; + this._customerOrgRegisterRepository = customerOrgRegisterRepository; } @@ -32,6 +40,9 @@ namespace Shentun.Peis.CustomerOrgGroupDetails /// public async Task CheckAndDeleteAsync(Guid CustomerOrgGroupId) { + + await CheckCustomerOrgStatus(CustomerOrgGroupId); + var customerOrgGroupDetailList = await _repository.GetListAsync(m => m.CustomerOrgGroupId == CustomerOrgGroupId); if (customerOrgGroupDetailList.Any()) { @@ -59,7 +70,25 @@ namespace Shentun.Peis.CustomerOrgGroupDetails await _repository.DeleteManyAsync(customerOrgGroupDetailList); } - + + } + + /// + /// 检查单位状态是否可以使用 未启用和加锁和单位体检次数已完成,不允许操作 + /// + /// 单位分组ID + /// + 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}未启用或者已锁定,无法操作!"); + } } } } diff --git a/src/Shentun.Peis.Domain/CustomerOrgGroups/CustomerOrgGroupManager.cs b/src/Shentun.Peis.Domain/CustomerOrgGroups/CustomerOrgGroupManager.cs index e95366e..b0ab5de 100644 --- a/src/Shentun.Peis.Domain/CustomerOrgGroups/CustomerOrgGroupManager.cs +++ b/src/Shentun.Peis.Domain/CustomerOrgGroups/CustomerOrgGroupManager.cs @@ -24,7 +24,7 @@ namespace Shentun.Peis.CustomerOrgGroups private readonly IRepository _repository; private readonly IRepository _patientRegisterRepository; - private readonly IRepository _customerOrgGroupDetailRepository; + private readonly IRepository _customerOrgRepository; private readonly IRepository _customerOrgRegisterRepositor; private readonly CustomerOrgGroupDetailManager _customerOrgGroupDetailManager; @@ -32,14 +32,14 @@ namespace Shentun.Peis.CustomerOrgGroups public CustomerOrgGroupManager( IRepository repository, IRepository patientRegisterRepository, - IRepository customerOrgGroupDetailRepository, + IRepository customerOrgRepository, IRepository customerOrgRegisterRepositor, CustomerOrgGroupDetailManager customerOrgGroupDetailManager) { _repository = repository; this._patientRegisterRepository = patientRegisterRepository; - this._customerOrgGroupDetailRepository = customerOrgGroupDetailRepository; + this._customerOrgRepository = customerOrgRepository; this._customerOrgRegisterRepositor = customerOrgRegisterRepositor; this._customerOrgGroupDetailManager = customerOrgGroupDetailManager; @@ -55,11 +55,11 @@ namespace Shentun.Peis.CustomerOrgGroups CustomerOrgGroup entity ) { - //DataHelper.CheckVerifyData(entity.DisplayName, "名称"); - //await EntityHelper.CheckSameName(_repository, entity.DisplayName); - - //var customerorgRegisterEnt = await _customerorgRegisterRepository.FindAsync(m => m.CustomerOrgId == customerOrgId && m.IsComplete == 'N'); - + if (customerOrgId != null && customerOrgId != Guid.Empty) + { + //检查单位状态 + await CheckCustomerOrgStatus(customerOrgId.Value); + } Guid NewCustomerorgRegisterId = Guid.Empty; if (IsMaxMedicalTimes == 'Y') { @@ -127,15 +127,7 @@ namespace Shentun.Peis.CustomerOrgGroups - /// - /// 修改排序 相邻之间 - /// - /// 需要修改的ID - /// 目标ID - public async Task UpdateSortAsync(Guid id, Guid targetid) - { - await EntityHelper.UpdateSort(_repository, id, targetid); - } + /// /// 修改排序 置顶,置底 @@ -213,7 +205,7 @@ namespace Shentun.Peis.CustomerOrgGroups /// - /// 检查体检次数状态 如果已完成 就不能经行操作 + /// 检查体检次数状态 如果已完成 就不能进行操作 /// /// /// @@ -225,5 +217,20 @@ namespace Shentun.Peis.CustomerOrgGroups throw new UserFriendlyException("当前分组的体检次数已完成,无法操作!"); } } + + + /// + /// 检查单位状态是否可以使用 + /// + /// + /// + private async Task CheckCustomerOrgStatus(Guid CustomerOrgId) + { + var customerOrgEntity = await _customerOrgRepository.FirstOrDefaultAsync(f => f.Id == CustomerOrgId && (f.IsLock == 'Y' || f.IsActive == 'N')); + if (customerOrgEntity != null) + { + throw new UserFriendlyException("当前单位未启用或者已锁定,无法操作!"); + } + } } } diff --git a/src/Shentun.Peis.Domain/CustomerOrgRegisters/CustomerOrgRegisterManager.cs b/src/Shentun.Peis.Domain/CustomerOrgRegisters/CustomerOrgRegisterManager.cs index 831ec6e..42edb9d 100644 --- a/src/Shentun.Peis.Domain/CustomerOrgRegisters/CustomerOrgRegisterManager.cs +++ b/src/Shentun.Peis.Domain/CustomerOrgRegisters/CustomerOrgRegisterManager.cs @@ -24,6 +24,7 @@ namespace Shentun.Peis.CustomerOrgRegisters private readonly IRepository _repository; private readonly IRepository _customerOrgRepository; private readonly IRepository _customerOrgGroupRepository; + private readonly IRepository _patientRegisterRepository; private readonly CustomerOrgGroupManager _customerOrgGroupManager; public CustomerOrgRegisterManager( @@ -31,12 +32,14 @@ namespace Shentun.Peis.CustomerOrgRegisters IRepository customerOrgRepository, IRepository customerOrgGroupRepository, CustomerOrgGroupManager customerOrgGroupManager - ) +, + IRepository patientRegisterRepository) { _repository = repository; this._customerOrgRepository = customerOrgRepository; this._customerOrgGroupRepository = customerOrgGroupRepository; this._customerOrgGroupManager = customerOrgGroupManager; + this._patientRegisterRepository = patientRegisterRepository; } /// /// 创建 @@ -136,7 +139,8 @@ namespace Shentun.Peis.CustomerOrgRegisters RegisterNo = "" }; - return await _repository.InsertAsync(entity); + return entity; + // return await _repository.InsertAsync(entity); } /// @@ -184,13 +188,23 @@ namespace Shentun.Peis.CustomerOrgRegisters public async Task CheckAndDeleteAsync(Guid id) { var customerOrgRegisterEnt = await _repository.FirstOrDefaultAsync(m => m.Id == id); + + if (customerOrgRegisterEnt != null) { + + var patientRegisterEntity =await _patientRegisterRepository.FirstOrDefaultAsync(m => m.CustomerOrgRegisterId == id); + if (patientRegisterEntity != null) + { + throw new UserFriendlyException($"单位体检次数\"{customerOrgRegisterEnt.MedicalTimes}\"已被{patientRegisterEntity.PatientName}登记使用,不能删除"); + } + if (customerOrgRegisterEnt.IsComplete == 'Y') { throw new UserFriendlyException($"单位体检次数\"{customerOrgRegisterEnt.MedicalTimes}\"已完成,不能删除"); } + var customerOrgGroups = await _customerOrgGroupRepository.GetListAsync(m => m.CustomerOrgRegisterId == id); if (customerOrgGroups.Any()) diff --git a/src/Shentun.Peis.Domain/CustomerOrgTypes/CustomerOrgTypeManager.cs b/src/Shentun.Peis.Domain/CustomerOrgTypes/CustomerOrgTypeManager.cs index 7cb1820..407cfe8 100644 --- a/src/Shentun.Peis.Domain/CustomerOrgTypes/CustomerOrgTypeManager.cs +++ b/src/Shentun.Peis.Domain/CustomerOrgTypes/CustomerOrgTypeManager.cs @@ -69,15 +69,7 @@ namespace Shentun.Peis.CustomerOrgTypes } - /// - /// 修改排序 相邻之间 - /// - /// 需要修改的ID - /// 目标ID - public async Task UpdateSortAsync(Guid id, Guid targetid) - { - await EntityHelper.UpdateSort(_repository, id, targetid); - } + /// /// 修改排序 置顶,置底