zhangjinkun 6 gadi atpakaļ
vecāks
revīzija
f8b0dcd3e5
2 mainītis faili ar 25 papildinājumiem un 21 dzēšanām
  1. 23 21
      src/jy/extract/extract.go
  2. 2 0
      src/jy/extract/extractInit.go

+ 23 - 21
src/jy/extract/extract.go

@@ -555,28 +555,30 @@ func ExtRegBack(j *ju.Job, in *RegLuaInfo, t *TaskInfo) {
 		}
 	} else {
 		extinfo := map[string]interface{}{}
-		if in.Field != "" && j.Result[in.Field] != nil {
-			tmp := j.Result[in.Field]
-			exts := []interface{}{}
-			for k, v := range tmp {
-				text := qu.ObjToString(v.Value)
-				if text != "" {
-					text = in.RegPreBac.Reg.ReplaceAllString(text, in.RegPreBac.Replace)
+		if in.Field != "" {
+			if j.Result[in.Field] != nil {
+				tmp := j.Result[in.Field]
+				exts := []interface{}{}
+				for k, v := range tmp {
+					text := qu.ObjToString(v.Value)
+					if text != "" {
+						text = in.RegPreBac.Reg.ReplaceAllString(text, in.RegPreBac.Replace)
+					}
+					j.Result[in.Field][k].Value = text
+					exts = append(exts, map[string]interface{}{
+						"field":     v.Field,
+						"code":      v.Code,
+						"ruletext":  v.RuleText,
+						"type":      v.Type,
+						"matchtype": v.MatchType,
+						"extfrom":   v.ExtFrom,
+						"value":     text,
+					})
+				}
+				extinfo[in.Field] = exts
+				if len(extinfo) > 0 {
+					AddExtLog("clear", j.SourceMid, tmp, extinfo, in, t) //抽取日志
 				}
-				j.Result[in.Field][k].Value = text
-				exts = append(exts, map[string]interface{}{
-					"field":     v.Field,
-					"code":      v.Code,
-					"ruletext":  v.RuleText,
-					"type":      v.Type,
-					"matchtype": v.MatchType,
-					"extfrom":   v.ExtFrom,
-					"value":     text,
-				})
-			}
-			extinfo[in.Field] = exts
-			if len(extinfo) > 0 {
-				AddExtLog("clear", j.SourceMid, tmp, extinfo, in, t) //抽取日志
 			}
 		} else {
 			for key, tmp := range j.Result {

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

@@ -24,6 +24,7 @@ type ExtReg struct {
 	ExtractPos map[string]int
 }
 type RuleCore struct {
+	Field     string        //逻辑字段
 	LuaLogic  string        //进入逻辑
 	ExtFrom   string        //从哪个字段抽取
 	RulePres  []*RegLuaInfo //抽取前置规则
@@ -181,6 +182,7 @@ func (e *ExtractTask) InitRuleCore() {
 				continue
 			}
 			rcore := &RuleCore{}
+			rcore.Field = vinfo["s_field"].(string)
 			rcore.LuaLogic = qu.ObjToString(vv["s_luascript"]) //是否进入逻辑脚本
 			rcore.ExtFrom = qu.If(vv["extfrom"].(bool), "title", "detail").(string)
 			//前置规则