fengweiqiang 6 år sedan
förälder
incheckning
4af64729d6
1 ändrade filer med 26 tillägg och 0 borttagningar
  1. 26 0
      src/jy/extract/score.go

+ 26 - 0
src/jy/extract/score.go

@@ -105,6 +105,9 @@ func ScoreFields(j *ju.Job, ftag map[string][]*Tag) map[string][]*ju.ExtField {
 	qu.Catch()
 	result := j.Result
 	for field, tmps := range result {
+		if field == "projectcode" {
+			tmps = projectWeightClear(tmps)
+		}
 		locktag.Lock()
 		taglength := len(ftag[field])
 		locktag.Unlock()
@@ -307,3 +310,26 @@ func ScoreFields(j *ju.Job, ftag map[string][]*Tag) map[string][]*ju.ExtField {
 	}
 	return result
 }
+
+//项目编号权重清理
+func projectWeightClear(tmps []*ju.ExtField) []*ju.ExtField {
+	newList := make([]*ju.ExtField, 0)
+	if len(tmps)<1{
+		return newList
+	}
+	tmpWeight := -999 //记录最大权重
+	tmpIndex := -999  //记录最大权重下标
+	for i, v := range tmps {
+		if v.Weight == 0 {
+			newList = append(newList, v)
+			continue
+		} else if v.Weight > tmpWeight {
+			tmpWeight = v.Weight
+			tmpIndex = i
+		}
+	}
+	if tmpIndex != -999 {
+		newList = append(newList, tmps[tmpIndex])
+	}
+	return newList
+}