UpgradeDaily.php 2.9 KB

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