package chart_info

import (
	"hongze/hongze_yb/models/request"
	responseModel "hongze/hongze_yb/models/response"
	"hongze/hongze_yb/models/tables/chart_edb_mapping"
	"hongze/hongze_yb/models/tables/chart_info"
	"time"
)

type ChartInfoDetailResp struct {
	ChartInfo            *chart_info.ChartInfoView
	EdbInfoList          []*chart_edb_mapping.ChartEdbInfoMappingList
	XEdbIdValue          []int   `description:"柱方图的x轴数据，指标id"`
	XDataList            []XData `description:"商品价格曲线的X轴数据"`
	YDataList            []YData `description:"柱方图的y轴数据"`
	MyChartInfo          *responseModel.MyChartItem
	CorrelationChartInfo *CorrelationInfo `description:"相关性图表信息"`
	DataResp             interface{}      `description:"图表数据,根据图的类型而定的,没有确定的数据格式"`
}

type ChartLibChartInfoDetailResp struct {
	ChartInfo            *chart_info.ChartInfoView
	EdbInfoList          []*chart_edb_mapping.ChartEdbInfoMappingTimeString
	XEdbIdValue          []int            `description:"柱方图的x轴数据，指标id"`
	XDataList            []XData          `description:"商品价格曲线的X轴数据"`
	YDataList            []YData          `description:"柱方图的y轴数据"`
	CorrelationChartInfo *CorrelationInfo `description:"相关性图表信息"`
	DataResp             interface{}      `description:"图表数据,根据图的类型而定的,没有确定的数据格式"`
	WaterMark            string           `description:"水印"`
}

// XData 商品价格曲线的的x轴数据
type XData struct {
	Name   string `description:"别名"`
	NameEn string `description:"英文别名"`
	IsHide int    `description:"是否隐藏，0不隐藏，1隐藏"`
}

// YData 柱方图的y轴数据
type YData struct {
	Date           string          `description:"数据日期"`
	ConfigDate     time.Time       `description:"配置的日期" json:"-"`
	Color          string          `description:"数据颜色"`
	Name           string          `description:"别名"`
	NameEn         string          `description:"英文别名"`
	Value          []float64       `description:"每个指标的值"`
	NoDataEdbList  []int           `description:"没有数据的指标列表"`
	XEdbInfoIdList []int           `description:"对应X轴的指标id列表"`
	EdbValMap      map[int]float64 `description:"指标与值的对应" json:"-"`
	M              []int           `description:"对应开始日期的间隔值" json:"-"`
	NameList       []string        `description:"每个值对应的名称"`
	EnNameList     []string        `description:"每个值对应的英文名称"`
	Unit           string          `description:"中文单位名称"`
	UnitEn         string          `description:"英文单位名称"`
	SeriesEdb      struct {
		SeriesId  int `description:"因子指标系列ID"`
		EdbInfoId int `description:"指标ID"`
	} `description:"对应的系列指标"`
}

type CorrelationInfo struct {
	LeadValue       int    `description:"领先值"`
	LeadUnit        string `description:"领先单位"`
	StartDate       string `description:"开始日期"`
	EndDate         string `description:"结束日期"`
	EdbInfoIdFirst  int    `description:"A指标ID"`
	EdbInfoIdSecond int    `description:"B指标ID"`
	PeriodData      string `description:"X轴-期数数据"`
	CorrelationData string `description:"Y轴-相关性系数"`
	AnalysisMode    int    `description:"分析模式: 0-单因子; 1-多因子"`
}

// RollingCorrelationChartDataResp 滚动相关性图
type RollingCorrelationChartDataResp struct {
	XDateTimeValue []string `description:"滚动相关性图的x轴数据，日期数据"`
	YDataList      []YData  `description:"滚动相关性图的y轴数据"`
}

// ProfitFutureGoodChartResp 商品利润图
type ProfitFutureGoodChartResp struct {
	XDataList    []XData
	YDataList    []YData
	ProfitName   string               `description:"利润的名称"`
	ProfitNameEn string               `description:"利润的英文名称"`
	Extra        request.ChartInfoReq `description:"柱方图的配置"`
}

// RadarChartInfoResp 雷达图数据
type RadarChartInfoResp struct {
	YDataList   []RadarYData `description:"数据列"`
	XEdbIdValue []int
}

// RadarYData 雷达图的y轴数据
type RadarYData struct {
	Date  string    `description:"数据日期"`
	Color string    `description:"数据颜色"`
	Name  string    `description:"别名"`
	Value []float64 `description:"每个指标的值"`
}

// 截面组合图额外配置
type ChartSectionExtraConf struct {
	DateConfList        []*ChartSectionDateConfItem
	IsHeap              int                      `description:"是否堆积（1.堆积，0不堆积）"`
	XDataList           []XData                  `description:"横轴名称设置"`
	UnitList            *ChartSectionCombineUnit `description:"纵轴单位设置"`
	BaseChartSeriesName string                   `description:"基准系列名称"`
	SortType            int                      `description:"排序类型，0默认，1升序，2降序"`
}

