From 1abac97801538bba9be091e5b7fb5db5c1bacfb3 Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Thu, 22 Jan 2026 12:00:51 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF?= =?utf8?q?=D0=BE=20=D0=BE=D1=82=D1=87=D0=B5=D1=82=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/OrderControlReportService.php | 45 ++++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/erp24/services/OrderControlReportService.php b/erp24/services/OrderControlReportService.php index 8e848af0..bbf76327 100644 --- a/erp24/services/OrderControlReportService.php +++ b/erp24/services/OrderControlReportService.php @@ -744,7 +744,8 @@ class OrderControlReportService public function formatTelegramControlReport(ControlReportResult $result): string { $lines = []; - $lines[] = '*\[Контроль MP\]* Отчёт за ' . $this->escapeMarkdownV2($result->reportDate) . ' ' . $this->escapeMarkdownV2($result->interval); + $intervalWithShift = $this->formatIntervalWithShiftName($result->interval); + $lines[] = '*\[Контроль MP\]* Отчёт за ' . $this->escapeMarkdownV2($result->reportDate) . ' ' . $this->escapeMarkdownV2($intervalWithShift); $lines[] = ''; // Секция "Завис в доставке" @@ -776,7 +777,7 @@ class OrderControlReportService /** * Форматирует таблицу проблем для Telegram (моноширинный блок) * - * Формат: | Дата | Интервал | Заказ | РМК | МП + * Формат: | Дата | Интервал | Заказ | РМК | МП | Причина * * @param OrderIssue[] $issues * @return string @@ -785,7 +786,7 @@ class OrderControlReportService { $rows = []; $rows[] = '```'; - $rows[] = '| Дата | Интервал | Заказ | РМК | МП'; + $rows[] = '| Дата | Интервал | Заказ | РМК | МП | Причина'; foreach ($issues as $issue) { $rows[] = $this->formatIssueRow($issue); @@ -799,7 +800,7 @@ class OrderControlReportService /** * Форматирует строку таблицы для проблемы * - * Формат: | Дата | Интервал | Заказ | РМК | МП + * Формат: | Дата | Интервал | Заказ | РМК | МП | Причина * * @param OrderIssue $issue * @return string @@ -810,14 +811,16 @@ class OrderControlReportService $interval = $this->getShortInterval($issue->interval); $rmk = $issue->rmkStatus ?? '-'; $mp = $this->formatMpStatus($issue); + $reason = $issue->getIssueReasonLabel() ?: '-'; return sprintf( - '| %s | %s | %s | %s | %s', + '| %s | %s | %s | %s | %s | %s', $date, $interval, $issue->orderNumber, $rmk, - $mp + $mp, + $reason ); } @@ -844,6 +847,29 @@ class OrderControlReportService return $interval; } + /** + * Форматирует интервал с названием смены для заголовка отчёта + * + * 08:00 → "08:00 (день)" + * 20:00 → "20:00 (ночь)" + * + * @param string|null $interval + * @return string + */ + private function formatIntervalWithShiftName(?string $interval): string + { + $shortInterval = $this->getShortInterval($interval); + + if ($shortInterval === '08:00') { + return '08:00 (день)'; + } + if ($shortInterval === '20:00') { + return '20:00 (ночь)'; + } + + return $shortInterval; + } + /** * Форматирует МП-статус для отображения * @@ -923,7 +949,7 @@ class OrderControlReportService -

[Контроль MP] Отчёт за ' . $this->escapeHtml($result->reportDate) . ' ' . $this->escapeHtml($result->interval) . '

'; +

[Контроль MP] Отчёт за ' . $this->escapeHtml($result->reportDate) . ' ' . $this->escapeHtml($this->formatIntervalWithShiftName($result->interval)) . '

'; // Общая таблица со всеми проблемами, сортировка по типу $allIssues = []; @@ -952,14 +978,16 @@ class OrderControlReportService Заказ РМК МП + Причина '; foreach ($allIssues as $item) { /** @var OrderIssue $issue */ $issue = $item['issue']; $date = $issue->reportDate ?: date('d.m.Y'); - $interval = $issue->interval ?: OrderIssue::calculateInterval($this->testMode); + $interval = $this->getShortInterval($issue->interval); $mpStatus = $issue->mpStatus ?? '-'; + $reason = $issue->getIssueReasonLabel() ?: '-'; $html .= ' @@ -969,6 +997,7 @@ class OrderControlReportService ' . $this->escapeHtml($issue->orderNumber) . ' ' . $this->escapeHtml($issue->rmkStatus ?? '-') . ' ' . $this->escapeHtml($mpStatus) . ' + ' . $this->escapeHtml($reason) . ' '; } -- 2.39.5