zhengkun 3 жил өмнө
parent
commit
7bc280bbe9

+ 2 - 2
src/config.json

@@ -1,8 +1,8 @@
 {
     "port": "7000",
-    "mgodb": "192.168.3.207:27092",
+    "mgodb": "127.0.0.1:27017",
     "dbsize": 10,
-    "dbname": "datavalidation",
+    "dbname": "zhengkun",
     "alltocoll": "marked",
     "bidding":{
         "addr":"192.168.3.207:27092",

+ 33 - 23
src/front/quality.go

@@ -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,
 		},
 	}
 }

+ 2 - 0
src/main.go

@@ -34,6 +34,8 @@ func init() {
 }
 
 func main() {
+	//go front.QuaFieldScore([]string{"buyer"},"zktest_data") //临时测试-质量
+
 	//Mgo.UpdateById("test11", "61a9975a180a78e6edf8285d", map[string]interface{}{
 	//	"$inc": map[string]interface{}{
 	//		"count": -555,

+ 6 - 6
src/util/config.go

@@ -128,13 +128,13 @@ func InitConfig() {
 
 //质量相关初始化配置
 func initQuaConfig()  {
-	qyxyconf := Quaconfig["qyxy_mgodb"].(map[string]interface{})
+	qyxyconf := Quaconfig["qy_mongodb"].(map[string]interface{})
 	Mgo_QY = &mongodb.MongodbSim{
-		MongodbAddr: qyxyconf["addr"].(string),
-		DbName:      qyxyconf["db"].(string),
-		Size:        qu.IntAllDef(qyxyconf["pool"], 5),
-		UserName:    qyxyconf["username"].(string),
-		Password:    qyxyconf["password"].(string),
+		MongodbAddr: qyxyconf["qy_addrName"].(string),
+		DbName:      qyxyconf["qy_dbName"].(string),
+		Size:        qu.IntAllDef(qyxyconf["qy_pool"], 5),
+		UserName:    qyxyconf["qy_username"].(string),
+		Password:    qyxyconf["qy_password"].(string),
 	}
 	Mgo_QY.InitPool()
 

+ 6 - 7
src/web/qua_res/qua_config.json

@@ -1,12 +1,11 @@
 {
   "qyxy_es":"http://127.0.0.1:12003",
-  "qyxy_mgodb": {
-    "addr": "127.0.0.1:27017",
-    "db": "mixdata",
-    "coll": "qyxy_std",
-    "pool": 10,
-    "username": "zhengkun",
-    "password": "zk@123123"
+  "qy_mongodb": {
+    "qy_addrName": "127.0.0.1:27017",
+    "qy_dbName": "mixdata",
+    "qy_username": "",
+    "qy_password": "",
+    "qy_pool": 10
   },
   "ext_from": {
     "title": 98,