edb_info_calculate.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package data_manage
  2. import (
  3. "eta_gn/eta_chart_lib/global"
  4. "eta_gn/eta_chart_lib/utils"
  5. "time"
  6. )
  7. func GetEdbInfoCalculateMap(edbInfoId, source int) (list []*EdbInfo, err error) {
  8. o := global.DmSQL["data"]
  9. sql := ` SELECT b.* FROM edb_info_calculate_mapping AS a
  10. INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
  11. WHERE a.edb_info_id=? ORDER BY sort ASC `
  12. err = o.Raw(sql, edbInfoId).Find(&list).Error
  13. return
  14. }
  15. func GetEdbInfoAllCalculateByEdbInfoIdList(edbInfoIdList []int) (list []*EdbInfo, err error) {
  16. num := len(edbInfoIdList)
  17. if num <= 0 {
  18. return
  19. }
  20. o := global.DmSQL["data"]
  21. sql := ` SELECT b.* FROM edb_info_calculate_mapping AS a
  22. INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
  23. WHERE a.from_edb_info_id in (` + utils.GetGormInReplace(num) + `)
  24. GROUP BY a.edb_info_id
  25. ORDER BY a.edb_info_id ASC `
  26. err = o.Raw(sql, edbInfoIdList).Scan(&list).Error
  27. return
  28. }
  29. type EdbInfoCalculateMappingInfo struct {
  30. EdbInfoCalculateMappingId int `gorm:"column:edb_info_calculate_mapping_id;primaryKey" description:"计算指标映射ID" orm:"column(edb_info_calculate_mapping_id);pk"`
  31. EdbInfoId int `gorm:"column:edb_info_id" description:"计算指标id"`
  32. Source int `gorm:"column:source" description:"计算指标来源"`
  33. SourceName string `gorm:"column:source_name" description:"计算指标来源名称"`
  34. EdbCode string `gorm:"column:edb_code" description:"计算指标编码"`
  35. FromEdbInfoId int `gorm:"column:from_edb_info_id" description:"基础指标id"`
  36. FromEdbCode string `gorm:"column:from_edb_code" description:"基础指标编码"`
  37. FromEdbName string `gorm:"column:from_edb_name" description:"基础指标名称"`
  38. FromSource int `gorm:"column:from_source" description:"基础指标来源"`
  39. FromSourceName string `gorm:"column:from_source_name" description:"基础指标来源名称"`
  40. MoveValue int `gorm:"column:move_value" description:"领先值"`
  41. FromTag string `gorm:"column:from_tag" description:"来源指标标签"`
  42. Sort int `gorm:"column:sort" description:"计算指标名称排序"`
  43. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  44. ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"`
  45. FromEdbType int `gorm:"column:from_edb_type" description:"来源指标类型:1:基础指标,2:计算指标"`
  46. FromEdbInfoType int `gorm:"column:from_edb_info_type" description:"来源指标类型: 0-基础指标; 1-预测指标"`
  47. FromClassifyId int `gorm:"column:from_classify_id" description:"来源指标分类ID"`
  48. FromUniqueCode string `gorm:"column:from_unique_code" description:"来源指标唯一编码"`
  49. }
  50. func GetEdbInfoCalculateMappingListByEdbInfoId(edbInfoId int) (items []*EdbInfoCalculateMappingInfo, err error) {
  51. o := global.DmSQL["data"]
  52. sql := ` SELECT a.*,b.edb_type as from_edb_type,b.edb_info_type as from_edb_info_type, b.unique_code AS from_unique_code, b.classify_id AS from_classify_id FROM edb_info_calculate_mapping AS a
  53. INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
  54. WHERE a.edb_info_id=? `
  55. err = o.Raw(sql, edbInfoId).Scan(&items).Error
  56. return
  57. }