分配任务
parent
f1adbd924c
commit
8703e3cfc6
|
@ -85,6 +85,8 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<IResponseOutput> BatchAssignDoctorToSubject(BatchAssignDoctorToSubjectCommand command)
|
public async Task<IResponseOutput> BatchAssignDoctorToSubject(BatchAssignDoctorToSubjectCommand command)
|
||||||
{
|
{
|
||||||
|
var inOrder = _trialRepository.Where(t => t.Id == command.TrialId).Select(t => t.IsReadingTaskViewInOrder).FirstOrDefault();
|
||||||
|
|
||||||
foreach (var subjectId in command.SubjectIdList)
|
foreach (var subjectId in command.SubjectIdList)
|
||||||
{
|
{
|
||||||
foreach (var doctorArm in command.DoctorArmList)
|
foreach (var doctorArm in command.DoctorArmList)
|
||||||
|
@ -95,16 +97,54 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == subjectId && t.ArmEnum == doctorArm.ArmEnum && t.TrialId == command.TrialId && t.TaskAllocationState == TaskAllocationState.NotAllocate && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false,
|
Expression<Func<VisitTask, bool>> updateWhere = t => t.SubjectId == subjectId && t.ArmEnum == doctorArm.ArmEnum && t.TrialId == command.TrialId && t.TaskAllocationState == TaskAllocationState.NotAllocate && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false;
|
||||||
|
|
||||||
|
if (inOrder)
|
||||||
|
{
|
||||||
|
|
||||||
|
var notCheckPassedMinVisitNum = await _subjectVisitRepository.Where(t => t.SubjectId == subjectId && t.CheckState!=CheckStateEnum.CVPassed).OrderBy(t => t.VisitNum).Select(t => t.VisitNum).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
|
||||||
|
updateWhere = updateWhere.And(t => t.VisitTaskNum < notCheckPassedMinVisitNum);
|
||||||
|
|
||||||
|
////找到未分配的最小的任务号
|
||||||
|
//var minVisitTaskNum = _visitTaskRepository.Where(t => t.SubjectId == subjectId && t.ArmEnum == doctorArm.ArmEnum && t.TrialId == command.TrialId && t.IsAnalysisCreate == false && t.TaskAllocationState == TaskAllocationState.NotAllocate && t.TaskState == TaskState.Effect).OrderBy(t => t.VisitTaskNum).Select(t => t.VisitTaskNum).FirstOrDefault();
|
||||||
|
|
||||||
|
//var maxVisitTaskNum = _visitTaskRepository.Where(t => t.SubjectId == subjectId && t.ArmEnum == doctorArm.ArmEnum && t.TrialId == command.TrialId && t.IsAnalysisCreate == false && t.TaskAllocationState == TaskAllocationState.NotAllocate && t.TaskState == TaskState.Effect).OrderByDescending(t => t.VisitTaskNum).Select(t => t.VisitTaskNum).FirstOrDefault();
|
||||||
|
|
||||||
|
|
||||||
|
//if (_subjectVisitRepository.Where(t => t.SubjectId == subjectId && t.VisitNum < minVisitTaskNum).Any(t => t.CheckState != CheckStateEnum.CVPassed))
|
||||||
|
//{
|
||||||
|
// //throw new BusinessValidationFailedException("Subject 前序有访视未一致性核查通过,不允许分配任务");
|
||||||
|
|
||||||
|
|
||||||
|
// //不分配
|
||||||
|
// updateWhere = updateWhere.And(t => t.VisitTaskNum < minVisitTaskNum);
|
||||||
|
|
||||||
|
//}
|
||||||
|
//else if(_subjectVisitRepository.Where(t => t.SubjectId == subjectId && t.VisitNum<=maxVisitTaskNum && t.VisitNum >= minVisitTaskNum).Any(t => t.CheckState != CheckStateEnum.CVPassed))
|
||||||
|
//{
|
||||||
|
// var notCheckPassedVisitNum= await _subjectVisitRepository.Where(t => t.SubjectId == subjectId && t.VisitNum <= maxVisitTaskNum && t.VisitNum >= minVisitTaskNum).OrderByDescending(t=>t.VisitNum).Select(t=>t.VisitNum).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
// //分配两者之间的任务
|
||||||
|
// updateWhere = updateWhere.And(t => t.VisitTaskNum >= minVisitTaskNum && t.VisitTaskNum<= notCheckPassedVisitNum);
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
await _visitTaskRepository
|
||||||
|
.BatchUpdateNoTrackingAsync(updateWhere,
|
||||||
u => new VisitTask()
|
u => new VisitTask()
|
||||||
{
|
{
|
||||||
AllocateTime = DateTime.Now,
|
AllocateTime = DateTime.Now,
|
||||||
DoctorUserId = doctorArm.DoctorUserId,
|
DoctorUserId = doctorArm.DoctorUserId,
|
||||||
TaskAllocationState = TaskAllocationState.Allocated,
|
TaskAllocationState = TaskAllocationState.Allocated,
|
||||||
|
|
||||||
SuggesteFinishedTime = /*t.IsUrgent ? DateTime.Now.AddDays(2) :*/ DateTime.Now.AddDays(7),
|
SuggesteFinishedTime = DateTime.Now.AddDays(7),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//task.SuggesteFinishedTime = task.IsUrgent ? DateTime.Now.AddDays(2) : DateTime.Now.AddDays(7);
|
//task.SuggesteFinishedTime = task.IsUrgent ? DateTime.Now.AddDays(2) : DateTime.Now.AddDays(7);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1321,7 +1361,7 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
||||||
await _repository.UpdatePartialFromQueryAsync<Subject>(t => t.Id == subjectId, u => new Subject() { IsReReadingOrBackInfluenceAnalysis = true });
|
await _repository.UpdatePartialFromQueryAsync<Subject>(t => t.Id == subjectId, u => new Subject() { IsReReadingOrBackInfluenceAnalysis = true });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue