edb_info_calculate_mapping.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package data_manage
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "time"
  6. )
  7. // EdbInfoCalculateMapping 计算指标于基础指标,关系表
  8. type EdbInfoCalculateMapping struct {
  9. EdbInfoCalculateMappingId int `orm:"column(edb_info_calculate_mapping_id);pk" gorm:"primaryKey" `
  10. EdbInfoId int `description:"计算指标id"`
  11. Source int `description:"计算指标来源"`
  12. SourceName string `description:"计算指标来源名称"`
  13. EdbCode string `description:"计算指标编码"`
  14. FromEdbInfoId int `description:"基础指标id"`
  15. FromEdbCode string `description:"基础指标编码"`
  16. FromEdbName string `description:"基础指标名称"`
  17. FromSource int `description:"基础指标来源"`
  18. FromSourceName string `description:"基础指标来源名称"`
  19. FromTag string `description:"来源指标标签"`
  20. Sort int `description:"计算指标名称排序"`
  21. CreateTime time.Time `description:"创建时间"`
  22. ModifyTime time.Time `description:"修改时间"`
  23. }
  24. func GetEdbInfoCalculateMappingCount(edbInfoId int) (count int, err error) {
  25. o := global.DmSQL["data"]
  26. sql := ` SELECT COUNT(1) AS count FROM edb_info_calculate_mapping WHERE from_edb_info_id=? `
  27. err = o.Raw(sql, edbInfoId).Scan(&count).Error
  28. return
  29. }
  30. type EdbInfoCalculateMappingView struct {
  31. EdbInfoCalculateMappingId int `orm:"column(edb_info_calculate_mapping_id);pk" gorm:"primaryKey" `
  32. EdbInfoId int `description:"计算指标id"`
  33. Source int `description:"计算指标来源"`
  34. SourceName string `description:"计算指标来源名称"`
  35. EdbCode string `description:"计算指标编码"`
  36. FromEdbInfoId int `description:"基础指标id"`
  37. FromEdbCode string `description:"基础指标编码"`
  38. FromEdbName string `description:"基础指标名称"`
  39. FromSource int `description:"基础指标来源"`
  40. FromSourceName string `description:"基础指标来源名称"`
  41. FromTag string `description:"来源指标标签"`
  42. Sort int `description:"计算指标名称排序"`
  43. CreateTime time.Time `description:"创建时间"`
  44. ModifyTime time.Time `description:"修改时间"`
  45. StartDate string `description:"开始日期"`
  46. EndDate string `description:"结束日期"`
  47. CalculateFormula string `description:"N值"`
  48. MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
  49. MoveFrequency string `description:"移动频度"`
  50. }
  51. func GetEdbInfoCalculateMappingDetail(edbInfoId int) (item *EdbInfoCalculateMappingView, err error) {
  52. o := global.DmSQL["data"]
  53. sql := ` SELECT a.*,b.start_date,b.end_date,b.calculate_formula,b.move_type,b.move_frequency FROM edb_info_calculate_mapping AS a
  54. INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
  55. WHERE a.edb_info_id=? `
  56. err = o.Raw(sql, edbInfoId).Scan(&item).Error
  57. return
  58. }
  59. // EdbInfoCalculateMappingInfo
  60. // @Description: 计算指标与基础指标关系表
  61. type EdbInfoCalculateMappingInfo struct {
  62. EdbInfoCalculateMappingId int `orm:"column(edb_info_calculate_mapping_id);pk" gorm:"primaryKey" `
  63. EdbInfoId int `description:"计算指标id"`
  64. Source int `description:"计算指标来源"`
  65. SourceName string `description:"计算指标来源名称"`
  66. EdbCode string `description:"计算指标编码"`
  67. FromEdbInfoId int `description:"基础指标id"`
  68. FromEdbCode string `description:"基础指标编码"`
  69. FromEdbName string `description:"基础指标名称"`
  70. FromSource int `description:"基础指标来源"`
  71. FromSourceName string `description:"基础指标来源名称"`
  72. MoveValue int `description:"领先值"`
  73. FromTag string `description:"来源指标标签"`
  74. Sort int `description:"计算指标名称排序"`
  75. CreateTime time.Time `description:"创建时间"`
  76. ModifyTime time.Time `description:"修改时间"`
  77. FromEdbType int `description:"来源指标类型:1:基础指标,2:计算指标"`
  78. FromEdbInfoType int `description:"来源指标类型: 0-基础指标; 1-预测指标"`
  79. FromClassifyId int `description:"来源指标分类ID"`
  80. FromUniqueCode string `description:"来源指标唯一编码"`
  81. NoUpdate int8 `description:"是否停止更新,0:继续更新;1:停止更新"`
  82. }
  83. // GetEdbInfoCalculateMappingListByEdbInfoId 根据生成的指标id获取来源的指标id列表
  84. func GetEdbInfoCalculateMappingListByEdbInfoId(edbInfoId int) (items []*EdbInfoCalculateMappingInfo, err error) {
  85. o := global.DmSQL["data"]
  86. 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,b.no_update FROM edb_info_calculate_mapping AS a
  87. INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
  88. WHERE a.edb_info_id=? `
  89. err = o.Raw(sql, edbInfoId).Scan(&items).Error
  90. return
  91. }
  92. // GetEdbInfoCalculateMappingListByEdbInfoIds 根据生成的指标id获取来源的指标id列表
  93. func GetEdbInfoCalculateMappingListByEdbInfoIds(edbInfoIds []int) (items []*EdbInfoCalculateMappingInfo, err error) {
  94. o := global.DmSQL["data"]
  95. 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,b.no_update FROM edb_info_calculate_mapping AS a
  96. INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
  97. WHERE a.edb_info_id in (` + utils.GetOrmInReplace(len(edbInfoIds)) + `) `
  98. err = o.Raw(sql, edbInfoIds).Scan(&items).Error
  99. return
  100. }