Forráskód Böngészése

Merge branch 'bzq1/chart_time_range' of eta_server/eta_api into master

baoziqiang 3 hónapja
szülő
commit
07966fe80a

+ 27 - 26
controllers/data_manage/chart_info.go

@@ -16,13 +16,14 @@ import (
 	etaTrialService "eta/eta_api/services/eta_trial"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"os"
 	"os/exec"
 	"sort"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/rdlucklib/rdluck_tools/paging"
 )
 
 // 图表管理
@@ -1041,7 +1042,7 @@ func (this *ChartInfoController) ChartInfoDetail() {
 		}
 		extraConfigStr = chartInfo.BarConfig
 	}
-	yearMax := 0
+	var dateMax time.Time
 	if dateType == utils.DateTypeNYears {
 		for _, v := range mappingList {
 			if v.LatestDate != "" {
@@ -1051,14 +1052,14 @@ func (this *ChartInfoController) ChartInfoDetail() {
 					br.ErrMsg = "获取图表日期信息失败,Err:" + tErr.Error()
 					return
 				}
-				if lastDateT.Year() > yearMax {
-					yearMax = lastDateT.Year()
+				if lastDateT.After(dateMax) {
+					dateMax = lastDateT
 				}
 			}
 		}
 	}
 	// 开始/结束日期
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, yearMax)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, dateMax)
 
 	if chartInfo.HaveOperaAuth {
 		// 获取图表中的指标数据
@@ -1287,7 +1288,7 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
 		br.ErrMsg = "获取图表,指标信息失败,Err:" + err.Error()
 		return
 	}
-	yearMax := 0
+	var dateMax time.Time
 	for k, v := range mappingList {
 		if tmpV, ok := edbInfoIdMapping[v.EdbInfoId]; ok {
 			v.EdbInfoType = tmpV.EdbInfoType
@@ -1311,8 +1312,8 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
 					br.ErrMsg = "获取图表日期信息失败,Err:" + tErr.Error()
 					return
 				}
-				if lastDateT.Year() > yearMax {
-					yearMax = lastDateT.Year()
+				if lastDateT.After(dateMax) {
+					dateMax = lastDateT
 				}
 			}
 		}
@@ -1327,7 +1328,7 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
 	}
 
 	// 开始/结束日期
-	startDate, endDate := utils.GetDateByDateTypeV2(req.DateType, req.StartDate, req.EndDate, req.StartYear, yearMax)
+	startDate, endDate := utils.GetDateByDateTypeV2(req.DateType, req.StartDate, req.EndDate, req.StartYear, dateMax)
 	if startDate == "" {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败 时间格式错误"
@@ -1593,7 +1594,7 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
 			dateType = 3
 		}
 	}
-	yearMax := 0
+	var dateMax time.Time
 	if dateType == utils.DateTypeNYears {
 		for _, v := range mappingList {
 			if v.LatestDate != "" {
@@ -1603,13 +1604,13 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
 					br.ErrMsg = "获取图表日期信息失败,Err:" + tErr.Error()
 					return
 				}
-				if lastDateT.Year() > yearMax {
-					yearMax = lastDateT.Year()
+				if lastDateT.After(dateMax) {
+					dateMax = lastDateT
 				}
 			}
 		}
 	}
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, yearMax)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, dateMax)
 
 	if chartInfo.ChartType == 2 {
 		chartInfo.StartDate = startDate
@@ -1755,7 +1756,7 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
 	}
 
 	resp.ClassifyLevels = classifyLevels
-	
+
 	//图表操作权限
 	chartInfo.IsEdit = data.CheckOpChartPermission(sysUser, chartInfo.SysUserId, chartInfo.HaveOperaAuth)
 	chartInfo.Button = data_manage.ChartViewButton{
@@ -1891,13 +1892,13 @@ func (this *ChartInfoController) ChartInfoEdbInfoDetail() {
 		br.Msg = "获取失败,Err:" + err.Error()
 		return
 	}
-	maxYear := 0
+	var maxDate time.Time
 	if edbInfo.LatestDate != "" {
 		latestDateT, _ := time.Parse(utils.FormatDate, edbInfo.LatestDate)
-		maxYear = latestDateT.Year()
+		maxDate = latestDateT
 	}
 
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxYear)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxDate)
 	if startDate == "" {
 		br.Msg = "参数错误"
 		br.Msg = "参数错误,无效的查询日期"
@@ -2733,7 +2734,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 		return
 	}
 
