项目邮件配置修改--014
parent
bc1e39450d
commit
a4e26f9895
|
@ -1,4 +1,5 @@
|
|||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
|
@ -25,13 +26,62 @@ namespace IRaCIS.Core.Application.Service
|
|||
private readonly IRepository<TrialEmailNoticeConfig> _trialEmailNoticeConfigRepository;
|
||||
|
||||
private readonly IRepository<EmailNoticeConfig> _emailNoticeConfigRepository;
|
||||
public EmailSendService(IRepository<TrialEmailNoticeConfig> trialEmailNoticeConfigRepository, IRepository<EmailNoticeConfig> emailNoticeConfigRepository)
|
||||
|
||||
private readonly IRepository<Trial> _trialRepository;
|
||||
public EmailSendService(IRepository<TrialEmailNoticeConfig> trialEmailNoticeConfigRepository, IRepository<EmailNoticeConfig> emailNoticeConfigRepository, IRepository<Trial> trialRepository)
|
||||
{
|
||||
_trialEmailNoticeConfigRepository = trialEmailNoticeConfigRepository;
|
||||
_emailNoticeConfigRepository = emailNoticeConfigRepository;
|
||||
_trialRepository = trialRepository;
|
||||
}
|
||||
|
||||
|
||||
public async Task TrialImageQCTaskEmail(Guid trialId)
|
||||
{
|
||||
var trialInfo=_repository.Where<Trial>(t=>t.Id == trialId).Select(t=>new {t.ResearchProgramNo,t.ExperimentName, t.TrialCode,t.TrialStatusStr}).FirstOrDefault();
|
||||
|
||||
|
||||
|
||||
//找到 该项目的IQC 用户Id
|
||||
var userIdList = await _repository.Where<TrialUser>(t => t.TrialId == trialId).Where(t => t.User.UserTypeEnum == UserTypeEnum.IQC).Select(t => t.UserId).ToListAsync();
|
||||
|
||||
//判断是否任务可以领取 ,可以的话 发送邮件
|
||||
|
||||
foreach (var userId in userIdList)
|
||||
{
|
||||
//过滤项目 并且 将 _userInfo.Id 换位 当前发送邮件的Id
|
||||
var query = _trialRepository.Where(t=>t.Id==trialId)
|
||||
.Where(t => t.TrialUserList.Any(t => t.UserId == userId))
|
||||
.Where(t => t.QCProcessEnum != TrialQCProcess.NotAudit)
|
||||
.Select(t => new
|
||||
{
|
||||
//待领取量
|
||||
ToBeClaimedCount = t.SubjectVisitList.Where(u => u.CurrentActionUserId == null && (u.PreliminaryAuditUserId == null || (u.PreliminaryAuditUserId != userId && u.ReviewAuditUserId == null))).Count(),
|
||||
|
||||
//待审核通过,统计从已领取到QC提交之间的 已领取 待审核 审核中 (审核完成 领取人就会清理 所以只用查询当前领取人是自己的就好了)
|
||||
ToBeReviewedCount = t.SubjectVisitList.Where(u => u.CurrentActionUserId == userId).Count()
|
||||
|
||||
});
|
||||
|
||||
var sendStat= await query.FirstOrDefaultAsync();
|
||||
|
||||
//当前人 有待领取的或者有待审核的才发邮件
|
||||
if (sendStat != null && (sendStat.ToBeClaimedCount > 0 || sendStat.ToBeReviewedCount>0))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task SendTrialEmail(Guid trialId, CommonDocumentBusinessScenario businessScenario, Func<TrialEmailNoticeConfig, (string topicStr, string htmlBodyStr)> topicAndHtmlFunc, Guid? trialReadingCriterionId, Guid? subjectId)
|
||||
{
|
||||
//找到配置
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace IRaCIS.Core.Domain.Models
|
|||
public List<TrialEmailNoticeConfig> TrialEmailNoticeConfigList { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<EmailNoticeUserType> EmailNoticeUserTypeList { get; set; }
|
||||
public List<EmailNoticeUserType> EmailNoticeUserTypeList { get; set; }=new List<EmailNoticeUserType>();
|
||||
public string Code { get; set; } = String.Empty;
|
||||
|
||||
public CommonDocumentBusinessScenario BusinessScenarioEnum { get; set; }
|
||||
|
|
Loading…
Reference in New Issue