From 6318c09946206eead73a5416d599746734b8b0f8 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 8 Apr 2022 13:44:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E7=B1=BB=E5=9E=8B=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Document/TrialDocumentService.cs | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index ed0143d74..cb215cdce 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -27,7 +27,7 @@ namespace IRaCIS.Core.Application.Services private readonly IRepository _systemDocumentRepository; public TrialDocumentService(IWebHostEnvironment hostEnvironment, IRepository trialDocumentRepository - , IRepository systemDocConfirmedUserRepository,IRepository systemDocumentRepository) + , IRepository systemDocConfirmedUserRepository, IRepository systemDocumentRepository) { _hostEnvironment = hostEnvironment; _trialDocumentRepository = trialDocumentRepository; @@ -46,7 +46,7 @@ namespace IRaCIS.Core.Application.Services var trialDocumentQueryable = _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == queryTrialDocument.TrialId) .WhereIf(!string.IsNullOrEmpty(queryTrialDocument.Name), t => t.Name.Contains(queryTrialDocument.Name)) - .WhereIf(queryTrialDocument.FileTypeId!=null, t => t.FileTypeId==queryTrialDocument.FileTypeId) + .WhereIf(queryTrialDocument.FileTypeId != null, t => t.FileTypeId == queryTrialDocument.FileTypeId) .ProjectTo(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken }); return await trialDocumentQueryable.ToPagedListAsync(queryTrialDocument.PageIndex, queryTrialDocument.PageSize, queryTrialDocument.SortField, queryTrialDocument.Asc); @@ -144,6 +144,7 @@ namespace IRaCIS.Core.Application.Services SignViewMinimumMinutes = needConfirmedUserType.SystemDocument.SignViewMinimumMinutes, Name = needConfirmedUserType.SystemDocument.Name, Path = needConfirmedUserType.SystemDocument.Path, + FileTypeId = needConfirmedUserType.SystemDocument.FileTypeId, FileType = needConfirmedUserType.SystemDocument.FileType.Value, UpdateTime = needConfirmedUserType.SystemDocument.UpdateTime, @@ -174,6 +175,7 @@ namespace IRaCIS.Core.Application.Services IsDeleted = trialDoc.IsDeleted, Name = trialDoc.Name, Path = trialDoc.Path, + FileTypeId = trialDoc.FileTypeId, FileType = trialDoc.FileType.Value, UpdateTime = trialDoc.UpdateTime, SignViewMinimumMinutes = trialDoc.SignViewMinimumMinutes, @@ -190,7 +192,7 @@ namespace IRaCIS.Core.Application.Services var unionQuery = systemDocumentQueryable.Union(trialDocQueryable) .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) - .WhereIf(querySystemDocument.FileTypeId!=null, t => t.FileTypeId==querySystemDocument.FileTypeId); + .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId); return await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc); } @@ -290,8 +292,7 @@ namespace IRaCIS.Core.Application.Services var trialFininshedTime = await _repository.Where(t => t.Id == querySystemDocument.TrialId).Select(t => t.TrialFinishedTime).FirstOrDefaultAsync(); var trialDocQuery = from trialDocumentNeedConfirmedUserType in _repository.Where(t => t.TrialDocument.TrialId == querySystemDocument.TrialId) - //.Where(t => t.TrialDocument.Trial.TrialUserList.Any(cc => cc.User.UserTypeId == t.NeedConfirmUserTypeId)) - join trialUser in _repository.Where(t => t.TrialId == querySystemDocument.TrialId) + join trialUser in _repository.Where(t => t.TrialId == querySystemDocument.TrialId) .WhereIf(querySystemDocument.UserId != null, t => t.UserId == querySystemDocument.UserId) .WhereIf(querySystemDocument.UserTypeId != null, t => t.User.UserTypeId == querySystemDocument.UserTypeId) on trialDocumentNeedConfirmedUserType.NeedConfirmUserTypeId equals trialUser.User.UserTypeId @@ -309,6 +310,7 @@ namespace IRaCIS.Core.Application.Services SignViewMinimumMinutes = trialDocumentNeedConfirmedUserType.TrialDocument.SignViewMinimumMinutes, Name = trialDocumentNeedConfirmedUserType.TrialDocument.Name, Path = trialDocumentNeedConfirmedUserType.TrialDocument.Path, + FileTypeId = trialDocumentNeedConfirmedUserType.TrialDocument.FileTypeId, FileType = trialDocumentNeedConfirmedUserType.TrialDocument.FileType.Value, UpdateTime = trialDocumentNeedConfirmedUserType.TrialDocument.UpdateTime, @@ -343,6 +345,7 @@ namespace IRaCIS.Core.Application.Services Name = needConfirmEdUserType.SystemDocument.Name, Path = needConfirmEdUserType.SystemDocument.Path, FileType = needConfirmEdUserType.SystemDocument.FileType.Value, + FileTypeId = needConfirmEdUserType.SystemDocument.FileTypeId, UpdateTime = needConfirmEdUserType.SystemDocument.UpdateTime, @@ -357,7 +360,7 @@ namespace IRaCIS.Core.Application.Services var unionQuery = trialDocQuery.Union(systemDocQuery) .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) - .WhereIf(querySystemDocument.FileTypeId!=null, t => t.FileTypeId==querySystemDocument.FileTypeId); + .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId); return await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc); } @@ -383,11 +386,13 @@ namespace IRaCIS.Core.Application.Services /// /// [HttpGet("{trialId:guid}")] - public async Task> GetTrialDocAndSystemDocType(Guid trialId) + public async Task GetTrialDocAndSystemDocType(Guid trialId) { - return await _trialDocumentRepository.Where(t => t.TrialId == trialId).Select(t => t.FileType.Value) - .Union(_repository.GetQueryable().Select(t => t.FileType.Value)).Distinct() - .ToListAsync(); + var result = await _trialDocumentRepository.Where(t => t.TrialId == trialId).Select(t => new { FileType = t.FileType.Value, t.FileTypeId }) + .Union(_systemDocumentRepository.Select(t => new { FileType = t.FileType.Value, t.FileTypeId })) + .ToListAsync(); + + return ResponseOutput.Ok(result); } public async Task AddOrUpdateTrialDocument(AddOrEditTrialDocument addOrEditTrialDocument) @@ -397,7 +402,7 @@ namespace IRaCIS.Core.Application.Services var entity = _mapper.Map(addOrEditTrialDocument); - if (await _trialDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditTrialDocument.FileTypeId && t.Name == addOrEditTrialDocument.Name && t.TrialId == addOrEditTrialDocument.TrialId,true)) + if (await _trialDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditTrialDocument.FileTypeId && t.Name == addOrEditTrialDocument.Name && t.TrialId == addOrEditTrialDocument.TrialId, true)) { return ResponseOutput.NotOk("同类型已存在该文件名"); } @@ -407,7 +412,7 @@ namespace IRaCIS.Core.Application.Services } else { - if (await _trialDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditTrialDocument.FileTypeId && t.Name == addOrEditTrialDocument.Name && t.Id != addOrEditTrialDocument.Id && t.TrialId == addOrEditTrialDocument.TrialId,true)) + if (await _trialDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditTrialDocument.FileTypeId && t.Name == addOrEditTrialDocument.Name && t.Id != addOrEditTrialDocument.Id && t.TrialId == addOrEditTrialDocument.TrialId, true)) { return ResponseOutput.NotOk("同类型已存在该文件名"); } @@ -489,7 +494,7 @@ namespace IRaCIS.Core.Application.Services } - success= await _repository.SaveChangesAsync(); + success = await _repository.SaveChangesAsync(); return ResponseOutput.Result(success); } @@ -497,7 +502,7 @@ namespace IRaCIS.Core.Application.Services /// /// 用户 签名某个文档 /// - + /// public async Task UserConfirm(UserConfirmCommand userConfirmCommand) { @@ -519,7 +524,7 @@ namespace IRaCIS.Core.Application.Services { return ResponseOutput.NotOk("该文档已经签名"); } - if (!await _systemDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId) || await _trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId && t.IsDeleted,true)) + if (!await _systemDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId) || await _trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId && t.IsDeleted, true)) { return ResponseOutput.NotOk("文件已删除或者废除,签署失败!"); } @@ -533,7 +538,7 @@ namespace IRaCIS.Core.Application.Services return ResponseOutput.NotOk("该文档已经签名"); } - if (!await _trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId) || await _repository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId && t.IsDeleted,true)) + if (!await _trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId) || await _repository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId && t.IsDeleted, true)) { return ResponseOutput.NotOk("文件已删除或者废除,签署失败!"); } @@ -645,7 +650,7 @@ namespace IRaCIS.Core.Application.Services var unionQuery = systemDocumentQueryable.Union(trialDocQueryable) .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) - .WhereIf(querySystemDocument.FileTypeId!=null, t => t.FileTypeId==querySystemDocument.FileTypeId); + .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId); return unionQuery.ToPagedList(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc); }