You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
|
|
|
|
use App\Services\Brief\WeeklyBriefService;
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
|
|
|
|
class GenerateWeeklyBriefCommand extends Command
|
|
|
|
|
|
{
|
|
|
|
|
|
protected $signature = 'brief:generate-weekly {--week-start=} {--week-end=}';
|
|
|
|
|
|
|
|
|
|
|
|
protected $description = '生成中国高校AI科技成果周报(基于爬虫入库数据)';
|
|
|
|
|
|
|
|
|
|
|
|
public function handle(WeeklyBriefService $service): int
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($this->option('week-start') && $this->option('week-end')) {
|
|
|
|
|
|
$weekStart = \Carbon\Carbon::parse($this->option('week-start'))->timezone('Asia/Shanghai')->startOfDay();
|
|
|
|
|
|
$weekEnd = \Carbon\Carbon::parse($this->option('week-end'))->timezone('Asia/Shanghai')->endOfDay();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
[$weekStart, $weekEnd] = $service->resolvePreviousWeek();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$brief = $service->generate($weekStart, $weekEnd, null, true);
|
|
|
|
|
|
|
|
|
|
|
|
$this->info("已生成简报 #{$brief->id}:{$brief->title}");
|
|
|
|
|
|
|
|
|
|
|
|
return self::SUCCESS;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|