Bladeren bron

睿姿得爬取-配置更新

gmy 1 maand geleden
bovenliggende
commit
4716b57c66
3 gewijzigde bestanden met toevoegingen van 13 en 2 verwijderingen
  1. 1 1
      services/liangyou/commodity_liangyou.go
  2. 1 1
      services/ruizide/data_processor.go
  3. 11 0
      utils/date_util.go

+ 1 - 1
services/liangyou/commodity_liangyou.go

@@ -505,7 +505,7 @@ func processReport(ctx context.Context, product string, category string, reportU
 						EdbCode:       edbIndexData.EdbCode,
 						DataTime:      baseFromLyData.DataTime,
 						Value:         baseFromLyData.Value,
-						DataTimestamp: uint64(time.Now().UnixNano() / int64(time.Millisecond)),
+						DataTimestamp: uint64(utils.StringToTimeFormat(baseFromLyData.DataTime, utils.FormatDate).UnixMilli()),
 					}
 					edbDataLyList = append(edbDataLyList, edbDataLy)
 				}

+ 1 - 1
services/ruizide/data_processor.go

@@ -373,7 +373,7 @@ func fileResolver() {
 						EdbCode:       index.IndexCode,
 						DataTime:      index.DataTime,
 						Value:         index.Value,
-						DataTimestamp: uint64(time.Now().UnixNano() / int64(time.Millisecond)),
+						DataTimestamp: uint64(utils.StringToTimeFormat(index.DataTime, utils.FormatDate).UnixMilli()),
 					}
 					edbDataList = append(edbDataList, edbDataRzd)
 				}

+ 11 - 0
utils/date_util.go

@@ -184,6 +184,17 @@ func StringToTime(dateText string) (time.Time, error) {
 	return reportDate, nil
 }
 
+// StringToTimeFormat 转换时间格式 string --> time.Time
+func StringToTimeFormat(dateText string, format string) time.Time {
+	// 解析日期
+	reportDate, err := time.Parse(format, strings.TrimSpace(dateText))
+	if err != nil {
+		return time.Time{}
+	}
+
+	return reportDate
+}
+
 // StringToTimeZero string 类型时间转换为 time dateText 格式为 2024-08-03 --> 2024-08-03 00:00:00
 func StringToTimeZero(dateText string) (time.Time, error) {
 	// 解析日期