Browse Source

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

baoziqiang 3 months ago
parent
commit
897043ea70

+ 5 - 0
controllers/data_manage/chart_info.go

@@ -1327,6 +1327,11 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
 		mappingList[k] = v
 	}
 
+	if req.ChartType == utils.CHART_TYPE_SEASON && req.DateType == utils.DateTypeNYears {
+		// 季节性图表,要特殊处理起始日期, 最近N年
+		dateMax = time.Date(dateMax.Year()+1, 1, 1, 0, 0, 0, 0, time.Local)
+	}
+
 	// 开始/结束日期
 	startDate, endDate := utils.GetDateByDateTypeV2(req.DateType, req.StartDate, req.EndDate, req.StartYear, dateMax)
 	if startDate == "" {

+ 2 - 0
controllers/data_manage/edb_info.go

@@ -4673,7 +4673,9 @@ func (this *ChartInfoController) EdbInfoDataSeasonal() {
 	}
 	var latestDateT time.Time
 	if edbInfo.LatestDate != "" {
+		// 季节性图需要特殊处理最近N年数据
 		latestDateT, _ = time.Parse(utils.FormatDate, edbInfo.LatestDate)
+		latestDateT = time.Date(latestDateT.Year()+1, 1, 1, 0, 0, 0, 0, time.Local)
 	}
 
 	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, latestDateT)

+ 4 - 0
controllers/data_manage/predict_edb_info.go

@@ -1412,6 +1412,10 @@ func (this *PredictEdbInfoController) DataList() {
 		latestDateT, _ := time.Parse(utils.FormatDate, edbInfo.LatestDate)
 		maxDate = latestDateT
 	}
+	if chartType == utils.CHART_TYPE_SEASON && dateType == utils.DateTypeNYears {
+		// 季节性图需要特殊处理最近N年数据
+		maxDate = time.Date(maxDate.Year()+1, 1, 1, 0, 0, 0, 0, time.Local)
+	}
 
 	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxDate)
 	if endDate == "" {

+ 4 - 1
controllers/data_manage/supply_analysis/variety_edb.go

@@ -750,7 +750,10 @@ func (this *VarietyController) EdbInfoDataSeasonal() {
 		Calendar:         "",
 	}
 
-	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, varietyEdbInfo.EndDate)
+	// 特殊处理季节性图的日期
+	maxDate := time.Date(varietyEdbInfo.EndDate.Year()+1, 1, 1, 0, 0, 0, 0, time.Local)
+
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxDate)
 
 	dataList, minVal, maxVal, err := supply_analysisServ.GetChartEdbSeasonalData(varietyEdbId, calendar, startDate, endDate, edbInfo.LatestDate)
 	if err != nil {

+ 6 - 5
services/data/chart_info.go

@@ -11,12 +11,13 @@ import (
 	"eta/eta_api/services/data/data_manage_permission"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/shopspring/decimal"
 	"math"
 	"sort"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/shopspring/decimal"
 )
 
 func ChartInfoRefreshV1(chartInfoId int) (err error) {
@@ -3906,7 +3907,7 @@ func SeasonChartData(dataList []*data_manage.ChartEdbInfoMapping, seasonExtraCon
 						continue
 					}
 					// 农历时dataTimeList的年份为最新年份,图例时间的年份才是真实年份
-					chartLegend,_ := strconv.Atoi(v.ChartLegend)
+					chartLegend, _ := strconv.Atoi(v.ChartLegend)
 					if chartLegend < startYear {
 						continue
 					}
@@ -4042,7 +4043,7 @@ func SeasonChartData(dataList []*data_manage.ChartEdbInfoMapping, seasonExtraCon
 							continue
 						}
 						// 农历时dataTimeList的年份为最新年份,图例时间的年份才是真实年份
-						chartLegend,_ := strconv.Atoi(v.ChartLegend)
+						chartLegend, _ := strconv.Atoi(v.ChartLegend)
 						if chartLegend < startYear {
 							continue
 						}
@@ -4215,7 +4216,7 @@ func SeasonChartData(dataList []*data_manage.ChartEdbInfoMapping, seasonExtraCon
 						continue
 					}
 					// 农历时dataTimeList的年份为最新年份,图例时间的年份才是真实年份
-					chartLegend,_ := strconv.Atoi(quarterDataList[i].ChartLegend)
+					chartLegend, _ := strconv.Atoi(quarterDataList[i].ChartLegend)
 					if chartLegend < startYear {
 						continue
 					}
@@ -4303,7 +4304,7 @@ func SeasonChartData(dataList []*data_manage.ChartEdbInfoMapping, seasonExtraCon
 						continue
 					}
 					// 农历时dataTimeList的年份为最新年份,图例时间的年份才是真实年份
-					chartLegend,_ := strconv.Atoi(quarterDataList[i].ChartLegend)
+					chartLegend, _ := strconv.Atoi(quarterDataList[i].ChartLegend)
 					if chartLegend < startYear {
 						continue
 					}