]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-360 Сборка страницы автопм
authormarina <m.zozirova@gmail.com>
Tue, 10 Jun 2025 08:54:41 +0000 (11:54 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 10 Jun 2025 08:54:41 +0000 (11:54 +0300)
erp24/commands/CronController.php
erp24/migrations/m250605_201027_create_autoplannagramma_table.php
erp24/migrations/m250610_085127_aletr_quantity_column_in_autoplannogramma.php [new file with mode: 0644]

index 70cb2b37e462d9d2faee1f279df283ed2db0726e..504c82539a269e5606000d8726b545552500e520 100644 (file)
@@ -1567,22 +1567,34 @@ class CronController extends Controller
         $month = date('m');
         $year = date('Y');
         $planDate = $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-01';
+        $this->stdout("Начало расчетов автопланнограммы\n", BaseConsole::FG_GREEN);
         $service = new AutoPlannogrammaService();
         $stores = CityStore::findAll(['visible' => CityStore::IS_VISIBLE]);
         foreach ($stores as $store) {
-            $forecast = $service->calculateFullForecastForWeek(['month' => $month, 'year' => $year, 'store_id' => $store->id, 'plan_date' => $planDate]);
-            Yii::error("Рассчитана автопланограмма для магазина  $store->id");
+            $this->stdout("Начало рассчетов автопланограммы для магазина  $store->id\n", BaseConsole::FG_GREEN);
+            $forecast = $service->calculateFullForecastForWeek([
+                'month' => $month,
+                'year' => $year,
+                'type' => AutoPlannogrammaService::TYPE_SALES,
+                'store_id' => $store->id,
+                'category' => null,
+                'subcategory' => null,
+                'species' => null,
+                'plan_date' => $planDate
+            ]);
+            $this->stdout("Рассчитана автопланограмма для магазина  $store->id\n", BaseConsole::FG_GREEN);
+//            $this->stdout(print_r($forecast, true)); die();
 
             foreach ($forecast as $item) {
                 $model = new Autoplannogramma();
-//                    $model->week = $weekNumber;
                 $model->month = $month;
                 $model->year = $year;
                 $model->product_id = $item['product_id'];
                 $model->store_id = $item['store_id'];
-//                    $model->quantity = round($item[$weekKey]);
-                $model->quantity_forecast = round($item[$weekKey]);
+                $model->quantity = $item['forecast_week_pieces'];
+                $model->quantity_forecast = $item['forecast_week_pieces'];
                 $model->is_archive = false;
+                $model->capacity_type = 'max';
 
                 if (!$model->save()) {
                     Yii::error("Ошибка сохранения: " . json_encode($model->errors), __METHOD__);
index 27ec025348faa338ddb6a898a876c846c08c825e..848cfc506a15ccb7f47e2ebb0aef7d19c77af526 100644 (file)
@@ -36,6 +36,6 @@ class m250605_201027_create_autoplannagramma_table extends Migration
      */
     public function safeDown()
     {
-        $this->dropTable('{{%autoplannogramma}}');
+        $this->dropTable('{{%erp24.autoplannogramma}}');
     }
 }
diff --git a/erp24/migrations/m250610_085127_aletr_quantity_column_in_autoplannogramma.php b/erp24/migrations/m250610_085127_aletr_quantity_column_in_autoplannogramma.php
new file mode 100644 (file)
index 0000000..acaf378
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+use yii\db\Migration;
+
+class m250610_085127_aletr_quantity_column_in_autoplannogramma extends Migration
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $this->alterColumn('autoplannogramma', 'quantity', $this->float()->comment('Количество'));
+        $this->alterColumn('autoplannogramma', 'quantity_forecast',$this->float()->comment('Количество рассчитанное'));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $this->alterColumn('autoplannogramma', 'quantity', $this->integer()->comment('Количество'));
+        $this->alterColumn('autoplannogramma', 'quantity_forecast',$this->integer()->comment('Количество рассчитанное'));
+
+    }
+}