-	yearMax := 0
+	var dateMax time.Time
 	if dateType == utils.DateTypeNYears {
 		for _, v := range mappingList {
 			if v.LatestDate != "" {
@@ -2743,13 +2744,13 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 					errMsg = "获取图表日期信息失败,Err:" + tErr.Error()
 					return
 				}
-				if lastDateT.Year() > yearMax {
-					yearMax = lastDateT.Year()
+				if lastDateT.After(dateMax) {
+					dateMax = lastDateT
 				}
 			}
 		}
 	}
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, yearMax)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, dateMax)
 
 	extraConfigStr := chartInfo.ExtraConfig //图表额外数据参数
 	var barConfig data_manage.BarChartInfoReq
@@ -4163,7 +4164,7 @@ func (this *ChartInfoController) ChartInfoConvertDetail() {
 			}
 			extraConfigStr = chartInfo.BarConfig
 		}
-		yearMax := 0
+		var dateMax time.Time
 		if dateType == utils.DateTypeNYears {
 			for _, v := range mappingList {
 				if v.LatestDate != "" {
@@ -4173,14 +4174,14 @@ func (this *ChartInfoController) ChartInfoConvertDetail() {
 						br.ErrMsg = "获取图表日期信息失败,Err:" + tErr.Error()
 						return
 					}
-					if lastDateT.Year() > yearMax {
-						yearMax = lastDateT.Year()
+					if lastDateT.After(dateMax) {
+						dateMax = lastDateT
 					}
 				}
 			}
 		}
 		// 开始/结束日期
-		startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, yearMax)
+		startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, dateMax)
 
 		// 获取图表中的指标数据
 		edbList, xEdbIdValue, yDataList, dataResp, err, errMsg := data.GetChartConvertEdbData(chartInfoId, chartType, calendar, startDate, endDate, mappingList, extraConfigStr, chartInfo.SeasonExtraConfig, isAxis)
@@ -5012,4 +5013,4 @@ func (this *ChartInfoController) ModifyChartList() {
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"
-}
+}

+ 4 - 4
controllers/data_manage/chart_theme.go

