Browse Source

修改存量遍历打印,抽取新增分数等前后端修改

apple 5 years ago
parent
commit
f82ddb15ed

+ 12 - 0
src/jy/admin/rule.go

@@ -467,6 +467,12 @@ func RuleLogicCoreSave(c *gin.Context) {
 		data["l_createtime"] = time.Now().Unix()
 		data["s_username"] = sessions.Default(c).Get("username")
 		data["delete"] = false
+		score := qu.Float64All(data["s_default_score"])
+		if score<=0{
+			data["s_default_score"] = 0.0
+		}else {
+			data["s_default_score"] = score
+		}
 		s_type := data["s_type"]
 		code := ""
 		if s_type == "0" { //抽取逻辑正则
@@ -478,6 +484,12 @@ func RuleLogicCoreSave(c *gin.Context) {
 		b = Mgo.Save("rule_logicore", data) != ""
 	} else {
 		data["l_lasttime"] = time.Now().Unix()
+		score := qu.Float64All(data["s_default_score"])
+		if score<=0{
+			data["s_default_score"] = 0.0
+		}else {
+			data["s_default_score"] = score
+		}
 		b = Mgo.Update("rule_logicore", `{"_id":"`+_id+`"}`, map[string]interface{}{
 			"$set": data,
 		}, true, false)

+ 29 - 6
src/jy/extract/extract.go

@@ -809,7 +809,13 @@ func ExtRuleCore(doc map[string]interface{}, e *ExtractTask, vc *RuleCore, j *ju
 				j.Result[k] = [](*ju.ExtField){}
 			}
 			for _, tmp := range v {
-				field := &ju.ExtField{Weight: qu.IntAll(tmp["weight"]), ExtFrom: qu.ObjToString(tmp["extfrom"]), Field: k, Code: qu.ObjToString(tmp["code"]), Type: qu.ObjToString(tmp["type"]), MatchType: qu.ObjToString(tmp["matchtype"]), RuleText: qu.ObjToString(tmp["ruletext"]), SourceValue: tmp["sourcevalue"], Value: tmp["value"]}
+				field := &ju.ExtField{Weight: qu.IntAll(tmp["weight"]),
+					ExtFrom: qu.ObjToString(tmp["extfrom"]), Field: k,
+					Code: qu.ObjToString(tmp["code"]), Type: qu.ObjToString(tmp["type"]),
+					MatchType: qu.ObjToString(tmp["matchtype"]),
+					RuleText: qu.ObjToString(tmp["ruletext"]),
+					SourceValue: tmp["sourcevalue"],
+					Value: tmp["value"]}
 				if k == "bidamount" && field.ExtFrom == "第一候选人" {
 					field.Score = 1
 				}
@@ -1223,10 +1229,12 @@ func extractFromKv(field, fieldname string, blocks []*ju.Block, vc *RuleCore, kv
 //正则提取结果
 func extRegCoreToResult(extfrom, text string, tag *map[string]string, j *ju.Job, vre *RegLuaInfo, isSite bool) map[string][]map[string]interface{} {
 	defer qu.Catch()
-	var score int
+	var score float64
+	score = vre.Score
 	if isSite {
-		score = 1
+		score = score+1.0
 	}
+
 	extinfo := map[string][]map[string]interface{}{}
 	rep := map[string]string{}
 	if vre.RegCore.Bextract { //正则是两部分的,可以直接抽取的(含下划线)
@@ -1300,7 +1308,17 @@ func extRegCoreToResult(extfrom, text string, tag *map[string]string, j *ju.Job,
 					}
 					tmps = append(tmps, tmp)
 
-					exfield := ju.ExtField{BlockTag: *tag, Field: vre.Field, Code: vre.Code, RuleText: vre.RuleText, Type: "regexp", MatchType: "regcontent", ExtFrom: extfrom, SourceValue: rep[vre.Field+"_"+fmt.Sprint(i)], Value: rep[vre.Field+"_"+fmt.Sprint(i)]}
+					exfield := ju.ExtField{
+						BlockTag: *tag,
+						Field: vre.Field,
+						Code: vre.Code,
+						RuleText: vre.RuleText,
+						Type: "regexp",
+						MatchType: "regcontent",
+						ExtFrom: extfrom,
+						SourceValue: rep[vre.Field+"_"+fmt.Sprint(i)],
+						Value: rep[vre.Field+"_"+fmt.Sprint(i)],
+						Score:score}
 					if tmp["blocktag"] != nil {
 						exfield.BlockTag = tmp["blocktag"].(map[string]string)
 					}
@@ -1308,6 +1326,7 @@ func extRegCoreToResult(extfrom, text string, tag *map[string]string, j *ju.Job,
 				}
 			}
 			if len(tmps) > 0 {
+				//fmt.Println(tmps)
 				extinfo[vre.Field] = tmps
 			}
 		}
@@ -1340,7 +1359,9 @@ func extRegCoreToResult(extfrom, text string, tag *map[string]string, j *ju.Job,
 			if j.Result[vre.Field] == nil {
 				j.Result[vre.Field] = [](*ju.ExtField){}
 			}
-			field := &ju.ExtField{BlockTag: *tag, Field: vre.Field, Code: vre.Code, RuleText: vre.RuleText, Type: "regexp", MatchType: "regcontent", ExtFrom: extfrom, SourceValue: text, Value: val}
+			field := &ju.ExtField{BlockTag: *tag, Field: vre.Field, Code: vre.Code, RuleText: vre.RuleText, Type: "regexp", MatchType: "regcontent", ExtFrom: extfrom, SourceValue: text,
+				Value: val,
+				Score:score}
 			if tmp["blocktag"] != nil {
 				field.BlockTag = tmp["blocktag"].(map[string]string)
 			}
@@ -1364,7 +1385,9 @@ func ExtRegBack(j *ju.Job, in *RegLuaInfo, t *TaskInfo) {
 			if tmps, ok := v.([]map[string]interface{}); ok {
 				j.Result[k] = [](*ju.ExtField){}
 				for _, tmp := range tmps {
-					field := &ju.ExtField{Field: k, Code: qu.ObjToString(tmp["code"]), RuleText: qu.ObjToString(tmp["ruletext"]), Type: qu.ObjToString(tmp["type"]), MatchType: qu.ObjToString(tmp["matchtype"]), ExtFrom: qu.ObjToString(tmp["extfrom"]), Value: tmp["value"]}
+					field := &ju.ExtField{Field: k, Code: qu.ObjToString(tmp["code"]), RuleText: qu.ObjToString(tmp["ruletext"]), Type: qu.ObjToString(tmp["type"]), MatchType: qu.ObjToString(tmp["matchtype"]),
+						ExtFrom: qu.ObjToString(tmp["extfrom"]),
+						Value: tmp["value"]}
 					if tmp["blocktag"] != nil {
 						field.BlockTag = tmp["blocktag"].(map[string]string)
 					}

+ 2 - 0
src/jy/extract/extractInit.go

@@ -21,6 +21,7 @@ import (
 type RegLuaInfo struct {
 	//正则或脚本信息
 	Code, Name, Field string  //
+	Score 			  float64
 	RuleText          string  //
 	IsLua             bool    //
 	RegPreBac         *ExtReg //
@@ -525,6 +526,7 @@ func (e *ExtractTask) InitRuleCore(isSite bool) {
 					Field: field,
 					Code:  v["s_code"].(string),
 					Name:  v["s_name"].(string),
+					Score: v["s_default_score"].(float64),
 					IsLua: qu.If(v["s_type"].(string) == "1", true, false).(bool),
 				}
 				if rinfo.IsLua {

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

@@ -125,6 +125,19 @@ func ScoreFields(j *ju.Job, ftag map[string][]*Tag) map[string][]*ju.ExtField {
 		taglength := len(ftag[field])
 		locktag.Unlock()
 		for tmpsindex, tmpsvalue := range tmps {
+
+			if tmpsvalue.Score>0 {
+				//有初始分先添加进去
+				tmps[tmpsindex].ScoreItem = append(tmps[tmpsindex].ScoreItem, &ju.ScoreItem{
+					Des: "正则初始分",
+					Code: tmpsvalue.Code,
+					RuleText: tmpsvalue.RuleText,
+					ScoreFrom: "正则初始分",
+					Value: tmpsvalue.Value,
+					Score: tmpsvalue.Score,
+				})
+			}
+
 			//没有抽取到值,不打分
 			if string_value := fmt.Sprint(tmpsvalue.Value); string_value == "" || string_value == "0" || string_value == "<nil>" {
 				if field == "budget" || field == "bidamount" {

+ 1 - 1
src/jy/pretreated/colonkv.go

@@ -571,7 +571,7 @@ func FormatContactKv(kvs *[]*Kv, title string, buyers []string, contactFormat *C
 		//qutil.Debug("ContactInfoMustReg.MatchString(k)+++", !ContactInfoMustReg.MatchString(k))
 		matchMust := ContactInfoMustReg.MatchString(k)
 		matchHas := ContactInfoVagueReg.MatchString(k)
-		qutil.Debug("matchMust:", matchMust, "matchHas:", matchHas)
+		//qutil.Debug("matchMust:", matchMust, "matchHas:", matchHas)
 		if !matchMust && matchHas {
 			k = ContactInfoVagueReg.FindString(k)
 		}

+ 3 - 1
src/web/templates/admin/rule_logicore.html

@@ -153,7 +153,9 @@ $(function () {
 			case "newlua":
 			case "new":
 				comtag=[{label:"名称",s_label:"s_name",placeholder:"",must:true},{label:"描述",s_label:"s_descript",type:"tpl_text"},{label:"启用",s_label:"isuse",type:"tpl_list_local",list:[{"s_name":"是","_id":true},{"s_name":"否","_id":false}],default:true}]
-				regtag=[{label:"字段",s_label:"s_field",type:"tpl_list_local",url:"/admin/getfields",default:{{.field}}},{label:"正则",s_label:"s_rule",type:"tpl_text",must:true}]
+				regtag=[{label:"字段",s_label:"s_field",type:"tpl_list_local",url:"/admin/getfields",default:{{.field}}},{label:"正则",s_label:"s_rule",type:"tpl_text",must:true},
+					{label:"分数",s_label:"s_default_score",placeholder:"默认0"}]
+
 				luatag=[{label:"字段",s_label:"s_field",type:"tpl_list_local",url:"/admin/getfields",default:{{.field}}},{label:"脚本",s_label:"s_luascript",type:"tpl_text",must:true}]
 				testcon=[{label:"测试内容",s_label:"s_testcon",type:"tpl_text",must:true}]
 				hiddentag=[{s_label:"_id",type:"tpl_hidden"},{s_label:"vid",type:"tpl_hidden"},{s_label:"pid",type:"tpl_hidden"},{s_label:"sid",type:"tpl_hidden"},{s_label:"s_type",type:"tpl_hidden"}]

+ 1 - 1
udp_winner/config.json

@@ -8,7 +8,7 @@
   "mgodb_enterprise": "enterprise",
   "mgodb_enterprise_c": "qyxy",
   "mgourl": "172.17.145.163:27082",
-  "mgodb_extract_kf": "extract_kf",
+  "mgodb_extract_kf": "extract_v3",
   "mgo_qyk_c": "winner_2",
   "mgo_qyk_c_w_new": "winner_new_2",
   "mgo_qyk_c_w_err": "winner_err_2",

+ 2 - 3
udp_winner/main.go

@@ -43,7 +43,6 @@ var (
 初始化
 */
 func init() {
-
 	log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
 	util.ReadConfig(&Config)
 	util.ReadConfig(&Sysconfig)
@@ -118,7 +117,7 @@ func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 				CPoolWinner <- true
 				go func(mapinfo *map[string]interface{}) {
 					defer func() { <-CPoolWinner }()
-					TaskWinner(mapinfo)
+					//TaskWinner(mapinfo)
 				}(tmp)
 				CPoolBuery <- true
 				go func(mapinfo *map[string]interface{}) {
@@ -128,7 +127,7 @@ func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 				CPoolAgency <- true
 				go func(mapinfo *map[string]interface{}) {
 					defer func() { <-CPoolAgency }()
-					TaskAgency(mapinfo)
+					//TaskAgency(mapinfo)
 				}(tmp)
 			}else if tmpstype =="winner" {
 				CPoolWinner <- true

+ 5 - 0
udp_winner/timedTaskAgency.go

@@ -63,6 +63,11 @@ func TaskAgency(mapinfo *map[string]interface{}) {
 		var tmpRangeId string
 		for cursor.Next(&tmp) {
 			num++
+
+			if num%10000==0 &&num>0{
+				log.Println("当前代理机构数量:",num)
+			}
+
 			mgoId := tmp["_id"].(bson.ObjectId).Hex()
 			tmpRangeId = mgoId
 			agency, ok := tmp["agency"].(string)

+ 4 - 0
udp_winner/timedTaskBuyer.go

@@ -63,6 +63,10 @@ func TaskBuyer(mapinfo *map[string]interface{}) {
 		var tmpRangeId string
 		for cursor.Next(&tmp) {
 			num++
+			if num%10000==0 &&num>0{
+				log.Println("当前采购单位数量:",num)
+			}
+
 			mgoId := tmp["_id"].(bson.ObjectId).Hex()
 			tmpRangeId = mgoId
 			buyer, ok := tmp["buyer"].(string)