index_v2.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package watch
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "eta/mysteel_watch/global"
  6. "eta/mysteel_watch/models/index"
  7. )
  8. // GetNoMergeIndexByFrequencyCount 获取未合并的指标总数量
  9. func GetIndexCountByFrequencyV2(req GetMaxFileIndexReq) (total float64, err error) {
  10. urlStr := "/mysteel_chemical/getIndexCountByFrequency"
  11. if global.CONFIG.Serve.EdbLibUrl == `` {
  12. err = errors.New("刷新未配置")
  13. return
  14. }
  15. postUrl := global.CONFIG.Serve.EdbLibUrl + urlStr
  16. postData, err := json.Marshal(req)
  17. if err != nil {
  18. return
  19. }
  20. result, err := HttpPost(postUrl, string(postData), "application/json")
  21. if err != nil {
  22. return
  23. }
  24. var resp BaseResponse
  25. global.LOG.Info(" GetNoMergeIndexByFrequencyCountV2 Result: " + string(result))
  26. err = json.Unmarshal(result, &resp)
  27. if err != nil {
  28. return
  29. }
  30. t, ok := resp.Data.(float64)
  31. if ok {
  32. total = t
  33. }
  34. return
  35. }
  36. // GetNoMergeIndexByFrequencyPage 当下需要合并到excel的指标
  37. func GetIndexLimitByFrequency(frequency string, limit int) (item []index.BaseFromMysteelChemicalIndex, err error) {
  38. urlStr := "/mysteel_chemical/getIndexLimitByFrequency"
  39. if global.CONFIG.Serve.EdbLibUrl == `` {
  40. err = errors.New("刷新未配置")
  41. return
  42. }
  43. postUrl := global.CONFIG.Serve.EdbLibUrl + urlStr
  44. postData, err := json.Marshal(GetNoMergeIndexByFrequencyPageReq{
  45. Frequency: frequency,
  46. Limit: limit,
  47. })
  48. if err != nil {
  49. return
  50. }
  51. result, err := HttpPost(postUrl, string(postData), "application/json")
  52. if err != nil {
  53. return
  54. }
  55. var resp IndexesResponse
  56. global.LOG.Info(" GetIndexLimitByFrequency Result: " + string(result))
  57. err = json.Unmarshal(result, &resp)
  58. if err != nil {
  59. return
  60. }
  61. item = resp.Data
  62. return
  63. }
  64. // GetIndexPageByFrequency 当下需要合并到excel的指标
  65. func GetIndexPageByFrequency(frequency, endDate string, startSize, pageSize int) (item []index.BaseFromMysteelChemicalIndex, err error) {
  66. urlStr := "/mysteel_chemical/getIndexPageByFrequency"
  67. if global.CONFIG.Serve.EdbLibUrl == `` {
  68. err = errors.New("刷新未配置")
  69. return
  70. }
  71. postUrl := global.CONFIG.Serve.EdbLibUrl + urlStr
  72. postData, err := json.Marshal(GetNoMergeIndexByFrequencyPageReqV2{
  73. Frequency: frequency,
  74. StartSize: startSize,
  75. PageSize: pageSize,
  76. EndDate: endDate,
  77. TerminalCode: global.CONFIG.Serve.TerminalCode,
  78. })
  79. if err != nil {
  80. return
  81. }
  82. result, err := HttpPost(postUrl, string(postData), "application/json")
  83. if err != nil {
  84. return
  85. }
  86. var resp IndexesResponse
  87. //global.LOG.Info(" GetIndexLimitByFrequency Result: " + string(result))
  88. err = json.Unmarshal(result, &resp)
  89. if err != nil {
  90. return
  91. }
  92. item = resp.Data
  93. return
  94. }