Browse Source

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

fengweiqiang 4 years ago
parent
commit
097a5b8d4c

+ 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
 

+ 4 - 4
projectinfo/src/config.json

@@ -8,12 +8,12 @@
 		"db" : "mixdata",
 		"size": 15,
 		"buyer_ent": "buyer_enterprise",
-		"tagcoll": "project_biaoqian_new",
+		"tagcoll": "project_biaoqian",
 		"savecoll": "project_forecast_test"
 	},
 	"udpport": ":1182",
 	"forecast": {
-		"规划可研": ["立项环评", "勘察设计", "建设准备", "前期准备"],
+		"规划可研": ["立项环评", "勘察设计", "建设准备", "前期施工"],
 		"立项环评": ["勘察设计", "建设准备", "前期施工"],
 		"勘察设计": ["建设准备", "前期施工"],
 		"建设准备": ["前期施工"],
@@ -26,8 +26,8 @@
 	"projecttype": ["报建", "核准类", "核准", "审批类", "审批"],
 	"rate": "60%",
 	"elastic": {
-        "addr": "http://127.0.0.1:9800",
-        "index": "bidding",
+        "addr": "http://192.168.3.11:9800",
+        "index": "bidding_v5",
         "itype": "bidding",
         "pool": 12
     }

+ 99 - 6
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)
@@ -213,14 +265,12 @@ 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"]
 					t["p_rate"] = Rate
 					t["time"] = ""
+					projects := GetProjects(qu.ObjToString(t["purchasing"]), buyer)
+					if len(projects) > 0 {
+						t["p_projects"] = projects
+					}
 					maps = append(maps, t)
 				}
 				//qu.Debug("ForecastFlag---", ForecastFlag)
@@ -239,6 +289,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"
 )

+ 40 - 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,26 +300,29 @@ 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 {
 						for _, f := range tmpArr {
+							qu.Debug("field---", f)
 							if text := m[f]; text != nil {
 								if textstr := fmt.Sprint(text); textstr != "" {
 									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 +335,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 +577,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 +617,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 +641,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 +654,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 +675,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{}{

+ 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
+			}
 		}
 		//下面可以多线程跑的--->
 		//处理分类

+ 5 - 5
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",
@@ -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"]))