]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Исправление логики завершения задачи
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 4 Jul 2025 11:12:46 +0000 (14:12 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 4 Jul 2025 11:12:46 +0000 (14:12 +0300)
erp24/controllers/CategoryPlanController.php
erp24/web/js/category-plan/index.js

index 1a05858a3a1bb6bc2f1fa851d59a44a680ef71a5..cf3032516e30a3ae33580196929bbdea2395ef3c 100644 (file)
@@ -263,7 +263,6 @@ class CategoryPlanController extends Controller {
                                 'month'     => $model->month,
                                 'storeId'   => $model->store_id,
                                 'status'    => 'pending',
-                                'info'      => 'auto',
                                 'startTime' => date('Y-m-d H:i:s'),
                                 'progress'  => 0,
                                 'error'     => null
@@ -276,7 +275,6 @@ class CategoryPlanController extends Controller {
                             $log->context = json_encode($cacheValue, JSON_UNESCAPED_UNICODE);
                             $log->year = (int)$cacheValue['year'];
                             $log->month = (int)$cacheValue['month'];
-                            $log->info = $cacheValue['info'];
                             $log->active = 1;
                             $log->progress = 0;
                             $log->status = 1;
@@ -608,7 +606,6 @@ class CategoryPlanController extends Controller {
         $year  = (int)Yii::$app->request->get('year');
         $month = (int)Yii::$app->request->get('month');
         $store = (int)Yii::$app->request->get('store_id');
-        $changes = Yii::$app->request->get('changes');
 
         $taskName = "taskApRecalculate";
         $scriptLauncherLog = ScriptLauncherLog::find()
@@ -629,14 +626,13 @@ class CategoryPlanController extends Controller {
                 'status'    => 'pending',
                 'startTime' => date('Y-m-d H:i:s'),
                 'progress'  => 0,
-                'error'     => null
+                'error'     => null,
             ];
             $log = new ScriptLauncherLog();
             $log->source = 'CronController';
             $log->category = 'autoplannogramma';
             $log->prefix = 'actionAutoplannogrammaRecalculate';
             $log->name = $taskName;
-            $log->info = $cacheValue['info'];
             $log->context = json_encode($cacheValue, JSON_UNESCAPED_UNICODE);
             $log->year = (int)$cacheValue['year'];
             $log->month = (int)$cacheValue['month'];
@@ -661,7 +657,7 @@ class CategoryPlanController extends Controller {
             ->limit(1)
             ->one();
         $task = json_decode($scriptLauncherLog->context, true );
-        if (!$task || $scriptLauncherLog->active == 0) {
+        if (!$task) {
             return $this->asJson(['status' => 'not_found']);
         }
 
index be55dbdee330d3e26fee048922ff9b60d1ae63e6..952716c9750e15e1e04a382a3c63cb46fbb579e0 100644 (file)
@@ -215,6 +215,7 @@ $(document).ready(() => {
         $('#rebuild').prop('disabled', true).text('Пересчёт запущен...');
         $('#delete').prop('disabled', true);
         $('#filter-btn').prop('disabled', true);
+
         $.ajax({
             url: '/category-plan/rebuild',
             type: 'GET',
@@ -222,7 +223,6 @@ $(document).ready(() => {
                 year: $('#dynamicmodel-year').val(),
                 month: $('#dynamicmodel-month').val(),
                 store_id: store_id,
-                changes: localStorage.getItem('planChanges'),
                 [param26]:      token26
             },
             success: function (data) {
@@ -236,7 +236,6 @@ $(document).ready(() => {
                 }
                 if (data.status == 'started') {
                     startTaskPolling();
-
                     console.log(data.data);
                 }
 
@@ -250,7 +249,26 @@ $(document).ready(() => {
             }
         });
     });
-    startTaskPolling();
+    $.ajax({
+        url: '/category-plan/check-task',
+        type: 'GET',
+        dataType: 'json',
+        success: function (data) {
+            console.log(data.status);
+            console.log(data.start);
+            if (data.status === 'running' || data.status === 'pending') {
+                startTaskPolling();
+                $('#rebuild').prop('disabled', true).text('Пересчёт запущен...');
+                $('#delete').prop('disabled', true);
+                $('#filter-btn').prop('disabled', true);
+                $('#changes-hint').hide();
+                $('#changes').hide();
+                $('#changes-count').hide();
+                $('#categoryPlan').addClass('block_table');
+            }
+        }
+    });
+
 });
 
 let taskPollInterval = null;
@@ -304,5 +322,5 @@ function startTaskPolling() {
                 }
             }
         });
-    }, 3000);
+    }, 5000);
 }
\ No newline at end of file