//using IRaCIS.Application.Contracts;
//using IRaCIS.Core.Application.Contracts;
//using System.Linq.Expressions;
//using IRaCIS.Core.Infrastructure.ExpressionExtend;
//using IRaCIS.Core.Infra.EFCore;
//using IRaCIS.Core.Domain.Models;
//using IRaCIS.Core.Domain.Share;
//using IRaCIS.Core.Infrastructure.Extention;
//using Microsoft.AspNetCore.Mvc;

//namespace IRaCIS.Core.Application.Services
//{
//    /// <summary>
//    /// TP、Global、AD 工作量分配查看
//    /// </summary>
//    [ ApiExplorerSettings(GroupName = "Trial")]
//#pragma warning disable
//    public class WorkloadDistributionService : BaseService, IWorkloadDistributionService
//    {
//        private readonly IWorkloadTPRepository _workloadTpRepository;
//        private readonly IWorkloadGlobalRepository _workloadGlobalRepository;
//        private readonly IWorkloadADRepository _workloadAdRepository;
//        private readonly IRepository<SubjectVisit> _subjectVisitRepository;
//        private readonly IRepository<DicomStudy> _studyRepository;
//        private readonly IRepository<Doctor> _doctorRepository;
//        private readonly IRepository<Subject> _subjectRepository;
//        private readonly IRepository<Site> _siteRepository;
//        private readonly IWorkloadDetailRepository _workloadDetailRepository;
       

//        public WorkloadDistributionService(IWorkloadTPRepository workloadTpRepository,
//            IWorkloadGlobalRepository workloadGlobalRepository,
//            IWorkloadADRepository workloadAdRepository,
//            IRepository<SubjectVisit> subjectVisitRepository, IRepository<DicomStudy> studyRepository,
//            IRepository<Doctor> doctorRepository, IRepository<Subject> subjectRepository,
//            IRepository<Site> siteRepository,
//            IWorkloadDetailRepository workloadDetailRepository,
//            IUserInfo userInfo)
//        {
//            _workloadTpRepository = workloadTpRepository;
//            _workloadGlobalRepository = workloadGlobalRepository;
//            _workloadAdRepository = workloadAdRepository;
//            _subjectVisitRepository = subjectVisitRepository;
//            _studyRepository = studyRepository;
//            _doctorRepository = doctorRepository;
//            _subjectRepository = subjectRepository;
//            _siteRepository = siteRepository;
//            _workloadDetailRepository = workloadDetailRepository;
            
//        }

//        /// <summary>
//        /// 批量分配Tp
//        /// </summary>
//        /// <param name="workloadTPCommand"></param>
//        /// <returns></returns>
//        [HttpPost]
//        public IResponseOutput DistributeTP(WorkloadTPCommand workloadTPCommand)
//        {
//            //当前采用的是没有提示到具体的TP，如有需要在修改下
//            var studyIdList = workloadTPCommand.TpList.Select(u => u.StudyId);
//            var temp = _workloadTpRepository.Where(u => studyIdList.Contains(u.StudyId) && u.ReviewerId == workloadTPCommand.ReviewerId);
//            if (temp.Any() )
//            {
//                return ResponseOutput.NotOk("The TPs of different Arms of the same subject couldn't be assigned to the same reviewer.");
//            }
//            var success = false;
//            workloadTPCommand.TpList.ForEach(t =>
//            {
//                _workloadDetailRepository.Add(new WorkloadDetail
//                {
//                    WorkloadId = t.Id,
//                    OptUserName = _userInfo.RealName,
//                    OptTime = DateTime.Now,
//                    Status = (int)WorkloadStatus.Distributed,
//                    ReviewerId = workloadTPCommand.ReviewerId
//                });
//                _workloadDetailRepository.SaveChanges();
//                success = _workloadTpRepository.Update(u => u.Id == t.Id, k => new WorkloadTP()
//                {
//                    ReviewerId = workloadTPCommand.ReviewerId,
//                    Status = (int)WorkloadStatus.Distributed
//                });
//            });
//            return ResponseOutput.Result(success);
//        }


