Эх сурвалжийг харах

fix:新增返回移动后的最新数据日期

Roc 1 жил өмнө
parent
commit
44f5dec14e

+ 1 - 0
models/data_manage/chart_info.go

@@ -439,6 +439,7 @@ type ChartEdbInfoMapping struct {
 	ChartType           int     `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图,8:商品价格曲线图,9:相关性图"`
 	LatestDate          string  `description:"数据最新日期"`
 	LatestValue         float64 `description:"数据最新值"`
+	MoveLatestDate      string  `description:"移动后的数据最新日期"`
 	UniqueCode          string  `description:"指标唯一编码"`
 	MinValue            float64 `json:"-" description:"最小值"`
 	MaxValue            float64 `json:"-" description:"最大值"`

+ 16 - 2
services/data/chart_info.go

@@ -16,7 +16,6 @@ import (
 	"time"
 )
 
-
 type ChartInfoReq struct {
 	ChartInfoId int `description:"图表id,新增时传0"`
 }
@@ -196,6 +195,7 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 		item.LatestValue = v.LatestValue
 		item.LatestDate = v.LatestDate
 		item.UniqueCode = v.UniqueCode
+		item.MoveLatestDate = v.LatestDate
 
 		var startDateReal string
 		var diffSeconds int64
@@ -227,6 +227,21 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 			} else {
 				startDateReal = startDate
 			}
+
+			// 预测指标的开始日期也要偏移
+			{
+				day, tmpErr := utils.GetDaysBetween2Date(utils.FormatDate, startDate, startDateReal)
+				if tmpErr != nil {
+					err = tmpErr
+					return
+				}
+				latestDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, v.MoveLatestDate, time.Local)
+				if tmpErr != nil {
+					err = tmpErr
+					return
+				}
+				item.MoveLatestDate = latestDateTime.AddDate(0, 0, day).Format(utils.FormatDate)
+			}
 		}
 		//fmt.Println("line 1011 chart:", v.Source, v.EdbInfoId, startDateReal, endDate)
 		calendarPreYear := 0
@@ -592,7 +607,6 @@ func BarChartData(mappingList []*data_manage.ChartEdbInfoMapping, edbDataListMap
 	return
 }
 
-
 func CheckIsEnChart(chartNameEn string, edbList []*data_manage.ChartEdbInfoMapping, source, chartType int) bool {
 	// 相关性图表不判断指标
 	if source == utils.CHART_SOURCE_CORRELATION && chartNameEn != "" {