Jianghan 2 jaren geleden
bovenliggende
commit
0e451a262d
2 gewijzigde bestanden met toevoegingen van 67 en 4 verwijderingen
  1. 2 2
      exportData/config.json
  2. 65 2
      exportData/main.go

+ 2 - 2
exportData/config.json

@@ -1,9 +1,9 @@
 {
-  "mgoAddr": "192.168.3.207:27092",
+  "mgoAddr": "127.0.0.1:27092",
   "mgoDbName": "wjh",
   "mgoColl": "bidding",
   "mgoSize": 10,
-  "exportType": 3,
+  "exportType": 2,
   "isMark": 1,
   "search": {},
   "fieldsSort": ["matchkey", "area", "city", "title", "subtype", "detail", "publishtime", "href", "jybxhref", "projectname",

+ 65 - 2
exportData/main.go

@@ -226,7 +226,70 @@ func main() {
 					}
 				}
 			} else {
-				util.Debug("是否标注isMark字段值有问题~", IsMark)
+				if baseInfo["purchasinglist"] != nil {
+					plist := baseInfo["purchasinglist"].([]interface{})
+					for _, p := range plist {
+						row := sheet.AddRow()
+						p1 := p.(map[string]interface{})
+						for _, v := range FieldsArr {
+							if v == "itemname" || v == "brandname" || v == "model" || v == "unitname" || v == "unitprice" || v == "number" {
+								row.AddCell().SetValue(p1[v])
+							} else if v == "totalprice" {
+								if p1["totalprice"] != nil {
+									row.AddCell().SetValue(p1[v])
+								} else {
+									if p1["unitprice"] != nil && p1["number"] != nil {
+										d1 := decimal.NewFromFloat(util.Float64All(p1["unitprice"])).Mul(decimal.NewFromInt(int64(util.IntAll(p1["number"]))))
+										row.AddCell().SetValue(d1)
+									} else {
+										row.AddCell().SetValue("")
+									}
+								}
+							} else if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
+								v == "signaturedate" || v == "comeintime" || v == "createtime" {
+								str := ""
+								if baseInfo[v] != nil {
+									date := util.Int64All(baseInfo[v])
+									str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
+								}
+								row.AddCell().SetValue(str)
+							} else if v == "id" {
+								if tmp["id"] != nil {
+									id := SE.EncodeString(util.ObjToString(tmp["id"]))
+									row.AddCell().SetValue(id)
+								} else {
+									id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
+									row.AddCell().SetValue(id)
+								}
+							} else {
+								row.AddCell().SetValue(baseInfo[v])
+							}
+						}
+					}
+				} else {
+					row := sheet.AddRow()
+					for _, v := range FieldsArr {
+						if v == "publishtime" || v == "bidopentime" || v == "project_startdate" || v == "project_completedate" ||
+							v == "signaturedate" || v == "comeintime" || v == "createtime" {
+							str := ""
+							if baseInfo[v] != nil {
+								date := util.Int64All(baseInfo[v])
+								str = util.FormatDateByInt64(&date, util.Date_Short_Layout)
+							}
+							row.AddCell().SetValue(str)
+						} else if v == "id" {
+							if tmp["id"] != nil {
+								id := SE.EncodeString(util.ObjToString(tmp["id"]))
+								row.AddCell().SetValue(id)
+							} else {
+								id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
+								row.AddCell().SetValue(id)
+							}
+						} else {
+							row.AddCell().SetValue(baseInfo[v])
+						}
+					}
+				}
 				break
 			}
 		case 2:
@@ -371,7 +434,7 @@ func main() {
 						m[v] = baseInfo[v]
 					}
 				}
-				Mgo.Save("bidding_v1", m)
+				Mgo.Save(DbColl+"_cf", m)
 			}
 		}
 	}