fix(templateDistributor): исправлено зацикливание Worker при распределении по периоду равно количества шаблонов и рабочий к дней

This commit is contained in:
Mikhail Kuznetsov
2024-07-12 14:51:01 +10:00
parent 6e7d4e1fd4
commit 847161ef41

View File

@@ -160,7 +160,7 @@ namespace PARR.TemplateDistributor
distrPlan[workDay.Key] -= templatesCountForCurDay;
}
return templateToDistrib;
return templates;
@@ -312,7 +312,7 @@ namespace PARR.TemplateDistributor
var templateDistributed = 0;
if (templateCount > workDays.Count)
if (templateCount >= workDays.Count)
{
var mainPartTemplateCountToDistribute = templateCount / workDays.Count;
foreach (var item in d)
@@ -323,6 +323,7 @@ namespace PARR.TemplateDistributor
}
}
var templatesPerWorkDay = (double)workDays.Count / (templateCount % workDays.Count);
var currentStep = (double)Math.Floor(templatesPerWorkDay);//??????? точно double?
var balance = (double)templatesPerWorkDay - Math.Floor(currentStep);
@@ -336,10 +337,11 @@ namespace PARR.TemplateDistributor
templateDistributed++;
currentIndex += (int)Math.Floor(currentStep);
currentStep = templatesPerWorkDay + balance;
balance = currentStep - templatesPerWorkDay;
}
}
currentStep = templatesPerWorkDay + balance;
balance = templatesPerWorkDay - currentStep;
}
return d;