处理延时的任务
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
b0d17b0466
commit
05693d090d
|
@ -12985,6 +12985,11 @@
|
|||
通知PM 进行一致性核查
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.Application.MassTransit.Consumer.QCClaimTaskEventConsumer">
|
||||
<summary>
|
||||
QC 领取了质控任务
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.Application.MassTransit.Consumer.MasstransitTestConsumer">
|
||||
<summary>
|
||||
meditor send 的时候,请求流会先到消费者,返回后才会执行后续代码
|
||||
|
|
|
@ -83,3 +83,13 @@ public class CheckStateChangedToAuditEventConsumer : IConsumer<CheckStateChanged
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// QC 领取了质控任务
|
||||
/// </summary>
|
||||
public class QCClaimTaskEventConsumer : IConsumer<QCClaimTaskEvent>
|
||||
{
|
||||
public Task Consume(ConsumeContext<QCClaimTaskEvent> context)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,6 +184,9 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
public string EmailHtmlContent { get; set; } = string.Empty;
|
||||
public string EmailHtmlContentCN { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public int? EmailDelaySeconds { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -206,7 +209,6 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
public string FromEmail { get; set; } = string.Empty;
|
||||
|
||||
public List<Guid> BlackUserIdList { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,12 +17,13 @@ public abstract class DomainEvent
|
|||
public Guid EventId { get; set; } = NewId.NextSequentialGuid();
|
||||
|
||||
//是不是延迟消费的事件,需要用定时任务调度
|
||||
public bool IsScheduleEvent { get; set; }=false;
|
||||
public bool IsDelayScheduleEvent => DelaySeconds!=null && DelaySeconds > 0;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 在事件产生多少s后开始消费该事件
|
||||
/// </summary>
|
||||
public int DelaySeconds{ get; set; }
|
||||
public int? DelaySeconds{ get; set; }
|
||||
|
||||
public string CultureInfoName { get; set; } = CultureInfo.CurrentCulture.Name;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,10 @@ public class EmailNoticeConfig : BaseFullDeleteAuditEntity
|
|||
|
||||
[Comment("发送周期")]
|
||||
public string EmailCron { get; set; } = null!;
|
||||
|
||||
[Comment("邮件延时秒数,比如一个事件触发,延迟多少s后才发邮件")]
|
||||
public int? EmailDelaySeconds { get; set; } = null!;
|
||||
|
||||
[MaxLength]
|
||||
public string EmailHtmlContent { get; set; } = null!;
|
||||
[MaxLength]
|
||||
|
|
|
@ -82,6 +82,10 @@ public class TrialEmailNoticeConfig : BaseFullDeleteAuditEntity
|
|||
|
||||
public Guid? TrialReadingCriterionId { get; set; }
|
||||
|
||||
|
||||
[Comment("邮件延时秒数,比如一个事件触发,延迟多少s后才发邮件")]
|
||||
public int? EmailDelaySeconds { get; set; } = null!;
|
||||
|
||||
}
|
||||
|
||||
[Comment("项目 - 项目邮件用户黑名单")]
|
||||
|
|
|
@ -76,4 +76,14 @@ public class CheckStateChangedToAuditEvent : DomainEvent
|
|||
{
|
||||
public Guid SubjectVisitId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// QC 领取了质控任务
|
||||
/// </summary>
|
||||
public class QCClaimTaskEvent : DomainEvent
|
||||
{
|
||||
public Guid SubjectVisitId { get; set; }
|
||||
|
||||
public Guid CurrentActionUserId { get; set; }
|
||||
}
|
|
@ -71,6 +71,7 @@ public static class DBContext_Ext
|
|||
var originSubmitState = entry.Property(p => p.SubmitState).OriginalValue;
|
||||
var originAuditState = entry.Property(p => p.AuditState).OriginalValue;
|
||||
var originCheckState = entry.Property(p => p.CheckState).OriginalValue;
|
||||
var originCurrentActionUserId = entry.Property(p => p.CurrentActionUserId).OriginalValue;
|
||||
|
||||
//入组或者PD 才执行下面的逻辑
|
||||
if ((subjectVisit.IsEnrollmentConfirm || subjectVisit.PDState == PDStateEnum.PDProgress))
|
||||
|
@ -91,6 +92,16 @@ public static class DBContext_Ext
|
|||
subjectVisit.AddDomainEvent(new CheckStateChangedToAuditEvent() { SubjectVisitId = subjectVisit.Id });
|
||||
}
|
||||
|
||||
if (originCurrentActionUserId == null && subjectVisit.CurrentActionUserId != null)
|
||||
{
|
||||
var delaySeconds = dbContext.TrialEmailNoticeConfig.Where(t => t.BusinessScenarioEnum == EmailBusinessScenario.EligibilityVerification_PendingClaim)
|
||||
.Select(t => t.EmailDelaySeconds).FirstOrDefault();
|
||||
|
||||
subjectVisit.AddDomainEvent(new QCClaimTaskEvent() { SubjectVisitId = subjectVisit.Id, DelaySeconds= delaySeconds, CurrentActionUserId = (Guid)subjectVisit.CurrentActionUserId });
|
||||
|
||||
}
|
||||
|
||||
|
||||
//添加进记录
|
||||
eventStoreList.AddRange(GetStoreEvents(subjectVisit.DomainEvents));
|
||||
}
|
||||
|
@ -180,7 +191,7 @@ public static class DBContext_Ext
|
|||
if (findSubjectVisit.IsEnrollmentConfirm || findSubjectVisit.PDState == PDStateEnum.PDProgress)
|
||||
{
|
||||
|
||||
taskMedicalReview.AddDomainEvent(new UrgentMedicalReviewAddedEvent() { IsPD= findSubjectVisit.PDState == PDStateEnum.PDProgress, MedicalReviewId = taskMedicalReview.Id, VisitTaskId = taskMedicalReview.VisitTaskId });
|
||||
taskMedicalReview.AddDomainEvent(new UrgentMedicalReviewAddedEvent() { IsPD = findSubjectVisit.PDState == PDStateEnum.PDProgress, MedicalReviewId = taskMedicalReview.Id, VisitTaskId = taskMedicalReview.VisitTaskId });
|
||||
|
||||
//添加进记录
|
||||
eventStoreList.AddRange(GetStoreEvents(taskMedicalReview.DomainEvents));
|
||||
|
@ -220,7 +231,7 @@ public static class DBContext_Ext
|
|||
}
|
||||
else if (entry.State == EntityState.Added && readingMedicalReviewDialog.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer)
|
||||
{
|
||||
readingMedicalReviewDialog.AddDomainEvent(new UrgentIRRepliedMedicalReview() { IsPD= findSubjectVisit.PDState == PDStateEnum.PDProgress, MedicalReviewId= readingMedicalReviewDialog.TaskMedicalReviewId, ReadingMedicalReviewDialogId = readingMedicalReviewDialog.Id });
|
||||
readingMedicalReviewDialog.AddDomainEvent(new UrgentIRRepliedMedicalReview() { IsPD = findSubjectVisit.PDState == PDStateEnum.PDProgress, MedicalReviewId = readingMedicalReviewDialog.TaskMedicalReviewId, ReadingMedicalReviewDialogId = readingMedicalReviewDialog.Id });
|
||||
}
|
||||
|
||||
//添加进记录
|
||||
|
@ -259,7 +270,7 @@ public static class DBContext_Ext
|
|||
if (findSubjectVisit.IsEnrollmentConfirm || findSubjectVisit.PDState == PDStateEnum.PDProgress)
|
||||
{
|
||||
|
||||
visitTask.AddDomainEvent(new UrgentApplyedReReading() { VisitTaskId = visitTask.Id, ReReadingApplyState= visitTask.ReReadingApplyState });
|
||||
visitTask.AddDomainEvent(new UrgentApplyedReReading() { VisitTaskId = visitTask.Id, ReReadingApplyState = visitTask.ReReadingApplyState });
|
||||
|
||||
//添加进记录
|
||||
eventStoreList.AddRange(GetStoreEvents(visitTask.DomainEvents));
|
||||
|
@ -275,7 +286,7 @@ public static class DBContext_Ext
|
|||
|
||||
private static List<EventStoreRecord> GetStoreEvents(IReadOnlyCollection<DomainEvent> domainEvents)
|
||||
{
|
||||
return domainEvents.Select(t => new EventStoreRecord() { Id = t.EventId, EventType = t.GetType().AssemblyQualifiedName, EventTypeName=t.GetType().Name, EventData = t.ToJsonStr() }).ToList();
|
||||
return domainEvents.Select(t => new EventStoreRecord() { Id = t.EventId, EventType = t.GetType().AssemblyQualifiedName, EventTypeName = t.GetType().Name, EventData = t.ToJsonStr() }).ToList();
|
||||
}
|
||||
public class EnrollmentConfirmAndPD
|
||||
{
|
||||
|
|
|
@ -58,10 +58,10 @@ namespace IRaCIS.Core.Infra.EFCore.Interceptor
|
|||
//这种方式会导致消息没处理
|
||||
//await publishEndpoint.Publish(domainEvent);
|
||||
|
||||
if (domainEvent.IsScheduleEvent)
|
||||
if (domainEvent.IsDelayScheduleEvent)
|
||||
{
|
||||
//延迟调度的消息,比如1h后再消费
|
||||
await _scheduler.SchedulePublish(DateTime.Now.AddSeconds(domainEvent.DelaySeconds), (object)domainEvent);
|
||||
await _scheduler.SchedulePublish(DateTime.Now.AddSeconds((int)domainEvent.DelaySeconds!), (object)domainEvent);
|
||||
}
|
||||
|
||||
await _mediator.Publish(domainEvent.GetType(), domainEvent);
|
||||
|
|
Loading…
Reference in New Issue