task.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package services
  2. import (
  3. "fmt"
  4. "github.com/astaxie/beego/toolbox"
  5. "hongze/hongze_task/services/data"
  6. "hongze/hongze_task/services/company_contract"
  7. "hongze/hongze_task/utils"
  8. )
  9. func Task() {
  10. fmt.Println("task start")
  11. //如果是生产环境,才需要走这些任务
  12. if utils.RunMode == "release" {
  13. releaseTask()
  14. }
  15. //每日定时合同处理
  16. handleCompanyContract := toolbox.NewTask("handleCompanyContract", "0 1 0 * * *", company_contract.HandleCompanyContract)
  17. toolbox.AddTask("每日定时合同处理", handleCompanyContract)
  18. //正式->试用
  19. companyTryOut := toolbox.NewTask("companyTryOut", "0 5 0 * * *", CompanyTryOut)
  20. toolbox.AddTask("正式->试用", companyTryOut)
  21. //试用->冻结
  22. companyFreeze := toolbox.NewTask("companyFreeze", "0 10 0 * * *", CompanyFreeze)
  23. toolbox.AddTask("试用->冻结", companyFreeze)
  24. //冻结->流失
  25. companyLoss := toolbox.NewTask("companyLoss", "0 20 0 * * *", CompanyLoss)
  26. toolbox.AddTask("冻结->流失", companyLoss)
  27. //用户产品权限试用-->关闭
  28. companyReportPermissionClose := toolbox.NewTask("companyReportPermissionClose", "0 30 0 * * *", CompanyReportPermissionClose)
  29. toolbox.AddTask("用户产品权限试用-->关闭", companyReportPermissionClose)
  30. //删除日志记录
  31. //deleteReportSaveLog := toolbox.NewTask("deleteReportSaveLog", "0 30 08 * * *", DeleteReportSaveLog)
  32. //toolbox.AddTask("deleteReportSaveLog", deleteReportSaveLog)
  33. // 存量客户数据统计
  34. stackCompanyStatistic := toolbox.NewTask("stackCompanyStatistic", "0 35 0 * * *", StackCompanyStatistic)
  35. toolbox.AddTask("存量客户数据统计", stackCompanyStatistic)
  36. toolbox.StartTask()
  37. //GetHistoryLzProductDetail()
  38. //GetLzPrice()
  39. //GetLzProductDetail()
  40. //LzExportExcel()
  41. //GetLzProductList()GetLzProductDetail
  42. fmt.Println("task end")
  43. }
  44. //生产环境需要走的任务
  45. func releaseTask() {
  46. //隆众指标获取
  47. getLzProductList := toolbox.NewTask("getLzProductList", "0 0 11-19/1 * * * ", GetLzProductList)
  48. toolbox.AddTask("getLzProductList", getLzProductList)
  49. //隆众指标数据获取
  50. getLzProductDetail := toolbox.NewTask("getLzProductDetail", "0 5 11-19/1 * * * ", GetLzProductDetail)
  51. toolbox.AddTask("getLzProductDetail", getLzProductDetail)
  52. //隆众价格指标获取
  53. getLzProductPriceProduct := toolbox.NewTask("getLzProductPriceProduct", "0 5 11-19/1 * * * ", GetLzProductPriceProduct)
  54. toolbox.AddTask("getLzProductPriceProduct", getLzProductPriceProduct)
  55. //隆众价格指标数据获取
  56. getLzProductPriceData := toolbox.NewTask("getLzProductPriceData", "0 10 11-19/1 * * * ", GetLzProductPriceData)
  57. toolbox.AddTask("getLzProductPriceData", getLzProductPriceData)
  58. //发送邮件
  59. sendEmail := toolbox.NewTask("sendEmail", "0 0 12 * * 0 ", SendEmail)
  60. toolbox.AddTask("sendEmail", sendEmail)
  61. oneMinute := toolbox.NewTask("oneMinute", "0 */1 7-23 * * * ", OneMinute)
  62. toolbox.AddTask("oneMinute", oneMinute)
  63. // 正式/试用 用户到期提醒
  64. companyRemind := toolbox.NewTask("companyRemind", "0 30 08 * * *", CompanyRemind)
  65. toolbox.AddTask("companyRemind", companyRemind)
  66. //潜在客户
  67. freeViewerDetail := toolbox.NewTask("freeViewerDetail", "0 0 9 * * 1 ", FreeViewerDetail)
  68. toolbox.AddTask("潜在客户", freeViewerDetail)
  69. //刷新指标数据
  70. refreshData := toolbox.NewTask("refreshData", "0 0 18 * * *", RefreshData)
  71. toolbox.AddTask("refreshData", refreshData)
  72. //刷新计算指标数据
  73. refreshCalculateData := toolbox.NewTask("refreshCalculateData", "0 10 18 * * *", RefreshCalculateData)
  74. toolbox.AddTask("refreshCalculateData", refreshCalculateData)
  75. checkPbDataInterface := toolbox.NewTask("checkPbDataInterface", "0 */5 * * * * ", data.CheckPbDataInterface)
  76. toolbox.AddTask("checkPbDataInterface", checkPbDataInterface)
  77. }
  78. func TaskTest() {
  79. fmt.Println("The task is start")
  80. //companyReportPermissionClose := toolbox.NewTask("companyTryOut", "0 5 0 * * *", CompanyReportPermissionClose)
  81. companyReportPermissionClose := toolbox.NewTask("companyReportPermissionClose", "0/30 * * * * *", CompanyReportPermissionClose)
  82. toolbox.AddTask("用户产品权限试用-->关闭", companyReportPermissionClose)
  83. toolbox.StartTask()
  84. fmt.Println("The task is end")
  85. }
  86. func Task123() {
  87. fmt.Println("start")
  88. //FreeViewerDetail()
  89. HongzeUsers()
  90. fmt.Println("end")
  91. return
  92. }
  93. func SendEmail() (err error) {
  94. //报告历史访问次数
  95. go ReportViewTimes()
  96. //报告访问详情
  97. go ReportViewDetail()
  98. //用户权限统计
  99. go HongzeUsers()
  100. return
  101. }
  102. func OneMinute() (err error) {
  103. //日度
  104. //FrequencyByDay()
  105. //周度
  106. FrequencyByWeek()
  107. //月度
  108. FrequencyByMonth()
  109. return
  110. }
  111. func RefreshData() (err error) {
  112. //wind
  113. go data.RefreshDataFromWind()
  114. //同花顺
  115. go data.RefreshDataFromThs()
  116. //彭博
  117. go data.RefreshDataFromPb()
  118. return
  119. }
  120. func RefreshCalculateData() (err error) {
  121. //计算指标
  122. go data.RefreshDataFromCalculateAll()
  123. //刷新公历转农历数据
  124. go data.RefreshDataFromQuarterAll()
  125. return
  126. }