//        /// <summary>
//        /// 批量分配AD
//        /// </summary>
//        /// <param name="workloadTPCommand"></param>
//        /// <returns></returns>
//        [HttpPost]
//        public IResponseOutput DistributeAD(WorkloadAdCommand workloadTPCommand)
//        {
//            var success = false;
//            workloadTPCommand.IdList.ForEach(t =>
//            {
//                _workloadDetailRepository.Add(new WorkloadDetail
//                {
//                    WorkloadId = t,
//                    OptUserName = _userInfo.RealName,
//                    OptTime = DateTime.Now,
//                    Status = (int)WorkloadStatus.Distributed,
//                    ReviewerId = workloadTPCommand.ReviewerId
//                });
//                _workloadDetailRepository.SaveChanges();
//                success = _workloadAdRepository.Update(u => u.Id == t, k => new WorkloadAD()
//                {
//                    ReviewerId = workloadTPCommand.ReviewerId,
//                    Status = (int)WorkloadStatus.Distributed
//                });
//            });
//            return ResponseOutput.Result(success);
//        }

//        /// <summary>
//        /// 批量分配Global
//        /// </summary>
//        /// <param name="workloadGCommand"></param>
//        /// <returns></returns>
//        [HttpPost]
//        public IResponseOutput DistributeGlobal(WorkloadGlobalCommand workloadGCommand)
//        {
//            var temp = _workloadGlobalRepository.Where(u => workloadGCommand.GlobalList.Select(s => s.SubjectId).Contains(u.SubjectId)
//            && workloadGCommand.GlobalList.Select(s => s.VisitNum).Contains(u.VisitNum) &&
//            u.ReviewerId == workloadGCommand.ReviewerId);
//            if (temp.Any())
//            {
//                return ResponseOutput.NotOk("The Globals of different Arms of the same subject couldn't be assigned to the same reviewer.");
//            }

//            var success = false;
//            workloadGCommand.GlobalList.ForEach(t =>
//            {
//                _workloadDetailRepository.Add(new WorkloadDetail
//                {
//                    WorkloadId = t.Id,
//                    OptUserName = _userInfo.RealName,
//                    OptTime = DateTime.Now,
//                    Status = (int)WorkloadStatus.Distributed,
//                    ReviewerId = workloadGCommand.ReviewerId
//                });
//                _workloadDetailRepository.SaveChanges();
//                success = _workloadGlobalRepository.Update(u => u.Id == t.Id, k => new WorkloadGlobal()
//                {
//                    ReviewerId = workloadGCommand.ReviewerId,
//                    Status = (int)WorkloadStatus.Distributed
//                });
//            });
//            return ResponseOutput.Result(success);
//        }

//        [HttpPost]
//        public PageOutput<WorkloadGlobalDTO> GetWorkloadGlobalList(WorkloadDistributionQueryParam param)
//        {
//            IQueryable<WorkloadGlobalDTO> query = null;
//            Expression<Func<WorkloadGlobal, bool>> workloadTPLambda = x => x.TrialId == param.TrialId;
//            if (param.SiteId != null)
//            {
//                workloadTPLambda = workloadTPLambda.And(t => t.SiteId == param.SiteId);
//            }

//            if (param.Status != null)
//            {
//                workloadTPLambda = workloadTPLambda.And(t => t.Status == param.Status);
//            }
//            if (!string.IsNullOrEmpty(param.WorkloadCode))
//            {
//                var globalCode = param.WorkloadCode.Trim();
//                workloadTPLambda = workloadTPLambda.And(t => t.GlobalCode.Contains(globalCode));
//            }
//            if (param.GroupId != null && param.GroupId > 0)
//            {
//                var groupCode = "G0" + param.GroupId;
//                workloadTPLambda = workloadTPLambda.And(t => t.GlobalCode.Contains(groupCode));
//            }

//            Expression<Func<Subject, bool>> subjectLambda = x => x.TrialId == param.TrialId;
//            if (!string.IsNullOrEmpty(param.SubjectCode))
//            {
//                var subjectCode = param.SubjectCode.Trim();
//                subjectLambda = subjectLambda.And(t => t.Code.Contains(subjectCode));
//            }
//            Expression<Func<Doctor, bool>> doctorLambda = x => true;
//            if (!string.IsNullOrEmpty(param.Reviewer))
//            {
//                var reviewer = param.Reviewer.Trim();

