calculate_residual_analysis_config.go 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package residual_analysis_model
  2. import (
  3. "eta/eta_api/models/data_manage"
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. type CalculateResidualAnalysisConfig struct {
  7. CalculateResidualAnalysisConfigId int `orm:"column(calculate_residual_analysis_config_id);pk;auto" description:"自增id"`
  8. Config string `orm:"column(config)" description:"计算参数配置"`
  9. SysUserId int `orm:"column(sys_user_id)" description:"操作人id"`
  10. CreateTime string `orm:"column(create_time)" description:"创建时间"`
  11. ModifyTime string `orm:"column(modify_time)" description:"修改时间"`
  12. }
  13. func init() {
  14. orm.RegisterModel(new(CalculateResidualAnalysisConfig))
  15. }
  16. // ResidualAnalysisReq 残差分析预览请求
  17. type ResidualAnalysisReq struct {
  18. EdbInfoIdA int `description:"指标A"`
  19. EdbInfoIdB int `description:"指标B"`
  20. EdbInfoId int `description:"残差指标id"`
  21. ResidualType int `description:"残差类型: 1-映射残差 2-拟合残差"`
  22. DateType int `description:"时间类型 -1-自定义时间 0-至今 n-枚举时间(近n年)"`
  23. StartDate string `description:"自定义开始日期"`
  24. EndDate string `description:"自定义结束日期"`
  25. IsOrder bool `description:"true:正序,false:逆序"`
  26. IndexType int `description:"1-标准指标 2-领先指标"`
  27. LeadValue int `description:"领先值"`
  28. LeadFrequency string `description:"领先频度"`
  29. LeftIndexMin float64 `description:"指标A左侧下限"`
  30. LeftIndexMax float64 `description:"指标A左侧上限"`
  31. RightIndexMin float64 `description:"指标B右侧下限"`
  32. RightIndexMax float64 `description:"指标B右侧上限"`
  33. ResidualIndexMin float64 `description:"残差指标下限"`
  34. ResidualIndexMax float64 `description:"残差指标上限"`
  35. ContrastIndexMin float64 `description:"对比指标下限"`
  36. ContrastIndexMax float64 `description:"对比指标上限"`
  37. }
  38. // ResidualAnalysisResp 残差分析预览响应
  39. type ResidualAnalysisResp struct {
  40. OriginalChartData ChartResp `description:"原始图数据"`
  41. MappingChartData ChartResp `description:"映射图数据"`
  42. ResidualChartData ChartResp `description:"残差图数据"`
  43. }
  44. type ChartResp struct {
  45. ChartInfo *ResidualAnalysisChartInfo
  46. EdbInfoList []ResidualAnalysisChartEdbInfoMapping
  47. }
  48. type ResidualAnalysisChartInfo struct {
  49. ChartName string `description:"来源名称"`
  50. ChartNameEn string `description:"英文图表名称"`
  51. Unit string `description:"中文单位名称"`
  52. UnitEn string `description:"英文单位名称"`
  53. UniqueCode string `description:"图表唯一编码"`
  54. DateType int `description:"时间类型 0-自定义时间 1-至今 n-枚举时间(近n年)"`
  55. StartDate string `description:"自定义开始日期"`
  56. EndDate string `description:"自定义结束日期"`
  57. ChartType int `description:"生成样式:1:曲线图,2:季节性图"`
  58. ChartWidth float64 `description:"线条大小"`
  59. Calendar string `description:"公历/农历"`
  60. Disabled int `description:"是否禁用,0:启用,1:禁用,默认:0"`
  61. Source int `description:"1:ETA图库;2:商品价格曲线;3:相关性图表"`
  62. ChartSource string `description:"图表来源str"`
  63. ChartSourceEn string `description:"图表来源(英文)"`
  64. SourcesFrom string `description:"图表来源"`
  65. Instructions string `description:"图表说明"`
  66. }
  67. type ResidualAnalysisChartEdbInfoMapping struct {
  68. EdbInfoId int `description:"指标id"`
  69. SourceName string `description:"来源名称"`
  70. Source int `description:"来源id"`
  71. EdbCode string `description:"指标编码"`
  72. EdbName string `description:"指标名称"`
  73. EdbNameEn string `description:"英文指标名称"`
  74. EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
  75. Frequency string `description:"频率"`
  76. FrequencyEn string `description:"英文频率"`
  77. Unit string `description:"单位"`
  78. UnitEn string `description:"英文单位"`
  79. StartDate string `description:"起始日期"`
  80. EndDate string `description:"终止日期"`
  81. ModifyTime string `description:"指标最后更新时间"`
  82. MaxData float64 `description:"上限"`
  83. MinData float64 `description:"下限"`
  84. IsOrder bool `description:"true:正序,false:逆序"`
  85. IsAxis int `description:"1:左轴,0:右轴"`
  86. EdbInfoType int `description:"1:标准指标,0:领先指标"`
  87. EdbInfoCategoryType int `description:"0:普通指标,1:预测指标"`
  88. LeadValue int `description:"领先值"`
  89. LeadUnit string `description:"领先单位"`
  90. LeadUnitEn string `description:"领先英文单位"`
  91. ChartStyle string `description:"图表类型"`
  92. ChartColor string `description:"颜色"`
  93. PredictChartColor string `description:"预测数据的颜色"`
  94. ChartWidth float64 `description:"线条大小"`
  95. ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图,8:商品价格曲线图,9:相关性图"`
  96. LatestDate string `description:"数据最新日期"`
  97. LatestValue float64 `description:"数据最新值"`
  98. MinValue float64 `json:"-" description:"最小值"`
  99. MaxValue float64 `json:"-" description:"最大值"`
  100. DataList interface{}
  101. }
  102. type ResidualAnalysisIndexSaveReq struct {
  103. EdbCode string `description:"指标编码"`
  104. EdbName string `description:"指标名称"`
  105. EdbNameEn string `description:"英文指标名称"`
  106. EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
  107. Frequency string `description:"频率"`
  108. FrequencyEn string `description:"英文频率"`
  109. Unit string `description:"单位"`
  110. UnitEn string `description:"英文单位"`
  111. ClassifyId int `description:"分类id"`
  112. ConfigId int `description:"残差配置id"`
  113. ResidualType int `orm:"column(residual_type)" description:"残差类型: 1-映射残差 2-拟合残差"`
  114. DataList []ResidualAnalysisData `description:"指标数据"`
  115. }
  116. // ResidualAnalysisConfigVo 残差分析配置vo
  117. type ResidualAnalysisConfigVo struct {
  118. DateType int `description:"时间类型 -1-自定义时间 0-至今 n-枚举时间(近n年)"`
  119. StartDate string `description:"自定义开始日期"`
  120. EndDate string `description:"自定义结束日期"`
  121. IsOrder bool `description:"true:正序,false:逆序"`
  122. IndexType int `description:"1-标准指标 2-领先指标"`
  123. LeadValue int `description:"领先值"`
  124. LeadFrequency string `description:"领先频度"`
  125. LeftIndexMin float64 `description:"指标A左侧下限"`
  126. LeftIndexMax float64 `description:"指标A左侧上限"`
  127. RightIndexMin float64 `description:"指标B右侧下限"`
  128. RightIndexMax float64 `description:"指标B右侧上限"`
  129. ResidualIndexMin float64 `description:"残差指标下限"`
  130. ResidualIndexMax float64 `description:"残差指标上限"`
  131. ContrastIndexMin float64 `description:"对比指标下限"`
  132. ContrastIndexMax float64 `description:"对比指标上限"`
  133. }
  134. // ResidualAnalysisDetailResp 详情响应接口
  135. type ResidualAnalysisDetailResp struct {
  136. ConfigInfo *CalculateResidualAnalysisConfig
  137. EdbInfoList []*data_manage.EdbInfoList
  138. }
  139. // GetResidualAnalysisConfigById 根据配置id查询配置信息
  140. func GetResidualAnalysisConfigById(configId int) (residualAnalysisConfig CalculateResidualAnalysisConfig, err error) {
  141. o := orm.NewOrm()
  142. sql := "SELECT * FROM residual_analysis_config WHERE calculate_residual_analysis_config_id=?"
  143. err = o.Raw(sql, configId).QueryRow(&residualAnalysisConfig)
  144. return residualAnalysisConfig, nil
  145. }
  146. // UpdateResidualAnalysisConfig 更新配置信息
  147. func UpdateResidualAnalysisConfig(config CalculateResidualAnalysisConfig) (err error) {
  148. o := orm.NewOrm()
  149. _, err = o.Update(config)
  150. if err != nil {
  151. return err
  152. }
  153. return nil
  154. }
  155. // SaveResidualAnalysisConfig 保存配置信息
  156. func SaveResidualAnalysisConfig(config CalculateResidualAnalysisConfig) (id int64, err error) {
  157. o := orm.NewOrm()
  158. id, err = o.Insert(config)
  159. if err != nil {
  160. return 0, err
  161. }
  162. return id, nil
  163. }