UpdateDrugReportAssCommand.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Facades\Servers\Logs\Log;
  4. use App\Models\DrugReportInfo;
  5. use App\Servers\UpdateDrugReportService;
  6. use Carbon\Carbon;
  7. use Illuminate\Console\Command;
  8. class UpdateDrugReportAssCommand extends Command
  9. {
  10. protected $signature = 'update-drug-report-ass';
  11. protected $description = '同步药检报告数据';
  12. public function __construct()
  13. {
  14. parent::__construct();
  15. }
  16. public function handle(UpdateDrugReportService $service): int
  17. {
  18. echo "开始同步药检报告数据...", PHP_EOL;
  19. $endDateTime = cache('increment:drug:ass:time');
  20. if (!$endDateTime){
  21. $endTime = time();
  22. }else{
  23. $endTime = strtotime($endDateTime);
  24. }
  25. $startTime = ($endTime - 86400 * 30);
  26. $startTime = date('Y-m-d H:i:s', $startTime);
  27. $endTime = date('Y-m-d H:i:s', $endTime);
  28. $page = 1;
  29. $pageSize = 20;
  30. Log::info('update-drug-report-ass','更新同步开始', ['startTime'=>$startTime, 'endTime'=>$endTime]);
  31. $data = $service->syncDrugReport($startTime, $endTime, $page, $pageSize);
  32. Log::info('update-drug-report-ass','更新同步结束'. ",共{$data['count']},处理 {$data['total']} 条记录!", ['startTime'=>$startTime, 'endTime'=>$endTime]);
  33. echo "共{$data['count']},处理 {$data['total']} 条记录!", PHP_EOL;
  34. return 0;
  35. }
  36. }