返回签名文档数量
parent
eba41a039d
commit
b52e2de6e5
|
@ -20,6 +20,7 @@ using Localization;
|
|||
using Magicodes.ExporterAndImporter.Core.Filters;
|
||||
using IRaCIS.Core.Application.MediatR.CommandAndQueries;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using Invio.Extensions.Authentication.JwtBearer;
|
||||
|
||||
namespace IRaCIS.Core.API
|
||||
{
|
||||
|
@ -198,6 +199,7 @@ namespace IRaCIS.Core.API
|
|||
app.UseRouting();
|
||||
|
||||
app.UseAuthentication();
|
||||
//app.UseJwtBearerQueryString();
|
||||
app.UseAuthorization();
|
||||
|
||||
//文件伺服 必须带Token 访问
|
||||
|
|
|
@ -20,72 +20,82 @@ namespace IRaCIS.Core.API
|
|||
configuration.Bind("JwtSetting", jwtSetting);
|
||||
|
||||
services
|
||||
.AddAuthentication(o=> {
|
||||
.AddAuthentication(o =>
|
||||
{
|
||||
o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
o.DefaultChallengeScheme = nameof(ApiResponseHandler);
|
||||
o.DefaultForbidScheme = nameof(ApiResponseHandler);
|
||||
})
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidIssuer = jwtSetting.Issuer,
|
||||
ValidAudience = jwtSetting.Audience,
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSetting.SecurityKey)),
|
||||
// 默认 300s
|
||||
ClockSkew = TimeSpan.Zero
|
||||
};
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidIssuer = jwtSetting.Issuer,
|
||||
ValidAudience = jwtSetting.Audience,
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSetting.SecurityKey)),
|
||||
// 默认 300s
|
||||
ClockSkew = TimeSpan.Zero
|
||||
};
|
||||
|
||||
// OPTION 1: use `Invio.Extensions.Authentication.JwtBearer`
|
||||
// OPTION 1: use `Invio.Extensions.Authentication.JwtBearer`
|
||||
|
||||
options.AddQueryStringAuthentication();
|
||||
options.AddQueryStringAuthentication();
|
||||
|
||||
// OPTION 2: do it manually
|
||||
|
||||
#region
|
||||
//options.Events = new JwtBearerEvents
|
||||
//{
|
||||
// OnMessageReceived = (context) => {
|
||||
|
||||
// if (!context.Request.Query.TryGetValue("access_token", out StringValues values))
|
||||
// {
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
//).AddJwtBearerQueryStringAuthentication(
|
||||
// (JwtBearerQueryStringOptions options) =>
|
||||
// {
|
||||
// options.QueryStringParameterName = "access_token";
|
||||
// options.QueryStringBehavior = QueryStringBehaviors.Redact;
|
||||
// };
|
||||
|
||||
// if (values.Count > 1)
|
||||
// {
|
||||
// context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||
// context.Fail(
|
||||
// "Only one 'access_token' query string parameter can be defined. " +
|
||||
// $"However, {values.Count:N0} were included in the request."
|
||||
// );
|
||||
// OPTION 2: do it manually
|
||||
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
#region
|
||||
//options.Events = new JwtBearerEvents
|
||||
//{
|
||||
// OnMessageReceived = (context) => {
|
||||
|
||||
// var token = values.Single();
|
||||
// if (!context.Request.Query.TryGetValue("access_token", out StringValues values))
|
||||
// {
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
|
||||
// if (String.IsNullOrWhiteSpace(token))
|
||||
// {
|
||||
// context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||
// context.Fail(
|
||||
// "The 'access_token' query string parameter was defined, " +
|
||||
// "but a value to represent the token was not included."
|
||||
// );
|
||||
// if (values.Count > 1)
|
||||
// {
|
||||
// context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||
// context.Fail(
|
||||
// "Only one 'access_token' query string parameter can be defined. " +
|
||||
// $"However, {values.Count:N0} were included in the request."
|
||||
// );
|
||||
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
|
||||
// context.Token = token;
|
||||
// var token = values.Single();
|
||||
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
//};
|
||||
#endregion
|
||||
// if (String.IsNullOrWhiteSpace(token))
|
||||
// {
|
||||
// context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||
// context.Fail(
|
||||
// "The 'access_token' query string parameter was defined, " +
|
||||
// "but a value to represent the token was not included."
|
||||
// );
|
||||
|
||||
})
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
|
||||
// context.Token = token;
|
||||
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
//};
|
||||
#endregion
|
||||
|
||||
})
|
||||
.AddScheme<AuthenticationSchemeOptions, ApiResponseHandler>(nameof(ApiResponseHandler), o => { });
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1179,13 +1179,6 @@
|
|||
<param name="querySystemDocument"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Services.TrialDocumentService.GetUserIsHaveDocumentNeedSign(System.Guid)">
|
||||
<summary>
|
||||
获取用户是否有文档未签署
|
||||
</summary>
|
||||
<param name="trialId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Services.TrialDocumentService.GetDocumentConfirmList(IRaCIS.Core.Application.Contracts.DocumentTrialUnionQuery)">
|
||||
<summary>
|
||||
获取确认列表情况 项目文档+系统文档+具体的人
|
||||
|
|
|
@ -197,56 +197,24 @@ namespace IRaCIS.Core.Application.Services
|
|||
.WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmUserId != null)
|
||||
.WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmUserId == null);
|
||||
|
||||
return await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
|
||||
var result = await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
|
||||
|
||||
var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true)
|
||||
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id))
|
||||
.Where(t => t.IsDeleted == false && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
.CountAsync();
|
||||
|
||||
|
||||
var needSignSystemDocCount = await _systemDocumentRepository
|
||||
.Where(t => t.IsDeleted == false && !t.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
.CountAsync();
|
||||
|
||||
result.OtherData = new { NeedSignCount= needSignTrialDocCount + needSignSystemDocCount , NeedSignTrialDocCount= needSignTrialDocCount, NeedSignSystemDocCount = needSignSystemDocCount } ;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户是否有文档未签署
|
||||
/// </summary>
|
||||
/// <param name="trialId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{trialId:guid}")]
|
||||
public async Task<bool> GetUserIsHaveDocumentNeedSign(Guid trialId)
|
||||
{
|
||||
var trialFininshedTime = await _repository.Where<Trial>(t => t.Id == trialId).Select(t => t.TrialFinishedTime).FirstOrDefaultAsync();
|
||||
|
||||
//系统文档查询
|
||||
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.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
|
||||
join confirm in _repository.GetQueryable<SystemDocConfirmedUser>() on new { ConfirmUserId = trialUser.UserId, SystemDocumentId = needConfirmedUserType.SystemDocumentId } equals new { confirm.ConfirmUserId, confirm.SystemDocumentId } into cc
|
||||
from confirm in cc.DefaultIfEmpty()
|
||||
select new
|
||||
{
|
||||
//ConfirmUserId = confirm.ConfirmUserId,
|
||||
ConfirmTime = confirm.ConfirmTime,
|
||||
};
|
||||
|
||||
//项目文档查询
|
||||
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.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
|
||||
new { trialUser.UserId, TrialDocumentId = trialDoc.Id } equals new { UserId = confirm.ConfirmUserId, confirm.TrialDocumentId } into cc
|
||||
from confirm in cc.DefaultIfEmpty()
|
||||
select new
|
||||
{
|
||||
//ConfirmUserId = confirm.ConfirmUserId,
|
||||
ConfirmTime = confirm.ConfirmTime,
|
||||
};
|
||||
|
||||
var unionQuery = systemDocumentQueryable.Union(trialDocQueryable);
|
||||
|
||||
return await unionQuery.AnyAsync(t => t.ConfirmTime == null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -533,7 +501,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> UserConfirm(UserConfirmCommand userConfirmCommand)
|
||||
{
|
||||
|
||||
|
||||
if (userConfirmCommand.isSystemDoc)
|
||||
{
|
||||
if (await _repository.AnyAsync<SystemDocConfirmedUser>(t => t.SystemDocumentId == userConfirmCommand.DocumentId && t.ConfirmUserId == _userInfo.Id))
|
||||
|
@ -545,7 +513,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
return ResponseOutput.NotOk("文件已删除或者废除,签署失败!");
|
||||
}
|
||||
|
||||
await _systemDocConfirmedUserRepository.AddAsync(new SystemDocConfirmedUser() { ConfirmTime = DateTime.Now, ConfirmUserId = _userInfo.Id, IsDeleted=false, SystemDocumentId = userConfirmCommand.DocumentId },true);
|
||||
await _systemDocConfirmedUserRepository.AddAsync(new SystemDocConfirmedUser() { ConfirmTime = DateTime.Now, ConfirmUserId = _userInfo.Id, IsDeleted = false, SystemDocumentId = userConfirmCommand.DocumentId }, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -559,7 +527,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
return ResponseOutput.NotOk("文件已删除或者废除,签署失败!");
|
||||
}
|
||||
|
||||
await _trialDocUserTypeConfirmedUserRepository.AddAsync(new TrialDocUserTypeConfirmedUser() { ConfirmTime = DateTime.Now, ConfirmUserId = _userInfo.Id,IsDeleted=false, TrialDocumentId = userConfirmCommand.DocumentId },true);
|
||||
await _trialDocUserTypeConfirmedUserRepository.AddAsync(new TrialDocUserTypeConfirmedUser() { ConfirmTime = DateTime.Now, ConfirmUserId = _userInfo.Id, IsDeleted = false, TrialDocumentId = userConfirmCommand.DocumentId }, true);
|
||||
}
|
||||
|
||||
await _repository.SaveChangesAsync();
|
||||
|
|
|
@ -313,7 +313,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
|
||||
var sv = (await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == input.subjectVisitId)).IfNullThrowException();
|
||||
|
||||
if ( sv.RequestBackState == RequestBackStateEnum.CRC_RequestBack)
|
||||
if (sv.RequestBackState == RequestBackStateEnum.CRC_RequestBack)
|
||||
{
|
||||
ResponseOutput.NotOk("当前访视处于申请回退状态, 不允许关闭质疑。");
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
/// <returns></returns>
|
||||
[HttpPut("{trialId:guid}")]
|
||||
[TypeFilter(typeof(TrialResourceFilter))]
|
||||
[Authorize(Policy = IRaCISPolicy.PM_APM )]
|
||||
[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
||||
public async Task<IResponseOutput> SetCheckPass(SetCheckPassDt data)
|
||||
{
|
||||
//if (_userInfo.UserTypeEnumInt != (int)UserTypeEnum.ProjectManager && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.APM)
|
||||
|
@ -407,7 +407,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
{
|
||||
sv.RequestBackState = RequestBackStateEnum.CRC_RequestBack;
|
||||
|
||||
await _subjectVisitRepository.SaveChangesAsync();
|
||||
await _subjectVisitRepository.SaveChangesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1301,7 +1301,19 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
return ResponseOutput.NotOk("有访视未上传任何Dicom/非Dicom影像数据,不允许提交");
|
||||
}
|
||||
|
||||
//单个提交提示信息
|
||||
if (dbSubjectVisitList.Count() == 1 && dbSubjectVisitList.First().SubmitState == SubmitStateEnum.Submitted)
|
||||
{
|
||||
return ResponseOutput.NotOk("当前访视的影像数据,已经由其他CRC提交。", 3, ApiResponseCodeEnum.NeedTips);
|
||||
}
|
||||
else if(dbSubjectVisitList.Any(t => t.SubmitState == SubmitStateEnum.Submitted))
|
||||
{
|
||||
return ResponseOutput.NotOk("当前批量提交访视的影像数据,其中部分已由其他CRC提交。", 3, ApiResponseCodeEnum.NeedTips);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 别人未提交的
|
||||
foreach (var dbSubjectVisit in dbSubjectVisitList)
|
||||
{
|
||||
|
||||
|
@ -1369,10 +1381,6 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
dbSubjectVisit.SubmitTime = DateTime.Now;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return ResponseOutput.NotOk("当前访视的影像数据,已经由其他CRC提交。",3,ApiResponseCodeEnum.NeedTips);
|
||||
}
|
||||
//不审 直接QC通过 可能一致性核查 也可能不一致性核查
|
||||
if (trialConfig.QCProcessEnum == TrialQCProcess.NotAudit)
|
||||
{
|
||||
|
@ -1394,12 +1402,18 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var success = await _repository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Result(success);
|
||||
|
||||
|
||||
|
||||
|
||||
return ResponseOutput.Ok(success);
|
||||
|
||||
|
||||
|
||||
|
@ -1685,7 +1699,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
if (trialConfig.QCProcessEnum == TrialQCProcess.DoubleAudit && await _repository.AnyAsync<QCChallenge>(t => t.Id == qcChallengeId && t.SubjectVisit.AuditState == AuditStateEnum.InSecondaryQC))
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// //一致性核查质疑状态
|
||||
// sv.CheckChallengeState = CheckChanllengeTypeEnum.None;
|
||||
|
@ -1734,7 +1748,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
[Authorize(Policy = IRaCISPolicy.CRC)]
|
||||
public async Task<IResponseOutput> SetReuploadFinished(CRCReuploadFinishedCommand cRCReuploadFinishedCommand)
|
||||
{
|
||||
|
||||
|
||||
var qcChallenge = (await _qcChallengeRepository.FirstOrDefaultAsync(t => t.Id == cRCReuploadFinishedCommand.QCChallengeId)).IfNullThrowException();
|
||||
|
||||
if (qcChallenge.ReuploadEnum != QCChanllengeReuploadEnum.QCAgreeUpload)
|
||||
|
@ -1876,7 +1890,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
|
||||
if (command.SubjectFirstGiveMedicineTime != null)
|
||||
{
|
||||
await _subjectRepository.UpdatePartialFromQueryAsync(command.SubjectId, u => new Subject() { FirstGiveMedicineTime = command.SubjectFirstGiveMedicineTime, },true);
|
||||
await _subjectRepository.UpdatePartialFromQueryAsync(command.SubjectId, u => new Subject() { FirstGiveMedicineTime = command.SubjectFirstGiveMedicineTime, }, true);
|
||||
}
|
||||
|
||||
await _subjectVisitRepository.SaveChangesAsync();
|
||||
|
|
Loading…
Reference in New Issue