handle_data.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package eta_bridge
  2. import (
  3. "errors"
  4. "eta/eta_data_init/models"
  5. "eta/eta_data_init/utils"
  6. "fmt"
  7. )
  8. func getPushIndexValueItemReqList(source, subSource, edbInfoId int) (pushIndexValueList []*PushIndexValueItemReq, err error) {
  9. pushIndexValueList = make([]*PushIndexValueItemReq, 0)
  10. tableName := models.GetEdbDataTableName(source, subSource)
  11. if tableName == "" {
  12. err = errors.New("没有找到来源对应的表")
  13. return
  14. }
  15. list, err := models.GetAllEdbDataListByCondition(tableName, edbInfoId)
  16. if err != nil {
  17. return
  18. }
  19. for _, edbData := range list {
  20. // 数据信息
  21. pushIndexValueList = append(pushIndexValueList, &PushIndexValueItemReq{
  22. Id: utils.MD5(fmt.Sprint(source, "_", subSource, "_", edbData.EdbDataId)),
  23. IndexCode: fmt.Sprint(source, "_", edbData.EdbCode),
  24. Value: fmt.Sprint(edbData.Value),
  25. BusinessDate: edbData.DataTime,
  26. CreateTime: edbData.CreateTime,
  27. UpdateTime: edbData.ModifyTime,
  28. Status: "1",
  29. })
  30. }
  31. return
  32. }
  33. // getSourceType
  34. // @Description: 获取指标来源类型
  35. // @author: Roc
  36. // @datetime 2024-03-01 13:40:03
  37. // @param source int
  38. // @return string
  39. func getSourceType(source int) string {
  40. switch source {
  41. case utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_YS, utils.DATA_SOURCE_BAIINFO, utils.DATA_SOURCE_SCI: //钢联,有色,百川盈孚,红桃3
  42. return "RPA"
  43. case utils.DATA_SOURCE_MANUAL:
  44. return "手工"
  45. default:
  46. return "接口"
  47. }
  48. }
  49. // OrigInfo
  50. // @Description: 数据源中的指标基础信息
  51. type OrigInfo struct {
  52. EdbName string
  53. SourceName string
  54. }
  55. // getOrigInfo
  56. // @Description: 获取数据源中的指标基础信息
  57. // @author: Roc
  58. // @datetime 2024-03-11 16:45:34
  59. // @param source int
  60. // @param subSource int
  61. // @param edbCode string
  62. // @param edbName string
  63. // @return origInfo OrigInfo
  64. func getOrigInfo(source, subSource int, edbCode, edbName string) (origInfo OrigInfo) {
  65. switch source {
  66. case utils.DATA_SOURCE_THS, utils.DATA_SOURCE_WIND: // 同花顺、wind
  67. origInfo.SourceName = "经济数据库"
  68. if subSource == utils.DATA_SUB_SOURCE_DATE {
  69. origInfo.SourceName = "日期序列"
  70. }
  71. case utils.DATA_SOURCE_MYSTEEL_CHEMICAL:
  72. edbInfo, err := models.GetBaseFromMysteelChemicalIndexItemByCode(edbCode)
  73. if err != nil {
  74. return
  75. }
  76. origInfo.EdbName = edbInfo.IndexName
  77. origInfo.SourceName = edbInfo.Source
  78. // 钢联化工
  79. case utils.DATA_SOURCE_YS: // 有色
  80. edbInfo, err := models.GetBaseFromSmmIndexItemItemByCode(edbCode)
  81. if err != nil {
  82. return
  83. }
  84. origInfo.EdbName = edbInfo.IndexName
  85. origInfo.SourceName = edbInfo.Interface
  86. }
  87. // 如果原始名称为空,则使用ETA指标库的名称作为原始名称
  88. if origInfo.EdbName == `` {
  89. origInfo.EdbName = edbName
  90. }
  91. return
  92. }
  93. // getMaxModifyTime
  94. // @Description: 获取eta指标明细中的指标最大修改时间
  95. // @author: Roc
  96. // @datetime 2024-03-11 17:10:28
  97. // @param source int
  98. // @param edbCode string
  99. // @param addUpdateTime string
  100. // @return modifyTime string
  101. //func getMaxModifyTime(source, subSource int, edbCode, addUpdateTime string) (modifyTime string) {
  102. // modifyTime, err := data_manage.GetEdbInfoMaxModifyTime(source, subSource, edbCode)
  103. // if err != nil {
  104. // modifyTime = addUpdateTime
  105. // return
  106. // }
  107. //
  108. // return
  109. //}