chart_info.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package data_manage
  2. import (
  3. "eta_gn/eta_task/global"
  4. "eta_gn/eta_task/utils"
  5. "time"
  6. )
  7. type ChartInfo struct {
  8. ChartInfoId int `gorm:"column:chart_info_id;primaryKey"` // `orm:"column(chart_info_id);pk"`
  9. ChartName string `description:"来源名称"`
  10. ChartClassifyId int `description:"图表分类id"`
  11. SysUserId int
  12. SysUserRealName string
  13. UniqueCode string `description:"图表唯一编码"`
  14. CreateTime time.Time
  15. ModifyTime time.Time
  16. DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
  17. StartDate string `description:"自定义开始日期"`
  18. EndDate string `description:"自定义结束日期"`
  19. IsSetName int `description:"设置名称"`
  20. EdbInfoIds string `description:"指标id"`
  21. ChartType int `description:"生成样式:1:曲线图,2:季节性图"`
  22. Calendar string `description:"公历/农历"`
  23. SeasonStartDate string `description:"季节性图开始日期"`
  24. SeasonEndDate string `description:"季节性图开始日期"`
  25. ChartImage string `description:"图表图片"`
  26. Sort int `description:"排序字段,数字越小越排前面"`
  27. EdbEndDate string `description:"指标最后更新日期"`
  28. Source int `description:"1:ETA图库;2:商品价格曲线"`
  29. ExtraConfig string `description:"图表额外配置,json数据"`
  30. }
  31. func GetAllChartInfo() (list []*ChartInfo, err error) {
  32. //o := orm.NewOrm()
  33. sql := ` SELECT * FROM chart_info `
  34. //_, err = o.Raw(sql).QueryRows(&list)
  35. err = global.DEFAULT_DmSQL.Raw(sql).Find(&list).Error
  36. return
  37. }
  38. func GetChartInfoEdbEndDate() (list []*ChartInfo, err error) {
  39. //o := orm.NewOrm()
  40. //sql := ` SELECT a.*,max(c.end_date) AS edb_end_date FROM chart_info AS a
  41. // INNER JOIN chart_edb_mapping AS b ON a.chart_info_id=b.chart_info_id
  42. // INNER JOIN edb_info AS c ON b.edb_info_id=c.edb_info_id
  43. // GROUP BY a.chart_info_id `
  44. sql := `SELECT a.chart_info_id, a.chart_name, a.unique_code, a.chart_classify_id, a.sys_user_id, a.sys_user_real_name, a.create_time, a.modify_time, a.date_type, a.start_date, a.end_date, a.is_set_name, a.edb_info_ids, a.chart_type, a.calendar, a.season_start_date, a.season_end_date, a.chart_image, a.sort, a.edb_end_date, a.x_min, a.x_max, a.left_min, a.left_max, a.right_min, a.right_max, a.right2_min, a.right2_max, a.min_max_save, a.chart_name_en, a.disabled, a.bar_config, a.source, a.extra_config, a.season_extra_config, a.start_year, a.chart_theme_id, a.sources_from, a.instructions, a.markers_lines, a.markers_areas, a.unit, a.unit_en, a.is_join_permission, a.forum_chart_info_id, a.chart_alias, a.date_type_num,max(c.end_date) AS edb_end_date FROM chart_info AS a
  45. INNER JOIN chart_edb_mapping AS b ON a.chart_info_id=b.chart_info_id
  46. INNER JOIN edb_info AS c ON b.edb_info_id=c.edb_info_id
  47. GROUP BY a.chart_info_id, a.chart_name, a.unique_code, a.chart_classify_id, a.sys_user_id, a.sys_user_real_name, a.create_time, a.modify_time, a.date_type, a.start_date, a.end_date, a.is_set_name, a.edb_info_ids, a.chart_type, a.calendar, a.season_start_date, a.season_end_date, a.chart_image, a.sort, a.edb_end_date, a.x_min, a.x_max, a.left_min, a.left_max, a.right_min, a.right_max, a.right2_min, a.right2_max, a.min_max_save, a.chart_name_en, a.disabled, a.bar_config, a.source, a.extra_config, a.season_extra_config, a.start_year, a.chart_theme_id, a.sources_from, a.instructions, a.markers_lines, a.markers_areas, a.unit, a.unit_en, a.is_join_permission, a.forum_chart_info_id, a.chart_alias, a.date_type_num `
  48. //_, err = o.Raw(sql).QueryRows(&list)
  49. err = global.DEFAULT_DmSQL.Raw(sql).Find(&list).Error
  50. return
  51. }
  52. func ModifyChartInfoEdbEndDate(chartInfoId int, edbEndDate string) (err error) {
  53. //o := orm.NewOrm()
  54. sql := ` UPDATE chart_info SET edb_end_date=? WHERE chart_info_id=? `
  55. //_, err = o.Raw(sql, edbEndDate, chartInfoId).Exec()
  56. err = global.DEFAULT_DmSQL.Exec(sql, edbEndDate, chartInfoId).Error
  57. return
  58. }
  59. // 根据chart_info_id数组获取图表信息
  60. func GetChartInfoByChartInfoIds(chartInfoIds []int) (list []*ChartInfo, err error) {
  61. //o := orm.NewOrmUsingDB("data")
  62. sql := ` SELECT * FROM chart_info WHERE chart_info_id IN (` + utils.GetOrmInReplace(len(chartInfoIds)) + `) `
  63. //_, err = o.Raw(sql, chartInfoIds).QueryRows(&list)
  64. err = global.DmSQL["data"].Raw(sql, chartInfoIds).Find(&list).Error
  65. return
  66. }