From: fomichev Date: Fri, 4 Jul 2025 11:12:46 +0000 (+0300) Subject: Исправление логики завершения задачи X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=1e3946fd1b3823f16adc34b60ba4834ec005f5fc;p=erp24_rep%2Fyii-erp24%2F.git Исправление логики завершения задачи --- diff --git a/erp24/controllers/CategoryPlanController.php b/erp24/controllers/CategoryPlanController.php index 1a05858a..cf303251 100644 --- a/erp24/controllers/CategoryPlanController.php +++ b/erp24/controllers/CategoryPlanController.php @@ -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']); } diff --git a/erp24/web/js/category-plan/index.js b/erp24/web/js/category-plan/index.js index be55dbde..952716c9 100644 --- a/erp24/web/js/category-plan/index.js +++ b/erp24/web/js/category-plan/index.js @@ -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