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
e54681588e

+ 2 - 2
fullproject/src_v1/config.json

@@ -72,8 +72,8 @@
         "pre_regexp": ["\\(不见面开标\\)", "\\(买方)", "\\(\\d+个月\\)", "\\d{4}年", "\\d+月", "<[^>]*>", "AB", "CC", "CB", "CA", "[A-Z]?\\d+", "\\(第(\\d+|一|二|三|四|五|六|七)(批|次)?\\)", "\\(\\d+局\\)", "\\d+标段", "\\(二次)", "(重招\\d)", "(\\(|(?)周(五|四|三|二|一|日|六)?(\\)|))",
             "(\\(|()?[a-zA-Z](\\)|))?", "(\\(|()?\\d{0,8}.?\\d+(\\)|))?", "#(~|、)?", "#\\d{1,};?", "(\\+|\\.|、|-|#|%|:|:)+"],
         "back_regexp": ["采购人$", "[^a-zA-Z\\p{Han}]{1,}$"],
-        "back_rep_regexp": ["(有限公$)#有限公司", "(有限责任公$)#有限责任公司", "(公司公司&)#公司", "(公司等&)#公司"],
-        "blacklist": ["有问题", "个县公司", "T及分公司", "大厦\\d+室", "住宅楼", "购物中心", "盖法人章", "东侧路面拓宽", "、技术研发中心", "地下室", "车库", "二公司", "二类居住", "钢芯铝绞线", "已仔细"]
+        "back_rep_regexp": ["(有限公$)#有限公司", "(有限责任公$)#er有限责任公司", "(公司公司&)#公司", "(公司等&)#公司"],
+        "blacklist": ["有问题", "个县公司", "T及分公司", "大厦\\d+室", "住宅楼", "购物中心", "盖法人章", "东侧路面拓宽", "、技术研发中心", "地下室", "车库", "二类居住", "钢芯铝绞线", "已仔细"]
     },
     "agency": {
         "pre_regexp": ["发布人:", "<[^>]*>", "(\\(|()?[a-zA-Z](\\)|))?", "(\\(|()?\\d{0,8}.?\\d+(\\)|))?", "#(~|、)?", "#\\d{1,};?", "(\\+|\\.|、|-|#|%|:|:)+"],

+ 4 - 4
fullproject/src_v1/main.go

@@ -71,7 +71,7 @@ func DealSign() {
 	}
 }
 
