分配算法简单完成
parent
2d8f739f12
commit
6070dbca25
|
@ -1297,6 +1297,11 @@
|
||||||
阅片期ID
|
阅片期ID
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.PreviewTheReadingListInDto.ReadingScope">
|
||||||
|
<summary>
|
||||||
|
阅片范围
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.PreviewTheReadingListInDto.SiteIds">
|
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.PreviewTheReadingListInDto.SiteIds">
|
||||||
<summary>
|
<summary>
|
||||||
中心ID
|
中心ID
|
||||||
|
|
|
@ -319,7 +319,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
//自动分配的话,需要把手动分配的给删掉
|
//自动分配的话,需要把手动分配的给删掉
|
||||||
|
|
||||||
throw new BusinessValidationFailedException("自动分配算法正在开发,还未完成");
|
//throw new BusinessValidationFailedException("自动分配算法正在开发,还未完成");
|
||||||
|
|
||||||
var trialId = autoSubjectAssignCommand.TrialId;
|
var trialId = autoSubjectAssignCommand.TrialId;
|
||||||
|
|
||||||
|
@ -384,7 +384,19 @@ namespace IRaCIS.Core.Application.Service
|
||||||
//eg : 10个Sujbect 都是1/4 先分配整数 再分配 10%4=2个
|
//eg : 10个Sujbect 都是1/4 先分配整数 再分配 10%4=2个
|
||||||
|
|
||||||
//特殊: 不够分的subject数量 适用于 2个Subject 4个医生 这种
|
//特殊: 不够分的subject数量 适用于 2个Subject 4个医生 这种
|
||||||
var specialSubjectCount = subjectCount % waitAllocationDoctorList.Count();
|
|
||||||
|
|
||||||
|
var integerPlan = 0;
|
||||||
|
|
||||||
|
waitAllocationDoctorList.ForEach(doctor =>
|
||||||
|
{
|
||||||
|
|
||||||
|
integerPlan += (int)Math.Floor((double)(subjectCount * doctor.PlanReadingRatio ) / 100);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var specialSubjectCount = subjectCount - integerPlan;
|
||||||
|
|
||||||
//按照医生维度 分配Subject
|
//按照医生维度 分配Subject
|
||||||
foreach (var doctor in waitAllocationDoctorList)
|
foreach (var doctor in waitAllocationDoctorList)
|
||||||
|
@ -401,7 +413,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
var planSubjectCount = (int)Math.Ceiling((double)(subjectCount * doctor.PlanReadingRatio) / 100);
|
var planSubjectCount = (int)Math.Ceiling((double)(subjectCount * doctor.PlanReadingRatio) / 100);
|
||||||
|
|
||||||
//权重大的,将特殊的分配
|
//权重大的,将特殊的分配
|
||||||
if (doctor.Weight >= 50)
|
if (doctor.Weight != 50)
|
||||||
{
|
{
|
||||||
if (specialSubjectCount > 0)
|
if (specialSubjectCount > 0)
|
||||||
{
|
{
|
||||||
|
@ -443,8 +455,17 @@ namespace IRaCIS.Core.Application.Service
|
||||||
}
|
}
|
||||||
if (trialConfig.ReadingType == ReadingMethod.Double)
|
if (trialConfig.ReadingType == ReadingMethod.Double)
|
||||||
{
|
{
|
||||||
|
var integerPlan = 0;
|
||||||
|
|
||||||
var specialSubjectCount = subjectCount % waitAllocationDoctorList.Count();
|
waitAllocationDoctorList.ForEach(doctor =>
|
||||||
|
{
|
||||||
|
|
||||||
|
integerPlan += (int)Math.Floor((double)(subjectCount * doctor.PlanReadingRatio * 2) / 100);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var specialSubjectCount = (subjectCount * 2) - integerPlan;
|
||||||
|
|
||||||
//按照医生维度 分配Subject
|
//按照医生维度 分配Subject
|
||||||
foreach (var doctor in waitAllocationDoctorList)
|
foreach (var doctor in waitAllocationDoctorList)
|
||||||
|
@ -458,10 +479,13 @@ namespace IRaCIS.Core.Application.Service
|
||||||
var hasAssignedSubjectCount = hasAssignedSubjectIdList.Count();
|
var hasAssignedSubjectCount = hasAssignedSubjectIdList.Count();
|
||||||
|
|
||||||
//该医生计划分配到的Subject 最接近的整数数量
|
//该医生计划分配到的Subject 最接近的整数数量
|
||||||
var planSubjectCount = (int)Math.Floor((double)(subjectCount * doctor.PlanReadingRatio *2) / 100);
|
var planSubjectCount = (int)Math.Floor((double)(subjectCount * doctor.PlanReadingRatio * 2) / 100);
|
||||||
|
|
||||||
//权重大的,将特殊的分配
|
//判断是否能整除
|
||||||
if (doctor.Weight >= 50)
|
|
||||||
|
var yuShu = (subjectCount * doctor.PlanReadingRatio * 2) % 100;
|
||||||
|
|
||||||
|
if ( yuShu != 0)
|
||||||
{
|
{
|
||||||
if (specialSubjectCount > 0)
|
if (specialSubjectCount > 0)
|
||||||
{
|
{
|
||||||
|
@ -469,14 +493,11 @@ namespace IRaCIS.Core.Application.Service
|
||||||
planSubjectCount++;
|
planSubjectCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
planSubjectCount++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//如果计划的数量 大于已经分配的数量 那么该医生 可以分配新的Subject
|
//如果计划的数量 大于已经分配的数量 那么该医生 可以分配新的Subject
|
||||||
if (planSubjectCount > hasAssignedSubjectCount)
|
if (planSubjectCount > hasAssignedSubjectCount)
|
||||||
{
|
{
|
||||||
|
@ -488,13 +509,13 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
//取需要分配的数量 并且没有分配给其他医生的包括自己
|
//取需要分配的数量 并且没有分配给其他医生的包括自己
|
||||||
var assignSubjectIdList = subjectList.Where(t => !hasAssignedSubjectIdList.Contains(t.SubjectId) && !otherExceptDoctorIdList.Contains(t.SubjectId))
|
var assignSubjectIdList = subjectList.Where(t => !hasAssignedSubjectIdList.Contains(t.SubjectId) && !otherExceptDoctorIdList.Contains(t.SubjectId))
|
||||||
.Select(t => t.SubjectId).Take((planSubjectCount - hasAssignedSubjectCount) * 2).ToList();
|
.Select(t => t.SubjectId).Take((planSubjectCount - hasAssignedSubjectCount) ).ToList();
|
||||||
|
|
||||||
foreach (var assignSubjectId in assignSubjectIdList)
|
foreach (var assignSubjectId in assignSubjectIdList)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var otherHaveAssignedSubject= assignedSubjectDoctorList.Where(t => t.SubjectId == assignSubjectId).FirstOrDefault();
|
var otherHaveAssignedSubject = assignedSubjectDoctorList.Where(t => t.SubjectId == assignSubjectId).FirstOrDefault();
|
||||||
|
|
||||||
if (otherHaveAssignedSubject != null)
|
if (otherHaveAssignedSubject != null)
|
||||||
{
|
{
|
||||||
|
@ -506,7 +527,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = assignSubjectId, DoctorUserId = doctor.DoctorUserId, ArmEnum = 2, AssignTime = DateTime.Now });
|
await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = assignSubjectId, DoctorUserId = doctor.DoctorUserId, ArmEnum = 2, AssignTime = DateTime.Now });
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(otherHaveAssignedSubject.ArmEnum == 2)
|
else if (otherHaveAssignedSubject.ArmEnum == 2)
|
||||||
{
|
{
|
||||||
assignedSubjectDoctorList.Add(new { SubjectId = assignSubjectId, DoctorUserId = doctor.DoctorUserId, ArmEnum = 1 });
|
assignedSubjectDoctorList.Add(new { SubjectId = assignSubjectId, DoctorUserId = doctor.DoctorUserId, ArmEnum = 1 });
|
||||||
|
|
||||||
|
@ -521,7 +542,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = assignSubjectId, DoctorUserId = doctor.DoctorUserId, ArmEnum = 1, AssignTime = DateTime.Now });
|
await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = assignSubjectId, DoctorUserId = doctor.DoctorUserId, ArmEnum = 1, AssignTime = DateTime.Now });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue