|
@@ -366,6 +366,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: 基础数据刷新
|
|
@@ -399,6 +454,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
|
|
|
}
|
|
@@ -426,7 +484,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 {
|
|
@@ -682,7 +739,7 @@ func DisableEdbRefresh(cont context.Context) (err error) {
|
|
|
utils.Rc.Delete(cacheKey)
|
|
|
}
|
|
|
if err != nil {
|
|
|
- tips := "DisableEdbRefresh-钢联化工和wind指标设置成禁止刷新失败, ErrMsg:\n" + err.Error()
|
|
|
+ tips := "DisableEdbRefresh-钢联化工、wind、彭博、彭博财务、同花顺指标设置成禁止刷新失败, ErrMsg:\n" + err.Error()
|
|
|
utils.FileLog.Info(tips)
|
|
|
go alarm_msg.SendAlarmMsg(tips, 3)
|
|
|
}
|
|
@@ -791,12 +848,12 @@ func DisableEdbRefresh(cont context.Context) (err error) {
|
|
|
}
|
|
|
|
|
|
if rule.EdbStopDays > 0 {
|
|
|
- // 查询钢联和wind来源的指标
|
|
|
+ // 查询钢联和wind、彭博、彭博财务、同花顺来源的指标
|
|
|
edbEndDate := now.AddDate(0, 0, -rule.EdbStopDays+1).Format(utils.FormatDate)
|
|
|
|
|
|
- condition := ` AND no_update=0 AND source in (?,?) AND ((create_time < ? and set_update_time is null) or set_update_time < ? )`
|
|
|
+ condition := ` AND no_update=0 AND source in (?,?,?,?,?) AND ((create_time < ? and set_update_time is null) or set_update_time < ? )`
|
|
|
var pars []interface{}
|
|
|
- pars = append(pars, utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_WIND, edbEndDate, edbEndDate)
|
|
|
+ pars = append(pars, utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_WIND, utils.DATA_SOURCE_PB_FINANCE, utils.DATA_SOURCE_PB, utils.DATA_SOURCE_THS, edbEndDate, edbEndDate)
|
|
|
// 查询钢联化工指标和wind指标 分批查询,先查总数,再查列表
|
|
|
totalCount, e := data_manage.GetEdbInfoCountByCondition(condition, pars)
|
|
|
if e != nil {
|