From b8d75df6e55f8b5ae49c7135b45b83ede266ceea Mon Sep 17 00:00:00 2001 From: cjy Date: Wed, 11 Mar 2026 10:45:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=9A=8F=E6=9C=BA=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/service/cast/report.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/service/cast/report.go b/pkg/service/cast/report.go index a56fb10b..561f8672 100644 --- a/pkg/service/cast/report.go +++ b/pkg/service/cast/report.go @@ -18,6 +18,7 @@ import ( "fonchain-fiee/pkg/service/upload" "fonchain-fiee/pkg/utils" "fonchain-fiee/pkg/utils/stime" + "math/rand" "net/url" "os" "path/filepath" @@ -1556,7 +1557,7 @@ func ImportCompetitiveReportHistoryBatch(ctx *gin.Context) { // 第一列:ReportUuid reportUuid := "" if len(row) > 0 { - reportUuid = strings.TrimSpace(row[0]) + reportUuid = utils.CleanString(row[0]) } if reportUuid == "" { _ = excelData.SetCellValue("Sheet1", cellD, "ReportUuid 不能为空") @@ -1566,7 +1567,7 @@ func ImportCompetitiveReportHistoryBatch(ctx *gin.Context) { // 第二列:Title(可为空) title := "" if len(row) > 1 { - title = strings.TrimSpace(row[1]) + title = utils.CleanString(row[1]) } // 第三列:SubmitTime @@ -1575,6 +1576,16 @@ func ImportCompetitiveReportHistoryBatch(ctx *gin.Context) { submitTime = row[2] } + // 将 submitTime(YYYY-MM-DD 00:00:00)加随机 9~15 小时、0~59 分钟、0~59 秒,使提交时间更真实 + if submitTime != "" { + if parsedTime, parseErr := time.Parse("2006-01-02 15:04:05", submitTime); parseErr == nil { + randomDuration := time.Duration(rand.Intn(7)+9)*time.Hour + + time.Duration(rand.Intn(60))*time.Minute + + time.Duration(rand.Intn(60))*time.Second + submitTime = parsedTime.Add(randomDuration).Format("2006-01-02 15:04:05") + } + } + // 构造请求 importReq := &cast.ImportCompetitiveReportHistoryReq{ ReportUuid: reportUuid,