Bladeren bron

1.8 预算、中标金额修改,添加字段

jianghan7 5 jaren geleden
bovenliggende
commit
0e86542fcc
4 gewijzigde bestanden met toevoegingen van 184 en 110 verwijderingen
  1. 14 0
      fullproject/src_v1/init.go
  2. 119 86
      fullproject/src_v1/project.go
  3. 16 14
      fullproject/src_v1/task.go
  4. 35 10
      fullproject/src_v1/update.go

+ 14 - 0
fullproject/src_v1/init.go

@@ -229,6 +229,8 @@ type Info struct {
 	SubType     string                 `json:"subtype"`
 	ProjectName string                 `json:"projectname"`
 	ProjectCode string                 `json:"projectcode"`
+	ProjectScope string				  	`json:"projectscope"`
+	ContractCode string				   `json:"contractcode"`
 	Buyer       string                 `json:"buyer"`
 	Buyerperson string                 `json:"buyerperson"`
 	Buyertel    string                 `json:"buyertel"`
@@ -296,8 +298,20 @@ type ProjectInfo struct {
 	score         int
 	comStr        string
 	resVal, pjVal int
+	InfoFiled	map[string]InfoFiled
 }
 
+//存储部分招标信息字段,业务逻辑处理需要
+type InfoFiled struct {
+	budget			float64
+	bidamount		float64
+	contractCode	string
+	projectName		string
+	projectCode		string
+	bidstatus		string
+}
+
+//站点信息
 type Site struct {
 	Id			string				`json:"_id"`
 	Site		string				`json:"site"`			//站点名字

+ 119 - 86
fullproject/src_v1/project.go

@@ -407,6 +407,7 @@ func compareResult(resVal, pjVal, score2 int, comStr, compareBuyer, compareCity,
 	return eqV
 }
 
+//项目中的字段
 var FIELDS = []string{
 	"area",
 	"city",
@@ -418,18 +419,23 @@ var FIELDS = []string{
 	"buyerperson",
 	"buyertel",
 	"winner",
-	//"budget",
-	//"bidamount",
-	//"bidstatus",
 	"agency",
 	"projectscope",
-
 	"topscopeclass",
 	"subscopeclass",
 	"winnerorder",
 	"package",
 }
 
+var bidtype = map[string]string{
+	"招标": "招标",
+	"邀标":	"邀标",
+	"询价":	"询价",
+	"单一":	"单一",
+	"竞价":	"竞价",
+	"竞谈":	"竞谈",
+}
+
 var bidstatus = map[string]string{
 	"预告": "预告",
 	"中标": "中标",
@@ -473,9 +479,14 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 	set["ids"] = []string{thisinfo.Id}
 	if thisinfo.TopType == "招标" {
 		set["zbtime"] = tmp["publishtime"]
-	} else if thisinfo.TopType == "结果" {
+	} else if thisinfo.TopType == "结果" || thisinfo.SubType == "合同" {
 		set["jgtime"] = tmp["publishtime"]
 	}
+	//废标、流标   处理时间
+	if thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
+		set["zbtime"] = int64(0)
+		set["bidopentime"] = int64(0)
+	}
 	//异常标记
 	if thisinfo.TopType != "招标" && thisinfo.TopType != "拟建" && thisinfo.TopType != "预告" {
 		set["exception"] = 1
@@ -487,19 +498,22 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 		}
 	}
 
-	//招标类型
 	bt := qu.ObjToString(tmp["toptype"])
-	set["bidtype"] = bt
-	bs, _ := tmp["subtype"].(string)
+	bs := qu.ObjToString(tmp["subtype"])
 	p.mapBidLock.Lock()
-	if bidstatus[bs] != "" {
-		set["bidstatus"] = thisinfo.SubType
-	} else if tmp["infoformat"] == 2 {
-		set["bidstatus"] = "拟建"
-	} else if tmp["subytpe"] == "招标" {
-		set["bidstatus"] = thisinfo.TopType
-	} else {
-		set["bidstatus"] = "其它"
+	if bt == "招标" {
+		set["projectscope"] = qu.ObjToString(tmp["projectscope"])
+		set["bidtype"] = bidtype[bs]
+		set["bidstatus"] = bs
+	}else {
+		set["bidtype"] = bt
+		if bidstatus[bs] != "" {
+			set["bidstatus"] = thisinfo.SubType
+		} else if tmp["infoformat"] == 2 {
+			set["bidstatus"] = "拟建"
+		} else {
+			set["bidstatus"] = "其它"
+		}
 	}
 	p.mapBidLock.Unlock()
 
@@ -518,7 +532,20 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 	} else {
 		set["multipackage"] = 0
 	}
+
+	p1.InfoFiled = make(map[string]InfoFiled)
+	p1.InfoFiled[thisinfo.Id] =
+		InfoFiled{
+			budget: thisinfo.Budget,
+			bidamount: thisinfo.Bidamount,
+			projectName: thisinfo.ProjectName,
+			contractCode: thisinfo.ContractCode,
+			projectCode: thisinfo.ProjectCode,
+			bidstatus: bs,
+	}
+
 	push := p.PushListInfo(tmp, thisinfo.Id)
+	push["s_winner"] = strings.Join(thisinfo.Winners, ",")
 	set["list"] = []bson.M{
 		push,
 	}
@@ -534,9 +561,11 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 	return pId.Hex(), &p1
 }
 
+//招标信息字段
 var INFOFIELDS = []string{
 	"projectname",
 	"projectcode",
+	"projectscope",
 	"title",
 	"href",
 	"publishtime",
@@ -557,7 +586,8 @@ var INFOFIELDS = []string{
 	"buyertel",
 	"area",
 	"city",
-	"list",
+	"spidercode",
+	"site",
 }
 
 //项目中list的信息
@@ -603,6 +633,7 @@ func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info, bidty
 		Bidamount:     thisinfo.Bidamount,
 		Bidstatus:     thisinfo.SubType,
 		Bidtype:       bidtype,
+		Winners: 	   thisinfo.Winners,
 	}
 	if thisinfo.LenPTC > 5 {
 		p1.MPC = append(p1.MPC, thisinfo.PTC)
@@ -632,20 +663,31 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 	//2--lasttime
 	pInfo.LastTime = thisinfo.Publishtime
 	set["lasttime"] = thisinfo.Publishtime
-	set["bidtype"] = tmp["toptype"]
-	bs, _ := tmp["subtype"].(string)
+	if thisinfo.TopType == "招标" {
+		set["zbtime"] = tmp["publishtime"]
+	} else if thisinfo.TopType == "结果" || thisinfo.SubType == "合同" {
+		set["jgtime"] = tmp["publishtime"]
+	}
+
+	bt := qu.ObjToString(tmp["toptype"])
+	bs := qu.ObjToString(tmp["subtype"])
 	p.mapBidLock.Lock()
-	if bidstatus[bs] != "" {
-		set["bidstatus"] = thisinfo.SubType
-		if bidstatus[bs] != "预告" && bidstatus[bs] != "合同" {
-			set["jgtime"] = tmp["publishtime"]
+	if bt == "招标" {
+		//招标状态,更新projectscope
+		if tmp["projectscope"] != nil {
+			set["projectscope"] = qu.ObjToString(tmp["projectscope"])
+		}
+		set["bidtype"] = bidtype[bs]
+		set["bidstatus"] = bs
+	}else {
+		set["bidtype"] = bt
+		if bidstatus[bs] != "" {
+			set["bidstatus"] = thisinfo.SubType
+		} else if tmp["infoformat"] == 2 {
+			set["bidstatus"] = "拟建"
+		} else {
+			set["bidstatus"] = "其它"
 		}
-	} else if tmp["infoformat"] == 2 {
-		set["bidstatus"] = "拟建"
-	} else if tmp["subytpe"] == "招标" {
-		set["bidstatus"] = thisinfo.TopType
-	} else {
-		set["bidstatus"] = "其它"
 	}
 	p.mapBidLock.Unlock()
 
@@ -759,10 +801,8 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 				sort.Strings(pInfo.Winners)
 			}
 		}
-		//set["winners"] = pInfo.Winners
 		set["s_winner"] = strings.Join(pInfo.Winners, ",")
 	}
-
 	if thisinfo.HasPackage { //多包处理
 		set["multipackage"] = 1
 		pkg := PackageFormat(thisinfo, pInfo)
@@ -775,18 +815,17 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 	CountAmount(pInfo, thisinfo)
 	set["budget"] = pInfo.Budget
 	set["bidamount"] = pInfo.Bidamount
-	//
 
 	set["mpn"] = pInfo.MPN
 	set["mpc"] = pInfo.MPC
 	set["pici"] = p.pici
-
 	update := map[string]interface{}{}
 	if len(set) > 0 {
 		update["$set"] = set
 	}
 	//保留原数据吧
 	push := p.PushListInfo(tmp, thisinfo.Id)
+	push["s_winner"] = strings.Join(thisinfo.Winners, ",")
 	push["compareStr"] = comStr
 	push["resVal"] = pInfo.resVal
 	push["pjVal"] = pInfo.pjVal
@@ -979,8 +1018,20 @@ func CountAmount(project *ProjectInfo, info *Info) {
 			}
 		}else {
 			//招标不是单包
-			if project.Budget < info.Budget {
-				project.Budget = info.Budget
+			flag := false
+			if project.InfoFiled != nil && len(project.InfoFiled) > 0 {
+				for _, res := range project.InfoFiled {
+					if res.projectName == info.ProjectName {
+						if res.budget < info.Budget {
+							project.Budget = project.Budget - res.budget + info.Budget
+						}
+						flag = true
+						break
+					}
+				}
+				if !flag {
+					project.Budget = project.Budget + info.Budget
+				}
 			}
 		}
 	}
@@ -1023,59 +1074,41 @@ func CountAmount(project *ProjectInfo, info *Info) {
 				}
 			}else {
 				//招标不是单包
-				if project.Bidamount < info.Bidamount {
-					project.Bidamount = info.Bidamount
+				flag := false
+				if project.InfoFiled != nil && len(project.InfoFiled) > 0 {
+					for _, res := range project.InfoFiled {
+						if res.bidstatus == "合同" && res.contractCode != "" && info.SubType == "合同" && info.ContractCode != "" {
+							if res.contractCode == info.ContractCode {
+								if res.bidamount < info.Bidamount {
+									project.Bidamount = project.Bidamount - res.bidamount + info.Bidamount
+								}
+								flag = true
+								break
+							}
+						}else {
+							if res.projectName == info.ProjectName {
+								if res.bidamount < info.Bidamount {
+									project.Bidamount = project.Bidamount - res.bidamount + info.Bidamount
+								}
+								flag = true
+								break
+							}
+						}
+
+					}
+					if !flag {
+						project.Bidamount = project.Bidamount + info.Bidamount
+					}
 				}
 			}
 		}
 	}