//                doctorLambda = doctorLambda.And(t => t.ChineseName.Contains(reviewer)
//                                                     || t.FirstName.Contains(reviewer) || t.LastName.Contains(reviewer));
//                query = from workloadG in _workloadGlobalRepository.Where(workloadTPLambda)
//                        join subject in _subjectRepository.Where(subjectLambda) on workloadG.SubjectId equals subject.Id
//                        join site in _siteRepository.AsQueryable() on workloadG.SiteId equals site.Id
//                        join doctor in _doctorRepository.Where(doctorLambda) on workloadG.ReviewerId equals doctor.Id
//                        select new WorkloadGlobalDTO()
//                        {
//                            Id = workloadG.Id,
//                            ReviewerCode = doctor.ReviewerCode,
//                            ReviewerChineseName = doctor.ChineseName,
//                            ReviewerFirstName = doctor.FirstName,
//                            ReviewerId = doctor.Id,
//                            ReviewerLastName = doctor.LastName,
//                            SiteId = workloadG.SiteId,
//                            SiteName = site.SiteName,
//                            Status = workloadG.Status,
//                            GlobalCode = workloadG.GlobalCode,
//                            SubjectCode = subject.Code,
//                            VisitId = workloadG.VisitId,
//                            UpdateTime = workloadG.UpdateTime,
//                            SubjectId = workloadG.SubjectId,
//                            VisitNum = workloadG.VisitNum,
//                            VisitName = workloadG.VisitName
//                        };
//            }
//            else
//            {
//                query = from workloadG in _workloadGlobalRepository.Where(workloadTPLambda)
//                        join subject in _subjectRepository.Where(subjectLambda) on workloadG.SubjectId equals subject.Id
//                        join site in _siteRepository.AsQueryable() on workloadG.SiteId equals site.Id
//                        join doctor in _doctorRepository.Where(doctorLambda) on workloadG.ReviewerId equals doctor.Id into cc
//                        from doctor in cc.DefaultIfEmpty()
//                        select new WorkloadGlobalDTO()
//                        {
//                            Id = workloadG.Id,
//                            ReviewerCode = doctor.ReviewerCode,
//                            ReviewerChineseName = doctor.ChineseName,
//                            ReviewerFirstName = doctor.FirstName,
//                            ReviewerId = doctor.Id,
//                            ReviewerLastName = doctor.LastName,
//                            SiteId = workloadG.SiteId,
//                            SiteName = site.SiteName,
//                            Status = workloadG.Status,
//                            GlobalCode = workloadG.GlobalCode,
//                            SubjectCode = subject.Code,
//                            VisitId = workloadG.VisitId,
//                            UpdateTime = workloadG.UpdateTime,
//                            SubjectId = workloadG.SubjectId,
//                            VisitNum = workloadG.VisitNum,
//                            VisitName = workloadG.VisitName
//                        };
//            }

//            var count = query.Count();

//            var propName = param.SortField == string.Empty ? "GlobalCode" : param.SortField;

//            query = param.Asc
//                ? query.OrderBy(propName).ThenBy(t => t.SiteName).ThenBy(t => t.SubjectCode)
//                : query.OrderByDescending(propName).ThenBy(t => t.SiteName).ThenBy(t => t.SubjectCode);

//            query = query.Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize);
//            var list = query.ToList();

//            return new PageOutput<WorkloadGlobalDTO>(param.PageIndex,
//                param.PageSize, count, list);
//        }

//        [HttpPost]
//        public PageOutput<WorkloadADDTO> GetWorkloadADList(WorkloadDistributionQueryParam param)
//        {
//            IQueryable<WorkloadADDTO> query = null;
//            Expression<Func<WorkloadAD, bool>> workloadAdLambda = x => x.TrialId == param.TrialId;
//            if (param.SiteId != null)
//            {
//                workloadAdLambda = workloadAdLambda.And(t => t.SiteId == param.SiteId);
//            }

//            if (param.Status != null)
//            {
//                workloadAdLambda = workloadAdLambda.And(t => t.Status == param.Status);
//            }
//            if (!string.IsNullOrEmpty(param.WorkloadCode))
//            {
//                var adCode = param.WorkloadCode.Trim();
//                workloadAdLambda = workloadAdLambda.And(t => t.ADCode.Contains(adCode));
//            }

//            Expression<Func<Subject, bool>> subjectLambda = x => x.TrialId == param.TrialId;
//            if (!string.IsNullOrEmpty(param.SubjectCode))
//            {
//                var subjectCode = param.SubjectCode.Trim();
//                subjectLambda = subjectLambda.And(t => t.Code.Contains(subjectCode));

