|
@@ -1,43 +1,40 @@
|
|
|
package front
|
|
|
|
|
|
import (
|
|
|
- "go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
"log"
|
|
|
qu "qfw/util"
|
|
|
"qua"
|
|
|
+ "time"
|
|
|
u "util"
|
|
|
)
|
|
|
-func (f *Front) QuaData() {
|
|
|
+
|
|
|
+func (f *Front) QuaScoreData() {
|
|
|
defer qu.Catch()
|
|
|
- //xxx := f.GetString("xxx")
|
|
|
- QuaFieldScore()
|
|
|
+ coll_name := f.GetString("coll_name")
|
|
|
+ field_tag := f.GetSlice("field_tag")
|
|
|
+ rep := QuaFieldScore(field_tag,coll_name)
|
|
|
f.ServeJson(map[string]interface{}{
|
|
|
- "rep": true,
|
|
|
+ "rep": rep,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
-func QuaFieldScore() {
|
|
|
- //此表是否打分过--是否过滤
|
|
|
-
|
|
|
+func QuaFieldScore(field_tag []string,coll_name string) bool {
|
|
|
+ if coll_name=="" || len(field_tag)<=0 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
//查询标注表-临时测试-指定表
|
|
|
+ start := int(time.Now().Unix())
|
|
|
q := map[string]interface{}{}
|
|
|
sess := u.Mgo.GetMgoConn()
|
|
|
defer u.Mgo.DestoryMongoConn(sess)
|
|
|
- coll_name := "zktest_data" //临时测试表
|
|
|
it := sess.DB(u.Mgo.DbName).C(coll_name).Find(&q).Iter()
|
|
|
updateFieldScore,total := [][]map[string]interface{}{},0
|
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
|
if total%1000 == 0 {
|
|
|
log.Println("当前数量:", total)
|
|
|
}
|
|
|
- tmpid := tmp["_id"].(primitive.ObjectID).Hex()
|
|
|
- data,_ := u.MgoE.FindById("zktest_score",tmpid,nil)
|
|
|
- field_source := map[string]interface{}{}
|
|
|
- if len(*data) > 0 && *data != nil {
|
|
|
- field_source = *qu.ObjToMap((*data)["field_source"])
|
|
|
- }
|
|
|
- update_dict := calculateFieldScore(tmp,field_source)
|
|
|
+ update_dict := calculateFieldScore(tmp,field_tag)
|
|
|
updateFieldScore = append(updateFieldScore, []map[string]interface{}{
|
|
|
map[string]interface{}{"_id": tmp["_id"]},
|
|
|
update_dict,
|
|
@@ -51,10 +48,13 @@ func QuaFieldScore() {
|
|
|
if len(updateFieldScore) >0 {
|
|
|
u.Mgo.UpSertBulk(coll_name, updateFieldScore...)
|
|
|
}
|
|
|
- log.Println("field score is over - 总计数量",total)
|
|
|
+ log.Printf("处理耗时:%d秒~数量:%d个\n", int(time.Now().Unix())-start,total)
|
|
|
+ return true
|
|
|
}
|
|
|
|
|
|
-func calculateFieldScore(tmp map[string]interface{},source map[string]interface{}) (map[string]interface{}) {
|
|
|
+//计算字段分
|
|
|
+func calculateFieldScore(tmp map[string]interface{},field_tag []string) (map[string]interface{}) {
|
|
|
+ source := *qu.ObjToMap(tmp["field_source"])
|
|
|
f_s := qua.FieldSourceScore(source) //打初始分
|
|
|
update_dict := make(map[string]interface{},0)
|
|
|
buyer_s := qua.BuyerFieldScore(tmp,f_s["buyer"])
|
|
@@ -76,15 +76,25 @@ func calculateFieldScore(tmp map[string]interface{},source map[string]interface{
|
|
|
}
|
|
|
|
|
|
|
|
|
- //综合比对是否正确
|
|
|
- b_istagging := false
|
|
|
-
|
|
|
-
|
|
|
+ //综合比对是否正确 field_tag
|
|
|
+ isUse ,v_taginfo:= true,make(map[string]interface{},0)
|
|
|
+ for _,key :=range field_tag{
|
|
|
+ v_taginfo[key] = int64(1)
|
|
|
+ value := *qu.ObjToMap(update_dict[key])
|
|
|
+ score := qu.Int64All(value["score"])
|
|
|
+ if score < 98 {
|
|
|
+ isUse = false //需要标注
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ b_istagging := !isUse
|
|
|
|
|
|
return map[string]interface{}{
|
|
|
"$set": map[string]interface{}{
|
|
|
- "field_score": update_dict,
|
|
|
+ "v_fieldscore": update_dict,
|
|
|
+ "b_cleartag" :false,
|
|
|
"b_istagging":b_istagging,
|
|
|
+ "v_taginfo" :v_taginfo,
|
|
|
},
|
|
|
}
|
|
|
}
|