-
-
-	//if info.Budget > 0 {
-	//	//项目中第一条招标信息是否是包/段项目
-	//	key := KeyPackage.FindStringSubmatch(project.ProjectName)
-	//	if len(key) > 0 {
-	//		//判断项目中是否已经计算过该包/段的预算
-	//		if !isCount(project, info.ProjectName) {
-	//			project.Budget = project.Budget + info.Budget
-	//		}
-	//	}else {
-	//		if project.Budget < info.Budget {
-	//			project.Budget = info.Budget
-	//		}
-	//	}
-	//}
-	////中标、成交、合同     处理中标金额(bidamount)
-	//if info.SubType == "中标" || info.SubType == "成交" || info.SubType == "合同" {
-	//	if info.Bidamount > 0 {
-	//		key := KeyPackage.FindStringSubmatch(project.ProjectName)
-	//		if len(key) > 0 {
-	//			if !isCount(project, info.ProjectName) {
-	//				project.Bidamount = project.Bidamount + info.Bidamount
-	//			}
-	//		}else {
-	//			if project.Bidamount > info.Bidamount {
-	//				project.Bidamount = info.Bidamount
-	//			}
-	//		}
-	//	}
-	//}
-	//
-	////保存信息到IdStatusInfo
-	//if project.IdStatusInfo != nil {
-	//	project.IdStatusInfo[info.Id] = map[string]interface{}{
-	//		"projectname": info.ProjectName,
-	//		"bidstatus": info.SubType,
-	//		"budget": info.Budget,
-	//		"bidamount": info.Bidamount,
-	//	}
-	//}else {
-	//	project.IdStatusInfo = map[string]map[string]interface{}{}
-	//	project.IdStatusInfo[info.Id] = map[string]interface{}{
-	//		"projectname": info.ProjectName,
-	//		"bidstatus": info.SubType,
-	//		"budget": info.Budget,
-	//		"bidamount": info.Bidamount,
-	//	}
-	//}
+	project.InfoFiled[info.Id] = InfoFiled{
+		budget:       info.Budget,
+		bidamount:    info.Bidamount,
+		contractCode: info.ContractCode,
+		projectName:  info.ProjectName,
+		projectCode:  info.ProjectCode,
+		bidstatus: 	  info.SubType,
+	}
 }

