From: marina Date: Tue, 10 Jun 2025 08:54:41 +0000 (+0300) Subject: ERP-360 Сборка страницы автопм X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=8762189bc120ef8b9d4772cca8b5709f17d52cb8;p=erp24_rep%2Fyii-erp24%2F.git ERP-360 Сборка страницы автопм --- 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('Количество рассчитанное')); + + } +}