package request

// 单元格的数据类型
const (
	DateDT                   = iota + 1 //日期
	EdbDT                               // 2 指标类型
	CustomTextDT                        // 3 自定义文本
	InsertDataDT                        // 4 插值(插入指标值,表格上,自动判断日期和指标的交集位置,插入值)
	PopInsertDataDT                     // 5 弹框插值(在表格上选择日期,然后空白单元格选择弹框并选择指标,插入该指标与该日期的值)
	FormulateCalculateDataDT            // 6 公式计算(A+B这种)
	InsertEdbCalculateDataDT            // 7 插入指标系统计算公式生成的值
)

// 单元格的日期类型类型
const (
	CustomDateT = iota //手动输入日期
	SystemDateT        // 系统日期
	EdbDateDT          // 导入指标日期(指标库的最新日期)
)

// 单元格的日期类型类型
const (
	SystemCurrDateT      = iota + 1 //系统当前日期
	SystemCalculateDateT            // 系统日期计算后的日期
	SystemFrequencyDateT            // 导入系统日期相关的指定频率(所在周/旬/月/季/半年/年的最后/最早一天)
)

// MixedTableReq 混合表格保存请求参数
type MixedTableReq struct {
	CellRelation string                    `description:"单元格关系"`
	Data         [][]MixedTableCellDataReq `description:"混合表格单元格参数"`
}

// MixedTableCellDataReq 混合表格单元格参数
type MixedTableCellDataReq struct {
	Uid          string `description:"单元格唯一标识"`
	DataType     int    `description:"数据类型,1:日期,2:指标,3:自定义文本,4:插值"`
	DataTime     string `description:"所属日期"`
	DataTimeType int    `description:"日期类型:0:手动输入日期;1:导入系统日期;;3:导入指标日期(指标库的最新日期);"`
	EdbInfoId    int    `description:"指标id"`
	ShowValue    string `description:"展示值"`
	Value        string `description:"实际值"`
	Extra        string `description:"额外参数"`
}

// CellRelationConf
// @Description: 单元格的关系配置结构体
type CellRelationConf struct {
	CellRelation
	//Type         int          `json:"type" description:"数据类型,跟MixedTableCellDataReq的DataType保持一致"`
	//Key          string       `json:"key" description:"单元格的唯一标识"`
	RelationDate CellRelation `json:"relation_date"`
	RelationEdb  CellRelation `json:"relation_edb"`
}

// CellRelation
// @Description: 单元格的关系结构体
type CellRelation struct {
	Type int    `json:"type" description:"数据类型,跟MixedTableCellDataReq的DataType保持一致"`
	Key  string `json:"key" description:"单元格的唯一标识"`
}

// SystemDateConf
// @Description: 系统导入日期配置
type SystemDateConf struct {
	Source             int    `description:"类型,1:导入系统日期;2:导入系统日期计算后的日期;3:导入系统日期相关的指定频率"`
	CalculateNum       int    `description:"计算频度的数量"`
	CalculateFrequency string `description:"计算频度"`
	Frequency          string `description:"指定频度"`
	Day                string `description:"指定日期"`
}

// EdbDateConf
// @Description: 导入指标日期配置
type EdbDateConf struct {
	EdbInfoId int `description:"指标id"`
}

// CalculateConf
// @Description: 计算公式
type CalculateConf struct {
	EdbInfoId     int         `description:"指标id"`
	DataTime      string      `description:"所属日期,这个日期有传递的话,那么就取上下两期+自己的数据;没有传就默认最近5期的数据"`
	Frequency     string      `description:"需要转换的频度"`
	Formula       interface{} `description:"计算公式,默认是string,实际上还需要转成其他样式"`
	Calendar      string      `description:"公历/农历"`
	MoveType      int         `description:"移动方式:1:领先(默认),2:滞后"`
	MoveFrequency string      `description:"移动频度"`
	Source        int         `description:"1:累计值转月;2:累计值转季;3:同比值;4:同差值;5:N数值移动平均数计算;6:环比值;7:环差值;8:升频;9:降频;10:时间移位;11:超季节性;12:年化;13:累计值;14:累计值年初至今;15:指数修匀;16:日均值"`
}

// BaseCalculateConf
// @Description: 基础计算公式(A+B)
type BaseCalculateConf struct {
	Formula             string         `description:"计算公式,默认是string,实际上还需要转成其他样式"`
	RelationEdbInfoList []RelationCell `description:"关联单元格(计算公式中关联的单元格,用于计算的时候去匹配)"`
}

// RelationCell
// @Description: 关联单元格的信息
type RelationCell struct {
	Tag string `description:"指标标签"`
	Row string `description:"第几行"`
	Key string `json:"key" description:"单元格的唯一标识"`
}