소스 검색

12.27--------项目合并修改

jianghan7 5 년 전
부모
커밋
ecb4d91b46
4개의 변경된 파일111개의 추가작업 그리고 96개의 파일을 삭제
  1. 1 1
      fullproject/src_v1/config.json
  2. 50 46
      fullproject/src_v1/project.go
  3. 10 10
      fullproject/src_v1/task.go
  4. 50 39
      fullproject/src_v1/update.go

+ 1 - 1
fullproject/src_v1/config.json

@@ -4,7 +4,7 @@
 	"mongodbServers": "192.168.3.207:27082",
     "mongodbPoolSize": 10,
     "mongodbName": "extract_kf",
-	"hints":"_id_1_publishtime_1",
+	"hints":"publishtime_1",
     "extractColl": "jh_info",
     "projectColl": "jh_project",
     "backupFlag": true,

+ 50 - 46
fullproject/src_v1/project.go

@@ -129,11 +129,11 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
 
 			//代理机构完全不相同,直接新建项目
 			if CheckContain(compareProject.Agency, info.Agency) == 3 {
-				break
+				continue
 			}
 			//地区(省、市、区)不同,直接新建项目
 			if ComparePlace(compareProject, info) {
-				break
+				continue
 			}
 
 			info.PNBH = 0
@@ -175,45 +175,54 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
 				})
 			}
 
-			bFindProject = true
-			findPid = resN[0].Id.Hex()
-			for k2, bv := range []int{bpn, bpc, bptc, bpb} {
-				if bv > -1 {
-					pids[bv].Arr = append(pids[bv].Arr, findPid)
-					if k2 == 0 {
-						if resN[0].ProjectName == "" {
-							resN[0].ProjectName = info.ProjectName
-						} else {
-							if resN[0].MPN == nil {
-								resN[0].MPN = []string{info.ProjectName}
+			ex := 0
+			resArr := []*ProjectInfo{}
+			for _, res := range resN{
+				choose, e := CompareStatus(resN[0], info)
+				if !choose {
+					ex = e
+					resArr = append(resArr, res)
+				}
+			}
+			if len(resArr) > 0 {
+				bFindProject = true
+				findPid = resArr[0].Id.Hex()
+				for k2, bv := range []int{bpn, bpc, bptc, bpb} {
+					if bv > -1 {
+						pids[bv].Arr = append(pids[bv].Arr, findPid)
+						if k2 == 0 {
+							if resArr[0].ProjectName == "" {
+								resArr[0].ProjectName = info.ProjectName
 							} else {
-								resN[0].MPN = append(resN[0].MPN, info.ProjectName)
+								if resArr[0].MPN == nil {
+									resArr[0].MPN = []string{info.ProjectName}
+								} else {
+									resArr[0].MPN = append(resArr[0].MPN, info.ProjectName)
+								}
 							}
-						}
 
-					} else if k2 < 3 {
-						if resN[0].ProjectCode == "" {
-							resN[0].ProjectCode = qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)
-						} else {
-							if resN[0].MPC == nil {
-								resN[0].MPC = []string{qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)}
+						} else if k2 < 3 {
+							if resArr[0].ProjectCode == "" {
+								resArr[0].ProjectCode = qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)
 							} else {
-								resN[0].MPC = append(resN[0].MPC, qu.If(k2 == 1, info.ProjectCode, info.PTC).(string))
+								if resArr[0].MPC == nil {
+									resArr[0].MPC = []string{qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)}
+								} else {
+									resArr[0].MPC = append(resArr[0].MPC, qu.If(k2 == 1, info.ProjectCode, info.PTC).(string))
+								}
 							}
-						}
 
-					} else {
-						if resN[0].Buyer == "" {
-							resN[0].Buyer = info.Buyer
+						} else {
+							if resArr[0].Buyer == "" {
+								resArr[0].Buyer = info.Buyer
+							}
 						}
 					}
 				}
-			}
-			choose, ex := CompareStatus(resN[0], info)
-			if !choose {
-				p.UpdateProject(tmp, info, resN[0], kv+1, resN[0].comStr, ex)
+				p.UpdateProject(tmp, info, resArr[0], kv+1, resArr[0].comStr, ex)
 			}else {
 				bFindProject = false
+				findPid = ""
 			}
 			break
 		}
@@ -496,15 +505,9 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 		bt = "招标"
 	}
 	set["bidtype"] = bt
