|
@@ -362,6 +362,61 @@ func getConfigRefreshData(now time.Time) (sourceEdbInfoListMap map[string][]*edb
|
|
|
fmt.Println("Get ConfigRefreshData End")
|
|
|
return
|
|
|
}
|
|
|
+func needForUpdate(date time.Time, frequency string) bool {
|
|
|
+ //如果当前已经更新最新的数据则停止更新
|
|
|
+ today := time.Now()
|
|
|
+ switch frequency {
|
|
|
+ case "日度":
|
|
|
+ return !date.Equal(today)
|
|
|
+ case "周度":
|
|
|
+ // 获取本周的开始日期(周一)
|
|
|
+ startOfWeek := today.AddDate(0, 0, int(time.Monday-today.Weekday()))
|
|
|
+ return date.Before(startOfWeek)
|
|
|
+ case "旬度":
|
|
|
+ day := today.Day()
|
|
|
+ var beginOfTenDays time.Time
|
|
|
+ if day <= 10 {
|
|
|
+ beginOfTenDays = time.Date(today.Year(), today.Month(), 1, 0, 0, 0, 0, time.Local)
|
|
|
+ return date.Before(beginOfTenDays)
|
|
|
+ } else if day <= 20 {
|
|
|
+ beginOfTenDays = time.Date(today.Year(), today.Month(), 11, 0, 0, 0, 0, time.Local)
|
|
|
+ return date.Before(beginOfTenDays)
|
|
|
+ } else {
|
|
|
+ beginOfTenDays = time.Date(today.Year(), today.Month(), 21, 0, 0, 0, 0, time.Local)
|
|
|
+ return date.Before(beginOfTenDays)
|
|
|
+ }
|
|
|
+ case "月度":
|
|
|
+ beginOfMonth := time.Date(today.Year(), today.Month(), 1, 0, 0, 0, 0, time.Local)
|
|
|
+ return date.Before(beginOfMonth)
|
|
|
+ case "季度":
|
|
|
+ month := today.Month()
|
|
|
+ var beginOfQuarter time.Time
|
|
|
+ if month <= 3 {
|
|
|
+ beginOfQuarter = time.Date(today.Year(), 1, 1, 0, 0, 0, 0, time.Local)
|
|
|
+ } else if month <= 6 {
|
|
|
+ beginOfQuarter = time.Date(today.Year(), 4, 1, 0, 0, 0, 0, time.Local)
|
|
|
+ } else if month <= 9 {
|
|
|
+ beginOfQuarter = time.Date(today.Year(), 7, 1, 0, 0, 0, 0, time.Local)
|
|
|
+ } else {
|
|
|
+ beginOfQuarter = time.Date(today.Year(), 10, 1, 0, 0, 0, 0, time.Local)
|
|
|
+ }
|
|
|
+ return date.Before(beginOfQuarter)
|
|
|
+ case "半年度":
|
|
|
+ month := today.Month()
|
|
|
+ var beginOfHalfYear time.Time
|
|
|
+ if month <= 6 {
|
|
|
+ beginOfHalfYear = time.Date(today.Year(), 1, 1, 0, 0, 0, 0, time.Local)
|
|
|
+ } else {
|
|
|
+ beginOfHalfYear = time.Date(today.Year(), 7, 1, 0, 0, 0, 0, time.Local)
|
|
|
+ }
|
|
|
+ return date.Before(beginOfHalfYear)
|
|
|
+ case "年度":
|
|
|
+ startOfYear := time.Date(today.Year(), 1, 1, 0, 0, 0, 0, time.Local)
|
|
|
+ return date.Before(startOfYear)
|
|
|
+ default:
|
|
|
+ return true
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
// BaseRefreshData
|
|
|
// @Description: 基础数据刷新
|
|
@@ -395,6 +450,9 @@ func BaseRefreshData(wg *sync.WaitGroup, source, subSource int, items []*edb_ref
|
|
|
if v.NoUpdate == 1 {
|
|
|
continue
|
|
|
}
|
|
|
+ if !needForUpdate(v.EndDate, v.Frequency) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
if v.DataRefreshNum > 0 {
|
|
|
dataRefreshNum = v.DataRefreshNum
|
|
|
}
|
|
@@ -422,7 +480,6 @@ func BaseRefreshData(wg *sync.WaitGroup, source, subSource int, items []*edb_ref
|
|
|
}
|
|
|
}
|
|
|
fmt.Println(startDate)
|
|
|
-
|
|
|
// 数据更新
|
|
|
resp, tmpErr := data.RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
|
|
|
if tmpErr != nil {
|