main.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "mongodb"
  6. "qfw/util"
  7. "strings"
  8. "github.com/shopspring/decimal"
  9. "github.com/tealeg/xlsx"
  10. )
  11. var (
  12. Sysconfig map[string]interface{}
  13. Mgo *mongodb.MongodbSim
  14. Dbname, DbColl string
  15. ExportType, IsMark int
  16. Search map[string]interface{}
  17. Fields map[string]interface{}
  18. FieldsArr []string
  19. FiedlsPurchase []string
  20. SE = util.SimpleEncrypt{Key: "topJYBX2019"}
  21. )
  22. func init() {
  23. util.ReadConfig(&Sysconfig)
  24. // Mgo = &mongodb.MongodbSim{
  25. // MongodbAddr: Sysconfig["mgoAddr"].(string),
  26. // Size: util.IntAllDef(Sysconfig["mgoSize"], 5),
  27. // DbName: Sysconfig["mgoDbName"].(string),
  28. // }
  29. // Mgo.InitPool()
  30. log.Println(Sysconfig)
  31. Mgo = mongodb.NewMgo(Sysconfig["mgoAddr"].(string), Sysconfig["mgoDbName"].(string), 15)
  32. Dbname = Sysconfig["mgoDbName"].(string)
  33. DbColl = Sysconfig["mgoColl"].(string)
  34. ExportType = util.IntAll(Sysconfig["exportType"])
  35. IsMark = util.IntAll(Sysconfig["isMark"])
  36. Search = Sysconfig["search"].(map[string]interface{})
  37. FieldsArr = util.ObjArrToStringArr(Sysconfig["fieldsSort"].([]interface{}))
  38. Fields = Sysconfig["fields"].(map[string]interface{})
  39. FiedlsPurchase = util.ObjArrToStringArr(Sysconfig["fields_purchase"].([]interface{}))
  40. if ExportType == 1 {
  41. FieldsArr[len(FieldsArr)-1] = "itemname"
  42. FieldsArr = append(FieldsArr, "brandname", "model", "unitname", "unitprice", "number", "totalprice", "id")
  43. Fields["itemname"] = "产品名称"
  44. Fields["brandname"] = "品牌"
  45. Fields["model"] = "规格型号"
  46. Fields["unitname"] = "单位"
  47. Fields["unitprice"] = "单价"
  48. Fields["number"] = "数量"
  49. Fields["totalprice"] = "小计"
  50. } else if ExportType == 3 {
  51. FiedlsPurchase[len(FiedlsPurchase)-1] = "projectname_purchase"
  52. FiedlsPurchase = append(FiedlsPurchase, "projectscope_purchase", "item", "buyer_purchase", "remark", "totalprice", "expurasingtime", "cgyxxqhref", "id")
  53. Fields["projectname_purchase"] = "采购意向名称"
  54. Fields["projectscope_purchase"] = "采购内容"
  55. Fields["item"] = "采购品目"
  56. Fields["remark"] = "备注"
  57. Fields["buyer_purchase"] = "采购单位"
  58. Fields["totalprice"] = "预计采购金额(元)"
  59. Fields["expurasingtime"] = "预计采购时间"
  60. Fields["cgyxxqhref"] = "采购意向详情链接"
  61. } else if ExportType == 4 {
  62. FieldsArr[len(FieldsArr)-1] = "itemname"
  63. FieldsArr = append(FieldsArr, "brandname", "madel", "unitname", "unitprice", "number", "totalprice", "id", "departroom")
  64. Fields["itemname"] = "产品名称"
  65. Fields["brandname"] = "品牌"
  66. Fields["madel"] = "规格型号"
  67. Fields["unitname"] = "单位"
  68. Fields["unitprice"] = "单价"
  69. Fields["number"] = "数量"
  70. Fields["totalprice"] = "小计"
  71. Fields["departroom"] = "科室"
  72. }
  73. util.Debug(FieldsArr)
  74. }
  75. func main() {
  76. sess := Mgo.GetMgoConn()
  77. defer Mgo.DestoryMongoConn(sess)
  78. file := xlsx.NewFile()
  79. sheet, err := file.AddSheet("sheet1")
  80. if err != nil {
  81. panic(err)
  82. }
  83. row := sheet.AddRow()
  84. if ExportType == 3 {
  85. // 标的物 采购意向
  86. for _, v := range FiedlsPurchase {
  87. row.AddCell().SetValue(Fields[v])
  88. }
  89. } else {
  90. for _, v := range FieldsArr {
  91. row.AddCell().SetValue(Fields[v])
  92. }
  93. }
  94. q := map[string]interface{}{}
  95. if len(Search) > 0 {
  96. q = Search
  97. }
  98. c := Mgo.Count(DbColl, q)
  99. util.Debug("search size result ---", DbColl, q, c)
  100. if c == 0 {
  101. return
  102. }
  103. query := sess.DB(Dbname).C(DbColl).Find(&q).Iter()
  104. count := 0
  105. for tmp := make(map[string]interface{}); query.Next(&tmp); count++ {
  106. if count%500 == 0 {
  107. util.Debug("current ---", count)
  108. }
  109. var baseInfo map[string]interface{}
  110. if tmp["v_baseinfo"] != nil {
  111. baseInfo = tmp["v_baseinfo"].(map[string]interface{})
  112. } else {
  113. baseInfo = tmp
  114. }
  115. tagInfo, _ := tmp["v_taginfo"].(map[string]interface{})
  116. switch ExportType {
  117. case 0:
  118. // 不拆分
  119. row := sheet.AddRow()
  120. for _, v := range FieldsArr {
  121. if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
  122. v == "signaturedate" || v == "comeintime" || v == "createtime" {
  123. str := ""
  124. if baseInfo[v] != nil {
  125. date := util.Int64All(baseInfo[v])
  126. str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
  127. }
  128. row.AddCell().SetValue(str)
  129. } else if v == "id" {
  130. if tmp["id"] != nil {
  131. id := SE.EncodeString(util.ObjToString(tmp["id"]))
  132. row.AddCell().SetValue(id)
  133. } else {
  134. id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
  135. row.AddCell().SetValue(id)
  136. }
  137. } else {
  138. row.AddCell().SetValue(baseInfo[v])
  139. }
  140. }
  141. case 1:
  142. // 拆分标的物
  143. if IsMark == 1 {
  144. if tagInfo["purchasinglist"] != nil {
  145. if baseInfo["purchasinglist"] != nil {
  146. plist := baseInfo["purchasinglist"].([]interface{})
  147. for _, p := range plist {
  148. row := sheet.AddRow()
  149. p1 := p.(map[string]interface{})
  150. for _, v := range FieldsArr {
  151. if v == "itemname" || v == "brandname" || v == "model" || v == "unitname" || v == "unitprice" || v == "number" {
  152. row.AddCell().SetValue(p1[v])
  153. } else if v == "totalprice" {
  154. if p1["totalprice"] != nil {
  155. row.AddCell().SetValue(p1[v])
  156. } else {
  157. if p1["unitprice"] != nil && p1["number"] != nil {
  158. d1 := decimal.NewFromFloat(util.Float64All(p1["unitprice"])).Mul(decimal.NewFromInt(int64(util.IntAll(p1["number"]))))
  159. row.AddCell().SetValue(d1)
  160. } else {
  161. row.AddCell().SetValue("")
  162. }
  163. }
  164. } else if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
  165. v == "signaturedate" || v == "comeintime" || v == "createtime" {
  166. str := ""
  167. if baseInfo[v] != nil {
  168. date := util.Int64All(baseInfo[v])
  169. str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
  170. }
  171. row.AddCell().SetValue(str)
  172. } else if v == "id" {
  173. if tmp["id"] != nil {
  174. id := SE.EncodeString(util.ObjToString(tmp["id"]))
  175. row.AddCell().SetValue(id)
  176. } else {
  177. id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
  178. row.AddCell().SetValue(id)
  179. }
  180. } else {
  181. row.AddCell().SetValue(baseInfo[v])
  182. }
  183. }
  184. }
  185. } else {
  186. row := sheet.AddRow()
  187. for _, v := range FieldsArr {
  188. if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
  189. v == "signaturedate" || v == "comeintime" || v == "createtime" {
  190. str := ""
  191. if baseInfo[v] != nil {
  192. date := util.Int64All(baseInfo[v])
  193. str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
  194. }
  195. row.AddCell().SetValue(str)
  196. } else if v == "id" {
  197. if tmp["id"] != nil {
  198. id := SE.EncodeString(util.ObjToString(tmp["id"]))
  199. row.AddCell().SetValue(id)
  200. } else {
  201. id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
  202. row.AddCell().SetValue(id)
  203. }
  204. } else {
  205. row.AddCell().SetValue(baseInfo[v])
  206. }
  207. }
  208. }
  209. } else {
  210. row := sheet.AddRow()
  211. for _, v := range FieldsArr {
  212. if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
  213. v == "signaturedate" || v == "comeintime" || v == "createtime" {
  214. str := ""
  215. if baseInfo[v] != nil {
  216. date := util.Int64All(baseInfo[v])
  217. str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
  218. }
  219. row.AddCell().SetValue(str)
  220. } else if v == "id" {
  221. if tmp["id"] != nil {
  222. id := SE.EncodeString(util.ObjToString(tmp["id"]))
  223. row.AddCell().SetValue(id)
  224. } else {
  225. id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
  226. row.AddCell().SetValue(id)
  227. }
  228. } else {
  229. row.AddCell().SetValue(baseInfo[v])
  230. }
  231. }
  232. }
  233. } else {
  234. if baseInfo["purchasinglist"] != nil {
  235. plist := baseInfo["purchasinglist"].([]interface{})
  236. for _, p := range plist {
  237. row := sheet.AddRow()
  238. p1 := p.(map[string]interface{})
  239. for _, v := range FieldsArr {
  240. if v == "itemname" || v == "brandname" || v == "model" || v == "unitname" || v == "unitprice" || v == "number" {
  241. row.AddCell().SetValue(p1[v])
  242. } else if v == "totalprice" {
  243. if p1["totalprice"] != nil {
  244. row.AddCell().SetValue(p1[v])
  245. } else {
  246. if p1["unitprice"] != nil && p1["number"] != nil {
  247. d1 := decimal.NewFromFloat(util.Float64All(p1["unitprice"])).Mul(decimal.NewFromInt(int64(util.IntAll(p1["number"]))))
  248. row.AddCell().SetValue(d1)
  249. } else {
  250. row.AddCell().SetValue("")
  251. }
  252. }
  253. } else if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
  254. v == "signaturedate" || v == "comeintime" || v == "createtime" {
  255. str := ""
  256. if baseInfo[v] != nil {
  257. date := util.Int64All(baseInfo[v])
  258. str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
  259. }
  260. row.AddCell().SetValue(str)
  261. } else if v == "id" {
  262. if tmp["id"] != nil {
  263. id := SE.EncodeString(util.ObjToString(tmp["id"]))
  264. row.AddCell().SetValue(id)
  265. } else {
  266. id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
  267. row.AddCell().SetValue(id)
  268. }
  269. } else {
  270. row.AddCell().SetValue(baseInfo[v])
  271. }
  272. }
  273. }
  274. } else {
  275. row := sheet.AddRow()
  276. for _, v := range FieldsArr {
  277. if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
  278. v == "signaturedate" || v == "comeintime" || v == "createtime" {
  279. str := ""
  280. if baseInfo[v] != nil {
  281. date := util.Int64All(baseInfo[v])
  282. str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
  283. }
  284. row.AddCell().SetValue(str)
  285. } else if v == "id" {
  286. if tmp["id"] != nil {
  287. id := SE.EncodeString(util.ObjToString(tmp["id"]))
  288. row.AddCell().SetValue(id)
  289. } else {
  290. id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
  291. row.AddCell().SetValue(id)
  292. }
  293. } else {
  294. row.AddCell().SetValue(baseInfo[v])
  295. }
  296. }
  297. }
  298. break
  299. }
  300. case 2:
  301. // 多包拆分
  302. if baseInfo["package"] != nil {
  303. pkg := baseInfo["package"].(map[string]interface{})
  304. for _, p := range pkg {
  305. row := sheet.AddRow()
  306. p1 := p.(map[string]interface{})
  307. winner := []string{}
  308. bidamount := float64(0)
  309. if p1["winner_all"] != nil {
  310. if all := p1["winner_all"].([]interface{}); all != nil {
  311. if len(all) > 0 {
  312. for _, a := range all {
  313. a1 := a.(map[string]interface{})
  314. if util.ObjToString(a1["winner"]) != "" {
  315. winner = append(winner, util.ObjToString(a1["winner"]))
  316. }
  317. bidamount = util.Float64All(a1["bidamount"])
  318. }
  319. }
  320. }
  321. }
  322. for _, v := range FieldsArr {
  323. if v == "s_winner" && len(winner) > 0 {
  324. row.AddCell().SetValue(strings.Join(winner, ","))
  325. } else if v == "bidamount" {
  326. row.AddCell().SetValue(bidamount)
  327. } else if v == "winnerperson" || v == "winnertel" {
  328. row.AddCell().SetValue("")
  329. } else if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
  330. v == "signaturedate" || v == "comeintime" || v == "createtime" {
  331. str := ""
  332. if baseInfo[v] != nil {
  333. date := util.Int64All(baseInfo[v])
  334. str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
  335. }
  336. row.AddCell().SetValue(str)
  337. } else if v == "id" {
  338. if tmp["id"] != nil {
  339. id := SE.EncodeString(util.ObjToString(tmp["id"]))
  340. row.AddCell().SetValue(id)
  341. } else {
  342. id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
  343. row.AddCell().SetValue(id)
  344. }
  345. } else {
  346. row.AddCell().SetValue(baseInfo[v])
  347. }
  348. }
  349. }
  350. } else {
  351. row := sheet.AddRow()
  352. for _, v := range FieldsArr {
  353. if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
  354. v == "signaturedate" || v == "comeintime" || v == "createtime" {
  355. str := ""
  356. if baseInfo[v] != nil {
  357. date := util.Int64All(baseInfo[v])
  358. str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
  359. }
  360. row.AddCell().SetValue(str)
  361. } else if v == "id" {
  362. if tmp["id"] != nil {
  363. id := SE.EncodeString(util.ObjToString(tmp["id"]))
  364. row.AddCell().SetValue(id)
  365. } else {
  366. id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
  367. row.AddCell().SetValue(id)
  368. }
  369. } else {
  370. row.AddCell().SetValue(baseInfo[v])
  371. }
  372. }
  373. }
  374. case 3:
  375. // 标的物 采购意向数据拆分
  376. if baseInfo["procurementlist"] != nil {
  377. plist := baseInfo["procurementlist"].([]interface{})
  378. for _, p := range plist {
  379. isOk := false
  380. m := make(map[string]interface{})
  381. p1 := p.(map[string]interface{})
  382. matchkey := util.ObjToString(baseInfo["matchkey"])
  383. projectname_purchase := util.ObjToString(p1["projectname"])
  384. projectscope_purchase := util.ObjToString(p1["projectscope"])
  385. remark := util.ObjToString(p1["remark"])
  386. item := util.ObjToString(p1["item"])
  387. for _, m := range strings.Split(matchkey, ",") {
  388. if strings.Contains(projectname_purchase, m) || strings.Contains(projectscope_purchase, m) || strings.Contains(remark, m) || strings.Contains(item, m) {
  389. isOk = true
  390. }
  391. }
  392. log.Println("matchkey ", matchkey)
  393. log.Println("projectname_purchase ", projectname_purchase)
  394. log.Println("projectscope_purchase ", projectscope_purchase)
  395. log.Println("remark ", remark)
  396. if isOk {
  397. row := sheet.AddRow()
  398. for _, v := range FiedlsPurchase {
  399. if v == "projectname_purchase" || v == "projectscope_purchase" || v == "item" || v == "buyer_purchase" ||
  400. v == "totalprice" || v == "expurasingtime" || v == "cgyxxqhref" || v == "remark" {
  401. v1 := strings.ReplaceAll(v, "_purchase", "")
  402. row.AddCell().SetValue(p1[v1])
  403. m[v] = p1[v1]
  404. } else if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
  405. v == "signaturedate" || v == "comeintime" || v == "createtime" {
  406. str := ""
  407. if baseInfo[v] != nil {
  408. date := util.Int64All(baseInfo[v])
  409. str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
  410. }
  411. row.AddCell().SetValue(str)
  412. m[v] = str
  413. } else if v == "id" {
  414. if tmp["id"] != nil {
  415. id := SE.EncodeString(util.ObjToString(tmp["id"]))
  416. row.AddCell().SetValue(id)
  417. m[v] = id
  418. } else {
  419. id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
  420. row.AddCell().SetValue(id)
  421. m[v] = id
  422. }
  423. } else {
  424. row.AddCell().SetValue(baseInfo[v])
  425. m[v] = baseInfo[v]
  426. }
  427. }
  428. Mgo.Save("bidding_v1", m)
  429. }
  430. }
  431. } else {
  432. row := sheet.AddRow()
  433. m := make(map[string]interface{})
  434. for _, v := range FiedlsPurchase {
  435. if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
  436. v == "signaturedate" || v == "comeintime" || v == "createtime" {
  437. str := ""
  438. if baseInfo[v] != nil {
  439. date := util.Int64All(baseInfo[v])
  440. str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
  441. }
  442. row.AddCell().SetValue(str)
  443. m[v] = str
  444. } else if v == "id" {
  445. if tmp["id"] != nil {
  446. id := SE.EncodeString(util.ObjToString(tmp["id"]))
  447. row.AddCell().SetValue(id)
  448. m[v] = id
  449. } else {
  450. id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
  451. row.AddCell().SetValue(id)
  452. m[v] = id
  453. }
  454. } else {
  455. row.AddCell().SetValue(baseInfo[v])
  456. m[v] = baseInfo[v]
  457. }
  458. }
  459. Mgo.Save(DbColl+"_cf", m)
  460. }
  461. case 4:
  462. // 多包 标的物拆分
  463. if baseInfo["package"] != nil {
  464. pkg := baseInfo["package"].(map[string]interface{})
  465. for _, p := range pkg {
  466. p1 := p.(map[string]interface{})
  467. winner := []string{}
  468. bidamount := float64(0)
  469. if p1["winner_all"] != nil {
  470. if all := p1["winner_all"].([]interface{}); all != nil {
  471. if len(all) > 0 {
  472. for _, a := range all {
  473. a1 := a.(map[string]interface{})
  474. if util.ObjToString(a1["winner"]) != "" {
  475. winner = append(winner, util.ObjToString(a1["winner"]))
  476. }
  477. bidamount = util.Float64All(a1["bidamount"])
  478. }
  479. }
  480. }
  481. }
  482. if len(winner) <= 0 {
  483. continue
  484. }
  485. if plist, ok := p1["purchasinglist"].([]interface{}); ok {
  486. for _, p := range plist {
  487. row := sheet.AddRow()
  488. p1 := p.(map[string]interface{})
  489. for _, v := range FieldsArr {
  490. if v == "itemname" || v == "brandname" || v == "madel" || v == "unitname" || v == "unitprice" || v == "number" || v == "departroom" {
  491. row.AddCell().SetValue(p1[v])
  492. } else if v == "totalprice" {
  493. if p1["totalprice"] != nil {
  494. row.AddCell().SetValue(p1[v])
  495. } else {
  496. if p1["unitprice"] != nil && p1["number"] != nil {
  497. d1 := decimal.NewFromFloat(util.Float64All(p1["unitprice"])).Mul(decimal.NewFromInt(int64(util.IntAll(p1["number"]))))
  498. row.AddCell().SetValue(d1)
  499. } else {
  500. row.AddCell().SetValue("")
  501. }
  502. }
  503. } else if v == "bidamount" {
  504. row.AddCell().SetValue(bidamount)
  505. } else if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
  506. v == "signaturedate" || v == "comeintime" || v == "createtime" {
  507. str := ""
  508. if baseInfo[v] != nil {
  509. date := util.Int64All(baseInfo[v])
  510. str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
  511. }
  512. row.AddCell().SetValue(str)
  513. } else if v == "s_winner" {
  514. row.AddCell().SetValue(strings.Join(winner, ","))
  515. } else if v == "id" {
  516. if tmp["id"] != nil {
  517. id := SE.EncodeString(util.ObjToString(tmp["id"]))
  518. row.AddCell().SetValue(id)
  519. } else {
  520. id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
  521. row.AddCell().SetValue(id)
  522. }
  523. } else {
  524. row.AddCell().SetValue(baseInfo[v])
  525. }
  526. }
  527. }
  528. }
  529. }
  530. } else {
  531. row := sheet.AddRow()
  532. for _, v := range FieldsArr {
  533. if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
  534. v == "signaturedate" || v == "comeintime" || v == "createtime" {
  535. str := ""
  536. if baseInfo[v] != nil {
  537. date := util.Int64All(baseInfo[v])
  538. str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
  539. }
  540. row.AddCell().SetValue(str)
  541. } else if v == "id" {
  542. if tmp["id"] != nil {
  543. id := SE.EncodeString(util.ObjToString(tmp["id"]))
  544. row.AddCell().SetValue(id)
  545. } else {
  546. id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
  547. row.AddCell().SetValue(id)
  548. }
  549. } else {
  550. row.AddCell().SetValue(baseInfo[v])
  551. }
  552. }
  553. }
  554. }
  555. }
  556. util.Debug("over ---", count)
  557. fname := fmt.Sprintf("./数据导出%s.xlsx", util.NowFormat(util.DATEFORMAT))
  558. err = file.Save(fname)
  559. if err != nil {
  560. panic(err)
  561. }
  562. }