@@ -231,7 +231,7 @@ func (c *ChartThemeController) GetThemePreviewData() {
 	chartInfo.Source = chartThemeType.ChartSource
 	chartInfo.ChartType = chartThemeType.ChartType
 
-	yearMax := 0
+	var dateMax time.Time
 	if dateType == utils.DateTypeNYears {
 		for _, v := range mappingList {
 			if v.LatestDate != "" {
@@ -241,14 +241,14 @@ func (c *ChartThemeController) GetThemePreviewData() {
 					br.ErrMsg = "获取图表日期信息失败,Err:" + tErr.Error()
 					return
 				}
-				if lastDateT.Year() > yearMax {
-					yearMax = lastDateT.Year()
+				if lastDateT.After(dateMax) {
+					dateMax = lastDateT
 				}
 			}
 		}
 	}
 	// 开始/结束日期
-	startDate, endDate := utils.GetDateByDateTypeV2(dateType, tmpStartDate, tmpEndDate, startYear, yearMax)
+	startDate, endDate := utils.GetDateByDateTypeV2(dateType, tmpStartDate, tmpEndDate, startYear, dateMax)
 
 	// 获取图表中的指标数据
 	edbList, xEdbIdValue, yDataList, dataResp, err, errMsg := data.GetThemePreviewChartEdbData(chartType, calendar, startDate, endDate, mappingList, extraConfigStr, chartInfo.SeasonExtraConfig)

+ 10 - 13
controllers/data_manage/edb_info.go

@@ -1864,7 +1864,7 @@ func (this *EdbInfoController) EdbInfoSearch() {
 				searchItem.Unit = indexInfo.Unit
 				searchItem.EdbName = indexInfo.IndexName
 			}
-		}  else if source == utils.DATA_SOURCE_HISUGAR { //泛糖科技
+		} else if source == utils.DATA_SOURCE_HISUGAR { //泛糖科技
 			dataItems, err := data_manage.GetEdbDataAllByEdbCode(edbCode, source, subSource, utils.EDB_DATA_LIMIT)
 			if err != nil && err.Error() != utils.ErrNoRow() {
 				br.Msg = "获取失败"
@@ -3896,12 +3896,11 @@ func (this *ChartInfoController) EdbInfoData() {
 	resp.DataList = make([]*data_manage.EdbDataList, 0)
 	// 数据获取
 	if fullEdb.HaveOperaAuth { // 有权限才获取数据
-		maxYear := 0
+		var latestDateT time.Time
 		if edbInfo.LatestDate != "" {
-			latestDateT, _ := time.Parse(utils.FormatDate, edbInfo.LatestDate)
-			maxYear = latestDateT.Year()
+			latestDateT, _ = time.Parse(utils.FormatDate, edbInfo.LatestDate)
 		}
-		startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxYear)
+		startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, latestDateT)
 		dataList, err = data_manage.GetEdbDataList(edbInfo.Source, edbInfo.SubSource, edbInfoId, startDate, endDate)
 		if err != nil {
 			br.Msg = "获取失败"
@@ -4570,13 +4569,12 @@ func (this *ChartInfoController) EdbInfoDataTb() {
 		br.Msg = "获取失败,Err:" + err.Error()
 		return
 	}
-	maxYear := 0
+	var latestDateT time.Time
 	if edbInfo.LatestDate != "" {
-		latestDateT, _ := time.Parse(utils.FormatDate, edbInfo.LatestDate)
-		maxYear = latestDateT.Year()
+		latestDateT, _ = time.Parse(utils.FormatDate, edbInfo.LatestDate)
 	}
 
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxYear)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, latestDateT)
 
 	var startDateTime time.Time
 	if startDate != `` {
@@ -4673,13 +4671,12 @@ func (this *ChartInfoController) EdbInfoDataSeasonal() {
 		br.Msg = "获取失败,Err:" + err.Error()
 		return
 	}
-	maxYear := 0
+	var latestDateT time.Time
 	if edbInfo.LatestDate != "" {
-		latestDateT, _ := time.Parse(utils.FormatDate, edbInfo.LatestDate)
-		maxYear = latestDateT.Year()
+		latestDateT, _ = time.Parse(utils.FormatDate, edbInfo.LatestDate)
 	}
 
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxYear)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, latestDateT)
 
 	dataList, err := data.GetChartEdbSeasonalData(calendar, startDate, endDate, edbInfo)
 	if err != nil {

+ 9 - 8
controllers/data_manage/future_good/future_good_chart_info.go

@@ -16,13 +16,14 @@ import (
 	etaTrialService "eta/eta_api/services/eta_trial"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"os"
 	"os/exec"
 	"sort"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/rdlucklib/rdluck_tools/paging"
 )
 
 // FutureGoodChartInfoController 商品价格图表管理
@@ -1332,16 +1333,16 @@ func getFutureGoodChartInfo(chartInfo *data_manage.ChartInfoView, chartType, dat
 		return
 	}
 
-	maxYear := 0
+	var maxDate time.Time
 	for _, v := range edbInfoMappingList {
 		if v.LatestDate != "" {
 			latestDateT, _ := time.Parse(utils.FormatDate, v.LatestDate)
-			if maxYear < latestDateT.Year() {
-				maxYear = latestDateT.Year()
+			if latestDateT.After(maxDate) {
+				maxDate = latestDateT
 			}
 		}
 	}
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxYear)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxDate)
 
 	// 商品价格曲线图的一些配置
 	var barConfig data_manage.FutureGoodBarChartInfoReq
@@ -1986,13 +1987,13 @@ func (this *FutureGoodChartInfoController) ChartInfoEdbInfoDetail() {
 		br.Msg = "获取失败,Err:" + err.Error()
 		return
 	}
-	maxYear := 0
+	var maxDate time.Time
 	if edbInfo.LatestDate != "" {
 		latestDateT, _ := time.Parse(utils.FormatDate, edbInfo.LatestDate)
-		maxYear = latestDateT.Year()
+		maxDate = latestDateT
 	}
 
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxYear)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxDate)
 	if startDate == "" {
 		br.Msg = "参数错误"
 		br.Msg = "参数错误,无效的查询日期"

+ 23 - 22
controllers/data_manage/line_feature/chart_info.go

@@ -15,10 +15,11 @@ import (
 	lineFeatureServ "eta/eta_api/services/data/line_feature"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/rdlucklib/rdluck_tools/paging"
 )
 
 // LineFeaturesChartInfoController 统计特征图表管理
@@ -170,12 +171,12 @@ func (this *LineFeaturesChartInfoController) MultipleGraphPreview() {
 
 	// 曲线图表信息
 	curveConf := req.Curve
-	maxYear := 0
+	var maxDate time.Time
 	if edbInfoMapping.LatestDate != "" {
 		latestDateT, _ := time.Parse(utils.FormatDate, edbInfoMapping.LatestDate)
-		maxYear = latestDateT.Year()
+		maxDate = latestDateT
 	}
-	startDate, endDate := utils.GetDateByDateTypeV2(curveConf.DateType, curveConf.StartDate, curveConf.EndDate, curveConf.StartYear, maxYear)
+	startDate, endDate := utils.GetDateByDateTypeV2(curveConf.DateType, curveConf.StartDate, curveConf.EndDate, curveConf.StartYear, maxDate)
 	{
 		tmpChartInfo := *chartInfo
 		// 获取图表中的指标数据
@@ -434,12 +435,12 @@ func (this *LineFeaturesChartInfoController) MultipleGraphPreviewCurve() {
 		tmpChartInfo := *chartInfo
 
 		curveConf := req.Curve
-		maxYear := 0
+		var maxDate time.Time
 		if edbInfoMapping.LatestDate != "" {
 			latestDateT, _ := time.Parse(utils.FormatDate, edbInfoMapping.LatestDate)
-			maxYear = latestDateT.Year()
+			maxDate = latestDateT
 		}
-		startDate, endDate := utils.GetDateByDateTypeV2(curveConf.DateType, curveConf.StartDate, curveConf.EndDate, curveConf.StartYear, maxYear)
+		startDate, endDate := utils.GetDateByDateTypeV2(curveConf.DateType, curveConf.StartDate, curveConf.EndDate, curveConf.StartYear, maxDate)
 
 		// 获取图表中的指标数据
 		edbList, _, _, _, err, errMsg := data.GetChartEdbData(tmpChartInfo.ChartInfoId, tmpChartInfo.ChartType, tmpChartInfo.Calendar, startDate, endDate, []*data_manage.ChartEdbInfoMapping{edbInfoMapping}, tmpChartInfo.ExtraConfig, tmpChartInfo.SeasonExtraConfig)
@@ -584,12 +585,12 @@ func (this *LineFeaturesChartInfoController) MultipleGraphConfigSaveChart() {
 	isSendEmail := true
 
 	curveConf := req.Curve
-	maxYear := 0
+	var maxDate time.Time
 	if edbInfoMapping.LatestDate != "" {
 		latestDateT, _ := time.Parse(utils.FormatDate, edbInfoMapping.LatestDate)
-		maxYear = latestDateT.Year()
+		maxDate = latestDateT
 	}
-	startDate, endDate := utils.GetDateByDateTypeV2(curveConf.DateType, curveConf.StartDate, curveConf.EndDate, curveConf.StartYear, maxYear)
+	startDate, endDate := utils.GetDateByDateTypeV2(curveConf.DateType, curveConf.StartDate, curveConf.EndDate, curveConf.StartYear, maxDate)
 	switch req.Source {
 	case utils.CHART_MULTIPLE_GRAPH_CURVE: // 曲线图
 		curveConf := req.Curve
@@ -1830,12 +1831,12 @@ func (this *LineFeaturesChartInfoController) Detail() {
 			br.ErrMsg = "格式化配置项失败,Err:" + err.Error()
 			return
 		}
-		maxYear := 0
+		var maxDate time.Time
 		if edbMapping.LatestDate != "" {
 			latestDateT, _ := time.Parse(utils.FormatDate, edbMapping.LatestDate)
-			maxYear = latestDateT.Year()
+			maxDate = latestDateT
 		}
-		startDate, endDate := utils.GetDateByDateTypeV2(chartInfo.DateType, chartInfo.StartDate, chartInfo.EndDate, chartInfo.StartYear, maxYear)
+		startDate, endDate := utils.GetDateByDateTypeV2(chartInfo.DateType, chartInfo.StartDate, chartInfo.EndDate, chartInfo.StartYear, maxDate)
 		edbList, resultResp, err, errMsg = lineFeatureServ.GetStandardDeviationData(0, startDate, endDate, edbMapping, calculateValue)
 	case utils.CHART_SOURCE_LINE_FEATURE_PERCENTILE:
 		var percentileConfig request.Percentile
@@ -1845,12 +1846,12 @@ func (this *LineFeaturesChartInfoController) Detail() {
 			br.ErrMsg = "格式化配置项失败,Err:" + err.Error()
 			return
 		}
-		maxYear := 0
+		var maxDate time.Time
 		if edbMapping.LatestDate != "" {
 			latestDateT, _ := time.Parse(utils.FormatDate, edbMapping.LatestDate)
-			maxYear = latestDateT.Year()
+			maxDate = latestDateT
 		}
-		startDate, endDate := utils.GetDateByDateTypeV2(chartInfo.DateType, chartInfo.StartDate, chartInfo.EndDate, chartInfo.StartYear, maxYear)
+		startDate, endDate := utils.GetDateByDateTypeV2(chartInfo.DateType, chartInfo.StartDate, chartInfo.EndDate, chartInfo.StartYear, maxDate)
 		edbList, resultResp, err, errMsg = lineFeatureServ.GetPercentileData(0, startDate, endDate, edbMapping, percentileConfig.CalculateValue, percentileConfig.CalculateUnit, percentileConfig.PercentType)
 	case utils.CHART_SOURCE_LINE_FEATURE_FREQUENCY:
 		var frequencyDistributionConfig request.FrequencyDistribution
@@ -2459,12 +2460,12 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 			errMsg = "格式化配置项失败,Err:" + tmpErr.Error()
 			return
 		}
-		maxYear := 0
+		var maxDate time.Time
 		if edbMapping.LatestDate != "" {
 			latestDateT, _ := time.Parse(utils.FormatDate, edbMapping.LatestDate)
-			maxYear = latestDateT.Year()
+			maxDate = latestDateT
 		}
-		startDate, endDate := utils.GetDateByDateTypeV2(chartInfo.DateType, chartInfo.StartDate, chartInfo.EndDate, chartInfo.StartYear, maxYear)
+		startDate, endDate := utils.GetDateByDateTypeV2(chartInfo.DateType, chartInfo.StartDate, chartInfo.EndDate, chartInfo.StartYear, maxDate)
 		edbList, resultResp, err, msg = lineFeatureServ.GetStandardDeviationData(0, startDate, endDate, edbMapping, calculateValue)
 	case utils.CHART_SOURCE_LINE_FEATURE_PERCENTILE:
 		var percentileConfig request.Percentile
@@ -2474,12 +2475,12 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 			errMsg = "格式化配置项失败,Err:" + err.Error()
 			return
 		}
-		maxYear := 0
+		var maxDate time.Time
 		if edbMapping.LatestDate != "" {
 			latestDateT, _ := time.Parse(utils.FormatDate, edbMapping.LatestDate)
-			maxYear = latestDateT.Year()
+			maxDate = latestDateT
 		}
-		startDate, endDate := utils.GetDateByDateTypeV2(chartInfo.DateType, chartInfo.StartDate, chartInfo.EndDate, chartInfo.StartYear, maxYear)
+		startDate, endDate := utils.GetDateByDateTypeV2(chartInfo.DateType, chartInfo.StartDate, chartInfo.EndDate, chartInfo.StartYear, maxDate)
 		edbList, resultResp, err, msg = lineFeatureServ.GetPercentileData(0, startDate, endDate, edbMapping, percentileConfig.CalculateValue, percentileConfig.CalculateUnit, percentileConfig.PercentType)
 	case utils.CHART_SOURCE_LINE_FEATURE_FREQUENCY:
 		var frequencyDistributionConfig request.FrequencyDistribution

+ 8 - 4
controllers/data_manage/multiple_graph_config.go

@@ -191,7 +191,7 @@ func (this *ChartInfoController) MultipleGraphPreview() {
 		br.ErrMsg = "获取图表,指标信息失败,Err:" + err.Error()
 		return
 	}
-	maxYear := 0
+	var maxDate time.Time
 	var edbInfoMappingA, edbInfoMappingB *data_manage.ChartEdbInfoMapping
 	for _, v := range mappingList {
 		if v.EdbInfoId == req.EdbInfoIdA {
@@ -202,7 +202,7 @@ func (this *ChartInfoController) MultipleGraphPreview() {
 		}
 		if v.LatestDate != "" {
 			latestDateT, _ := time.Parse(utils.FormatDate, v.LatestDate)
-			maxYear = latestDateT.Year()
+			maxDate = latestDateT
 		}
 	}
 	if edbInfoMappingA == nil {
@@ -242,7 +242,7 @@ func (this *ChartInfoController) MultipleGraphPreview() {
 			}
 		}
 
-		startDate, endDate := utils.GetDateByDateTypeV2(curveConf.DateType, curveConf.StartDate, curveConf.EndDate, curveConf.StartYear, maxYear)
+		startDate, endDate := utils.GetDateByDateTypeV2(curveConf.DateType, curveConf.StartDate, curveConf.EndDate, curveConf.StartYear, maxDate)
 		// 获取图表中的指标数据
 		edbList, _, _, _, err, errMsg := data.GetChartEdbData(tmpChartInfo.ChartInfoId, tmpChartInfo.ChartType, tmpChartInfo.Calendar, startDate, endDate, mappingList, tmpChartInfo.ExtraConfig, tmpChartInfo.SeasonExtraConfig)
 		if err != nil {
@@ -362,7 +362,7 @@ func (this *ChartInfoController) MultipleGraphPreview() {
 
 			// 数据的开始/结束日期
 			curveConf := req.Curve
-			startDate, endDate := utils.GetDateByDateTypeV2(curveConf.DateType, curveConf.StartDate, curveConf.EndDate, curveConf.StartYear, maxYear)
+			startDate, endDate := utils.GetDateByDateTypeV2(curveConf.DateType, curveConf.StartDate, curveConf.EndDate, curveConf.StartYear, maxDate)
 
 			rollingCorrelationData := make([]interface{}, 0)
 			for _, rollingCorrelationConf := range rollingCorrelationConfList {
@@ -513,6 +513,10 @@ func (this *ChartInfoController) MultipleGraphPreviewCurve() {
 			startDate = "2020-01-01"
 		case 11:
 			startDate = "2022-01-01"
+		case 12:
+			startDate = "2023-01-01"
+		case 13:
+			startDate = "2024-01-01"
 		}
 
 		edbInfoType := 0

+ 6 - 6
controllers/data_manage/predict_edb_info.go

@@ -1407,13 +1407,13 @@ func (this *PredictEdbInfoController) DataList() {
 		}
 	}
 
-	maxYear := 0
+	var maxDate time.Time
 	if edbInfo.LatestDate != "" {
 		latestDateT, _ := time.Parse(utils.FormatDate, edbInfo.LatestDate)
-		maxYear = latestDateT.Year()
+		maxDate = latestDateT
 	}
 
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxYear)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxDate)
 	if endDate == "" {
 		endDate = time.Now().Format(utils.FormatDate)
 	}
@@ -1638,13 +1638,13 @@ func (this *PredictEdbInfoController) ChartDataList() {
 		return
 	}
 	// todo 确认预测指标是否用的是来源指标的最新日期
-	maxYear := 0
+	var maxDate time.Time
 	if sourceEdbInfoItem.LatestDate != "" {
 		latestDateT, _ := time.Parse(utils.FormatDate, sourceEdbInfoItem.LatestDate)
-		maxYear = latestDateT.Year()
+		maxDate = latestDateT
 	}
 
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxYear)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxDate)
 	if endDate == "" {
 		endDate = time.Now().Format(utils.FormatDate)
 	}

+ 6 - 5
controllers/data_manage/supply_analysis/variety_edb.go

@@ -11,12 +11,13 @@ import (
 	supply_analysisServ "eta/eta_api/services/data/supply_analysis"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/tealeg/xlsx"
 	"os"
 	"path/filepath"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/tealeg/xlsx"
 )
 
 // EdbList
@@ -96,7 +97,7 @@ func (this *VarietyController) EdbList() {
 
 		if tmpItem, ok := edbInfoAndClassifyMap[v.EdbInfoId]; ok {
 			classifyNameList := make([]string, 0)
- 
+
 			// 所属分类
 			{
 				classifyList, tmpErr, errMsg := data.GetFullClassifyByClassifyId(tmpItem.ClassifyId)
@@ -620,7 +621,7 @@ func (this *VarietyController) EdbInfoDataTb() {
 		Calendar:         "",
 	}
 
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, varietyEdbInfo.EndDate.Year())
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, varietyEdbInfo.EndDate)
 
 	var startDateTime time.Time
 	if startDate != `` {
@@ -749,7 +750,7 @@ func (this *VarietyController) EdbInfoDataSeasonal() {
 		Calendar:         "",
 	}
 
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, varietyEdbInfo.EndDate.Year())
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, varietyEdbInfo.EndDate)
 
 	dataList, minVal, maxVal, err := supply_analysisServ.GetChartEdbSeasonalData(varietyEdbId, calendar, startDate, endDate, edbInfo.LatestDate)
 	if err != nil {
@@ -848,7 +849,7 @@ func (this *VarietyController) EdbDataListV2() {
 		Calendar:         "",
 	}
 
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, varietyEdbInfo.EndDate.Year())
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, varietyEdbInfo.EndDate)
 
 	var startDateTime time.Time
 	if startDate != `` {

+ 5 - 5
services/data/chart_info_excel_balance.go

@@ -634,7 +634,7 @@ func GetBalanceExcelChartDetail(chartInfo *data_manage.ChartInfoView, mappingLis
 			dateType = 3
 		}
 	}
-	yearMax := 0
+	var dateMax time.Time
 	if dateType == utils.DateTypeNYears {
 		for _, v := range mappingList {
 			if v.LatestDate != "" {
@@ -644,13 +644,13 @@ func GetBalanceExcelChartDetail(chartInfo *data_manage.ChartInfoView, mappingLis
 					err = fmt.Errorf("获取图表日期信息失败,Err:" + tErr.Error())
 					return
 				}
-				if lastDateT.Year() > yearMax {
-					yearMax = lastDateT.Year()
+				if lastDateT.After(dateMax) {
+					dateMax = lastDateT
 				}
 			}
 		}
 	}
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, yearMax)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, dateMax)
 
 	if chartInfo.ChartType == 2 {
 		chartInfo.StartDate = startDate
@@ -1011,7 +1011,7 @@ func GetBalanceExcelEdbDataMapList(chartInfoId, chartType int, calendar, startDa
 			var rightAxisDate time.Time
 			if jumpYear == 1 {
 				latestDate = latestDate.AddDate(-1, 0, 0)
-				latestDateStr := fmt.Sprintf("%d-%s", latestDate.Year(),xStartDate)
+				latestDateStr := fmt.Sprintf("%d-%s", latestDate.Year(), xStartDate)
 				rightAxisDate, err = time.Parse(utils.FormatDate, latestDateStr)
 				if err != nil {
 					return

+ 6 - 1
services/data/line_equation/chart_info.go

@@ -10,12 +10,13 @@ import (
 	"eta/eta_api/services/data"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/shopspring/decimal"
 	"math"
 	"sort"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/shopspring/decimal"
 )
 
 type LineEquationResp struct {
@@ -298,6 +299,10 @@ func getConfigData(lineChartInfoConfig request.LineChartInfoReq) (mappingList []
 		startDate = "2020-01-01"
 	case 11:
 		startDate = "2022-01-01"
+	case 12:
+		startDate = "2023-01-01"
+	case 13:
+		startDate = "2024-01-01"
 	}
 
 	//指标数据

+ 10 - 9
services/data/range_analysis/chart_info.go

@@ -9,12 +9,13 @@ import (
 	"eta/eta_api/services/data"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/shopspring/decimal"
 	"math"
 	"sort"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/shopspring/decimal"
 )
 
 // GetAutoCalculateDateDataList 获取当前时间相关的区间作为计算依据
@@ -451,7 +452,7 @@ func GetChartDataByEdbInfoList(chartInfoId int, dateType, startYear int, startDa
 		xEdbIdValue = append(xEdbIdValue, edbInfoMapping.EdbInfoId)
 	}
 	//根据时间类型来筛选最终的数据
-	yearMax := 0
+	var dateMax time.Time
 	if dateType == utils.DateTypeNYears {
 		for _, v := range edbInfoMappingList {
 			dataList := v.DataList.([]*data_manage.EdbDataList)
@@ -463,14 +464,14 @@ func GetChartDataByEdbInfoList(chartInfoId int, dateType, startYear int, startDa
 						err = fmt.Errorf("获取图表日期信息失败,Err:" + tErr.Error())
 						return
 					}
-					if lastDateT.Year() > yearMax {
-						yearMax = lastDateT.Year()
+					if lastDateT.After(dateMax) {
+						dateMax = lastDateT
 					}
 				}
 			}
 		}
 	}
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, yearMax)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, dateMax)
 
 	if startDate != "" {
 		for k, v := range edbInfoMappingList {
@@ -602,7 +603,7 @@ func GetChartDataByEdbInfoListBySeries(chartInfoId int, dateType, startYear int,
 		edbInfoMapping.MinData = minData
 		xEdbIdValue = append(xEdbIdValue, edbInfoMapping.EdbInfoId)
 	}
-	yearMax := 0
+	var dateMax time.Time
 	if dateType == utils.DateTypeNYears {
 		for _, v := range edbInfoMappingList {
 			dataList := v.DataList.([]*data_manage.EdbDataList)
@@ -613,13 +614,13 @@ func GetChartDataByEdbInfoListBySeries(chartInfoId int, dateType, startYear int,
 					err = fmt.Errorf("获取图表日期信息失败,Err:" + tErr.Error())
 					return
 				}
-				if lastDateT.Year() > yearMax {
-					yearMax = lastDateT.Year()
+				if lastDateT.After(dateMax) {
+					dateMax = lastDateT
 				}
 			}
 		}
 	}
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, yearMax)
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, dateMax)
 
 	if startDate != "" {
 		for k, v := range edbInfoMappingList {

+ 1 - 1
services/data/trade_analysis/trade_analysis_data.go

@@ -56,7 +56,7 @@ func FormatCompanyTradeData2EdbMappings(companyTradeData []*tradeAnalysisModel.C
 		// 根据参数取日期范围
 		var startTime, endTime time.Time
 		if dateType > 0 {
-			st, ed := utils.GetDateByDateTypeV2(dateType, startDate, endDate, dateTypeNum, 0)
+			st, ed := utils.GetDateByDateTypeV2(dateType, startDate, endDate, dateTypeNum, time.Time{})
 			if st != "" {
 				startTime, _ = time.ParseInLocation(utils.FormatDate, st, time.Local)
 			}

+ 9 - 5
utils/common.go

@@ -1718,7 +1718,7 @@ func GetDateByDateType(dateType int, tmpStartDate, tmpEndDate string) (startDate
 	return
 }
 
-func GetDateByDateTypeV2(dateType int, tmpStartDate, tmpEndDate string, startYear, yearMax int) (startDate, endDate string) {
+func GetDateByDateTypeV2(dateType int, tmpStartDate, tmpEndDate string, startYear int, latestDate time.Time) (startDate, endDate string) {
 	startDate = tmpStartDate
 	endDate = tmpEndDate
 	switch dateType {
@@ -1753,16 +1753,20 @@ func GetDateByDateTypeV2(dateType int, tmpStartDate, tmpEndDate string, startYea
 	case 11:
 		startDate = "2022-01-01"
 		endDate = ""
+	case 12:
+		startDate = "2023-01-01"
+		endDate = ""
+	case 13:
+		startDate = "2024-01-01"
+		endDate = ""
 	case DateTypeNYears:
 		if startYear == 0 { //默认取最近5年
 			startYear = 5
 		}
-		if yearMax == 0 {
+		if latestDate.IsZero() {
 			return
 		}
-		startYear = startYear - 1
-		baseDate, _ := time.Parse(FormatDate, fmt.Sprintf("%d-01-01", yearMax))
-		startDate = baseDate.AddDate(-startYear, 0, 0).Format(FormatDate)
+		startDate = latestDate.AddDate(-startYear, 0, 0).Format(FormatDate)
 		endDate = ""
 	case DateTypeOneWeek:
 		//if startDate != "" {