UpgradeDaily.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. $start = time();
  37. if(app()->isLocal()==false){
  38. $this->call('message:webhook',[
  39. 'listener' => 'dingtalk',
  40. 'url' => 'dingtalk1',
  41. 'title' => "后台任务",
  42. 'message' => " wikipali: 每日统计后台任务开始执行。",
  43. ]);
  44. }
  45. Log::info('wikipali: 每日统计后台任务开始执行');
  46. $message = "wikipali: 每日统计后台任务执行完毕。";
  47. //巴利原文段落库目录结构改变时运行
  48. //$this->call('upgrade:palitext');
  49. #巴利段落标签
  50. //$this->call('upgrade:palitexttag');
  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. #译文进度
  65. $this->call('upgrade:progress');
  66. $time = time()-$currTime;
  67. $message .= "progress:{$time}; ";
  68. $currTime = time();
  69. $this->call('upgrade:progress.chapter');
  70. $time = time()-$currTime;
  71. $message .= "progress.chapter:{$time}; ";
  72. $currTime = time();
  73. # 逐词译数据库分析
  74. $this->call('upgrade:wbw.analyses');
  75. $time = time()-$currTime;
  76. $message .= "wbw.analyses:{$time}; ";
  77. */
  78. # 导出离线数据
  79. $this->call('export:offline',['format'=>'lzma']);
  80. $time = time()-$currTime;
  81. $message .= "export:offline:{$time}; ";
  82. Log::info('导出离线数据完毕');
  83. $time = time()-$start;
  84. $message .= "总时间:{$time}; ";
  85. if(app()->isLocal()==false){
  86. $this->call('message:webhook',[
  87. 'listener' => 'dingtalk',
  88. 'url' => 'dingtalk1',
  89. 'title' => "后台任务",
  90. 'message' => $message,
  91. ]);
  92. //发送dingding消息
  93. $this->call('message:webhookarticlenew',[
  94. 'host' => 'https://oapi.dingtalk.com/robot/send?access_token=34143dbec80a8fc09c1cb5897a5639ee3a9a32ecfe31835ad29bf7013bdb9fdf',
  95. 'type' => 'dingtalk',
  96. ]);
  97. //发送微信消息
  98. $this->call('message:webhookarticlenew',[
  99. 'host' => 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=25dbd74f-c89c-40e5-8cbc-48b1ef7710b8',
  100. 'type' => 'wechat',
  101. ]);
  102. }
  103. return 0;
  104. }
  105. }