UpgradeDaily.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. $this->call('upgrade:progress');
  61. $time = time()-$currTime;
  62. $message .= "progress:{$time}; ";
  63. $currTime = time();
  64. $this->call('upgrade:progress.chapter');
  65. $time = time()-$currTime;
  66. $message .= "progress.chapter:{$time}; ";
  67. $currTime = time();
  68. # 逐词译数据库分析
  69. $this->call('upgrade:wbw.analyses');
  70. $time = time()-$currTime;
  71. $message .= "wbw.analyses:{$time}; ";
  72. $currTime = time();
  73. $time = time()-$start;
  74. $message .= "总时间:{$time}; ";
  75. if(app()->isLocal()==false){
  76. $this->call('message:webhook',[
  77. 'listener' => 'dingtalk',
  78. 'url' => 'dingtalk1',
  79. 'title' => "后台任务",
  80. 'message' => $message,
  81. ]);
  82. //发送dingding消息
  83. $this->call('message:webhookarticlenew',[
  84. 'host' => 'https://oapi.dingtalk.com/robot/send?access_token=34143dbec80a8fc09c1cb5897a5639ee3a9a32ecfe31835ad29bf7013bdb9fdf',
  85. 'type' => 'dingtalk',
  86. ]);
  87. //发送微信消息
  88. $this->call('message:webhookarticlenew',[
  89. 'host' => 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=25dbd74f-c89c-40e5-8cbc-48b1ef7710b8',
  90. 'type' => 'wechat',
  91. ]);
  92. }
  93. return 0;
  94. }
  95. }