Просмотр исходного кода

12.25------------项目合并-bug修改

jianghan7 5 лет назад
Родитель
Сommit
53b68dd02b
4 измененных файлов с 21 добавлено и 17 удалено
  1. 1 0
      fullproject/src_v1/init.go
  2. 0 2
      fullproject/src_v1/main.go
  3. 18 14
      fullproject/src_v1/task.go
  4. 2 1
      fullproject/src_v1/update.go

+ 1 - 0
fullproject/src_v1/init.go

@@ -226,6 +226,7 @@ type Info struct {
 	Id          string                 `json:"_id"`
 	Href        string                 `json:"href"` //源地址
 	Publishtime int64                  `json:"publishtime"`
+	Comeintime  int64				   `json:"comeintime"`
 	Title       string                 `json:"title"`
 	TopType     string                 `json:"toptype"`
 	SubType     string                 `json:"subtype"`

+ 0 - 2
fullproject/src_v1/main.go

@@ -120,8 +120,6 @@ func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 					P_QL.pici = time.Now().Unix()
 					P_QL.taskUpdateInfo(mapInfo)
 				}()
-			case "updateProject":		//项目字段变更
-
 			case "history": //历史数据合并,暂时不写
 				go func() {
 					defer func() {

+ 18 - 14
fullproject/src_v1/task.go

@@ -159,6 +159,8 @@ 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)
@@ -213,7 +215,7 @@ func (p *ProjectTask) clearMem() {
 			p.mapHrefLock.Unlock()
 			p.AllIdsMapLock.Unlock()
 			p.findLock.Unlock()
-			log.Println("清除完成:", clearNum, len(p.AllIdsMap), len(p.mapPn), len(p.mapPc), len(p.mapPb))
+			log.Println("清除完成:", clearNum, len(p.AllIdsMap), len(p.mapPn), len(p.mapPc), len(p.mapPb), len(p.mapHref))
 		} else {
 			p.clearContimes++
 		}
@@ -288,7 +290,7 @@ func (p *ProjectTask) taskZl(udpInfo map[string]interface{}) {
 	if q == nil {
 		q = map[string]interface{}{
 			"_id": map[string]interface{}{
-				"$gte":  StringTOBsonId(gtid),
+				"$gt":  StringTOBsonId(gtid),
 				"$lte": StringTOBsonId(lteid),
 			},
 		}
@@ -390,12 +392,14 @@ func (p *ProjectTask) enter(db, coll string, q map[string]interface{}) {
 					}()
 					if util.IntAll(tmp["repeat"]) == 0 {
 						p.fillInPlace(tmp)
+						info := ParseInfo(tmp)
+						p.currentTime = info.Publishtime
 						if p.currentType == "updateInfo" {
 							//招标信息更改合并
-							p.updateJudge(tmp)
+							p.updateJudge(tmp, info)
 						}else {
 							//普通合并
-							p.CommonMerge(tmp)
+							p.CommonMerge(tmp, info)
 						}
 					}else {
 						//信息错误,进行更新
@@ -408,9 +412,9 @@ 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{}
@@ -459,8 +463,7 @@ var (
 	StrOrNum2 = regexp.MustCompile("^[0-9_-]+$|^[a-zA-Z_-]+$")
 )
 
-func (p *ProjectTask) CommonMerge(tmp map[string]interface{}) {
-	info := ParseInfo(tmp)
+func (p *ProjectTask) CommonMerge(tmp map[string]interface{}, info *Info) {
 	if info != nil && !((info.pnbval == 1 && info.Buyer != "") || info.pnbval == 0) {
 		if jsonData, ok := tmp["jsondata"].(map[string]interface{}); ok {
 			if jsonData != nil && jsonData["projecthref"] != nil {
@@ -483,12 +486,10 @@ func (p *ProjectTask) CommonMerge(tmp map[string]interface{}) {
 				}
 			}else {
 				//项目合并
-				p.currentTime = info.Publishtime
 				p.startProjectMerge(info, tmp)
 			}
 		}else {
 			//项目合并
-			p.currentTime = info.Publishtime
 			p.startProjectMerge(info, tmp)
 		}
 	}
@@ -508,6 +509,10 @@ func ParseInfo(tmp map[string]interface{}) (info *Info) {
 		thisinfo.Subscopeclass = []string{}
 	}
 
+	if thisinfo.Publishtime == 0 {
+		thisinfo.Publishtime = thisinfo.Comeintime
+	}
+
 	//从标题中查找项目编号
 	res := titleGetPc.FindStringSubmatch(thisinfo.Title)
 	if len(res) > 1 && len(res[1]) > 6 && thisinfo.ProjectCode != res[1] && !numCheckPc.MatchString(res[1]) && !_zimureg1.MatchString(res[1]) {
@@ -584,10 +589,9 @@ func ParseInfo(tmp map[string]interface{}) (info *Info) {
 	return thisinfo
 }
 
-func (p *ProjectTask) updateJudge(tmp map[string]interface{})  {
+func (p *ProjectTask) updateJudge(tmp map[string]interface{}, info *Info)  {
 	index := -1
 	pInfoId := ""
-	info := ParseInfo(tmp)
 	p.AllIdsMapLock.Lock()
 	F:
 	for k, ID := range p.AllIdsMap {
@@ -614,7 +618,7 @@ func (p *ProjectTask) updateJudge(tmp map[string]interface{})  {
 
 		//projecthref字段
 		jsonData := tmp["jsondata"].(map[string]interface{})
-		if jsonData != nil && jsonData["projecthref"] != "" {
+		if jsonData != nil && jsonData["projecthref"] != nil {
 			proHref := jsonData["projecthref"].(string)
 			tmp["projecthref"] = proHref
 			p.mapHrefLock.Lock()

+ 2 - 1
fullproject/src_v1/update.go

@@ -42,7 +42,8 @@ func (p *ProjectTask) mergeAndModify(pInfoId string, index int, info *Info, tmp
 				continue
 			}
 			tmp1 := MongoTool.FindById(ExtractColl, infoId)
-			p.CommonMerge(tmp1)
+			info1 := ParseInfo(tmp1)
+			p.CommonMerge(tmp1, info1)
 		}
 	}else {
 		log.Println("第n条合并", "------n------")