handle_data.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. // @return origInfo OrigInfo
  63. func getOrigInfo(source, subSource int, edbCode string) (origInfo OrigInfo) {
  64. switch source {
  65. case utils.DATA_SOURCE_THS, utils.DATA_SOURCE_WIND: // 同花顺、wind
  66. origInfo.SourceName = "经济数据库"
  67. if subSource == utils.DATA_SUB_SOURCE_DATE {
  68. origInfo.SourceName = "日期序列"
  69. }
  70. case utils.DATA_SOURCE_MYSTEEL_CHEMICAL:
  71. edbInfo, err := models.GetBaseFromMysteelChemicalIndexItemByCode(edbCode)
  72. if err != nil {
  73. return
  74. }
  75. origInfo.EdbName = edbInfo.IndexName
  76. origInfo.SourceName = edbInfo.Source
  77. // 钢联化工
  78. case utils.DATA_SOURCE_YS: // 有色
  79. edbInfo, err := models.GetBaseFromSmmIndexItemItemByCode(edbCode)
  80. if err != nil {
  81. return
  82. }
  83. origInfo.EdbName = edbInfo.IndexName
  84. origInfo.SourceName = edbInfo.Interface
  85. }
  86. return
  87. }
  88. // getMaxModifyTime
  89. // @Description: 获取eta指标明细中的指标最大修改时间
  90. // @author: Roc
  91. // @datetime 2024-03-11 17:10:28
  92. // @param source int
  93. // @param edbCode string
  94. // @param addUpdateTime string
  95. // @return modifyTime string
  96. //func getMaxModifyTime(source, subSource int, edbCode, addUpdateTime string) (modifyTime string) {
  97. // modifyTime, err := data_manage.GetEdbInfoMaxModifyTime(source, subSource, edbCode)
  98. // if err != nil {
  99. // modifyTime = addUpdateTime
  100. // return
  101. // }
  102. //
  103. // return
  104. //}