xlsx.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/xuri/excelize/v2"
  5. util "jygit.jydev.jianyu360.cn/data_processing/common_utils"
  6. "jygit.jydev.jianyu360.cn/data_processing/common_utils/mongodb"
  7. "log"
  8. "time"
  9. )
  10. // dealXlsxData 处理xlsx 给的样例数据,匹配在建项目数据,然后存储MongoDB
  11. func dealXlsxData() {
  12. //url := "http://172.17.4.184:19908"
  13. ////url := "http://127.0.0.1:19908"
  14. //username := "jybid"
  15. //password := "Top2023_JEB01i@31"
  16. ////index := "bidding" //索引名称
  17. //// 创建 Elasticsearch 客户端
  18. //client, err := elastic.NewClient(
  19. // elastic.SetURL(url),
  20. // elastic.SetBasicAuth(username, password),
  21. // elastic.SetSniff(false),
  22. //)
  23. //if err != nil {
  24. // log.Fatalf("创建 Elasticsearch 客户端失败:%s", err)
  25. //}
  26. // 2. 读取 Excel
  27. f, err := excelize.OpenFile("投资入库项目_202504.xlsx")
  28. if err != nil {
  29. log.Fatal("❌ 无法打开 Excel 文件:", err)
  30. }
  31. defer func() {
  32. f.Save()
  33. if err := f.Close(); err != nil {
  34. fmt.Println(err)
  35. }
  36. }()
  37. // 3. 读取 B 列(项目名称)
  38. rows, err := f.GetRows("Sheet1") // 替换为正确的 Sheet 名称
  39. if err != nil {
  40. log.Fatal("❌ 无法读取 Excel:", err)
  41. }
  42. log.Println("开始处理数据--------")
  43. for i := 1; i < len(rows); i++ {
  44. p1_project_code := rows[i][0]
  45. p1_project_name := rows[i][1]
  46. p1_project_owner := rows[i][2]
  47. p1_project_owner_code := rows[i][3]
  48. p1_project_owner_area := rows[i][4]
  49. p1_project_total := rows[i][5]
  50. //
  51. log.Println("项目名称--------", p1_project_name)
  52. insert := map[string]interface{}{
  53. "p1_project_code": p1_project_code,
  54. "p1_project_name": p1_project_name,
  55. "p1_project_owner": p1_project_owner,
  56. "p1_project_owner_code": p1_project_owner_code,
  57. "p1_project_owner_area": p1_project_owner_area,
  58. "p1_project_total": p1_project_total,
  59. }
  60. start := 8
  61. row := rows[i]
  62. p1_biddings := make([]map[string]interface{}, 0)
  63. p1_bidding_ids := make([]string, 0)
  64. biddingIdMap := make(map[string]map[string]interface{}, 0)
  65. //projectIdMap := make(map[string]map[string]interface{}, 0) //project_id -> project map
  66. for i := start; i+3 < len(row); i += 4 {
  67. href := row[i+2]
  68. score := row[i+3]
  69. bid := GetIdByURL(href)
  70. p1_bidding_ids = append(p1_bidding_ids, bid)
  71. bidding, _ := MgoB.FindById("bidding", bid, nil)
  72. da := map[string]interface{}{
  73. "id": bid,
  74. "title": (*bidding)["title"],
  75. "area": (*bidding)["area"],
  76. "city": (*bidding)["city"],
  77. "projectname": (*bidding)["projectname"],
  78. "score": score,
  79. "toptype": (*bidding)["toptype"],
  80. "subtype": (*bidding)["subtype"],
  81. "buyer": (*bidding)["buyer"],
  82. "budget": (*bidding)["budget"],
  83. "buyerperson": (*bidding)["buyerperson"],
  84. "buyertel": (*bidding)["buyertel"],
  85. "s_winner": (*bidding)["s_winner"],
  86. "bidamount": (*bidding)["bidamount"],
  87. "winnertel": (*bidding)["winnertel"],
  88. "agency": (*bidding)["agency"],
  89. "publishtime": (*bidding)["publishtime"],
  90. }
  91. biddingIdMap[bid] = da
  92. //log.Println("aa", insert, amount, title, href, score)
  93. p1_biddings = append(p1_biddings, da)
  94. }
  95. //insert["biddings"] = p1_biddings
  96. p1_bidding_ids = removeDuplicates(p1_bidding_ids)
  97. for _, vv := range p1_bidding_ids {
  98. where2 := map[string]interface{}{
  99. "ids": vv,
  100. }
  101. projectset, _ := MgoP.FindOne("projectset_20230904", where2)
  102. if projectset != nil && len(*projectset) > 0 {
  103. data := map[string]interface{}{
  104. "project_id": mongodb.BsonIdToSId((*projectset)["_id"]),
  105. "projectname": util.ObjToString((*projectset)["projectname"]),
  106. "bidamount": (*projectset)["bidamount"],
  107. "sortprice": (*projectset)["sortprice"],
  108. "area": (*projectset)["area"],
  109. "city": (*projectset)["city"],
  110. "district": (*projectset)["district"],
  111. "bidstatus": (*projectset)["bidstatus"],
  112. "buyer": (*projectset)["buyer"],
  113. "firsttime": (*projectset)["firsttime"],
  114. "bidtype": (*projectset)["bidtype"],
  115. }
  116. biddData := biddingIdMap[vv]
  117. biddData["project"] = data
  118. biddingIdMap[vv] = biddData
  119. }
  120. }
  121. var insertBidding = make([]map[string]interface{}, 0)
  122. for _, v := range biddingIdMap {
  123. insertBidding = append(insertBidding, v)
  124. }
  125. insert["bidding"] = insertBidding
  126. MgoP.InsertOrUpdate("qfw", "wcc_dealXlsxData_0524", insert)
  127. }
  128. log.Println("数据处理完毕--------")
  129. }
  130. // exportTestData 导出拓扑统计局 样例数据
  131. func exportTestData() {
  132. // 打开已有模板
  133. f, err := excelize.OpenFile("统计局入库项目数据目录树.xlsx")
  134. if err != nil {
  135. log.Fatal("打开模板失败:", err)
  136. }
  137. sheet := f.GetSheetName(0) // 使用第一个 Sheet,也可以改成具体 Sheet 名
  138. startRow := 2 // 假设第 1 行是表头,数据从第 2 行开始
  139. rowIndex := startRow
  140. sess := MgoP.GetMgoConn()
  141. defer MgoP.DestoryMongoConn(sess)
  142. queryMgo := sess.DB("qfw").C("wcc_dealXlsxData_0524").Find(nil).Select(nil).Iter()
  143. count := 0
  144. for tmp := make(map[string]interface{}); queryMgo.Next(tmp); count++ {
  145. if count%1000 == 0 {
  146. log.Println("current", count)
  147. }
  148. //
  149. projectname := util.ObjToString(tmp["p1_project_name"])
  150. where := map[string]interface{}{
  151. "projectname": projectname,
  152. }
  153. pro_project, _ := MgoP.FindOne("projectset_proposed", where)
  154. ppid := ""
  155. if pro_project != nil {
  156. ppid = mongodb.BsonIdToSId((*pro_project)["_id"])
  157. }
  158. //1.拟建原始数据
  159. v1 := []interface{}{
  160. ppid,
  161. tmp["p1_project_code"],
  162. tmp["p1_project_name"],
  163. tmp["p1_project_owner"],
  164. tmp["p1_project_owner_code"],
  165. tmp["p1_project_owner_area"],
  166. }
  167. // 遍历招采信息
  168. if biddingList, ok := tmp["bidding"].([]interface{}); ok {
  169. for _, bidItem := range biddingList {
  170. bid := bidItem.(map[string]interface{})
  171. project := bid["project"].(map[string]interface{})
  172. // 在建招采项目信息
  173. v2 := []interface{}{
  174. project["project_id"],
  175. project["projectname"],
  176. project["bidamount"],
  177. project["area"],
  178. project["city"],
  179. project["bidstatus"],
  180. project["buyer"],
  181. time.Unix(util.Int64All(project["firsttime"]), 0).In(time.FixedZone("CST", 8*3600)).Format("2006-01-02 15:04:05"),
  182. bid["score"],
  183. }
  184. // 标讯信息
  185. v3 := []interface{}{
  186. bid["id"],
  187. bid["title"],
  188. bid["subtype"],
  189. bid["area"],
  190. bid["city"],
  191. bid["buyer"],
  192. bid["budget"],
  193. bid["buyerperson"],
  194. bid["buyertel"],
  195. bid["s_winner"],
  196. bid["bidamount"],
  197. bid["winnertel"],
  198. bid["agency"],
  199. time.Unix(util.Int64All(bid["publishtime"]), 0).In(time.FixedZone("CST", 8*3600)).Format("2006-01-02 15:04:05"),
  200. //bid["publishtime"],
  201. bid["score"],
  202. }
  203. // 拼接成一行
  204. fullRow := append(append(v1, v2...), v3...)
  205. cell, _ := excelize.CoordinatesToCellName(1, rowIndex)
  206. f.SetSheetRow(sheet, cell, &fullRow)
  207. rowIndex++
  208. // 写入表格,如写入 Excel
  209. //excelWriter.WriteRow(fullRow) // 你需要实现 WriteRow 方法
  210. }
  211. }
  212. }
  213. // 保存为另一个文件,防止覆盖模板
  214. outputFile := "统计局入库项目数据导出.xlsx"
  215. if err := f.SaveAs(outputFile); err != nil {
  216. log.Fatal("保存 Excel 失败:", err)
  217. }
  218. log.Println("✅ 数据写入完成,共写入行数:", rowIndex-startRow)
  219. }
  220. // exportTestData1 导出统计局 拟建数据
  221. func exportTestData1() {
  222. // 1. 连接 MongoDB
  223. sess := MgoP.GetMgoConn()
  224. defer MgoP.DestoryMongoConn(sess)
  225. // 2. 打开 Excel 模板
  226. f, err := excelize.OpenFile("统计局输出结果.xlsx")
  227. if err != nil {
  228. log.Fatalf("无法打开Excel模板: %v", err)
  229. }
  230. sheet := f.GetSheetName(0)
  231. rowIndex := 3 // 假设第一行是表头
  232. // 3. 查询 Mongo 数据
  233. queryMgo := sess.DB("qfw").C("wcc_dealXlsxData_0524").Find(nil).Iter()
  234. count := 0
  235. for tmp := make(map[string]interface{}); queryMgo.Next(tmp); count++ {
  236. if count%10 == 0 {
  237. log.Println("current", count)
  238. }
  239. v0 := []interface{}{
  240. tmp["p1_project_code"],
  241. tmp["p1_project_name"],
  242. tmp["p1_project_owner"],
  243. tmp["p1_project_owner_area"],
  244. }
  245. //projectIdMap := make(map[string]bool)
  246. // ----------- 核心容错处理逻辑 ------------
  247. if biddingListRaw, ok := tmp["bidding"]; ok {
  248. biddingList, ok := biddingListRaw.([]interface{})
  249. if !ok || len(biddingList) == 0 {
  250. writeEmptyRow1(f, sheet, rowIndex, v0)
  251. rowIndex++
  252. } else {
  253. for _, bidItem := range biddingList {
  254. bidMap, ok := bidItem.(map[string]interface{})
  255. if !ok {
  256. continue
  257. }
  258. v1 := make([]interface{}, 6)
  259. for i := range v1 {
  260. v1[i] = ""
  261. }
  262. if util.ObjToString(bidMap["toptype"]) == "拟建" {
  263. if nj, ok := bidMap["project"].(map[string]interface{}); ok {
  264. v1 = []interface{}{
  265. nj["project_id"],
  266. nj["approvecode"],
  267. nj["projectname"],
  268. nj["owner"],
  269. nj["credit_no"],
  270. }
  271. //if projectIdMap[util.ObjToString(nj["project_id"])] {
  272. // continue
  273. //}
  274. //
  275. //projectIdMap[util.ObjToString(nj["project_id"])] = true
  276. acd := ""
  277. if util.ObjToString(nj["area"]) != "" {
  278. acd = util.ObjToString(nj["area"])
  279. }
  280. if util.ObjToString(nj["city"]) != "" {
  281. acd = acd + "-" + util.ObjToString(nj["city"])
  282. }
  283. if util.ObjToString(nj["district"]) != "" {
  284. acd = acd + "-" + util.ObjToString(nj["district"])
  285. }
  286. v1 = append(v1, acd)
  287. }
  288. v2 := make([]interface{}, 9)
  289. for i := range v2 {
  290. v2[i] = ""
  291. }
  292. v3 := make([]interface{}, 15)
  293. for i := range v3 {
  294. v3[i] = ""
  295. }
  296. fullRow := append(append(append(v0, v1...), v2...), v3...)
  297. cell, _ := excelize.CoordinatesToCellName(1, rowIndex)
  298. f.SetSheetRow(sheet, cell, &fullRow)
  299. rowIndex++
  300. continue
  301. }
  302. // v2
  303. v2 := make([]interface{}, 9)
  304. for i := range v2 {
  305. v2[i] = ""
  306. }
  307. if projRaw, ok := bidMap["project"]; ok {
  308. if project, ok := projRaw.(map[string]interface{}); ok {
  309. firstTimeStr := ""
  310. if val, ok := project["firsttime"]; ok {
  311. if t := util.Int64All(val); t > 0 {
  312. firstTimeStr = time.Unix(t, 0).In(time.FixedZone("CST", 8*3600)).Format("2006-01-02 15:04:05")
  313. }
  314. }
  315. v2 = []interface{}{
  316. project["project_id"],
  317. project["projectname"],
  318. project["bidamount"],
  319. project["area"],
  320. project["city"],
  321. project["bidstatus"],
  322. project["buyer"],
  323. firstTimeStr,
  324. bidMap["score"],
  325. }
  326. }
  327. }
  328. publishTimeStr := ""
  329. if val, ok := bidMap["publishtime"]; ok {
  330. if t := util.Int64All(val); t > 0 {
  331. publishTimeStr = time.Unix(t, 0).In(time.FixedZone("CST", 8*3600)).Format("2006-01-02 15:04:05")
  332. }
  333. }
  334. v3 := []interface{}{
  335. bidMap["id"],
  336. bidMap["title"],
  337. bidMap["subtype"],
  338. bidMap["area"],
  339. bidMap["city"],
  340. bidMap["buyer"],
  341. bidMap["budget"],
  342. bidMap["buyerperson"],
  343. bidMap["buyertel"],
  344. bidMap["s_winner"],
  345. bidMap["bidamount"],
  346. bidMap["winnertel"],
  347. bidMap["agency"],
  348. publishTimeStr,
  349. bidMap["score"],
  350. }
  351. fullRow := append(append(append(v0, v1...), v2...), v3...)
  352. cell, _ := excelize.CoordinatesToCellName(1, rowIndex)
  353. f.SetSheetRow(sheet, cell, &fullRow)
  354. rowIndex++
  355. }
  356. }
  357. } else {
  358. // bidding 字段不存在
  359. writeEmptyRow1(f, sheet, rowIndex, v0)
  360. rowIndex++
  361. }
  362. }
  363. // 4. 保存结果
  364. if err := f.SaveAs("输出结果.xlsx"); err != nil {
  365. log.Fatalf("保存文件失败: %v", err)
  366. }
  367. log.Println("导出完成,保存为 输出结果.xlsx")
  368. }
  369. // exportTestData2 导出 陇南市 拟建数据
  370. func exportTestData2() {
  371. // 1. 连接 MongoDB
  372. sess := MgoP.GetMgoConn()
  373. defer MgoP.DestoryMongoConn(sess)
  374. // 2. 打开 Excel 模板
  375. f, err := excelize.OpenFile("统计局入库项目数据目录树.xlsx")
  376. if err != nil {
  377. log.Fatalf("无法打开Excel模板: %v", err)
  378. }
  379. sheet := f.GetSheetName(0)
  380. rowIndex := 3 // 假设第一行是表头
  381. where := map[string]interface{}{
  382. "city": "陇南市",
  383. }
  384. // 3. 查询 Mongo 数据
  385. queryMgo := sess.DB("qfw").C("wcc_dealProposed22_0524").Find(where).Iter()
  386. count := 0
  387. for tmp := make(map[string]interface{}); queryMgo.Next(tmp); count++ {
  388. if count%1000 == 0 {
  389. log.Println("current", count)
  390. }
  391. //projectname := util.ObjToString(tmp["p1_project_name"])
  392. //where := map[string]interface{}{"projectname": projectname}
  393. //pro_project, _ := MgoP.FindOne("projectset_proposed", where)
  394. //ppid := ""
  395. //if pro_project != nil {
  396. // ppid = mongodb.BsonIdToSId((*pro_project)["_id"])
  397. //}
  398. v1 := []interface{}{
  399. //ppid,
  400. tmp["proposed_id"],
  401. tmp["approvecode"],
  402. tmp["projectname"],
  403. tmp["buyer"],
  404. tmp["credit_no"],
  405. }
  406. //fmt.Sprintf("%s-%s-%s", tmp["area"], tmp["city"], tmp["district"]),
  407. acd := ""
  408. if util.ObjToString(tmp["area"]) != "" {
  409. acd = util.ObjToString(tmp["area"])
  410. }
  411. if util.ObjToString(tmp["city"]) != "" {
  412. acd = acd + "-" + util.ObjToString(tmp["city"])
  413. }
  414. if util.ObjToString(tmp["district"]) != "" {
  415. acd = acd + "-" + util.ObjToString(tmp["district"])
  416. }
  417. v1 = append(v1, acd)
  418. // ----------- 核心容错处理逻辑 ------------
  419. if biddingListRaw, ok := tmp["bidding"]; ok {
  420. biddingList, ok := biddingListRaw.([]interface{})
  421. if !ok || len(biddingList) == 0 {
  422. writeEmptyRow(f, sheet, rowIndex, v1)
  423. rowIndex++
  424. } else {
  425. for _, bidItem := range biddingList {
  426. bidMap, ok := bidItem.(map[string]interface{})
  427. if !ok {
  428. continue
  429. }
  430. if util.ObjToString(bidMap["toptype"]) == "拟建" {
  431. continue
  432. }
  433. // v2
  434. v2 := make([]interface{}, 9)
  435. for i := range v2 {
  436. v2[i] = ""
  437. }
  438. if projRaw, ok := bidMap["project"]; ok {
  439. if project, ok := projRaw.(map[string]interface{}); ok {
  440. firstTimeStr := ""
  441. if val, ok := project["firsttime"]; ok {
  442. if t := util.Int64All(val); t > 0 {
  443. firstTimeStr = time.Unix(t, 0).In(time.FixedZone("CST", 8*3600)).Format("2006-01-02 15:04:05")
  444. }
  445. }
  446. v2 = []interface{}{
  447. project["project_id"],
  448. project["projectname"],
  449. project["bidamount"],
  450. project["area"],
  451. project["city"],
  452. project["bidstatus"],
  453. project["buyer"],
  454. firstTimeStr,
  455. bidMap["score"],
  456. }
  457. }
  458. }
  459. publishTimeStr := ""
  460. if val, ok := bidMap["publishtime"]; ok {
  461. if t := util.Int64All(val); t > 0 {
  462. publishTimeStr = time.Unix(t, 0).In(time.FixedZone("CST", 8*3600)).Format("2006-01-02 15:04:05")
  463. }
  464. }
  465. v3 := []interface{}{
  466. bidMap["id"],
  467. bidMap["title"],
  468. bidMap["subtype"],
  469. bidMap["area"],
  470. bidMap["city"],
  471. bidMap["buyer"],
  472. bidMap["budget"],
  473. bidMap["buyerperson"],
  474. bidMap["buyertel"],
  475. bidMap["s_winner"],
  476. bidMap["bidamount"],
  477. bidMap["winnertel"],
  478. bidMap["agency"],
  479. publishTimeStr,
  480. bidMap["score"],
  481. }
  482. fullRow := append(append(v1, v2...), v3...)
  483. cell, _ := excelize.CoordinatesToCellName(1, rowIndex)
  484. f.SetSheetRow(sheet, cell, &fullRow)
  485. rowIndex++
  486. }
  487. }
  488. } else {
  489. // bidding 字段不存在
  490. writeEmptyRow(f, sheet, rowIndex, v1)
  491. rowIndex++
  492. }
  493. }
  494. // 4. 保存结果
  495. if err := f.SaveAs("输出结果.xlsx"); err != nil {
  496. log.Fatalf("保存文件失败: %v", err)
  497. }
  498. log.Println("导出完成,保存为 输出结果.xlsx")
  499. }
  500. func writeEmptyRow1(f *excelize.File, sheet string, rowIndex int, v1 []interface{}) {
  501. emptyV1 := make([]interface{}, 6)
  502. emptyV2 := make([]interface{}, 9)
  503. emptyV3 := make([]interface{}, 15)
  504. for i := range emptyV2 {
  505. emptyV2[i] = ""
  506. }
  507. for i := range emptyV1 {
  508. emptyV1[i] = ""
  509. }
  510. for i := range emptyV3 {
  511. emptyV3[i] = ""
  512. }
  513. fullRow := append(append(append(v1, emptyV1...), emptyV2...), emptyV3...)
  514. cell, _ := excelize.CoordinatesToCellName(1, rowIndex)
  515. f.SetSheetRow(sheet, cell, &fullRow)
  516. }
  517. func writeEmptyRow(f *excelize.File, sheet string, rowIndex int, v1 []interface{}) {
  518. emptyV2 := make([]interface{}, 9)
  519. emptyV3 := make([]interface{}, 15)
  520. for i := range emptyV2 {
  521. emptyV2[i] = ""
  522. }
  523. for i := range emptyV3 {
  524. emptyV3[i] = ""
  525. }
  526. fullRow := append(append(v1, emptyV2...), emptyV3...)
  527. cell, _ := excelize.CoordinatesToCellName(1, rowIndex)
  528. f.SetSheetRow(sheet, cell, &fullRow)
  529. }
  530. // 测试,更新approvecode 字段
  531. func ddd() {
  532. sess := MgoP.GetMgoConn()
  533. defer MgoP.DestoryMongoConn(sess)
  534. // 3. 查询 Mongo 数据
  535. queryMgo := sess.DB("qfw").C("wcc_dealXlsxData_0524").Find(nil).Iter()
  536. count := 0
  537. for tmp := make(map[string]interface{}); queryMgo.Next(tmp); count++ {
  538. if count%1000 == 0 {
  539. log.Println("current", count)
  540. }
  541. pro_id := util.ObjToString(tmp["proposed_id"])
  542. pro, _ := MgoP.FindById("projectset_proposed", pro_id, nil)
  543. if util.ObjToString((*pro)["approvecode"]) != "" {
  544. update := map[string]interface{}{
  545. "approvecode": (*pro)["approvecode"],
  546. }
  547. id := mongodb.BsonIdToSId(tmp["_id"])
  548. MgoP.UpdateById("wcc_dealProposed22_0524", id, map[string]interface{}{"$set": update})
  549. }
  550. }
  551. }
  552. func dda() {
  553. sess := MgoP.GetMgoConn()
  554. defer MgoP.DestoryMongoConn(sess)
  555. // 3. 查询 Mongo 数据
  556. queryMgo := sess.DB("qfw").C("wcc_dealXlsxData_0524").Find(nil).Iter()
  557. count := 0
  558. for tmp := make(map[string]interface{}); queryMgo.Next(tmp); count++ {
  559. if count%1000 == 0 {
  560. log.Println("current", count)
  561. }
  562. id := mongodb.BsonIdToSId(tmp["_id"])
  563. update := make(map[string]interface{})
  564. if bidding, ok := tmp["bidding"].([]interface{}); ok {
  565. if len(bidding) > 0 {
  566. for _, bd := range bidding {
  567. if bda, ok := bd.(map[string]interface{}); ok {
  568. if util.ObjToString(bda["toptype"]) == "拟建" {
  569. bid := util.ObjToString(bda["id"])
  570. where := map[string]interface{}{
  571. "ids": bid,
  572. }
  573. pp, _ := MgoP.FindOne("projectset_proposed", where)
  574. update["nj"] = (*pp)
  575. MgoP.UpdateById("wcc_dealXlsxData_0524", id, map[string]interface{}{"$set": update})
  576. }
  577. }
  578. }
  579. }
  580. }
  581. }
  582. }