From: fomichev Date: Thu, 29 May 2025 09:39:12 +0000 (+0300) Subject: Правки по методу расчетов без истории X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=73483c99b3677ed0ba42bb08f9c866f06e966d25;p=erp24_rep%2Fyii-erp24%2F.git Правки по методу расчетов без истории --- 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; }