From 9d3eb2a2898378b82d4b6d857c0ad95c7f146fd4 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Wed, 17 Sep 2025 16:53:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=8C=87=E6=A0=87=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=AD=98=E5=82=A8=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- features/pm/kpi_c_report/controller.go | 20 ++++++++++---------- features/pm/kpi_c_report/model.go | 3 +-- features/pm/performance.go | 1 + 3 files changed, 12 insertions(+), 12 deletions(-) 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, } // 发送到匹配的网元