Browse Source

Merge branch 'feature/1.0.5_chartinfo' into debug

xyxie 1 year ago
parent
commit
a24d64f718
1 changed files with 35 additions and 8 deletions
  1. 35 8
      services/data/chart_info.go

+ 35 - 8
services/data/chart_info.go

@@ -849,6 +849,7 @@ func GetSeasonEdbInfoDataListByXDate(dataList []*data_manage.EdbDataList, latest
 	quarterMap := make(map[string][]*data_manage.EdbDataList, 0)
 
 	//整理出日期
+	leftNameFlag := true
 	for currentStartYear := startYear; currentStartYear <= endYear; currentStartYear++ {
 		startStr := fmt.Sprintf("%d-%s", currentStartYear, xStartDate)
 		currentEndYear := currentStartYear
@@ -875,18 +876,30 @@ func GetSeasonEdbInfoDataListByXDate(dataList []*data_manage.EdbDataList, latest
 			//如果最新的日期在起始日之前,则跳出循环
 			break
 		}
+		if startT.Before(lastDateT) && endT.After(lastDateT) {
+			if endYear > currentStartYear {
+				leftNameFlag = false
+			}
+		}
 		if endT.Year() > nowYear {
 			//如果最新的日期比真实年份要大,则数据全部按照最大的年份补齐
 			nowYear = endT.Year()
 		}
 		item := data_manage.QuarterXDateItem{
-			StartDate:   startT,
-			EndDate:     endT,
-			ShowName:    showName,
-			ChartLegend: strconv.Itoa(startT.Year()),
+			StartDate: startT,
+			EndDate:   endT,
+			ShowName:  showName,
 		}
 		dataMap[name] = item
 	}
+	for k, v := range dataMap {
+		if leftNameFlag {
+			v.ChartLegend = strconv.Itoa(v.StartDate.Year())
+		} else {
+			v.ChartLegend = strconv.Itoa(v.EndDate.Year())
+		}
+		dataMap[k] = v
+	}
 
 	for _, v := range dataList {
 		dataTimeT, _ := time.Parse(utils.FormatDate, v.DataTime)
@@ -1016,7 +1029,9 @@ func GetSeasonEdbInfoDataListByXDateNong(result *data_manage.EdbDataResult, late
 	quarterDataList := make([]*data_manage.QuarterData, 0)
 	resultData := make([]*data_manage.QuarterData, 0)
 	quarterMap := make(map[string][]*data_manage.EdbDataList, 0)
+
 	//整理出日期
+	leftNameFlag := true
 	for currentStartYear := startYear; currentStartYear <= endYear; currentStartYear++ {
 		startStr := fmt.Sprintf("%d-%s", currentStartYear, xStartDate)
 		currentEndYear := currentStartYear
@@ -1042,18 +1057,30 @@ func GetSeasonEdbInfoDataListByXDateNong(result *data_manage.EdbDataResult, late
 			//如果最新的日期在起始日之前,则跳出循环
 			break
 		}
+		if startT.Before(lastDateT) && endT.After(lastDateT) {
+			if endYear > currentStartYear {
+				leftNameFlag = false
+			}
+		}
 		if endT.Year() > nowYear {
 			//如果最新的日期比真实年份要大,则数据全部按照最大的年份补齐
 			nowYear = endT.Year()
 		}
 		item := data_manage.QuarterXDateItem{
-			StartDate:   startT,
-			EndDate:     endT,
-			ShowName:    showName,
-			ChartLegend: strconv.Itoa(startT.Year()),
+			StartDate: startT,
+			EndDate:   endT,
+			ShowName:  showName,
 		}
 		dataMap[showName] = item
 	}
+	for k, v := range dataMap {
+		if leftNameFlag {
+			v.ChartLegend = strconv.Itoa(v.StartDate.Year())
+		} else {
+			v.ChartLegend = strconv.Itoa(v.EndDate.Year())
+		}
+		dataMap[k] = v
+	}
 
 	yearDataListMap := make(map[int]*data_manage.EdbDataItems, 0)