Browse Source

Merge branch 'dev3.4' of http://192.168.3.207:10080/qmx/jy-data-extract into dev3.4

apple 4 years ago
parent
commit
38ade5c7d5

+ 36 - 36
fullproject/src_v1/init.go

@@ -224,28 +224,30 @@ func NewKeyMap() *KeyMap {
 
 //招标信息实体类
 type Info struct {
-	Id            string                 `json:"_id"`
-	Href          string                 `json:"href"` //源地址
-	Publishtime   int64                  `json:"publishtime"`
-	Comeintime    int64                  `json:"comeintime"`
-	Title         string                 `json:"title"`
-	TopType       string                 `json:"toptype"`
-	SubType       string                 `json:"subtype"`
-	ProjectName   string                 `json:"projectname"`
-	ProjectCode   string                 `json:"projectcode"`
-	ProjectScope  string                 `json:"projectscope"`
-	ContractCode  string                 `json:"contractcode"`
-	Buyer         string                 `json:"buyer"`
-	Buyerperson   string                 `json:"buyerperson"`
-	Buyertel      string                 `json:"buyertel"`
-	Agency        string                 `json:"agency"`
-	Area          string                 `json:"area"`
-	City          string                 `json:"city"`
-	District      string                 `json:"district"`
-	Infoformat    int                    `json:"infoformat"`
-	ReviewExperts []string               `json:"review_experts"`
-	HasPackage    bool                   // `json:"haspackage"`
-	Package       map[string]interface{} `json:"package"`
+	Id            string                   `json:"_id"`
+	Href          string                   `json:"href"` //源地址
+	Publishtime   int64                    `json:"publishtime"`
+	Comeintime    int64                    `json:"comeintime"`
+	Title         string                   `json:"title"`
+	TopType       string                   `json:"toptype"`
+	SubType       string                   `json:"subtype"`
+	ProjectName   string                   `json:"projectname"`
+	ProjectCode   string                   `json:"projectcode"`
+	ProjectScope  string                   `json:"projectscope"`
+	ContractCode  string                   `json:"contractcode"`
+	Buyer         string                   `json:"buyer"`
+	Buyerperson   string                   `json:"buyerperson"`
+	Buyertel      string                   `json:"buyertel"`
+	Agency        string                   `json:"agency"`
+	Area          string                   `json:"area"`
+	City          string                   `json:"city"`
+	District      string                   `json:"district"`
+	Infoformat    int                      `json:"infoformat"`
+	ReviewExperts []string                 `json:"review_experts"`
+	Purchasing    string                   `json:"purchasing"`
+	WinnerOrder   []map[string]interface{} `json:"winnerorder"`
+	HasPackage    bool                     // `json:"haspackage"`
+	Package       map[string]interface{}   `json:"package"`
 	//PNum          string                 `json:"pnum"`
 	Topscopeclass []string `json:"topscopeclass"`
 	Subscopeclass []string `json:"subscopeclass"`
@@ -255,14 +257,11 @@ type Info struct {
 	Bidamount     float64  `json:"bidamount"`
 	Winners       []string
 	dealtype      int
-
-	Winnerorder []string
-
-	PTC    string //从标题中抽的项目编号
-	pnbval int    //项目名称、编号、采购单位存在的个数
-	LenPC  int    //项目编号长度
-	LenPN  int    //项目名称长度
-	LenPTC int    //标题抽的项目编号长度
+	PTC           string //从标题中抽的项目编号
+	pnbval        int    //项目名称、编号、采购单位存在的个数
+	LenPC         int    //项目编号长度
+	LenPN         int    //项目名称长度
+	LenPTC        int    //标题抽的项目编号长度
 	//以下三个元素做对比,计算包含时候使用
 	PNBH  int //0初始,+包含,-被包含
 	PCBH  int
@@ -292,17 +291,18 @@ type ProjectInfo struct {
 	District      string             `json:"district"`                //区县
 	Bidstatus     string             `json:"bidstatus"`               //
 	Bidtype       string             `json:"bidtype"`                 //
-	ReviewExperts []string			 `json:"review_experts"`			 // 项目评审专家
+	ReviewExperts []string           `json:"review_experts"`          // 项目评审专家
+	Purchasing    string             `json:"purchasing"`              // 标的物
 	//HasPackage    bool                   `json:"haspackage"`              //是否有分包
 	Package     map[string]interface{} `json:"package,omitempty"`     //分包的对比对象
 	Buyerclass  string                 `json:"buyerclass"`            //采购单位分类
 	Bidopentime int64                  `json:"bidopentime,omitempty"` //开标时间
 	//	Zbtime        int64                  `json:"zbtime"`        //招标时间
-	Jgtime    int64   `json:"jgtime"`              //结果中标时间
-	Zbtime    int64   `json:"zbtime"`              //招标时间
-	Bidamount float64 `json:"bidamount,omitempty"` //中标金额
-	Budget    float64 `json:"budget,omitempty"`    //预算
-	//Winnerorder []string `json:"winnerorder"` //中标候选人
+	Jgtime        int64    `json:"jgtime"`              //结果中标时间
+	Zbtime        int64    `json:"zbtime"`              //招标时间
+	Bidamount     float64  `json:"bidamount,omitempty"` //中标金额
+	Budget        float64  `json:"budget,omitempty"`    //预算
+	Winnerorder   []string `json:"winnerorder"`         //中标候选人
 	score         int
 	comStr        string
 	resVal, pjVal int

+ 60 - 5
fullproject/src_v1/project.go

@@ -420,7 +420,6 @@ var FIELDS = []string{
 	"agency",
 	"topscopeclass",
 	"subscopeclass",
-	"winnerorder",
 	"package",
 }
 
@@ -480,7 +479,11 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 		set["bidstatus"] = "拟建"
 		bt = "拟建"
 	} else {
-		set["bidtype"] = bidtype[bs]
+		if bidtype[bs] != "" {
+			set["bidtype"] = bidtype[bs]
+		}else {
+			set["bidtype"] = "招标"
+		}
 		if bt == "招标" {
 			set["projectscope"] = qu.ObjToString(tmp["projectscope"])
 			set["bidstatus"] = bt
@@ -569,6 +572,21 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 	//项目评审专家
 	if len(thisinfo.ReviewExperts) > 0 {
 		set["review_experts"] = thisinfo.ReviewExperts
+		p1.ReviewExperts = thisinfo.ReviewExperts
+	}
+	//标的物
+	if thisinfo.Purchasing != "" {
+		set["purchasing"] = thisinfo.Purchasing
+		p1.Purchasing = thisinfo.Purchasing
+	}
+	//中标候选人
+	if len(thisinfo.WinnerOrder) > 0 {
+		var list = []string{}
+		for _, v := range thisinfo.WinnerOrder{
+			list = append(list, qu.ObjToString(v["entname"]))
+		}
+		set["winnerorder"] = list
+		p1.Winnerorder = list
 	}
 
 	p1.InfoFiled = make(map[string]InfoField)
@@ -633,6 +651,8 @@ var INFOFIELDS = []string{
 	"district",
 	"spidercode",
 	"site",
+	"review_experts",
+	"purchasing",
 }
 
 //项目中list的信息
@@ -677,6 +697,7 @@ func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info, bidty
 		Bidtype:       bidtype,
 		Winners:       thisinfo.Winners,
 		ReviewExperts: thisinfo.ReviewExperts,
+		Purchasing:	   thisinfo.Purchasing,
 	}
 	if thisinfo.LenPTC > 5 {
 		p1.MPC = append(p1.MPC, thisinfo.PTC)
@@ -748,9 +769,6 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 	bt := qu.ObjToString(tmp["toptype"])
 	bs := qu.ObjToString(tmp["subtype"])
 	p.mapBidLock.Lock()
-	if bidtype[bs] != "" {
-		set["bidtype"] = bidtype[bs]
-	}
 	if bt == "招标" {
 		//招标状态,更新projectscope
 		if tmp["projectscope"] != nil {
@@ -758,6 +776,13 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 		}
 		set["bidstatus"] = bt
 		pInfo.Bidstatus = bt
+		if bidtype[bs] != "" {
+			set["bidtype"] = bidtype[bs]
+			pInfo.Bidtype = bidtype[bs]
+		}else {
+			set["bidtype"] = "招标"
+			pInfo.Bidtype = "招标"
+		}
 	} else {
 		if bidstatus[bs] != "" {
 			set["bidstatus"] = thisinfo.SubType
@@ -862,6 +887,36 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 		}
 		set["review_experts"] = pInfo.ReviewExperts
 	}
+	if thisinfo.Purchasing != "" {
+		if pInfo.Purchasing == "" {
+			pInfo.Purchasing = thisinfo.Purchasing
+			set["purchasing"] = thisinfo.Purchasing
+		}else {
+			list := strings.Split(pInfo.Purchasing, ",")
+			for _, k := range list {
+				if BinarySearch(strings.Split(thisinfo.Purchasing, ","), k) == -1 {
+					list = append(list, k)
+					sort.Strings(list)
+				}
+			}
+			set["purchasing"] = strings.Join(list, ",")
+		}
+	}
+
+	//中标候选人
+	if len(thisinfo.WinnerOrder) > 0 {
+		var list = []string{}
+		for _, v := range thisinfo.WinnerOrder{
+			list = append(list, qu.ObjToString(v["entname"]))
+		}
+		for _, k := range list {
+			if BinarySearch(list, k) == -1 {
+				pInfo.Winnerorder = append(pInfo.Winnerorder, k)
+				sort.Strings(pInfo.Winnerorder)
+			}
+		}
+		set["winnerorder"] = pInfo.Winnerorder
+	}
 
 	if len(thisinfo.Subscopeclass) > 0 {
 		sort.Strings(pInfo.Subscopeclass)

+ 1 - 1
fullproject/src_v1/task.go

@@ -595,7 +595,7 @@ func (p *ProjectTask) enter(db, coll string, q map[string]interface{}) {
 	}()
 	fields := map[string]interface{} {"area": 1, "city": 1, "district": 1, "comeintime": 1, "publishtime": 1, "bidopentime": 1, "title": 1, "projectname": 1, "href": 1,
 		"projectcode": 1, "buyerclass": 1, "winner": 1, "s_winner": 1, "buyer": 1, "buyerperson": 1, "buyertel": 1, "infoformat": 1, "toptype": 1, "subtype": 1, "spidercode": 1,
-		"site": 1, "topscopeclass": 1, "subscopeclass": 1, "bidamount": 1, "budget": 1, "agency": 1, "package": 1, "jsondata": 1, "review_experts": 1}
+		"site": 1, "topscopeclass": 1, "subscopeclass": 1, "bidamount": 1, "budget": 1, "agency": 1, "package": 1, "jsondata": 1, "review_experts": 1, "purchasing": 1}
 	ms := sess.DB(db).C(coll).Find(q).Select(fields).Sort("publishtime")
 	if Sysconfig["hints"] != nil {
 		ms.Hint(Sysconfig["hints"])

+ 28 - 0
projectforecast/config.json

@@ -0,0 +1,28 @@
+{
+  "mongodbServers": "192.168.3.166:27082",
+  "mongodbPoolSize": 10,
+  "mongodbName": "bqData",
+  "mongoColl_pro": "projectinfo_c",
+  "mongoColl_tag": "project_biaoqian",
+  "mongoColl_save": "project_forecast",
+  "udpport": ":1182",
+  "spiderCodes": ["jzgc_nxjzscjgfwxt_gcyj", "jzgc_fjsjshyxxgkpt_gcxmcx", "jzgc_ahszfhcxjshyggxxcxzx_qycx", "jzgc_ahszfhcxjshyggxxcxzx_xmcx", "jzgc_bjsjzscxxgkpt_qyxx", "jzgc_bjsjzscxxgkpt_xmxx_htbaxx", "jzgc_bjsjzscxxgkpt_xmxx_jgbaxx",
+    "jzgc_bjsjzscxxgkpt_xmxx_lwfblyxx", "jzgc_bjsjzscxxgkpt_xmxx_sgxkxx", "jzgc_bjsjzscxxgkpt_xmxx_yjxx", "jzgc_cqszfhcxjswyh_qyxx", "jzgc_cqszfhcxjswyh_xmxx", "jzgc_fjsjshyxxgkpt_qyxxcx", "jzgc_gdsjshysjkfpt_qyxx", "jzgc_gdsjshysjkfpt_xmxx",
+    "jzgc_gssjzscjgggfwpt_sgxkxm", "jzgc_gxjzscjgycxxxythptxxfb_gcxm", "jzgc_gxjzscjgycxxxythptxxfb_qyxx", "jzgc_hbszfhcxjst_gcxx", "jzgc_hbszfhcxjst_qyzz", "jzgc_hnsjzscjgggfwpt_jsgcqy", "jzgc_hnsjzschgczlaqjgythpt_gcxx", "jzgc_hnsjzschgczlaqjgythpt_qyxx",
+    "jzgc_hnsjzscjgggfwpt_jsxm", "jzgc_jlsjzscjgggfwpt_gcxmxx", "jzgc_jlsjzscjgggfwpt_qyxx", "jzgc_jssjzscjgycxxxythpt_qyxx", "jzgc_lnsjzscggfwpt_gcxmxx", "jzgc_lnsjzscggfwpt_qyxx", "jzgc_nmgzzqjzscjgycxxxglpt_gcxmxx", "jzgc_nmgzzqjzscjgycxxxglpt_qyxx",
+    "jzgc_nxjzscjgfwxt_qysj", "jzgc_nxjzscjgfwxt_gcsj", "jzgc_qhsgcjsjghxyglpt_gcxm", "jzgc_qhsgcjsjghxyglpt_qyxx", "jzgc_scszfcxjshysjgxpt_qyxx", "jzgc_sdszfcxjsfwjgyxyxxzhpt_qycx", "jzgc_sdszfcxjsfwjgyxyxxzhpt_xmcx", "jzgc_sxsjzscjgggfwpt_qyxx",
+    "jzgc_sxsjzscjgggfwpt_xmxx", "jzgc_tjszfhcxjswyh_gcxmxx", "jzgc_sxsjzscjgycxxxfbpt_gcxmxxcx", "jzgc_sxsjzscjgycxxxfbpt_qycx", "jzgc_xjgcjsy_gcxm", "jzgc_xjgcjsy_qyxx", "jzgc_xzzzqjzscjgycxxxpt_gcxx", "jzgc_xzzzqjzscjgycxxxpt_qyxx", "jzgc_scszfcxjshysjgxpt_xmxx"
+  ],
+  "forecast": {
+    "规划科研": ["立项环评", "勘察设计", "建设准备", "前期准备"],
+    "立项环评": ["勘察设计", "建设准备", "前期施工"],
+    "勘察设计": ["建设准备", "前期施工"],
+    "建设准备": ["前期施工"],
+    "前期施工": ["后期施工"],
+    "后期施工": ["竣工验收", "运行维护", "物品采购"],
+    "竣工验收": ["运行维护", "物品采购"],
+    "运行维护": ["物品采购"]},
+  "category": ["道路", "学校", "医院"],
+  "nature": ["新建", "扩建", "拆建"],
+  "rate": "60%"
+}

+ 74 - 0
projectforecast/main.go

@@ -0,0 +1,74 @@
+package main
+
+import (
+	"encoding/json"
+	mu "mfw/util"
+	"mongodb"
+	"net"
+	"qfw/util"
+)
+
+var (
+	Sysconfig   map[string]interface{}
+	MongoTool   *mongodb.MongodbSim
+	Dbname      string
+	CollPro     string //项目表
+	CollTag     string //标签表
+	CollSave    string
+	Rate        string
+	Forecast    map[string]interface{}
+	Category    []interface{}
+	Nature      []interface{}
+	SpiderCodes []interface{}
+	udpclient   mu.UdpClient
+)
+
+var MgoSaveCache = make(chan map[string]interface{}, 2000)
+var SP = make(chan bool, 5)
+
+func init() {
+	util.ReadConfig(&Sysconfig)
+
+	Dbname = Sysconfig["mongodbName"].(string)
+	MongoTool = &mongodb.MongodbSim{
+		MongodbAddr: Sysconfig["mongodbServers"].(string),
+		Size:        util.IntAll(Sysconfig["mongodbPoolSize"]),
+		DbName:      Dbname,
+	}
+	MongoTool.InitPool()
+
+	CollPro = Sysconfig["mongoColl_pro"].(string)
+	CollTag = Sysconfig["mongoColl_tag"].(string)
+	CollSave = Sysconfig["mongoColl_save"].(string)
+	Rate = util.ObjToString(Sysconfig["rate"])
+	Forecast = Sysconfig["forecast"].(map[string]interface{})
+	Category = Sysconfig["category"].([]interface{})
+	Nature = Sysconfig["nature"].([]interface{})
+	SpiderCodes = Sysconfig["spiderCodes"].([]interface{})
+
+	udpport, _ := Sysconfig["udpport"].(string)
+	udpclient = mu.UdpClient{Local: udpport, BufSize: 1024}
+	udpclient.Listen(processUdpMsg)
+	util.Debug("Udp服务监听", udpport)
+}
+
+func main() {
+	go SaveMgo()
+	//GetProjectData("1597386920")
+	ch := make(chan bool, 1)
+	<-ch
+}
+
+
+//udp调用信号
+func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
+	util.Debug(act)
+	var mapInfo map[string]interface{}
+	err := json.Unmarshal(data, &mapInfo)
+	util.Debug("err:", err, "mapInfo:", mapInfo)
+	if err != nil {
+		_ = udpclient.WriteUdp([]byte("err:"+err.Error()), mu.OP_NOOP, ra)
+	} else if mapInfo != nil {
+		GetProjectData(util.ObjToString(mapInfo["updatetime"]))
+	}
+}

+ 184 - 0
projectforecast/task.go

@@ -0,0 +1,184 @@
+package main
+
+import (
+	"go.mongodb.org/mongo-driver/bson"
+	"log"
+	"mongodb"
+	qu "qfw/util"
+	"strconv"
+	"time"
+)
+
+var queryClose = make(chan bool)
+var queryCloseOver = make(chan bool)
+
+func SaveMgo() {
+	log.Println("Mgo Save...")
+	arru := make([]map[string]interface{}, 200)
+	indexu := 0
+	for {
+		select {
+		case v := <-MgoSaveCache:
+			arru[indexu] = v
+			indexu++
+			if indexu == 200 {
+				SP <- true
+				go func(arru []map[string]interface{}) {
+					defer func() {
+						<-SP
+					}()
+					MongoTool.SaveBulk(CollSave, arru...)
+				}(arru)
+				arru = make([]map[string]interface{}, 200)
+				indexu = 0
+			}
+		case <-time.After(1000 * time.Millisecond):
+			if indexu > 0 {
+				SP <- true
+				go func(arru []map[string]interface{}) {
+					defer func() {
+						<-SP
+					}()
+					MongoTool.SaveBulk(CollSave, arru...)
+				}(arru[:indexu])
+				arru = make([]map[string]interface{}, 200)
+				indexu = 0
+			}
+		}
+	}
+}
+
+//项目数据
+func GetProjectData(t string) {
+	defer qu.Catch()
+	count, taskcount := 0, 0
+	sess := MongoTool.GetMgoConn()
+	defer MongoTool.DestoryMongoConn(sess)
+	dataPool := make(chan map[string]interface{}, 2000)
+	over := make(chan bool)
+	pool := make(chan bool, 4)
+	go func() {
+	L:
+		for {
+			select {
+			case tmp := <-dataPool:
+				pool <- true
+				taskcount++
+				go func(tmp map[string]interface{}) {
+					defer func() {
+						<-pool
+					}()
+					ForecastMethod(tmp)
+				}(tmp)
+			case <-over:
+				break L
+			}
+		}
+	}()
+	uptime, err := strconv.ParseInt(t, 10, 64)
+	if err == nil {
+		qu.Debug(err)
+	}
+	query := bson.M{
+		"updatetime": bson.M{"$gt": uptime},
+		"o_projectinfo.nature":     bson.M{"$in": Nature},
+		"spidercode": bson.M{"$in": SpiderCodes},
+		"$or": []bson.M{
+			{"category_buyer": bson.M{"$in": Category}},
+			{"category_purpose": bson.M{"$in": Category}},
+		},
+	}
+	qu.Debug("query-----", CollPro, query["updatetime"])
+	filed := map[string]interface{}{"area": 1, "city": 1, "buyer": 1, "projectname": 1, "category": 1, "nature": 1, "category_buyer": 1, "category_purpose": 1, "stage": 1, "o_projectinfo": 1}
+	it := sess.DB(Dbname).C(CollPro).Select(filed).Find(query).Iter()
+	var lastid interface{}
+L:
+	for {
+		select {
+		case <-queryClose:
+			log.Println("receive interrupt sign")
+			log.Println("close iter..", lastid, it.Cursor.Close(nil))
+			queryCloseOver <- true
+			break L
+		default:
+			tmp := make(map[string]interface{})
+			if it.Next(&tmp) {
+				lastid = tmp["_id"]
+				if count%1000 == 0 {
+					log.Println("current", count, lastid)
+				}
+				dataPool <- tmp
+				count++
+			} else {
+				break L
+			}
+		}
+	}
+	time.Sleep(5 * time.Second)
+	over <- true
+	//阻塞
+	for n := 0; n < 4; n++ {
+		pool <- true
+	}
+}
+
+func ForecastMethod(pro map[string]interface{}) {
+	pro["infoid"] = mongodb.BsonIdToSId(pro["_id"])
+	pro["yucetime"] = time.Now().Unix()
+	pro["nature"] = (*qu.ObjToMap(pro["o_projectinfo"]))["nature"]
+	delete(pro, "_id")
+	delete(pro, "o_projectinfo")
+	category := GetCategory(pro)
+	stage := qu.ObjToString(pro["stage"])
+	q := bson.M{
+		"category": category,
+		"stage":    bson.M{"$in": Forecast[stage]},
+	}
+	var maps []map[string]interface{}
+	if pro["results"] != nil {
+		maps = qu.ObjArrToMapArr(pro["results"].([]interface{}))
+	} else {
+		maps = []map[string]interface{}{}
+	}
+	result, _ := MongoTool.Find(CollTag, q, nil, nil, false, -1, -1)
+	for _, t := range *result {
+		if len(t) == 0 {
+			continue
+		}
+		tmp := make(map[string]interface{})
+		tmp["stage"] = t["stage"]
+		tmp["purchase_classify"] = t["purchase_classify"]
+		tmp["purchasing"] = t["purchasing"]
+		tmp["p_rate"] = Rate
+		tmp["time"] = ""
+		//tmp["p_projects"] = ""		暂无该字段
+		maps = append(maps, tmp)
+	}
+	if len(maps) > 0 {
+		pro["results"] = maps
+	}
+	//update := map[string]interface{}{}
+	//update["$set"] = pro
+	MgoSaveCache <- pro
+}
+
+func GetCategory(tmp map[string]interface{}) string {
+	categoryBuyerIndex := -1
+	categoryPurposeIndex := -1
+	for k, v := range Category {
+		if tmp["category_buyer"] != nil {
+			if qu.ObjToString(tmp["category_buyer"]) == qu.ObjToString(v) {
+				categoryBuyerIndex = k
+			}
+		}
+		if tmp["category_purpose"] != nil {
+			categoryPurposeIndex = k
+		}
+	}
+
+	if categoryBuyerIndex >= categoryPurposeIndex {
+		return qu.ObjToString(Category[categoryBuyerIndex])
+	} else {
+		return qu.ObjToString(Category[categoryPurposeIndex])
+	}
+}

+ 8 - 8
standardata/src/config.json

@@ -1,14 +1,14 @@
 {
-  "mgofrom": "172.17.4.187:27083",
+  "mgofrom": "192.168.3.207:27092",
   "mgofromsize":5,
-  "mgofromdb":"qfw",
-  "mgoto": "172.17.145.163:27082",
+  "mgofromdb":"mxs",
+  "mgoto": "192.168.3.207:27092",
   "mgotosize":5,
-  "mgotodb":"extract_v3",
-  "mgoent": "172.17.145.163:27082",
+  "mgotodb":"mxs",
+  "mgoent": "192.168.3.207:27092",
   "mgoentsize":5,
-  "mgoentdb":"enterprise",
-  "extractcoll":"result_20200116",
+  "mgoentdb":"mxs",
+  "extractcoll":"test",
   "standardata":{
 	"winner":{
 		"standarent":"winner_enterprisenew",
@@ -16,7 +16,7 @@
 		"redisdb":1
 	},
     "buyer":{
-      "standarent":"buyer_agency_enterprise",
+      "standarent":"buyer_enterprise",
       "standarerr":"buyer_err",
       "redisdb":2
     },

+ 19 - 1
standardata/src/standarbuyer.go

@@ -49,6 +49,15 @@ func buyerStandarData(db string, query map[string]interface{}) {
 				ps = append(ps, v)
 				data := comHisMegerNewData(buyer, "buyer", ps)
 				if data != nil {
+					//提取固话和手机号
+					contactArr := []interface{}{}
+					contactArr = append(contactArr, v)
+					latestFixedPhone, latestMobilePhone, timesFixedPhone, timesMobilePhone := getPhone(contactArr)
+					data["latestfixedphone"] = latestFixedPhone
+					data["latestmobilephone"] = latestMobilePhone
+					data["fixedphone"] = timesFixedPhone
+					data["mobilephone"] = timesMobilePhone
+					data["institute_type"] = "企业"
 					_id := MongoTo.Save(buyerent, data)
 					redis.PutRedis("buyer", buyerbd, buyer, _id.(primitive.ObjectID).Hex(), -1)
 					savetoerr = false
@@ -215,7 +224,7 @@ func buyerStandarHistory(db string) {
 
 //企业数据整合(已有标注信息)
 func buyerMegerBuyerclass(id string, ps map[string]interface{}) map[string]interface{} {
-	tmp := MongoEnt.FindById(buyerent, id, bson.M{"buyerclass": 1})
+	tmp := MongoEnt.FindById(buyerent, id, bson.M{"buyerclass": 1, "contact": 1})
 	if len(tmp) < 1 {
 		return nil
 	}
@@ -233,5 +242,14 @@ func buyerMegerBuyerclass(id string, ps map[string]interface{}) map[string]inter
 	}
 	data["buyerclass"] = newbuyerclass
 	data["updatetime"] = time.Now().Unix()
+	//contact
+	contact := tmp["contact"].(primitive.A)
+	contact = append(contact, ps)
+	//提取固话和手机号
+	latestFixedPhone, latestMobilePhone, timesFixedPhone, timesMobilePhone := getPhone(contact)
+	data["latestfixedphone"] = latestFixedPhone
+	data["latestmobilephone"] = latestMobilePhone
+	data["fixedphone"] = timesFixedPhone
+	data["mobilephone"] = timesMobilePhone
 	return data
 }

+ 95 - 0
standardata/src/util.go

@@ -2,11 +2,31 @@ package main
 
 import (
 	"fmt"
+	qu "qfw/util"
 	"regexp"
 	"strconv"
 	"strings"
 )
 
+var (
+	//固话
+	FixedPhone1 = regexp.MustCompile(`^\d{2,4}-\d{7,8}([-,,、转]\d{3,5}){0,}$`)                     //0411-83622266;020-87258495-306、301
+	FixedPhone2 = regexp.MustCompile(`^[((\[【]{1}\d{2,4}[))\]】]{1}\d{7,8}([-,,、转×]\d{3,5}){0,}$`) //(0411)83622266;(020)87768198-172
+	FixedPhone3 = regexp.MustCompile(`^\d{6,8}([-,,、转×]\d{3,5}){0,}$`)                            //83622266;87768198-818
+	FixedPhone4 = regexp.MustCompile(`^(0)\d{9,12}([-,,、转]\d{3,5}){0,}$`)                         //051082222549;02037619082-805
+	//手机号
+	MobilePhone1 = regexp.MustCompile(`^(1)\d{10}$`)                                    //15136526299
+	MobilePhone2 = regexp.MustCompile(`^[((\[【]{1}\d{2,4}[))\]】]{1}\d{11}$`)            //(0411)15136526299
+	MobilePhone3 = regexp.MustCompile(`^\d{2,4}-\d{11}$`)                               //0771-13878601988
+	MobilePhone4 = regexp.MustCompile(`^(1)\d{2}([\s\\u3000\\u2003\\u00a0]+\d{4}){2}$`) //138 0565 9091
+	//
+	RegAreaCode = regexp.MustCompile(`^\d{2,4}$`) //区号
+	RegSpace    = regexp.MustCompile("[\\s\u3000\u2003\u00a0]+")
+	RegReplace1 = regexp.MustCompile("(-|—|-|―|×){1,}[\\s\u3000\u2003\u00a0]{0,}") //将一些符号替换为-
+	RegReplace2 = regexp.MustCompile("[((\\[【]+")
+	RegReplace3 = regexp.MustCompile("[))\\]】]+")
+	RegSplit    = regexp.MustCompile("[\\s\u3000\u2003\u00a0,,、;/]") //[\\s\u3000\u2003\u00a0,,、;/]
+)
 var (
 	regOperator, _ = regexp.Compile(`[*|+|)*)]`)
 	regNumFloat, _ = regexp.Compile(`([1-9]\d*|0)(\.\d+)?`)
@@ -30,6 +50,7 @@ var (
 	cutAllSpace, _ = regexp.Compile(`\s*`)
 	spaces         = []string{"\u3000", "\u2003", "\u00a0", "\t", "\r", "\n"}
 )
+
 //大写数子金额转换
 func capitalMoney(data []interface{}) []interface{} {
 	nodes := []float64{}
@@ -245,3 +266,77 @@ func replaceSymbol(con string, rep []string) string {
 	return con
 }
 
+//提取固话和手机号
+func getPhone(contactArr []interface{}) (latestFixedPhone, latestMobilePhone, timesFixedPhone, timesMobilePhone string) {
+	// latestFixedPhone, latestMobilePhone := "", ""                       //记录最新抽取的固话和手机号
+	// timesFixedPhone, timesMobilePhone := "", ""                         //记录出现次数最多的固话和手机号
+	timeNumFp, timesNumMp := 0, 0                                       //记录固话和手机号出现最多的次数
+	fixedPhoneMap, mobilePhoneMap := map[string]int{}, map[string]int{} //记录所有固话和手机号出现的次数
+	for i := len(contactArr) - 1; i >= 0; i-- {
+		conMap := contactArr[i].(map[string]interface{})
+		if phone := qu.ObjToString(conMap["phone"]); phone != "" {
+			fixedPhoneArr, mobilePhoneArr, _ := PhoneStandard(phone) //提取固话、手机号
+			for _, fp := range fixedPhoneArr {
+				fixedPhoneMap[fp]++
+				fpTimes := fixedPhoneMap[fp]
+				if fpTimes > timeNumFp {
+					timeNumFp = fpTimes
+					timesFixedPhone = fp
+				}
+				if latestFixedPhone == "" {
+					latestFixedPhone = fp
+				}
+			}
+			for _, mp := range mobilePhoneArr {
+				mobilePhoneMap[mp]++
+				mpTimes := mobilePhoneMap[mp]
+				if mpTimes > timesNumMp {
+					timesNumMp = mpTimes
+					timesMobilePhone = mp
+				}
+				if latestMobilePhone == "" {
+					latestMobilePhone = mp
+				}
+			}
+		}
+	}
+	return
+}
+
+//提取固话、手机号
+func PhoneStandard(text string) (FixedPhone, MobilePhone, Others []string) {
+	defer qu.Catch()
+	text = RegReplace1.ReplaceAllString(text, "-") //替换
+	//特殊处理手机号
+	if mp := MobilePhone4.FindString(text); mp != "" {
+		mp = RegSpace.ReplaceAllString(mp, "")
+		MobilePhone = append(MobilePhone, mp)
+		return
+	}
+	for _, t := range RegSplit.Split(text, -1) {
+		if t != "" {
+			if mp := MobilePhone1.FindString(t); mp != "" { //手机号
+				MobilePhone = append(MobilePhone, mp)
+			} else if mp := MobilePhone2.FindString(t); mp != "" { //手机号
+				mp = RegReplace2.ReplaceAllString(mp, "")
+				mp = RegReplace3.ReplaceAllString(mp, "-")
+				MobilePhone = append(MobilePhone, mp)
+			} else if mp := MobilePhone3.FindString(t); mp != "" { //手机号
+				MobilePhone = append(MobilePhone, mp)
+			} else if fp := FixedPhone3.FindString(t); fp != "" { //固话
+				FixedPhone = append(FixedPhone, fp)
+			} else if fp := FixedPhone2.FindString(t); fp != "" { //固话
+				fp = RegReplace2.ReplaceAllString(fp, "")
+				fp = RegReplace3.ReplaceAllString(fp, "-")
+				FixedPhone = append(FixedPhone, fp)
+			} else if fp := FixedPhone1.FindString(t); fp != "" { //固话
+				FixedPhone = append(FixedPhone, fp)
+			} else if fp := FixedPhone4.FindString(t); fp != "" { //固话
+				FixedPhone = append(FixedPhone, fp)
+			} else { //其他
+				Others = append(Others, t)
+			}
+		}
+	}
+	return
+}

+ 79 - 19
udpcreateindex/src/biddingall.go

@@ -5,6 +5,8 @@ import (
 	"log"
 	qutil "qfw/util"
 	elastic "qfw/util/elastic"
+
+	//"reflect"
 	"strings"
 	"sync"
 
@@ -270,6 +272,83 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
 			UpdatesLock.Lock()
 			if qutil.IntAll(update["extracttype"]) != -1 {
 				newTmp := map[string]interface{}{}
+				// for field, ftype := range biddingIndexFieldsMap { //
+				// 	if tmp[field] != nil && del[field] == nil { //
+				// 		//qutil.Debug(field, tmp[field], reflect.TypeOf(tmp[field]).String(), ftype)
+				// 		if field == "projectinfo" {
+				// 			mp, _ := tmp[field].(map[string]interface{})
+				// 			if mp != nil {
+				// 				newmap := map[string]interface{}{}
+				// 				for k, ktype := range projectinfoFieldsMap {
+				// 					mpv := mp[k]
+				// 					if mpv != nil && reflect.TypeOf(mpv).String() == ktype {
+				// 						newmap[k] = mp[k]
+				// 					}
+				// 				}
+				// 				if len(newmap) > 0 {
+				// 					newTmp[field] = newmap
+				// 				}
+				// 			}
+				// 		} else if field == "purchasinglist" { //标的物处理
+				// 			purchasinglist_new := []map[string]interface{}{}
+				// 			if pcl, _ := tmp[field].([]interface{}); len(pcl) > 0 {
+				// 				for _, ls := range pcl {
+				// 					lsm_new := make(map[string]interface{})
+				// 					lsm := ls.(map[string]interface{})
+				// 					for pf, pftype := range purchasinglistFieldsMap {
+				// 						lsmv := lsm[pf]
+				// 						if lsmv != nil && reflect.TypeOf(lsmv).String() == pftype {
+				// 							lsm_new[pf] = lsm[pf]
+				// 						}
+				// 					}
+				// 					if lsm_new != nil && len(lsm_new) > 0 {
+				// 						purchasinglist_new = append(purchasinglist_new, lsm_new)
+				// 					}
+				// 				}
+				// 			}
+				// 			if len(purchasinglist_new) > 0 {
+				// 				newTmp[field] = purchasinglist_new
+				// 			}
+				// 		} else if field == "winnerorder" { //中标候选
+				// 			winnerorder_new := []map[string]interface{}{}
+				// 			if winnerorder, _ := tmp[field].([]interface{}); len(winnerorder) > 0 {
+				// 				for _, win := range winnerorder {
+				// 					winMap_new := make(map[string]interface{})
+				// 					winMap := win.(map[string]interface{})
+				// 					for wf, wftype := range winnerorderlistFieldsMap {
+				// 						wfv := winMap[wf]
+				// 						if wfv != nil && reflect.TypeOf(wfv).String() == wftype {
+				// 							if wf == "sort" && qutil.Int64All(wfv) > 100 {
+				// 								continue
+				// 							}
+				// 							winMap_new[wf] = winMap[wf]
+				// 						}
+				// 					}
+				// 					if winMap_new != nil && len(winMap_new) > 0 {
+				// 						winnerorder_new = append(winnerorder_new, winMap_new)
+				// 					}
+				// 				}
+				// 			}
+				// 			if len(winnerorder_new) > 0 {
+				// 				newTmp[field] = winnerorder_new
+				// 			}
+				// 		} else if field == "detail" { //过滤
+				// 			detail, _ := tmp[field].(string)
+				// 			if len([]rune(detail)) > detailLength {
+				// 				detail = detail[:detailLength]
+				// 			}
+				// 			newTmp[field] = FilterDetail(detail)
+				// 		} else if field == "_id" || field == "topscopeclass" { //不做处理
+				// 			newTmp[field] = tmp[field]
+				// 		} else { //其它字段判断数据类型,不正确舍弃
+				// 			if fieldval := tmp[field]; reflect.TypeOf(fieldval).String() != ftype {
+				// 				continue
+				// 			} else {
+				// 				newTmp[field] = fieldval
+				// 			}
+				// 		}
+				// 	}
+				// }
 				for _, v := range biddingIndexFields { //
 					if tmp[v] != nil && del[v] == nil { //
 						if "projectinfo" == v {
@@ -304,25 +383,6 @@ func biddingAllTask(data []byte, mapInfo map[string]interface{}) {
 							if len(purchasinglist_new) > 0 {
 								newTmp[v] = purchasinglist_new
 							}
-							/*} else if v == "winnerorder" { //中标候选
-							winnerorder_new := []map[string]interface{}{}
-							if winnerorder, _ := tmp[v].([]interface{}); len(winnerorder) > 0 {
-								for _, win := range winnerorder {
-									winMap_new := make(map[string]interface{})
-									winMap := win.(map[string]interface{})
-									for _, wf := range winnerorderlistFields {
-										if winMap[wf] != nil {
-											winMap_new[wf] = winMap[wf]
-										}
-									}
-									if winMap_new != nil && len(winMap_new) > 0 {
-										winnerorder_new = append(winnerorder_new, winMap_new)
-									}
-								}
-							}
-							if len(winnerorder_new) > 0 {
-								newTmp[v] = winnerorder_new
-							}*/
 						} else {
 							if v == "detail" {
 								detail, _ := tmp[v].(string)

+ 4 - 1
udpcreateindex/src/biddingindex.go

@@ -360,7 +360,10 @@ func doIndex(infos []map[string]interface{}, eMap map[string]map[string]interfac
 								winMap_new := make(map[string]interface{})
 								winMap := win.(map[string]interface{})
 								for _, wf := range winnerorderlistFields {
-									if winMap[wf] != nil {
+									if wfv := winMap[wf]; wfv != nil {
+										if wf == "sort" && qutil.Int64All(wfv) > 100 {
+											continue
+										}
 										winMap_new[wf] = winMap[wf]
 									}
 								}

+ 10 - 3
udpcreateindex/src/buyerindex.go

@@ -19,7 +19,7 @@ func buyerTask(data []byte, mapInfo map[string]interface{}) {
 			},
 		}
 	}
-	session := extractmgo.GetMgoConn(1800)
+	session := extractmgo.GetMgoConn()
 	defer extractmgo.DestoryMongoConn(session)
 	c, _ := buyer["collect"].(string)
 	db, _ := buyer["db"].(string)
@@ -29,13 +29,20 @@ func buyerTask(data []byte, mapInfo map[string]interface{}) {
 	savepool := make(chan bool, 10)
 
 	log.Println("查询语句:", q, "同步总数:", count, "elastic库:", index)
-	query := session.DB(db).C(c).Find(q).Select(bson.M{"pici": 0}).Iter()
+	query := session.DB(db).C(c).Find(q).Select(map[string]interface{}{
+		"buyer_name": 1,
+		"province":   1,
+		"city":       1,
+		"district":   1,
+	}).Iter()
 
 	arr := make([]map[string]interface{}, savesizei)
 	var n int
 	i := 0
 	for tmp := make(map[string]interface{}); query.Next(tmp); i = i + 1 {
-		go IS.Add("buyer")
+		//go IS.Add("buyer")
+		tmp["name"] = tmp["buyer_name"]
+		delete(tmp, "buyer_name")
 		arr[i] = tmp
 		n++
 		if i == savesizei-1 {

+ 15 - 11
udpcreateindex/src/config.json

@@ -1,7 +1,7 @@
 {
     "udpport": ":1483",
     "msg_server": "10.171.112.160:7070",
-     "mongodb": {
+    "mongodb": {
         "addr": "192.168.3.207:27092",
         "pool": 10,
         "db": "mxs"
@@ -9,7 +9,7 @@
 	"savedb": {
         "addr": "192.168.3.207:27092",
         "size": 10,
-        "db": "mxs"
+        "db": "qfw_data"
     },
     "jkmail": {
         "to":"zhangjinkun@topnet.net.cn",
@@ -22,9 +22,9 @@
         "type": "winner"
     },
     "buyer": {
-        "db": "qfw",
-        "collect": "buyer",
-        "index": "buyer",
+        "db": "mxs",
+        "collect": "buyer_enterprise",
+        "index": "buyer_v5",
         "type": "buyer"
     },
     "biddingback": {
@@ -35,26 +35,30 @@
     },
     "bidding": {
         "db": "mxs",
-        "collect": "bidding",
-        "index": "bidding_v1",
+        "collect": "test",
+        "index": "bidding_v5",
         "type": "bidding",
         "extractdb": "mxs",
         "extractcollect": "extract",
         "indexfields":[ 
         "buyerzipcode","winnertel","winnerperson","contractcode","winneraddr","agencyaddr","buyeraddr","signaturedate","projectperiod","projectaddr","agencytel","agencyperson","buyerperson","agency","projectscope","projectcode","bidopentime","supervisorrate","buyertel","bidamount","winner","buyer","budget","projectname","bidstatus","buyerclass","topscopeclass","s_topscopeclass","s_subscopeclass","area","city","district","s_winner","_id","title","detail","site","comeintime","href","infoformat","publishtime","s_sha","spidercode","subtype","toptype","projectinfo","purchasing","purchasinglist","filetext","channel","winnerorder"
         ],
+        "indexfieldsmap":{"buyerzipcode":"string","winnertel":"string","winnerperson":"string","contractcode":"string","winneraddr":"string","agencyaddr":"string","buyeraddr":"string","signaturedate":"int64","projectperiod":"string","projectaddr":"string","agencytel":"string","agencyperson":"string","buyerperson":"string","agency":"string","projectscope":"string","projectcode":"string","bidopentime":"int64","supervisorrate":"float64","buyertel":"string","bidamount":"float64","winner":"string","buyer":"string","budget":"float64","projectname":"string","bidstatus":"string","buyerclass":"string","topscopeclass":"","s_topscopeclass":"string","s_subscopeclass":"string","area":"string","city":"string","district":"string","s_winner":"string","_id":"","title":"string","detail":"string","site":"string","comeintime":"int64","href":"string","infoformat":"int","publishtime":"int64","s_sha":"string","spidercode":"string","subtype":"string","toptype":"string","projectinfo":"","purchasing":"string","purchasinglist":"","filetext":"string","channel":"string","winnerorder":""},
         "fields": "buyerzipcode,winnertel,winnerperson,contractcode,winneraddr,agencyaddr,buyeraddr,signaturedate,projectperiod,projectaddr,agencytel,agencyperson,buyerperson,agency,projectscope,projectcode,bidopentime,supervisorrate,buyertel,bidamount,winner,buyer,budget,projectname,buyerclass,topscopeclass,s_topscopeclass,area,city,district,s_winner,toptype,subtype,subscopeclass,s_subscopeclass,dataging,winnerorder",
-        "projectinfo": "approvecode,approvecontent,approvestatus,approvetime,approvedept,approvenumber,projecttype,approvecity",
+        "projectinfo":"approvecode,approvecontent,approvestatus,approvetime,approvedept,approvenumber,projecttype,approvecity", 
+     	"projectinfomap":{"approvecode":"string","approvecontent":"string","approvestatus":"string","approvetime":"string","approvedept":"string","approvenumber":"string","projecttype":"string","approvecity":"string"},
         "purchasinglist": "itemname,model,unitname,number",
+        "purchasinglistmap":{"itemname":"string","model":"string","unitname":"string","number":"float64"},
         "winnerorder": "sort,sortstr,entname",
+        "winnerordermap": {"sort":"int","sortstr":"string","entname":"string"},
         "multiIndex": ""
     },
     "filelength": 50000,
     "detaillength": 50000,
     "project": {
         "db": "mxs",
-        "collect": "test",
-        "index": "projectset_v1",
+        "collect": "projectset",
+        "index": "projectset_v5",
         "type": "projectset"
     },
     "project2": {
@@ -95,7 +99,7 @@
 		}
     },
     "elastic": {
-        "addr": "http://192.168.3.128:9800",
+        "addr": "http://192.168.3.11:9800",
         "pool": 12
     }
 }

+ 52 - 23
udpcreateindex/src/main.go

@@ -14,23 +14,27 @@ import (
 )
 
 var (
-	Sysconfig             map[string]interface{} //配置文件
-	mgo                   *mongodb.MongodbSim    //mongodb操作对象
-	extractmgo            *mongodb.MongodbSim    //mongodb操作对象
-	project2db            *mongodb.MongodbSim    //mongodb操作对象
-	mgostandard           *mongodb.MongodbSim    //mongodb操作对象
-	qyxydb                *mongodb.MongodbSim    //mongodb操作对象
-	udpclient             mu.UdpClient           //udp对象
-	updport               string
-	savesizei             = 500
-	biddingIndexFields    = []string{"_id", "buyerclass", "s_winner", "title", "detail", "detail_bak", "area", "areaval", "site", "type", "amount", "bidopendate", "bidopentime", "buyer", "channel", "city", "comeintime", "contenthtml", "descript", "description", "extracttype", "href", "infoformat", "keywords", "projectcode", "projectname", "publishtime", "s_sha", "spidercode", "subtype", "summary", "toptype", "urltop", "winner", "agency", "budget", "bidamount", "s_subscopeclass", "projectscope", "bidstatus"}
-	projectinfoFields     []string
-	multiIndex            []string
-	purchasinglistFields  []string
-	winnerorderlistFields []string
-	BulkSize              = 400
-	detailLength          = 50000
-	fileLength            = 50000
+	Sysconfig                map[string]interface{} //配置文件
+	mgo                      *mongodb.MongodbSim    //mongodb操作对象
+	extractmgo               *mongodb.MongodbSim    //mongodb操作对象
+	project2db               *mongodb.MongodbSim    //mongodb操作对象
+	mgostandard              *mongodb.MongodbSim    //mongodb操作对象
+	qyxydb                   *mongodb.MongodbSim    //mongodb操作对象
+	udpclient                mu.UdpClient           //udp对象
+	updport                  string
+	savesizei                = 500
+	biddingIndexFields       = []string{"_id", "buyerclass", "s_winner", "title", "detail", "detail_bak", "area", "areaval", "site", "type", "amount", "bidopendate", "bidopentime", "buyer", "channel", "city", "comeintime", "contenthtml", "descript", "description", "extracttype", "href", "infoformat", "keywords", "projectcode", "projectname", "publishtime", "s_sha", "spidercode", "subtype", "summary", "toptype", "urltop", "winner", "agency", "budget", "bidamount", "s_subscopeclass", "projectscope", "bidstatus"}
+	biddingIndexFieldsMap    = map[string]string{}
+	projectinfoFields        []string
+	projectinfoFieldsMap     = map[string]string{}
+	multiIndex               []string
+	purchasinglistFields     []string
+	winnerorderlistFields    []string
+	purchasinglistFieldsMap  = map[string]string{}
+	winnerorderlistFieldsMap = map[string]string{}
+	BulkSize                 = 400
+	detailLength             = 50000
+	fileLength               = 50000
 	//bidding_other连接信息
 	bidding_other_es *elastic.Elastic
 	other_index      string
@@ -131,18 +135,43 @@ func init() {
 			purchasinglistFields = strings.Split(pcl, ",")
 		}
 	}
-	// if bidding["winnerorder"] != nil {
-	// 	winnerorder := util.ObjToString(bidding["winnerorder"])
-	// 	if winnerorder != "" {
-	// 		winnerorderlistFields = strings.Split(winnerorder, ",")
-	// 	}
-	// }
+	if bidding["winnerorder"] != nil {
+		winnerorder := util.ObjToString(bidding["winnerorder"])
+		if winnerorder != "" {
+			winnerorderlistFields = strings.Split(winnerorder, ",")
+		}
+	}
 	if bidding["multiIndex"] != nil {
 		mi := util.ObjToString(bidding["multiIndex"])
 		if mi != "" {
 			multiIndex = strings.Split(mi, ",")
 		}
 	}
+	//
+	if bidding["indexfieldsmap"] != nil {
+		for k, v := range bidding["indexfieldsmap"].(map[string]interface{}) {
+			biddingIndexFieldsMap[k] = util.ObjToString(v)
+		}
+		util.Debug(biddingIndexFieldsMap)
+	}
+	if bidding["projectinfomap"] != nil {
+		for k, v := range bidding["projectinfomap"].(map[string]interface{}) {
+			projectinfoFieldsMap[k] = util.ObjToString(v)
+		}
+		util.Debug(projectinfoFieldsMap)
+	}
+	if bidding["purchasinglistmap"] != nil {
+		for k, v := range bidding["purchasinglistmap"].(map[string]interface{}) {
+			purchasinglistFieldsMap[k] = util.ObjToString(v)
+		}
+		util.Debug(purchasinglistFieldsMap)
+	}
+	if bidding["winnerordermap"] != nil {
+		for k, v := range bidding["winnerordermap"].(map[string]interface{}) {
+			winnerorderlistFieldsMap[k] = util.ObjToString(v)
+		}
+		util.Debug(winnerorderlistFieldsMap)
+	}
 	log.Println(projectinfoFields)
 	log.Println(purchasinglistFields)
 	//初始化oss

+ 3 - 1
udpcreateindex/src/projectindex.go

@@ -102,7 +102,9 @@ func projectTask(data []byte, project, mapInfo map[string]interface{}) {
 		if float64(budget) > 0 && float64(bidamount) > 0 {
 			rate := float64(1) - float64(bidamount)/float64(budget)
 			f, _ := strconv.ParseFloat(strconv.FormatFloat(rate, 'f', 2, 64), 64)
-			tmp["project_rate"] = f
+			if f > 0 {
+				tmp["project_rate"] = f
+			}
 		}
 		if topscopeclass, ok := tmp["topscopeclass"].([]interface{}); ok {
 			tc := []string{}