From 689f0b1798f296df075270ef03f9ac2897388555 Mon Sep 17 00:00:00 2001 From: haoliang <821644@qq.com> Date: Sat, 9 May 2026 17:43:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=91=8A=E8=AD=A6=E4=B8=AD?= =?UTF-8?q?=E5=BF=834=E4=B8=AABug=EF=BC=9A=E6=97=B6=E9=97=B4=E6=98=BE?= =?UTF-8?q?=E7=A4=BA0001-01-01=E3=80=81=E7=BB=9F=E8=AE=A1=E5=8D=A1?= =?UTF-8?q?=E7=89=87=E5=85=A80=E3=80=81=E6=96=B0=E5=A2=9E=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E7=B1=BB=E5=9E=8B=E6=97=A0=E6=A0=87=E7=AD=BE=E3=80=81?= =?UTF-8?q?=E6=9C=BA=E5=BA=8A=E4=B8=8B=E6=8B=89=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. AlertRepository SQL缺少列别名致Dapper无法映射created_at→CreatedAt 2. AlertStatisticsResponse返回嵌套unresolvedByType,前端期望扁平collectFail等 3. AlertPage缺少production_error/summary_error的中文标签映射 4. 机床下拉模板用m.id/m.name,API返回value/label格式不匹配 --- frontend/src/views/alert/AlertPage.vue | 8 +++++++- .../Dto/Alert/AlertStatisticsResponse.cs | 19 ++++++++++++++++++- src/CncRepository/Impl/AlertRepository.cs | 2 +- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/alert/AlertPage.vue b/frontend/src/views/alert/AlertPage.vue index 02c6560..b5b7ff0 100644 --- a/frontend/src/views/alert/AlertPage.vue +++ b/frontend/src/views/alert/AlertPage.vue @@ -18,6 +18,8 @@ + + @@ -31,7 +33,7 @@ - + @@ -146,6 +148,8 @@ function alertTypeTag(type: string): string { production_anomaly: 'warning', unknown_device: 'info', service_error: 'danger', + production_error: 'danger', + summary_error: 'danger', } return map[type] || 'info' } @@ -157,6 +161,8 @@ function alertTypeLabel(type: string): string { production_anomaly: '产量异常', unknown_device: '未知设备', service_error: '服务错误', + production_error: '产量跟踪异常', + summary_error: '日终汇总异常', } return map[type] || type } diff --git a/src/CncModels/Dto/Alert/AlertStatisticsResponse.cs b/src/CncModels/Dto/Alert/AlertStatisticsResponse.cs index 76fa1a9..a100728 100644 --- a/src/CncModels/Dto/Alert/AlertStatisticsResponse.cs +++ b/src/CncModels/Dto/Alert/AlertStatisticsResponse.cs @@ -7,10 +7,27 @@ namespace CncModels.Dto.Alert /// public class AlertStatisticsResponse { - /// 未处理告警总数 + /// 未处理告警总数(前端用 unresolved) public int UnresolvedCount { get; set; } /// 按告警类型统计的未处理数量 public Dictionary UnresolvedByType { get; set; } = new Dictionary(); + + // 以下为前端 AlertStats 接口需要的扁平字段 + + /// 未处理总数(前端字段名 unresolved) + public int Unresolved => UnresolvedCount; + + /// 采集失败未处理数 + public int CollectFail => UnresolvedByType.TryGetValue("collect_fail", out var v) ? v : 0; + + /// 设备离线未处理数 + public int DeviceOffline => UnresolvedByType.TryGetValue("device_offline", out var v) ? v : 0; + + /// 产量异常未处理数 + public int ProductionAnomaly => UnresolvedByType.TryGetValue("production_anomaly", out var v) ? v : 0; + + /// 未知设备未处理数 + public int UnknownDevice => UnresolvedByType.TryGetValue("unknown_device", out var v) ? v : 0; } } diff --git a/src/CncRepository/Impl/AlertRepository.cs b/src/CncRepository/Impl/AlertRepository.cs index 043bc6f..934a38a 100644 --- a/src/CncRepository/Impl/AlertRepository.cs +++ b/src/CncRepository/Impl/AlertRepository.cs @@ -30,7 +30,7 @@ namespace CncRepository.Impl { using (var conn = CreateConnection()) { - string sql = @"SELECT a.id, a.created_at, a.alert_type, a.title, m.name AS MachineName, a.detail, a.is_resolved, a.resolved_at + string sql = @"SELECT a.id AS Id, a.created_at AS CreatedAt, a.alert_type AS AlertType, a.title AS Title, m.name AS MachineName, a.detail AS Detail, a.is_resolved AS IsResolved, a.resolved_at AS ResolvedAt FROM cnc_alert a LEFT JOIN cnc_machine m ON a.machine_id = m.id WHERE 1=1"; string countSql = @"SELECT COUNT(*) FROM cnc_alert a LEFT JOIN cnc_machine m ON a.machine_id = m.id WHERE 1=1";