data_ini.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package controllers
  2. import (
  3. "eta/eta_task/models"
  4. "eta/eta_task/services"
  5. "eta/eta_task/utils"
  6. "github.com/beego/beego/v2/server/web"
  7. "time"
  8. )
  9. type DataInitController struct {
  10. web.Controller
  11. }
  12. // InitEdbRelation
  13. // @Title 初始化历史的图表、表格等引用记录
  14. // @Description 初始化历史的图表、表格等引用记录
  15. // @Param request body fe_calendar.FeCalendarMatterSaveReq true "type json string"
  16. // @Success 200 string "操作成功"
  17. // @router /relation_init [get]
  18. func (c *DataInitController) InitEdbRelation() {
  19. br := new(models.BaseResponse).Init()
  20. defer func() {
  21. c.Data["json"] = br
  22. c.ServeJSON()
  23. }()
  24. cacheKey := "eta_task:InitEdbRelation"
  25. deleteCache := true
  26. defer func() {
  27. if deleteCache {
  28. utils.Rc.Delete(cacheKey)
  29. }
  30. }()
  31. if !utils.Rc.SetNX(cacheKey, 1, 5*time.Minute) {
  32. deleteCache = false
  33. br.Msg = `系统处理中,请稍后重试!`
  34. return
  35. }
  36. /*services.InitChartEdbRelation()
  37. services.InitChartCrossVariety()
  38. services.InitCalendarIndicatorRelation()
  39. services.InitSandBoxEdbRelation()
  40. services.InitExcelEdbRelation()*/
  41. services.InitPredictEdbRelation()
  42. br.Ret = 200
  43. br.Success = true
  44. br.Msg = "处理成功"
  45. }
  46. func (c *DataInitController) DisableEdbRefresh() {
  47. br := new(models.BaseResponse).Init()
  48. defer func() {
  49. c.Data["json"] = br
  50. c.ServeJSON()
  51. }()
  52. br.Ret = 200
  53. br.Success = true
  54. br.Msg = "处理成功"
  55. }