//            }
//            Expression<Func<Doctor, bool>> doctorLambda = x => true;
//            if (!string.IsNullOrEmpty(param.Reviewer))
//            {
//                var reviewer = param.Reviewer.Trim();
//                doctorLambda = doctorLambda.And(t => t.ChineseName.Contains(reviewer)
//                                                     || t.FirstName.Contains(reviewer) || t.LastName.Contains(reviewer));
//                query = from workloadAd in _workloadAdRepository.Where(workloadAdLambda)
//                        join subject in _subjectRepository.Where(subjectLambda) on workloadAd.SubjectId equals subject.Id
//                        join site in _siteRepository.AsQueryable() on workloadAd.SiteId equals site.Id
//                        join doctor in _doctorRepository.Where(doctorLambda) on workloadAd.ReviewerId equals doctor.Id
//                        select new WorkloadADDTO()
//                        {
//                            Id = workloadAd.Id,
//                            ReviewerCode = doctor.ReviewerCode,
//                            ReviewerChineseName = doctor.ChineseName,
//                            ReviewerFirstName = doctor.FirstName,
//                            ReviewerId = doctor.Id,
//                            ReviewerLastName = doctor.LastName,
//                            SiteId = workloadAd.SiteId,
//                            SiteName = site.SiteName,
//                            Status = workloadAd.Status,
//                            ADCode = workloadAd.ADCode,
//                            SubjectCode = subject.Code,
//                            SubjectId = workloadAd.SubjectId,
//                            UpdateTime = workloadAd.UpdateTime
//                        };
//            }
//            else
//            {
//                query = from workloadAd in _workloadAdRepository.Where(workloadAdLambda)
//                        join subject in _subjectRepository.Where(subjectLambda) on workloadAd.SubjectId equals subject.Id

//                        join site in _siteRepository.AsQueryable() on workloadAd.SiteId equals site.Id
//                        join doctor in _doctorRepository.Where(doctorLambda) on workloadAd.ReviewerId equals doctor.Id into cc
//                        from doctor in cc.DefaultIfEmpty()
//                        select new WorkloadADDTO()
//                        {
//                            Id = workloadAd.Id,
//                            ReviewerCode = doctor.ReviewerCode,
//                            ReviewerChineseName = doctor.ChineseName,
//                            ReviewerFirstName = doctor.FirstName,
//                            ReviewerId = doctor.Id,
//                            ReviewerLastName = doctor.LastName,
//                            SiteId = workloadAd.SiteId,
//                            SiteName = site.SiteName,
//                            Status = workloadAd.Status,
//                            ADCode = workloadAd.ADCode,
//                            SubjectCode = subject.Code,
//                            SubjectId = workloadAd.SubjectId,
//                            UpdateTime = workloadAd.UpdateTime
//                        };

//            }
//            var count = query.Count();

//            var propName = param.SortField == string.Empty ? "ADCode" : param.SortField;

//            query = param.Asc
//                ? query.OrderBy(propName).ThenBy(t => t.SiteName).ThenBy(t => t.SubjectCode)
//                : query.OrderByDescending(propName).ThenBy(t => t.SiteName).ThenBy(t => t.SubjectCode);

//            query = query.Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize);
//            var list = query.ToList();

//            return new PageOutput<WorkloadADDTO>(param.PageIndex,
//                param.PageSize, count, list);
//        }

//        [HttpPost]
//        public PageOutput<WorkloadTPDTO> GetWorkloadTPList(WorkloadDistributionQueryParam param)
//        {
//            IQueryable<WorkloadTPDTO> query = null;
//            Expression<Func<WorkloadTP, bool>> workloadTPLambda = x => x.TrialId == param.TrialId;
//            if (param.SiteId != null)
//            {
//                workloadTPLambda = workloadTPLambda.And(t => t.SiteId == param.SiteId);
//            }

//            if (param.Status != null)
//            {
//                workloadTPLambda = workloadTPLambda.And(t => t.Status == param.Status);
//            }
//            if (!string.IsNullOrEmpty(param.WorkloadCode))
//            {
//                var timepoint = param.WorkloadCode.Trim();

//                workloadTPLambda = workloadTPLambda.And(t => t.TimepointCode.Contains(timepoint));
//            }
//            if (param.GroupId != null && param.GroupId > 0)
//            {
//                var groupCode = "T0" + param.GroupId;
//                workloadTPLambda = workloadTPLambda.And(t => t.TimepointCode.Contains(groupCode));
//            }

