using IRaCIS.Application.Interfaces; using IRaCIS.Core.Application.Contracts; using Microsoft.AspNetCore.Mvc; namespace IRaCIS.Core.Application.Services { /// /// Financial---项目收入价格验证 /// [ApiExplorerSettings(GroupName = "Financial")] public class TrialRevenuesPriceVerificationService(IRepository _trialRevenuesPriceVerificationRepository, IRepository _trialRepository, IRepository _doctorRepository, IRepository _paymentRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ITrialRevenuesPriceVerificationService { [HttpPost] public async Task GetAnalysisVerifyList(RevenusVerifyQueryDTO param) { AnalysisVerifyResultDTO result = new AnalysisVerifyResultDTO(); result.RevenuesVerifyList = await GetRevenuesVerifyList(param); var bDate = new DateTime(param.BeginDate.Year, param.BeginDate.Month, 1); var eDate = new DateTime(param.EndDate.Year, param.EndDate.Month, 1); eDate = eDate.AddMonths(1).AddSeconds(-1); Expression> paymentLambda = x => x.YearMonthDate >= bDate && x.YearMonthDate <= eDate && !x.IsLock; var query = from payment in _paymentRepository.Where(paymentLambda) join doctor in _doctorRepository.AsQueryable() on payment.DoctorId equals doctor.Id select new AnalysisNeedLockDTO() { YearMonth = payment.YearMonth, ReviewerCode = doctor.ReviewerCode, ReviewerName = doctor.LastName + " / " + doctor.FirstName, ReviewerNameCN = doctor.ChineseName }; result.MonthVerifyResult = (await query.ToListAsync()).GroupBy(t => t.YearMonth).Select(g => new MonthlyResult { YearMonth = g.Key, ReviewerNameList = g.Select(t => t.ReviewerName).ToList(), ReviewerNameCNList = g.Select(t => t.ReviewerNameCN).ToList(), ReviewerCodeList = g.Select(t => t.ReviewerCode).ToList() }).OrderBy(t => t.YearMonth).ToList(); return result; } [HttpPost] public async Task> GetRevenuesVerifyList(RevenusVerifyQueryDTO param) { var bDate = new DateTime(param.BeginDate.Year, param.BeginDate.Month, 1); var eDate = new DateTime(param.EndDate.Year, param.EndDate.Month, 1); Expression> trialRevenuesPriceVerificationLambda = x => x.WorkLoadDate >= bDate && x.WorkLoadDate <= eDate; var query = (from trialVerify in _trialRevenuesPriceVerificationRepository.Where(trialRevenuesPriceVerificationLambda) join trail in _trialRepository.AsQueryable() on trialVerify.TrialId equals trail.Id select new RevenusVerifyDTO { TrialCode = trail.TrialCode, Timepoint = trialVerify.Timepoint, TimepointIn24H = trialVerify.TimepointIn24H, TimepointIn48H = trialVerify.TimepointIn48H, Adjudication = trialVerify.Adjudication, AdjudicationIn24H = trialVerify.AdjudicationIn24H, AdjudicationIn48H = trialVerify.AdjudicationIn48H, Global = trialVerify.Global, Downtime = trialVerify.Downtime, Training = trialVerify.Training }).Distinct(); return await query.ToListAsync(); } //废弃 [Obsolete] public async Task> GetRevenuesVerifyResultList(RevenusVerifyQueryDTO param) { var bDate = new DateTime(param.BeginDate.Year, param.BeginDate.Month, 1); var eDate = new DateTime(param.EndDate.Year, param.EndDate.Month, 1); Expression> trialRevenuesPriceVerificationLambda = x => x.WorkLoadDate >= bDate && x.WorkLoadDate <= eDate; var query = (from trialVerify in _trialRevenuesPriceVerificationRepository.Where(trialRevenuesPriceVerificationLambda) join trail in _trialRepository.AsQueryable() on trialVerify.TrialId equals trail.Id select new RevenusVerifyDTO { TrialCode = trail.TrialCode, Timepoint = trialVerify.Timepoint, TimepointIn24H = trialVerify.TimepointIn24H, TimepointIn48H = trialVerify.TimepointIn48H, Adjudication = trialVerify.Adjudication, AdjudicationIn24H = trialVerify.AdjudicationIn24H, AdjudicationIn48H = trialVerify.AdjudicationIn48H, Global = trialVerify.Global, Downtime = trialVerify.Downtime, Training = trialVerify.Training }).Distinct(); return await query.ToListAsync(); #region 提示 old //query = from trialVerify in _trialRevenuesPriceVerificationRepository.GetAll() // join trail in _trialRepository.GetAll() on trialVerify.TrialId equals trail.Id // join reviewer in _doctorRepository.GetAll() on trialVerify.ReviewerId equals reviewer.Id // select new RevenusVerifyDTO() // { // ReviewerCode = reviewer.Code, // TrialCode = trail.Code, // YearMonth = trialVerify.YearMonth // }; ////0是Detail 1是按照项目 2是按照人 3按照月份 //if (param.StatType == 0) //{ // query = from trialVerify in _trialRevenuesPriceVerificationRepository.GetAll() // join trail in _trialRepository.GetAll() on trialVerify.TrialId equals trail.Id // join reviewer in _doctorRepository.GetAll() on trialVerify.ReviewerId equals reviewer.Id // select new RevenusVerifyDTO() // { // ReviewerCode = reviewer.Code, // TrialCode = trail.Code, // YearMonth = trialVerify.YearMonth // }; //} //else if (param.StatType == 1) //{ // query = (from trialVerify in _trialRevenuesPriceVerificationRepository.GetAll() // join trail in _trialRepository.GetAll() on trialVerify.TrialId equals trail.Id // select new RevenusVerifyDTO() // { // ReviewerCode = "", // TrialCode = trail.Code, // YearMonth = "" // }).Distinct(); //} //else if (param.StatType == 2) //{ // query = (from trialVerify in _trialRevenuesPriceVerificationRepository.GetAll() // join trail in _trialRepository.GetAll() on trialVerify.TrialId equals trail.Id // join reviewer in _doctorRepository.GetAll() on trialVerify.ReviewerId equals reviewer.Id // select new RevenusVerifyDTO() // { // ReviewerCode = reviewer.Code, // TrialCode = trail.Code, // YearMonth = "" // }).Distinct(); //} //else //{ // query = from trialVerify in _trialRevenuesPriceVerificationRepository.GetAll() // join trail in _trialRepository.GetAll() on trialVerify.TrialId equals trail.Id // join reviewer in _doctorRepository.GetAll() on trialVerify.ReviewerId equals reviewer.Id // select new RevenusVerifyDTO() // { // ReviewerCode = reviewer.Code, // TrialCode = trail.Code, // YearMonth = trialVerify.YearMonth // }; //} #endregion } } }