From 73483c99b3677ed0ba42bb08f9c866f06e966d25 Mon Sep 17 00:00:00 2001 From: fomichev Date: Thu, 29 May 2025 12:39:12 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF?= =?utf8?q?=D0=BE=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=83=20=D1=80=D0=B0?= =?utf8?q?=D1=81=D1=87=D0=B5=D1=82=D0=BE=D0=B2=20=D0=B1=D0=B5=D0=B7=20?= =?utf8?q?=D0=B8=D1=81=D1=82=D0=BE=D1=80=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/AutoPlannogrammaService.php | 24 ++++++---------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/erp24/services/AutoPlannogrammaService.php b/erp24/services/AutoPlannogrammaService.php index e54e3662..e46d26e4 100644 --- a/erp24/services/AutoPlannogrammaService.php +++ b/erp24/services/AutoPlannogrammaService.php @@ -628,7 +628,6 @@ class AutoPlannogrammaService */ public function calculateSpeciesForecastForProductsWithoutHistory($dateFrom, $filters): array { - $t0 = hrtime(true); // Получение ID видимых магазинов $storeIds = array_map(fn($store) => $store->id, $this->getVisibleStores()); @@ -644,10 +643,8 @@ class AutoPlannogrammaService $year = $date->format('Y'); $result = []; - $initTime = (hrtime(true) - $t0) / 1e6; // миллисекунды - Yii::warning( "Init (getVisibleStores + filters): {$initTime} ms\n"); + foreach ($storeIds as $storeId) { - $t1 = hrtime(true); $histResult = StorePlanService::calculateHistoricalShare( $storeId, $month, @@ -656,8 +653,6 @@ class AutoPlannogrammaService $subcategory, $species ); - $dur = (hrtime(true) - $t1) / 1e6; - Yii::warning( "calculateHistoricalShare for store {$storeId}: {$dur} ms\n"); $productsWithoutHistory = $histResult['without_history'] ?? []; if (empty($productsWithoutHistory)) { @@ -665,33 +660,26 @@ class AutoPlannogrammaService } // ——————— WEIGHTED SALES ———————— - $t2 = hrtime(true); - $weightedResults = StorePlanService::calculateMedianSalesForProductsWithoutHistory( + + $medianResults = StorePlanService::calculateMedianSalesForProductsWithoutHistoryExtended( $storeId, $month, $year, $productsWithoutHistory ); - $dur = (hrtime(true) - $t2) / 1e6; - Yii::warning("calculateMedianSalesForProductsWithoutHistory for store {$storeId}: {$dur} ms\n"); - if (empty($weightedResults)) { + if (empty($medianResults)) { continue; } // ——————— COST CALCULATION ———————— - $t3 = hrtime(true); + $costs = StorePlanService::calculateCostForProductsWithoutHistory( - $storeId, $month, $year, $weightedResults + $storeId, $month, $year, $medianResults ); - $dur = (hrtime(true) - $t3) / 1e6; - Yii::warning( "calculateCostForProductsWithoutHistory for store {$storeId}: {$dur} ms\n"); if (!empty($costs)) { $result = array_merge($result, $costs); } } - $totalTime = (hrtime(true) - $t0) / 1e6; - Yii::warning( "Total calculateSpeciesForecastForProductsWithoutHistory: {$totalTime} ms\n"); - return $result; } -- 2.39.5