// 截面组合图额外配置
type ChartSectionAllExtraConf struct {
	ChartSectionExtraConf
	SeriesList []*ChartSectionSeriesItem
}

type ChartSectionDateConfItem struct {
	MoveForward    int    `description:"前移的期数"`
	EdbInfoId      int    `description:"指标ID"`
	EdbName        string `description:"指标名称"`
	EdbNameEn      string `description:"指标名称英文"`
	EdbInfoType    int    `description:"指标类型"`
	Frequency      string `description:"频度"`
	EndDate        string `description:"最新日期"`
	StaticDate     string `description:"固定日期"`
	DateType       int    `description:"日期类型:0 指标日期，1系统日期, 2固定日期"`
	DateConfName   string `description:"引用日期名称"` // 引用日期名称不能重复
	DateConfNameEn string `description:"引用日期英文名称"`
	DateChange     []*ChartSectionDateChange
}

// 截面组合图引用日期配置
type ChartSectionDateChange struct {
	Year         int
	Month        int
	Day          int
	Frequency    string `description:"频度变换"`
	FrequencyDay string `description:"频度的固定日期"`
	ChangeType   int    `description:"日期变换类型1日期位移，2指定频率"`
}

// 截面组合图系列配置
type ChartSectionSeriesItem struct {
	ChartSeriesId int     `description:"系列ID"`
	SeriesName    string  `description:"系列名称"` //系列名称不可同名
	SeriesNameEn  string  `description:"系列英文名称"`
	ChartStyle    string  `description:"图表类型"`
	ChartColor    string  `description:"颜色"`
	ChartWidth    int     `description:"线条大小"`
	IsPoint       int     `description:"是否用数据点展示（0 否，1是）"`
	IsNumber      int     `description:"是否用数值展示（0 否，1是）"`
	IsAxis        int     `description:"1:左轴,0:右轴"`
	MaxData       float64 `description:"上限"`
	MinData       float64 `description:"下限"`
	//IsOrder         bool    `description:"true:正序,false:逆序"`
	EdbInfoList    []*ChartSectionSeriesEdbConf
	DataList       []float64
	NoDataEdbIndex []int
}
type ChartSectionSeriesEdbConf struct {
	ChartSeriesEdbMappingId int `description:"映射ID"`
	ChartSeriesId           int `description:"系列ID"`
	//ChartInfoId             int `description:"图表ID"`
	EdbInfoId    int `description:"指标id"`
	DateConf     *ChartSectionSeriesDateConfItem
	EdbName      string `description:"中文别名"`
	EdbNameEn    string `description:"英文别名"`
	EdbInfoType  int    `description:"指标类型"`
	Unit         string `description:"单位"`
	UnitEn       string `description:"英文单位"`
	DateConfName string `description:"引用日期名称"`
	DateConfType int    `description:"日期类型，0指标最新日期， 1引用日期"`
}

// 系列里的指标日期配置
type ChartSectionSeriesDateConfItem struct {
	MoveForward int `description:"前移的期数"`
	DateChange  []*ChartSectionDateChange
}

// PreviewSectionCombineChartReq 预览截面组合图的请求
type PreviewSectionCombineChartReq struct {
	ChartName       string `description:"图表名称"`
	ChartClassifyId int    `description:"分类id"`
	ExtraConfig     string `description:"图表额外配置信息,json字符串"`
}

type ChartSectionCombineUnit struct {
	LeftName       string `description:"左轴单位"`
	LeftNameEn     string `description:"左轴英文单位"`
	RightName      string `description:"右轴单位"`
	RightNameEn    string `description:"右轴英文单位"`
	RightTwoName   string `description:"右2轴单位"`
	RightTwoNameEn string `description:"右2轴英文单位"`
}

type ChartSectionCombineDataResp struct {
	DateConfList        []*ChartSectionDateConfItem
	IsHeap              int                      `description:"是否堆积（1.堆积，0不堆积）"`
	XDataList           []XData                  `description:"横轴名称设置"`
	UnitList            *ChartSectionCombineUnit `description:"纵轴单位设置"`
	BaseChartSeriesName string                   `description:"基准系列名称"`
	SortType            int                      `description:"排序类型，0默认，1升序，2降序"`
	SeriesList          []*ChartSectionSeriesItem
	LeftMin             string `description:"图表左侧最小值"`
	LeftMax             string `description:"图表左侧最大值"`
	RightMin            string `description:"图表右侧最小值"`
	RightMax            string `description:"图表右侧最大值"`
	Right2Min           string `description:"图表右侧最小值"`
	Right2Max           string `description:"图表右侧最大值"`
}

// 时序组合图额外配置
type ChartTimeCombineExtraConf struct {
	IsHeap int `description:"是否堆积（1.堆积，0不堆积）"`
}

type ChartTimeCombineDataResp struct {
	IsHeap int `description:"是否堆积（1.堆积，0不堆积）"`
}
