2
0

2 کامیت‌ها 3c78e3323a ... dd829b5fb0

نویسنده SHA1 پیام تاریخ
  317699326@qq.com dd829b5fb0 Merge branch 'aj_base_index_refresh' into debug 1 روز پیش
  317699326@qq.com 228b131a1d 数据源新增开始和结束日期 1 روز پیش
6فایلهای تغییر یافته به همراه30 افزوده شده و 10 حذف شده
  1. 8 2
      models/base_from_baiinfo.go
  2. 2 2
      models/base_from_bloomberg.go
  3. 2 2
      models/base_from_business.go
  4. 7 2
      models/base_from_ccf.go
  5. 10 2
      models/base_from_fenwei.go
  6. 1 0
      models/base_from_icpi.go

+ 8 - 2
models/base_from_baiinfo.go

@@ -247,13 +247,19 @@ func GetBaiinfoIndexInfoMaxAndMinInfo(indexCode string) (item *EdbInfoMaxAndMinI
 	o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date,MIN(value) AS min_value,MAX(value) AS max_value FROM base_from_baiinfo_data WHERE index_code=? `
 	err = o.Raw(sql, indexCode).QueryRow(&item)
+
+	var latest_value float64
+	sql = ` SELECT value AS latest_value FROM base_from_baiinfo_data WHERE index_code=? ORDER BY data_time DESC LIMIT 1 `
+	err = o.Raw(sql, indexCode).QueryRow(&latest_value)
+	item.LatestValue = latest_value
+
 	return
 }
 
 func ModifyBaiinfoIndexMaxAndMinInfo(indexCode string, item *EdbInfoMaxAndMinInfo) (err error) {
 	o := orm.NewOrm()
-	sql := ` UPDATE base_from_baiinfo_index SET start_date=?,end_date=?,modify_time=NOW() WHERE index_code=? `
-	_, err = o.Raw(sql, item.MinDate, item.MaxDate, indexCode).Exec()
+	sql := ` UPDATE base_from_baiinfo_index SET start_date=?,end_date=?,latest_value = ?,modify_time=NOW() WHERE index_code=? `
+	_, err = o.Raw(sql, item.MinDate, item.MaxDate, item.LatestValue, indexCode).Exec()
 	return
 }
 

+ 2 - 2
models/base_from_bloomberg.go

@@ -133,8 +133,8 @@ func GetBaseFromBloombergIndexMinMax(indexCode string) (item *EdbInfoMaxAndMinIn
 
 func ModifyBaseFromBloombergIndexMinMax(indexCode string, item *EdbInfoMaxAndMinInfo) (err error) {
 	o := orm.NewOrm()
-	sql := ` UPDATE base_from_bloomberg_index SET start_date = ?, end_date = ?, modify_time = NOW() WHERE index_code = ? `
-	_, err = o.Raw(sql, item.MinDate, item.MaxDate, indexCode).Exec()
+	sql := ` UPDATE base_from_bloomberg_index SET start_date = ?, end_date = ?,latest_value = ?, modify_time = NOW() WHERE index_code = ? `
+	_, err = o.Raw(sql, item.MinDate, item.MaxDate, item.LatestValue, indexCode).Exec()
 	return
 }
 

+ 2 - 2
models/base_from_business.go

@@ -320,11 +320,11 @@ func (m BaseFromBusinessIndex) getEdbInfoMaxAndMinInfoByMysql(edbCode string) (i
 // @return err error
 func (m *BaseFromBusinessIndex) ModifyIndexMaxAndMinInfo(indexCode string, item *EdbInfoMaxAndMinInfo, isIndexUpdateOrAdd bool) (err error) {
 	o := orm.NewOrm()
-	sql := ` UPDATE base_from_business_index SET start_date=?,end_date=?,modify_time=NOW() `
+	sql := ` UPDATE base_from_business_index SET start_date=?,end_date=?,latest_value=?,modify_time=NOW() `
 	if isIndexUpdateOrAdd {
 		sql += `,data_update_time=NOW() `
 	}
 	sql += ` WHERE index_code=?`
-	_, err = o.Raw(sql, item.MinDate, item.MaxDate, indexCode).Exec()
+	_, err = o.Raw(sql, item.MinDate, item.MaxDate, item.LatestValue, indexCode).Exec()
 	return
 }

+ 7 - 2
models/base_from_ccf.go

@@ -233,8 +233,8 @@ func (m *BaseFromCCFIndex) Update(updateCols []string) (err error) {
 
 func (m *BaseFromCCFIndex) ModifyIndexMaxAndMinDate(indexCode string, item *EdbInfoMaxAndMinInfo) (err error) {
 	o := orm.NewOrm()
-	sql := ` UPDATE base_from_ccf_index SET start_date=?,end_date=?,modify_time=NOW() WHERE index_code=? `
-	_, err = o.Raw(sql, item.MinDate, item.MaxDate, indexCode).Exec()
+	sql := ` UPDATE base_from_ccf_index SET start_date=?,end_date=?,latest_value=?,modify_time=NOW() WHERE index_code=? `
+	_, err = o.Raw(sql, item.MinDate, item.MaxDate, item.LatestValue, indexCode).Exec()
 	return
 }
 
@@ -320,6 +320,11 @@ func (m *BaseFromCCFData) GetMaxAndMinDateByIndexCode(indexCode string) (item *E
 	o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date,MIN(value) AS min_value,MAX(value) AS max_value FROM base_from_ccf_data WHERE index_code=? `
 	err = o.Raw(sql, indexCode).QueryRow(&item)
+
+	var latest_value float64
+	sql = ` SELECT value AS latest_value FROM base_from_ccf_data WHERE index_code=? ORDER BY data_time DESC LIMIT 1 `
+	err = o.Raw(sql, indexCode).QueryRow(&latest_value)
+	item.LatestValue = latest_value
 	return
 }
 

