|
@@ -454,3 +454,57 @@ func AddIndexRefreshToLpush(filePath string) {
|
|
|
pushLock.Unlock()
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+func IndexUpdateCheck() {
|
|
|
+ //day:周一至周六
|
|
|
+ //week,周三至周五
|
|
|
+ //month:每月月中和月底
|
|
|
+ //season:每个季度的下一个月,月中和月底
|
|
|
+ //year:每个月月初
|
|
|
+ // 频度:日度,周度,月度,季度,年度
|
|
|
+ frequencyBatch := []string{"日度"}
|
|
|
+ //today, _ := time.Parse(utils.FormatDate, "2023-09-01")
|
|
|
+ today := time.Now()
|
|
|
+ todayDate := today.Format(utils.FormatDate)
|
|
|
+ // 是否是周度指标更新的日子
|
|
|
+ if today.Weekday() >= 3 {
|
|
|
+ frequencyBatch = append(frequencyBatch, "周度")
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否是月度指标更新的日子
|
|
|
+ /*tmpT, _ := time.ParseInLocation(utils.FormatDate, today.Format(utils.FormatYearMonth)+"-01", time.Local)
|
|
|
+ lastDate := tmpT.AddDate(0, 1, -1).Format(utils.FormatDate)
|
|
|
+ if lastDate == todayDate {
|
|
|
+ frequencyBatch = append(frequencyBatch, "月度")
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断是否是季度指标更新的日子
|
|
|
+ if lastDate == todayDate && today.Month()%3 == 0 {
|
|
|
+ frequencyBatch = append(frequencyBatch, "季度")
|
|
|
+ }
|
|
|
+ //判断是否是年度指标更新的日子
|
|
|
+ tmpT, _ = time.ParseInLocation(utils.FormatDate, today.Format(utils.FormatYearMonth)+"-01", time.Local)
|
|
|
+ if tmpT.Format(utils.FormatDate) == todayDate {
|
|
|
+ frequencyBatch = append(frequencyBatch, "年度")
|
|
|
+ }*/
|
|
|
+ var req watch.RefreshCheckByDayReq
|
|
|
+ req.Source = 15
|
|
|
+ req.LatestDate = todayDate
|
|
|
+ req.FrequencyBatch = strings.Join(frequencyBatch, ",")
|
|
|
+ ret, err := watch.RefreshCheckByDay(req)
|
|
|
+ if err != nil {
|
|
|
+ global.LOG.Info(utils.APPNAME + " 钢联指标更新检查 出错" + time.Now().Format("2006-01-02 15:04:05") + ";Err:" + err.Error())
|
|
|
+ go alarm_msg.SendAlarmMsg(utils.APPNAME+" 钢联指标更新检查 出错"+time.Now().Format("2006-01-02 15:04:05")+";Err:"+err.Error(), 3)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println(ret.UnUpdateNum)
|
|
|
+ fmt.Println(ret.UpdateNum)
|
|
|
+ halfNum := ret.UpdateNum / 2
|
|
|
+ if ret.UnUpdateNum > halfNum {
|
|
|
+ tip := fmt.Sprintf("%s 钢联指标更新检查:更新数据过少; %s :已更新指标个数:%d, 未更新指标个数%d", utils.APPNAME, todayDate, ret.UpdateNum, ret.UnUpdateNum)
|
|
|
+ global.LOG.Info(tip)
|
|
|
+ go alarm_msg.SendAlarmMsg(tip, 3)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|