SyncSealDrugReportCommand.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Services\SyncSealDrugReportService;
  4. use Carbon\Carbon;
  5. use Illuminate\Console\Command;
  6. class SyncSealDrugReportCommand extends Command
  7. {
  8. // php artisan sync:seal-drug-report --start-time="2025-03-01 00:00:00" --end-time="2025-03-31 23:59:59"
  9. protected $signature = 'sync:seal-drug-report {--start-time=} {--end-time=} {--page=1} {--page-size=20}';
  10. protected $description = '同步已签收药检报告数据';
  11. public function handle(SyncSealDrugReportService $service): int
  12. {
  13. $startTime = $this->option('start-time') ?? Carbon::today()->startOfDay();
  14. $endTime = $this->option('end-time') ?? Carbon::now();
  15. $page = $this->option('page') ?? 1;
  16. $pageSize = $this->option('page-size') ?? 20;
  17. echo sprintf('已签收药检报告数据[%s, %s, %d, %d]:', $startTime, $endTime, $page, $pageSize), PHP_EOL;
  18. echo "全量同步开始……", PHP_EOL;
  19. $count = $service->syncSealDrugReport($startTime, $endTime, $page, $pageSize);
  20. echo "全量同步结束,共处理 {$count} 条记录!", PHP_EOL;
  21. return Command::SUCCESS;
  22. }
  23. }