-	bs, _ := tmp["bidstatus"].(string)
-	if bidstatus[bs] != "" {
-		set["bidstatus"] = bs
-	}
-	if set["bidstatus"] == nil && thisinfo.TopType == "结果" {
-		bs = thisinfo.SubType
-		set["bidstatus"] = thisinfo.SubType
-	}
-	p1, pkg := p.NewCachePinfo(pId, thisinfo, bs, bt)
+	set["bidstatus"] = thisinfo.SubType
+
+	p1, pkg := p.NewCachePinfo(pId, thisinfo, bt)
 	if len(thisinfo.Subscopeclass) > 0 {
 		s_subscopeclass := strings.Join(thisinfo.Subscopeclass, ",")
 		set["s_subscopeclass"] = s_subscopeclass
@@ -575,7 +578,7 @@ func (p *ProjectTask) PushListInfo(tmp map[string]interface{}, infoid string) bs
 }
 
 //生成存放在内存中的对象
-func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info, bidstatus, bidtype string) (ProjectInfo, map[string]interface{}) {
+func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info, bidtype string) (ProjectInfo, map[string]interface{}) {
 	pkg := map[string]interface{}{}
 	if thisinfo.HasPackage {
 		pkg, _, _ = PackageFormat(thisinfo, nil)
@@ -602,7 +605,7 @@ func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info, bidst
 		Budget:        thisinfo.Budget,
 		Package: 	   pkg,
 		Bidamount:     thisinfo.Bidamount,
-		Bidstatus:	   bidstatus,
+		Bidstatus:	   thisinfo.SubType,
 		Bidtype:	   bidtype,
 	}
 	if thisinfo.LenPTC > 5 {
@@ -825,13 +828,14 @@ func CompareStatus(project *ProjectInfo, info *Info) (bool, int) {
 		if project.Bidstatus == "拟建" || project.Bidstatus == "预告" || project.Bidstatus == "招标" {
 			return false, 0
 		}else if project.Bidstatus == info.SubType {
-			return true, 0
-		}else if project.Bidstatus == "成交" {
-			if info.SubType == "中标" {
-				return true, 0
-			}else {
+			key := titleGetPc.FindStringSubmatch(info.ProjectName)
+			if key != nil {
 				return false, 0
+			}else {
+				return true, 0
 			}
+		}else if project.Bidstatus == "成交" && info.SubType == "中标" {
+			return true, 0
 		}else if project.Bidstatus == "流标" || project.Bidstatus == "废标" {
 			return false, 2
 		}else if project.Bidstatus == "合同" || project.Bidstatus == "其它" {

+ 10 - 10
fullproject/src_v1/task.go

@@ -159,8 +159,6 @@ func (p *ProjectTask) clearMem() {
 			clearNum := 0
 			for k, v := range p.AllIdsMap {
 				if p.currentTime-v.P.LastTime > p.validTime {
-					log.Println(p.currentTime)
-					log.Println(k)
 					clearNum++
 					//删除id的map
 					delete(p.AllIdsMap, k)
@@ -412,11 +410,10 @@ func (p *ProjectTask) enter(db, coll string, q map[string]interface{}) {
 
 	}()
 	ms := sess.DB(db).C(coll).Find(q).Sort("publishtime")
-	//if Sysconfig["hints"] != nil {
-	//	ms.Hint(Sysconfig["hints"])
-	//}
+	if Sysconfig["hints"] != nil {
+		ms.Hint(Sysconfig["hints"])
+	}
 	query := ms.Iter()
-	//
 	var lastid interface{}
 L:
 	for {
@@ -430,7 +427,7 @@ L:
 			tmp := make(map[string]interface{})
 			if query.Next(&tmp) {
 				lastid = tmp["_id"]
-				if count%2000 == 0 {
+				if count%10000 == 0 {
 					log.Println("current", count, lastid)
 				}
 				infoPool <- tmp
@@ -461,6 +458,8 @@ var (
 	StrOrNum = regexp.MustCompile("^[0-9_-]{1,4}$|^[a-zA-Z_-]{1,4}$")
 	//纯数字或纯字母
 	StrOrNum2 = regexp.MustCompile("^[0-9_-]+$|^[a-zA-Z_-]+$")
+	//含分包词,招标未识别分包  合并到一个项目
+	KeyPackage = regexp.MustCompile("[0-9a-zA-Z一二三四五六七八九十ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ]+.{0,2}(包|段)|(包|段)[0-9a-zA-Z一二三四五六七八九十ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ]+.{0,2}")
 )
 
 func (p *ProjectTask) CommonMerge(tmp map[string]interface{}, info *Info) {
@@ -511,6 +510,7 @@ func ParseInfo(tmp map[string]interface{}) (info *Info) {
 
 	if thisinfo.Publishtime == 0 {
 		thisinfo.Publishtime = thisinfo.Comeintime
+		tmp["publishtime"] = thisinfo.Comeintime
 	}
 
 	//从标题中查找项目编号
@@ -680,9 +680,9 @@ func modifyEle(tmpPro map[string]interface{}, tmp map[string]interface{}) (map[s
 
 //补全位置信息
 func (p *ProjectTask) fillInPlace(tmp map[string]interface{})  {
-	area := tmp["area"].(string)
-	city := tmp["city"].(string)
-	district := tmp["district"].(string)
+	area := util.ObjToString(tmp["area"])
+	city := util.ObjToString(tmp["city"])
+	district := util.ObjToString(tmp["district"])
 	if area != "" && city != "" && district != "" {
 		return
 	}

+ 50 - 39
fullproject/src_v1/update.go

@@ -119,12 +119,12 @@ func (p *ProjectTask) updateMerge(index int, info *Info, pInfoId string, tmp map
 
 			//代理机构完全不相同,直接新建项目
 			if CheckContain(compareProject.Agency, info.Agency) == 3 {
-				break
+				continue
 			}
 
 			//地区(省、市、区)不同,直接新建项目
 			if ComparePlace(compareProject, info) {
-				break
+				continue
 			}
 
 			info.PNBH = 0
@@ -163,55 +163,66 @@ func (p *ProjectTask) updateMerge(index int, info *Info, pInfoId string, tmp map
 				})
 			}
 
-			bFindProject = true
-			findPid = resN[0].Id.Hex()
-			for k2, bv := range []int{bpn, bpc, bptc, bpb} {
-				if bv > -1 {
-					pids[bv].Arr = append(pids[bv].Arr, findPid)
-					if k2 == 0 {
-						if resN[0].ProjectName == "" {
-							resN[0].ProjectName = info.ProjectName
-						} else {
-							if resN[0].MPN == nil {
-								resN[0].MPN = []string{info.ProjectName}
+			ex := 0
+			resArr := []*ProjectInfo{}
+			for _, res := range resN{
+				choose, e := CompareStatus(resN[0], info)
+				if !choose {
+					ex = e
+					resArr = append(resArr, res)
+				}
+			}
+			if len(resArr) > 0 {
+				bFindProject = true
+				findPid = resArr[0].Id.Hex()
+				for k2, bv := range []int{bpn, bpc, bptc, bpb} {
+					if bv > -1 {
+						pids[bv].Arr = append(pids[bv].Arr, findPid)
+						if k2 == 0 {
+							if resArr[0].ProjectName == "" {
+								resArr[0].ProjectName = info.ProjectName
 							} else {
-								resN[0].MPN = append(resN[0].MPN, info.ProjectName)
+								if resArr[0].MPN == nil {
+									resArr[0].MPN = []string{info.ProjectName}
+								} else {
+									resArr[0].MPN = append(resArr[0].MPN, info.ProjectName)
+								}
 							}
-						}
 
-					} else if k2 < 3 {
-						if resN[0].ProjectCode == "" {
-							resN[0].ProjectCode = qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)
-						} else {
-							if resN[0].MPC == nil {
-								resN[0].MPC = []string{qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)}
+						} else if k2 < 3 {
+							if resArr[0].ProjectCode == "" {
+								resArr[0].ProjectCode = qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)
 							} else {
-								resN[0].MPC = append(resN[0].MPC, qu.If(k2 == 1, info.ProjectCode, info.PTC).(string))
+								if resArr[0].MPC == nil {
+									resArr[0].MPC = []string{qu.If(k2 == 1, info.ProjectCode, info.PTC).(string)}
+								} else {
+									resArr[0].MPC = append(resArr[0].MPC, qu.If(k2 == 1, info.ProjectCode, info.PTC).(string))
+								}
 							}
-						}
 
-					} else {
-						if resN[0].Buyer == "" {
-							resN[0].Buyer = info.Buyer
+						} else {
+							if resArr[0].Buyer == "" {
+								resArr[0].Buyer = info.Buyer
+							}
 						}
 					}
 				}
-			}
-			if index != 0 {
-				//招标条目信息在原项目中是第非0条时,返回对比结果
-				k = kv+1
-				comStr = resN[0].comStr
-				mergePro = resN[0]
-			}else {
-				mergePro = resN[0]
-				choose, ex := CompareStatus(resN[0], info)
-				if !choose {
+				if index != 0 {
+					//招标条目信息在原项目中是第非0条时,返回对比结果
+					k = kv+1
+					comStr = resArr[0].comStr
+					mergePro = resArr[0]
+					bFindProject = false
+					findPid = ""
+				}else {
+					mergePro = resArr[0]
 					//如果有合并,合并之前备份(快照)
 					backupPro(tmpPro)
-					p.UpdateProject(tmp, info, resN[0], kv+1, resN[0].comStr, ex)
-				}else {
-					bFindProject = false
+					p.UpdateProject(tmp, info, resArr[0], kv+1, resArr[0].comStr, ex)
 				}
+			}else {
+				bFindProject = false
+				findPid = ""
 			}
 			break
 		}