From 8762189bc120ef8b9d4772cca8b5709f17d52cb8 Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 10 Jun 2025 11:54:41 +0300 Subject: [PATCH] =?utf8?q?ERP-360=20=D0=A1=D0=B1=D0=BE=D1=80=D0=BA=D0=B0?= =?utf8?q?=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20=D0=B0?= =?utf8?q?=D0=B2=D1=82=D0=BE=D0=BF=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/commands/CronController.php | 22 ++++++++++++---- ...5_201027_create_autoplannagramma_table.php | 2 +- ...tr_quantity_column_in_autoplannogramma.php | 25 +++++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 erp24/migrations/m250610_085127_aletr_quantity_column_in_autoplannogramma.php diff --git a/erp24/commands/CronController.php b/erp24/commands/CronController.php index 70cb2b37..504c8253 100644 --- a/erp24/commands/CronController.php +++ b/erp24/commands/CronController.php @@ -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__); diff --git a/erp24/migrations/m250605_201027_create_autoplannagramma_table.php b/erp24/migrations/m250605_201027_create_autoplannagramma_table.php index 27ec0253..848cfc50 100644 --- a/erp24/migrations/m250605_201027_create_autoplannagramma_table.php +++ b/erp24/migrations/m250605_201027_create_autoplannagramma_table.php @@ -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 index 00000000..acaf378b --- /dev/null +++ b/erp24/migrations/m250610_085127_aletr_quantity_column_in_autoplannogramma.php @@ -0,0 +1,25 @@ +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('Количество рассчитанное')); + + } +} -- 2.39.5