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.

30 lines
1002 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?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;
}
}