diff --git a/features/pm/kpi_c_report/controller.go b/features/pm/kpi_c_report/controller.go index 3efc2531..09530358 100644 --- a/features/pm/kpi_c_report/controller.go +++ b/features/pm/kpi_c_report/controller.go @@ -42,11 +42,11 @@ func (k *KpiCReport) Get(c *gin.Context) { return } if querys.StartTime != "" { - conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) >= ?") + conditions = append(conditions, "created_at >= ?") params = append(params, querys.StartTime) } if querys.EndTime != "" { - conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) <= ?") + conditions = append(conditions, "created_at <= ?") params = append(params, querys.EndTime) } conditions = append(conditions, "kpi_values != 'null'") @@ -109,11 +109,11 @@ func (k *KpiCReport) GetReport2FE(c *gin.Context) { return } if querys.StartTime != "" { - conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) >= ?") + conditions = append(conditions, "created_at >= ?") params = append(params, querys.StartTime) } if querys.EndTime != "" { - conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) <= ?") + conditions = append(conditions, "created_at <= ?") params = append(params, querys.EndTime) } conditions = append(conditions, "kpi_values != 'null'") @@ -150,8 +150,8 @@ func (k *KpiCReport) GetReport2FE(c *gin.Context) { // 支持的排序字段映射 fieldGetters := map[string]func(*KpiCReport) any{ "id": func(row *KpiCReport) any { return row.ID }, - "timeGroup": func(row *KpiCReport) any { return row.CreatedAt.Unix() }, - "created_at": 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 }, // 可添加更多支持的字段 } @@ -234,11 +234,11 @@ func (k *KpiCReport) GetTotalList(c *gin.Context) { dbg := dborm.DefaultDB().Table(tableName) if querys.StartTime != "" { - conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) >= ?") + conditions = append(conditions, "created_at >= ?") params = append(params, querys.StartTime) } if querys.EndTime != "" { - conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) <= ?") + conditions = append(conditions, "created_at <= ?") params = append(params, querys.EndTime) } conditions = append(conditions, "kpi_values != 'null'") @@ -303,11 +303,11 @@ func (k *KpiCReport) Total(c *gin.Context) { dbg := dborm.DefaultDB().Table(tableName) if querys.StartTime != "" { - conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) >= ?") + conditions = append(conditions, "created_at >= ?") params = append(params, querys.StartTime) } if querys.EndTime != "" { - conditions = append(conditions, "(UNIX_TIMESTAMP(created_at) * 1000) <= ?") + conditions = append(conditions, "created_at <= ?") params = append(params, querys.EndTime) } conditions = append(conditions, "kpi_values != 'null'") diff --git a/features/pm/kpi_c_report/model.go b/features/pm/kpi_c_report/model.go index 512fb342..25d54097 100644 --- a/features/pm/kpi_c_report/model.go +++ b/features/pm/kpi_c_report/model.go @@ -4,7 +4,6 @@ import ( "database/sql/driver" "encoding/json" "fmt" - "time" ) type KpiCVal struct { @@ -26,7 +25,7 @@ type KpiCReport struct { Index int16 `gorm:"column:index" json:"index"` 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"` - 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"` } diff --git a/features/pm/performance.go b/features/pm/performance.go index 135ace03..e19dbb0a 100644 --- a/features/pm/performance.go +++ b/features/pm/performance.go @@ -292,6 +292,7 @@ func PostKPIReportFromNF(w http.ResponseWriter, r *http.Request) { Index: int16(kpiData.Index), Granularity: &kpiData.Granularity, TenantID: &kpiData.TenantID, + CreatedAt: kpiData.CreatedAt, } // 发送到匹配的网元