tapd.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package main
  2. import (
  3. "flag"
  4. "go-common/app/service/ep/footman/conf"
  5. "go-common/app/service/ep/footman/model"
  6. "go-common/app/service/ep/footman/service"
  7. "go-common/library/cache/memcache"
  8. "go-common/library/container/pool"
  9. "go-common/library/log"
  10. xhttp "go-common/library/net/http/blademaster"
  11. "go-common/library/net/netutil/breaker"
  12. "go-common/library/time"
  13. )
  14. func main() {
  15. var (
  16. workspaceType string
  17. reportType string
  18. workspaceID string
  19. iteration string
  20. reportPath string
  21. isTimeStr string
  22. startTime string
  23. endTime string
  24. importPath string
  25. importSheetName string
  26. )
  27. flag.StringVar(&workspaceType, "t", "", "端类型,android或ios")
  28. flag.StringVar(&reportType, "r", "", "报表类型")
  29. flag.StringVar(&workspaceID, "w", "", "项目ID")
  30. flag.StringVar(&iteration, "i", "", "迭代名称")
  31. flag.StringVar(&reportPath, "p", "", "报表文件路径")
  32. flag.StringVar(&isTimeStr, "d", "n", "是否详细时间")
  33. flag.StringVar(&startTime, "s", "", "开始时间 2018-01-01")
  34. flag.StringVar(&endTime, "e", "", "结束时间 2019-01-01")
  35. flag.StringVar(&importPath, "f", "", "导入文件")
  36. flag.StringVar(&importSheetName, "sn", "", "导入文件sheet name")
  37. flag.Parse()
  38. c := &conf.Config{
  39. Tapd: &conf.Tapd{
  40. RetryTime: 5,
  41. WaitTime: time.Duration(100000),
  42. },
  43. HTTPClient: &xhttp.ClientConfig{
  44. App: &xhttp.App{
  45. Key: "c05dd4e1638a8af0",
  46. Secret: "7daa7f8c06cd33c5c3067063c746fdcb",
  47. },
  48. Dial: time.Duration(2000000000),
  49. Timeout: time.Duration(10000000000),
  50. KeepAlive: time.Duration(60000000000),
  51. Breaker: &breaker.Config{
  52. Window: time.Duration(10000000000),
  53. Sleep: time.Duration(2000000000),
  54. Bucket: 10,
  55. Ratio: 0.5,
  56. Request: 100,
  57. },
  58. },
  59. Mail: &conf.Mail{
  60. Host: "smtp.exmail.qq.com",
  61. Port: 465,
  62. Username: "merlin@bilibili.com",
  63. Password: "",
  64. NoticeOwner: []string{"fengyifeng@bilibili.com"},
  65. },
  66. Memcache: &conf.Memcache{
  67. Expire: time.Duration(10000000),
  68. Config: &memcache.Config{
  69. Name: "merlin",
  70. Proto: "tcp",
  71. Addr: "172.22.33.137:11216",
  72. DialTimeout: time.Duration(1000),
  73. ReadTimeout: time.Duration(1000),
  74. WriteTimeout: time.Duration(1000),
  75. Config: &pool.Config{
  76. Active: 10,
  77. IdleTimeout: time.Duration(1000),
  78. },
  79. },
  80. },
  81. }
  82. s := service.New(c)
  83. switch reportType {
  84. //纯测试时长统计列表区分_ios_android
  85. case "testtime":
  86. if err := s.TestTimeReport(workspaceID, workspaceType, iteration, reportPath, model.Test, model.IPS, model.SPS, model.SCPS); err != nil {
  87. log.Error("Error happened when generating test time reprot:error(%v)", err)
  88. }
  89. //待测试时长统计 不区分ios android
  90. case "waittest":
  91. if err := s.WaitTimeReport(workspaceID, iteration, reportPath, model.Test, model.IPS, model.SPS, model.SCPS); err != nil {
  92. log.Error("Error happened when generating wait for test time reprot:error(%v)", err)
  93. }
  94. //产品验收时长统计 不区分ios android
  95. case "experiencetime":
  96. if err := s.TestTimeReport(workspaceID, workspaceType, iteration, reportPath, model.Experience, model.IPS, model.SPS, model.SCPS); err != nil {
  97. log.Error("Error happened when generating experience time reprot:error(%v)", err)
  98. }
  99. case "delayedstory":
  100. if err := s.DelayedStoryReport(workspaceID, workspaceType, iteration, reportPath, model.IPS, model.SPS, model.SCPS); err != nil {
  101. log.Error("Error happened when generating delayed story reprot:error(%v)", err)
  102. }
  103. //测试中打回需求统计
  104. case "testrejected":
  105. if err := s.RejectedStoryReport(workspaceID, workspaceType, iteration, reportPath, model.Test, model.IPS, model.SPS, model.SCPS); err != nil {
  106. log.Error("Error happened when generating test rejected story reprot:error(%v)", err)
  107. }
  108. //产品验收打回需求统计
  109. case "experiencerejected":
  110. if err := s.RejectedStoryReport(workspaceID, workspaceType, iteration, reportPath, model.Experience, model.IPS, model.SPS, model.SCPS); err != nil {
  111. log.Error("Error happened when generating experience rejected story reprot:error(%v)", err)
  112. }
  113. //故事墙
  114. case "storywall":
  115. isTime := false
  116. if isTimeStr == "y" {
  117. isTime = true
  118. }
  119. if err := s.StoryWallReport(workspaceID, workspaceType, iteration, reportPath, isTime, model.IPS, model.SPS, model.SCPS, model.CPS); err != nil {
  120. log.Error("Error happened when generating story wall reprot:error(%v)", err)
  121. }
  122. case "storywallreport":
  123. if err := s.GenStoryReport(workspaceType, importPath, importSheetName, reportPath, iteration, startTime, endTime); err != nil {
  124. log.Error("Error happened when generating experience rejected story reprot:error(%v)", err)
  125. }
  126. }
  127. }