xyxie 10 сар өмнө
parent
commit
994c14274f
1 өөрчлөгдсөн 56 нэмэгдсэн , 39 устгасан
  1. 56 39
      controllers/chart_info.go

+ 56 - 39
controllers/chart_info.go

@@ -5,7 +5,6 @@ import (
 	"eta/eta_forum_admin/models"
 	"eta/eta_forum_admin/services"
 	"eta/eta_forum_admin/utils"
-	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"strconv"
 	"strings"
@@ -44,54 +43,53 @@ func (this *ChartInfoController) ChartInfoDetail() {
 		return
 	}
 	chartInfoId, _ := this.GetInt("ChartInfoId")
+	edbInfoId := this.GetString("EdbInfoId")
+
+	var err error
+	chartInfo := new(models.ChartInfoView)
+	chartInfo.HaveOperaAuth = true
 
-	dateType, _ := this.GetInt("DateType")
-	fmt.Println("dateType:", dateType)
-	if dateType <= 0 {
-		dateType = 3
+	if chartInfoId <= 0 {
+		br.Msg = "请选择图表"
+		return
+	}
+	chartInfo, err = models.GetChartInfoViewById(chartInfoId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Msg = "该图表已删除,自动查看下一图表"
+			br.ErrMsg = "该图表已删除,自动查看下一图表,Err:" + err.Error()
+			br.Ret = 406
+			return
+		}
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
+		return
 	}
+	chartType := chartInfo.ChartType
 
-	startDate := this.GetString("StartDate")
-	endDate := this.GetString("EndDate")
-	startYear, _ := this.GetInt("StartYear")
+	startDate := chartInfo.StartDate
+	endDate := chartInfo.EndDate
+	seasonStartDate := chartInfo.SeasonStartDate
+	seasonEndDate := chartInfo.SeasonEndDate
+	startYear := chartInfo.StartYear
 
-	edbInfoId := this.GetString("EdbInfoId")
-	chartType, _ := this.GetInt("ChartType")
+	calendar := chartInfo.Calendar
 
-	calendar := this.GetString("Calendar")
 	if calendar == "" {
 		calendar = "公历"
 	}
 
-	var err error
-	chartInfo := new(models.ChartInfoView)
-	chartInfo.HaveOperaAuth = true
-
-	if chartInfoId > 0 {
-		chartInfo, err = models.GetChartInfoViewById(chartInfoId)
-		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
-				br.Msg = "该图表已删除,自动查看下一图表"
-				br.ErrMsg = "该图表已删除,自动查看下一图表,Err:" + err.Error()
-				br.Ret = 406
-				return
-			}
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
-			return
-		}
-		chartType = chartInfo.ChartType
+	dateType := chartInfo.DateType
 
-		// 获取主题样式
-		chartTheme, err := services.GetChartThemeConfig(chartInfo.ChartThemeId, chartInfo.Source, chartInfo.ChartType)
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取主题信息失败,Err:" + err.Error()
-			return
-		}
-		chartInfo.ChartThemeStyle = chartTheme.Config
-		chartInfo.ChartThemeId = chartTheme.ChartThemeId
+	// 获取主题样式
+	chartTheme, err := services.GetChartThemeConfig(chartInfo.ChartThemeId, chartInfo.Source, chartInfo.ChartType)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取主题信息失败,Err:" + err.Error()
+		return
 	}
+	chartInfo.ChartThemeStyle = chartTheme.Config
+	chartInfo.ChartThemeId = chartTheme.ChartThemeId
 
 	resp := new(models.ChartInfoDetailResp)
 
@@ -133,6 +131,21 @@ func (this *ChartInfoController) ChartInfoDetail() {
 		}
 		extraConfigStr = chartInfo.BarConfig
 	}
+	if chartType == 2 {
+		startDate = seasonStartDate
+		endDate = seasonEndDate
+		if dateType <= 0 {
+			if startDate != "" {
+				dateType = 5
+			} else {
+				dateType = utils.DateTypeNYears
+			}
+		}
+	} else {
+		if dateType <= 0 {
+			dateType = 3
+		}
+	}
 	yearMax := 0
 	if dateType == utils.DateTypeNYears {
 		for _, v := range mappingList {
@@ -149,9 +162,13 @@ func (this *ChartInfoController) ChartInfoDetail() {
 			}
 		}
 	}
-	// 开始/结束日期
 	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, yearMax)
 
+	if chartInfo.ChartType == 2 {
+		chartInfo.StartDate = startDate
+		chartInfo.EndDate = endDate
+	}
+
 	// 获取图表中的指标数据
 	edbList, xEdbIdValue, yDataList, dataResp, err, errMsg := services.GetChartEdbData(chartInfoId, chartType, calendar, startDate, endDate, mappingList, extraConfigStr, chartInfo.SeasonExtraConfig)
 	if err != nil {