@@ -29,7 +29,7 @@ namespace IRaCIS.Core.Application.Contracts
private readonly IRepository < User > _userRepository ;
private readonly IRepository < TrialSite > _trialSiteRepository ;
public TrialSiteSurveyService ( IRepository < TrialSiteSurvey > trialSiteSurveyRepository , IRepository < TrialSiteUserSurvey > trialSiteUserSurveyRepository , IRepository < User > userRepository , IRepository < TrialSite > trialSiteRepository )
public TrialSiteSurveyService ( IRepository < TrialSiteSurvey > trialSiteSurveyRepository , IRepository < TrialSiteUserSurvey > trialSiteUserSurveyRepository , IRepository < User > userRepository , IRepository < TrialSite > trialSiteRepository )
{
_trialSiteSurveyRepository = trialSiteSurveyRepository ;
_trialSiteUserSurveyRepository = trialSiteUserSurveyRepository ;
@@ -357,27 +357,72 @@ namespace IRaCIS.Core.Application.Contracts
}
/// <summary>
/// 获取 项目 某个 site的调研记录
/// 获取 项目 site的调研记录 New
/// </summary>
/// <returns></returns>
[HttpPost("{trialId:guid}") ]
public async Task < List < TrialSiteSurveyView > > GetTrialSiteSurveyList ( Guid trialId , TrialSiteSurveyQueryDTO trialSiteSurveyQueryDTO )
[HttpPost]
public async Task < PageOutput < TrialSiteSurveyView > > GetTrialSiteSurveyList ( TrialSiteSurveyQueryDTO surveyQueryDTO )
{
var trialSiteSurveyQueryable = _trialSiteSurveyRepository . Where ( t = > t . TrialId = = trialId ) . IgnoreQueryFilters ( )
//.WhereIf(trialSiteSurveyQueryDTO.si != null, t => t.SiteId == siteId)
. WhereIf ( ! string . IsNullOrWhiteSpace ( trialSiteSurveyQueryDTO . SiteName ) , t = > t . Site . SiteName . Contains ( trialSiteSurveyQueryDTO . SiteName ) )
. WhereIf ( ! string . IsNullOrWhiteSpace ( trialSiteSurveyQueryDTO . TrialSiteAliasName ) , t = > t . TrialSite . TrialSiteAliasName . Contains ( trialSiteSurveyQueryDTO . TrialSiteAliasName ) )
. WhereIf ( ! string . IsNullOrWhiteSpace ( trialSiteSurveyQueryDTO . TrialSiteCode ) , t = > t . TrialSite . TrialSiteAliasName . Contains ( trialSiteSurveyQueryDTO . TrialSiteCode ) )
//.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM, t => t.State >= TrialSiteSurveyEnum.ToSubmit)
//.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM, t => t.State >= TrialSiteSurveyEnum.SPMApproved)
. ProjectTo < TrialSiteSurveyView > ( _mapper . ConfigurationProvider ) ;
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 ( ! 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 )
. ProjectTo < TrialSiteSurveyView > ( _mapper . ConfigurationProvider ) ;
return await trialSiteSurveyQueryable . ToListAsync ( ) ;
return await trialSiteSurveyQueryable . ToPagedListAsync ( surveyQueryDTO . PageIndex , surveyQueryDTO . PageSize , surveyQueryDTO . SortField , surveyQueryDTO . Asc ) ;
}
/// <summary>
/// 项目Site调研用户列表 所有site的调研用户 最新的调研表的记录的用户 new
/// </summary>
/// <returns></returns>
public async Task < PageOutput < TrialSiteUserSurveyAllDTO > > TrialSiteSurveyUserList ( TrialSiteUserSurveyAllQuery queryParam )
{
var groupSelectIdQuery =
_trialSiteSurveyRepository . Where ( t = > t . TrialId = = queryParam . TrialId & & t . IsAbandon = = false )
. 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 )
. Select ( g = > g . OrderByDescending ( u = > u . CreateTime ) . Select ( t = > t . Id ) . First ( ) ) ;
var query = _trialSiteUserSurveyRepository
. Where ( t = > groupSelectIdQuery . Contains ( t . TrialSiteSurveyId ) )
. WhereIf ( queryParam . UserTypeId ! = null , t = > t . UserTypeId = = queryParam . UserTypeId )
. WhereIf ( queryParam . IsGenerateAccount ! = null , t = > t . IsGenerateAccount = = queryParam . IsGenerateAccount )
. WhereIf ( queryParam . TrialRoleNameId ! = null , t = > t . TrialRoleNameId = = queryParam . TrialRoleNameId )
. WhereIf ( queryParam . State ! = null & & queryParam . State ! = TrialSiteUserStateEnum . OverTime , t = > t . InviteState = = queryParam . State )
. WhereIf ( queryParam . State ! = null & & queryParam . State = = TrialSiteUserStateEnum . OverTime , t = > t . InviteState = = TrialSiteUserStateEnum . HasSend & & t . ExpireTime < DateTime . Now )
. WhereIf ( ! string . IsNullOrEmpty ( queryParam . UserKeyInfo ) , t = > ( t . LastName + " / " + t . FirstName ) . Contains ( queryParam . UserKeyInfo ) | | t . Email . Contains ( queryParam . UserKeyInfo ) | | t . Phone . Contains ( queryParam . UserKeyInfo ) )
. ProjectTo < TrialSiteUserSurveyAllDTO > ( _mapper . ConfigurationProvider ) ;
//var query = _trialSiteSurveyRepository.Where(t => t.TrialId == queryParam.TrialId && t.IsAbandon == false)
// .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)
// .Select(g => g.OrderByDescending(u => u.CreateTime).FirstOrDefault())
// .SelectMany(t => t.TrialSiteUserSurveyList)
//.WhereIf(queryParam.UserTypeId != null, t => t.UserTypeId == queryParam.UserTypeId)
//.WhereIf(queryParam.IsGenerateAccount != null, t => t.IsGenerateAccount == queryParam.IsGenerateAccount)
//.WhereIf(queryParam.TrialRoleNameId != null, t => t.TrialRoleNameId == queryParam.TrialRoleNameId)
//.WhereIf(queryParam.State != null && queryParam.State != TrialSiteUserStateEnum.OverTime, t => t.InviteState == queryParam.State)
//.WhereIf(queryParam.State != null && queryParam.State == TrialSiteUserStateEnum.OverTime, t => t.InviteState == TrialSiteUserStateEnum.HasSend && t.ExpireTime < DateTime.Now)
//.WhereIf(!string.IsNullOrEmpty(queryParam.UserKeyInfo), t => (t.LastName + " / " + t.FirstName).Contains(queryParam.UserKeyInfo) || t.Email.Contains(queryParam.UserKeyInfo) || t.Phone.Contains(queryParam.UserKeyInfo))
//.ProjectTo<TrialSiteUserSurveyAllDTO>(_mapper.ConfigurationProvider);
return await query . ToPagedListAsync ( queryParam . PageIndex , queryParam . PageSize , queryParam . SortField , queryParam . Asc ) ;
//return await query.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, queryParam.SortField, queryParam.Asc);
}
@@ -439,9 +484,9 @@ namespace IRaCIS.Core.Application.Contracts
{
//PM 给SPM发 (初审人)
user = await _userRepository . FirstOrDefaultAsync ( t = > t . Id = = survey . PreliminaryUserId ) ;
user = await _userRepository . FirstOrDefaultAsync ( t = > t . Id = = survey . PreliminaryUserId ) ;
messageToSend . To . Add ( new MailboxAddress ( String . Empty , survey . PreliminaryUserId = = null ? survey . Email : user . EMail ) ) ;
messageToSend . To . Add ( new MailboxAddress ( String . Empty , survey . PreliminaryUserId = = null ? survey . Email : user . EMail ) ) ;
survey . State = TrialSiteSurveyEnum . CRCSubmitted ;
@@ -469,13 +514,13 @@ namespace IRaCIS.Core.Application.Contracts
var trialInfo = await _repository . FirstOrDefaultAsync < Trial > ( t = > t . Id = = trialSiteSubmitBackCommand . TrialId ) ;
var siteInfo = await _trialSiteRepository . FirstOrDefaultAsync ( t = > t . TrialId = = trialSiteSubmitBackCommand . TrialId & & t . SiteId = = survey . SiteId , true ) ;
var siteInfo = await _trialSiteRepository . FirstOrDefaultAsync ( t = > t . TrialId = = trialSiteSubmitBackCommand . TrialId & & t . SiteId = = survey . SiteId , true ) ;
builder . HtmlBody = @ $"<body style='font-family: 微软雅黑;padding: 0;margin: 0;'>
<div style='padding-left: 40px;background: #f6f6f6'>
<div style='padding-top: 20px;'>
<div style='line-height: 40px;font-size: 18px'>
{ (user==null? survey.UserName: user.LastName + " / " + user.FirstName)}:
{ (user == null ? survey.UserName : user.LastName + " / " + user.FirstName)}:
< / div >
< div style = ' line - height : 40 px ; padding - left : 40 px ; margin - bottom : 10 px ; ' >
您 好 , 您 填 写 的 中 心 调 研 表 被 驳 回 , 详 细 信 息 如 下 :
@@ -681,7 +726,7 @@ namespace IRaCIS.Core.Application.Contracts
smtp . MessageSent + = ( sender , args ) = >
{
_ = _trialSiteUserSurveyRepository . UpdateFromQueryAsync ( t = > t . Id = = item . Id , u = > new TrialSiteUserSurvey ( ) { IsGenerateSuccess = true , InviteState = TrialSiteUserStateEnum . HasSend , IsJoin = null , ConfirmTime = null , RejectReason = String . Empty , SystemUserId = sysUserInfo . Id , ExpireTime = DateTime . Now . AddDays ( 7 ) } ) . Result ;
_ = _trialSiteUserSurveyRepository . UpdateFromQueryAsync ( t = > t . Id = = item . Id , u = > new TrialSiteUserSurvey ( ) { IsGenerateSuccess = true , InviteState = TrialSiteUserStateEnum . HasSend , IsJoin = null , ConfirmTime = null , RejectReason = String . Empty , SystemUserId = sysUserInfo . Id , ExpireTime = DateTime . Now . AddDays ( 7 ) } ) . Result ;
} ;
@@ -742,7 +787,7 @@ namespace IRaCIS.Core.Application.Contracts
else if ( _userInfo . UserTypeEnumInt = = ( int ) UserTypeEnum . SPM | | _userInfo . UserTypeEnumInt = = ( int ) UserTypeEnum . CPM )
{
await _trialSiteSurveyRepository . UpdateFromQueryAsync ( t = > t . Id = = trialSiteSurveyId & & t . State = = TrialSiteSurveyEnum . CRCSubmitted , u = > new TrialSiteSurvey ( ) { State = TrialSiteSurveyEnum . SPMApproved , PreliminaryUserId = _userInfo . Id , PreliminaryTime = DateTime . Now } ) ;
await _trialSiteSurveyRepository . UpdateFromQueryAsync ( t = > t . Id = = trialSiteSurveyId & & t . State = = TrialSiteSurveyEnum . CRCSubmitted , u = > new TrialSiteSurvey ( ) { State = TrialSiteSurveyEnum . SPMApproved , PreliminaryUserId = _userInfo . Id , PreliminaryTime = DateTime . Now } ) ;
}
else if ( _userInfo . UserTypeEnumInt = = ( int ) UserTypeEnum . APM | | _userInfo . UserTypeEnumInt = = ( int ) UserTypeEnum . ProjectManager )
@@ -759,7 +804,7 @@ namespace IRaCIS.Core.Application.Contracts
await SendInviteEmail ( new InviteEmailCommand ( ) { TrialId = trialId , RouteUrl = siteSurvyeSubmit . RouteUrl , UserList = needGenerateList } ) ;
await _trialSiteSurveyRepository . UpdateFromQueryAsync ( t = > t . Id = = trialSiteSurveyId & & t . State = = TrialSiteSurveyEnum . SPMApproved , u = > new TrialSiteSurvey ( ) { State = TrialSiteSurveyEnum . PMCreatedAndLock , ReviewerUserId = _userInfo . Id , ReviewerTime = DateTime . Now } ) ;
await _trialSiteSurveyRepository . UpdateFromQueryAsync ( t = > t . Id = = trialSiteSurveyId & & t . State = = TrialSiteSurveyEnum . SPMApproved , u = > new TrialSiteSurvey ( ) { State = TrialSiteSurveyEnum . PMCreatedAndLock , ReviewerUserId = _userInfo . Id , ReviewerTime = DateTime . Now } ) ;
}
@@ -767,21 +812,6 @@ namespace IRaCIS.Core.Application.Contracts
}
/// <summary>
/// 项目Site调研用户列表 所有site的调研用户 会有重复
/// </summary>
/// <returns></returns>
public async Task < PageOutput < TrialSiteUserSurveyAllDTO > > TrialSiteSurveyUserList ( TrialSiteUserSurveyAllQuery queryParam )
{
var query = _trialSiteUserSurveyRepository . Where ( t = > t . TrialSiteSurvey . TrialId = = queryParam . TrialId & & t . TrialSiteSurvey . IsAbandon = = false )
. WhereIf ( queryParam . SiteId ! = null , t = > t . TrialSiteSurvey . SiteId = = queryParam . SiteId )
. WhereIf ( ! string . IsNullOrEmpty ( queryParam . UserKeyInfo ) , t = > ( t . LastName + " / " + t . FirstName ) . Contains ( queryParam . UserKeyInfo ) | | t . Email . Contains ( queryParam . UserKeyInfo ) | | t . Phone . Contains ( queryParam . UserKeyInfo ) )
. WhereIf ( ! string . IsNullOrEmpty ( queryParam . FormWriterKeyInfo ) , t = > ( t . TrialSiteSurvey . UserName ) . Contains ( queryParam . FormWriterKeyInfo ) | | t . TrialSiteSurvey . Email . Contains ( queryParam . FormWriterKeyInfo ) | | t . TrialSiteSurvey . Phone . Contains ( queryParam . FormWriterKeyInfo ) )
. ProjectTo < TrialSiteUserSurveyAllDTO > ( _mapper . ConfigurationProvider ) ;
return await query . ToPagedListAsync ( queryParam . PageIndex , queryParam . PageSize , queryParam . SortField , queryParam . Asc ) ;
}