Bläddra i källkod

嘉悦-同步增量指标优化

hsun 1 år sedan
förälder
incheckning
125a670e59
2 ändrade filer med 12 tillägg och 2 borttagningar
  1. 6 0
      config/config.go
  2. 6 2
      services/index_data/jiayue_platform.go

+ 6 - 0
config/config.go

@@ -6,6 +6,7 @@ type Config struct {
 	Mysql    Mysql    `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
 	Redis    Redis    `mapstructure:"redis" json:"redis" yaml:"redis"`
 	OracleJY OracleJY `mapstructure:"oracle_jy" json:"oracle_jy" yaml:"oracle_jy"`
+	Business Business `mapstructure:"business" json:"business" yaml:"business"`
 }
 
 // Serve gin服务配置
@@ -65,3 +66,8 @@ type OracleJY struct {
 	Password string `mapstructure:"password" json:"password" yaml:"password" description:"oracle数据库密码"`
 	LibDir   string `mapstructure:"lib_dir" json:"lib_dir" yaml:"lib_dir" description:"oracle数据库组件"`
 }
+
+// Business 商家的配置
+type Business struct {
+	JiaYueIndexSyncMinute int `mapstructure:"jiayue-index-sync-minute" json:"jiayue-index-sync-minute" yaml:"jiayue-index-sync-minute" description:"嘉悦同步N分钟前至现在的指标(负数)"`
+}

+ 6 - 2
services/index_data/jiayue_platform.go

@@ -209,8 +209,12 @@ func GetNewIndexAndDataFromJiaYue() (indexList []*response.IndexResp, err error)
 
 	indexCond := ` 1=1`
 	indexPars := make([]interface{}, 0)
-	// TODO:查询半小时前至现在新增指标(具体时间待确定)
-	timeBefore := time.Now().Local().Add(-3 * time.Minute).Format(utils.FormatDateTime)
+	// 同步多久前至今的新指标
+	m := global.CONFIG.Business.JiaYueIndexSyncMinute
+	if m <= 0 {
+		m = -30 // 默认半小时
+	}
+	timeBefore := time.Now().Local().Add(time.Duration(m) * time.Minute).Format(utils.FormatDateTime)
 	indexCond += ` AND CREATE_TIME >= TO_DATE (:1, 'yyyy-mm-dd hh24:mi:ss') `
 	indexPars = append(indexPars, timeBefore)