//            Expression<Func<Subject, bool>> subjectLambda = x => x.TrialId == param.TrialId;
//            if (!string.IsNullOrEmpty(param.SubjectCode))
//            {
//                var subjectCode = param.SubjectCode.Trim();
//                subjectLambda = subjectLambda.And(t => t.Code.Contains(subjectCode));
//            }
//            Expression<Func<Doctor, bool>> doctorLambda = x => true;
//            if (!string.IsNullOrEmpty(param.Reviewer))
//            {
//                var reviewer = param.Reviewer.Trim();
//                doctorLambda = doctorLambda.And(t => t.ChineseName.Contains(reviewer)
//                                                     || t.FirstName.Contains(reviewer) || t.LastName.Contains(reviewer));
//                query = from workloadTp in _workloadTpRepository.Where(workloadTPLambda)
//                        join subject in _subjectRepository.Where(subjectLambda) on workloadTp.SubjectId equals subject.Id
//                        join subjectVisit in _subjectVisitRepository.AsQueryable() on workloadTp.SubjectVisitId equals subjectVisit.Id
//                        join study in _studyRepository.AsQueryable() on workloadTp.StudyId equals study.Id
//                        join site in _siteRepository.AsQueryable() on workloadTp.SiteId equals site.Id
//                        join doctor in _doctorRepository.Where(doctorLambda) on workloadTp.ReviewerId equals doctor.Id

//                        select new WorkloadTPDTO()
//                        {
//                            Id = workloadTp.Id,
//                            ReviewerCode = doctor.ReviewerCode,
//                            ReviewerChineseName = doctor.ChineseName,
//                            ReviewerFirstName = doctor.FirstName,
//                            ReviewerId = doctor.Id,
//                            ReviewerLastName = doctor.LastName,
//                            SiteId = workloadTp.SiteId,
//                            SiteName = site.SiteName,
//                            Status = workloadTp.Status,
//                            StudyCode = study.StudyCode,
//                            StudyId = workloadTp.StudyId,
//                            TimepointCode = workloadTp.TimepointCode,
//                            SubjectCode = subject.Code,
//                            SubjectVisitId = workloadTp.SubjectVisitId,
//                            SubjectId = workloadTp.SubjectId,
//                            VisitNum = subjectVisit.VisitNum,
//                            VisitName = subjectVisit.VisitName,
//                            UpdateTime = workloadTp.UpdateTime
//                        };
//            }
//            else
//            {
//                query = from workloadTp in _workloadTpRepository.Where(workloadTPLambda)
//                        join subject in _subjectRepository.Where(subjectLambda) on workloadTp.SubjectId equals subject.Id
//                        join subjectVisit in _subjectVisitRepository.AsQueryable() on workloadTp.SubjectVisitId equals subjectVisit.Id
//                        join study in _studyRepository.AsQueryable() on workloadTp.StudyId equals study.Id
//                        join site in _siteRepository.AsQueryable() on workloadTp.SiteId equals site.Id
//                        join doctor in _doctorRepository.Where(doctorLambda) on workloadTp.ReviewerId equals doctor.Id into cc
//                        from doctor in cc.DefaultIfEmpty()
//                        select new WorkloadTPDTO()
//                        {
//                            Id = workloadTp.Id,
//                            ReviewerCode = doctor.ReviewerCode,
//                            ReviewerChineseName = doctor.ChineseName,
//                            ReviewerFirstName = doctor.FirstName,
//                            ReviewerId = doctor.Id,
//                            ReviewerLastName = doctor.LastName,
//                            SiteId = workloadTp.SiteId,
//                            SiteName = site.SiteName,
//                            Status = workloadTp.Status,
//                            StudyCode = study.StudyCode,
//                            StudyId = workloadTp.StudyId,
//                            TimepointCode = workloadTp.TimepointCode,
//                            SubjectCode = subject.Code,
//                            SubjectVisitId = workloadTp.SubjectVisitId,
//                            SubjectId = workloadTp.SubjectId,
//                            VisitNum = subjectVisit.VisitNum,
//                            VisitName = subjectVisit.VisitName,
//                            UpdateTime = workloadTp.UpdateTime
//                        };

//            }
//            var count = query.Count();

//            var propName = param.SortField == string.Empty ? "TimepointCode" : param.SortField;
//            query = param.Asc
//                ? query.OrderBy(propName).ThenBy(t => t.SiteName).ThenBy(t => t.SubjectCode)
//                : query.OrderByDescending(propName).ThenBy(t => t.SiteName).ThenBy(t => t.SubjectCode);
//            query = query.Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize);
//            var list = query.ToList();

//            return new PageOutput<WorkloadTPDTO>(param.PageIndex,
//                param.PageSize, count, list);
//        }