-func mainT() {
+func main() {
 	//udp跑增量  id段   project
 	//udp跑全量			qlT
 	//udp跑历史数据  信息id1,id2/或id段  ls
@@ -90,9 +90,9 @@ func mainT() {
 }
 
 //测试组人员使用
-func main() {
-	sid = "5cde1a74a5cb26b9b782dd1f"
-	eid = "5dee234de9d1f601e4c4b813"
+func mainT() {
+	sid = "5eddb9189e628c5991654802"
+	eid = "5f9670aa50cded0641b30736"
 	//flag.StringVar(&sid, "sid", "", "开始id")
 	//flag.StringVar(&eid, "eid", "", "结束id")
 	//flag.Parse()

+ 11 - 9
fullproject/src_v1/task.go

@@ -322,10 +322,7 @@ func (p *ProjectTask) taskZl(udpInfo map[string]interface{}) {
 //招标字段更新
 func (p *ProjectTask) taskUpdateInfo(udpInfo map[string]interface{}) {
 	defer util.Catch()
-	db, _ := udpInfo["db"].(string)
-	if db == "" {
-		db = MongoTool.DbName
-	}
+	db := MongoTool.DbName
 	coll, _ := udpInfo["coll"].(string)
 	if coll == "" {
 		coll = ExtractColl
@@ -563,6 +560,7 @@ func (p *ProjectTask) enter(db, coll string, q map[string]interface{}) {
 	}()
 	p.Brun = true
 	count, taskcount := 0, 0
+	countRepeat := 0
 
 	pool := make(chan bool, p.thread)
 	log.Println("start project", q)
@@ -584,6 +582,7 @@ func (p *ProjectTask) enter(db, coll string, q map[string]interface{}) {
 					if util.IntAll(tmp["repeat"]) == 0 {
 						if P_QL.currentType == "project" && util.IntAll(tmp["dataging"]) == 1 {
 							//增量	dataging为1不参与合并
+							util.Debug("增量   dataging == 1 ", tmp["_id"])
 							return
 						}
 						p.fillInPlace(tmp)
@@ -598,6 +597,8 @@ func (p *ProjectTask) enter(db, coll string, q map[string]interface{}) {
 						}
 					} else {
 						//信息错误,进行更新
+						util.Debug(tmp["_id"])
+						countRepeat++
 					}
 				}(tmp)
 			case <-over:
@@ -605,9 +606,10 @@ 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, "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, "purchasing": 1, "winnerorder": 1}
+	//fields := map[string]interface{} {"repeat": 1, "dataging": 1, "area": 1, "city": 1, "district": 1, "comeintime": 1, "publishtime": 1, "bidopentime": 1, "title": 1, "projectname": 1, "href": 1,
+	//	"projectcode": 1, "buyerclass": 1, "winner": 1, "buyer": 1, "buyerperson": 1, "buyertel": 1, "infoformat": 1, "toptype": 1, "subtype": 1, "spidercode": 1, "projectscope": 1, "contractcode": 1,
+	//	"site": 1, "topscopeclass": 1, "subscopeclass": 1, "bidamount": 1, "budget": 1, "agency": 1, "package": 1, "jsondata": 1, "review_experts": 1, "purchasing": 1, "winnerorder": 1}
+	fields := map[string]interface{}{"kvtext": 0, "repeat_reason": 0}
 	ms := sess.DB(db).C(coll).Find(q).Select(fields).Sort("publishtime")
 	if Sysconfig["hints"] != nil {
 		ms.Hint(Sysconfig["hints"])
@@ -643,7 +645,7 @@ L:
 	for n := 0; n < p.thread; n++ {
 		pool <- true
 	}
-	log.Println("所有线程执行完成...", count, taskcount)
+	log.Println("所有线程执行完成...", count, taskcount, countRepeat)
 
 }
 
@@ -801,7 +803,7 @@ func ParseInfo(tmp map[string]interface{}) (info *Info) {
 	}
 	thisinfo.WinnerOrder = wins
 	//清理buyer
-	buyer := QyFilter(util.ObjToString(tmp["tmp"]), "buyer")
+	buyer := QyFilter(util.ObjToString(tmp["buyer"]), "buyer")
 	tmp["buyer"] = buyer
 	thisinfo.Buyer = buyer
 

+ 10 - 10
projectinfo/src/config.json

@@ -1,23 +1,23 @@
 {
-	"mgodb": "192.168.3.207:27092",
+	"mgodb": "172.17.145.163:27080",
 	"dbsize": 10,
-	"dbname": "mxs",
-	"dbcoll": "nijian",
+	"dbname": "mixdata",
+	"dbcoll": "project_nijian",
 	"mixdata":{
-		"addr": "192.168.3.207:27092",
+		"addr": "172.17.145.163:27080",
 		"db" : "mixdata",
 		"size": 15,
 		"buyer_ent": "buyer_enterprise",
-		"tagcoll": "project_biaoqian_new",
-		"savecoll": "project_forecast_test"
+		"tagcoll": "project_biaoqian_nijian",
+		"savecoll": "project_forecast_nijian"
 	},
 	"udpport": ":1182",
 	"forecast": {
-		"规划可研": ["立项环评", "勘察设计", "建设准备", "前期准备"],
+		"规划可研": ["立项环评", "勘察设计", "建设准备", "前期施工"],
 		"立项环评": ["勘察设计", "建设准备", "前期施工"],
 		"勘察设计": ["建设准备", "前期施工"],
-		"建设准备": ["前期施工"],
-		"前期施工": ["后期施工"],
+		"建设准备": ["建设准备","前期施工"],
+		"前期施工": ["后期施工","竣工验收","运行维护"],
 		"后期施工": ["竣工验收", "运行维护"],	
 		"竣工验收": ["运行维护"],
 		"运行维护": ["物品采购"]
@@ -26,7 +26,7 @@
 	"projecttype": ["报建", "核准类", "核准", "审批类", "审批"],
 	"rate": "60%",
 	"elastic": {
-        "addr": "http://127.0.0.1:9800",
+        "addr": "http://172.17.145.170:9800",
         "index": "bidding",
         "itype": "bidding",
         "pool": 12

+ 108 - 10
projectinfo/src/task.go

@@ -1,9 +1,11 @@
 package main
 
 import (
+	"fmt"
 	"log"
 	mgoutil "mongodb"
 	qu "qfw/util"
+	"strings"
 	"sync"
 	"time"
 
@@ -13,6 +15,56 @@ import (
 	//"go.mongodb.org/mongo-driver/bson/primitive"
 )
 
+const ESMODEL = `
+{
+  "query": {
+    "filtered": {
+      "filter": {
+        "bool": {
+          "must": [
+            {
+              "term": {
+                "buyer": "%s"
+              }
+            }
+          ]
+        }
+      },
+      "query": {
+        "bool": {
+          "should": [
+            {
+              "multi_match": {
+                "query": "%s",
+                "type": "phrase",
+                "fields": [
+                  "purchasing",
+                  "s_projectname",
+                  "title"
+                ]
+              }
+            }
+          ]
+        }
+      }
+    }
+  },
+  "from": 0,
+  "size": 100,
+  "sort": [
+    {
+      "publishtime": "desc"
+    }
+  ],
+  "_source": [
+    "buyerperson",
+    "buyertel",
+    "projectname",
+    "_id"
+  ]
+}
+`
+
 func SaveMgo() {
 	log.Println("Mgo Save...")
 	arru := make([]map[string]interface{}, 200)
@@ -169,14 +221,16 @@ func GetProjectData(sid, eid string) {
 				q := bson.M{}           //查询条件
 				if sub_category != "" { //sub_category存在优先用sub_category
 					q = bson.M{
-						"sub_category": sub_category,
+						//"sub_category": sub_category,
+						"sub_category": bson.M{"$elemMatch": bson.M{"$eq": sub_category}},
 					}
 				} else { //top_category
 					q = bson.M{
-						"top_category": top_category,
+						//"top_category": top_category,
+						"top_category": bson.M{"$elemMatch": bson.M{"$eq": top_category}},
 					}
 				}
-				if stage == "后期施工" || stage == "竣工验收" || stage == "运行维护" {
+				if stage == "前期施工" || stage == "后期施工" || stage == "竣工验收" || stage == "运行维护" {
 					//qu.Debug("ForecastFlag---", ForecastFlag)
 					if ForecastFlag == 0 { //第一次增加main_project判断
 						main_project := qu.ObjToString(pro["main_project"])
@@ -199,7 +253,7 @@ func GetProjectData(sid, eid string) {
 						q["stage"] = bson.M{"$in": tmpArr}
 					}
 					ForecastFlag++
-				} else { //规划可研、立项环评、勘察设计、建设准备、前期施工
+				} else { //规划可研、立项环评、勘察设计、建设准备
 					q["stage"] = bson.M{"$in": tmpArr}
 					ForecastFlag = 2
 				}
@@ -212,14 +266,15 @@ func GetProjectData(sid, eid string) {
 					ForecastFlag++
 				}
 				for _, t := range *result {
-					// r := make(map[string]interface{})
-					// r["stage"] = t["stage"]
-					// r["purchase_classify"] = t["purchase_classify"]
-					// r["purchasing"] = t["purchasing"]
-					// r["top_category"] = t["top_category"]
-					// r["sub_category"] = t["sub_category"]
+					delete(t, "_id")
 					t["p_rate"] = Rate
 					t["time"] = ""
+					if buyer != "" {
+						projects := GetProjects(qu.ObjToString(t["purchasing"]), buyer)
+						if len(projects) > 0 {
+							t["p_projects"] = projects
+						}
+					}
 					maps = append(maps, t)
 				}
 				//qu.Debug("ForecastFlag---", ForecastFlag)
@@ -238,6 +293,49 @@ func GetProjectData(sid, eid string) {
 	log.Println("Run Over...Count:", sum)
 }
 
+func GetProjects(purchasing, buyer string) (projects []map[string]interface{}) {
+	if purchasing != "" {
+		for _, text := range strings.Split(purchasing, ",") {
+			latest_project := map[string]interface{}{} //存储最后一条数据信息
+			result_project := map[string]interface{}{} //存储每个purchasing所查询的招标信息
+			esquery := fmt.Sprintf(ESMODEL, buyer, text)
+			list := Es.Get(Index, Itype, esquery)
+			if list != nil && len(*list) > 0 {
+				for i, l := range *list {
+					p_phone := qu.ObjToString(l["buyertel"])
+					if p_phone != "" { //记录有联系电话的最新信息
+						result_project["p_purchasing"] = text
+						result_project["p_phone"] = p_phone
+						if p_person := qu.ObjToString(l["buyerperson"]); p_person != "" {
+							result_project["p_person"] = p_person
+						}
+						result_project["p_id"] = qu.ObjToString(l["_id"])
+						result_project["p_orther"] = qu.ObjToString(l["projectname"])
+						break
+					}
+					if i == 0 { //记录第一条数据信息
+						latest_project["p_purchasing"] = text
+						// if p_phone != "" {
+						// 	latest_project["p_phone"] = p_phone
+						// }
+						if p_person := qu.ObjToString(l["buyerperson"]); p_person != "" {
+							latest_project["p_person"] = p_person
+						}
+						latest_project["p_id"] = qu.ObjToString(l["_id"])
+						latest_project["p_orther"] = qu.ObjToString(l["projectname"])
+					}
+				}
+			}
+			if len(result_project) > 0 {
+				projects = append(projects, result_project)
+			} else if len(latest_project) > 0 {
+				projects = append(projects, latest_project)
+			}
+		}
+	}
+	return
+}
+
 /*
 func GetProjectData_back(t string) {
 	defer qu.Catch()

+ 2 - 2
qyxy/src/config.json

@@ -7,8 +7,8 @@
 	"tasktime": 1,
 	"updatetime": 1597202468,
 	"elastic": {
-        "addr": "http://192.168.3.128:9800",
-        "index": "qyxy",
+        "addr": "http://192.168.3.11:9800",
+        "index": "qyxy_v1",
         "itype": "qyxy",
         "otherindex": "qyxy_all",
         "otheritype": "qyxy",

+ 2 - 1
qyxy/src/main.go

@@ -1,7 +1,8 @@
 package main
 
 import (
-	mgoutil "mgoutil/mongodb"
+	//mgoutil "mgoutil/mongodb"
+	mgoutil "mongodb"
 	qu "qfw/util"
 	es "qfw/util/elastic"
 )

+ 39 - 31
qyxy/src/task.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"log"
 	qu "qfw/util"
+	"regexp"
 	"sort"
 	"strings"
 	"sync"
@@ -15,28 +16,31 @@ import (
 	"go.mongodb.org/mongo-driver/bson/primitive"
 )
 
-//es、mgo非全部字段
-var FieldListMap = map[string]map[string]bool{
-	"partners":  map[string]bool{"stock_type": true, "stock_name": true, "stock_capital": false, "stock_realcapital": false, "identify_type": true, "identify_no": true},
-	"employees": map[string]bool{"employee_name": false, "position": false},
-}
-
-//全部字段
-var AllFieldListMap = []string{"punishes", "operations", "illegals"}
+var (
+	//清理
+	Han = regexp.MustCompile("[\\p{Han}]") //匹配汉字
 
-//地区处理
-var AreaFiled = []string{"credit_no", "company_code", "area_code"}
+	//es、mgo非全部字段
+	FieldListMap = map[string]map[string]bool{
+		"partners":  map[string]bool{"stock_type": true, "stock_name": true, "stock_capital": false, "stock_realcapital": false, "identify_type": true, "identify_no": true},
+		"employees": map[string]bool{"employee_name": false, "position": false},
+	}
+	//全部字段
+	AllFieldListMap = []string{"punishes", "operations", "illegals"}
+	//地区处理
+	AreaFiled = []string{"credit_no", "company_code", "area_code"}
+	//年报信息
+	AnnualReportsArr = [][]string{
+		[]string{"report_year", "company_phone", "zip_code", "company_email", "employee_no", "operator_name"},
+		[]string{"total_assets", "total_equity", "total_sales", "total_profit", "main_business_income", "profit_amount", "total_tax", "total_liability"},
+	}
+)
 
 // var AllFieldListMap = map[string]string{
 // 	"punishes":   "punish_size",
 // 	"operations": "operation_size",
 // 	"illegals":   "illegal_size",
 // }
-var AnnualReportsArr = [][]string{
-	[]string{"report_year", "company_phone", "zip_code", "company_email", "employee_no", "operator_name"},
-	[]string{"total_assets", "total_equity", "total_sales", "total_profit", "main_business_income", "profit_amount", "total_tax", "total_liability"},
-}
-
 //不生索引字段
 //var NotEsField = []string{"cancel_reason", "revoke_reason", "cancels"} //cancel_size
 
@@ -232,7 +236,7 @@ func QyxyStandard() bool {
 			//list数据
 			stockName := []string{}
 			for field, fieldMap := range FieldListMap {
-				if list, ok := tmp[field].(primitive.A); ok && len(list) > 0 {
+				if list, ok := tmp[field].([]interface{}); ok && len(list) > 0 {
 					if len(list) > 500 {
 						list = list[:500]
 					}
@@ -272,7 +276,7 @@ func QyxyStandard() bool {
 				esMap["stock_name"] = strings.Join(stockName, ",")
 			}
 			for _, field := range AllFieldListMap {
-				if list, ok := tmp[field].(primitive.A); ok && len(list) > 0 {
+				if list, ok := tmp[field].([]interface{}); ok && len(list) > 0 {
 					tmpArrMgo := []map[string]interface{}{}
 					for _, l := range list {
 						tmpMapMgo := map[string]interface{}{}
@@ -296,10 +300,10 @@ func QyxyStandard() bool {
 			sortArr := []string{}                          //存年份
 			sortMap := map[string]map[string]interface{}{} //key:年份;val:每一个年报中的company_phone,company_email,stock_name
 			tmpArrMgo := []map[string]interface{}{}
-			if annual_reports, ok := tmp["annual_reports"].(primitive.A); ok && len(annual_reports) > 0 {
+			if annual_reports, ok := tmp["annual_reports"].([]interface{}); ok && len(annual_reports) > 0 {
 				for _, annual_report := range annual_reports {
-					tmpMapMgo := map[string]interface{}{}
-					tmpMap := map[string]interface{}{}
+					tmpMapMgo := map[string]interface{}{} //记录每个年报信息标准化到mgo的数据
+					tmpMap := map[string]interface{}{}    //只记录每个年报信息的company_email和company_phone
 					report_year := ""
 					m := annual_report.(map[string]interface{})
 					for i, tmpArr := range AnnualReportsArr {
@@ -309,13 +313,15 @@ func QyxyStandard() bool {
 									if f == "report_year" {
 										report_year = textstr
 										sortArr = append(sortArr, textstr)
-									} else if f == "company_phone" && len(textstr) >= 7 {
+									} else if f == "company_phone" && !Han.MatchString(textstr) && len(textstr) >= 7 {
 										tmpMap[f] = textstr
-									} else if f == "company_email" {
+										tmpMapMgo[f] = textstr
+									} else if f == "company_email" && !Han.MatchString(textstr) && len(textstr) >= 4 {
 										tmpMap[f] = textstr
+										tmpMapMgo[f] = textstr
 									}
 									if i == 0 { //字符串信息
-										if f == "company_phone" && len(textstr) < 7 {
+										if f == "company_phone" || f == "company_email" {
 											continue
 										}
 										tmpMapMgo[f] = textstr
@@ -328,7 +334,7 @@ func QyxyStandard() bool {
 						}
 					}
 					// stock_nameArr := []string{}
-					// if i_partners, ok := m["report_partners"].(primitive.A); ok && len(i_partners) > 0 { //股东信息
+					// if i_partners, ok := m["report_partners"].([]interface{}); ok && len(i_partners) > 0 { //股东信息
 					// 	for _, par := range i_partners {
 					// 		m := par.(map[string]interface{})
 					// 		if stock_name, ok := m["stock_name"].(string); ok && stock_name != "" {
@@ -570,7 +576,7 @@ func HistoryQyxyStandard() bool {
 			//list数据
 			stockName := []string{}
 			for field, fieldMap := range FieldListMap {
-				if list, ok := tmp[field].(primitive.A); ok && len(list) > 0 {
+				if list, ok := tmp[field].([]interface{}); ok && len(list) > 0 {
 					if len(list) > 500 {
 						list = list[:500]
 					}
@@ -610,7 +616,7 @@ func HistoryQyxyStandard() bool {
 				esMap["stock_name"] = strings.Join(stockName, ",")
 			}
 			for _, field := range AllFieldListMap {
-				if list, ok := tmp[field].(primitive.A); ok && len(list) > 0 {
+				if list, ok := tmp[field].([]interface{}); ok && len(list) > 0 {
 					tmpArrMgo := []map[string]interface{}{}
 					for _, l := range list {
 						tmpMapMgo := map[string]interface{}{}
@@ -634,7 +640,7 @@ func HistoryQyxyStandard() bool {
 			sortArr := []string{}                          //存年份
 			sortMap := map[string]map[string]interface{}{} //key:年份;val:每一个年报中的company_phone,company_email,stock_name
 			tmpArrMgo := []map[string]interface{}{}
-			if annual_reports, ok := tmp["annual_reports"].(primitive.A); ok && len(annual_reports) > 0 {
+			if annual_reports, ok := tmp["annual_reports"].([]interface{}); ok && len(annual_reports) > 0 {
 				for _, annual_report := range annual_reports {
 					tmpMapMgo := map[string]interface{}{}
 					tmpMap := map[string]interface{}{}
@@ -647,13 +653,15 @@ func HistoryQyxyStandard() bool {
 									if f == "report_year" {
 										report_year = textstr
 										sortArr = append(sortArr, textstr)
-									} else if f == "company_phone" && len(textstr) >= 7 {
+									} else if f == "company_phone" && !Han.MatchString(textstr) && len(textstr) >= 7 {
 										tmpMap[f] = textstr
-									} else if f == "company_email" {
+										tmpMapMgo[f] = textstr
+									} else if f == "company_email" && !Han.MatchString(textstr) && len(textstr) >= 4 {
 										tmpMap[f] = textstr
+										tmpMapMgo[f] = textstr
 									}
 									if i == 0 { //字符串信息
-										if f == "company_phone" && len(textstr) < 7 {
+										if f == "company_phone" || f == "company_email" {
 											continue
 										}
 										tmpMapMgo[f] = textstr
@@ -666,7 +674,7 @@ func HistoryQyxyStandard() bool {
 						}
 					}
 					// stock_nameArr := []string{}
-					// if i_partners, ok := m["report_partners"].(primitive.A); ok && len(i_partners) > 0 { //股东信息
+					// if i_partners, ok := m["report_partners"].([]interface{}); ok && len(i_partners) > 0 { //股东信息
 					// 	for _, par := range i_partners {
 					// 		m := par.(map[string]interface{})
 					// 		if stock_name, ok := m["stock_name"].(string); ok && stock_name != "" {

+ 1 - 1
qyxy_change/qy_baidu/config.json

@@ -72,7 +72,7 @@
       "change_name": "其他事项备案",
       "change_push": false,
       "change_info": "其他事项备案",
-      "change_keyword": ["备案", "设立"]
+      "change_keyword": ["备案"]
     },
     {
       "change_code": "100009",

+ 3 - 2
qyxy_change/qy_baidu/main.go

@@ -3,6 +3,7 @@ package main
 import (
 	"mongodb"
 	"qfw/util"
+	"regexp"
 )
 
 var (
@@ -15,6 +16,8 @@ var (
 	BdTaskTime                                 int
 	PaTaskTime								   string
 	ChangeMap                                  []map[string]interface{}
+
+	timeReg, _ = regexp.Compile(`^[\d]{4}-[\d]{1,2}-[\d]{1,2}`)
 )
 
 func init() {
@@ -69,8 +72,6 @@ func initChangeMap() {
 func main() {
 	go SaveData()
 	go TimeTask()
-	//GetBdData()
-	//GetPaData()
 	ch := make(chan bool, 1)
 	<-ch
 }

+ 74 - 4
qyxy_change/qy_baidu/task.go

@@ -9,11 +9,12 @@ import (
 	"mongodb"
 	"qfw/util"
 	"regexp"
+	"strings"
 	"time"
 )
 
 func TimeTask() {
-	GetBdData()
+	//GetPaData()
 	c := cron.New()
 	cronstrBd := "0 0 */" + fmt.Sprint(BdTaskTime) + " * * ?" 		//每TaskTime小时执行一次
 	//cronstr := "0 0 " + fmt.Sprint(TaskTime) + " * * ?"			//每天TaskTime跑一次
@@ -48,16 +49,22 @@ func GetPaData() {
 	lastid := ""
 	sess := MgoMix.GetMgoConn()
 	defer MgoMix.DestoryMongoConn(sess)
-	fields := map[string]interface{}{"changes": 1, "company_id": 1, "company_name": 1}
+	fields := map[string]interface{}{"changes": 1, "company_id": 1, "company_name": 1, "company_type": 1, "establish_date": 1, "create_time": 1}
 	query := sess.DB(Dbname_pa).C(CollPa).Find(nil).Select(fields).Iter()
+	c := MgoMix.Count(CollPa, nil)
+	util.Debug("ping an count ------", c)
 	tmp := make(map[string]interface{})
 	for query.Next(&tmp) {
-		lastid = mongodb.BsonIdToSId(tmp["_id"])
+		lastid = mongodb.BsonIdToSId(tmp["company_id"])
 		if count%1000 == 0 {
 			util.Debug("ping an ----current-----", count, lastid)
 		}
+		if strings.Contains(util.ObjToString(tmp["company_type"]), "个体") {
+			continue
+		}
+		currentTime := time.Now().Unix()
 		if tmp["changes"] != nil && len(tmp["changes"].([]interface{})) > 0 {
-			currentTime := time.Now().Unix()
+			delete(tmp, "establish_date")
 			q := bson.M{"company_name": tmp["company_name"]}
 			changeEnt, _ := MgoMix.FindOne(CollSave, q)
 			if changeEnt != nil && len(*changeEnt) > 0 {
@@ -83,6 +90,68 @@ func GetPaData() {
 				tmp["updatetime"] = currentTime
 			}
 			update := make(map[string]interface{})
+			tmp["datasource"] = "pingan"
+			update["$set"] = tmp
+			updateInfo := []map[string]interface{}{
+				{
+					"_id": tmp["_id"],
+				},
+				update,
+			}
+			MgoSaveCache <- updateInfo
+			count++
+		}else {
+			//{
+			//	"change_code": "100000",
+			//	"change_name": "新设立公司",
+			//	"change_push": true,
+			//	"change_info": "新设立公司",
+			//	"change_keyword": ["新设立"]
+			//},
+			setupData := ""
+			if tmp["establish_date"] != nil {
+				if timeTmp, ok := tmp["establish_date"].(primitive.DateTime); ok {
+					t := timeTmp.Time()
+					setupData = util.FormatDate(&t, util.Date_Short_Layout)
+				} else if timeTmp, ok := tmp["establish_date"].(string); ok && timeTmp != "" {
+					t := timeReg.FindString(timeTmp)
+					if t != "" {
+						setupData = t
+					}
+				}
+			}
+			createData := ""
+			if tmp["create_time"] != nil {
+				if timeTmp, ok := tmp["create_time"].(primitive.DateTime); ok {
+					t := timeTmp.Time()
+					createData = util.FormatDate(&t, util.Date_Short_Layout)
+				} else if timeTmp, ok := tmp["create_time"].(string); ok && timeTmp != "" {
+					t := timeReg.FindString(timeTmp)
+					if t != "" {
+						createData = t
+					}
+				}
+			}
+			tm2, _ := time.Parse("2006-01-02", createData)
+			//当前时间17天内
+			if tm2.Unix() < (time.Now().Unix() - 17 * 60 * 60 * 24) {
+				continue
+			}
+			delete(tmp, "establish_date")
+			delete(tmp, "create_time")
+			changeInfo := make(map[string]interface{})
+			changeInfo["change_field"] = "新设立公司"
+			changeInfo["change_name_new"] = "新设立公司"
+			changeInfo["content_before"] = ""
+			changeInfo["content_after"] = "新设立公司"
+			changeInfo["change_date"] = setupData
+
+			tmp["changes"] = []map[string]interface{}{changeInfo}
+			tmp["_id"] = primitive.NewObjectID()
+			tmp["createtime"] = currentTime
+			tmp["updatetime"] = currentTime
+			tmp["datasource"] = "pingan"
+			update := make(map[string]interface{})
 			update["$set"] = tmp
 			updateInfo := []map[string]interface{}{
 				{
@@ -135,6 +204,7 @@ func findEnt(tmp map[string]interface{}) {
 		saveEnt := map[string]interface{}{}
 		if saveEnt != nil && len(*paEnt) > 0 {
 			//3、企业库有该企业信息
+			saveEnt["datasource"] = "baidu"
 			saveEnt["_id"] = primitive.NewObjectID()
 			saveEnt["company_id"] = (*paEnt)["company_id"]
 			saveEnt["company_name"] = (*ent)["entName"]

+ 1 - 0
qyxy_change/qy_foucs/task.go

@@ -74,6 +74,7 @@ func findEnt(tmp map[string]interface{}) {
 	tmp["_id"] = primitive.NewObjectID()
 	tmp["createtime"] = currentTime
 	tmp["updatetime"] = currentTime
+	tmp["datasource"] = "focus"
 	update := make(map[string]interface{})
 	update["$set"] = tmp
 	updateInfo := []map[string]interface{}{

+ 1 - 1
src/jy/cluster/ssh.go

@@ -49,7 +49,7 @@ var sshstr = `
 cd /opt
 kill -9 $(pidof extract_v3)
 rm -rf extract_v3*
-wget http://172.17.4.196:9080/res/extract_v3.tgz
+wget http://172.17.145.179:9080/res/extract_v3.tgz
 tar -xzvf extract_v3.tgz
 cd /opt/extract_v3
 chmod 777 extract_v3

+ 55 - 39
src/jy/extract/extract.go

@@ -216,9 +216,7 @@ func RunExtractTask(taskId string) {
 			//if qu.ObjToString(v["sensitive"]) != "" { //去除含敏感词数据
 			//	continue
 			//}
-			if qu.ObjToString(v["spidercode"]) == "a_gjggzyjypt_gcjs_kbjl" { //临时
-				continue
-			}
+			//根据标题判断是否抽取
 			b := IsExtract("title", qu.ObjToString(v["title"]), "")
 			if !b {
 				continue
@@ -328,6 +326,17 @@ func (e *ExtractTask) PreInfo(doc map[string]interface{}) (j, jf *ju.Job, isSite
 		if (*toMap)["jsoncontent"] != nil {
 			delete(*toMap, "jsoncontent")
 		}
+		for k,v := range *toMap{
+			if _,ok := v.(float64);ok{
+				continue
+			}else if _,ok := v.(int64);ok{
+				continue
+			}else if _,ok2 := v.(string);ok2{
+				continue
+			}else {
+				delete(*toMap,k)
+			}
+		}
 	}
 	j = &ju.Job{
 		SourceMid:      qu.BsonIdToSId(doc["_id"]),
@@ -459,12 +468,21 @@ func file2text(doc *map[string]interface{}) {
 
 //抽取
 func (e *ExtractTask) ExtractProcess(j, jf *ju.Job, isSite bool) {
+
 	e.ExtractDetail(j, isSite, j.SpiderCode)
 	if jf != nil && jf.IsFile {
-		e.ExtractFile(jf, isSite, j.SpiderCode)
-		for tmpk, _ := range jf.Result {
+		e.ExtractDetail(jf, isSite, j.SpiderCode)
+		for tmpk, xs := range jf.Result {
 			if len(j.Result[tmpk]) == 0 {
+				if tmpk == "budget" || tmpk == "bidamount" {
+					for _, v := range xs {
+						if fv, ok := v.Value.(float64); ok && fv > 100 && fv < 50000000000 {
+							j.Result[tmpk] = append(j.Result[tmpk], v)
+						}
+					}
+				} else {
 					j.Result[tmpk] = append(j.Result[tmpk], jf.Result[tmpk]...)
+				}
 			}
 		}
 		if len(j.Winnerorder) == 0 && jf.Winnerorder != nil && len(jf.Winnerorder) > 0 {
@@ -1455,6 +1473,12 @@ func ExtRegBack(j *ju.Job, in *RegLuaInfo, t *TaskInfo, vc *RuleCore) {
 						return
 					}
 					text := qu.ObjToString(v.Value)
+					if v.Field == "bidamount" || v.Field == "budget" {
+						if strings.Contains(qu.ObjToString(v.SourceValue), "费率") {
+							j.Result[in.Field][k].IsTrue = false
+							continue
+						}
+					}
 					if text != "" {
 						text = in.RegPreBac.Reg.ReplaceAllString(text, in.RegPreBac.Replace)
 					}
@@ -1825,7 +1849,13 @@ func AnalysisSaveResult(j, jf *ju.Job, e *ExtractTask) {
 		if len(j.Winnerorder) > 0 { //候选人信息
 			for i, v := range j.Winnerorder {
 				if v["price"] != nil {
-					j.Winnerorder[i]["price"] = clear.ObjToMoney([]interface{}{v["price"], ""}, j.SpiderCode)[0]				}
+					tmpPrice := clear.ObjToMoney([]interface{}{v["price"], ""}, j.SpiderCode, j.IsClearnMoney)
+					if tmpPrice[len(tmpPrice)-1].(bool) {
+						j.Winnerorder[i]["price"] = tmpPrice[0]
+					} else {
+						delete(j.Winnerorder[i], "price")
+					}
+				}
 			}
 			tmp["winnerorder"] = j.Winnerorder
 		}
@@ -1839,12 +1869,9 @@ func AnalysisSaveResult(j, jf *ju.Job, e *ExtractTask) {
 					if v.Score > -1 {
 						ffield[v.Field] = v.Value
 						if tmp[v.Field] == nil {
-							if v.Field == "budget" || v.Field == "bidamount" {
-								if fv, ok := v.Value.(float64); ok && fv > 100 && fv < 50000000000 {
-									tmp[v.Field] = v.Value
-								}
-							} else {
+							if (v.Field == "bidamount" || v.Field == "budget") && v.IsTrue {
 								tmp[v.Field] = v.Value
+								break
 							}
 						}
 						break
@@ -1946,7 +1973,7 @@ func AnalysisSaveResult(j, jf *ju.Job, e *ExtractTask) {
 						kvtext.WriteString(jv_k)
 						kvtext.WriteString(":")
 						kvtext.WriteString(jv_vv.Value)
-						kvtext.WriteString(" ")
+						kvtext.WriteString("\n")
 					}
 				}
 			}
@@ -1975,21 +2002,13 @@ func AnalysisSaveResult(j, jf *ju.Job, e *ExtractTask) {
 			tmp["projectname"] = j.Title
 		}
 		tmp["repeat"] = 0
+		if ju.Ffield {
+			if len(ffield) > 0 {
+				tmp["ffield"] = ffield
+			}
+		}
 		if e.TaskInfo.TestColl == "" {
 			if len(tmp) > 0 { //保存抽取结果
-				/*	if len(e.SiteFields) <= 0 {
-						//for field, _ := range e.Fields {
-						//	if tmp[field] == nil &&  {
-						//		tmp[field] = "" //覆盖之前版本数据
-						//	}
-						//}
-					} else {
-						//for field, _ := range e.SiteFields {
-						//	if tmp[field] == nil &&{
-						//		tmp[field] = "" //覆盖之前版本数据
-						//	}
-						//}
-					}*/
 				tmparr := []map[string]interface{}{
 					map[string]interface{}{
 						"_id": qu.StringTOBsonId(_id),
@@ -2018,19 +2037,6 @@ func AnalysisSaveResult(j, jf *ju.Job, e *ExtractTask) {
 			}
 		} else { //测试结果
 			delete(tmp, "_id")
-			//auxinfo := auxInfo(j)
-			//auxinfof := auxInfo(jf)
-			//if len(auxinfo) > 0 {
-			//	tmp["fieldall"] = auxinfo
-			//}
-			//if len(auxinfof) > 0 {
-			//	tmp["fieldallf"] = auxinfof
-			//}
-			if ju.Ffield {
-				if len(ffield) > 0 {
-					tmp["ffield"] = ffield
-				}
-			}
 			delete(tmp, "fieldall")
 			if len(j.BlockPackage) > 0 { //分包详情
 				if len(j.BlockPackage) > 10 {
@@ -2410,7 +2416,17 @@ func resetWinnerorder(j *ju.Job) {
 	} else if len(bidamounts) > 0 {
 		j.Result["bidamount"] = append(j.Result["bidamount"], bidamounts...)
 	}
-	
+	if j.Result["winner"] == nil && len(j.Winnerorder) > 0 && qu.Float64All(j.Winnerorder[0]["sort"]) == 1 {
+		winners = append(winners, &ju.ExtField{Code: "winnerorder", Field: "winner", ExtFrom: "j.Winnerorder", Value: j.Winnerorder[0]["entname"], Score: 0.5})
+		j.Result["winner"] = winners
+		if j.Winnerorder[0]["price"] != nil {
+			tmpPrice := clear.ObjToMoney([]interface{}{j.Winnerorder[0]["price"], ""}, j.SpiderCode, j.IsClearnMoney)
+			if tmpPrice[len(tmpPrice)-1].(bool) {
+				bidamounts = append(bidamounts, &ju.ExtField{Code: "winnerorder", Field: "bidamount", ExtFrom: "j.Winnerorder", SourceValue: j.Winnerorder[0]["price"], Value: tmpPrice[0], Score: 2.5, IsTrue: true})
+			}
+			j.Result["bidamount"] = bidamounts
+		}
+	}
 }
 func RemoveReplicaSliceString(slc []string) []string {
 	result := make([]string, 0)

+ 1 - 1
src/jy/extract/extractudp.go

@@ -161,7 +161,7 @@ func ExtractByUdp(sid, eid string, ra *net.UDPAddr, instanceId ...string) {
 				//	log.Debug(index, qu.BsonIdToSId(v["_id"]), "//去除含敏感词数据")
 				//	continue
 				//}
-				if qu.ObjToString(v["spidercode"]) == "a_gjggzyjypt_gcjs_kbjl" { //临时开标记录
+				if qu.ObjToString(v["spidercode"]) == "a_gjggzyjypt_gcjs_kbjl" || "a_hbszbtbggfwpt_kbjl" == qu.ObjToString(v["spidercode"]) { //临时开标记录
 					log.Debug(index, qu.BsonIdToSId(v["_id"]), "//开标记录")
 					continue
 				}

+ 19 - 18
src/jy/extract/score_jsondata.go

@@ -24,7 +24,7 @@ var endOfPunctuationClrear = regexp.MustCompile("[,,.。??;;]+$")
 var keysClrear = regexp.MustCompile("(详见|公告|X|内文|某单位|某部|文件|\\*|暂无|?|\\?)")
 
 //jsondata清理
-func clearJd(jd *map[string]interface{}, e *ExtractTask, spiderCode,IsClearnMoney string) {
+func clearJd(jd *map[string]interface{}, e *ExtractTask, spiderCode string, isclearnMoney string) {
 	for k, v := range *jd {
 		if k == "buyer" || k == "winner" || k == "agency" || k == "projectcode" || k == "projectname" {
 			vstring := util2.ObjToString(v)
@@ -37,7 +37,7 @@ func clearJd(jd *map[string]interface{}, e *ExtractTask, spiderCode,IsClearnMone
 			cfn := e.ClearFn[k]
 			lockclear.Unlock()
 			if len(cfn) > 0 {
-				data := clear.DoClearFn(cfn, []interface{}{vstring, ""}, spiderCode,IsClearnMoney)
+				data := clear.DoClearFn(cfn, []interface{}{vstring, ""}, spiderCode, isclearnMoney)
 				lockclear.Lock()
 				if clear.AsyField[k] != nil || clear.SymField[k] != nil || clear.MesField[k] != nil {
 					vstring = clear.OtherClean(k, util2.ObjToString(data[0]))
@@ -47,7 +47,6 @@ func clearJd(jd *map[string]interface{}, e *ExtractTask, spiderCode,IsClearnMone
 			vstring = htmlclrear.ReplaceAllString(vstring, "")
 			vstring = endOfParenthesesClrear.ReplaceAllString(vstring, "")
 			vstring = endOfPunctuationClrear.ReplaceAllString(vstring, "")
-			vstring = keysClrear.ReplaceAllString(vstring, "")
 			if utf8.RuneCountInString(vstring) < 5 {
 				delete(*jd, k)
 				continue
@@ -85,7 +84,7 @@ func JsonDataMergeProcessing(j *util.Job, e *ExtractTask) map[string][]*util.Ext
 				if len(cfn) == 0 {
 					continue
 				}
-				newNum := clear.DoClearFn(cfn, []interface{}{(*j.Jsondata)[v], ""}, j.SpiderCode,j.IsClearnMoney)
+				newNum := clear.DoClearFn(cfn, []interface{}{(*j.Jsondata)[v], ""}, j.SpiderCode, j.IsClearnMoney)
 				//if util2.IntAll(newNum[0]) != 0 {
 				extFields := make([]*util.ExtField, 0)
 				extFields = append(extFields, &util.ExtField{Code: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), Field: v, ExtFrom: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), SourceValue: (*j.Jsondata)[v], Value: newNum[0], Score: 0.1, IsTrue: newNum[len(newNum)-1].(bool)})
@@ -105,7 +104,7 @@ func JsonDataMergeProcessing(j *util.Job, e *ExtractTask) map[string][]*util.Ext
 				if bt, ok := (*j.Jsondata)[v].(float64); ok && bt > 0 {
 					extFields = append(extFields, &util.ExtField{Code: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), Field: v, ExtFrom: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), SourceValue: (*j.Jsondata)[v], Value: bt, Score: 0.1})
 				} else {
-					newNum := clear.DoClearFn(cfn, []interface{}{(*j.Jsondata)[v], ""}, j.SpiderCode)
+					newNum := clear.DoClearFn(cfn, []interface{}{(*j.Jsondata)[v], ""}, j.SpiderCode, j.IsClearnMoney)
 					extFields = append(extFields, &util.ExtField{Code: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), Field: v, ExtFrom: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), SourceValue: (*j.Jsondata)[v], Value: newNum[0], Score: 0.1})
 				}
 				j.Result[v] = extFields
@@ -203,21 +202,23 @@ func JsonDataMergeProcessing(j *util.Job, e *ExtractTask) map[string][]*util.Ext
 				if len(cfn) == 0 {
 					continue
 				}
-				newNum := clear.DoClearFn(cfn, []interface{}{(*j.Jsondata)[v], ""}, j.SpiderCode,j.IsClearnMoney)
-				//if util2.IntAll(newNum[0]) != 0 {
-				extFields := make([]*util.ExtField, 0)
-				if jdextweight > 1 {
-					if oneScore < 0 {
-						oneScore = 0.1
-					}
-					extFields = append(extFields, &util.ExtField{Code: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), Field: v, ExtFrom: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), SourceValue: (*j.Jsondata)[v], Value: newNum[0], Score: oneScore + 1, IsTrue: newNum[len(newNum)-1].(bool)})
-				} else {
-					if oneScore < 0 {
-						oneScore = 0.1
+				newNum := clear.DoClearFn(cfn, []interface{}{(*j.Jsondata)[v], ""}, j.SpiderCode, j.IsClearnMoney)
+				if newNum[len(newNum)-1].(bool) {
+					//if util2.IntAll(newNum[0]) != 0 {
+					extFields := make([]*util.ExtField, 0)
+					if jdextweight > 1 {
+						if oneScore < 0 {
+							oneScore = 0.1
+						}
+						extFields = append(extFields, &util.ExtField{Code: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), Field: v, ExtFrom: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), SourceValue: (*j.Jsondata)[v], Value: newNum[0], Score: oneScore + 1, IsTrue: newNum[len(newNum)-1].(bool)})
+					} else {
+						if oneScore < 0 {
+							oneScore = 0.1
+						}
+						extFields = append(extFields, &util.ExtField{Code: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), Field: v, ExtFrom: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), SourceValue: (*j.Jsondata)[v], Value: newNum[0], Score: oneScore, IsTrue: newNum[len(newNum)-1].(bool)})
 					}
-					extFields = append(extFields, &util.ExtField{Code: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), Field: v, ExtFrom: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), SourceValue: (*j.Jsondata)[v], Value: newNum[0], Score: oneScore, IsTrue: newNum[len(newNum)-1].(bool)})
+					j.Result[v] = append(j.Result[v], extFields...)
 				}
-				j.Result[v] = append(j.Result[v], extFields...)
 				continue
 			}
 

+ 29 - 11
src/jy/pretreated/analystep.go

@@ -14,25 +14,33 @@ import (
 	"github.com/PuerkitoBio/goquery"
 )
 
-var yjReg *regexp.Regexp = regexp.MustCompile("单位业绩|个人业绩|主要人员相关资料|投标文件格式|项目业绩|否决投标的?情况说明")
+var yjReg *regexp.Regexp = regexp.MustCompile("单位业绩|个人业绩|投标人业绩|主要人员相关资料|投标文件格式|唱标记录|项目业绩|否决投标的?情况说明")
+var hisReg2 = regexp.MustCompile("(开标记录|业绩|[得评]+[审打]{0,2}分情况|无效标)[::\n]*.*?[\n]?(</tr>|</table>|</td>)")
+var formattext = regexp.MustCompile("(投标总价)([0-9,.万元]*)")
+var formattext2 = regexp.MustCompile("中标单价.*(中标总价.*)")
 
 func AnalyStart(job *util.Job, isSite bool, codeSite string) {
 	con := job.Content
 	//全文的需要修复表格
 	con = RepairCon(con)
 	//格式化正文
+	con = hisReg.ReplaceAllString(con, "")
+	con = hisReg2.ReplaceAllString(con, "${2}")
+	con = formattext.ReplaceAllString(con, "${1}:${2}")
+	con = formattext2.ReplaceAllString(con, "${1}")
 	con = formatText(con, "all")
 	job.Content = con
 	//计算表格占比,返回表格数组、占比
-	tabs, ration := ComputeConRatio(con, 1)
-	if len(tabs) > 0 {
+	tabs, _ := ComputeConRatio(con, 1)
+	/*if len(tabs) > 0 {
 		newcon, newtabs, newration := FindBigText(con, ration, tabs)
 		if newcon != "" {
 			con = newcon
+			con = formatText(con, "all")
 			tabs = newtabs
 			ration = newration
 		}
-	}
+	}*/
 	job.BlockPackage = map[string]*util.BlockPackage{}
 	blockArrays, _ := DivideBlock(job.CategorySecond, con, 1, job.RuleBlock, isSite, codeSite) //分块
 	if len(blockArrays) > 0 {                                                                  //有分块
@@ -66,13 +74,18 @@ func AnalyStart(job *util.Job, isSite bool, codeSite string) {
 			job.HasTable = 1 //添加标识:文本中有table
 			newCon = TextAfterRemoveTable(con)
 			//log.Println(newCon)
-			if newCon!=""{
+			if newCon != "" {
 				job.BlockPackage = FindPackageFromText(job.Title, newCon, isSite, codeSite)
 			}
 			for i := 0; i < len(tabs); i++ {
-				//fmt.Println(tabs[i].Html())
+				blockTag := ""
+				if len(tabs[i].Nodes) > 0 {
+					if tabs[i].Nodes[0].PrevSibling != nil {
+						blockTag = tabs[i].Nodes[0].PrevSibling.Data
+					}
+				}
 				//添加标识:文本中有table
-				tabres := AnalyTableV2(tabs[i], job.Category, "", con, 1, job.SourceMid, job.RuleBlock, isSite, codeSite) //解析表格入口 返回:汇总表格对象
+				tabres := AnalyTableV2(tabs[i], job.Category, blockTag, con, 1, job.SourceMid, job.RuleBlock, isSite, codeSite) //解析表格入口 返回:汇总表格对象
 				processTableResult(tabres, bl, job, isSite, codeSite)
 			}
 		} else {
@@ -83,11 +96,12 @@ func AnalyStart(job *util.Job, isSite bool, codeSite string) {
 		//log.Println(bl.Text)
 		FindProjectCode(bl.Text, job) //匹配项目编号
 		if yjReg.MatchString(bl.Text) {
-			if strings.Index(bl.Text, "业绩")>1{
+			if strings.Index(bl.Text, "业绩") > 1 {
 				bl.Text = bl.Text[:strings.Index(bl.Text, "业绩")]
 			}
 		}
 		//调用kv解析
+		bl.Text = formatText(bl.Text, "all")
 		bl.ColonKV = GetKVAll(bl.Text, "", nil, 1, isSite, codeSite)
 		bl.SpaceKV = SspacekvEntity.Entrance(bl.Text, "", nil, isSite, codeSite)
 		//新加 未分块table中未能解析到中标候选人,从正文中解析
@@ -106,7 +120,9 @@ func processTableInBlock(bl *util.Block, job *util.Job, isSite bool, codeSite st
 	for _, tab := range tabs {
 		job.HasTable = 1
 		tmptag := ""
-		if tab.Nodes[0] != nil && tab.Nodes[0].PrevSibling != nil {
+		if bl.Title != "" && len(bl.Title) < 20 {
+			tmptag = bl.Title
+		} else if tab.Nodes[0] != nil && tab.Nodes[0].PrevSibling != nil {
 			tmptag = strings.TrimSpace(tab.Nodes[0].PrevSibling.Data)
 		}
 		//添加标识:文本中有table
@@ -290,8 +306,10 @@ func processTableResult(tabres *TableResult, block *util.Block, job *util.Job, i
 						wror = append(wror, v)
 						continue
 					} else if tmpWins[v["entname"].(string)] > 0 && tmpWins[v["entname"].(string)] == v["sort"].(int) && v["price"] != nil {
-						if tmpWins[v["entname"].(string)]-1 >= 0 {
-							job.Winnerorder[tmpWins[v["entname"].(string)]-1] = v
+						if tmpWins[v["entname"].(string)]-1 >= 0 && len(job.Winnerorder) > 0 {
+							if len(job.Winnerorder) > (tmpWins[v["entname"].(string)] - 1) {
+								job.Winnerorder[tmpWins[v["entname"].(string)]-1] = v
+							}
 							continue
 						}
 					}

+ 24 - 10
src/jy/pretreated/winnerorder.go

@@ -1,6 +1,8 @@
 package pretreated
 
 import (
+	"jy/clear"
+	//"jy/clear"
 	"jy/util"
 	qutil "qfw/util"
 	"regexp"
@@ -27,14 +29,16 @@ var (
 	numberReg2        = regexp.MustCompile("[\\d一二三四五六七八九十.,,]+")
 	thisNumberReg     = regexp.MustCompile("第" + numberReg.String())
 	winnerReg0        = regexp.MustCompile("(中标候选人第\\d名)")
-	winnerReg1        = regexp.MustCompile("(^|[^为])(【?(推荐)?第[一二三四五六七八九十1-9]+(合格|名|包|标段)?】?((候|侯)选)?(入围|备选|成交|中(标|选))人?([((]成交[))])?((候|侯)选|排序)?(人(单位)?|供[应货]商|单位|机构)(名称)?为?)($|[^,;;。,])")
-	winnerReg2        = regexp.MustCompile("(排名第[一二三四五六七八九十1-9]+|第[一二三四五六七八九十1-9]+(候|侯)选人)")
+	winnerReg1        = regexp.MustCompile("(^|[^为])(【?(推荐)?第[一二三四五六七八九十1-9]+(合格|名|包|标段)?】?([候|侯]选)?(入围|备选|成交|中[标|选])人?([((]成交[))])?([候|侯]选|排序)?(人(单位)?|供[应货]商|单位|机构)(名称)?为?)($|[^,;;。,])")
+	winnerReg2        = regexp.MustCompile("(排名第[一二三四五六七八九十1-9]+|第[一二三四五六七八九十1-9]+(中标)?[候|侯]选人|中标候选人排名[:]\\d)")
 	//winnerReg2     = regexp.MustCompile("(第[一二三四五六七八九十1-9]+(候|侯)选人)")
 	winnerReg3     = regexp.MustCompile("((中标候选人)?第[一二三四五六七八九十1-9]+名)")
-	winnerReg4     = regexp.MustCompile("((确认|推荐|评审|排[名|序])[为::]+|(由高到低排序前.名|公示下列内容|(确定|推荐)的?中[标|选]候选人|\n中[标|选]候选.{1,3}\\s*\n|\n(中(标|选)候选.{1,3}[::\u3000\u2003\u00a0\\s]|成交候选供应商)|(排[名|序]|公[示|告]|具体|推荐|结果(公示)?|中[标|选]候选人.{0,2})如下|[一二三四五六七八九十\\d]+、(中[标|选]候选[^\n::]{1,8}|.{0,8}(成交|结果)信息|成交[^\n::]{2,8}))[为::]?)")
+	winnerReg4     = regexp.MustCompile("((确认|推荐|评审|排[名|序])[为::]+|(由高到低排序前.名|公示下列内容|(确定|推荐)的?中[标|选]候选人|\n中[标|选]候选.{1,3}\\s*\n|\n(中[标|选]候选.{1,3}[::\u3000\u2003\u00a0\\s]|成交候选供应商)|(排[名|序]|公[示|告]|具体|推荐|结果(公示)?|中[标|选]候选人.{0,2})如下|[一二三四五六七八九十\\d]+、(中[标|选]候选[^\n::]{1,8}|.{0,8}(成交|结果)信息|成交[^\n::]{2,8}))[为::]?)")
 	winnerReg5     = regexp.MustCompile("([^,;;。,、\n投标人]+?)(为?)(第[一二三四五六七八九十1-9]+(成交|中标)?([候|侯]选(人|供应商|单位|机构)|名)|排名第[一二三四五六七八九十1-9]+)([,;;。,、]|\\s+\n)")
 	winnerReg6     = regexp.MustCompile("(^(排名)?第[一二三四五六七八九十1-9]+[名中标成交备选候人单位供应商]*)")
 	winnerReg7     = regexp.MustCompile("第[一二三四五六七八九十]{1}标段[::]")
+	winnerReg8     = regexp.MustCompile("(第[一二三四五六七八九十]中标候选人)[::]?\n(1)单位名称:(.*)\n(2)投标报价(含税):(.*)")
+	winnerRegclear = regexp.MustCompile("(买方人员|经评审.*排名第[一二三四五六七八九十1-9]+)")
 	colonEndReg    = regexp.MustCompile("[::]$")
 	toWarpReg      = regexp.MustCompile("[,。,;;]+")
 	findamountReg  = regexp.MustCompile("[,。,;;\u3000\u2003\u00a0\\s]+")
@@ -42,8 +46,8 @@ var (
 	companyWarpReg = regexp.MustCompile("(公司)(.+?[::])")
 	findCompanyReg = regexp.MustCompile("[^::]+公司")
 	colonSpaceReg  = regexp.MustCompile("[::]\\s+")
-	findCandidate  = regexp.MustCompile("(^.{5,}(公司|集团|单位|机构|企业|厂|场|院|所|店|中心|市|局|站|城|处|行|部|队|联合(会|体))|工作室)")
-	findCandidate2 = regexp.MustCompile("(^.{5,}(公司|集团|单位|机构|企业|厂|场|院|所|店|中心|局|站|城|处|行|部|队|联合(会|体)|工作室)$)")
+	findCandidate  = regexp.MustCompile("(^.{5,}(公司|集团|单位|机构|企业|厂|场|院|所|店|中心|市|局|站|城|处|行|部|队|联合[会|体])|工作室)")
+	findCandidate2 = regexp.MustCompile("(^.{5,}(公司|集团|单位|机构|企业|厂|场|院|所|店|中心|局|站|城|处|行|部|队|联合[会|体]|工作室|有限司)$)")
 	clearSpace1    = regexp.MustCompile("([((][\\d一二三四五六七八九十][))][\\s\u3000\u2003\u00a0\\t]*|<[^>].+?>)")
 	clearSpace2    = regexp.MustCompile("</?[^>]+>")
 	offerReg       = regexp.MustCompile("(中标|磋商|投标|报|单|成交)总?(价|金额)")
@@ -55,10 +59,15 @@ var (
  *from 来源
  */
 func (wo *WinnerOrderEntity) Find(text string, flag bool, from int, isSite bool, codeSite string) []map[string]interface{} {
-	if clearSpace2.MatchString(text) {
-		return  []map[string]interface{}{}
+	if clearSpace2.MatchString(text){
+		text = TextAfterRemoveTable(text)
+	}
+	text = winnerRegclear.ReplaceAllString(text,"")
+	if nswinnertabletag.MatchString(text) {
+		return []map[string]interface{}{}
 	}
 	text = winnerReg5.ReplaceAllString(text, "\n$3:$1\n")
+	text = winnerReg8.ReplaceAllString(text,"\n${1}:${2}\n中标金额:${3}\n")
 	/*
 		"_id" : ObjectId("5c2c6f60a5cb26b9b7b62cd8")
 
@@ -240,7 +249,7 @@ func (wo *WinnerOrderEntity) findByReg(content string, blocks []string, reg_2 *r
 				val := wo.clear("中标单位", v)
 				if val != nil && utf8.RuneCountInString(qutil.ObjToString(val)) > 5 {
 					count++
-					object["entname"] = strings.TrimSpace(qutil.ObjToString(val))
+					object["entname"] = strings.TrimRight(strings.ReplaceAll(strings.TrimSpace(qutil.ObjToString(val)), "公司", "公司,"), ",")
 					object["sort"] = wo.toNumber(k, count)
 					object["sortstr"] = thisNumberReg.FindString(k)
 					object["type"] = i
@@ -257,9 +266,14 @@ func (wo *WinnerOrderEntity) findByReg(content string, blocks []string, reg_2 *r
 				}
 				//找到了中标金额
 				if findOfferFlag && object["entname"] != nil {
-					val := wo.clear("中标金额", v)
+					val := wo.clear("中标金额", v+GetMoneyUnit(k, v))
 					if val != nil {
-						object["price"] = val
+						moneys := clear.ObjToMoney([]interface{}{val, ""})
+						if len(moneys) > 0 {
+							if vf, ok := moneys[0].(float64); ok &&  moneys[len(moneys)-1].(bool){
+								object["price"] = float64(vf)
+							}
+						}
 					}
 					winners = append(winners, object)
 					object = map[string]interface{}{}

+ 17 - 15
src/res/fieldscore.json

@@ -209,12 +209,12 @@
             },
             {
                 "describe": "包含负分不再展示",
-                "regstr": "(详见|提出|面向|[^实]施工[^程]|获得|test|认定|一批|项目$|详细请?见?正文)",
+                "regstr": "([^实]施工[^程]|项目$|详细请?见?正文)",
                 "score": -50
             },
             {
-                "describe": "一个字或者两个字不再显示",
-                "regstr": "^[\\s]*[\\u4e00-\\u9fa5]{1,2}[\\s]*$",
+                "describe": "黑名单",
+                "regstr": "(^.{0,4}$|T及分公司|大厦[0-9]+室|东侧路面拓宽|、技术研发中心|钢芯铝绞线)",
                 "score": -50
             }
         ],
@@ -223,16 +223,8 @@
                 "describe": "[gt,lte,score]",
                 "range": [
                     0,
-                    3,
-                    -20
-                ]
-            },
-            {
-                "describe": "[gt,lte,score]",
-                "range": [
-                    3,
                     4,
-                    -1
+                    -20
                 ]
             },
             {
@@ -258,7 +250,7 @@
         "positivewords": [
             {
                 "describe": "以*结尾",
-                "regstr": ".{2,100}(集团|公司|学校|中心|家具城|门诊|\\[大中小\\]学|部|院|局|厂|店|所|队|社|室|厅|段|会|场|行)$",
+                "regstr": ".{2,100}(集团|公司|学校|中心|家具城|门诊|[大中小]学|部|院|局|厂|店|所|队|社|室|厅|段|会|场|行|联合体)$",
                 "score": 3
             },{
                 "describe": "关键词",
@@ -269,13 +261,18 @@
         "negativewords": [
             {
                 "describe": "包含负分",
-                "regstr": "(我公司|定标|通知|异议|要求|代理|详细|test|意见|原因|具体|结果|负责|付款|附件|候选|招标失败|注册表|交易中心|序号内容|不足|公告|变更|采购|招标|废标|废止|流标|中标|投标|评标|开标|供应商|金额|万元|元整|预算|报价|单价|第(\\\\d|一|二|三|四|五)(名|包)|排名|候选|确定|标段|(标|一|二|三|四|五)包|中选|成交[^通]|包号|(A|B|C|D|E|F|G)包|地址|详情|要求|推荐|名称|评审|得分|合同|平方米|公示期|结果|备注|说明|单位|代表|委托|工作日|营业(执|期)|通过|代码|电话|联系|条件|合理|费率|以上|以下|拟定|注:|\\\\d[\\\\s]{0,10}(\\\\.|元|包|米|平米|平方米|吨|辆|千克|克|毫克|毫升|公升|套|件|瓶|箱|只|台|年|月|日|天|号)|(:|:|;|;|?|¥|\\\\*|%)|^[a-zA-Z0-9-]{5,100}|^[a-zA-Z0-9-]{1,100}$|[a-zA-Z0-9-]{10,100})\n",
+                "regstr": "((中标|候选|成交|代表|投标|代理)人|我公司|定标|通知|异议|法院|要求|代理|详细|test|意见|原因|具体|结果|负责|付款|附件|候选|招标失败|注册表|交易中心|序号内容|不足|公告|变更|采购|招标|废标|废止|流标|中标|投标|评标|开标|供应商|金额|万元|元整|预算|报价|单价|第(\\d|一|二|三|四|五)(名|包)|排名|候选|确定|标段|(标|一|二|三|四|五)包|中选|成交[^通]|包号|(A|B|C|D|E|F|G)包|地址|详情|要求|推荐|名称|评审|得分|合同|平方米|公示期|结果|备注|说明|单位|代表|委托|工作日|营业(执|期)|通过|代码|电话|联系|条件|合理|费率|以上|以下|拟定|注:|\\d[\\s]{0,10}(\\d|元|包|米|平米|平方米|吨|辆|千克|克|毫克|毫升|公升|套|件|瓶|箱|只|台|年|月|日|天|号)|(:|:|;|;|?|¥|\\*|%)|^[a-zA-Z0-9-]{5,100}|^[a-zA-Z0-9-]{1,100}$|[a-zA-Z0-9-]{10,100}\\n)",
                 "score": -20
             },
 			{
                 "describe": "非结尾",
                 "regstr": ".*[^集团|公司|学校|中心|家具城|门诊|\\[大中小\\]学|部|院|局|厂|店|所|队|社|室|厅|段|会|场|行|处]$",
                 "score": -5
+            },
+            {
+                "describe": "黑名单",
+                "regstr": "(^.{0,4}$|[((]或印鉴[))]|(多家|没有)中标商|违法违规行|(中标人|供应商)名称|合同包合计|楼青年公寓装修工程|评标委员会|(投标人|供应商)被人民法院|符合初步评审标准|评标结果公示|供应商评审申报|与营业执照|保管员签字|评审小组名单|单位负责人|^[xX]+$|候选人数量|微型企业且所)",
+                "score": -50
             }
         ],
         "length": [
@@ -339,6 +336,11 @@
                 "describe": "乱码特殊符号",
                 "regstr": "[±??¨êí¤ì×üàóμˉ÷°úéè《》-]",
                 "score": -20
+            },
+            {
+                "describe": "黑名单",
+                "regstr": "(集中代理采购|竞争性谈判|“组组通”工程|提交一份公司|公司组织的|[((]章[))]$|^.{0,4}$)",
+                "score": -50
             }
         ],
         "length": [
@@ -771,7 +773,7 @@
             {
                 "describe": "-结束没有抽取完",
                 "regstr": "-$",
-                "score": -1
+                "score": -1.5
             },
             {
                 "describe": "开始到结束连续字符-0.5",

+ 397 - 12
src/res/sv.txt

@@ -2094,7 +2094,8 @@
 色达县 4 n
 雷山县 4 n
 新兴县 4 n
-城区 4 n
+晋城市城区 4 n
+汕尾市城区 4 n
 石阡县 4 n
 厦门市 4 n
 开化县 4 n
@@ -2268,7 +2269,7 @@
 吉利区 4 n
 高密市 4 n
 徐闻县 4 n
-当阳市 4 n
+当阳市 5 n
 明光市 4 n
 云岩区 4 n
 沂源县 4 n
@@ -2876,6 +2877,8 @@
 沧县 4 n
 惠水县 4 n
 莱芜市 4 n
+莱芜区 4 n
+从化市 4 n
 宜黄县 4 n
 金堂县 4 n
 绵阳市 4 n
@@ -3409,7 +3412,6 @@
 景泰 3 n
 仙居 3 n
 海淀 3 n
-市北 3 n
 银海 3 n
 岭东 3 n
 玛多 3 n
@@ -4137,7 +4139,7 @@
 涪城 3 n
 解放 3 n
 连州 3 n
-大厂	 3 n
+大厂 3 n
 大连 3 n
 金湾 3 n
 门头沟 3 n
@@ -4486,7 +4488,6 @@
 鼎湖 3 n
 定兴 3 n
 定南 3 n
-市南 3 n
 科右前旗 3 n
 讷河 3 n
 天峻 3 n
@@ -5441,6 +5442,7 @@
 于田 3 n
 桐城 3 n
 弥渡 3 n
+沧源县 4 n
 沧源 3 n
 日照 3 n
 新和 3 n
@@ -5774,7 +5776,6 @@
 惠州 3 n
 沈阳 3 n
 富蕴 3 n
-市中 3 n
 南岸 3 n
 西藏 3 n
 宾阳 3 n
@@ -5961,7 +5962,6 @@
 甘洛 3 n
 南安 3 n
 屯昌 3 n
-资源 3 n
 渌口 3 n
 平江 3 n
 牧野 3 n
@@ -14133,6 +14133,7 @@
 旺丹乡 4 n
 右三村委会 4 n
 西参村委会 4 n
+杏市村村民委员会 4 n
 王胡村民委员会 4 n
 西迷堤村委会 4 n
 青泥湖办事处 4 n
@@ -110082,6 +110083,7 @@
 生研所社区居委会 4 n
 石狗村委会 4 n
 豪园社区居委会 4 n
+石滩镇故县村委会 4 n
 龙埚村委会 4 n
 麻丘镇居委会(南昌高新开发区) 4 n
 东流村委会 4 n
@@ -122303,7 +122305,7 @@
 河石村民委员会 4 n
 菜利社区村民委员会 4 n
 卞李村委会 4 n
-鱼嘴镇人民政府 4 n
+鱼嘴镇 4 n
 月家村村委会 4 n
 海湾村村委会 4 n
 刘坑头村委会 4 n
@@ -293909,7 +293911,6 @@
 青坑岙村村委会 4 n
 小东流村委会 4 n
 车田村 4 n
-庄村 4 n
 达卧村民委员会 4 n
 城头盖村委会 4 n
 李花园村委会 4 n
@@ -328654,6 +328655,7 @@
 孙家社区居委会 4 n
 柴家庙村民委员会 4 n
 李磨村委会 4 n
+上草市村委会 4 n
 北小路村民委员会 4 n
 铁牛里社区居委会 4 n
 贺家巷村委会 4 n
@@ -392042,7 +392044,6 @@ IT家园社区居委会 4 n
 马堑村民委员会 4 n
 里变村委会 4 n
 大丰居委会 4 n
-县园艺场 4 n
 泉边村 4 n
 史家占村委会 4 n
 枫桥居民委员会 4 n
@@ -394323,7 +394324,6 @@ IT家园社区居委会 4 n
 河东社区小杨庄村民委员会 4 n
 翠竹社区居民委员会 4 n
 西群社区居委会 4 n
-县良种场 4 n
 信号村委会 4 n
 元柏村委会 4 n
 金玉路社区居民委员会 4 n
@@ -409009,4 +409009,389 @@ IT家园社区居委会 4 n
 德安县园艺场 4 n
 长春西汀 4 n
 北京朝阳 5 n
-教育资源 5 n
+教育资源 5 n
+国土资源 5 n
+彬县 4 n
+开县 4 n
+盘县 4 n
+户县 4 n
+郫县 4 n
+海安县 4 n
+章丘市 4 n
+清新县 4 n
+潜山县 4 n
+威宁自治县 4 n
+蓟州县 4 n
+苍山县 4 n
+门源县 4 n
+永年县 4 n
+藁城市 4 n
+金平县 4 n
+燕郊市 4 n
+通州湾示范区 4 n
+九台市 4 n
+文登市 4 n
+江东区 4 n
+庐陵新区 4 n
+襄樊市 4 n
+通安镇 3 n
+昆玉市 4 n
+湄洲岛市 4 n
+托县市 4 n
+大丰市 4 n
+即墨市 4 n
+汩罗 3 n
+汩罗市 4 n
+峨嵋山市 4 n
+米泉市 4 n
+龙港市 4 n
+人力资源 5 n
+自然资源 5 n
+普兰店市 4 n
+佟二堡新市 4 n
+监利市 4 n
+鹿泉市 4 n
+上土市 4 n
+洵口市 4 n
+制锦市 4 n
+长乐市 4 n
+永定县 4 n
+双河市 4 n
+高要市 4 n
+子长市 4 n
+射洪市 4 n
+顺德市 4 n
+东菀市 4 n
+嫩江市 4 n
+丰林县市 4 n
+临安市 4 n
+东中市 4 n
+阳东县 4 n
+海州市 4 n
+胶南市 4 n
+宜州市 4 n
+彭水自治县 4 n
+北屯市 4 n
+屯留县 4 n
+新兴市 4 n
+文家市 4 n
+金坛市 4 n
+库车市 4 n
+星子县 4 n
+南康市 4 n
+兖州市 4 n
+辽县 4 n
+建阳市 4 n
+澄江市 4 n
+广德市 4 n
+无为市 4 n
+龙南市 4 n
+东乡县 4 n
+姜堰市 4 n
+华县市 4 n
+长垣市 4 n 
+达县 4 n
+候马市 4 n
+奉化市 4 n
+察布查尔县 4 n
+道真县 4 n
+洪泽县 4 n
+天祝县 4 n
+橫峰县 4 n
+双江县 4 n
+耿马县 4 n
+宁蒗县 4 n
+玉龙县 4 n
+南涧县 4 n
+巍山县 4 n
+兰坪县 4 n
+贡山县 4 n
+石林县 4 n
+禄劝县 4 n
+墨江县 4 n
+孟连县 4 n
+宁洱县 4 n
+景东县 4 n
+景谷县 4 n
+西盟县 4 n
+镇沅县 4 n
+元江县 4 n
+峨山县 4 n
+新平县 4 n
+屏边县 4 n
+维西县 4 n
+寻甸县 4 n
+江城县 4 n
+漾濞县 4 n
+马龙县 4 n
+澜沧县 4 n
+晋宁县 4 n
+新晃县 4 n
+芷江县 4 n
+通道县 4 n
+靖州县 4 n
+麻阳县 4 n
+江华县 4 n
+城步县 4 n
+宽甸县 4 n
+新宾县 4 n
+清原县 4 n
+喀左县 4 n
+桓仁县 4 n
+阜新县 4 n
+岫岩县 4 n
+阜蒙县 4 n
+武鸣县 4 n
+玉环县 4 n
+长阳县 4 n
+五峰县 4 n
+邹县 4 n
+林县 4 n
+陕县 4 n
+民和回族自治县 4 n
+安县 4 n
+木里县 4 n
+峨边县 4 n
+马边县 4 n
+北川县 4 n
+金秀县 4 n
+三江县 4 n
+融水县 4 n
+恭城县 4 n
+龙胜县 4 n
+大化县 4 n
+巴马县 4 n
+环江县 4 n
+罗城县 4 n
+都安县 4 n
+隆林县 4 n
+富川县 4 n
+辽中县 4 n
+道真自治县 4 n
+张川县 4 n
+肃南县 4 n
+肃北县 4 n
+阿克塞县 4 n
+滦县 4 n
+唐海县 4 n
+连山县 4 n
+连南县 4 n
+乳源县 4 n
+宁乡县 4 n
+香格里拉县 4 n
+泸水县 4 n
+荣昌县 4 n
+铜梁县 4 n
+酉阳县 4 n
+广丰县 4 n
+水富县 4 n
+东乡族县 4 n
+靖西县 4 n
+乐都县 4 n
+宣化县 4 n
+达孜县 4 n
+栾城县 4 n
+双流县 4 n
+塔什库尔干县 4 n
+巴里坤县 4 n
+察布查尔锡伯县 4 n
+和布克赛尔县 4 n
+焉耆县 4 n
+松桃县 4 n
+关岭县 4 n
+紫云县 4 n
+镇宁县 4 n
+务川县 4 n
+玉屏县 4 n
+沿河县 4 n
+印江县 4 n
+三都县 4 n
+定陶县 4 n
+梁平县 4 n
+潮安县 4 n
+大箐山县 4 n
+东宁县 4 n
+耿马自治县 4 n
+抚远县 4 n
+大洼县 4 n
+延庆县 4 n
+镇宁自治县 4 n
+务川自治县 4 n
+隆孜县 4 n
+高陵县 4 n
+横山县 4 n
+临桂县 4 n
+马尔康县 4 n
+怀仁县 4 n
+武隆县 4 n
+潼南县 4 n
+关岭自治县 4 n
+印江自治县 4 n
+丰宁县 4 n
+围场自治县 4 n
+宽城县 4 n
+孟村县 4 n
+青龙县 4 n
+满城县 4 n
+肥乡县 4 n
+平泉县 4 n
+江川县 4 n
+沾益县 4 n
+汤旺县 4 n
+大足县 4 n
+神木县 4 n
+崇明县 4 n
+济阳县 4 n
+垦利县 4 n
+溧水县 4 n
+兴仁县 4 n
+邹平县 4 n
+蓟县 4 n
+通州市 4 n
+宣章县 4 n
+吴江市 4 n
+上虞市 4 n
+富阳市 4 n
+可克达拉市 4 n
+邵东市 4 n
+冀州市 4 n
+茂港区 4 n
+石柱土家族县 4 n
+石柱自治县 4 n
+秀山自治县 4 n
+秀山 3 n
+酉阳自治县 4 n
+景宁县 4 n
+景宁自治县 4 n
+五峰自治县 4 n
+长阳自治县 4 n
+伊通县 4 n
+伊通自治县 4 n
+长白自治县 4 n
+积石山自治 4 n
+积石山县 4 n
+杜尔伯特县 4 n
+新站区 4 n
+达茂联合旗 4 n
+峡山区 4 n
+托县 4 n
+南郑县 4 n
+安塞县 4 n
+漷县 4 n
+密云县 4 n
+康定县 4 n
+隆昌县 4 n
+彭山县 4 n
+罗江县 4 n
+中共 5 n
+万全县 4 n
+围场县 4 n
+清苑县 4 n
+抚宁县 4 n
+徐水县 4 n
+崇礼县 4 n
+陵县 4 n
+沾化县 4 n
+杜蒙县 4 n
+漠河县 4 n
+睛隆县 4 n
+遵义县 4 n
+石仟县 4 n
+平坝县 4 n
+双江自治县 4 n
+浙川县 4 n
+沁阳县 4 n
+荔浦县 4 n
+新建县 4 n
+余江县 4 n
+洞头县 4 n
+京山县 4 n
+静海县 4 n
+堆龙德庆县 4 n
+高淳县 4 n
+揭东县 4 n
+綦江县 4 n
+璧山县 4 n
+蓉江新区 4 n
+宝水新区 4 n
+万州江南新区 4 n
+万盛区 4 n
+万盛经济技术开发区 4 n
+沈抚新区 4 n
+东戴河新区 4 n
+金普新区 4 n
+辽东湾新区 4 n
+金港新区 4 n
+萝岗区 4 n
+漳河新区 4 n
+龙华新区 4 n
+大鹏新区 4 n
+光明新区 4 n
+石岐区 4 n
+常州经济开发区 4 n
+戚墅堰区 4 n
+新海城区 4 n
+碧溪新区 4 n
+沧浪区 4 n
+太仓港区 4 n
+金阊区 4 n
+江北新区 4 n
+金洞管理区 4 n
+洪江区 4 n
+洞庭湖区 4 n
+察北管理区 4 n
+渤海新区 4 n
+塞北管理区 4 n
+汉沽管理区 4 n
+信都区 4 n
+滹沱新区 4 n
+柳东新区 4 n
+玉东新区 4 n
+临桂新区 4 n
+福绵管理区 4 n
+淮滨新区 4 n
+毛集区 4 n
+毛集实验区 4 n
+郑蒲港新区 4 n
+池北区 4 n
+康巴什新区 4 n
+乌拉盖管理区 4 n
+柳梧新区 4 n
+杨凌区 4 n
+岷东新区 4 n
+鸡公山管理区 4 n
+郑东新区 4 n
+濮阳新区 4 n
+濮北新区 4 n
+新蒲新区 4 n
+万山特区 4 n
+石岛管理区 4 n
+金林区 4 n
+大沽区 4 n
+钱塘新区 4 n
+道理区 4 n
+广信区 4 n
+洋河新区 4 n
+金海湖新区 4 n
+万盛经开区 4 n
+伊滨区 4 n
+翠亨新区 4 n
+红谷滩区 4 n
+东陵区 4 n
+元坝区 4 n
+滇中新区 4 n
+台商区 4 n
+海门临江新区 4 n
+金明区 4 n
+邢东新区 4 n
+袍江新区 4 n
+东津新区 4 n
+和横琴新区 4 n
+正定新区 4 n
+乌翠区 4 n
+普湾新区 4 n
+北部新区 4 n
+冀南新区 4 n
+任泽区 4 n
+西洞庭管理区 4 n
+羊山新区 4 n

+ 1 - 1
standardata/src/config.json

@@ -9,7 +9,7 @@
   "mgoentsize":5,
   "mgoentdb":"mxs",
   "extractcoll":"extract",
-  "extractdb": "extract_kf",
+  "extractdb": "extract_v3xs",
   "versioncoll": "tagdetailinfo",
   "extractversion": "V3.1.2",
   "standardata":{

+ 398 - 15
standardata/src/res/sv.txt

@@ -2094,7 +2094,8 @@
 色达县 4 n
 雷山县 4 n
 新兴县 4 n
-城区 4 n
+晋城市城区 4 n
+汕尾市城区 4 n
 石阡县 4 n
 厦门市 4 n
 开化县 4 n
@@ -2268,7 +2269,7 @@
 吉利区 4 n
 高密市 4 n
 徐闻县 4 n
-当阳市 4 n
+当阳市 5 n
 明光市 4 n
 云岩区 4 n
 沂源县 4 n
@@ -2876,6 +2877,8 @@
 沧县 4 n
 惠水县 4 n
 莱芜市 4 n
+莱芜区 4 n
+从化市 4 n
 宜黄县 4 n
 金堂县 4 n
 绵阳市 4 n
@@ -3409,7 +3412,6 @@
 景泰 3 n
 仙居 3 n
 海淀 3 n
-市北 3 n
 银海 3 n
 岭东 3 n
 玛多 3 n
@@ -4137,7 +4139,7 @@
 涪城 3 n
 解放 3 n
 连州 3 n
-大厂	 3 n
+大厂 3 n
 大连 3 n
 金湾 3 n
 门头沟 3 n
@@ -4486,7 +4488,6 @@
 鼎湖 3 n
 定兴 3 n
 定南 3 n
-市南 3 n
 科右前旗 3 n
 讷河 3 n
 天峻 3 n
@@ -5441,6 +5442,7 @@
 于田 3 n
 桐城 3 n
 弥渡 3 n
+沧源县 4 n
 沧源 3 n
 日照 3 n
 新和 3 n
@@ -5774,7 +5776,6 @@
 惠州 3 n
 沈阳 3 n
 富蕴 3 n
-市中 3 n
 南岸 3 n
 西藏 3 n
 宾阳 3 n
@@ -5961,7 +5962,6 @@
 甘洛 3 n
 南安 3 n
 屯昌 3 n
-资源 3 n
 渌口 3 n
 平江 3 n
 牧野 3 n
@@ -14133,6 +14133,7 @@
 旺丹乡 4 n
 右三村委会 4 n
 西参村委会 4 n
+杏市村村民委员会 4 n
 王胡村民委员会 4 n
 西迷堤村委会 4 n
 青泥湖办事处 4 n
@@ -110082,6 +110083,7 @@
 生研所社区居委会 4 n
 石狗村委会 4 n
 豪园社区居委会 4 n
+石滩镇故县村委会 4 n
 龙埚村委会 4 n
 麻丘镇居委会(南昌高新开发区) 4 n
 东流村委会 4 n
@@ -122303,7 +122305,7 @@
 河石村民委员会 4 n
 菜利社区村民委员会 4 n
 卞李村委会 4 n
-鱼嘴镇人民政府 4 n
+鱼嘴镇 4 n
 月家村村委会 4 n
 海湾村村委会 4 n
 刘坑头村委会 4 n
@@ -248449,7 +248451,6 @@
 芦家村民委员会 4 n
 独树岗村民委员会 4 n
 上傅家社区 4 n
-经济开发区管理委员会 4 n
 白蒲镇 4 n
 牛园居委会 4 n
 南辛屯村委会 4 n
@@ -293909,7 +293910,6 @@
 青坑岙村村委会 4 n
 小东流村委会 4 n
 车田村 4 n
-庄村 4 n
 达卧村民委员会 4 n
 城头盖村委会 4 n
 李花园村委会 4 n
@@ -328654,6 +328654,7 @@
 孙家社区居委会 4 n
 柴家庙村民委员会 4 n
 李磨村委会 4 n
+上草市村委会 4 n
 北小路村民委员会 4 n
 铁牛里社区居委会 4 n
 贺家巷村委会 4 n
@@ -359229,7 +359230,7 @@
 王杜庄村委会 4 n
 联义村村委会 4 n
 罗卜坎村民委员会 4 n
-高新技术产业开发区管理委员会 4 n
+涿州市高新技术产业开发区管理委员会 4 n
 枫树塝村民委员会 4 n
 先锋镇 4 n
 尕勒艾日克村委会 4 n
@@ -363034,7 +363035,6 @@
 旺疃社区村委会 4 n
 夏垫村委会 4 n
 门二营村委会 4 n
-工业园区管理委员会 4 n
 凌云乡 4 n
 柏木山村委会 4 n
 姚寨村委会 4 n
@@ -392042,7 +392042,6 @@ IT家园社区居委会 4 n
 马堑村民委员会 4 n
 里变村委会 4 n
 大丰居委会 4 n
-县园艺场 4 n
 泉边村 4 n
 史家占村委会 4 n
 枫桥居民委员会 4 n
@@ -394323,7 +394322,6 @@ IT家园社区居委会 4 n
 河东社区小杨庄村民委员会 4 n
 翠竹社区居民委员会 4 n
 西群社区居委会 4 n
-县良种场 4 n
 信号村委会 4 n
 元柏村委会 4 n
 金玉路社区居民委员会 4 n
@@ -409009,4 +409007,389 @@ IT家园社区居委会 4 n
 德安县园艺场 4 n
 长春西汀 4 n
 北京朝阳 5 n
-教育资源 5 n
+教育资源 5 n
+国土资源 5 n
+彬县 4 n
+开县 4 n
+盘县 4 n
+户县 4 n
+郫县 4 n
+海安县 4 n
+章丘市 4 n
+清新县 4 n
+潜山县 4 n
+威宁自治县 4 n
+蓟州县 4 n
+苍山县 4 n
+门源县 4 n
+永年县 4 n
+藁城市 4 n
+金平县 4 n
+燕郊市 4 n
+通州湾示范区 4 n
+九台市 4 n
+文登市 4 n
+江东区 4 n
+庐陵新区 4 n
+襄樊市 4 n
+通安镇 3 n
+昆玉市 4 n
+湄洲岛市 4 n
+托县市 4 n
+大丰市 4 n
+即墨市 4 n
+汩罗 3 n
+汩罗市 4 n
+峨嵋山市 4 n
+米泉市 4 n
+龙港市 4 n
+人力资源 5 n
+自然资源 5 n
+普兰店市 4 n
+佟二堡新市 4 n
+监利市 4 n
+鹿泉市 4 n
+上土市 4 n
+洵口市 4 n
+制锦市 4 n
+长乐市 4 n
+永定县 4 n
+双河市 4 n
+高要市 4 n
+子长市 4 n
+射洪市 4 n
+顺德市 4 n
+东菀市 4 n
+嫩江市 4 n
+丰林县市 4 n
+临安市 4 n
+东中市 4 n
+阳东县 4 n
+海州市 4 n
+胶南市 4 n
+宜州市 4 n
+彭水自治县 4 n
+北屯市 4 n
+屯留县 4 n
+新兴市 4 n
+文家市 4 n
+金坛市 4 n
+库车市 4 n
+星子县 4 n
+南康市 4 n
+兖州市 4 n
+辽县 4 n
+建阳市 4 n
+澄江市 4 n
+广德市 4 n
+无为市 4 n
+龙南市 4 n
+东乡县 4 n
+姜堰市 4 n
+华县市 4 n
+长垣市 4 n 
+达县 4 n
+候马市 4 n
+奉化市 4 n
+察布查尔县 4 n
+道真县 4 n
+洪泽县 4 n
+天祝县 4 n
+橫峰县 4 n
+双江县 4 n
+耿马县 4 n
+宁蒗县 4 n
+玉龙县 4 n
+南涧县 4 n
+巍山县 4 n
+兰坪县 4 n
+贡山县 4 n
+石林县 4 n
+禄劝县 4 n
+墨江县 4 n
+孟连县 4 n
+宁洱县 4 n
+景东县 4 n
+景谷县 4 n
+西盟县 4 n
+镇沅县 4 n
+元江县 4 n
+峨山县 4 n
+新平县 4 n
+屏边县 4 n
+维西县 4 n
+寻甸县 4 n
+江城县 4 n
+漾濞县 4 n
+马龙县 4 n
+澜沧县 4 n
+晋宁县 4 n
+新晃县 4 n
+芷江县 4 n
+通道县 4 n
+靖州县 4 n
+麻阳县 4 n
+江华县 4 n
+城步县 4 n
+宽甸县 4 n
+新宾县 4 n
+清原县 4 n
+喀左县 4 n
+桓仁县 4 n
+阜新县 4 n
+岫岩县 4 n
+阜蒙县 4 n
+武鸣县 4 n
+玉环县 4 n
+长阳县 4 n
+五峰县 4 n
+邹县 4 n
+林县 4 n
+陕县 4 n
+民和回族自治县 4 n
+安县 4 n
+木里县 4 n
+峨边县 4 n
+马边县 4 n
+北川县 4 n
+金秀县 4 n
+三江县 4 n
+融水县 4 n
+恭城县 4 n
+龙胜县 4 n
+大化县 4 n
+巴马县 4 n
+环江县 4 n
+罗城县 4 n
+都安县 4 n
+隆林县 4 n
+富川县 4 n
+辽中县 4 n
+道真自治县 4 n
+张川县 4 n
+肃南县 4 n
+肃北县 4 n
+阿克塞县 4 n
+滦县 4 n
+唐海县 4 n
+连山县 4 n
+连南县 4 n
+乳源县 4 n
+宁乡县 4 n
+香格里拉县 4 n
+泸水县 4 n
+荣昌县 4 n
+铜梁县 4 n
+酉阳县 4 n
+广丰县 4 n
+水富县 4 n
+东乡族县 4 n
+靖西县 4 n
+乐都县 4 n
+宣化县 4 n
+达孜县 4 n
+栾城县 4 n
+双流县 4 n
+塔什库尔干县 4 n
+巴里坤县 4 n
+察布查尔锡伯县 4 n
+和布克赛尔县 4 n
+焉耆县 4 n
+松桃县 4 n
+关岭县 4 n
+紫云县 4 n
+镇宁县 4 n
+务川县 4 n
+玉屏县 4 n
+沿河县 4 n
+印江县 4 n
+三都县 4 n
+定陶县 4 n
+梁平县 4 n
+潮安县 4 n
+大箐山县 4 n
+东宁县 4 n
+耿马自治县 4 n
+抚远县 4 n
+大洼县 4 n
+延庆县 4 n
+镇宁自治县 4 n
+务川自治县 4 n
+隆孜县 4 n
+高陵县 4 n
+横山县 4 n
+临桂县 4 n
+马尔康县 4 n
+怀仁县 4 n
+武隆县 4 n
+潼南县 4 n
+关岭自治县 4 n
+印江自治县 4 n
+丰宁县 4 n
+围场自治县 4 n
+宽城县 4 n
+孟村县 4 n
+青龙县 4 n
+满城县 4 n
+肥乡县 4 n
+平泉县 4 n
+江川县 4 n
+沾益县 4 n
+汤旺县 4 n
+大足县 4 n
+神木县 4 n
+崇明县 4 n
+济阳县 4 n
+垦利县 4 n
+溧水县 4 n
+兴仁县 4 n
+邹平县 4 n
+蓟县 4 n
+通州市 4 n
+宣章县 4 n
+吴江市 4 n
+上虞市 4 n
+富阳市 4 n
+可克达拉市 4 n
+邵东市 4 n
+冀州市 4 n
+茂港区 4 n
+石柱土家族县 4 n
+石柱自治县 4 n
+秀山自治县 4 n
+秀山 3 n
+酉阳自治县 4 n
+景宁县 4 n
+景宁自治县 4 n
+五峰自治县 4 n
+长阳自治县 4 n
+伊通县 4 n
+伊通自治县 4 n
+长白自治县 4 n
+积石山自治 4 n
+积石山县 4 n
+杜尔伯特县 4 n
+新站区 4 n
+达茂联合旗 4 n
+峡山区 4 n
+托县 4 n
+南郑县 4 n
+安塞县 4 n
+漷县 4 n
+密云县 4 n
+康定县 4 n
+隆昌县 4 n
+彭山县 4 n
+罗江县 4 n
+中共 5 n
+万全县 4 n
+围场县 4 n
+清苑县 4 n
+抚宁县 4 n
+徐水县 4 n
+崇礼县 4 n
+陵县 4 n
+沾化县 4 n
+杜蒙县 4 n
+漠河县 4 n
+睛隆县 4 n
+遵义县 4 n
+石仟县 4 n
+平坝县 4 n
+双江自治县 4 n
+浙川县 4 n
+沁阳县 4 n
+荔浦县 4 n
+新建县 4 n
+余江县 4 n
+洞头县 4 n
+京山县 4 n
+静海县 4 n
+堆龙德庆县 4 n
+高淳县 4 n
+揭东县 4 n
+綦江县 4 n
+璧山县 4 n
+蓉江新区 4 n
+宝水新区 4 n
+万州江南新区 4 n
+万盛区 4 n
+万盛经济技术开发区 4 n
+沈抚新区 4 n
+东戴河新区 4 n
+金普新区 4 n
+辽东湾新区 4 n
+金港新区 4 n
+萝岗区 4 n
+漳河新区 4 n
+龙华新区 4 n
+大鹏新区 4 n
+光明新区 4 n
+石岐区 4 n
+常州经济开发区 4 n
+戚墅堰区 4 n
+新海城区 4 n
+碧溪新区 4 n
+沧浪区 4 n
+太仓港区 4 n
+金阊区 4 n
+江北新区 4 n
+金洞管理区 4 n
+洪江区 4 n
+洞庭湖区 4 n
+察北管理区 4 n
+渤海新区 4 n
+塞北管理区 4 n
+汉沽管理区 4 n
+信都区 4 n
+滹沱新区 4 n
+柳东新区 4 n
+玉东新区 4 n
+临桂新区 4 n
+福绵管理区 4 n
+淮滨新区 4 n
+毛集区 4 n
+毛集实验区 4 n
+郑蒲港新区 4 n
+池北区 4 n
+康巴什新区 4 n
+乌拉盖管理区 4 n
+柳梧新区 4 n
+杨凌区 4 n
+岷东新区 4 n
+鸡公山管理区 4 n
+郑东新区 4 n
+濮阳新区 4 n
+濮北新区 4 n
+新蒲新区 4 n
+万山特区 4 n
+石岛管理区 4 n
+金林区 4 n
+大沽区 4 n
+钱塘新区 4 n
+道理区 4 n
+广信区 4 n
+洋河新区 4 n
+金海湖新区 4 n
+万盛经开区 4 n
+伊滨区 4 n
+翠亨新区 4 n
+红谷滩区 4 n
+东陵区 4 n
+元坝区 4 n
+滇中新区 4 n
+台商区 4 n
+海门临江新区 4 n
+金明区 4 n
+邢东新区 4 n
+袍江新区 4 n
+东津新区 4 n
+和横琴新区 4 n
+正定新区 4 n
+乌翠区 4 n
+普湾新区 4 n
+北部新区 4 n
+冀南新区 4 n
+任泽区 4 n
+西洞庭管理区 4 n
+羊山新区 4 n

+ 40 - 28
standardata/src/standaragency.go

@@ -38,7 +38,7 @@ func agencyStandarData(db string, query map[string]interface{}) {
 		agencytel := qu.ObjToString(tmp["agencytel"])
 		if entid == "" { //redis 未存
 			savetoerr := true
-			if agencytel != "" {
+			if agencytel != "" || agencyperson != "" {
 				v := map[string]interface{}{
 					"contact_person": agencyperson,
 					"phone":          agencytel,
@@ -48,6 +48,28 @@ func agencyStandarData(db string, query map[string]interface{}) {
 				ps = append(ps, v)
 				data := comHisMegerNewData(agency, "agency", ps)
 				if data != nil {
+					province, city, district := "", "", ""
+					province = qu.ObjToString(data["province"])
+					if province == "" { //省份为空,buyer优先提取区域信息再company_address
+						province, city, district = GetProvinceCityDistrict([]string{agency}) //先buyer
+						if province == "" {                                                  //再address
+							if address := qu.ObjToString(data["company_address"]); address != "" {
+								province, city, district = GetProvinceCityDistrict([]string{address})
+							}
+						}
+						data["province"] = province
+						data["city"] = city
+						data["district"] = district
+					}
+					//提取固话和手机号
+					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(agencyent, data)
 					redis.PutRedis("agency", agencybd, agency, _id.(primitive.ObjectID).Hex(), -1)
 					savetoerr = false
@@ -56,42 +78,32 @@ func agencyStandarData(db string, query map[string]interface{}) {
 			if savetoerr {
 				t := MongoTo.FindOne(agencyerr, map[string]interface{}{"name": agency})
 				if len(t) < 1 {
+					province, city, district := GetProvinceCityDistrict([]string{agency})
 					MongoTo.Save(agencyerr, map[string]interface{}{
 						"name":       agency,
 						"check":      comMarkdata(agency, "agency"),
 						"updatetime": time.Now().Unix(),
+						"province":   province,
+						"city":       city,
+						"district":   district,
 					})
 				}
 			}
 		} else {
-			if agencytel != "" {
-				is_exist := false //电话是否存在
-				for _, v := range ps {
-					if v["phone"] == agencytel {
-						is_exist = true
-						if agencyperson != "" && v["contact_person"] != agencyperson {
-							v["contact_person"] = agencyperson
-							v["infoid"] = infoid
-							bs, _ := json.Marshal(ps) //替换数据,更新
-							redis.PutRedis("agency", agencybd, agency, bs, -1)
-						}
-						continue
-					}
-				}
-				if !is_exist {
-					v := map[string]interface{}{
-						"contact_person": agencyperson,
-						"phone":          agencytel,
-						"topscopeclass":  comRepTopscopeclass(topscopeclass),
-						"infoid":         infoid,
-					}
-					MongoTo.UpdateById(agencyent, entid,
-						map[string]interface{}{
-							"$set":  map[string]interface{}{"updatetime": time.Now().Unix()},
-							"$push": map[string]interface{}{"contact": v},
-						},
-					)
+			if agencytel != "" && agencyperson != "" {
+				v := map[string]interface{}{
+					"contact_person": agencyperson,
+					"phone":          agencytel,
+					"topscopeclass":  comRepTopscopeclass(topscopeclass),
+					"infoid":         infoid,
 				}
+				data := winMegerIndustry(entid, v)
+				MongoTo.UpdateById(agencyent, entid,
+					map[string]interface{}{
+						"$set":  data,
+						//"$push": map[string]interface{}{"contact": v},
+					},
+				)
 			}
 		}
 		tmp = map[string]interface{}{}

+ 16 - 9
standardata/src/standarbuyer.go

@@ -51,13 +51,12 @@ func buyerStandarData(db string, query map[string]interface{}) {
 				if data != nil {
 					province, city, district := "", "", ""
 					province = qu.ObjToString(data["province"])
-					if province == "" { //省份为空,company_address优先提取区域信息再buyer
-						company_address := qu.ObjToString(data["company_address"])
-						if company_address != "" {
-							province, city, district = GetProvinceCityDistrict([]string{company_address})
-						}
-						if province == "" {
-							province, city, district = GetProvinceCityDistrict([]string{buyer})
+					if province == "" { //省份为空,buyer优先提取区域信息再company_address
+						province, city, district = GetProvinceCityDistrict([]string{buyer}) //先buyer
+						if province == "" {                                                 //再address
+							if address := qu.ObjToString(data["company_address"]); address != "" {
+								province, city, district = GetProvinceCityDistrict([]string{address})
+							}
 						}
 						data["province"] = province
 						data["city"] = city
@@ -93,7 +92,7 @@ func buyerStandarData(db string, query map[string]interface{}) {
 				}
 			}
 		} else {
-			if buyerperson != "" || buyertel != "" {
+			if buyerperson != "" && buyertel != "" {
 				v := map[string]interface{}{
 					"contact_person": buyerperson,
 					"phone":          buyertel,
@@ -105,7 +104,7 @@ func buyerStandarData(db string, query map[string]interface{}) {
 				MongoTo.UpdateById(buyerent, entid,
 					map[string]interface{}{
 						"$set":  data,
-						"$push": map[string]interface{}{"contact": v},
+						//"$push": map[string]interface{}{"contact": v},
 					},
 				)
 			}
@@ -263,6 +262,14 @@ func buyerMegerBuyerclass(id string, ps map[string]interface{}) map[string]inter
 	//contact
 	contact := tmp["contact"].(primitive.A)
 	contact = append(contact, ps)
+	//bid_contact
+	bid_contacts,contacts := bid_contact(contact)
+	if len(bid_contacts) > 0 {
+		data["bid_contact"] = bid_contacts
+	}
+	//sort 200
+	contact = contacts
+	data["contact"] = contact
 	//提取固话和手机号
 	latestFixedPhone, latestMobilePhone, timesFixedPhone, timesMobilePhone := getPhone(contact)
 	data["latestfixedphone"] = latestFixedPhone

+ 61 - 16
standardata/src/standarwinner.go

@@ -46,6 +46,28 @@ func winnerStandarData(db string, query map[string]interface{}) {
 				}
 				data := comHisMegerNewData(winner, "winner", []map[string]interface{}{v})
 				if data != nil {
+					province, city, district := "", "", ""
+					province = qu.ObjToString(data["province"])
+					if province == "" { //省份为空,buyer优先提取区域信息再company_address
+						province, city, district = GetProvinceCityDistrict([]string{winner}) //先buyer
+						if province == "" {                                                 //再address
+							if address := qu.ObjToString(data["company_address"]); address != "" {
+								province, city, district = GetProvinceCityDistrict([]string{address})
+							}
+						}
+						data["province"] = province
+						data["city"] = city
+						data["district"] = district
+					}
+					//提取固话和手机号
+					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(winnerent, data)
 					redis.PutRedis("winner", winnerbd, winner, _id.(primitive.ObjectID).Hex(), -1)
 					savetoerr = false
@@ -54,16 +76,20 @@ func winnerStandarData(db string, query map[string]interface{}) {
 			if savetoerr {
 				t := MongoTo.FindOne(winnererr, map[string]interface{}{"name": winner})
 				if len(t) < 1 {
+					province, city, district := GetProvinceCityDistrict([]string{winner})
 					MongoTo.Save(winnererr, map[string]interface{}{
 						"name":          winner,
 						"topscopeclass": comRepTopscopeclass(topscopeclass),
 						"check":         comMarkdata(winner, "winner"),
 						"updatetime":    time.Now().Unix(),
+						"province":   province,
+						"city":       city,
+						"district":   district,
 					})
 				}
 			}
 		} else { //更新标准库
-			if winnerperson != "" || winnertel != "" {
+			if winnerperson != "" && winnertel != "" {
 				v := map[string]interface{}{
 					"contact_person": winnerperson,
 					"phone":          winnertel,
@@ -74,7 +100,7 @@ func winnerStandarData(db string, query map[string]interface{}) {
 				MongoTo.UpdateById(winnerent, entid,
 					map[string]interface{}{
 						"$set":  data,
-						"$push": map[string]interface{}{"contact": v},
+						//"$push": map[string]interface{}{"contact": v},
 					},
 				)
 			}
@@ -231,29 +257,48 @@ func winStandarHistory(db string) {
 
 //企业数据整合(已有标注信息)
 func winMegerIndustry(id string, ps map[string]interface{}) map[string]interface{} {
-	tmp := MongoEnt.FindById(winnerent, id, bson.M{"industry": 1})
+	tmp := MongoEnt.FindById(winnerent, id, bson.M{"industry": 1, "contact": 1})
 	if len(tmp) < 1 {
 		return nil
 	}
 	data := map[string]interface{}{}
-	industry := tmp["industry"].(primitive.A)
-	tmpindustry := map[string]bool{}
-	for _, v := range industry {
-		tt := qu.ObjToString(v)
-		tmpindustry[tt] = true
-	}
-	if topscopeclass, ok := ps["topscopeclass"].([]interface{}); ok {
-		for _, v := range topscopeclass {
+	industry,ok := tmp["industry"].(primitive.A)
+	if ok{
+		tmpindustry := map[string]bool{}
+		for _, v := range industry {
 			tt := qu.ObjToString(v)
 			tmpindustry[tt] = true
 		}
+		if topscopeclass, ok := ps["topscopeclass"].([]interface{}); ok {
+			for _, v := range topscopeclass {
+				tt := qu.ObjToString(v)
+				tmpindustry[tt] = true
+			}
+		}
+		newindustry := []interface{}{}
+		for k, _ := range tmpindustry {
+			newindustry = append(newindustry, k)
+		}
+		data["industry"] = newindustry
 	}
-	newindustry := []interface{}{}
-	for k, _ := range tmpindustry {
-		newindustry = append(newindustry, k)
-	}
-	data["industry"] = newindustry
 	data["updatetime"] = time.Now().Unix()
+	//contact
+	contact := tmp["contact"].(primitive.A)
+	contact = append(contact, ps)
+	//bid_contact
+	bid_contacts,contacts := bid_contact(contact)
+	if len(bid_contacts) > 0 {
+		data["bid_contact"] = bid_contacts
+	}
+	//sort 200
+	contact = contacts
+	data["contact"] = contact
+	//提取固话和手机号
+	latestFixedPhone, latestMobilePhone, timesFixedPhone, timesMobilePhone := getPhone(contact)
+	data["latestfixedphone"] = latestFixedPhone
+	data["latestmobilephone"] = latestMobilePhone
+	data["fixedphone"] = timesFixedPhone
+	data["mobilephone"] = timesMobilePhone
 	return data
 }
 

+ 73 - 1
standardata/src/util.go

@@ -2,11 +2,15 @@ package main
 
 import (
 	"fmt"
+	"go.mongodb.org/mongo-driver/bson/primitive"
 	"log"
+	"qfw/common/src/qfw/util"
 	qu "qfw/util"
 	"regexp"
+	"sort"
 	"strconv"
 	"strings"
+	"unicode/utf8"
 )
 
 var (
@@ -765,7 +769,7 @@ func NewGetDistrict(area, city, district string, finishD, tmpcity []string) (str
 					district = d
 					return city, district
 				}
-			} else { //多个city
+			} else {                         //多个city
 				for _, tc := range tmpcity { //多个city根据district最高分取
 					if tc == c.Name && len(finishD) == 1 {
 						city = c.Name
@@ -864,3 +868,71 @@ func PCDScoreByDistrictSim(stype, t string, score float64, ps, cs, ds *map[strin
 		}
 	}
 }
+
+//bid_contact
+func bid_contact(tc primitive.A) ([]contactPersonPhone, []interface{}) {
+	contact_person_phone := make(map[string]uint32)
+	contact_person_phone_time := make(map[string]int64)
+	tmps := make([]interface{}, 0)
+	for _, v := range tc {
+		if km, ok := v.(map[string]interface{}); ok {
+			contact_person := util.ObjToString(km["contact_person"])
+			phone := util.ObjToString(km["phone"])
+			if contact_person == "" || phone == "" || utf8.RuneCountInString(phone) < 5 {
+				continue
+			}
+			if contact_person_phone[contact_person+"+_+"+phone] == 0 {
+				tmps = append(tmps, v)
+				contact_person_phone[contact_person+"+_+"+phone]++
+			}
+		}
+	}
+	ttmps := make([]interface{}, 0)
+	ttnum := 0
+	for i := len(tmps) - 1; i >= 0; i-- {
+		ttnum++
+		if ttnum > 200 {
+			break
+		}
+		ttmps = append(ttmps, tmps[i])
+	}
+	//t["contact"] = ttmps
+	contact_person_phone = make(map[string]uint32)
+	for _, v := range ttmps {
+		if km, ok := v.(map[string]interface{}); ok {
+			contact_person := util.ObjToString(km["contact_person"])
+			phone := util.ObjToString(km["phone"])
+			infoid := util.ObjToString(km["infoid"])
+			contact_person_phone[contact_person+"+_+"+phone]++
+			_id, _ := primitive.ObjectIDFromHex(infoid)
+			contact_person_phone_time[contact_person+"+_+"+phone] = _id.Timestamp().Unix()
+		}
+	}
+	contactPersonPhoneSlices := make(contactPersonPhoneSlice, 0)
+	if len(contact_person_phone) > 0 {
+		for k, v := range contact_person_phone {
+			pp := strings.Split(k, "+_+")
+			contactPersonPhoneSlices = append(contactPersonPhoneSlices, contactPersonPhone{Str: k, SNum: v, ContactPerson: pp[0], Phone: pp[1], UTime: contact_person_phone_time[k]})
+		}
+		sort.Sort(contactPersonPhoneSlices)
+		//t["bid_contact"] = contactPersonPhoneSlices
+		if contactPersonPhoneSlices.Len() > 200 {
+			contactPersonPhoneSlices = contactPersonPhoneSlices[:200]
+		}
+	}
+	return contactPersonPhoneSlices, ttmps
+}
+
+type contactPersonPhone struct {
+	Str           string `json:"str" bson:"-"`
+	SNum          uint32 `json:"s_num" bson:"-"`
+	ContactPerson string `json:"contact_person"`
+	Phone         string `json:"phone"`
+	UTime         int64  `json:"u_time"`
+}
+
+type contactPersonPhoneSlice []contactPersonPhone
+
+func (p contactPersonPhoneSlice) Len() int           { return len(p) }
+func (p contactPersonPhoneSlice) Less(i, j int) bool { return p[i].UTime >= p[j].UTime }
+func (p contactPersonPhoneSlice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

+ 3 - 0
udpcreateindex/src/biddingindex.go

@@ -183,6 +183,9 @@ func doIndex(infos []map[string]interface{}, eMap map[string]map[string]interfac
 			}
 		} else {
 			compare = nil
+			if qutil.IntAll(tmp["dataging"]) == 1 { //修改未抽取的bidding数据的dataging
+				update["dataging"] = 0
+			}
 		}
 		//下面可以多线程跑的--->
 		//处理分类

+ 40 - 40
udpcreateindex/src/buyertask.go

@@ -37,7 +37,7 @@ func buyerEsTaskOnce() {
 	//参数
 	buyerent, _ := standard["buyerent"].(map[string]interface{})
 	buyer_ent := qu.ObjToString(buyerent["collect1"])
-	buyer_enterr := qu.ObjToString(buyerent["collect2"])
+	//buyer_enterr := qu.ObjToString(buyerent["collect2"])
 	index, _ := buyerent["index"].(string)
 	itype, _ := buyerent["type"].(string)
 	//mongo
@@ -101,44 +101,44 @@ func buyerEsTaskOnce() {
 		tmp = make(map[string]interface{})
 	}
 
-	log.Println("q:", q, "db:", mgostandard.DbName, "coll:", buyer_enterr)
-	it_2 := sess.DB(mgostandard.DbName).C(buyer_enterr).Find(&q).Sort("_id").Iter()
-	num_2 := 0
-	for tmp := make(map[string]interface{}); it_2.Next(&tmp); num_2++ {
-		if num_2%100 == 0 && num_2 > 0 {
-			log.Println("当前表:", buyer_enterr, "数量:", num_2)
-		}
-		pool <- true
-		wg.Add(1)
-		go func(tmp map[string]interface{}) {
-			defer func() {
-				<-pool
-				wg.Done()
-			}()
-			savetmp := map[string]interface{}{}
-			tmp_id := qu.BsonIdToSId(tmp["_id"])
-			savetmp["_id"] = tmp_id
-			savetmp["name"] = tmp["name"]
-			savetmp["buyer_name"] = tmp["name"]
-			if tmp["buyerclass"] != nil {
-				savetmp["buyerclass"] = tmp["buyerclass"]
-			}
-			for _, f := range fieldArr {
-				if val := qu.ObjToString(tmp[f]); val != "" {
-					savetmp[f] = val
-				}
-			}
-			buyerEsLock.Lock()
-			arrEs = append(arrEs, savetmp)
-			if len(arrEs) >= BulkSize {
-				tmps := arrEs
-				elastic.BulkSave(index, itype, &tmps, true)
-				arrEs = []map[string]interface{}{}
-			}
-			buyerEsLock.Unlock()
-		}(tmp)
-		tmp = make(map[string]interface{})
-	}
+	// log.Println("q:", q, "db:", mgostandard.DbName, "coll:", buyer_enterr)
+	// it_2 := sess.DB(mgostandard.DbName).C(buyer_enterr).Find(&q).Sort("_id").Iter()
+	// num_2 := 0
+	// for tmp := make(map[string]interface{}); it_2.Next(&tmp); num_2++ {
+	// 	if num_2%100 == 0 && num_2 > 0 {
+	// 		log.Println("当前表:", buyer_enterr, "数量:", num_2)
+	// 	}
+	// 	pool <- true
+	// 	wg.Add(1)
+	// 	go func(tmp map[string]interface{}) {
+	// 		defer func() {
+	// 			<-pool
+	// 			wg.Done()
+	// 		}()
+	// 		savetmp := map[string]interface{}{}
+	// 		tmp_id := qu.BsonIdToSId(tmp["_id"])
+	// 		savetmp["_id"] = tmp_id
+	// 		savetmp["name"] = tmp["name"]
+	// 		savetmp["buyer_name"] = tmp["name"]
+	// 		if tmp["buyerclass"] != nil {
+	// 			savetmp["buyerclass"] = tmp["buyerclass"]
+	// 		}
+	// 		for _, f := range fieldArr {
+	// 			if val := qu.ObjToString(tmp[f]); val != "" {
+	// 				savetmp[f] = val
+	// 			}
+	// 		}
+	// 		buyerEsLock.Lock()
+	// 		arrEs = append(arrEs, savetmp)
+	// 		if len(arrEs) >= BulkSize {
+	// 			tmps := arrEs
+	// 			elastic.BulkSave(index, itype, &tmps, true)
+	// 			arrEs = []map[string]interface{}{}
+	// 		}
+	// 		buyerEsLock.Unlock()
+	// 	}(tmp)
+	// 	tmp = make(map[string]interface{})
+	// }
 
 	wg.Wait()
 	buyerEsLock.Lock()
@@ -148,5 +148,5 @@ func buyerEsTaskOnce() {
 		arrEs = []map[string]interface{}{}
 	}
 	buyerEsLock.Unlock()
-	log.Println("buyeres  索引完毕!  总计:", num_1+num_2)
+	log.Println("buyeres  索引完毕!  总计:", num_1)
 }

+ 7 - 7
udpcreateindex/src/config.json

@@ -4,12 +4,12 @@
     "mongodb": {
         "addr": "192.168.3.207:27092",
         "pool": 10,
-        "db": "qfw_data"
+        "db": "mxs"
     },
 	"savedb": {
         "addr": "192.168.3.207:27092",
         "size": 10,
-        "db": "qfw_data"
+        "db": "mxs"
     },
     "jkmail": {
         "to":"zhangjinkun@topnet.net.cn",
@@ -47,8 +47,8 @@
         "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", 
      	"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"},
+        "purchasinglist": "itemname,brandname,model,unitname,number",
+        "purchasinglistmap":{"itemname":"string","brandname": "string","model":"string","unitname":"string","number":"float64"},
         "winnerorder": "sort,sortstr,entname",
         "winnerordermap": {"sort":"int","sortstr":"string","entname":"string"},
         "multiIndex": ""
@@ -56,9 +56,9 @@
     "filelength": 50000,
     "detaillength": 50000,
     "project": {
-        "db": "qfw_data",
+        "db": "mxs",
         "collect": "projectset",
-        "index": "projectset_v6",
+        "index": "projectset_v5",
         "type": "projectset"
     },
     "project2": {
@@ -100,7 +100,7 @@
 		}
     },
     "elastic": {
-        "addr": "http://192.168.3.128:9800",
+        "addr": "http://192.168.3.11:9800",
         "index": "bidding",
         "itype": "bidding",
         "pool": 12

+ 35 - 0
udpcreateindex/src/projectindex.go

@@ -1,7 +1,9 @@
 package main
 
 import (
+	"math"
 	"strconv"
+
 	//"fmt"
 	"log"
 	"qfw/util"
@@ -124,6 +126,10 @@ func projectTask(data []byte, project, mapInfo map[string]interface{}) {
 		//不生索引字段
 		delete(tmp, "package")
 		delete(tmp, "infofield")
+
+		bidopentime := util.Int64All(tmp["bidopentime"]) //开标日期
+		fzb_publishtime := int64(0)                      //记录第一个招标信息的publishtime
+		bidcycle_flag := false                           //判断是否已计算出标书表编制周期
 		list := tmp["list"].([]interface{})
 		for _, m := range list {
 			tmpM := m.(map[string]interface{})
@@ -139,6 +145,35 @@ func projectTask(data []byte, project, mapInfo map[string]interface{}) {
 			if len(listProjectscopeRune) > 1000 {
 				tmpM["projectscope"] = string(listProjectscopeRune[:1000])
 			}
+			//计算bidcycle标书表编制周期字段
+			if !bidcycle_flag && bidopentime > 0 { //bidopentime>0证明list中有bidopentime,无则不用计算bidcycle
+				if toptype := util.ObjToString(tmpM["toptype"]); toptype == "招标" {
+					zb_bidopentime := util.Int64All(tmpM["bidopentime"])
+					zb_publishtime := util.Int64All(tmpM["publishtime"])
+					if zb_publishtime > 0 {
+						if zb_bidopentime > 0 {
+							if tmpTime := zb_bidopentime - zb_publishtime; tmpTime > 0 {
+								f_day := float64(tmpTime) / float64(86400)
+								day := math.Ceil(f_day)
+								tmp["bidcycle"] = int(day)
+								bidcycle_flag = true
+							}
+						}
+						if fzb_publishtime == 0 { //仅赋值第一个招标信息的publishtime
+							fzb_publishtime = zb_publishtime
+						}
+					}
+				}
+			}
+		}
+		//计算bidcycle标书表编制周期字段
+		//list中招标信息中未能计算出bidcycle,用第一个招标信息的fzb_publishtime和外围bidopentime计算
+		if !bidcycle_flag && bidopentime > 0 && fzb_publishtime > 0 {
+			if tmpTime := bidopentime - fzb_publishtime; tmpTime > 0 {
+				f_day := float64(tmpTime) / float64(86400)
+				day := math.Ceil(f_day)
+				tmp["bidcycle"] = int(day)
+			}
 		}
 		//projectscope截断
 		projectscopeRune := []rune(util.ObjToString(tmp["projectscope"]))