+ 16 - 14
fullproject/src_v1/task.go

@@ -96,7 +96,7 @@ func NewPT() *ProjectTask {
 
 var P_QL *ProjectTask
 var sp = make(chan bool, 5)
-
+var updatalock sync.RWMutex
 //初始化全量合并对象
 func init() {
 	P_QL = NewPT()
@@ -114,26 +114,32 @@ func (p *ProjectTask) updateAllQueue() {
 			arru[indexu] = v
 			indexu++
 			if indexu == p.saveSize {
+				updatalock.Lock()
+				tmparr := arru
+				arru = make([][]map[string]interface{}, p.saveSize)
+				updatalock.Unlock()
 				sp <- true
-				go func(arru [][]map[string]interface{}) {
+				go func(tmparr [][]map[string]interface{}) {
 					defer func() {
 						<-sp
 					}()
-					MongoTool.UpSertBulk(p.coll, arru...)
-				}(arru)
-				arru = make([][]map[string]interface{}, p.saveSize)
+					MongoTool.UpSertBulk(p.coll, tmparr...)
+				}(tmparr)
 				indexu = 0
 			}
 		case <-time.After(1000 * time.Millisecond):
 			if indexu > 0 {
+				updatalock.Lock()
+				tmparr := arru
+				arru = make([][]map[string]interface{}, p.saveSize)
+				updatalock.Unlock()
 				sp <- true
-				go func(arru [][]map[string]interface{}) {
+				go func(tmparr [][]map[string]interface{}) {
 					defer func() {
 						<-sp
 					}()
-					MongoTool.UpSertBulk(p.coll, arru...)
-				}(arru[:indexu])
-				arru = make([][]map[string]interface{}, p.saveSize)
+					MongoTool.UpSertBulk(p.coll, tmparr...)
+				}(tmparr[:indexu])
 				indexu = 0
 			}
 		}
@@ -509,6 +515,7 @@ func ParseInfo(tmp map[string]interface{}) (info *Info) {
 	if thisinfo == nil {
 		return nil
 	}
+
 	if len(thisinfo.Topscopeclass) == 0 {
 		thisinfo.Topscopeclass = []string{}
 	}
@@ -519,11 +526,6 @@ func ParseInfo(tmp map[string]interface{}) (info *Info) {
 		thisinfo.SubType = util.ObjToString(tmp["bidstatus"])
 	}
 
-	if thisinfo.Publishtime == 0 {
-		thisinfo.Publishtime = thisinfo.Comeintime
-		tmp["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]) {

+ 35 - 10
fullproject/src_v1/update.go

@@ -269,20 +269,45 @@ func mergeProject(p *ProjectTask, pInfo *ProjectInfo, thisinfo *Info, set map[st
 	//2--lasttime
 	pInfo.LastTime = thisinfo.Publishtime
 	set["lasttime"] = thisinfo.Publishtime
-	set["bidtype"] = thisinfo.SubType
-	if thisinfo.SubType != "" {
-		set["bidstatus"] = thisinfo.SubType
-		if thisinfo.SubType != "预告" {
-			set["jgtime"] = thisinfo.Publishtime
+	if thisinfo.TopType == "招标" {
+		set["zbtime"] = thisinfo.Publishtime
+	} else if thisinfo.TopType == "结果" || thisinfo.SubType == "合同" {
+		set["jgtime"] = thisinfo.Publishtime
+	}
+	//废标、流标   处理时间
+	if thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
+		pInfo.FirstTime = thisinfo.Publishtime
+		pInfo.Bidopentime = int64(0)
+		pInfo.LastTime = thisinfo.Publishtime
+
+		set["firsttime"] = thisinfo.Publishtime
+		set["zbtime"] = int64(0)
+		set["publishtime"] = thisinfo.Publishtime
+		set["bidopentime"] = int64(0)
+	}
+
+	bt := thisinfo.TopType
+	bs := thisinfo.SubType
+	p.mapBidLock.Lock()
+	if bt == "招标" {
+		//招标状态,更新projectscope
+		if thisinfo.ProjectScope != "" {
+			set["projectscope"] = thisinfo.ProjectScope
 		}
-	}else if thisinfo.Infoformat == 2 {
-		set["bidstatus"] = "拟建"
-	}else if thisinfo.SubType == "招标" {
-		set["bidstatus"] = thisinfo.TopType
+		set["bidtype"] = bidtype[bs]
 	}else {
-		set["bidstatus"] = thisinfo.SubType
+		set["bidtype"] = bt
+		if bidstatus[bs] != "" {
+			set["bidstatus"] = thisinfo.SubType
+		} else if thisinfo.Infoformat == 2 {
+			set["bidstatus"] = "拟建"
+		} else {
+			set["bidstatus"] = "其它"
+		}
 	}
 
+	p.mapBidLock.Unlock()
+
 	//3\4\5--省、市、县
 	if thisinfo.Area != "全国" {
 		//xt := true