diff --git a/src/Core/Application/DTOs/ReportDtos.cs b/src/Core/Application/DTOs/ReportDtos.cs index 5ffed47..e844c39 100644 --- a/src/Core/Application/DTOs/ReportDtos.cs +++ b/src/Core/Application/DTOs/ReportDtos.cs @@ -6,6 +6,7 @@ public sealed class MetricRequestDto public string Column { get; set; } = "C-6111"; public string Metric { get; set; } = ""; // energy_efficiency | yield | control_residual public DateTime PeriodDateKst { get; set; } // 운전원이 고른 KST 날짜(00:00 기준) + public string Period { get; set; } = "DAILY"; // DAILY | MONTHLY | YEARLY — 윈도 = PeriodDateKst가 속한 일/월/연 public string SourceTable { get; set; } = "history_table"; // | fast_record public int? SessionId { get; set; } // fast_record일 때 } @@ -23,6 +24,7 @@ public sealed class MetricResultDto // ── 해상도-인지 메타 ── public string Source { get; set; } = ""; // history_table | fast_record + public string Period { get; set; } = "DAILY"; // DAILY | MONTHLY | YEARLY (집계 윈도) public int SamplingMs { get; set; } // 60000(history) | fast_session.sampling_ms public int N { get; set; } // 클린 후 표본수 public double CleanedFraction { get; set; } // 제거된 비율(0~1) diff --git a/src/Hc900Crawler/Controllers/ReportController.cs b/src/Hc900Crawler/Controllers/ReportController.cs index 61abfb9..0f23ac3 100644 --- a/src/Hc900Crawler/Controllers/ReportController.cs +++ b/src/Hc900Crawler/Controllers/ReportController.cs @@ -125,17 +125,17 @@ GROUP BY b ORDER BY b"; /// 웹에서 바로 보기 — 한 컬럼·날짜의 전 메트릭을 한 번에. [HttpGet("summary")] public async Task Summary(string column = "C-6111", DateTime? date = null, - string source = "history_table", int? sessionId = null, CancellationToken ct = default) + string source = "history_table", string period = "DAILY", int? sessionId = null, CancellationToken ct = default) { var d = (date ?? DateTime.UtcNow.AddHours(9).AddDays(-1)).Date; // 기본 = 어제(KST) var results = new List(); foreach (var m in SUMMARY_METRICS) results.Add(await _metrics.ComputeAsync(new MetricRequestDto { - Column = column, Metric = m, PeriodDateKst = d, + Column = column, Metric = m, PeriodDateKst = d, Period = period, SourceTable = source, SessionId = sessionId }, ct)); - return Ok(new { Column = column, Date = d.ToString("yyyy-MM-dd"), Source = source, Metrics = results }); + return Ok(new { Column = column, Date = d.ToString("yyyy-MM-dd"), Source = source, Period = period, Metrics = results }); } /// 엑셀 템플릿 등록. diff --git a/src/Hc900Crawler/wwwroot/js/reports.js b/src/Hc900Crawler/wwwroot/js/reports.js index 327fde1..65daadc 100644 --- a/src/Hc900Crawler/wwwroot/js/reports.js +++ b/src/Hc900Crawler/wwwroot/js/reports.js @@ -25,7 +25,7 @@ paneInit['reports'] = function () { if (go) go.onclick = async () => { out.innerHTML = '⏳ 조회 중...'; try { - let url = `/api/report/summary?column=${encodeURIComponent(col.value)}&date=${date.value}&source=${$('rvSource').value}`; + let url = `/api/report/summary?column=${encodeURIComponent(col.value)}&date=${date.value}&source=${$('rvSource').value}&period=${$('rvPeriod').value}`; if ($('rvSource').value === 'fast_record' && $('rvSess').value) url += `&sessionId=${$('rvSess').value}`; const r = await fetch(url); if (!r.ok) throw new Error('조회 실패 ' + r.status); @@ -73,7 +73,8 @@ function rpVal(m, kind) { return m.Status === 'ok' && m.Value != null ? rpFmt(m. function renderSummary(d) { const by = {}; (d.Metrics || []).forEach(m => by[m.Metric] = m); const cl = by['mass_balance_closure']; - let html = `
${d.Column} · ${d.Date} · ${d.Source}
`; + const pTxt = { DAILY: '일', MONTHLY: '월', YEARLY: '연' }[d.Period] || d.Period || '일'; + let html = `
${d.Column} · ${d.Date} · ${pTxt} · ${d.Source}
`; // 물질수지 신뢰블록 if (cl) { diff --git a/src/Hc900Crawler/wwwroot/panes/reports.html b/src/Hc900Crawler/wwwroot/panes/reports.html index 623abc5..735047b 100644 --- a/src/Hc900Crawler/wwwroot/panes/reports.html +++ b/src/Hc900Crawler/wwwroot/panes/reports.html @@ -20,6 +20,13 @@
+