Browse Source

汾渭更新时间

gmy 2 months ago
parent
commit
9065dfb180
1 changed files with 43 additions and 41 deletions
  1. 43 41
      controllers/data_manage/fenwei_data.go

+ 43 - 41
controllers/data_manage/fenwei_data.go

@@ -172,52 +172,54 @@ 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)
-		product.FenweiIndexId = v.FenweiIndexId
-		product.ClassifyId = v.ClassifyId
-		product.Unit = v.Unit
-		product.IndexCode = v.IndexCode
-		product.IndexName = v.IndexName
-		product.Frequency = v.Frequency
-		product.CreateTime = v.CreateTime
-
-		if lastModifyTimeMap[v.IndexCode] != "" {
-			product.ModifyTime = lastModifyTimeMap[v.IndexCode]
-		} else {
-			product.ModifyTime = ""
+	if indexes != nil {
+		// 获取指标数据最新更新时间
+		lastModifyTimeList, err := data_manage.GetFenWeiDataLastModifyTimeList(indexCodes)
+		if err != nil {
+			return
 		}
-
-		edbInfo := edbCodeMap[v.IndexCode]
-		if edbInfo != nil {
-			product.EdbInfoId = edbInfo.EdbInfoId
+		lastModifyTimeMap := make(map[string]string)
+		for _, v := range lastModifyTimeList {
+			lastModifyTimeMap[v.IndexCode] = v.ModifyTime
 		}
 
-		total := countMap[v.IndexCode]
-		page := paging.GetPaging(currentIndex, pageSize, total)
-		dataList, e := data_manage.GetFenweiIndexData(v.IndexCode, startSize, pageSize)
-		if e != nil {
-			br.Msg = "获取数据失败"
-			br.ErrMsg = "获取指标数据失败,Err:" + e.Error()
-			return
-		}
-		if dataList == nil {
-			dataList = make([]*data_manage.BaseFromFenweiData, 0)
+		for _, v := range indexes {
+			product := new(data_manage.BaseFromFenweiIndexList)
+			product.FenweiIndexId = v.FenweiIndexId
+			product.ClassifyId = v.ClassifyId
+			product.Unit = v.Unit
+			product.IndexCode = v.IndexCode
+			product.IndexName = v.IndexName
+			product.Frequency = v.Frequency
+			product.CreateTime = v.CreateTime
+
+			if lastModifyTimeMap[v.IndexCode] != "" {
+				product.ModifyTime = lastModifyTimeMap[v.IndexCode]
+			} else {
+				product.ModifyTime = ""
+			}
+
+			edbInfo := edbCodeMap[v.IndexCode]
+			if edbInfo != nil {
+				product.EdbInfoId = edbInfo.EdbInfoId
+			}
+
+			total := countMap[v.IndexCode]
+			page := paging.GetPaging(currentIndex, pageSize, total)
+			dataList, e := data_manage.GetFenweiIndexData(v.IndexCode, startSize, pageSize)
+			if e != nil {
+				br.Msg = "获取数据失败"
+				br.ErrMsg = "获取指标数据失败,Err:" + e.Error()
+				return
+			}
+			if dataList == nil {
+				dataList = make([]*data_manage.BaseFromFenweiData, 0)
+			}
+			product.DataList = dataList
+			product.Paging = page
+			resultList = append(resultList, product)
 		}
-		product.DataList = dataList
-		product.Paging = page
-		resultList = append(resultList, product)
 	}
 
 	br.Ret = 200