diff --git a/src/modules/network_data/service/kpi_c_report.go b/src/modules/network_data/service/kpi_c_report.go index 4f5bc252..6e30181c 100644 --- a/src/modules/network_data/service/kpi_c_report.go +++ b/src/modules/network_data/service/kpi_c_report.go @@ -22,6 +22,12 @@ type KpiCReport struct { // FindKPI 通过网元指标数据信息 func (s KpiCReport) FindData(query model.KPICQuery) []map[string]any { + // 标题单位映射 + kpicTitles := s.kpiCReportRepository.SelectKPITitle(query.NeType) + kpicTitleUnitMap := map[string]string{} + for _, v := range kpicTitles { + kpicTitleUnitMap[v.KpiId] = v.Unit + } // 原始数据 rows := s.kpiCReportRepository.SelectKPI(query) if len(rows) <= 0 { @@ -107,6 +113,17 @@ func (s KpiCReport) FindData(query model.KPICQuery) []map[string]any { } } } + // 处理单位 + for _, kpiId := range kpiIds { + unit, ok := kpicTitleUnitMap[kpiId] + if !ok { + continue + } + // "Mbps" "%" + if unit == "%" { + startItem[kpiId] = startItem[kpiId].(float64) / float64(len(records)) + } + } } data = append(data, startItem) }