fix: 随机提交时间
This commit is contained in:
parent
18e8548b07
commit
f69ffc07f7
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user