chart_edb_mapping.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. package models
  2. import (
  3. "eta_gn/eta_chart_lib/global"
  4. "eta_gn/eta_chart_lib/utils"
  5. )
  6. // GetEtaEdbChartEdbMapping 商品曲线图查询对应的普通指标
  7. func GetEtaEdbChartEdbMapping(chartInfoId int) (item *ChartEdbInfoMapping, err error) {
  8. o := global.DmSQL["data"]
  9. aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
  10. sql := ` SELECT ` + aField + `,b.source_name,b.source,b.sub_source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type
  11. FROM chart_edb_mapping AS a
  12. INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
  13. WHERE a.chart_info_id=? AND a.source = ?
  14. ORDER BY chart_edb_mapping_id ASC `
  15. err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_DEFAULT).First(&item).Error
  16. return
  17. }
  18. // GetEtaEdbChartEdbMappingList 商品曲线图查询对应的普通指标
  19. func GetEtaEdbChartEdbMappingList(chartInfoId int) (items []*ChartEdbInfoMapping, err error) {
  20. o := global.DmSQL["data"]
  21. aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
  22. sql := ` SELECT ` + aField + `,b.source_name,b.source,b.sub_source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.classify_id,b.is_join_permission
  23. FROM chart_edb_mapping AS a
  24. INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
  25. WHERE a.chart_info_id=? AND a.source = ?
  26. ORDER BY chart_edb_mapping_id ASC `
  27. err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_DEFAULT).Scan(&items).Error
  28. return
  29. }
  30. // GetFutureGoodEdbChartEdbMapping 商品曲线图查询对应的商品指标
  31. func GetFutureGoodEdbChartEdbMapping(chartInfoId int) (item *ChartEdbInfoMapping, err error) {
  32. o := global.DmSQL["data"]
  33. aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
  34. sql := ` SELECT ` + aField + `,b.future_good_edb_info_id,b.future_good_edb_code as edb_code,b.future_good_edb_name as edb_name,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value
  35. FROM chart_edb_mapping AS a
  36. INNER JOIN future_good_edb_info AS b ON a.edb_info_id=b.future_good_edb_info_id
  37. WHERE a.chart_info_id=? AND a.source = ?
  38. ORDER BY chart_edb_mapping_id ASC `
  39. err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_FUTURE_GOOD).First(&item).Error
  40. return
  41. }
  42. // GetFutureGoodEdbChartEdbMappingList 商品曲线图查询对应的商品指标
  43. func GetFutureGoodEdbChartEdbMappingList(chartInfoId int) (items []*ChartEdbInfoMapping, err error) {
  44. o := global.DmSQL["data"]
  45. aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
  46. sql := ` SELECT ` + aField + `,b.future_good_edb_info_id,b.future_good_edb_code as edb_code,b.future_good_edb_name as edb_name,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value
  47. FROM chart_edb_mapping AS a
  48. INNER JOIN future_good_edb_info AS b ON a.edb_info_id=b.future_good_edb_info_id
  49. WHERE a.chart_info_id=? AND a.source = ?
  50. ORDER BY chart_edb_mapping_id ASC `
  51. err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_FUTURE_GOOD).Scan(&items).Error
  52. return
  53. }
  54. // GetChartEdbMappingByEdbInfoId 根据指标id获取edb_mapping
  55. func GetChartEdbMappingByEdbInfoId(edbInfoId int) (item *ChartEdbInfoMapping, err error) {
  56. o := global.DmSQL["data"]
  57. sql := ` SELECT edb_info_id,source_name,source,sub_source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,max_value,min_value
  58. FROM edb_info
  59. WHERE edb_info_id = ? limit 1`
  60. err = o.Raw(sql, edbInfoId).First(&item).Error
  61. return
  62. }
  63. // GetChartEdbMappingListByEdbInfoIdList 根据指标id列表获取关联关系
  64. func GetChartEdbMappingListByEdbInfoIdList(edbIdList []int) (list []*ChartEdbInfoMapping, err error) {
  65. num := len(edbIdList)
  66. if num <= 0 {
  67. return
  68. }
  69. o := global.DmSQL["data"]
  70. sql := ` SELECT edb_info_id,source_name,source,sub_source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,max_value,min_value,edb_type
  71. FROM edb_info
  72. WHERE edb_info_id IN(` + utils.GetGormInReplace(num) + `)
  73. ORDER BY FIELD(edb_info_id,` + utils.GetOrmInReplace(num) + `)
  74. `
  75. var pars []interface{}
  76. pars = append(pars, edbIdList)
  77. for _, v := range edbIdList {
  78. pars = append(pars, v)
  79. }
  80. err = o.Raw(sql, pars...).Scan(&list).Error
  81. return
  82. }
  83. // func GetEtaEdbChartEdbMapping(chartInfoId int) (item *ChartEdbInfoMapping, err error) {
  84. // o := orm.NewOrmUsingDB("data")
  85. // aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
  86. // sql := ` SELECT ` + aField + `,b.source_name,b.source,b.sub_source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type
  87. // FROM chart_edb_mapping AS a
  88. // INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
  89. // WHERE a.chart_info_id=? AND a.source = ?
  90. // ORDER BY chart_edb_mapping_id ASC `
  91. // err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_DEFAULT).QueryRow(&item)
  92. // return
  93. // }
  94. // // GetEtaEdbChartEdbMappingList 商品曲线图查询对应的普通指标
  95. // func GetEtaEdbChartEdbMappingList(chartInfoId int) (items []*ChartEdbInfoMapping, err error) {
  96. // o := orm.NewOrmUsingDB("data")
  97. // aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
  98. // sql := ` SELECT ` + aField + `,b.source_name,b.source,b.sub_source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.classify_id,b.is_join_permission
  99. // FROM chart_edb_mapping AS a
  100. // INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
  101. // WHERE a.chart_info_id=? AND a.source = ?
  102. // ORDER BY chart_edb_mapping_id ASC `
  103. // _, err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_DEFAULT).QueryRows(&items)
  104. // return
  105. // }
  106. // // GetFutureGoodEdbChartEdbMapping 商品曲线图查询对应的商品指标
  107. // func GetFutureGoodEdbChartEdbMapping(chartInfoId int) (item *ChartEdbInfoMapping, err error) {
  108. // o := orm.NewOrmUsingDB("data")
  109. // aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
  110. // sql := ` SELECT ` + aField + `,b.future_good_edb_info_id,b.future_good_edb_code as edb_code,b.future_good_edb_name as edb_name,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value
  111. // FROM chart_edb_mapping AS a
  112. // INNER JOIN future_good_edb_info AS b ON a.edb_info_id=b.future_good_edb_info_id
  113. // WHERE a.chart_info_id=? AND a.source = ?
  114. // ORDER BY chart_edb_mapping_id ASC `
  115. // err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_FUTURE_GOOD).QueryRow(&item)
  116. // return
  117. // }
  118. // // GetFutureGoodEdbChartEdbMappingList 商品曲线图查询对应的商品指标
  119. // func GetFutureGoodEdbChartEdbMappingList(chartInfoId int) (items []*ChartEdbInfoMapping, err error) {
  120. // o := orm.NewOrmUsingDB("data")
  121. // aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source`
  122. // sql := ` SELECT ` + aField + `,b.future_good_edb_info_id,b.future_good_edb_code as edb_code,b.future_good_edb_name as edb_name,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value
  123. // FROM chart_edb_mapping AS a
  124. // INNER JOIN future_good_edb_info AS b ON a.edb_info_id=b.future_good_edb_info_id
  125. // WHERE a.chart_info_id=? AND a.source = ?
  126. // ORDER BY chart_edb_mapping_id ASC `
  127. // _, err = o.Raw(sql, chartInfoId, utils.CHART_SOURCE_FUTURE_GOOD).QueryRows(&items)
  128. // return
  129. // }
  130. // // GetChartEdbMappingByEdbInfoId 根据指标id获取edb_mapping
  131. // func GetChartEdbMappingByEdbInfoId(edbInfoId int) (item *ChartEdbInfoMapping, err error) {
  132. // o := orm.NewOrmUsingDB("data")
  133. // sql := ` SELECT edb_info_id,source_name,source,sub_source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,max_value,min_value
  134. // FROM edb_info
  135. // WHERE edb_info_id = ? limit 1`
  136. // err = o.Raw(sql, edbInfoId).QueryRow(&item)
  137. // return
  138. // }
  139. // // GetChartEdbMappingListByEdbInfoIdList 根据指标id列表获取关联关系
  140. // func GetChartEdbMappingListByEdbInfoIdList(edbIdList []int) (list []*ChartEdbInfoMapping, err error) {
  141. // num := len(edbIdList)
  142. // if num <= 0 {
  143. // return
  144. // }
  145. // o := orm.NewOrmUsingDB("data")
  146. // sql := ` SELECT edb_info_id,source_name,source,sub_source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,max_value,min_value,edb_type
  147. // FROM edb_info
  148. // WHERE edb_info_id IN(` + utils.GetOrmInReplace(num) + `)
  149. // ORDER BY FIELD(edb_info_id,` + utils.GetOrmInReplace(num) + `)
  150. // `
  151. // _, err = o.Raw(sql, edbIdList, edbIdList).QueryRows(&list)
  152. // return
  153. // }