UpgradeDaily.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Support\Carbon;
  5. use Illuminate\Support\Facades\Log;
  6. class UpgradeDaily extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'upgrade:daily';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = '每天的任务';
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return int
  33. */
  34. public function handle()
  35. {
  36. if(\App\Tools\Tools::isStop()){
  37. return 0;
  38. }
  39. Log::info('daily task start');
  40. $start = time();
  41. if(app()->isLocal()==false){
  42. $this->call('message:webhook',[
  43. 'listener' => 'dingtalk',
  44. 'url' => 'dingtalk1',
  45. 'title' => "后台任务",
  46. 'message' => " wikipali: 每日统计后台任务开始执行。",
  47. ]);
  48. }
  49. Log::info('wikipali: 每日统计后台任务开始执行');
  50. $message = "wikipali: 每日统计后台任务执行完毕。";
  51. //更新单词首选意思
  52. $this->call('upgrade:dict.default.meaning');
  53. $time = time()-$start;
  54. $message .= "dict.default.meaning:{$time}; ";
  55. $currTime = time();
  56. Log::info('更新单词首选意思完毕');
  57. //社区术语表
  58. $this->call('upgrade:community.term',['lang'=>'zh-Hans']);
  59. $time = time()-$currTime;
  60. $message .= "community.term:{$time}; ";
  61. $currTime = time();
  62. Log::info('社区术语表完毕');
  63. # 导出离线数据
  64. $this->call('export:offline',['format'=>'lzma']);
  65. $time = time()-$currTime;
  66. $message .= "export:offline:{$time}; ";
  67. Log::info('导出离线数据完毕');
  68. $time = time()-$start;
  69. $message .= "总时间:{$time}; ";
  70. if(app()->isLocal()==false){
  71. $this->call('message:webhook',[
  72. 'listener' => 'dingtalk',
  73. 'url' => 'dingtalk1',
  74. 'title' => "后台任务",
  75. 'message' => $message,
  76. ]);
  77. //发送dingding消息
  78. $this->call('message:webhookarticlenew',[
  79. 'host' => 'https://oapi.dingtalk.com/robot/send?access_token=34143dbec80a8fc09c1cb5897a5639ee3a9a32ecfe31835ad29bf7013bdb9fdf',
  80. 'type' => 'dingtalk',
  81. ]);
  82. //发送微信消息
  83. $this->call('message:webhookarticlenew',[
  84. 'host' => 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=25dbd74f-c89c-40e5-8cbc-48b1ef7710b8',
  85. 'type' => 'wechat',
  86. ]);
  87. }
  88. return 0;
  89. }
  90. }