fix: 随机提交时间

This commit is contained in:
cjy 2026-03-11 10:45:24 +08:00
parent 4ac5c334bd
commit b8d75df6e5

View File

@ -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]
}
// 将 submitTimeYYYY-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,