queue = QueueService::instance(); $this->process = ProcessService::instance(); if (defined('WorkQueueCode')) { if (!$this->queue instanceof QueueService) { $this->queue = QueueService::instance(); } if ($this->queue->code !== WorkQueueCode) { $this->queue->initialize(WorkQueueCode); } } return $this; } /** * 设置进度消息并继续执行 * @param null|string $message 进度消息 * @param null|integer $progress 进度数值 * @return static */ protected function setQueueProgress(?string $message = null, $progress = null) { if (defined('WorkQueueCode')) { $this->queue->progress(2, $message, $progress); } elseif (is_string($message)) { $this->output->writeln($message); } return $this; } /** * 设置失败消息并结束进程 * @param string $message 消息内容 * @return static * @throws Exception */ protected function setQueueError(string $message): Command { if (defined('WorkQueueCode')) { throw new Exception($message, 4, WorkQueueCode); } elseif (is_string($message)) { $this->output->writeln($message); } return $this; } /** * 设置成功消息并结束进程 * @param string $message 消息内容 * @return static * @throws Exception */ protected function setQueueSuccess(string $message): Command { if (defined('WorkQueueCode')) { throw new Exception($message, 3, WorkQueueCode); } elseif (is_string($message)) { $this->output->writeln($message); } return $this; } }