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[] = '';
// Секция "Завис в доставке"
/**
* Форматирует таблицу проблем для Telegram (моноширинный блок)
*
- * Формат: | Дата | Интервал | Заказ | РМК | МП
+ * Формат: | Дата | Интервал | Заказ | РМК | МП | Причина
*
* @param OrderIssue[] $issues
* @return string
{
$rows = [];
$rows[] = '```';
- $rows[] = '| Дата | Интервал | Заказ | РМК | МП';
+ $rows[] = '| Дата | Интервал | Заказ | РМК | МП | Причина';
foreach ($issues as $issue) {
$rows[] = $this->formatIssueRow($issue);
/**
* Форматирует строку таблицы для проблемы
*
- * Формат: | Дата | Интервал | Заказ | РМК | МП
+ * Формат: | Дата | Интервал | Заказ | РМК | МП | Причина
*
* @param OrderIssue $issue
* @return string
$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
);
}
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;
+ }
+
/**
* Форматирует МП-статус для отображения
*
</style>
</head>
<body>
- <h2>[Контроль MP] Отчёт за ' . $this->escapeHtml($result->reportDate) . ' ' . $this->escapeHtml($result->interval) . '</h2>';
+ <h2>[Контроль MP] Отчёт за ' . $this->escapeHtml($result->reportDate) . ' ' . $this->escapeHtml($this->formatIntervalWithShiftName($result->interval)) . '</h2>';
// Общая таблица со всеми проблемами, сортировка по типу
$allIssues = [];
<th>Заказ</th>
<th>РМК</th>
<th>МП</th>
+ <th>Причина</th>
</tr>';
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 .= '
<tr>
<td>' . $this->escapeHtml($issue->orderNumber) . '</td>
<td>' . $this->escapeHtml($issue->rmkStatus ?? '-') . '</td>
<td>' . $this->escapeHtml($mpStatus) . '</td>
+ <td>' . $this->escapeHtml($reason) . '</td>
</tr>';
}