Browse Source

优化横轴

xyxie 1 year ago
parent
commit
583a4b67a8
1 changed files with 4 additions and 21 deletions
  1. 4 21
      services/data/chart_info.go

+ 4 - 21
services/data/chart_info.go

@@ -299,10 +299,7 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 						err = errors.New("获取农历数据失败,Err:" + tmpErr.Error())
 						return
 					}
-
-					endDateTmp := dataList[len(dataList)-1].DataTime
-					endDateForm, _ := time.Parse(utils.FormatDate, endDateTmp)
-					quarterDataList, tErr := GetSeasonEdbInfoDataListByXDateNong(result, latestDate, seasonExtraConfig, calendarPreYear, int(endDateForm.Month()))
+					quarterDataList, tErr := GetSeasonEdbInfoDataListByXDateNong(result, latestDate, seasonExtraConfig, calendarPreYear)
 					if tErr != nil {
 						err = errors.New("获取季节性图表数据失败,Err:" + tErr.Error())
 						return
@@ -517,7 +514,7 @@ func GetSeasonEdbInfoDataListByXDate(dataList []*models.EdbDataList, latestDate
 }
 
 // GetSeasonEdbInfoDataListByXDateNong 季节性图的指标数据根据横轴选择农历时展示
-func GetSeasonEdbInfoDataListByXDateNong(result *models.EdbDataResult, latestDate time.Time, seasonExtraConfig string, calendarPreYear, thisMonth int) (quarterDataListSort models.QuarterDataList, err error) {
+func GetSeasonEdbInfoDataListByXDateNong(result *models.EdbDataResult, latestDate time.Time, seasonExtraConfig string, calendarPreYear int) (quarterDataListSort models.QuarterDataList, err error) {
 	xStartDate := "01-01"
 	xEndDate := "12-31"
 	jumpYear := 0
@@ -636,15 +633,7 @@ func GetSeasonEdbInfoDataListByXDateNong(result *models.EdbDataResult, latestDat
 	}
 
 	//判断哪些点应该落在同一条时间线上
-	maxY := 0
-	for _, lv := range result.List {
-		for _, item := range lv.Items {
-			dataTimeT, _ := time.Parse(utils.FormatDate, item.DataTime)
-			if dataTimeT.Year() > maxY {
-				maxY = dataTimeT.Year()
-			}
-		}
-	}
+	maxY := lastDateT.Year()
 	endTmp := fmt.Sprintf("%d-%s", maxY, xEndDate)
 	endTmpT, _ := time.Parse(utils.FormatDate, endTmp)
 	minY := maxY
@@ -656,14 +645,8 @@ func GetSeasonEdbInfoDataListByXDateNong(result *models.EdbDataResult, latestDat
 
 	for name, dateItem := range dataMap {
 		lv, ok1 := yearDataListMap[dateItem.EndDate.Year()]
-		if thisMonth > 11 {
-			lv, ok1 = yearDataListMap[dateItem.EndDate.Year()-1]
-		}
-		if dateItem.EndDate.Year() > maxY {
+		if dateItem.EndDate.Year() > lastDateT.Year() {
 			lv, ok1 = yearDataListMap[dateItem.StartDate.Year()]
-			if thisMonth > 11 {
-				lv, ok1 = yearDataListMap[dateItem.StartDate.Year()-1]
-			}
 		}
 		if !ok1 {
 			continue