From 4dcb7e61eec09ec88dd959fd2d350b3e28881d23 Mon Sep 17 00:00:00 2001 From: fomichev Date: Mon, 30 Jun 2025 20:24:35 +0300 Subject: [PATCH] =?utf8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA?= =?utf8?q?=D0=B0=20=D0=B2=20=D0=BA=D1=80=D0=BE=D0=BD=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/commands/CronController.php | 6 +++--- erp24/controllers/CategoryPlanController.php | 4 ++-- erp24/web/js/category-plan/index.js | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/erp24/commands/CronController.php b/erp24/commands/CronController.php index dcf56880..562b4b79 100644 --- a/erp24/commands/CronController.php +++ b/erp24/commands/CronController.php @@ -1746,8 +1746,8 @@ class CronController extends Controller $cache = Yii::$app->cache; $task = $cache->get($cacheKey); - - if (!is_array($task) || empty($task['taskName']) || $task['taskName'] !== 'apRecalculate') { + $this->stdout(json_encode($task, JSON_UNESCAPED_UNICODE)); + if (!is_array($task) || empty($task['taskName']) || $task['taskName'] !== 'apRecalculateTask') { $this->stdout("No pending apRecalculateTask\n"); return ExitCode::OK; } @@ -1770,7 +1770,7 @@ class CronController extends Controller } } - if (abs(time() - $task['startTime']) > 86400) { + if (abs(time() - strtotime($task['startTime'])) > 86400) { $this->stdout("Task startTime is out of allowed window\n"); $task['status'] = 'error'; $task['error'] = 'Invalid startTime'; diff --git a/erp24/controllers/CategoryPlanController.php b/erp24/controllers/CategoryPlanController.php index 916cfbc1..2dbdb248 100644 --- a/erp24/controllers/CategoryPlanController.php +++ b/erp24/controllers/CategoryPlanController.php @@ -1022,14 +1022,14 @@ class CategoryPlanController extends Controller { 'year' => $year, 'month' => $month, 'storeId' => $store, - 'status' => 'running', + 'status' => 'pending', 'startTime' => date('Y-m-d H:i:s'), 'progress' => 0, 'error' => null ]; Yii::$app->cache->set($taskName, $cacheValue, 3600); - return $this->asJson(['status' => 'started' ]); + return $this->asJson(['status' => 'started', 'data' => Yii::$app->cache->get('apRecalculateTask') ]); } public function actionCheckTask() diff --git a/erp24/web/js/category-plan/index.js b/erp24/web/js/category-plan/index.js index 5aeb723b..9b71df24 100644 --- a/erp24/web/js/category-plan/index.js +++ b/erp24/web/js/category-plan/index.js @@ -168,9 +168,10 @@ $(document).ready(() => { month: $('#dynamicmodel-month').val(), store_id: store_id }, - success: function () { + success: function (data) { startTaskPolling(); $('#rebuild').prop('disabled', true); + console.log(data.data); }, error: function () { alert('Ошибка запуска пересчёта!'); -- 2.39.5