From b6ca0f4db9ef45bf27c20301b4b98a5c148d8f05 Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Mon, 7 Mar 2022 08:47:17 +0800 Subject: [PATCH] =?UTF-8?q?[alerter]fixbug=20dashboard=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E5=A4=84=E7=90=86=E7=8E=87=E8=AE=A1=E7=AE=97=E5=92=8C=E6=97=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=97=B6=E5=91=8A=E8=AD=A6=E5=9B=BE=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E9=94=99=E4=B9=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usthe/alert/service/impl/AlertServiceImpl.java | 12 ++++++++---- .../app/routes/dashboard/dashboard.component.html | 4 ++-- .../src/app/routes/dashboard/dashboard.component.ts | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/alerter/src/main/java/com/usthe/alert/service/impl/AlertServiceImpl.java b/alerter/src/main/java/com/usthe/alert/service/impl/AlertServiceImpl.java index 6e9bc47..9958022 100644 --- a/alerter/src/main/java/com/usthe/alert/service/impl/AlertServiceImpl.java +++ b/alerter/src/main/java/com/usthe/alert/service/impl/AlertServiceImpl.java @@ -75,10 +75,14 @@ public class AlertServiceImpl implements AlertService { - alertSummary.getPriorityEmergencyNum() - alertSummary.getPriorityWarningNum(); alertSummary.setDealNum(dealNum); try { - float rate = BigDecimal.valueOf(100 * (float) dealNum / total) - .setScale(2, RoundingMode.HALF_UP) - .floatValue(); - alertSummary.setRate(rate); + if (total == 0) { + alertSummary.setRate(100); + } else { + float rate = BigDecimal.valueOf(100 * (float) dealNum / total) + .setScale(2, RoundingMode.HALF_UP) + .floatValue(); + alertSummary.setRate(rate); + } } catch (Exception e) { log.error(e.getMessage(), e); } diff --git a/web-app/src/app/routes/dashboard/dashboard.component.html b/web-app/src/app/routes/dashboard/dashboard.component.html index da2f7cf..5604be6 100644 --- a/web-app/src/app/routes/dashboard/dashboard.component.html +++ b/web-app/src/app/routes/dashboard/dashboard.component.html @@ -145,7 +145,7 @@ [autoResize]="true" [loading]="alertsLoading" (chartInit)="onAlertNumChartInit($event)" - style="width: 100%; height: 100%" + style="width: 100%; min-height: 300px" >
@@ -156,7 +156,7 @@ [autoResize]="true" [loading]="alertsDealLoading" (chartInit)="onAlertRateChartInit($event)" - style="width: 100%; height: 100%" + style="width: 100%; min-height: 300px" >
diff --git a/web-app/src/app/routes/dashboard/dashboard.component.ts b/web-app/src/app/routes/dashboard/dashboard.component.ts index 7d0c282..b6c9ea3 100644 --- a/web-app/src/app/routes/dashboard/dashboard.component.ts +++ b/web-app/src/app/routes/dashboard/dashboard.component.ts @@ -195,7 +195,7 @@ export class DashboardComponent implements OnInit, OnDestroy { }, data: [ { - value: 0, + value: 100, name: '告警处理率' } ]