future_good.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package data
  2. import (
  3. "encoding/json"
  4. "eta/eta_task/models/data_manage/future_good"
  5. "eta/eta_task/services/alarm_msg"
  6. "eta/eta_task/utils"
  7. "fmt"
  8. )
  9. // RefreshFutureGoodProfitChart 刷新商品利润曲线图
  10. func RefreshFutureGoodProfitChart() (err error) {
  11. defer func() {
  12. if err != nil {
  13. tips := fmt.Sprintf("RefreshFactorEdbCalculateData ErrMsg: %v", err)
  14. utils.FileLog.Info(tips)
  15. go alarm_msg.SendAlarmMsg(tips, 3)
  16. }
  17. }()
  18. profitOb := new(future_good.ChartInfoFutureGoodProfit)
  19. list, e := profitOb.GetItemsByCondition(``, make([]interface{}, 0), []string{}, "")
  20. if e != nil {
  21. err = fmt.Errorf("获取系列因子指标失败, err: %v", e)
  22. return
  23. }
  24. if len(list) == 0 {
  25. return
  26. }
  27. for _, v := range list {
  28. e = PostRefreshFutureGoodProfitChart(v.ChartInfoId)
  29. if e != nil {
  30. utils.FileLog.Info(fmt.Sprintf("PostRefreshFutureGoodProfitChart err, ChartInfoId: %d, err: %v", v.ChartInfoId, e))
  31. continue
  32. }
  33. }
  34. return
  35. }
  36. // PostRefreshFutureGoodProfitChart 因子指标图表重计算
  37. func PostRefreshFutureGoodProfitChart(chartInfoId int) (err error) {
  38. param := make(map[string]interface{})
  39. param["ChartInfoId"] = chartInfoId
  40. postUrl := fmt.Sprintf("%s%s", utils.EDB_LIB_URL, "future_good/relation/refresh")
  41. postData, e := json.Marshal(param)
  42. if e != nil {
  43. err = fmt.Errorf("param json err: %v", e)
  44. return
  45. }
  46. result, e := HttpPost(postUrl, string(postData), "application/json")
  47. if e != nil {
  48. err = fmt.Errorf("http post err: %v", e)
  49. return
  50. }
  51. utils.FileLog.Info("PostRefreshFutureGoodProfitChart:" + postUrl + ";" + string(postData) + ";result:" + string(result))
  52. return
  53. }