Browse Source

Merge branch 'eta_custom_bug_7034_fenwei_1224@guomengyuan' into debug

# Conflicts:
#	controllers/data_manage/fenwei_data.go
#	models/data_manage/base_from_fenwei.go
gmy 5 months ago
parent
commit
da8bbedb93
2 changed files with 15 additions and 13 deletions
  1. 11 9
      controllers/data_manage/fenwei_data.go
  2. 4 4
      models/data_manage/base_from_fenwei.go

+ 11 - 9
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,15 +192,7 @@ func (this *EdbInfoController) FenweiIndexData() {
 		product.IndexName = v.IndexName
 		product.Frequency = v.Frequency
 		product.CreateTime = v.CreateTime
-
-		// 获取指标数据最新更新时间
-		modifyTime, err := data_manage.GetFenWeiDataLastModifyTime(v.IndexCode)
-		if err != nil {
-			br.Msg = "获取数据失败"
-			br.ErrMsg = "获取指标数据最新更新时间失败, Err:" + err.Error()
-			return
-		}
-		product.ModifyTime = modifyTime
+		product.ModifyTime = lastModifyTimeMap[v.IndexCode]
 
 		edbInfo := edbCodeMap[v.IndexCode]
 		if edbInfo != nil {

+ 4 - 4
models/data_manage/base_from_fenwei.go

@@ -284,10 +284,10 @@ func GetFenWeiIndexInfoCount(condition string, pars []interface{}) (count int, e
 	return
 }
 
-// GetFenWeiDataLastModifyTime 获取指标数据最新更新时间
-func GetFenWeiDataLastModifyTime(indexCode string) (lastModifyTime string, err error) {
+// 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")
-	sql := ` SELECT MAX(modify_time) AS last_modify_time FROM base_from_fenwei_data WHERE index_code=? `
-	err = o.Raw(sql, indexCode).QueryRow(&lastModifyTime)
+	_, err = o.Raw(sql, indexCodes).QueryRows(&items)
 	return
 }