fix: 自定义指标数据统计处理单位累加问题
This commit is contained in:
@@ -22,6 +22,12 @@ type KpiCReport struct {
|
|||||||
|
|
||||||
// FindKPI 通过网元指标数据信息
|
// FindKPI 通过网元指标数据信息
|
||||||
func (s KpiCReport) FindData(query model.KPICQuery) []map[string]any {
|
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)
|
rows := s.kpiCReportRepository.SelectKPI(query)
|
||||||
if len(rows) <= 0 {
|
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)
|
data = append(data, startItem)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user