From: marina Date: Tue, 17 Jun 2025 12:25:09 +0000 (+0300) Subject: ERP-360 Сборка страницы автопм X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=38b3cbd0906f08c812bc585231b06e990ae0231d;p=erp24_rep%2Fyii-erp24%2F.git ERP-360 Сборка страницы автопм --- diff --git a/erp24/commands/CronController.php b/erp24/commands/CronController.php index bfc58c15..f14d68b0 100644 --- a/erp24/commands/CronController.php +++ b/erp24/commands/CronController.php @@ -1561,6 +1561,7 @@ class CronController extends Controller return ExitCode::OK; } + public function actionAutoplannogrammaCalculate() { $date = new \DateTime(); @@ -1610,11 +1611,10 @@ class CronController extends Controller foreach ($records as $record) { $existingRecords[$record->week . '_' . $record->product_id] = $record; } - foreach ($forecast as $item) { $key = $item['week'] . '_' . $item['product_id']; $model = $existingRecords[$key] ?? null; - + $this->stderr(implode("\n", $item), BaseConsole::FG_GREEN); if (!$model) { $model = new Autoplannogramma(); $model->month = $month; @@ -1624,10 +1624,14 @@ class CronController extends Controller $model->store_id = $item['store_id']; $model->is_archive = false; $model->capacity_type = 1; + $model->quantity = $item['forecast_week_pieces']; } - $model->quantity = $item['forecast_week_pieces']; - $model->quantity_forecast = $item['forecast_week_pieces']; + $needsUpdate = $model->quantity_forecast != $item['forecast_week_pieces']; + + if ($needsUpdate) { + $model->quantity_forecast = $item['forecast_week_pieces']; + } if (!$model->save()) { $errors = [];