|
@@ -1,13 +1,22 @@
|
|
package front
|
|
package front
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "go.mongodb.org/mongo-driver/bson/primitive"
|
|
"log"
|
|
"log"
|
|
qu "qfw/util"
|
|
qu "qfw/util"
|
|
"qua"
|
|
"qua"
|
|
"time"
|
|
"time"
|
|
u "util"
|
|
u "util"
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+func (f *Front) QuaScoreData() {
|
|
|
|
+ defer qu.Catch()
|
|
|
|
+ coll_name := f.GetString("coll_name")
|
|
|
|
+ field_tag := f.GetSlice("field_tag")
|
|
|
|
+ rep := QuaFieldScore(field_tag,coll_name)
|
|
|
|
+ f.ServeJson(map[string]interface{}{
|
|
|
|
+ "rep": rep,
|
|
|
|
+ })
|
|
|
|
+}
|
|
func QuaFieldScore(field_tag []string, coll_name string) bool {
|
|
func QuaFieldScore(field_tag []string, coll_name string) bool {
|
|
if coll_name == "" || len(field_tag) <= 0 {
|
|
if coll_name == "" || len(field_tag) <= 0 {
|
|
return false
|
|
return false
|
|
@@ -17,8 +26,8 @@ func QuaFieldScore(field_tag []string, coll_name string) bool {
|
|
q := map[string]interface{}{}
|
|
q := map[string]interface{}{}
|
|
sess := u.Mgo.GetMgoConn()
|
|
sess := u.Mgo.GetMgoConn()
|
|
defer u.Mgo.DestoryMongoConn(sess)
|
|
defer u.Mgo.DestoryMongoConn(sess)
|
|
- it := sess.DB(u.Mgo.DbName).C(coll_name).Find(&q).Iter()
|
|
|
|
- updateFieldScore, total := [][]map[string]interface{}{}, 0
|
|
|
|
|
|
+ it := sess.DB(u.Mgo.DbName).C(coll_name).Find(&q).Sort("_id").Iter()
|
|
|
|
+ updateFieldScore,total := [][]map[string]interface{}{},0
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
if total%1000 == 0 {
|
|
if total%1000 == 0 {
|
|
log.Println("当前数量:", total)
|
|
log.Println("当前数量:", total)
|
|
@@ -68,24 +77,123 @@ func calculateFieldScore(tmp map[string]interface{}, field_tag []string) map[str
|
|
update_dict["bidamount"] = bidamount_s
|
|
update_dict["bidamount"] = bidamount_s
|
|
}
|
|
}
|
|
|
|
|
|
- //综合比对是否正确 field_tag
|
|
|
|
- isUse, v_taginfo := true, make(map[string]interface{}, 0)
|
|
|
|
|
|
+ //综合比对是否正确 field_tag - 指定字段
|
|
|
|
+ isUse ,v_taginfo:= true,make(map[string]interface{},0)
|
|
|
|
+ b_isfield_tag := make(map[string]interface{},0)
|
|
for _, key := range field_tag {
|
|
for _, key := range field_tag {
|
|
v_taginfo[key] = int64(1)
|
|
v_taginfo[key] = int64(1)
|
|
value := *qu.ObjToMap(update_dict[key])
|
|
value := *qu.ObjToMap(update_dict[key])
|
|
score := qu.Int64All(value["score"])
|
|
score := qu.Int64All(value["score"])
|
|
- if score < 98 {
|
|
|
|
|
|
+ if score < 99 {
|
|
isUse = false //需要标注
|
|
isUse = false //需要标注
|
|
- break
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for k,v :=range update_dict{
|
|
|
|
+ data := *qu.ObjToMap(v)
|
|
|
|
+ score := qu.Int64All(data["score"])
|
|
|
|
+ if score < 99 {
|
|
|
|
+ b_isfield_tag[k] = true
|
|
|
|
+ }else {
|
|
|
|
+ b_isfield_tag[k] = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
b_istagging := !isUse
|
|
b_istagging := !isUse
|
|
|
|
|
|
|
|
+ //计算标的物-有效状态
|
|
|
|
+ b_isprchasing := calculatePrchasinglist(tmp)
|
|
|
|
+
|
|
return map[string]interface{}{
|
|
return map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"v_fieldscore": update_dict,
|
|
"v_fieldscore": update_dict,
|
|
- "b_istagging": b_istagging,
|
|
|
|
- "v_taginfo": v_taginfo,
|
|
|
|
|
|
+ "v_taginfo" :v_taginfo,
|
|
|
|
+ "b_cleartag" :false,
|
|
|
|
+ "b_isfield_tag":b_isfield_tag,
|
|
|
|
+ "b_istagging":b_istagging,
|
|
|
|
+ "b_isprchasing":b_isprchasing,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//标的物-计算
|
|
|
|
+func calculatePrchasinglist(tmp map[string]interface{}) bool {
|
|
|
|
+ b_ispurchasing := true //默认需要标注
|
|
|
|
+ if purchasinglist, ok := tmp["purchasinglist"].([]interface{}); ok {
|
|
|
|
+ if len(purchasinglist)<=0 {
|
|
|
|
+ return b_ispurchasing
|
|
|
|
+ }
|
|
|
|
+ isListUserArr := []bool{}
|
|
|
|
+ for _,data := range purchasinglist{
|
|
|
|
+ isUse := isUsePurchasing(*qu.ObjToMap(data))
|
|
|
|
+ isListUserArr = append(isListUserArr,isUse)
|
|
|
|
+ }
|
|
|
|
+ b_ispurchasing = !isUseAllPurchasing(isListUserArr)
|
|
|
|
+ return b_ispurchasing
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if purchasinglistA, okA := tmp["purchasinglist"].(primitive.A); okA {
|
|
|
|
+ if len(purchasinglistA)<=0 {
|
|
|
|
+ return b_ispurchasing
|
|
|
|
+ }
|
|
|
|
+ isListUserArr := []bool{}
|
|
|
|
+ for _,data := range purchasinglistA{
|
|
|
|
+ isUse := isUsePurchasing(*qu.ObjToMap(data))
|
|
|
|
+ isListUserArr = append(isListUserArr,isUse)
|
|
|
|
+ }
|
|
|
|
+ b_ispurchasing = !isUseAllPurchasing(isListUserArr)
|
|
|
|
+ }
|
|
|
|
+ return b_ispurchasing
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//判断各个标的物是否可用 默认不可用
|
|
|
|
+func isUsePurchasing(data map[string]interface{}) bool{
|
|
|
|
+ isUse := false
|
|
|
|
+ num := 1
|
|
|
|
+ total_score := qu.Float64All(data["score"])
|
|
|
|
+ if total_score <= float64(0) {
|
|
|
|
+ return isUse
|
|
|
|
+ }
|
|
|
|
+ ner_data := *qu.ObjToMap(data["ner_data"])
|
|
|
|
+ NerGoods := *qu.ObjToMap(ner_data["NerGoods"])
|
|
|
|
+ for _,v := range NerGoods{
|
|
|
|
+ num++
|
|
|
|
+ total_score+=qu.Float64All(v)
|
|
|
|
+ }
|
|
|
|
+ //计算总平均分输
|
|
|
|
+ if total_score/float64(num) > float64(0.3) {
|
|
|
|
+ isUse = true
|
|
|
|
+ }
|
|
|
|
+ return isUse
|
|
|
|
+}
|
|
|
|
+//是否整体可用 - 默认不可用
|
|
|
|
+func isUseAllPurchasing(isListUserArr []bool) bool{
|
|
|
|
+ isUse := false
|
|
|
|
+ total_num := len(isListUserArr)
|
|
|
|
+ ok_num :=0
|
|
|
|
+ for _,v := range isListUserArr {
|
|
|
|
+ if v {
|
|
|
|
+ ok_num++
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ok_num==0 {
|
|
|
|
+ return isUse
|
|
|
|
+ }
|
|
|
|
+ correct := float64(ok_num)/float64(total_num)
|
|
|
|
+ if total_num<=2 {
|
|
|
|
+ if correct>=float64(1) {
|
|
|
|
+ isUse = true
|
|
|
|
+ }
|
|
|
|
+ } else if total_num>2 && total_num<=6 {
|
|
|
|
+ if correct>=float64(0.6) {
|
|
|
|
+ isUse = true
|
|
|
|
+ }
|
|
|
|
+ }else if total_num>7 {
|
|
|
|
+ if correct>=float64(0.5) {
|
|
|
|
+ isUse = true
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return isUse
|
|
|
|
+}
|