IsAbandon->IsDeleted

Uat_Study
hang 2022-04-08 10:41:15 +08:00
parent 10bc94f9fd
commit 7aa3d7acdf
15 changed files with 159 additions and 107 deletions

View File

@ -1519,7 +1519,7 @@
</member>
<member name="M:IRaCIS.Core.Application.PersonalWorkstation.GetSiteSurveyApprovalList(IRaCIS.Core.Application.Contracts.TrialSiteSurveyStatQuery)">
<summary>
Site 调研 每个项目 处理任务数
Site 调研 每个项目 需要处理的审批统计
</summary>
<param name="query"></param>
<returns></returns>

View File

@ -29,6 +29,8 @@ namespace IRaCIS.Core.Application.Contracts
public bool IsSystemDoc { get; set; }
public string FileType { get; set; } = string.Empty;
}
@ -89,7 +91,7 @@ namespace IRaCIS.Core.Application.Contracts
public Guid? SystemDocumentId { get; set; }
public string Type { get; set; } = string.Empty;
public Guid? FileTypeId { get; set; }
public string Name { get; set; } = string.Empty;
@ -101,7 +103,7 @@ namespace IRaCIS.Core.Application.Contracts
[NotDefault]
public Guid TrialId { get; set; }
public string Type { get; set; } = string.Empty;
public Guid? FileTypeId { get; set; }
public string Name { get; set; } = string.Empty;
@ -139,11 +141,11 @@ namespace IRaCIS.Core.Application.Contracts
public class SystemDocumentAddOrEdit
{
public Guid? Id { get; set; }
public string Type { get; set; } = string.Empty;
public Guid FileTypeId { get; set; }
public string Name { get; set; } = string.Empty;
public string Path { get; set; } = string.Empty;
public bool IsAbandon { get; set; }
public bool IsDeleted { get; set; }
public int SignViewMinimumMinutes { get; set; }

View File

@ -31,8 +31,8 @@ namespace IRaCIS.Core.Application.Contracts
///<summary>TrialDocumentQuery 列表查询参数模型</summary>
public class TrialDocumentQuery : PageInput
{
public string Type { get; set; } = String.Empty;
public Guid? FileTypeId { get; set; }
public string Name { get; set; } = String.Empty;
@ -47,12 +47,12 @@ namespace IRaCIS.Core.Application.Contracts
public Guid? Id { get; set; }
public Guid TrialId { get; set; }
public string Type { get; set; } = String.Empty;
public Guid FileTypeId { get; set; }
public string Name { get; set; } = String.Empty;
public string Path { get; set; } = String.Empty;
public string Description { get; set; } = String.Empty;
public bool IsAbandon { get; set; }
public bool IsDeleted { get; set; }
public int SignViewMinimumMinutes { get; set; }

View File

@ -39,9 +39,9 @@ namespace IRaCIS.Core.Application.Services
[HttpPost]
public async Task<PageOutput<SystemDocumentView>> GetSystemDocumentListAsync(SystemDocumentQuery querySystemDocument)
{
var systemDocumentQueryable = _systemDocumentRepository
var systemDocumentQueryable = _systemDocumentRepository.AsQueryable(true)
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Type), t => t.Type.Contains(querySystemDocument.Type))
.WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId)
.ProjectTo<SystemDocumentView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken, userId = _userInfo.Id });
return await systemDocumentQueryable.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
@ -54,7 +54,7 @@ namespace IRaCIS.Core.Application.Services
var entity = _mapper.Map<SystemDocument>(addOrEditSystemDocument);
if (await _systemDocumentRepository.AnyAsync(t => t.Type == addOrEditSystemDocument.Type && t.Name == addOrEditSystemDocument.Name))
if (await _systemDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditSystemDocument.FileTypeId && t.Name == addOrEditSystemDocument.Name,true))
{
return ResponseOutput.NotOk("同类型已存在该文件名");
}
@ -66,24 +66,24 @@ namespace IRaCIS.Core.Application.Services
}
else
{
var document = await _systemDocumentRepository.Where(t => t.Id == addOrEditSystemDocument.Id, true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefaultAsync();
var document = await _systemDocumentRepository.Where(t => t.Id == addOrEditSystemDocument.Id, true,true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefaultAsync();
if (document == null) return Null404NotFound(document);
if (await _systemDocumentRepository.AnyAsync(t => t.Type == addOrEditSystemDocument.Type && t.Name == addOrEditSystemDocument.Name && t.Id != addOrEditSystemDocument.Id))
if (await _systemDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditSystemDocument.FileTypeId && t.Name == addOrEditSystemDocument.Name && t.Id != addOrEditSystemDocument.Id,true))
{
return ResponseOutput.NotOk("同类型已存在该文件名");
}
var dbDocumentType = document.Type;
_mapper.Map(addOrEditSystemDocument, document);
if (dbDocumentType != addOrEditSystemDocument.Type)
if (document.FileTypeId != addOrEditSystemDocument.FileTypeId)
{
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
var beforeFilePath = Path.Combine(rootPath, document.Path);
document.Path = document.Path.Replace(dbDocumentType, addOrEditSystemDocument.Type);
document.Path = document.Path.Replace(document.FileTypeId.ToString(), addOrEditSystemDocument.FileTypeId.ToString());
var nowPath = Path.Combine(rootPath, document.Path);
@ -128,7 +128,7 @@ namespace IRaCIS.Core.Application.Services
{
var query = from sysDoc in _systemDocumentRepository.Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
var query = from sysDoc in _systemDocumentRepository.Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId),true)
join confirm in _repository.GetQueryable<SystemDocConfirmedUser>() on new { ConfirmUserId = _userInfo.Id, SystemDocumentId = sysDoc.Id } equals new { confirm.ConfirmUserId, confirm.SystemDocumentId } into cc
from confirm in cc.DefaultIfEmpty()
@ -141,11 +141,11 @@ namespace IRaCIS.Core.Application.Services
Id = sysDoc.Id,
CreateTime = sysDoc.CreateTime,
IsAbandon = sysDoc.IsAbandon,
IsDeleted = sysDoc.IsDeleted,
SignViewMinimumMinutes = sysDoc.SignViewMinimumMinutes,
Name = sysDoc.Name,
Path = sysDoc.Path,
Type = sysDoc.Type,
FileType = sysDoc.FileType.Value,
UpdateTime = sysDoc.UpdateTime,
FullFilePath = sysDoc.Path + "?access_token=" + _userInfo.UserToken,

View File

@ -24,13 +24,15 @@ namespace IRaCIS.Core.Application.Services
private readonly IWebHostEnvironment _hostEnvironment;
private readonly IRepository<TrialDocument> _trialDocumentRepository;
private readonly IRepository<SystemDocConfirmedUser> _systemDocConfirmedUserRepository;
private readonly IRepository<SystemDocument> _systemDocumentRepository;
public TrialDocumentService(IWebHostEnvironment hostEnvironment, IRepository<TrialDocument> trialDocumentRepository
, IRepository<SystemDocConfirmedUser> systemDocConfirmedUserRepository)
, IRepository<SystemDocConfirmedUser> systemDocConfirmedUserRepository,IRepository<SystemDocument> systemDocumentRepository)
{
_hostEnvironment = hostEnvironment;
this._trialDocumentRepository = trialDocumentRepository;
this._systemDocConfirmedUserRepository = systemDocConfirmedUserRepository;
_trialDocumentRepository = trialDocumentRepository;
_systemDocConfirmedUserRepository = systemDocConfirmedUserRepository;
_systemDocumentRepository = systemDocumentRepository;
}
/// <summary>
@ -42,9 +44,9 @@ namespace IRaCIS.Core.Application.Services
public async Task<PageOutput<TrialDocumentView>> GetTrialDocumentList(TrialDocumentQuery queryTrialDocument)
{
var trialDocumentQueryable = _trialDocumentRepository.Where(t => t.TrialId == queryTrialDocument.TrialId)
var trialDocumentQueryable = _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == queryTrialDocument.TrialId)
.WhereIf(!string.IsNullOrEmpty(queryTrialDocument.Name), t => t.Name.Contains(queryTrialDocument.Name))
.WhereIf(!string.IsNullOrEmpty(queryTrialDocument.Type), t => t.Type.Contains(queryTrialDocument.Type))
.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);
@ -126,7 +128,7 @@ namespace IRaCIS.Core.Application.Services
var systemDocumentQueryable = from needConfirmedUserType in _repository.Where<SystemDocNeedConfirmedUserType>(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)
//.Where(u => u.UserTypeRole.UserList.SelectMany(cc => cc.UserTrials.Where(t => t.TrialId == querySystemDocument.TrialId)).Any(e => e.Trial.TrialFinishedTime < u.SystemDocument.CreateTime))
.WhereIf(trialFininshedTime != null, u => u.SystemDocument.CreateTime < trialFininshedTime)
.WhereIf(!_userInfo.IsAdmin, t => t.SystemDocument.IsAbandon == false || (t.SystemDocument.IsAbandon == true && t.SystemDocument.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
.WhereIf(!_userInfo.IsAdmin, t => t.SystemDocument.IsDeleted == false || (t.SystemDocument.IsDeleted == true && t.SystemDocument.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
join trialUser in _repository.Where<TrialUser>(t => t.TrialId == querySystemDocument.TrialId && t.UserId == _userInfo.Id)
on needConfirmedUserType.NeedConfirmUserTypeId equals trialUser.User.UserTypeId
@ -138,11 +140,11 @@ namespace IRaCIS.Core.Application.Services
Id = needConfirmedUserType.SystemDocument.Id,
CreateTime = needConfirmedUserType.SystemDocument.CreateTime,
IsAbandon = needConfirmedUserType.SystemDocument.IsAbandon,
IsDeleted = needConfirmedUserType.SystemDocument.IsDeleted,
SignViewMinimumMinutes = needConfirmedUserType.SystemDocument.SignViewMinimumMinutes,
Name = needConfirmedUserType.SystemDocument.Name,
Path = needConfirmedUserType.SystemDocument.Path,
Type = needConfirmedUserType.SystemDocument.Type,
FileType = needConfirmedUserType.SystemDocument.FileType.Value,
UpdateTime = needConfirmedUserType.SystemDocument.UpdateTime,
FullFilePath = needConfirmedUserType.SystemDocument.Path + "?access_token=" + _userInfo.UserToken,
@ -155,9 +157,9 @@ namespace IRaCIS.Core.Application.Services
};
//项目文档查询
var trialDocQueryable = from trialDoc in _trialDocumentRepository.Where(t => t.TrialId == querySystemDocument.TrialId)
var trialDocQueryable = from trialDoc in _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == querySystemDocument.TrialId)
.WhereIf(!_userInfo.IsAdmin, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
.WhereIf(!_userInfo.IsAdmin, t => t.IsAbandon == false || (t.IsAbandon == true && t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
.WhereIf(!_userInfo.IsAdmin, t => t.IsDeleted == false || (t.IsDeleted == true && t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
join trialUser in _repository.Where<TrialUser>(t => t.TrialId == querySystemDocument.TrialId && t.UserId == _userInfo.Id) on trialDoc.TrialId equals trialUser.TrialId
join confirm in _repository.Where<TrialDocUserTypeConfirmedUser>(t => t.TrialDocument.TrialId == querySystemDocument.TrialId) on
@ -169,10 +171,10 @@ namespace IRaCIS.Core.Application.Services
IsSystemDoc = false,
CreateTime = trialDoc.CreateTime,
FullFilePath = trialDoc.Path + "?access_token=" + _userInfo.UserToken,
IsAbandon = trialDoc.IsAbandon,
IsDeleted = trialDoc.IsDeleted,
Name = trialDoc.Name,
Path = trialDoc.Path,
Type = trialDoc.Type,
FileType = trialDoc.FileType.Value,
UpdateTime = trialDoc.UpdateTime,
SignViewMinimumMinutes = trialDoc.SignViewMinimumMinutes,
@ -188,7 +190,7 @@ namespace IRaCIS.Core.Application.Services
var unionQuery = systemDocumentQueryable.Union(trialDocQueryable)
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Type), t => t.Type.Contains(querySystemDocument.Type));
.WhereIf(querySystemDocument.FileTypeId!=null, t => t.FileTypeId==querySystemDocument.FileTypeId);
return await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
}
@ -208,7 +210,7 @@ namespace IRaCIS.Core.Application.Services
var systemDocumentQueryable = from needConfirmedUserType in _repository.Where<SystemDocNeedConfirmedUserType>(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)
//.Where(u => u.UserTypeRole.UserList.SelectMany(cc => cc.UserTrials.Where(t => t.TrialId == querySystemDocument.TrialId)).Any(e => e.Trial.TrialFinishedTime < u.SystemDocument.CreateTime))
.WhereIf(trialFininshedTime != null, u => u.SystemDocument.CreateTime < trialFininshedTime)
.WhereIf(!_userInfo.IsAdmin, t => t.SystemDocument.IsAbandon == false || (t.SystemDocument.IsAbandon == true && t.SystemDocument.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
.WhereIf(!_userInfo.IsAdmin, t => t.SystemDocument.IsDeleted == false || (t.SystemDocument.IsDeleted == true && t.SystemDocument.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
join trialUser in _repository.Where<TrialUser>(t => t.TrialId == trialId && t.UserId == _userInfo.Id)
on needConfirmedUserType.NeedConfirmUserTypeId equals trialUser.User.UserTypeId
@ -223,7 +225,7 @@ namespace IRaCIS.Core.Application.Services
//项目文档查询
var trialDocQueryable = from trialDoc in _trialDocumentRepository.Where(t => t.TrialId == trialId)
.WhereIf(!_userInfo.IsAdmin, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
.WhereIf(!_userInfo.IsAdmin, t => t.IsAbandon == false || (t.IsAbandon == true && t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
.WhereIf(!_userInfo.IsAdmin, t => t.IsDeleted == false || (t.IsDeleted == true && t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
join trialUser in _repository.Where<TrialUser>(t => t.TrialId == trialId && t.UserId == _userInfo.Id) on trialDoc.TrialId equals trialUser.TrialId
join confirm in _repository.Where<TrialDocUserTypeConfirmedUser>(t => t.TrialDocument.TrialId == trialId) on
@ -303,11 +305,11 @@ namespace IRaCIS.Core.Application.Services
Id = trialDocumentNeedConfirmedUserType.TrialDocument.Id,
CreateTime = trialDocumentNeedConfirmedUserType.TrialDocument.CreateTime,
IsAbandon = trialDocumentNeedConfirmedUserType.TrialDocument.IsAbandon,
IsDeleted = trialDocumentNeedConfirmedUserType.TrialDocument.IsDeleted,
SignViewMinimumMinutes = trialDocumentNeedConfirmedUserType.TrialDocument.SignViewMinimumMinutes,
Name = trialDocumentNeedConfirmedUserType.TrialDocument.Name,
Path = trialDocumentNeedConfirmedUserType.TrialDocument.Path,
Type = trialDocumentNeedConfirmedUserType.TrialDocument.Type,
FileType = trialDocumentNeedConfirmedUserType.TrialDocument.FileType.Value,
UpdateTime = trialDocumentNeedConfirmedUserType.TrialDocument.UpdateTime,
@ -336,11 +338,11 @@ namespace IRaCIS.Core.Application.Services
Id = needConfirmEdUserType.SystemDocument.Id,
CreateTime = needConfirmEdUserType.SystemDocument.CreateTime,
IsAbandon = needConfirmEdUserType.SystemDocument.IsAbandon,
IsDeleted = needConfirmEdUserType.SystemDocument.IsDeleted,
SignViewMinimumMinutes = needConfirmEdUserType.SystemDocument.SignViewMinimumMinutes,
Name = needConfirmEdUserType.SystemDocument.Name,
Path = needConfirmEdUserType.SystemDocument.Path,
Type = needConfirmEdUserType.SystemDocument.Type,
FileType = needConfirmEdUserType.SystemDocument.FileType.Value,
UpdateTime = needConfirmEdUserType.SystemDocument.UpdateTime,
@ -355,7 +357,7 @@ namespace IRaCIS.Core.Application.Services
var unionQuery = trialDocQuery.Union(systemDocQuery)
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Type), t => t.Type.Contains(querySystemDocument.Type));
.WhereIf(querySystemDocument.FileTypeId!=null, t => t.FileTypeId==querySystemDocument.FileTypeId);
return await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
}
@ -383,8 +385,8 @@ namespace IRaCIS.Core.Application.Services
[HttpGet("{trialId:guid}")]
public async Task<List<string>> GetTrialDocAndSystemDocType(Guid trialId)
{
return await _trialDocumentRepository.Where(t => t.TrialId == trialId).Select(t => t.Type)
.Union(_repository.GetQueryable<SystemDocument>().Select(t => t.Type)).Distinct()
return await _trialDocumentRepository.Where(t => t.TrialId == trialId).Select(t => t.FileType.Value)
.Union(_repository.GetQueryable<SystemDocument>().Select(t => t.FileType.Value)).Distinct()
.ToListAsync();
}
@ -395,7 +397,7 @@ namespace IRaCIS.Core.Application.Services
var entity = _mapper.Map<TrialDocument>(addOrEditTrialDocument);
if (await _trialDocumentRepository.AnyAsync(t => t.Type == addOrEditTrialDocument.Type && t.Name == addOrEditTrialDocument.Name && t.TrialId == addOrEditTrialDocument.TrialId))
if (await _trialDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditTrialDocument.FileTypeId && t.Name == addOrEditTrialDocument.Name && t.TrialId == addOrEditTrialDocument.TrialId,true))
{
return ResponseOutput.NotOk("同类型已存在该文件名");
}
@ -405,7 +407,7 @@ namespace IRaCIS.Core.Application.Services
}
else
{
if (await _trialDocumentRepository.AnyAsync(t => t.Type == addOrEditTrialDocument.Type && t.Name == addOrEditTrialDocument.Name && t.Id != addOrEditTrialDocument.Id && t.TrialId == addOrEditTrialDocument.TrialId))
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("同类型已存在该文件名");
}
@ -414,18 +416,18 @@ namespace IRaCIS.Core.Application.Services
if (document == null) return Null404NotFound(document);
var dbDocumentType = document.Type;
//var dbDocumentType = document.Type;
_mapper.Map(addOrEditTrialDocument, document);
if (dbDocumentType != addOrEditTrialDocument.Type)
if (document.FileTypeId != addOrEditTrialDocument.FileTypeId)
{
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
var beforeFilePath = Path.Combine(rootPath, document.Path);
document.Path = document.Path.Replace(dbDocumentType, addOrEditTrialDocument.Type);
document.Path = document.Path.Replace(document.FileTypeId.ToString(), addOrEditTrialDocument.FileTypeId.ToString());
var nowPath = Path.Combine(rootPath, document.Path);
@ -453,7 +455,7 @@ namespace IRaCIS.Core.Application.Services
[HttpDelete("{trialId:guid}/{trialDocumentId:guid}")]
public async Task<IResponseOutput> DeleteTrialDocument(Guid trialDocumentId, Guid trialId)
{
if (await _trialDocumentRepository.Where(t => t.Id == trialDocumentId).AnyAsync(t => t.TrialDocConfirmedUserList.Any()))
if (await _trialDocumentRepository.AsQueryable(true).Where(t => t.Id == trialDocumentId).AnyAsync(t => t.TrialDocConfirmedUserList.Any()))
{
return ResponseOutput.NotOk("该文档,已有用户签名 不允许删除");
}
@ -479,14 +481,12 @@ namespace IRaCIS.Core.Application.Services
if (isSystemDoc)
{
await _repository.AddAsync(new SystemDocConfirmedUser() { SystemDocumentId = documentId, SignFirstViewTime = DateTime.Now });
//success = await _repository.UpdateFromQueryAsync<SystemDocConfirmedUser>(t => t.Id == documentId, d => new SystemDocConfirmedUser() { SignFirstViewTime = DateTime.Now });
}
else
{
await _repository.AddAsync(new TrialDocUserTypeConfirmedUser() { TrialDocumentId = documentId, SignFirstViewTime = DateTime.Now });
//success = await _repository.UpdateFromQueryAsync<TrialDocUserTypeConfirmedUser>(t => t.Id == documentId , d => new TrialDocUserTypeConfirmedUser() { SignFirstViewTime = DateTime.Now });
}
success= await _repository.SaveChangesAsync();
@ -519,7 +519,7 @@ namespace IRaCIS.Core.Application.Services
{
return ResponseOutput.NotOk("该文档已经签名");
}
if (!await _repository.AnyAsync<SystemDocument>(t => t.Id == userConfirmCommand.DocumentId) || await _trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId && t.IsAbandon))
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 +533,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.IsAbandon))
if (!await _trialDocumentRepository.AnyAsync(t => t.Id == userConfirmCommand.DocumentId) || await _repository.AnyAsync<TrialDocument>(t => t.Id == userConfirmCommand.DocumentId && t.IsDeleted,true))
{
return ResponseOutput.NotOk("文件已删除或者废除,签署失败!");
}
@ -558,11 +558,11 @@ namespace IRaCIS.Core.Application.Services
{
if (isSystemDoc)
{
await _repository.UpdateFromQueryAsync<SystemDocument>(t => t.Id == documentId, u => new SystemDocument() { IsAbandon = true });
await _repository.UpdateFromQueryAsync<SystemDocument>(t => t.Id == documentId, u => new SystemDocument() { IsDeleted = true });
}
else
{
await _trialDocumentRepository.UpdateFromQueryAsync(t => t.Id == documentId, u => new TrialDocument() { IsAbandon = true });
await _trialDocumentRepository.UpdateFromQueryAsync(t => t.Id == documentId, u => new TrialDocument() { IsDeleted = true });
}
return ResponseOutput.Ok();
}
@ -606,17 +606,17 @@ namespace IRaCIS.Core.Application.Services
public PageOutput<DocumentUnionWithUserStatView> GetTrialSystemDocumentList(DocumentTrialUnionQuery querySystemDocument)
{
var systemDocumentQueryable = _repository
.WhereIf<SystemDocument>(!_userInfo.IsAdmin, t => t.IsAbandon == false)
.WhereIf<SystemDocument>(!_userInfo.IsAdmin, t => t.IsDeleted == false)
.Select(t => new DocumentUnionWithUserStatView()
{
Id = t.Id,
IsSystemDoc = true,
CreateTime = t.CreateTime,
FullFilePath = t.Path + "?access_token=" + _userInfo.UserToken,
IsAbandon = t.IsAbandon,
IsDeleted = t.IsDeleted,
Name = t.Name,
Path = t.Path,
Type = t.Type,
FileType = t.FileType.Value,
UpdateTime = t.UpdateTime,
SignViewMinimumMinutes = t.SignViewMinimumMinutes,
DocumentConfirmedUserCount = t.SystemDocConfirmedUserList.Count(),
@ -631,10 +631,10 @@ namespace IRaCIS.Core.Application.Services
IsSystemDoc = false,
CreateTime = t.CreateTime,
FullFilePath = t.Path + "?access_token=" + _userInfo.UserToken,
IsAbandon = t.IsAbandon,
IsDeleted = t.IsDeleted,
Name = t.Name,
Path = t.Path,
Type = t.Type,
FileType = t.FileType.Value,
UpdateTime = t.UpdateTime,
SignViewMinimumMinutes = t.SignViewMinimumMinutes,
@ -645,7 +645,7 @@ namespace IRaCIS.Core.Application.Services
var unionQuery = systemDocumentQueryable.Union(trialDocQueryable)
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Type), t => t.Type.Contains(querySystemDocument.Type));
.WhereIf(querySystemDocument.FileTypeId!=null, t => t.FileTypeId==querySystemDocument.FileTypeId);
return unionQuery.ToPagedList(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
}

View File

@ -96,7 +96,7 @@ namespace IRaCIS.Core.Application.Contracts
public string TrialSiteAliasName { get; set; } = String.Empty;
public string SiteName { get; set; } = string.Empty;
public bool IsAbandon { get; set; }
public bool IsDeleted { get; set; }
public Guid Id { get; set; }
public Guid TrialId { get; set; }
public Guid SiteId { get; set; }
@ -255,7 +255,7 @@ namespace IRaCIS.Core.Application.Contracts
public TrialSiteSurveyEnum? State { get; set; }
public bool? IsAbandon { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? UpdateTimeBegin { get; set; }

View File

@ -364,7 +364,7 @@ namespace IRaCIS.Core.Application.Contracts
{
var trialSiteSurveyQueryable = _trialSiteSurveyRepository.Where(t => t.TrialId == surveyQueryDTO.TrialId).IgnoreQueryFilters()
.WhereIf(surveyQueryDTO.SiteId != null, t => t.SiteId == surveyQueryDTO.SiteId)
.WhereIf(surveyQueryDTO.IsAbandon != null, t => t.IsAbandon == surveyQueryDTO.IsAbandon)
.WhereIf(surveyQueryDTO.IsDeleted != null, t => t.IsDeleted == surveyQueryDTO.IsDeleted)
.WhereIf(!string.IsNullOrWhiteSpace(surveyQueryDTO.UserKeyInfo), t => t.UserName.Contains(surveyQueryDTO.UserKeyInfo) || t.Phone.Contains(surveyQueryDTO.UserKeyInfo) || t.Email.Contains(surveyQueryDTO.UserKeyInfo))
.WhereIf(surveyQueryDTO.State != null, t => t.State == surveyQueryDTO.State)
.WhereIf(surveyQueryDTO.UpdateTimeBegin != null, t => t.UpdateTime >= surveyQueryDTO.UpdateTimeBegin)
@ -385,7 +385,7 @@ namespace IRaCIS.Core.Application.Contracts
var groupSelectIdQuery =
_trialSiteSurveyRepository.Where(t => t.TrialId == queryParam.TrialId && t.IsAbandon == false)
_trialSiteSurveyRepository.Where(t => t.TrialId == queryParam.TrialId)
.WhereIf(queryParam.SiteId != null, t => t.SiteId == queryParam.SiteId)
.WhereIf(!string.IsNullOrEmpty(queryParam.FormWriterKeyInfo), t => (t.UserName).Contains(queryParam.FormWriterKeyInfo) || t.Email.Contains(queryParam.FormWriterKeyInfo) || t.Phone.Contains(queryParam.FormWriterKeyInfo))
.GroupBy(t => t.SiteId)
@ -624,14 +624,14 @@ namespace IRaCIS.Core.Application.Contracts
[HttpPut("{trialId:guid}/{trialSiteSurveyId:guid}")]
public async Task<IResponseOutput> AbandonSiteSurvey(Guid trialSiteSurveyId)
{
var survey = (await _trialSiteSurveyRepository.FirstOrDefaultAsync(t => t.Id == trialSiteSurveyId)).IfNullThrowConvertException();
var survey = (await _trialSiteSurveyRepository.FirstOrDefaultAsync(t => t.Id == trialSiteSurveyId,true)).IfNullThrowConvertException();
if (survey.State != TrialSiteSurveyEnum.ToSubmit)
{
return ResponseOutput.NotOk("只允许废除未提交的记录");
}
survey.IsAbandon = true;
survey.IsDeleted = true;
await _repository.SaveChangesAsync();

View File

@ -43,7 +43,7 @@ namespace IRaCIS.Core.Application
TotalNeedSignTrialDocCount = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin
? 0
: await _trialDocumentRepository
.Where(t => t.IsAbandon == false || (t.IsAbandon == true &&
.Where(t => t.IsDeleted == false || (t.IsDeleted == true &&
t.TrialDocConfirmedUserList.Any(t =>
t.ConfirmUserId == _userInfo.Id)))
.SelectMany(t => t.NeedConfirmedUserTypeList)
@ -60,7 +60,7 @@ namespace IRaCIS.Core.Application
TotalNeedSignSystemDocCount = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin
? 0
: await _systemDocumentRepository
.Where(t => t.IsAbandon == false || (t.IsAbandon == true && t.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
.Where(t => t.IsDeleted == false || (t.IsDeleted == true && t.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id)))
.SelectMany(t => t.NeedConfirmedUserTypeList)
.CountAsync(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId),
@ -78,7 +78,7 @@ namespace IRaCIS.Core.Application
/// <summary>
/// Site 调研 每个项目 处理任务数
/// Site 调研 每个项目 需要处理的审批统计
/// </summary>
/// <param name="query"></param>
/// <returns></returns>

View File

@ -76,7 +76,7 @@ namespace IRaCIS.Core.Application.Services
var data = await _trialRepository.Where(t => t.Id == trialId).IgnoreQueryFilters().ProjectTo<TrialSiteUserSummaryExportDto>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
var groupSelectIdQuery =
_trialSiteSurveyRepository.Where(t => t.TrialId == trialId && t.IsAbandon == false)
_trialSiteSurveyRepository.Where(t => t.TrialId == trialId && t.IsDeleted == false)
.GroupBy(t => t.SiteId)
.Select(g => g.OrderByDescending(u => u.CreateTime).Select(t => t.Id).First());

View File

@ -13,18 +13,22 @@ namespace IRaCIS.Core.Domain.Models
///SystemDocument
///</summary>
[Table("SystemDocument")]
public class SystemDocument : Entity, IAuditUpdate, IAuditAdd
public class SystemDocument : Entity, IAuditUpdate, IAuditAdd,ISoftDelete
{
public List<SystemDocConfirmedUser> SystemDocConfirmedUserList { get; set; }
public List<SystemDocNeedConfirmedUserType> NeedConfirmedUserTypeList { get; set; }
/// <summary>
/// Type
/// </summary>
[Required]
public string Type { get; set; } = string.Empty;
[ForeignKey("FileTypeId")]
public Dictionary FileType { get; set; }
public Guid FileTypeId { get; set; }
/// <summary>
/// Name
@ -33,7 +37,7 @@ namespace IRaCIS.Core.Domain.Models
public string Name { get; set; } = string.Empty;
public bool IsAbandon { get; set; }
public int SignViewMinimumMinutes { get; set; }
@ -66,11 +70,12 @@ namespace IRaCIS.Core.Domain.Models
/// </summary>
[Required]
public Guid UpdateUserId { get; set; }
public DateTime? DeletedTime { get; set; }
public bool IsDeleted { get; set; }
}
}
}

View File

@ -25,13 +25,14 @@ namespace IRaCIS.Core.Domain.Models
public Trial Trial { get; set; }
//public List<TrialUser> TrialUserList { get; set; }
[ForeignKey("FileTypeId")]
public Dictionary FileType { get; set; }
public Guid FileTypeId { get; set; }
/// <summary>
/// Type
/// </summary>
[Required]
public string Type { get; set; } = string.Empty;
/// <summary>
/// Name
@ -58,7 +59,6 @@ namespace IRaCIS.Core.Domain.Models
public string Description { get; set; } = string.Empty;
public bool IsAbandon { get; set; }
public int SignViewMinimumMinutes { get; set; }
@ -85,8 +85,11 @@ namespace IRaCIS.Core.Domain.Models
/// </summary>
[Required]
public Guid UpdateUserId { get; set; }
public DateTime? DeletedTime { get; set; }
public bool IsDeleted { get; set; }
}

View File

@ -14,7 +14,7 @@ namespace IRaCIS.Core.Domain.Models
///TrialSiteSurvey
///</summary>
[Table("TrialSiteSurvey")]
public class TrialSiteSurvey : Entity, IAuditUpdate, IAuditAdd
public class TrialSiteSurvey : Entity, IAuditUpdate, IAuditAdd,ISoftDelete
{
//public bool IsLocked { get; set; }=false;
public TrialSiteSurveyEnum State { get; set; } = TrialSiteSurveyEnum.ToSubmit;
@ -32,7 +32,10 @@ namespace IRaCIS.Core.Domain.Models
public Site Site { get; set; }
public bool IsAbandon { get; set; }
public DateTime? DeletedTime { get; set; }
public bool IsDeleted { get; set; }
/// <summary>
/// TrialId

View File

@ -53,7 +53,7 @@ namespace IRaCIS.Core.Infra.EFCore
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<TrialSiteSurvey>()
.HasQueryFilter(t => t.IsAbandon == false);
.HasQueryFilter(t => t.IsDeleted == false);
// 软删除配置
foreach (var entityType in modelBuilder.Model.GetEntityTypes())

View File

@ -37,12 +37,12 @@ namespace IRaCIS.Core.Infra.EFCore
//Task<T> InsertOrUpdateAsync<T, TFrom>(this DbSet<T> dbset, TFrom from, bool autoSave = false, params EntityVerifyExp<T>[] verify) where T : Entity;
Task<bool> AnyAsync<T>(Expression<Func<T, bool>> filter) where T : Entity;
Task<bool> AnyAsync<T>(Expression<Func<T, bool>> filter, bool ignoreQueryFilters = false) where T : Entity;
Task<T> FirstOrDefaultAsync<T>(Expression<Func<T, bool>> exp = null) where T : Entity;
Task<int> CountAsync<T>(Expression<Func<T, bool>> exp = null) where T : Entity;
Task<T> FirstOrDefaultAsync<T>(Expression<Func<T, bool>> exp = null, bool ignoreQueryFilters = false) where T : Entity;
Task<int> CountAsync<T>(Expression<Func<T, bool>> exp = null, bool ignoreQueryFilters = false) where T : Entity;
IQueryable<T> Where<T>(Expression<Func<T, bool>> exp = null, bool isTraking = false) where T : Entity;
IQueryable<T> Where<T>(Expression<Func<T, bool>> exp = null, bool isTraking = false, bool ignoreQueryFilters = false) where T : Entity;
ValueTask<T> FindAsync<T>(Guid id) where T : Entity;
@ -167,14 +167,14 @@ namespace IRaCIS.Core.Infra.EFCore
{
if (verifyItem.verifyType == VerifyEnum.OnlyUpdate)
{
if (await _dbContext.Set<T>().AnyAsync(verifyItem.VerifyExp).ConfigureAwait(false))
if (await _dbContext.Set<T>().IgnoreQueryFilters().AnyAsync(verifyItem.VerifyExp).ConfigureAwait(false))
{
throw new BusinessValidationFailedException(verifyItem.VerifyMsg);
}
}
else if (verifyItem.verifyType == VerifyEnum.Both)
{
if (await _dbContext.Set<T>().AnyAsync(verifyItem.VerifyExp.And(t => t.Id != entity.Id)).ConfigureAwait(false))
if (await _dbContext.Set<T>().IgnoreQueryFilters().AnyAsync(verifyItem.VerifyExp.And(t => t.Id != entity.Id)).ConfigureAwait(false))
{
throw new BusinessValidationFailedException(verifyItem.VerifyMsg);
}
@ -200,9 +200,18 @@ namespace IRaCIS.Core.Infra.EFCore
{
return _dbContext.Entry<T>(t);
}
public async Task<bool> AnyAsync<T>(Expression<Func<T, bool>> filter) where T : Entity
public async Task<bool> AnyAsync<T>(Expression<Func<T, bool>> filter, bool ignoreQueryFilters = false) where T : Entity
{
return await _dbContext.Set<T>().AnyAsync(filter).ConfigureAwait(false); ;
var query = _dbContext.Set<T>().AsQueryable();
if (ignoreQueryFilters)
{
query = query.IgnoreQueryFilters();
}
return await query.AsNoTracking().AnyAsync(filter).ConfigureAwait(false);
}
@ -217,15 +226,40 @@ namespace IRaCIS.Core.Infra.EFCore
/// <param name="exp"></param>
/// <returns></returns>
///
public async Task<int> CountAsync<T>(Expression<Func<T, bool>> exp = null) where T : Entity
public async Task<int> CountAsync<T>(Expression<Func<T, bool>> exp = null, bool ignoreQueryFilters = false) where T : Entity
{
if (exp == null) return await _dbContext.Set<T>().CountAsync().ConfigureAwait(false);
return await _dbContext.Set<T>().CountAsync(exp).ConfigureAwait(false);
var query = _dbContext.Set<T>().AsQueryable();
if (ignoreQueryFilters)
{
query = query.IgnoreQueryFilters();
}
if (exp != null)
{
query = query.Where(exp);
}
return await query.CountAsync().ConfigureAwait(false);
}
public async Task<T> FirstOrDefaultAsync<T>(Expression<Func<T, bool>> exp = null) where T : Entity
public async Task<T> FirstOrDefaultAsync<T>(Expression<Func<T, bool>> exp = null, bool ignoreQueryFilters = false) where T : Entity
{
if (exp == null) return await _dbContext.Set<T>().FirstOrDefaultAsync().ConfigureAwait(false);
return await _dbContext.Set<T>().FirstOrDefaultAsync(exp).ConfigureAwait(false);
var query = _dbContext.Set<T>().AsQueryable();
if (ignoreQueryFilters)
{
query = query.IgnoreQueryFilters();
}
if (exp != null)
{
query = query.Where(exp);
}
return await query.FirstOrDefaultAsync().ConfigureAwait(false);
}
/// <summary>
@ -235,10 +269,15 @@ namespace IRaCIS.Core.Infra.EFCore
/// <param name="exp"></param>
/// <param name="isTraking"></param>
/// <returns></returns>
public IQueryable<T> Where<T>(Expression<Func<T, bool>> exp = null, bool isTraking = false) where T : Entity
public IQueryable<T> Where<T>(Expression<Func<T, bool>> exp = null, bool isTraking = false, bool ignoreQueryFilters = false) where T : Entity
{
IQueryable<T> query = _dbContext.Set<T>();
if (ignoreQueryFilters)
{
query = query.IgnoreQueryFilters();
}
if (!isTraking)
{
query = query.AsNoTracking();
@ -356,7 +395,7 @@ namespace IRaCIS.Core.Infra.EFCore
{
if (whereFilter == null) throw new ArgumentNullException(nameof(whereFilter));
return await _dbContext.Set<T>().AsNoTracking().Where(whereFilter).UpdateFromQueryAsync(updateFactory).ConfigureAwait(false) > 0;
return await _dbContext.Set<T>().AsNoTracking().IgnoreQueryFilters().Where(whereFilter).UpdateFromQueryAsync(updateFactory).ConfigureAwait(false) > 0;
}
}

View File

@ -252,7 +252,7 @@ namespace IRaCIS.Core.Infra.EFCore
// Z.EntityFramework.Plus.EFCore
public async Task<bool> DeleteFromQueryAsync(Expression<Func<TEntity, bool>> deleteFilter)
{
return await _dbSet.Where(deleteFilter).DeleteFromQueryAsync() > 0;
return await _dbSet.IgnoreQueryFilters().Where(deleteFilter).DeleteFromQueryAsync() > 0;
}
public async Task<bool> UpdateFromQueryAsync(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, TEntity>> updateFactory)