Работа над журналом для ст. мед сестер
This commit is contained in:
@@ -17,10 +17,28 @@ use Illuminate\Support\Facades\Log;
|
||||
class AutoReportService
|
||||
{
|
||||
public function __construct(
|
||||
protected ReportService $reportService,
|
||||
protected DateRangeService $dateRangeService,
|
||||
protected ReportSavePathService $reportSavePathService,
|
||||
) {}
|
||||
mixed $dateRangeService = null,
|
||||
mixed $reportSavePathService = null,
|
||||
?ReportSavePathService $legacyReportSavePathService = null,
|
||||
) {
|
||||
if ($dateRangeService instanceof ReportService) {
|
||||
$this->dateRangeService = $reportSavePathService instanceof DateRangeService
|
||||
? $reportSavePathService
|
||||
: app(DateRangeService::class);
|
||||
$this->reportSavePathService = $legacyReportSavePathService ?? app(ReportSavePathService::class);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dateRangeService = $dateRangeService instanceof DateRangeService
|
||||
? $dateRangeService
|
||||
: app(DateRangeService::class);
|
||||
$this->reportSavePathService = $reportSavePathService ?? app(ReportSavePathService::class);
|
||||
}
|
||||
|
||||
protected DateRangeService $dateRangeService;
|
||||
|
||||
protected ReportSavePathService $reportSavePathService;
|
||||
|
||||
/**
|
||||
* Заполнить отчеты для пользователя за период
|
||||
@@ -34,16 +52,11 @@ class AutoReportService
|
||||
): int {
|
||||
$createdCount = 0;
|
||||
|
||||
// Для многодневного диапазона расширяем конец на 1 день,
|
||||
// чтобы покрыть последние сутки (07:00 -> 07:00) целиком.
|
||||
$start = \Carbon\Carbon::createFromFormat('Y-m-d', $startDate, 'Asia/Yakutsk');
|
||||
$end = \Carbon\Carbon::createFromFormat('Y-m-d', $endDate, 'Asia/Yakutsk');
|
||||
$periodEnd = $start->equalTo($end)
|
||||
? $end->copy()
|
||||
: $end->copy()->addDay();
|
||||
|
||||
// Создаем период по дням
|
||||
$period = CarbonPeriod::create($start->toDateString(), $periodEnd->toDateString());
|
||||
$period = CarbonPeriod::create($start->toDateString(), $end->toDateString());
|
||||
|
||||
foreach ($period as $date) {
|
||||
$dateRange = $this->dateRangeService->getNormalizedDateRange($user, $date, $date);
|
||||
|
||||
Reference in New Issue
Block a user