//        //修改单个TP
//        [HttpPost("{tpId:guid}/{reviewerId:guid}")]
//        public IResponseOutput UpdateDistributeAD(Guid tpId, Guid reviewerId)
//        {
//            _workloadDetailRepository.Add(new WorkloadDetail
//            {
//                WorkloadId = tpId,
//                OptUserName = _userInfo.RealName,
//                OptTime = DateTime.Now,
//                Status = (int)WorkloadStatus.Distributed,
//                ReviewerId = reviewerId
//            });
//            _workloadDetailRepository.SaveChanges();
//            var success= _workloadAdRepository.Update(t => t.Id == tpId, u => new WorkloadAD()
//            {
//                ReviewerId = reviewerId,
//                Status = (int)WorkloadStatus.Distributed
//            });

//            return ResponseOutput.Result(success);
//        }

//        //修改单个Global
//        [HttpPost("{tpId:guid}/{reviewerId:guid}/{subjectId:guid}/{visitNum}")]
//        public IResponseOutput UpdateDistributeGlobal(Guid tpId, Guid reviewerId, Guid subjectId, decimal visitNum)
//        {
//            var temp = _workloadGlobalRepository.Where(u => u.SubjectId == subjectId &&
//            u.VisitNum == visitNum &&
//            u.ReviewerId == reviewerId && u.Id != tpId);
//            if (temp.Any())
//            {
//                return ResponseOutput.NotOk("The Global of the other arm of this subject has already been assigned to this reviewer, and the assignment couldn't be performed.");
//            }

//            _workloadDetailRepository.Add(new WorkloadDetail
//            {
//                WorkloadId = tpId,
//                OptUserName = _userInfo.RealName,
//                OptTime = DateTime.Now,
//                Status = (int)WorkloadStatus.Distributed,
//                ReviewerId = reviewerId
//            });
//            _workloadDetailRepository.SaveChanges();
//            return ResponseOutput.Result(_workloadGlobalRepository.Update(t => t.Id == tpId, u => new WorkloadGlobal()
//            {
//                ReviewerId = reviewerId,
//                Status = (int)WorkloadStatus.Distributed
//            }));
//        }

//        //修改单个TP
//        [HttpPost("{tpId:guid}/{reviewerId:guid}/{studyId:guid}")]
//        public IResponseOutput UpdateDistributeTP(Guid tpId, Guid reviewerId, Guid studyId)
//        {
//            var temp = _workloadTpRepository.Where(u => u.StudyId == studyId && u.ReviewerId == reviewerId && u.Id != tpId);
//            if (temp.Any())
//            {
//                return ResponseOutput.NotOk("The TP of the other arm of this subject has already been assigned to this reviewer, and the assignment couldn't be performed.");
//            }

//            _workloadDetailRepository.Add(new WorkloadDetail
//            {
//                WorkloadId = tpId,
//                OptUserName = _userInfo.RealName,
//                OptTime = DateTime.Now,
//                Status = (int)WorkloadStatus.Distributed,
//                ReviewerId = reviewerId
//            });
//            _workloadDetailRepository.SaveChanges();
//            return ResponseOutput.Result(_workloadTpRepository.Update(t => t.Id == tpId, u => new WorkloadTP()
//            {
//                ReviewerId = reviewerId,
//                Status = (int)WorkloadStatus.Distributed
//            }));
//        }

//        [HttpGet("{workloadId:guid}")]
//        public IResponseOutput<List<WorkloadDetailDTO>> GetWorkloadDetail(Guid workloadId)
//        {
//            IQueryable<WorkloadDetailDTO> query = null;
//            query = from detail in _workloadDetailRepository.Where(u => u.WorkloadId == workloadId)
//                    join doctor in _doctorRepository.AsQueryable() on detail.ReviewerId equals doctor.Id into cc
//                    from doctor in cc.DefaultIfEmpty()
//                    select new WorkloadDetailDTO()
//                    {
//                        OptTime = detail.OptTime,
//                        OptUserName = detail.OptUserName,
//                        ReviewerChineseName = doctor.ChineseName,
//                        ReviewerFirstName = doctor.FirstName,
//                        ReviewerLastName = doctor.LastName,
//                        Status = detail.Status
//                    };
//            var list = query.OrderByDescending(u => u.OptTime).ToList();
//            return ResponseOutput.Ok(list);
//        }

//        [HttpPost("UpdateGlobalStatus/{globalId:guid}")]
//        public IResponseOutput UpdateGlobalStatus(Guid globalId)
//        {
//            return ResponseOutput.Result(_workloadGlobalRepository.Update(u => u.Id == globalId, t => new WorkloadGlobal()
//            {
//                Status = 0
//            }));
//        }

//    }
//}
