<?php

namespace App\Console\Commands;

use App\Models\DrugReportInfo;
use App\Servers\SyncDrugReportService;
use Carbon\Carbon;
use Illuminate\Console\Command;

class SyncDrugReportCommand extends Command
{
    protected $signature = 'sync-drug-report';

    protected $description = '同步药检报告数据';
    public function __construct()
    {
        parent::__construct();
    }
    public function handle(SyncDrugReportService $service): int
    {
        echo "开始同步药检报告数据...", PHP_EOL;
        $isFull     = true;
        $source     = 'querysealdrugreport';
        $startTime  = '2024-01-01 00:00:00';
        $endTime    = '';
        $page       = 1;
        $pageSize   = 20;
        $data       = $service->syncDrugReport($source, $isFull, $startTime, $endTime, $page, $pageSize,1);
        $SealData   = $service->syncDrugReport($source, $isFull, $startTime, $endTime, $page, $pageSize,2);

        echo $isFull ? "全量同步结束" : "增量同步结束", "，共{$data['count']}，处理 {$data['total']} 条记录！", PHP_EOL;
        echo $isFull ? "全量同步结束" : "增量同步结束", "，共{$SealData['count']}，处理 {$SealData['total']} 条记录！", PHP_EOL;

        return 0;
    }

}
