瀏覽代碼

Merge branch 'ETA_1.9.4' into debug

zwxi 8 月之前
父節點
當前提交
569cf173bd
共有 1 個文件被更改,包括 33 次插入2 次删除
  1. 33 2
      services/data/chart_info.go

+ 33 - 2
services/data/chart_info.go

@@ -823,7 +823,27 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 			}
 
 		} else if chartType == 2 && item.IsAxis == 0 {
-			// 右轴数据处理,只要最新一年
+			// 右轴数据处理
+			xStartDate := "01-01"
+
+			jumpYear := 0
+			var seasonExtra data_manage.SeasonExtraItem
+			if seasonExtraConfig != "" {
+				err = json.Unmarshal([]byte(seasonExtraConfig), &seasonExtra)
+				if err != nil {
+					return
+				}
+			}
+
+			if seasonExtra.XStartDate != "" {
+				xStartDate = seasonExtra.XStartDate
+				jumpYear = seasonExtra.JumpYear
+			}
+
+			length := len(dataList)
+			if length == 0 {
+				return
+			}
 			latestDate, tmpErr := time.Parse(utils.FormatDate, v.LatestDate)
 			if tmpErr != nil {
 				//item.DataList = dataList
@@ -833,6 +853,17 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 				err = errors.New(fmt.Sprint("获取最后实际数据的日期失败,Err:" + tmpErr.Error() + ";LatestDate:" + v.LatestDate))
 				return
 			}
+
+			var rightAxisDate time.Time
+			if jumpYear == 1 {
+				latestDate = latestDate.AddDate(-1, 0, 0)
+				latestDateStr := fmt.Sprintf("%d-%s", latestDate.Year(),xStartDate)
+				rightAxisDate, err = time.Parse(utils.FormatDate, latestDateStr)
+				if err != nil {
+					return
+				}
+			}
+
 			newDataList := make([]*data_manage.EdbDataList, 0)
 			for _, v := range dataList {
 				dataTime, e := time.Parse(utils.FormatDate, v.DataTime)
@@ -840,7 +871,7 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 					err = errors.New("季节性图处理右轴指标数据转换日期失败,Err:" + e.Error())
 					return
 				}
-				if dataTime.Year() == latestDate.Year() {
+				if dataTime.Equal(rightAxisDate) || dataTime.After(rightAxisDate) {
 					newDataList = append(newDataList, v)
 				}
 			}