CityWarningNotice.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Support\Facades\Log;
  5. use App\Jobs\Manager\Process\CityWarningNoticeJobs;
  6. class CityWarningNotice extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'task:city_warning_notice';
  14. /**
  15. * 命令描述
  16. *
  17. * @var string
  18. */
  19. protected $description = '每天12点执行的定时任务';
  20. /**
  21. * 执行命令
  22. *
  23. * @return int
  24. */
  25. public function handle()
  26. {
  27. $this->info('开始执行每日采集预警通知任务...' . now());
  28. try {
  29. Log::info('每日采集预警通知任务执行中 - ' . now());
  30. CityWarningNoticeJobs::dispatchSync([]);
  31. $this->info('每日采集预警通知执行完成!' . now());
  32. return Command::SUCCESS;
  33. } catch (\Exception $e) {
  34. $this->error('每日采集预警通知任务执行失败: ' . $e->getMessage());
  35. return Command::FAILURE;
  36. }
  37. }
  38. }