]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Правки по методу расчетов без истории
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 29 May 2025 09:39:12 +0000 (12:39 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 29 May 2025 09:39:12 +0000 (12:39 +0300)
erp24/services/AutoPlannogrammaService.php

index e54e3662a0027f6279d5c1c05b6d9a7dfb4bbfc3..e46d26e4c7013621d68fa93491da3707320a1b1f 100644 (file)
@@ -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;
     }