+ 10 - 2
models/base_from_fenwei.go

@@ -234,8 +234,8 @@ func (m *BaseFromFenweiIndex) Update(updateCols []string) (err error) {
 
 func (m *BaseFromFenweiIndex) ModifyIndexMaxAndMinDate(indexCode string, item *EdbInfoMaxAndMinInfo) (err error) {
 	o := orm.NewOrm()
-	sql := ` UPDATE base_from_fenwei_index SET start_date=?,end_date=?,modify_time=NOW() WHERE index_code=? `
-	_, err = o.Raw(sql, item.MinDate, item.MaxDate, indexCode).Exec()
+	sql := ` UPDATE base_from_fenwei_index SET start_date=?,end_date=?,latest_value=?,modify_time=NOW() WHERE index_code=? `
+	_, err = o.Raw(sql, item.MinDate, item.MaxDate, item.LatestValue, indexCode).Exec()
 	return
 }
 
@@ -327,6 +327,14 @@ func (y *BaseFromFenweiData) GetMaxAndMinDateByIndexCode(indexCode string) (item
 	o := orm.NewOrm()
 	sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date,MIN(value) AS min_value,MAX(value) AS max_value FROM base_from_fenwei_data WHERE index_code=? `
 	err = o.Raw(sql, indexCode).QueryRow(&item)
+	// 获取最新值
+	var lastVal float64
+	sql = ` SELECT value AS latest_value FROM base_from_fenwei_data WHERE index_code = ? ORDER BY data_time DESC LIMIT 1 `
+	err = o.Raw(sql, indexCode).QueryRow(&lastVal)
+	if err != nil {
+		return
+	}
+	item.LatestValue = lastVal
 	return
 }
 

+ 1 - 0
models/base_from_icpi.go

@@ -17,6 +17,7 @@ type BaseFromIcpiIndex struct {
 	Frequency              string    `description:"频度"`
 	StartDate              time.Time `description:"开始日期"`
 	EndDate                time.Time `description:"结束日期"`
+	LatestValue            float64   `description:"最新值"`
 	CreateTime             time.Time `description:"创建时间"`
 	ModifyTime             time.Time `description:"修改时间"`
 }