jiaojiao7 4 жил өмнө
parent
commit
7fe9ae7caf

+ 6 - 1
src/history/historytask.go

@@ -79,7 +79,12 @@ func (this *HistoryData) HistoryTask(history_id string) {
 			log.Println("g根据项目id去重。。。")
 			start := time.Now().Unix()
 			log.Println("加载projectId---开始")
-			InitProjectId(appId)
+			if dataTable == 0 {
+				InitProjectId(appId)
+			}
+			if dataTable == 1 {
+				InitUsermailProjectId(appId)
+			}
 			end := time.Now().Unix()
 			log.Println("加载projectId---结束,耗时", end-start, "秒")
 		} else {

+ 36 - 9
src/history/util_history.go

@@ -68,7 +68,7 @@ func GetNotkeyAndKeyAddWord(list []map[string]interface{}, fieldMap map[string]i
 					tmp_nkw := nkw_addArr[0]
 					if tmp_nkw != "" {
 						cr := &CommonReg{}
-						cr.CsVal = tmp_nkw                   //记录原值
+						cr.CsVal = tmp_nkw //记录原值
 						if LetterCase.MatchString(tmp_nkw) { //判断附加词中是否有英文
 							tmp_nkw = strings.ToUpper(tmp_nkw) //附加词中有英文全部转为大写
 							cr.IsLetter = true                 //含字母
@@ -120,7 +120,7 @@ func GetNotkeyAndKeyAddWord(list []map[string]interface{}, fieldMap map[string]i
 				tmp_aw := aw_addArr[0]
 				if tmp_aw != "" {
 					cr := &CommonReg{}
-					cr.CsVal = tmp_aw                   //记录原值
+					cr.CsVal = tmp_aw //记录原值
 					if LetterCase.MatchString(tmp_aw) { //判断附加词中是否有英文
 						tmp_aw = strings.ToUpper(tmp_aw) //附加词中有英文全部转为大写
 						cr.IsLetter = true               //含字母
@@ -493,12 +493,13 @@ func AssembelSave(tmp map[string]interface{}, IsSearchHosp, IsSearchEnps bool, h
 	}
 	isOk := true
 	//if ProjectAppidMap[appid] {
-	if isFilter == 1 {
-		//log.Println("补充信息中根据项目id去重。。。。")
-		projectId := GetProjectId(id)
-		if projectId != "" {
-			projectIds := strings.Split(projectId, ",")
-			tmp["projectId"] = projectId
+	//log.Println("补充信息中根据项目id去重。。。。")
+	//所有的数据都匹配项目id,是否去重根据isFilter
+	projectId := GetProjectId(id)
+	if projectId != "" {
+		projectIds := strings.Split(projectId, ",")
+		tmp["projectId"] = projectId
+		if isFilter == 1 {
 			for _, v := range projectIds {
 				if _, ok := projectIdMap.Load(v); ok {
 					isOk = false
@@ -512,6 +513,7 @@ func AssembelSave(tmp map[string]interface{}, IsSearchHosp, IsSearchEnps bool, h
 			log.Println("项目id去重,项目id:", projectId, isOk)
 		}
 	}
+
 	//河南移动/盈峰科技
 	if NeedProjectidAppidMap[appid] {
 		projectId := GetProjectId(id)
@@ -1279,7 +1281,7 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id string, isfile, isHen
 					row.AddCell().SetValue(v["projectname"]) //项目名称
 					row.AddCell().SetValue(v["buyer"])       //采购单位
 					row.AddCell().SetValue(v["buyer_type"])  //采购单位类别---私有标签tagname
-					if v["bidamount"] != nil {               //中标金额
+					if v["bidamount"] != nil { //中标金额
 						row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
 					} else {
 						row.AddCell()
@@ -1405,6 +1407,31 @@ func InitProjectId(appid string) {
 	}
 }
 
+func InitUsermailProjectId(appid string) {
+	session := MgoCus.GetMgoConn()
+	count := 0
+	defer func() {
+		MgoCus.DestoryMongoConn(session)
+		log.Printf("本次共取到%d个projectId\n", count)
+	}()
+	customer := Sysconfig["customer"].(map[string]interface{})
+	query := map[string]interface{}{"appid": appid}
+	field := map[string]interface{}{"projectId": 1}
+	iter := session.DB(qu.ObjToString(customer["dbname"])).C(SaveUserMail).Find(query).Select(field).Sort("_id").Iter()
+	thisData := map[string]interface{}{}
+	for {
+		if !iter.Next(&thisData) {
+			break
+		}
+		projectId := qu.ObjToString(thisData["projectId"])
+		if projectId != "" {
+			projectIdMap.Store(projectId, true)
+			count++
+		}
+		thisData = map[string]interface{}{}
+	}
+}
+
 func checkBidId(appid, id string, dataTable int) bool {
 	isOk := true
 	if dataTable == 1 {