From: fomichev Date: Mon, 30 Jun 2025 17:24:35 +0000 (+0300) Subject: Настройка в кроне X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=4dcb7e61eec09ec88dd959fd2d350b3e28881d23;p=erp24_rep%2Fyii-erp24%2F.git Настройка в кроне --- 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('Ошибка запуска пересчёта!');