fix: 修复自定义指标创建时间异常存储错误
This commit is contained in:
@@ -42,11 +42,11 @@ func (k *KpiCReport) Get(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if querys.StartTime != "" {
|
if querys.StartTime != "" {
|
||||||
conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) >= ?")
|
conditions = append(conditions, "created_at >= ?")
|
||||||
params = append(params, querys.StartTime)
|
params = append(params, querys.StartTime)
|
||||||
}
|
}
|
||||||
if querys.EndTime != "" {
|
if querys.EndTime != "" {
|
||||||
conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) <= ?")
|
conditions = append(conditions, "created_at <= ?")
|
||||||
params = append(params, querys.EndTime)
|
params = append(params, querys.EndTime)
|
||||||
}
|
}
|
||||||
conditions = append(conditions, "kpi_values != 'null'")
|
conditions = append(conditions, "kpi_values != 'null'")
|
||||||
@@ -109,11 +109,11 @@ func (k *KpiCReport) GetReport2FE(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if querys.StartTime != "" {
|
if querys.StartTime != "" {
|
||||||
conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) >= ?")
|
conditions = append(conditions, "created_at >= ?")
|
||||||
params = append(params, querys.StartTime)
|
params = append(params, querys.StartTime)
|
||||||
}
|
}
|
||||||
if querys.EndTime != "" {
|
if querys.EndTime != "" {
|
||||||
conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) <= ?")
|
conditions = append(conditions, "created_at <= ?")
|
||||||
params = append(params, querys.EndTime)
|
params = append(params, querys.EndTime)
|
||||||
}
|
}
|
||||||
conditions = append(conditions, "kpi_values != 'null'")
|
conditions = append(conditions, "kpi_values != 'null'")
|
||||||
@@ -150,8 +150,8 @@ func (k *KpiCReport) GetReport2FE(c *gin.Context) {
|
|||||||
// 支持的排序字段映射
|
// 支持的排序字段映射
|
||||||
fieldGetters := map[string]func(*KpiCReport) any{
|
fieldGetters := map[string]func(*KpiCReport) any{
|
||||||
"id": func(row *KpiCReport) any { return row.ID },
|
"id": func(row *KpiCReport) any { return row.ID },
|
||||||
"timeGroup": func(row *KpiCReport) any { return row.CreatedAt.Unix() },
|
"timeGroup": func(row *KpiCReport) any { return row.CreatedAt },
|
||||||
"created_at": func(row *KpiCReport) any { return row.CreatedAt.Unix() },
|
"created_at": func(row *KpiCReport) any { return row.CreatedAt },
|
||||||
// 可添加更多支持的字段
|
// 可添加更多支持的字段
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,11 +234,11 @@ func (k *KpiCReport) GetTotalList(c *gin.Context) {
|
|||||||
dbg := dborm.DefaultDB().Table(tableName)
|
dbg := dborm.DefaultDB().Table(tableName)
|
||||||
|
|
||||||
if querys.StartTime != "" {
|
if querys.StartTime != "" {
|
||||||
conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) >= ?")
|
conditions = append(conditions, "created_at >= ?")
|
||||||
params = append(params, querys.StartTime)
|
params = append(params, querys.StartTime)
|
||||||
}
|
}
|
||||||
if querys.EndTime != "" {
|
if querys.EndTime != "" {
|
||||||
conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) <= ?")
|
conditions = append(conditions, "created_at <= ?")
|
||||||
params = append(params, querys.EndTime)
|
params = append(params, querys.EndTime)
|
||||||
}
|
}
|
||||||
conditions = append(conditions, "kpi_values != 'null'")
|
conditions = append(conditions, "kpi_values != 'null'")
|
||||||
@@ -303,11 +303,11 @@ func (k *KpiCReport) Total(c *gin.Context) {
|
|||||||
dbg := dborm.DefaultDB().Table(tableName)
|
dbg := dborm.DefaultDB().Table(tableName)
|
||||||
|
|
||||||
if querys.StartTime != "" {
|
if querys.StartTime != "" {
|
||||||
conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) >= ?")
|
conditions = append(conditions, "created_at >= ?")
|
||||||
params = append(params, querys.StartTime)
|
params = append(params, querys.StartTime)
|
||||||
}
|
}
|
||||||
if querys.EndTime != "" {
|
if querys.EndTime != "" {
|
||||||
conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) <= ?")
|
conditions = append(conditions, "created_at <= ?")
|
||||||
params = append(params, querys.EndTime)
|
params = append(params, querys.EndTime)
|
||||||
}
|
}
|
||||||
conditions = append(conditions, "kpi_values != 'null'")
|
conditions = append(conditions, "kpi_values != 'null'")
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type KpiCVal struct {
|
type KpiCVal struct {
|
||||||
@@ -26,7 +25,7 @@ type KpiCReport struct {
|
|||||||
Index int16 `gorm:"column:index" json:"index"`
|
Index int16 `gorm:"column:index" json:"index"`
|
||||||
Granularity *int8 `gorm:"column:granularity;default:60" json:"granularity,omitempty"` //Time granualarity: 5/10/.../60/300 (second)
|
Granularity *int8 `gorm:"column:granularity;default:60" json:"granularity,omitempty"` //Time granualarity: 5/10/.../60/300 (second)
|
||||||
KpiValues KpiCValues `gorm:"column:kpi_values;type:json" json:"kpiValues,omitempty"`
|
KpiValues KpiCValues `gorm:"column:kpi_values;type:json" json:"kpiValues,omitempty"`
|
||||||
CreatedAt *time.Time `gorm:"column:created_at;default:current_timestamp()" json:"createdAt,omitempty"`
|
CreatedAt int64 `gorm:"column:created_at" json:"createdAt,omitempty"`
|
||||||
TenantID *string `gorm:"column:tenant_id;default:NULL" json:"tenantID,omitempty"`
|
TenantID *string `gorm:"column:tenant_id;default:NULL" json:"tenantID,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -292,6 +292,7 @@ func PostKPIReportFromNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
Index: int16(kpiData.Index),
|
Index: int16(kpiData.Index),
|
||||||
Granularity: &kpiData.Granularity,
|
Granularity: &kpiData.Granularity,
|
||||||
TenantID: &kpiData.TenantID,
|
TenantID: &kpiData.TenantID,
|
||||||
|
CreatedAt: kpiData.CreatedAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送到匹配的网元
|
// 发送到匹配的网元
|
||||||
|
|||||||
Reference in New Issue
Block a user