فهرست منبع

Merge branch 'feature/eta1.9.5_future_good' of hongze/hongze_yb into master

xyxie 5 ماه پیش
والد
کامیت
bdf1c04d76

+ 42 - 15
controller/chart/chart_common.go

@@ -156,7 +156,8 @@ func getFutureGoodChartInfoDetail(chartInfo *chartInfoModel.ChartInfoView, myCha
 		}
 	}
 
-	edbInfoMapping, err := chartEdbMappingModel.GetEtaEdbChartEdbMapping(chartInfoId)
+	//edbInfoMapping, err := chartEdbMappingModel.GetEtaEdbChartEdbMapping(chartInfoId)
+	edbInfoMappingList, err := chartEdbMappingModel.GetEtaEdbChartEdbMappingList(chartInfoId)
 	if err != nil {
 		msg = "获取失败"
 		errMsg = "获取图表,现货指标信息失败,Err:" + err.Error()
@@ -170,8 +171,7 @@ func getFutureGoodChartInfoDetail(chartInfo *chartInfoModel.ChartInfoView, myCha
 	}
 
 	// 商品价格曲线图的一些配置
-	var barConfig request.BarChartInfoReq
-	barChartInfoDateList := make([]request.BarChartInfoDateReq, 0)
+	var barConfig request.FutureGoodBarChartInfoReq
 	//barChartInfoSort := request.BarChartInfoSortReq{}
 
 	if chartInfo.BarConfig == `` {
@@ -185,12 +185,24 @@ func getFutureGoodChartInfoDetail(chartInfo *chartInfoModel.ChartInfoView, myCha
 		errMsg = "商品价格曲线图配置异常"
 		return
 	}
-
-	barChartInfoDateList = barConfig.DateList
-	//barChartInfoSort = barConfig.Sort
-
+	baseEdbInfoId := barConfig.BaseEdbInfoId
+	var baseEdbInfoMapping *chartEdbMappingModel.ChartEdbInfoMapping
+	// todo 兼容历史数据,
+	if baseEdbInfoId == 0 {
+		// 默认取第一个现货指标
+		baseEdbInfoId = edbInfoMappingList[0].EdbInfoId
+		baseEdbInfoMapping = &edbInfoMappingList[0].ChartEdbInfoMapping
+		barConfig.BaseEdbInfoId = baseEdbInfoId
+	} else {
+		baseEdbInfoMapping, err = chartEdbMappingModel.GetChartEdbMappingByEdbInfoId(baseEdbInfoId)
+		if err != nil {
+			msg = "获取失败"
+			errMsg = "获取图表,指标信息失败,Err:" + err.Error()
+			return
+		}
+	}
 	// 获取图表中的指标数据
-	barConfigEdbInfoIdList, edbList, xEdbIdValue, xDataList, yDataList, sourceArr, err := future_goodServ.GetChartEdbData(chartInfoId, startDate, endDate, edbInfoMapping, futureGoodEdbInfoMapping, barChartInfoDateList)
+	barConfigEdbInfoIdList, edbList, xEdbIdValue, xDataList, yDataList, sourceArr, err := future_goodServ.GetChartEdbData(chartInfoId, startDate, endDate, baseEdbInfoMapping, edbInfoMappingList, futureGoodEdbInfoMapping, barConfig, true)
 	if err != nil {
 		msg = "获取失败"
 		errMsg = "获取图表,指标信息失败,Err:" + err.Error()
@@ -216,7 +228,7 @@ func getFutureGoodChartInfoDetail(chartInfo *chartInfoModel.ChartInfoView, myCha
 			}
 		}
 	}
-	baseEdbInfo := edbList[0] //现货指标
+	baseEdbInfo := baseEdbInfoMapping //现货指标
 	chartInfo.UnitEn = baseEdbInfo.UnitEn
 
 	// 访问记录-仅普通用户记录
@@ -253,11 +265,19 @@ func getFutureGoodChartInfoDetail(chartInfo *chartInfoModel.ChartInfoView, myCha
 
 		resp.MyChartInfo = myChartInfo
 	}
-
+	xDataListFinal := make([]chart_info.XData, 0)
+	for _, v := range xDataList {
+		tmp := chart_info.XData{
+			Name:   v.Name,
+			NameEn: v.NameEn,
+			IsHide: v.IsHide,
+		}
+		xDataListFinal = append(xDataListFinal, tmp)
+	}
 	resp.ChartInfo = chartInfo
 	resp.EdbInfoList = edbList
 	resp.XEdbIdValue = xEdbIdValue
-	resp.XDataList = xDataList
+	resp.XDataList = xDataListFinal
 	resp.YDataList = yDataList
 
 	isOk = true
@@ -280,15 +300,23 @@ func getFutureGoodProfitChartInfoDetail(chartInfo *chartInfoModel.ChartInfoView,
 		errMsg = "商品利润曲线图配置异常,Err:" + err.Error()
 		return
 	}
-
+	if len(extraConf.EdbInfoIdList) == 0 {
+		extraConf.EdbInfoIdList = append(extraConf.EdbInfoIdList, extraConf.BaseEdbInfoId)
+	}
 	edbList := make([]*chartEdbMappingModel.ChartEdbInfoMappingList, 0)
-	edbInfoMapping, err := chartEdbMappingModel.GetEtaEdbChartEdbMapping(chartInfoId)
+	edbInfoMappingList, err := chartEdbMappingModel.GetEtaEdbChartEdbMappingList(chartInfoId)
 	if err != nil {
 		msg = "获取失败"
 		errMsg = "获取图表,现货指标信息失败,Err:" + err.Error()
 		return
 	}
-	edbList = append(edbList, edbInfoMapping)
+	edbList = edbInfoMappingList
+	baseEdbInfo := new(chartEdbMappingModel.ChartEdbInfoMapping)
+	for _, v := range edbInfoMappingList {
+		if v.EdbInfoId == extraConf.BaseEdbInfoId {
+			baseEdbInfo = &v.ChartEdbInfoMapping
+		}
+	}
 	futureGoodEdbInfoMappingList, err := chartEdbMappingModel.GetFutureGoodEdbChartEdbMappingList(chartInfoId)
 	if err != nil {
 		msg = "获取失败"
@@ -326,7 +354,6 @@ func getFutureGoodProfitChartInfoDetail(chartInfo *chartInfoModel.ChartInfoView,
 		return
 	}
 
-	baseEdbInfo := edbList[0] //现货指标
 	chartInfo.UnitEn = baseEdbInfo.UnitEn
 
 	sourceArr := []string{"同花顺"}

+ 17 - 0
models/request/chart.go

@@ -7,12 +7,27 @@ type BarChartInfoReq struct {
 	Sort          BarChartInfoSortReq      `description:"排序"`
 }
 
+type FutureGoodBarChartInfoReq struct {
+	EdbInfoIdList []BarChartInfoEdbItemReq `description:"指标信息"`
+	DateList      []BarChartInfoDateReq    `description:"日期配置"`
+	XDataList     []XData                  `description:"横轴配置"`
+	BaseEdbInfoId int                      `description:"日期基准指标id"`
+}
+
+// XData 商品价格曲线的的x轴数据
+type XData struct {
+	Name   string `description:"别名"`
+	NameEn string `description:"英文别名"`
+	IsHide int    `description:"是否隐藏,0不隐藏,1隐藏"`
+}
+
 // BarChartInfoEdbItemReq 柱方图预览请求数据(指标相关)
 type BarChartInfoEdbItemReq struct {
 	EdbInfoId int    `description:"指标ID"`
 	Name      string `description:"别名"`
 	NameEn    string `description:"英文别名"`
 	Source    int    `description:"1:ETA图库;2:商品价格"`
+	IsHide    int    `description:"是否隐藏该项,0不隐藏,1隐藏"`
 }
 
 // BarChartInfoDateReq 柱方图预览请求数据(日期相关)
@@ -135,6 +150,8 @@ type ChartInfoReq struct {
 	BaseEdbInfoId           int                `description:"基础的指标id"`
 	DateList                []ChartInfoDateReq `description:"日期配置"`
 	ProfitNameEn            string             `description:"利润英文名称"`
+	EdbInfoIdList           []int              `description:"现货指标ID列表"`
+	XDataList               []XData            `description:"横轴配置"`
 }
 
 // EdbInfoFromTag 计算指标的关联指标

+ 1 - 0
models/response/chart_info/chart_info.go

@@ -34,6 +34,7 @@ type ChartLibChartInfoDetailResp struct {
 type XData struct {
 	Name   string `description:"别名"`
 	NameEn string `description:"英文别名"`
+	IsHide int    `description:"是否隐藏,0不隐藏,1隐藏"`
 }
 
 // YData 柱方图的y轴数据

+ 13 - 0
models/tables/chart_edb_mapping/query.go

@@ -123,6 +123,19 @@ func GetEtaEdbChartEdbMapping(chartInfoId int) (item *ChartEdbInfoMappingList, e
 	return
 }
 
+// GetEtaEdbChartEdbMappingList       商品曲线图查询对应的普通指标
+func GetEtaEdbChartEdbMappingList(chartInfoId int) (items []*ChartEdbInfoMappingList, err error) {
+	aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
+
+	sql := ` SELECT ` + aField + `,b.source_name,b.source,b.sub_source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.classify_id,b.is_join_permission
+             FROM chart_edb_mapping AS a
+			 INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
+			 WHERE a.chart_info_id=? AND a.source = ?
+             ORDER BY chart_edb_mapping_id ASC `
+	err = global.MYSQL["data"].Raw(sql, chartInfoId, utils.CHART_SOURCE_DEFAULT).Scan(&items).Error
+	return
+}
+
 // GetFutureGoodEdbChartEdbMapping       商品曲线图查询对应的商品指标
 func GetFutureGoodEdbChartEdbMapping(chartInfoId int) (item *ChartEdbInfoMappingList, err error) {
 	aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`

+ 2 - 2
models/tables/future_good_edb_data/future_good_edb_data.go

@@ -6,8 +6,8 @@ import (
 
 // FutureGoodEdbData 期货指标的数据
 type FutureGoodEdbData struct {
-	FutureGoodEdbDataID uint32    `gorm:"primaryKey;column:future_good_edb_data_id;type:int(9) unsigned;not null" json:"-"`
-	FutureGoodEdbInfoID uint32    `gorm:"index:idx_edbid_date;column:future_good_edb_info_id;type:int(9) unsigned" json:"futureGoodEdbInfoId"` // 期货指标id
+	FutureGoodEdbDataID int       `gorm:"primaryKey;column:future_good_edb_data_id;type:int(9) unsigned;not null" json:"-"`
+	FutureGoodEdbInfoID int       `gorm:"index:idx_edbid_date;column:future_good_edb_info_id;type:int(9) unsigned" json:"futureGoodEdbInfoId"` // 期货指标id
 	FutureGoodEdbCode   string    `gorm:"index:idx_code_date;column:future_good_edb_code;type:varchar(64)" json:"futureGoodEdbCode"`           // 期货指标code
 	DataTime            time.Time `gorm:"index:idx_code_date;index:idx_edbid_date;column:data_time;type:date" json:"dataTime"`                 // 数据日期
 	TradeCode           string    `gorm:"column:trade_code;type:varchar(64);default:''" json:"tradeCode"`                                      // 证券代码

+ 21 - 1
models/tables/future_good_edb_data/query.go

@@ -1,6 +1,8 @@
 package future_good_edb_data
 
-import "hongze/hongze_yb/global"
+import (
+	"hongze/hongze_yb/global"
+)
 
 func GetFutureGoodEdbDataListByDate(futureGoodEdbInfoId int, startDate, endDate string) (list []*FutureGoodEdbData, err error) {
 	var pars []interface{}
@@ -20,3 +22,21 @@ func GetFutureGoodEdbDataListByDate(futureGoodEdbInfoId int, startDate, endDate
 
 	return
 }
+
+func GetFutureGoodEdbDataListByIdsAndDate(futureGoodEdbInfoIds []int, startDate, endDate string) (list []*FutureGoodEdbData, err error) {
+	var pars []interface{}
+	sql := `SELECT * FROM future_good_edb_data WHERE 1=1 AND future_good_edb_info_id in (?)  `
+	pars = append(pars, futureGoodEdbInfoIds)
+	if startDate != "" {
+		sql += ` AND data_time>=? `
+		pars = append(pars, startDate)
+	}
+	if endDate != "" {
+		sql += ` AND data_time<=? `
+		pars = append(pars, endDate)
+	}
+
+	sql += ` ORDER BY data_time ASC `
+	err = global.MYSQL["data"].Raw(sql, pars...).Scan(&list).Error
+	return
+}

+ 4 - 4
models/tables/future_good_edb_info/future_good_edb_info.go

@@ -6,17 +6,17 @@ import (
 
 // FutureGoodEdbInfo 期货指标
 type FutureGoodEdbInfo struct {
-	FutureGoodEdbInfoID uint64    `gorm:"primaryKey;column:future_good_edb_info_id;type:bigint(9) unsigned;not null" json:"-"`                // 期货指标id
+	FutureGoodEdbInfoID int       `gorm:"primaryKey;column:future_good_edb_info_id;type:bigint(9) unsigned;not null" json:"-"`                // 期货指标id
 	FutureGoodEdbCode   string    `gorm:"column:future_good_edb_code;type:varchar(64);default:null;default:''" json:"futureGoodEdbCode"`      // 期货指标code
 	FutureGoodEdbName   string    `gorm:"column:future_good_edb_name;type:varchar(64);default:null;default:''" json:"futureGoodEdbName"`      // 期货指标名称
 	FutureGoodEdbNameEn string    `gorm:"column:future_good_edb_name_en;type:varchar(64);default:null;default:''" json:"futureGoodEdbNameEn"` // 期货指标名称(英文)
 	ParentID            uint64    `gorm:"column:parent_id;type:bigint(9) unsigned;default:null;default:0" json:"parentId"`                    // 上级期货id
 	RegionType          string    `gorm:"column:region_type;type:varchar(32);default:null;default:国内" json:"regionType"`                      // 交易所来源,海外还是国内
 	Exchange            string    `gorm:"column:exchange;type:varchar(32);default:null;default:''" json:"exchange"`                           // 所属交易所
-	FutureGoodEdbType   int8      `gorm:"column:future_good_edb_type;type:tinyint(4);default:null;default:1" json:"futureGoodEdbType"`        // 指标类型,1:年月是固定的合约;2:只有M+N期的合约,未固定年月
-	DateSourceID        int64     `gorm:"column:date_source_id;type:bigint(9);default:null;default:0" json:"dateSourceId"`                    // 画图时,日期来源的指标id
+	FutureGoodEdbType   int       `gorm:"column:future_good_edb_type;type:tinyint(4);default:null;default:1" json:"futureGoodEdbType"`        // 指标类型,1:年月是固定的合约;2:只有M+N期的合约,未固定年月
+	DateSourceID        int       `gorm:"column:date_source_id;type:bigint(9);default:null;default:0" json:"dateSourceId"`                    // 画图时,日期来源的指标id
 	Year                int       `gorm:"column:year;type:int(9);default:null;default:0" json:"year"`                                         // 所属年份
-	Month               uint32    `gorm:"column:month;type:int(9) unsigned;default:null;default:0" json:"month"`                              // 所属月份
+	Month               int       `gorm:"column:month;type:int(9) unsigned;default:null;default:0" json:"month"`                              // 所属月份
 	StartDate           time.Time `gorm:"column:start_date;type:date;default:null" json:"startDate"`                                          // 数据开始日期
 	EndDate             time.Time `gorm:"column:end_date;type:date;default:null" json:"endDate"`                                              // 数据结束日期
 	MinValue            float64   `gorm:"column:min_value;type:double;default:null;default:0" json:"minValue"`                                // 最小值

+ 432 - 234
services/chart/future_good/chart_info.go

@@ -15,47 +15,51 @@ import (
 	"hongze/hongze_yb/utils"
 	"sort"
 	"strconv"
+	"strings"
 	"time"
 )
 
 // GetChartEdbData 获取图表的指标数据
-func GetChartEdbData(chartInfoId int, startDate, endDate string, edbInfoMapping, futureGoodEdbInfoMapping *chartEdbMappingModel.ChartEdbInfoMappingList, barChartInfoDateList []request.BarChartInfoDateReq) (barConfigEdbInfoIdList []request.BarChartInfoEdbItemReq, edbList []*chartEdbMappingModel.ChartEdbInfoMappingList, xEdbIdValue []int, xDataList []chart_info.XData, yDataList []chart_info.YData, sourceArr []string, err error) {
+func GetChartEdbData(chartInfoId int, startDate, endDate string, baseEdbInfoMapping *chartEdbMappingModel.ChartEdbInfoMapping, edbInfoMappingList []*chartEdbMappingModel.ChartEdbInfoMappingList, futureGoodEdbInfoMapping *chartEdbMappingModel.ChartEdbInfoMappingList, barChartInfoConf request.FutureGoodBarChartInfoReq, needData bool) (barConfigEdbInfoIdList []request.BarChartInfoEdbItemReq, edbList []*chartEdbMappingModel.ChartEdbInfoMappingList, xEdbIdValue []int, xDataList []request.XData, yDataList []chart_info.YData, sourceArr []string, err error) {
 	edbList = make([]*chartEdbMappingModel.ChartEdbInfoMappingList, 0)
-
-	sourceArr = make([]string, 0)
+	barChartInfoDateList := barChartInfoConf.DateList
 	if futureGoodEdbInfoMapping == nil {
 		err = errors.New("商品指标未选取")
 		return
 	}
-	if edbInfoMapping == nil {
+	if len(edbInfoMappingList) == 0 {
 		err = errors.New("ETA指标未选取")
 		return
 	}
+
 	// 指标对应的所有数据
 	edbDataListMap := make(map[int][]*edbDataModel.EdbDataList)
 
-	item := new(chartEdbMappingModel.ChartEdbInfoMappingList)
-	edbInfoMapping.FrequencyEn = chart.GetFrequencyEn(edbInfoMapping.Frequency)
+	// todo item
+	//item := new(chartEdbMappingModel.ChartEdbInfoMappingList)
 
-	if edbInfoMapping.Unit == `无` {
-		edbInfoMapping.Unit = ``
-	}
 	if futureGoodEdbInfoMapping.Unit == `无` {
 		futureGoodEdbInfoMapping.Unit = ``
 	}
 
 	if chartInfoId <= 0 {
-		edbInfoMapping.IsAxis = 1
-		edbInfoMapping.LeadValue = 0
-		edbInfoMapping.LeadUnit = ""
-		edbInfoMapping.ChartEdbMappingId = 0
-		edbInfoMapping.ChartInfoId = 0
-		edbInfoMapping.IsOrder = false
-		edbInfoMapping.EdbInfoType = 1
-		edbInfoMapping.ChartStyle = ""
-		edbInfoMapping.ChartColor = ""
-		edbInfoMapping.ChartWidth = 0
-
+		for k, edbInfoMapping := range edbInfoMappingList {
+			edbInfoMapping.FrequencyEn = chart.GetFrequencyEn(edbInfoMapping.Frequency)
+			if edbInfoMapping.Unit == `无` {
+				edbInfoMapping.Unit = ``
+			}
+			edbInfoMapping.IsAxis = 1
+			edbInfoMapping.LeadValue = 0
+			edbInfoMapping.LeadUnit = ""
+			edbInfoMapping.ChartEdbMappingId = 0
+			edbInfoMapping.ChartInfoId = 0
+			edbInfoMapping.IsOrder = false
+			edbInfoMapping.EdbInfoType = 1
+			edbInfoMapping.ChartStyle = ""
+			edbInfoMapping.ChartColor = ""
+			edbInfoMapping.ChartWidth = 0
+			edbInfoMappingList[k] = edbInfoMapping
+		}
 		futureGoodEdbInfoMapping.IsAxis = 1
 		futureGoodEdbInfoMapping.LeadValue = 0
 		futureGoodEdbInfoMapping.LeadUnit = ""
@@ -67,37 +71,48 @@ func GetChartEdbData(chartInfoId int, startDate, endDate string, edbInfoMapping,
 		futureGoodEdbInfoMapping.ChartColor = ""
 		futureGoodEdbInfoMapping.ChartWidth = 0
 	} else {
-		edbInfoMapping.LeadUnitEn = chart.GetLeadUnitEn(edbInfoMapping.LeadUnit)
+		for k, edbInfoMapping := range edbInfoMappingList {
+			edbInfoMapping.FrequencyEn = chart.GetFrequencyEn(edbInfoMapping.Frequency)
+			if edbInfoMapping.Unit == `无` {
+				edbInfoMapping.Unit = ``
+			}
+			edbInfoMapping.LeadUnitEn = chart.GetLeadUnitEn(edbInfoMapping.LeadUnit)
+			edbInfoMappingList[k] = edbInfoMapping
+		}
 		futureGoodEdbInfoMapping.LeadUnitEn = chart.GetLeadUnitEn(futureGoodEdbInfoMapping.LeadUnit)
 	}
 
+	//查询横轴配置项
+	xDataItemMap := make(map[int]request.XData)
+	for k, v := range barChartInfoConf.XDataList {
+		xDataItemMap[k] = v
+	}
+
 	// 普通的指标数据
 	{
-		dataList := make([]*edbDataModel.EdbDataList, 0)
-
-		dataList, err = edbDataModel.GetEdbDataList(edbInfoMapping.Source, edbInfoMapping.SubSource, edbInfoMapping.EdbInfoId, startDate, endDate)
-		edbDataListMap[edbInfoMapping.EdbInfoId] = dataList
-		item.DataList = dataList
-
-		edbList = append(edbList, edbInfoMapping)
-
-		barConfigEdbInfoIdList = append(barConfigEdbInfoIdList, request.BarChartInfoEdbItemReq{
-			EdbInfoId: edbInfoMapping.EdbInfoId,
-			//Name:      edbInfoMapping.EdbName,
-			Name:   "现货价",
-			NameEn: "Spot Price",
-			Source: edbInfoMapping.Source,
-		})
-
-		if !utils.InArray(edbInfoMapping.Source, utils.SystemSourceList) { //来源于系统的指标,都展示为弘则研究
-			if !utils.InArray(edbInfoMapping.SourceName, sourceArr) {
-				sourceArr = append(sourceArr, edbInfoMapping.SourceName)
+		edbList = edbInfoMappingList
+
+		for k, edbInfoMapping := range edbInfoMappingList {
+			tmp := request.BarChartInfoEdbItemReq{
+				EdbInfoId: edbInfoMapping.EdbInfoId,
+				Name:      edbInfoMapping.EdbName,
+				NameEn:    edbInfoMapping.EdbNameEn,
+				Source:    edbInfoMapping.Source,
+			}
+			// 如果有配置,则用配置中的指标名称替换
+			xItem, ok := xDataItemMap[k]
+			if ok && xItem.Name != "" {
+				tmp.Name = xItem.Name
+				tmp.NameEn = xItem.NameEn
+				tmp.IsHide = xItem.IsHide
 			}
+			barConfigEdbInfoIdList = append(barConfigEdbInfoIdList, tmp)
 		}
 	}
 
 	// 获取主力合约和最新日期
 	var zlFutureGoodEdbInfo *future_good_edb_info.FutureGoodEdbInfo
+
 	var latestDate string // 最新日期是这个
 	var regionType string // 交易所来源:“国内”,“海外”
 	var futureGoodEdbType int
@@ -108,11 +123,11 @@ func GetChartEdbData(chartInfoId int, startDate, endDate string, edbInfoMapping,
 			return
 		}
 		regionType = zlFutureGoodEdbInfo.RegionType
-		futureGoodEdbType = int(zlFutureGoodEdbInfo.FutureGoodEdbType)
+		futureGoodEdbType = zlFutureGoodEdbInfo.FutureGoodEdbType
 
 		// 如果当前合约配置的 "画图时,日期来源的指标id" 并不是自己的话,那么就去查找对应配置的合约
-		if uint64(zlFutureGoodEdbInfo.DateSourceID) != zlFutureGoodEdbInfo.FutureGoodEdbInfoID {
-			sourceDateFutureGoodEdbInfo, tmpErr := future_good_edb_info.GetFutureGoodEdbInfo(int(zlFutureGoodEdbInfo.DateSourceID))
+		if zlFutureGoodEdbInfo.DateSourceID != zlFutureGoodEdbInfo.FutureGoodEdbInfoID {
+			sourceDateFutureGoodEdbInfo, tmpErr := future_good_edb_info.GetFutureGoodEdbInfo(zlFutureGoodEdbInfo.DateSourceID)
 			if tmpErr != nil {
 				err = tmpErr
 				return
@@ -141,70 +156,168 @@ func GetChartEdbData(chartInfoId int, startDate, endDate string, edbInfoMapping,
 
 	futureGoodMappingList := make([]*chartEdbMappingModel.ChartEdbInfoMappingList, 0)
 	for k, v := range futureGoodEdbInfoList {
+		tmp1 := chartEdbMappingModel.ChartEdbInfoMapping{
+			EdbInfoId:           v.FutureGoodEdbInfoID,
+			SourceName:          v.Exchange,
+			Source:              0,
+			EdbCode:             v.FutureGoodEdbCode,
+			EdbName:             v.FutureGoodEdbName,
+			EdbAliasName:        v.FutureGoodEdbName,
+			EdbNameEn:           v.FutureGoodEdbNameEn,
+			EdbType:             baseEdbInfoMapping.EdbType, //todo baseEdbInfoMapping
+			Frequency:           baseEdbInfoMapping.Frequency,
+			FrequencyEn:         baseEdbInfoMapping.FrequencyEn,
+			Unit:                baseEdbInfoMapping.Unit,
+			UnitEn:              baseEdbInfoMapping.UnitEn,
+			StartDate:           v.StartDate.Format(utils.FormatDate),
+			EndDate:             v.EndDate.Format(utils.FormatDate),
+			ModifyTime:          v.ModifyTime.Format(utils.FormatDateTime),
+			ChartEdbMappingId:   v.FutureGoodEdbInfoID,
+			ChartInfoId:         baseEdbInfoMapping.ChartInfoId,
+			MaxData:             v.MaxValue,
+			MinData:             v.MinValue,
+			IsOrder:             baseEdbInfoMapping.IsOrder,
+			IsAxis:              baseEdbInfoMapping.IsAxis,
+			EdbInfoType:         baseEdbInfoMapping.EdbInfoType,
+			EdbInfoCategoryType: baseEdbInfoMapping.EdbInfoCategoryType,
+			LeadValue:           baseEdbInfoMapping.LeadValue,
+			LeadUnit:            baseEdbInfoMapping.LeadUnit,
+			LeadUnitEn:          baseEdbInfoMapping.LeadUnitEn,
+			ChartStyle:          baseEdbInfoMapping.ChartStyle,
+			ChartColor:          baseEdbInfoMapping.ChartColor,
+			PredictChartColor:   baseEdbInfoMapping.PredictChartColor,
+			ChartWidth:          baseEdbInfoMapping.ChartWidth,
+			ChartType:           baseEdbInfoMapping.ChartType,
+			LatestDate:          v.LatestDate,
+			LatestValue:         v.LatestValue,
+			UniqueCode:          futureGoodEdbInfoMapping.UniqueCode + strconv.Itoa(k),
+			MinValue:            v.MinValue,
+			MaxValue:            v.MaxValue,
+		}
 		newMappingInfo := &chartEdbMappingModel.ChartEdbInfoMappingList{
-			ChartEdbInfoMapping: chartEdbMappingModel.ChartEdbInfoMapping{
-				EdbInfoId:           int(v.FutureGoodEdbInfoID),
-				SourceName:          v.Exchange,
-				Source:              utils.CHART_SOURCE_FUTURE_GOOD,
-				EdbCode:             v.FutureGoodEdbCode,
-				EdbName:             v.FutureGoodEdbName,
-				EdbAliasName:        v.FutureGoodEdbName,
-				EdbNameEn:           v.FutureGoodEdbNameEn,
-				EdbType:             edbInfoMapping.EdbType,
-				Frequency:           edbInfoMapping.Frequency,
-				FrequencyEn:         edbInfoMapping.FrequencyEn,
-				Unit:                edbInfoMapping.Unit,
-				UnitEn:              edbInfoMapping.UnitEn,
-				StartDate:           v.StartDate.Format(utils.FormatDateTime),
-				EndDate:             v.EndDate.Format(utils.FormatDateTime),
-				ModifyTime:          v.ModifyTime.Format(utils.FormatDateTime),
-				ChartEdbMappingId:   int(v.FutureGoodEdbInfoID),
-				ChartInfoId:         edbInfoMapping.ChartInfoId,
-				MaxData:             v.MaxValue,
-				MinData:             v.MinValue,
-				IsOrder:             edbInfoMapping.IsOrder,
-				IsAxis:              edbInfoMapping.IsAxis,
-				EdbInfoType:         edbInfoMapping.EdbInfoType,
-				EdbInfoCategoryType: edbInfoMapping.EdbInfoCategoryType,
-				LeadValue:           edbInfoMapping.LeadValue,
-				LeadUnit:            edbInfoMapping.LeadUnit,
-				LeadUnitEn:          edbInfoMapping.LeadUnitEn,
-				ChartStyle:          edbInfoMapping.ChartStyle,
-				ChartColor:          edbInfoMapping.ChartColor,
-				PredictChartColor:   edbInfoMapping.PredictChartColor,
-				ChartWidth:          edbInfoMapping.ChartWidth,
-				ChartType:           edbInfoMapping.ChartType,
-				LatestDate:          v.LatestDate,
-				LatestValue:         v.LatestValue,
-				UniqueCode:          futureGoodEdbInfoMapping.UniqueCode + "1" + strconv.Itoa(k),
-				MinValue:            v.MinValue,
-				MaxValue:            v.MaxValue,
-			},
-			DataList:   nil,
-			IsNullData: false,
+			ChartEdbInfoMapping: tmp1,
+			DataList:            nil,
+			IsNullData:          false,
 		}
 		futureGoodMappingList = append(futureGoodMappingList, newMappingInfo)
 
-		barConfigEdbInfoIdList = append(barConfigEdbInfoIdList, request.BarChartInfoEdbItemReq{
+		tmp := request.BarChartInfoEdbItemReq{
 			EdbInfoId: newMappingInfo.EdbInfoId,
 			Name:      fmt.Sprint("M+", v.Month),
 			NameEn:    fmt.Sprint("M+", v.Month),
 			Source:    newMappingInfo.Source,
-		})
+		}
+		// 判断如果有配置,需要替换为配置内容
+		xItem, ok := xDataItemMap[k]
+		if ok && xItem.Name != "" {
+			tmp.Name = xItem.Name
+			tmp.NameEn = xItem.NameEn
+			tmp.IsHide = xItem.IsHide
+		}
+		barConfigEdbInfoIdList = append(barConfigEdbInfoIdList, tmp)
+
+	}
+
+	if regionType == `海外` {
+		zlTmp := chartEdbMappingModel.ChartEdbInfoMapping{
+			EdbInfoId:           zlFutureGoodEdbInfo.FutureGoodEdbInfoID,
+			SourceName:          zlFutureGoodEdbInfo.Exchange,
+			Source:              0,
+			EdbCode:             zlFutureGoodEdbInfo.FutureGoodEdbCode,
+			EdbName:             zlFutureGoodEdbInfo.FutureGoodEdbName,
+			EdbAliasName:        zlFutureGoodEdbInfo.FutureGoodEdbName,
+			EdbNameEn:           zlFutureGoodEdbInfo.FutureGoodEdbNameEn,
+			EdbType:             baseEdbInfoMapping.EdbType,
+			Frequency:           baseEdbInfoMapping.Frequency,
+			FrequencyEn:         baseEdbInfoMapping.FrequencyEn,
+			Unit:                baseEdbInfoMapping.Unit,
+			UnitEn:              baseEdbInfoMapping.UnitEn,
+			StartDate:           zlFutureGoodEdbInfo.StartDate.Format(utils.FormatDate),
+			EndDate:             zlFutureGoodEdbInfo.EndDate.Format(utils.FormatDate),
+			ModifyTime:          zlFutureGoodEdbInfo.ModifyTime.Format(utils.FormatDateTime),
+			ChartEdbMappingId:   zlFutureGoodEdbInfo.FutureGoodEdbInfoID,
+			ChartInfoId:         baseEdbInfoMapping.ChartInfoId,
+			MaxData:             zlFutureGoodEdbInfo.MaxValue,
+			MinData:             zlFutureGoodEdbInfo.MinValue,
+			IsOrder:             baseEdbInfoMapping.IsOrder,
+			IsAxis:              baseEdbInfoMapping.IsAxis,
+			EdbInfoType:         baseEdbInfoMapping.EdbInfoType,
+			EdbInfoCategoryType: baseEdbInfoMapping.EdbInfoCategoryType,
+			LeadValue:           baseEdbInfoMapping.LeadValue,
+			LeadUnit:            baseEdbInfoMapping.LeadUnit,
+			LeadUnitEn:          baseEdbInfoMapping.LeadUnitEn,
+			ChartStyle:          baseEdbInfoMapping.ChartStyle,
+			ChartColor:          baseEdbInfoMapping.ChartColor,
+			PredictChartColor:   baseEdbInfoMapping.PredictChartColor,
+			ChartWidth:          baseEdbInfoMapping.ChartWidth,
+			ChartType:           baseEdbInfoMapping.ChartType,
+			LatestDate:          zlFutureGoodEdbInfo.LatestDate,
+			LatestValue:         zlFutureGoodEdbInfo.LatestValue,
+			UniqueCode:          futureGoodEdbInfoMapping.UniqueCode + strconv.Itoa(0),
+			MinValue:            zlFutureGoodEdbInfo.MinValue,
+			MaxValue:            zlFutureGoodEdbInfo.MaxValue,
+		}
+		zlFutureGoodEdbMapping := &chartEdbMappingModel.ChartEdbInfoMappingList{
+			ChartEdbInfoMapping: zlTmp,
+			DataList:            nil,
+			IsNullData:          false,
+		}
+		edbList = append(edbList, zlFutureGoodEdbMapping)
+		edbList = append(edbList, futureGoodMappingList...)
+	} else {
+		edbList = append(edbList, futureGoodMappingList...)
+	}
+
+	if !needData {
+		return
 	}
 
 	// 获取数据
-	for _, v := range futureGoodMappingList {
+
+	// 现货数据
+	for _, edbInfoMapping := range edbInfoMappingList {
 		dataList := make([]*edbDataModel.EdbDataList, 0)
+		dataList, err = edbDataModel.GetEdbDataList(edbInfoMapping.Source, edbInfoMapping.SubSource, edbInfoMapping.EdbInfoId, startDate, endDate)
+		if err != nil {
+			return
+		}
+		edbDataListMap[edbInfoMapping.EdbInfoId] = dataList
+		// todo item
+		//item.DataList = dataList
+	}
 
-		tmpDataList, tmpErr := future_good_edb_data.GetFutureGoodEdbDataListByDate(v.EdbInfoId, startDate, endDate)
+	futureEdbInfoIds := make([]int, 0)
+	for _, v := range futureGoodMappingList {
+		futureEdbInfoIds = append(futureEdbInfoIds, v.EdbInfoId)
+	}
+	tmpDataListMap := make(map[int][]*future_good_edb_data.FutureGoodEdbData)
+	if len(futureEdbInfoIds) > 0 {
+		// 期货数据
+		tmpDataList, tmpErr := future_good_edb_data.GetFutureGoodEdbDataListByIdsAndDate(futureEdbInfoIds, startDate, endDate)
 		if tmpErr != nil {
+			err = tmpErr
+			return
+		}
+
+		for _, v := range tmpDataList {
+			if _, ok := tmpDataListMap[v.FutureGoodEdbInfoID]; !ok {
+				tmpDataListMap[v.FutureGoodEdbInfoID] = make([]*future_good_edb_data.FutureGoodEdbData, 0)
+			}
+			tmpDataListMap[v.FutureGoodEdbInfoID] = append(tmpDataListMap[v.FutureGoodEdbInfoID], v)
+		}
+	}
+	// 期货数据
+	for _, v := range futureGoodMappingList {
+		dataList := make([]*edbDataModel.EdbDataList, 0)
+		tmpDataList, ok := tmpDataListMap[v.EdbInfoId]
+		if !ok {
+			err = fmt.Errorf("期货数据不存在 FutureGoodEdbInfoId: %d", v.EdbInfoId)
 			return
 		}
 		for _, tmpData := range tmpDataList {
 			dataList = append(dataList, &edbDataModel.EdbDataList{
-				EdbDataId:     int(tmpData.FutureGoodEdbDataID),
-				EdbInfoId:     int(tmpData.FutureGoodEdbInfoID),
+				EdbDataId:     tmpData.FutureGoodEdbDataID,
+				EdbInfoId:     tmpData.FutureGoodEdbInfoID,
 				DataTime:      tmpData.DataTime.Format(utils.FormatDate),
 				DataTimestamp: tmpData.DataTimestamp,
 				Value:         tmpData.Close,
@@ -214,16 +327,25 @@ func GetChartEdbData(chartInfoId int, startDate, endDate string, edbInfoMapping,
 		v.DataList = dataList
 	}
 
-	edbList = append(edbList, futureGoodMappingList...)
+	// 特殊处理日期
+	// 因为时间格式是:2023-07-19T00:00:00+08:00;所以需要分开
+	baseEndDateTime := strings.Split(baseEdbInfoMapping.EndDate, "T")
+	baseEndDate := baseEndDateTime[0]
 
-	xEdbIdValue, yDataList, err = BarChartData(edbList[0], futureGoodEdbInfoList, edbDataListMap, barChartInfoDateList, regionType, edbInfoMapping.EndDate)
+	xEdbIdValue, yDataList, err = BarChartData(baseEdbInfoMapping, edbInfoMappingList, futureGoodEdbInfoList, edbDataListMap, barChartInfoDateList, regionType, baseEndDate)
 
-	xDataList = []chart_info.XData{
-		{
-			Name:   "现货价",
-			NameEn: "Spot Price",
-		},
+	if len(barChartInfoConf.XDataList) > 0 {
+		xDataList = barChartInfoConf.XDataList
+	} else {
+		for _, v := range edbInfoMappingList {
+			xDataList = append(xDataList, request.XData{
+				Name:   v.EdbName,
+				NameEn: v.EdbNameEn,
+				IsHide: 0,
+			})
+		}
 	}
+
 	//yDataList =make([]chart_info.YData,0)
 	//chart_info.YData{
 	//	Date:           "",
@@ -236,7 +358,7 @@ func GetChartEdbData(chartInfoId int, startDate, endDate string, edbInfoMapping,
 	//}
 	futureGoodEdbInfoIndexMap := make(map[int]int)
 	for index, v := range futureGoodEdbInfoList {
-		futureGoodEdbInfoIndexMap[int(v.FutureGoodEdbInfoID)] = index
+		futureGoodEdbInfoIndexMap[v.FutureGoodEdbInfoID] = index
 	}
 	nMap := make(map[int]int)
 	maxIndex := 0 // 最大x轴的下标
@@ -253,19 +375,20 @@ func GetChartEdbData(chartInfoId int, startDate, endDate string, edbInfoMapping,
 		}
 
 		// 基础指标
-		{
-			baseEdbInfId := edbList[0].EdbInfoId
-			edbInfoIdList = append(edbInfoIdList, baseEdbInfId)
-			tmpVal, ok := yDataMap[baseEdbInfId]
+		baseEdbIds := make([]int, 0)
+		for _, tmp := range edbInfoMappingList {
+			edbInfoIdList = append(edbInfoIdList, tmp.EdbInfoId)
+			baseEdbIds = append(baseEdbIds, tmp.EdbInfoId)
+			tmpVal, ok := yDataMap[tmp.EdbInfoId]
 			valueList = append(valueList, tmpVal)
 			if !ok || tmpVal == 0 {
-				noDataEdbInfoIdList = append(noDataEdbInfoIdList, baseEdbInfId)
-				noDataEdbIdMap[baseEdbInfId] = baseEdbInfId
+				noDataEdbInfoIdList = append(noDataEdbInfoIdList, tmp.EdbInfoId)
+				noDataEdbIdMap[tmp.EdbInfoId] = tmp.EdbInfoId
 			}
 		}
 
 		for _, futureGoodEdbInfo := range futureGoodEdbInfoList {
-			tmpEdbInfId := int(futureGoodEdbInfo.FutureGoodEdbInfoID)
+			tmpEdbInfId := futureGoodEdbInfo.FutureGoodEdbInfoID
 			edbInfoIdList = append(edbInfoIdList, tmpEdbInfId)
 			tmpVal, ok := yDataMap[tmpEdbInfId]
 			valueList = append(valueList, tmpVal)
@@ -283,7 +406,7 @@ func GetChartEdbData(chartInfoId int, startDate, endDate string, edbInfoMapping,
 
 		for i := lenEdbId - 1; i >= 0; i-- {
 			// 如果没有在无数据的指标列表中找到,那么就找到了最大x轴的下标
-			if _, ok := noDataEdbIdMap[edbInfoIdList[i]]; !ok {
+			if _, ok := noDataEdbIdMap[edbInfoIdList[i]]; !ok || utils.InArrayByInt(baseEdbIds, edbInfoIdList[i]) {
 				// 如果最大x轴的下标 小于 当前下标,那么就重新赋值
 				if maxIndex < i-1 {
 					maxIndex = i - 1
@@ -319,34 +442,60 @@ func GetChartEdbData(chartInfoId int, startDate, endDate string, edbInfoMapping,
 			yDataList[k].Value = v.Value[0 : maxIndex+1]
 		}
 	}
-
-	tmpXDataList, newYDataList, err := handleResultData(regionType, futureGoodEdbType, yDataList, futureGoodEdbInfoList, maxIndex)
+	baseEdbLen := len(edbInfoMappingList)
+	tmpXDataList, newYDataList, err := handleResultData(regionType, futureGoodEdbType, baseEdbLen, yDataList, futureGoodEdbInfoList, maxIndex)
 	if err != nil {
 		return
 	}
-	xDataList = append(xDataList, tmpXDataList...)
+	if len(barChartInfoConf.XDataList) == 0 {
+		xDataList = append(xDataList, tmpXDataList...)
+	}
+
 	yDataList = newYDataList
 
 	return
 }
 
 // BarChartData 获取数据
-func BarChartData(edbInfoMapping *chartEdbMappingModel.ChartEdbInfoMappingList, futureGoodMappingList []*future_good_edb_info.FutureGoodEdbInfo, edbDataListMap map[int][]*edbDataModel.EdbDataList, barChartInfoDateList []request.BarChartInfoDateReq, regionType, latestDate string) (edbIdList []int, yDataList []chart_info.YData, err error) {
+func BarChartData(baseEdbInfoMapping *chartEdbMappingModel.ChartEdbInfoMapping, edbInfoMappingList []*chartEdbMappingModel.ChartEdbInfoMappingList, futureGoodMappingList []*future_good_edb_info.FutureGoodEdbInfo, edbDataListMap map[int][]*edbDataModel.EdbDataList, barChartInfoDateList []request.BarChartInfoDateReq, regionType, latestDate string) (edbIdList []int, yDataList []chart_info.YData, err error) {
 	// 指标数据数组(10086:{"2022-12-02":100.01,"2022-12-01":102.3})
-	edbDataMap := make(map[int]map[string]float64)
+	// 现货指标数据map
+	baseEdbDataMap := make(map[int]map[string]float64)
+	edbInfoMappingMap := make(map[int]struct{})
+	for _, v := range edbInfoMappingList {
+		edbInfoMappingMap[v.EdbInfoId] = struct{}{}
+	}
 	for edbInfoId, edbDataList := range edbDataListMap {
+		if _, ok1 := edbInfoMappingMap[edbInfoId]; ok1 {
+			edbDateData := make(map[string]float64)
+			for _, edbData := range edbDataList {
+				edbDateData[edbData.DataTime] = edbData.Value
+			}
+			baseEdbDataMap[edbInfoId] = edbDateData
+		}
+	}
+
+	// 期货指标数据map
+	futureGoodEdbDataMap := make(map[int]map[string]float64)
+	for edbInfoId, edbDataList := range edbDataListMap {
+		if _, ok := edbInfoMappingMap[edbInfoId]; ok {
+			continue
+		}
 		edbDateData := make(map[string]float64)
 		for _, edbData := range edbDataList {
 			edbDateData[edbData.DataTime] = edbData.Value
 		}
-		edbDataMap[edbInfoId] = edbDateData
+		futureGoodEdbDataMap[edbInfoId] = edbDateData
 	}
 
 	// edbIdList 指标展示顺序;x轴的指标顺序
 	edbIdList = make([]int, 0)
-	edbIdList = append(edbIdList, edbInfoMapping.EdbInfoId)
+	for _, v := range edbInfoMappingList {
+		edbIdList = append(edbIdList, v.EdbInfoId)
+	}
+
 	for _, v := range futureGoodMappingList {
-		edbIdList = append(edbIdList, int(v.FutureGoodEdbInfoID))
+		edbIdList = append(edbIdList, v.FutureGoodEdbInfoID)
 	}
 
 	latestDateTime, _ := time.ParseInLocation(utils.FormatDate, latestDate, time.Local)
@@ -385,23 +534,43 @@ func BarChartData(edbInfoMapping *chartEdbMappingModel.ChartEdbInfoMappingList,
 		noDataIdMap := make(map[int]int, 0) // 没有数据的指标map
 		xEdbInfoIdList := make([]int, 0)    // 当前数据的指标id列表
 
-		// 现货指标
-		realDateTime, findDataValue, isFind, tmpErr := GetNeedDateData(findDateTime, edbDataListMap[edbInfoMapping.EdbInfoId], edbDataMap[edbInfoMapping.EdbInfoId])
+		// 先找到基准日期
+		var realDateTime time.Time
+		realDateTime, findDataValue, isFind, tmpErr := GetNeedDateData(findDateTime, edbDataListMap[baseEdbInfoMapping.EdbInfoId], baseEdbDataMap[baseEdbInfoMapping.EdbInfoId], futureGoodEdbDataMap)
 		if tmpErr != nil {
 			err = tmpErr
 			return
 		}
-		findDataList = append(findDataList, findDataValue)
-		yDataMap[edbInfoMapping.EdbInfoId] = findDataValue
-		if isFind {
-			maxDate = realDateTime
-		} else {
-			noDataIdList = append(noDataIdList, edbInfoMapping.EdbInfoId)
-			noDataIdMap[edbInfoMapping.EdbInfoId] = edbInfoMapping.EdbInfoId
+		// 处理其余现货指标
+		for _, v := range edbInfoMappingList {
+			if v.EdbInfoId == baseEdbInfoMapping.EdbInfoId {
+				findDataList = append(findDataList, findDataValue)
+				yDataMap[baseEdbInfoMapping.EdbInfoId] = findDataValue
+				if isFind {
+					maxDate = realDateTime
+				} else {
+					noDataIdList = append(noDataIdList, baseEdbInfoMapping.EdbInfoId)
+					noDataIdMap[baseEdbInfoMapping.EdbInfoId] = baseEdbInfoMapping.EdbInfoId
+				}
+				xEdbInfoIdList = append(xEdbInfoIdList, v.EdbInfoId)
+				continue
+			}
+			findDataValueTmp, isFindTmp := baseEdbDataMap[v.EdbInfoId][realDateTime.Format(utils.FormatDate)]
+			findDataList = append(findDataList, findDataValueTmp)
+			yDataMap[v.EdbInfoId] = findDataValueTmp
+			if !isFindTmp {
+				noDataIdList = append(noDataIdList, v.EdbInfoId)
+				noDataIdMap[v.EdbInfoId] = v.EdbInfoId
+			}
+			xEdbInfoIdList = append(xEdbInfoIdList, v.EdbInfoId)
 		}
-		currMonth := findDateTime.Month() // 当前月份
-		currYear := findDateTime.Year()   // 当前年份
-		xEdbInfoIdList = append(xEdbInfoIdList, edbInfoMapping.EdbInfoId)
+		//currMonth := findDateTime.Month() // 当前月份
+		//currYear := findDateTime.Year()   // 当前年份
+
+		// 用实际日期的月份作为基准,往前推12个月(2024-5-13 16:26:43修改)
+		currMonth := realDateTime.Month() // 当前月份
+		currYear := realDateTime.Year()   // 当前年份
+
 		mList := make([]int, 0) // 间隔月份
 		indexList := make([]int, 0)
 		if regionType == `国内` {
@@ -420,11 +589,11 @@ func BarChartData(edbInfoMapping *chartEdbMappingModel.ChartEdbInfoMappingList,
 						continue
 					}
 					indexList = append(indexList, i)
-					mList = append(mList, int(v.Month))
+					mList = append(mList, v.Month)
 				} else {
-					if v.Year > currYear || (v.Year == currYear && int(v.Month) > int(currMonth)) {
+					if v.Year > currYear || (v.Year == currYear && v.Month > int(currMonth)) {
 						indexList = append(indexList, i)
-						mList = append(mList, (v.Year-currYear)*12+int(v.Month)-int(currMonth))
+						mList = append(mList, (v.Year-currYear)*12+v.Month-int(currMonth))
 					}
 				}
 			}
@@ -432,15 +601,15 @@ func BarChartData(edbInfoMapping *chartEdbMappingModel.ChartEdbInfoMappingList,
 
 		for _, i := range indexList {
 			futureGoodMapping := futureGoodMappingList[i] // 当前的期货指标
-			//tmpRealDateTime, tmpFindDataValue, tmpIsFind, tmpErr := GetNeedDateData(findDateTime, edbDataListMap[futureGoodMapping.FutureGoodEdbInfoId], edbDataMap[futureGoodMapping.FutureGoodEdbInfoId])
+			//tmpRealDateTime, tmpFindDataValue, tmpIsFind, tmpErr := GetNeedDateData(findDateTime, edbDataListMap[futureGoodMapping.FutureGoodEdbInfoID], edbDataMap[futureGoodMapping.FutureGoodEdbInfoID])
 			//if tmpErr != nil {
 			//	err = tmpErr
 			//	return
 			//}
 			//tmpRealDateTime := findDateTime	// 按照配置找到的日期
 			tmpRealDateTime := realDateTime // 实际现货的日期
-			tmpFindDataValue, tmpIsFind := edbDataMap[int(futureGoodMapping.FutureGoodEdbInfoID)][tmpRealDateTime.Format(utils.FormatDate)]
-			yDataMap[int(futureGoodMapping.FutureGoodEdbInfoID)] = tmpFindDataValue
+			tmpFindDataValue, tmpIsFind := futureGoodEdbDataMap[futureGoodMapping.FutureGoodEdbInfoID][tmpRealDateTime.Format(utils.FormatDate)]
+			yDataMap[futureGoodMapping.FutureGoodEdbInfoID] = tmpFindDataValue
 
 			findDataList = append(findDataList, tmpFindDataValue)
 			if tmpIsFind {
@@ -448,11 +617,11 @@ func BarChartData(edbInfoMapping *chartEdbMappingModel.ChartEdbInfoMappingList,
 					maxDate = tmpRealDateTime
 				}
 			} else {
-				noDataIdList = append(noDataIdList, int(futureGoodMapping.FutureGoodEdbInfoID))
-				noDataIdMap[int(futureGoodMapping.FutureGoodEdbInfoID)] = int(futureGoodMapping.FutureGoodEdbInfoID)
+				noDataIdList = append(noDataIdList, futureGoodMapping.FutureGoodEdbInfoID)
+				noDataIdMap[futureGoodMapping.FutureGoodEdbInfoID] = futureGoodMapping.FutureGoodEdbInfoID
 			}
 			// 当前期货合约的指标
-			xEdbInfoIdList = append(xEdbInfoIdList, int(futureGoodMapping.FutureGoodEdbInfoID))
+			xEdbInfoIdList = append(xEdbInfoIdList, futureGoodMapping.FutureGoodEdbInfoID)
 		}
 
 		yName := barChartInfoDate.Name
@@ -520,86 +689,9 @@ func BarChartData(edbInfoMapping *chartEdbMappingModel.ChartEdbInfoMappingList,
 	return
 }
 
-// GetNeedDateData 获取合约内需要的日期数据
-func GetNeedDateData(needDateTime time.Time, dataList []*edbDataModel.EdbDataList, edbDataMap map[string]float64) (findDateTime time.Time, findDataValue float64, isFind bool, err error) {
-	//dataList := edbDataListMap[edbInfoId] //指标的所有数据值
-	if len(dataList) <= 0 {
-		// 没有数据的指标id
-		return
-	}
-
-	//最早的日期
-	minDateTime, err := time.ParseInLocation(utils.FormatDate, dataList[0].DataTime, time.Local)
-	if err != nil {
-		return
-	}
-
-	for tmpDateTime := needDateTime; tmpDateTime.After(minDateTime) || tmpDateTime.Equal(minDateTime); tmpDateTime = tmpDateTime.AddDate(0, 0, -1) {
-		tmpDate := tmpDateTime.Format(utils.FormatDate)
-		if tmpValue, ok := edbDataMap[tmpDate]; ok { //如果能找到数据,那么就返回
-			// 数据为0,也直接返回,做无值处理
-			if tmpValue == 0 {
-				return
-			}
-			findDateTime, _ = time.ParseInLocation(utils.FormatDate, tmpDate, time.Local)
-			findDataValue = tmpValue
-			isFind = true
-			return
-		}
-	}
-
-	return
-}
-
-// FutureGoodChartInfoRefresh
-// @author Roc
-// @datetime 2023-2-2 18:44:46
-// @description 商品价格曲线图表刷新
-func FutureGoodChartInfoRefresh(chartInfoId int) (err error) {
-	var errMsg string
-	defer func() {
-		if err != nil {
-			go alarm_msg.SendAlarmMsg("ChartInfoRefresh:"+errMsg, 3)
-			fmt.Println("ChartInfoRefresh Err:" + errMsg)
-		}
-	}()
-
-	edbInfoMapping, err := chartEdbMappingModel.GetEtaEdbChartEdbMapping(chartInfoId)
-	if err != nil {
-		errMsg = "获取需要刷新的ETA指标失败:Err:" + err.Error()
-		return
-	}
-	// 获取期货指标
-	futureGoodEdbInfoMapping, err := chartEdbMappingModel.GetFutureGoodEdbChartEdbMapping(chartInfoId)
-	if err != nil {
-		errMsg = "获取需要刷新的商品期货指标失败:Err:" + err.Error()
-		return
-	}
-
-	// 获取期货指标以及期货数据
-	futureGoodEdbInfoList, err := future_good_edb_info.GetFutureGoodEdbInfoListByParentId(futureGoodEdbInfoMapping.EdbInfoId)
-	if err != nil {
-		return
-	}
-
-	// 批量刷新ETA指标
-	err, _ = chart.EdbInfoRefreshAllFromBase([]int{edbInfoMapping.EdbInfoId}, false)
-	if err != nil {
-		return
-	}
-
-	// 批量刷新期货指标
-	err = FutureGoodEdbInfoRefreshAllFromBase(futureGoodEdbInfoList, false)
-	if err != nil {
-		return
-	}
-
-	return
-}
-
 // handleResultData 处理成最终的结果数据
-func handleResultData(regionType string, futureGoodEdbType int, yDataList []chart_info.YData, futureGoodEdbInfoList []*future_good_edb_info.FutureGoodEdbInfo, maxIndex int) (xDataList []chart_info.XData, newYDataList []chart_info.YData, err error) {
-	xDataList = make([]chart_info.XData, 0)
+func handleResultData(regionType string, futureGoodEdbType, baseEdbLen int, yDataList []chart_info.YData, futureGoodEdbInfoList []*future_good_edb_info.FutureGoodEdbInfo, maxIndex int) (xDataList []request.XData, newYDataList []chart_info.YData, err error) {
+	xDataList = make([]request.XData, 0)
 	newYDataList = yDataList
 
 	if regionType == `国内` {
@@ -607,7 +699,8 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []char
 			if i > maxIndex {
 				break
 			}
-			xDataList = append(xDataList, chart_info.XData{
+			// todo x轴 内容调整
+			xDataList = append(xDataList, request.XData{
 				Name:   fmt.Sprint("M+", i),
 				NameEn: fmt.Sprint("M+", i),
 			})
@@ -617,13 +710,13 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []char
 
 	futureGoodEdbInfoMap := make(map[int]*future_good_edb_info.FutureGoodEdbInfo)
 	for _, v := range futureGoodEdbInfoList {
-		futureGoodEdbInfoMap[int(v.FutureGoodEdbInfoID)] = v
+		futureGoodEdbInfoMap[v.FutureGoodEdbInfoID] = v
 	}
 
 	if futureGoodEdbType == 2 { // 	FutureGoodEdbType   int       `description:"指标类型,1:年月是固定的合约;2:只有M+N期的合约,未固定年月"`
 		nList := []int{3, 15, 27}
 		for _, i := range nList {
-			xDataList = append(xDataList, chart_info.XData{
+			xDataList = append(xDataList, request.XData{
 				Name:   fmt.Sprint("M+", i),
 				NameEn: fmt.Sprint("M+", i),
 			})
@@ -635,11 +728,11 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []char
 			tmpNList := nList
 
 			//当前的主力合约
-			newYDataList[yIndex].XEdbInfoIdList = append(newYDataList[yIndex].XEdbInfoIdList, yData.XEdbInfoIdList[0])
-			newYDataList[yIndex].Value = append(newYDataList[yIndex].Value, yData.Value[0])
+			newYDataList[yIndex].XEdbInfoIdList = append(newYDataList[yIndex].XEdbInfoIdList, yData.XEdbInfoIdList[0:baseEdbLen]...)
+			newYDataList[yIndex].Value = append(newYDataList[yIndex].Value, yData.Value[0:baseEdbLen]...)
 
-			xEdbInfoIdList := yData.XEdbInfoIdList[1:]
-			valIndex := 1
+			xEdbInfoIdList := yData.XEdbInfoIdList[baseEdbLen:]
+			valIndex := baseEdbLen
 			needNum := 0
 			for _, n := range tmpNList {
 				if len(xEdbInfoIdList) > 0 {
@@ -650,7 +743,7 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []char
 						return
 					}
 					// 当前距离最早的日期相差的N数
-					if int(futureGoodEdbInfo.Month) == n {
+					if futureGoodEdbInfo.Month == n {
 						if needNum > 0 {
 							currVal := yData.Value[valIndex]
 							preVal := yData.Value[valIndex-1]
@@ -712,7 +805,7 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []char
 		//v.XEdbInfoIdList
 		for edbInfoIndex, edbInfoId := range v.XEdbInfoIdList {
 			// 第一个不处理
-			if edbInfoIndex == 0 {
+			if edbInfoIndex <= baseEdbLen-1 {
 				continue
 			}
 
@@ -721,7 +814,7 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []char
 				err = errors.New("找不到指标")
 				return
 			}
-			n := (futureGoodEdbInfo.Year-currYear)*12 + int(futureGoodEdbInfo.Month) - int(currMonth)
+			n := (futureGoodEdbInfo.Year-currYear)*12 + futureGoodEdbInfo.Month - int(currMonth)
 			nMap[n] = n
 		}
 
@@ -739,7 +832,7 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []char
 	//prevMonth := 1
 
 	for _, n := range nList {
-		xDataList = append(xDataList, chart_info.XData{
+		xDataList = append(xDataList, request.XData{
 			Name:   fmt.Sprint("M+", n),
 			NameEn: fmt.Sprint("M+", n),
 		})
@@ -751,12 +844,12 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []char
 		tmpNList := nList
 
 		//当前的主力合约
-		newYDataList[yIndex].XEdbInfoIdList = append(newYDataList[yIndex].XEdbInfoIdList, yData.XEdbInfoIdList[0])
-		newYDataList[yIndex].Value = append(newYDataList[yIndex].Value, yData.Value[0])
+		newYDataList[yIndex].XEdbInfoIdList = append(newYDataList[yIndex].XEdbInfoIdList, yData.XEdbInfoIdList[0:baseEdbLen]...)
+		newYDataList[yIndex].Value = append(newYDataList[yIndex].Value, yData.Value[0:baseEdbLen]...)
 
-		xEdbInfoIdList := yData.XEdbInfoIdList[1:]
+		xEdbInfoIdList := yData.XEdbInfoIdList[baseEdbLen:]
 		currDataTime := yData.ConfigDate
-		valIndex := 1
+		valIndex := baseEdbLen
 		needNum := 0
 		for _, n := range tmpNList {
 			if len(xEdbInfoIdList) > 0 {
@@ -767,7 +860,7 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []char
 					return
 				}
 				// 当前距离最早的日期相差的N数
-				divMonth := (futureGoodEdbInfo.Year-currDataTime.Year())*12 + (int(futureGoodEdbInfo.Month) - int(currDataTime.Month()))
+				divMonth := (futureGoodEdbInfo.Year-currDataTime.Year())*12 + (futureGoodEdbInfo.Month - int(currDataTime.Month()))
 				if divMonth == n {
 					if needNum > 0 {
 						currVal := yData.Value[valIndex]
@@ -818,7 +911,6 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []char
 			newYDataList[yIndex].Value = yData.Value[0 : maxI+1]
 		}
 	}
-
 	return
 }
 
@@ -862,14 +954,14 @@ func getFutureGoodEdbInfoList(latestDateTime time.Time, tmpFutureGoodEdbInfoList
 		}
 		//海外的连续日期,目前
 		if v.FutureGoodEdbType == 2 {
-			if int(v.Month) <= maxM {
-				//addMonth := int(earliestDateTime.Month()) + int(v.Month)
+			if v.Month <= maxM {
+				//addMonth := int(earliestDateTime.Month()) + v.Month
 				//v.Year = earliestDateTime.Year() + addMonth/12
 				//realMonth := addMonth % 12
 				//if realMonth == 0 {
 				//	realMonth = 12
 				//}
-				//v.Month = uint32(realMonth)
+				//v.Month = realMonth
 				futureGoodEdbInfoList = append(futureGoodEdbInfoList, v)
 			}
 			continue
@@ -884,7 +976,7 @@ func getFutureGoodEdbInfoList(latestDateTime time.Time, tmpFutureGoodEdbInfoList
 			continue
 		}
 		// 如果(当前年-最新日期的年份) * 12个月 + (当前月-最新日期的月份) 小于总月份
-		if (v.Year-earliestDateTime.Year())*12+(int(v.Month)-int(earliestDateTime.Month())) <= maxM {
+		if (v.Year-earliestDateTime.Year())*12+(v.Month-int(earliestDateTime.Month())) <= maxM {
 			futureGoodEdbInfoList = append(futureGoodEdbInfoList, v)
 			continue
 		}
@@ -893,3 +985,109 @@ func getFutureGoodEdbInfoList(latestDateTime time.Time, tmpFutureGoodEdbInfoList
 
 	return
 }
+
+// GetNeedDateData 获取合约内需要的日期数据
+func GetNeedDateData(needDateTime time.Time, dataList []*edbDataModel.EdbDataList, edbDataMap map[string]float64, allEdbDataMap map[int]map[string]float64) (findDateTime time.Time, findDataValue float64, isFind bool, err error) {
+	//dataList := edbDataListMap[edbInfoId] //指标的所有数据值
+	if len(dataList) <= 0 {
+		// 没有数据的指标id
+		return
+	}
+
+	//最早的日期
+	minDateTime, err := time.ParseInLocation(utils.FormatDate, dataList[0].DataTime, time.Local)
+	if err != nil {
+		return
+	}
+
+	// 该日期存在数据的期货指标的最小数量,目前是现货和期货各1个,总共2个
+	maxCount := 1
+
+	for tmpDateTime := needDateTime; tmpDateTime.After(minDateTime) || tmpDateTime.Equal(minDateTime); tmpDateTime = tmpDateTime.AddDate(0, 0, -1) {
+		tmpDate := tmpDateTime.Format(utils.FormatDate)
+		tmpValue, ok := edbDataMap[tmpDate]
+		if !ok {
+			continue
+		}
+
+		// 该日期存在数据的指标数量
+		count := 0
+
+		for _, currEdbDataMap := range allEdbDataMap {
+			_, tmpIsFind := currEdbDataMap[tmpDate]
+			if tmpIsFind {
+				count++
+				if count >= maxCount {
+					continue
+				}
+			}
+		}
+
+		// 该日期存在数据的期货指标数量小于2个,那么要继续往前找
+		if count < maxCount {
+			continue
+		}
+
+		//如果能找到数据,那么就返回
+		// 数据为0,也直接返回,做无值处理
+		if tmpValue == 0 {
+			return
+		}
+		findDateTime, _ = time.ParseInLocation(utils.FormatDate, tmpDate, time.Local)
+		findDataValue = tmpValue
+		isFind = true
+		return
+	}
+
+	return
+}
+
+// FutureGoodChartInfoRefresh
+// @author Roc
+// @datetime 2023-2-2 18:44:46
+// @description 商品价格曲线图表刷新
+func FutureGoodChartInfoRefresh(chartInfoId int) (err error) {
+	var errMsg string
+	defer func() {
+		if err != nil {
+			go alarm_msg.SendAlarmMsg("ChartInfoRefresh:"+errMsg, 3)
+			fmt.Println("ChartInfoRefresh Err:" + errMsg)
+		}
+	}()
+
+	edbInfoMappingList, err := chartEdbMappingModel.GetEtaEdbChartEdbMappingList(chartInfoId)
+	if err != nil {
+		errMsg = "获取需要刷新的ETA指标失败:Err:" + err.Error()
+		return
+	}
+	edbInfoIds := make([]int, 0)
+	for _, edbInfoMapping := range edbInfoMappingList {
+		edbInfoIds = append(edbInfoIds, edbInfoMapping.EdbInfoId)
+	}
+	// 获取期货指标
+	futureGoodEdbInfoMapping, err := chartEdbMappingModel.GetFutureGoodEdbChartEdbMapping(chartInfoId)
+	if err != nil {
+		errMsg = "获取需要刷新的商品期货指标失败:Err:" + err.Error()
+		return
+	}
+
+	// 获取期货指标以及期货数据
+	futureGoodEdbInfoList, err := future_good_edb_info.GetFutureGoodEdbInfoListByParentId(futureGoodEdbInfoMapping.EdbInfoId)
+	if err != nil {
+		return
+	}
+
+	// 批量刷新ETA指标
+	err, _ = chart.EdbInfoRefreshAllFromBase(edbInfoIds, false)
+	if err != nil {
+		return
+	}
+
+	// 批量刷新期货指标
+	err = FutureGoodEdbInfoRefreshAllFromBase(futureGoodEdbInfoList, false)
+	if err != nil {
+		return
+	}
+
+	return
+}