95 lines
4.2 KiB
C#
95 lines
4.2 KiB
C#
using IRaCIS.Core.Application.Contracts;
|
|
using IRaCIS.Core.Domain.Share;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace IRaCIS.Core.Application
|
|
{
|
|
[ApiExplorerSettings(GroupName = "Trial")]
|
|
public class PersonalWorkstation : BaseService
|
|
{
|
|
private readonly IRepository<Trial> _trialRepository;
|
|
private readonly IRepository<TrialUser> _trialUserRepository;
|
|
private readonly IRepository<TrialDocument> _trialDocumentRepository;
|
|
private readonly IRepository<SystemDocument> _systemDocumentRepository;
|
|
|
|
public PersonalWorkstation(IRepository<Trial> trialRepository, IRepository<TrialUser> trialUserRepository, IRepository<TrialDocument> trialDocumentRepository,IRepository<SystemDocument> systemDocumentRepository)
|
|
{
|
|
_trialRepository = trialRepository;
|
|
_trialUserRepository = trialUserRepository;
|
|
_trialDocumentRepository = trialDocumentRepository;
|
|
_systemDocumentRepository = systemDocumentRepository;
|
|
}
|
|
|
|
|
|
public async Task<PersonalStataDTO> GetBasicStat()
|
|
{
|
|
|
|
|
|
return new PersonalStataDTO()
|
|
{
|
|
//正参与的数量
|
|
TrialCount = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin
|
|
? await _trialRepository.CountAsync()
|
|
: await _trialUserRepository.Where(t => t.UserId == _userInfo.Id).CountAsync(),
|
|
|
|
DeletedCount = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin
|
|
? await _trialRepository.AsQueryable(true).CountAsync(t => t.IsDeleted)
|
|
: await _trialUserRepository.AsQueryable(true).Where(t => t.UserId == _userInfo.Id && t.IsDeleted)
|
|
.CountAsync(),
|
|
|
|
|
|
TotalNeedSignTrialDocCount = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin
|
|
? 0
|
|
: await _trialDocumentRepository
|
|
.Where(t => t.IsAbandon == false || (t.IsAbandon == true &&
|
|
t.TrialDocConfirmedUserList.Any(t =>
|
|
t.ConfirmUserId == _userInfo.Id)))
|
|
.SelectMany(t => t.NeedConfirmedUserTypeList)
|
|
.CountAsync(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId),
|
|
|
|
HaveSignedTrialDocCount = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin
|
|
? 0
|
|
: await _trialDocumentRepository
|
|
.Where(t => t.NeedConfirmedUserTypeList.Any(
|
|
t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
|
.SelectMany(t => t.TrialDocConfirmedUserList)
|
|
.CountAsync(t => t.ConfirmUserId == _userInfo.Id),
|
|
|
|
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)))
|
|
.SelectMany(t => t.NeedConfirmedUserTypeList)
|
|
.CountAsync(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId),
|
|
|
|
|
|
HaveSignedSystemDocCount = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin
|
|
? 0
|
|
: await _systemDocumentRepository
|
|
.Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
|
.SelectMany(t => t.SystemDocConfirmedUserList)
|
|
.CountAsync(t => t.ConfirmUserId == _userInfo.Id),
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public async Task<PageOutput<TrialSiteSurveyStat>> GetSiteSurveyApprovalList(TrialSiteSurveyStatQuery query)
|
|
{
|
|
|
|
return await _trialRepository.ProjectTo<TrialSiteSurveyStat>(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.Id })
|
|
.ToPagedListAsync(query.PageIndex, query.PageSize, query.SortField, query.Asc);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|