fix: 黄金指标5s数据sql调整
This commit is contained in:
@@ -49,6 +49,10 @@ func (s *PerfKPIController) GoldKPI(c *gin.Context) {
|
|||||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if querys.Interval < 5 || querys.Interval > 3600 {
|
||||||
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 查询网元获取IP
|
// 查询网元获取IP
|
||||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(querys.NeType, querys.NeID)
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(querys.NeType, querys.NeID)
|
||||||
|
|||||||
@@ -43,9 +43,15 @@ func (r *PerfKPIImpl) SelectGoldKPI(query model.GoldKPIQuery, kpiIds []string) [
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 查询字段列
|
// 查询字段列
|
||||||
timeFormat := "DATE_FORMAT(gk.start_time, '%Y-%m-%d %H:')"
|
timeFormat := "DATE_FORMAT(gk.start_time, '%Y-%m-%d %H:%i:')"
|
||||||
minuteGroup := fmt.Sprintf("LPAD(FLOOR(SECOND(gk.start_time) / %d) * %d, 2, '0')", query.Interval, query.Interval)
|
secondGroup := fmt.Sprintf("LPAD(FLOOR(SECOND(gk.start_time) / %d) * %d, 2, '0')", query.Interval, query.Interval)
|
||||||
groupByField := fmt.Sprintf("CONCAT( %s, %s ) AS timeGroup", timeFormat, minuteGroup)
|
groupByField := fmt.Sprintf("CONCAT( %s, %s ) AS timeGroup", timeFormat, secondGroup)
|
||||||
|
if query.Interval > 60 {
|
||||||
|
minute := query.Interval / 60
|
||||||
|
timeFormat = "DATE_FORMAT(gk.start_time, '%Y-%m-%d %H:')"
|
||||||
|
minuteGroup := fmt.Sprintf("LPAD(FLOOR(MINUTE(gk.start_time) / %d) * %d, 2, '0')", minute, minute)
|
||||||
|
groupByField = fmt.Sprintf("CONCAT( %s, %s ) AS timeGroup", timeFormat, minuteGroup)
|
||||||
|
}
|
||||||
var fields = []string{
|
var fields = []string{
|
||||||
groupByField,
|
groupByField,
|
||||||
"min(CASE WHEN gk.index != '' THEN gk.index ELSE 0 END) AS startIndex",
|
"min(CASE WHEN gk.index != '' THEN gk.index ELSE 0 END) AS startIndex",
|
||||||
|
|||||||
Reference in New Issue
Block a user