UpgradeDaily.php 3.2 KB

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