]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-360 Сборка страницы автопм
authormarina <m.zozirova@gmail.com>
Tue, 17 Jun 2025 12:25:09 +0000 (15:25 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 17 Jun 2025 12:25:09 +0000 (15:25 +0300)
erp24/commands/CronController.php

index bfc58c157d9b8322159faf34bed3c070fd129a06..f14d68b0ca20f7762d456d907a640935c221ee72 100644 (file)
@@ -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 = [];