Browse Source

汾渭更新时间

gmy 2 months ago
parent
commit
a72fcee404
2 changed files with 19 additions and 1 deletions
  1. 11 1
      controllers/data_manage/fenwei_data.go
  2. 8 0
      models/data_manage/base_from_fenwei.go

+ 11 - 1
controllers/data_manage/fenwei_data.go

@@ -172,6 +172,16 @@ func (this *EdbInfoController) FenweiIndexData() {
 		edbCodeMap[v.EdbCode] = v
 	}
 
+	// 获取指标数据最新更新时间
+	lastModifyTimeList, err := data_manage.GetFenWeiDataLastModifyTimeList(indexCodes)
+	if err != nil {
+		return
+	}
+	lastModifyTimeMap := make(map[string]string)
+	for _, v := range lastModifyTimeList {
+		lastModifyTimeMap[v.IndexCode] = v.ModifyTime
+	}
+
 	resultList := make([]*data_manage.BaseFromFenweiIndexList, 0)
 	for _, v := range indexes {
 		product := new(data_manage.BaseFromFenweiIndexList)
@@ -182,7 +192,7 @@ func (this *EdbInfoController) FenweiIndexData() {
 		product.IndexName = v.IndexName
 		product.Frequency = v.Frequency
 		product.CreateTime = v.CreateTime
-		product.ModifyTime = v.ModifyTime
+		product.ModifyTime = lastModifyTimeMap[v.IndexCode]
 
 		edbInfo := edbCodeMap[v.IndexCode]
 		if edbInfo != nil {

+ 8 - 0
models/data_manage/base_from_fenwei.go

@@ -283,3 +283,11 @@ func GetFenWeiIndexInfoCount(condition string, pars []interface{}) (count int, e
 	err = o.Raw(sql, pars).QueryRow(&count)
 	return
 }
+
+// GetFenWeiDataLastModifyTimeList 查询指标数据最新更新时间
+func GetFenWeiDataLastModifyTimeList(indexCodes []string) (items []*BaseFromFenweiData, err error) {
+	sql := ` SELECT MAX(modify_time) AS modify_time, index_code FROM base_from_fenwei_data WHERE index_code IN(` + utils.GetOrmInReplace(len(indexCodes)) + `) GROUP BY index_code `
+	o := orm.NewOrmUsingDB("data")
+	_, err = o.Raw(sql, indexCodes).QueryRows(&items)
+	return
+}