文档类型处理
parent
3273ad590e
commit
6318c09946
|
@ -27,7 +27,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
private readonly IRepository<SystemDocument> _systemDocumentRepository;
|
||||
|
||||
public TrialDocumentService(IWebHostEnvironment hostEnvironment, IRepository<TrialDocument> trialDocumentRepository
|
||||
, IRepository<SystemDocConfirmedUser> systemDocConfirmedUserRepository,IRepository<SystemDocument> systemDocumentRepository)
|
||||
, IRepository<SystemDocConfirmedUser> systemDocConfirmedUserRepository, IRepository<SystemDocument> 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<TrialDocumentView>(_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<Trial>(t => t.Id == querySystemDocument.TrialId).Select(t => t.TrialFinishedTime).FirstOrDefaultAsync();
|
||||
|
||||
var trialDocQuery = from trialDocumentNeedConfirmedUserType in _repository.Where<TrialDocNeedConfirmedUserType>(t => t.TrialDocument.TrialId == querySystemDocument.TrialId)
|
||||
//.Where(t => t.TrialDocument.Trial.TrialUserList.Any(cc => cc.User.UserTypeId == t.NeedConfirmUserTypeId))
|
||||
join trialUser in _repository.Where<TrialUser>(t => t.TrialId == querySystemDocument.TrialId)
|
||||
join trialUser in _repository.Where<TrialUser>(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
|
|||
/// <param name="trialId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{trialId:guid}")]
|
||||
public async Task<List<string>> GetTrialDocAndSystemDocType(Guid trialId)
|
||||
public async Task<IResponseOutput> GetTrialDocAndSystemDocType(Guid trialId)
|
||||
{
|
||||
return await _trialDocumentRepository.Where(t => t.TrialId == trialId).Select(t => t.FileType.Value)
|
||||
.Union(_repository.GetQueryable<SystemDocument>().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<IResponseOutput> AddOrUpdateTrialDocument(AddOrEditTrialDocument addOrEditTrialDocument)
|
||||
|
@ -397,7 +402,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
var entity = _mapper.Map<TrialDocument>(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
|
|||
/// <summary>
|
||||
/// 用户 签名某个文档
|
||||
/// </summary>
|
||||
|
||||
|
||||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> 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<TrialDocument>(t => t.Id == userConfirmCommand.DocumentId && t.IsDeleted,true))
|
||||
if (!await _trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId) || await _repository.AnyAsync<TrialDocument>(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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue