| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Console\Commands;
- use App\Models\DrugReportInfo;
- use App\Servers\HistoryDrugReportService;
- use Carbon\Carbon;
- use Illuminate\Console\Command;
- use App\Facades\Servers\Logs\Log;
- class HistorySyncDrugReportCommand extends Command
- {
- protected $signature = 'drug-report-history';
- protected $description = '操作日志同步更新药检报告数据';
- public function handle(HistoryDrugReportService $service): int
- {
- Log::info('drug-report-history','操作历史同步开始');
- $time = time();
- $lastTime = cache('drug:report:history:time');
- $lastTime = 0;
- if (empty($lastTime)){
- $startTime = Carbon::yesterday()->startOfDay()->format('Y-m-d');
- }else{
- $startTime = date('Y-m-d', $lastTime);
- }
- $endTime = date('Y-m-d', $time);
- $page = 1;
- $pageSize = 20;
- Log::info('drug-report-history','操作历史同步开始', ['startTime'=>$startTime, 'endTime'=>$endTime]);
- $count = $service->syncDrugReport( $startTime, $endTime, $page, $pageSize, $lastTime);
- cache(['drug:report:history:time'=>$time]);
- Log::info('drug-report-history','操作历史同步结束:'.$count, ['startTime'=>$startTime, 'endTime'=>$endTime]);
- return 0;
- }
- }
|