read.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package main
  2. import (
  3. log "github.com/donnie4w/go-logger/logger"
  4. "github.com/tealeg/xlsx"
  5. "strings"
  6. u "ul"
  7. )
  8. var keyBxArr = []string{"infoid", "rulename", "projectId", "sourceinfoid", "isOptimization", "matchkey", "tagname", "bidtype", "bidway", "toptype", "subtype", "title", "area", "city", "district", "publishtime", "projectcode", "projectname", "buyer", "buyerclass", "tagname2", "budget", "buyerperson", "buyertel", "s_winner", "tagname3", "bidamount", "winnerperson", "winnertel", "agency", "agencyperson", "agencytel", "href", "jybxhref", "docstarttime", "docendtime", "bidstarttime", "bidendtime", "bidopentime", "isCompetitors"}
  9. var indexBxArr = []int{0, -1, 1, 2, 4, -1, 3, -1, -1, 6, 7, 5, 13, 14, 15, 16, 17, -1, 8, 9, 10, 18, 20, 21, 11, 12, 19, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1, -1}
  10. var keyNhArr = []string{"projectId", "sourceinfoid", "tagname", "projectname", "buyer", "s_winner", "area", "city", "district", "projectcode", "zb_infoid", "tagname2", "buyerclass", "buyerperson", "buyertel", "zb_updatetime", "zb_type", "budget", "agency", "agencyperson", "agencytel", "zb_href", "infoid", "tagname3", "winnerperson", "winnertel", "updatetime", "jg_type", "bidamount", "href"}
  11. var indexNhArr = []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29}
  12. // 获取铁塔标讯数据
  13. func readTowerBxInfo() {
  14. log.Debug(len(keyBxArr), "~", len(indexBxArr))
  15. ff, _ := xlsx.OpenFile("res/qlm.xlsx")
  16. total := 0
  17. for _, sheet := range ff.Sheets {
  18. for k, row := range sheet.Rows {
  19. if k == 0 {
  20. log.Debug("长度~", len(row.Cells))
  21. continue
  22. }
  23. if total%10000 == 0 {
  24. log.Debug("cur index ", total)
  25. }
  26. var arr []string
  27. for _, cell := range row.Cells {
  28. arr = append(arr, cell.String())
  29. }
  30. splitBxData(arr)
  31. total++
  32. }
  33. log.Debug("is over ...", total)
  34. }
  35. }
  36. func splitBxData(arr []string) {
  37. if arr[0] == "" {
  38. return
  39. }
  40. info := map[string]interface{}{}
  41. for k, v := range indexBxArr {
  42. if v <= -1 {
  43. continue
  44. }
  45. if arr[v] != "" {
  46. key := keyBxArr[k]
  47. if key == "publishtime" {
  48. nv := strings.ReplaceAll(arr[v], ";@", "")
  49. nv = strings.ReplaceAll(nv, "/", "-")
  50. info[key] = nv
  51. } else {
  52. info[key] = arr[v]
  53. }
  54. }
  55. }
  56. u.SaveMgo.Save("zktest_tower_info", info)
  57. }
  58. // 获取铁塔捏合数据
  59. func readTowerNhInfo() {
  60. log.Debug(len(keyNhArr), "~", len(indexNhArr))
  61. ff, _ := xlsx.OpenFile("res/qlm_nh.xlsx")
  62. total := 0
  63. for _, sheet := range ff.Sheets {
  64. for k, row := range sheet.Rows {
  65. total++
  66. if k == 0 {
  67. log.Debug("长度~", len(row.Cells))
  68. continue
  69. }
  70. if total%10000 == 0 {
  71. log.Debug("cur index ", total)
  72. }
  73. var arr []string
  74. for _, cell := range row.Cells {
  75. arr = append(arr, cell.String())
  76. }
  77. splitNhData(arr)
  78. }
  79. log.Debug("is over ...", total)
  80. }
  81. }
  82. func splitNhData(arr []string) {
  83. info := map[string]interface{}{}
  84. for k, v := range indexNhArr {
  85. if v <= -1 {
  86. continue
  87. }
  88. if arr[v] != "" {
  89. key := keyNhArr[k]
  90. if key == "zb_updatetime" || key == "jg_updatetime" {
  91. nv := strings.ReplaceAll(arr[v], ";@", "")
  92. nv = strings.ReplaceAll(nv, "/", "-")
  93. info[key] = nv
  94. } else {
  95. info[key] = arr[v]
  96. }
  97. }
  98. }
  99. u.SaveMgo.Save("zktest_tower_nh_info", info)
  100. }