data_ini.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package controllers
  2. import (
  3. "eta_gn/eta_task/models"
  4. "eta_gn/eta_task/services"
  5. "eta_gn/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. br.Ret = 200
  42. br.Success = true
  43. br.Msg = "处理成功"
  44. }
  45. func (c *DataInitController) DisableEdbRefresh() {
  46. br := new(models.BaseResponse).Init()
  47. defer func() {
  48. c.Data["json"] = br
  49. c.ServeJSON()
  50. }()
  51. br.Ret = 200
  52. br.Success = true
  53. br.Msg = "处理成功"
  54. }