Compare commits

...

2 Commits

3 changed files with 32 additions and 11 deletions

View File

@ -58,10 +58,15 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
Id = model.Id
});
model.Status = vm?.Status ?? OrderStatus.Неизвестен;
if ((int)model.Status == (int)newstatus - 1)
if ((int)model.Status == (int)newstatus - 1 || model.Status == OrderStatus.Ожидание)
{
if (newstatus == OrderStatus.Выдан)
{
//if (newstatus == OrderStatus.Выдан)
//{
//}
model.Status = newstatus;
if (newstatus == OrderStatus.Готов)
{
if (vm == null)
{
return false;
@ -72,14 +77,13 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
});
if (manufacture == null || !_storeLogic.FillStore(manufacture, vm.Count))
{
throw new Exception("Не удалось заполнить магазины");
model.Status = OrderStatus.Ожидание;
}
else
{
model.DateImplement = DateTime.Now;
}
}
model.Status = newstatus;
if (newstatus == OrderStatus.Готов)
{
model.DateImplement = DateTime.Now;
}
if (_orderStorage.Update(model) != null)
{
return true;

View File

@ -34,7 +34,15 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
if (orders == null || orders.Count == 0)
{
_logger.LogWarning("DoWork. Orders is null or empty");
return;
orders = _orderLogic.ReadList(new()
{
Status = OrderStatus.Ожидание
});
if (orders == null || orders.Count == 0)
{
_logger.LogWarning("DoWork. Orders is null or empty");
return;
}
}
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
foreach (var implementer in implementers)
@ -56,6 +64,14 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
await RunOrderInWork(implementer);
await Task.Run(() =>
{
//сначала отрабатываем заказы в статусе "ожидание"
foreach (var order in orders.Where(x => x.ImplementerId == implementer.Id && x.Status == OrderStatus.Ожидание))
{
_orderLogic.FinishOrder(new OrderBindingModel()
{
Id = order.Id
});
}
foreach (var order in orders)
{
try

View File

@ -6,6 +6,7 @@
Принят = 0,
Выполняется = 1,
Готов = 2,
Выдан = 3
Выдан = 3,
Ожидание = 4
}
}