xuzhiheng 11 ヶ月 前
コミット
42c515ce03
2 ファイル変更69 行追加45 行削除
  1. 10 8
      exportData/config.json
  2. 59 37
      exportData/main.go

+ 10 - 8
exportData/config.json

@@ -1,19 +1,20 @@
 {
-  "mgoAddr": "192.168.3.71:29099",
-  "mgoDbName": "wjh",
-  "mgoColl": "f_data",
+  "mgoAddr": "192.168.3.167:27080",
+  "mgoDbName": "jyqyfw_historyData2023",
+  "mgoColl": "1-2023Kdxf_jy_cgyx",
   "mgoSize": 10,
-  "exportType": 2,
+  "exportType": 3,
   "isMark": 1,
   "search": {},
-  "fieldsSort": ["matchkey", "area", "city", "title", "subtype", "detail", "publishtime", "href", "jybxhref", "projectname",
-    "projectcode", "projectscope", "budget", "bidamount", "bidopentime", "buyer", "buyerperson", "buyertel", "agency", "s_winner",
+  "fieldsSort": ["matchkey","rulename","tagname","tagname2","tagname3", "area", "city","district", "title", "subtype", "detail", "publishtime", "href", "jybxhref", "projectname",
+    "projectcode", "projectscope", "budget", "bidamount", "bidopentime", "buyer","buyerclass", "buyerperson", "buyertel", "agency", "s_winner",
     "winnerperson", "winnertel", "company_phone", "company_email", "id"],
-  "fields_purchase": ["area", "city", "title", "subtype", "detail", "publishtime", "href", "jybxhref", "projectname",
+  "fields_purchase": ["matchkey","rulename","tagname","tagname2","tagname3", "area", "city","district", "title", "subtype", "detail", "publishtime", "href", "jybxhref", "projectname",
     "projectcode", "projectscope", "id"],
   "fields": {
     "matchkey": "信息匹配词",
-    "area": "省份",
+    "rulename":"规则名称","tagname":"标签","tagname2":"局/校端","tagname3":"学段",
+    "area": "省份","district":"区县",
     "city": "城市",
     "title": "公告标题",
     "subtype": "公告类别",
@@ -28,6 +29,7 @@
     "bidamount": "中标金额(元)",
     "bidopentime": "开标日期",
     "buyer": "采购单位",
+    "buyerclass":"采购单位类型",
     "buyerperson": "采购单位联系人",
     "buyertel": "采购单位联系电话",
     "agency": "招标代理机构",

+ 59 - 37
exportData/main.go

@@ -2,11 +2,13 @@ package main
 
 import (
 	"fmt"
-	"github.com/shopspring/decimal"
-	"github.com/tealeg/xlsx"
+	"log"
 	"mongodb"
 	"qfw/util"
 	"strings"
+
+	"github.com/shopspring/decimal"
+	"github.com/tealeg/xlsx"
 )
 
 var (
@@ -23,12 +25,15 @@ var (
 
 func init() {
 	util.ReadConfig(&Sysconfig)
-	Mgo = &mongodb.MongodbSim{
-		MongodbAddr: Sysconfig["mgoAddr"].(string),
-		Size:        util.IntAllDef(Sysconfig["mgoSize"], 5),
-		DbName:      Sysconfig["mgoDbName"].(string),
-	}
-	Mgo.InitPool()
+	// Mgo = &mongodb.MongodbSim{
+	// 	MongodbAddr: Sysconfig["mgoAddr"].(string),
+	// 	Size:        util.IntAllDef(Sysconfig["mgoSize"], 5),
+	// 	DbName:      Sysconfig["mgoDbName"].(string),
+	// }
+	// Mgo.InitPool()
+	log.Println(Sysconfig)
+	Mgo = mongodb.NewMgo(Sysconfig["mgoAddr"].(string), Sysconfig["mgoDbName"].(string), 15)
+
 	Dbname = Sysconfig["mgoDbName"].(string)
 	DbColl = Sysconfig["mgoColl"].(string)
 
@@ -106,7 +111,7 @@ func main() {
 	if c == 0 {
 		return
 	}
-	query := sess.DB(Dbname).C(DbColl).Find(&q).Select(nil).Iter()
+	query := sess.DB(Dbname).C(DbColl).Find(&q).Iter()
 	count := 0
 	for tmp := make(map[string]interface{}); query.Next(&tmp); count++ {
 		if count%500 == 0 {
@@ -383,40 +388,57 @@ func main() {
 			if baseInfo["procurementlist"] != nil {
 				plist := baseInfo["procurementlist"].([]interface{})
 				for _, p := range plist {
-					row := sheet.AddRow()
+					isOk := false
 					m := make(map[string]interface{})
 					p1 := p.(map[string]interface{})
-					for _, v := range FiedlsPurchase {
-						if v == "projectname_purchase" || v == "projectscope_purchase" || v == "item" || v == "buyer_purchase" ||
-							v == "totalprice" || v == "expurasingtime" || v == "cgyxxqhref" || v == "remark" {
-							v1 := strings.ReplaceAll(v, "_purchase", "")
-							row.AddCell().SetValue(p1[v1])
-							m[v] = p1[v1]
-						} 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)
-							m[v] = str
-						} else if v == "id" {
-							if tmp["id"] != nil {
-								id := SE.EncodeString(util.ObjToString(tmp["id"]))
-								row.AddCell().SetValue(id)
-								m[v] = id
+					matchkey := util.ObjToString(baseInfo["matchkey"])
+					projectname_purchase := util.ObjToString(p1["projectname"])
+					projectscope_purchase := util.ObjToString(p1["projectscope"])
+					remark := util.ObjToString(p1["remark"])
+					item := util.ObjToString(p1["item"])
+					for _, m := range strings.Split(matchkey, ",") {
+						if strings.Contains(projectname_purchase, m) || strings.Contains(projectscope_purchase, m) || strings.Contains(remark, m) || strings.Contains(item, m) {
+							isOk = true
+						}
+					}
+					log.Println("matchkey ", matchkey)
+					log.Println("projectname_purchase ", projectname_purchase)
+					log.Println("projectscope_purchase ", projectscope_purchase)
+					log.Println("remark ", remark)
+					if isOk {
+						row := sheet.AddRow()
+						for _, v := range FiedlsPurchase {
+							if v == "projectname_purchase" || v == "projectscope_purchase" || v == "item" || v == "buyer_purchase" ||
+								v == "totalprice" || v == "expurasingtime" || v == "cgyxxqhref" || v == "remark" {
+								v1 := strings.ReplaceAll(v, "_purchase", "")
+								row.AddCell().SetValue(p1[v1])
+								m[v] = p1[v1]
+							} 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)
+								m[v] = str
+							} else if v == "id" {
+								if tmp["id"] != nil {
+									id := SE.EncodeString(util.ObjToString(tmp["id"]))
+									row.AddCell().SetValue(id)
+									m[v] = id
+								} else {
+									id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
+									row.AddCell().SetValue(id)
+									m[v] = id
+								}
 							} else {
-								id := SE.EncodeString(mongodb.BsonIdToSId(tmp["_id"]))
-								row.AddCell().SetValue(id)
-								m[v] = id
+								row.AddCell().SetValue(baseInfo[v])
+								m[v] = baseInfo[v]
 							}
-						} else {
-							row.AddCell().SetValue(baseInfo[v])
-							m[v] = baseInfo[v]
 						}
+						Mgo.Save("bidding_v1", m)
 					}
-					Mgo.Save("bidding_v1", m)
 				}
 			} else {
 				row := sheet.AddRow()