|
@@ -3,6 +3,7 @@ package extract
|
|
|
|
|
|
import (
|
|
|
db "jy/mongodbutil"
|
|
|
+ "log"
|
|
|
qu "qfw/util"
|
|
|
"regexp"
|
|
|
"strings"
|
|
@@ -85,6 +86,7 @@ func (e *ExtractTask) InitTestTaskInfo(resultcoll, trackcoll string) {
|
|
|
//加载任务信息
|
|
|
func (e *ExtractTask) InitTaskInfo() {
|
|
|
task, _ := db.Mgo.FindById("task", e.Id, nil)
|
|
|
+ log.Println("task", task)
|
|
|
if len(*task) > 1 {
|
|
|
v, _ := db.Mgo.FindOne("version", `{"version":"`+(*task)["s_version"].(string)+`"}`)
|
|
|
e.TaskInfo = &TaskInfo{
|
|
@@ -100,6 +102,7 @@ func (e *ExtractTask) InitTaskInfo() {
|
|
|
LastExtId: qu.ObjToString((*task)["s_extlastid"]),
|
|
|
ProcessPool: make(chan bool, qu.IntAllDef((*task)["i_process"], 1)),
|
|
|
}
|
|
|
+ log.Println(e.TaskInfo.Name, e.TaskInfo.ProcessPool)
|
|
|
} else {
|
|
|
return
|
|
|
}
|
|
@@ -118,13 +121,17 @@ func (e *ExtractTask) InitRulePres() {
|
|
|
if rinfo.IsLua {
|
|
|
rinfo.RuleText = v["s_luascript"].(string)
|
|
|
} else {
|
|
|
- rinfo.RuleText = v["s_rule"].(string)
|
|
|
- tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
- if len(tmp) == 2 {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
- } else {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
- }
|
|
|
+ qu.Try(func() {
|
|
|
+ rinfo.RuleText = v["s_rule"].(string)
|
|
|
+ tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
+ if len(tmp) == 2 {
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
+ } else {
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
+ }
|
|
|
+ }, func(err interface{}) {
|
|
|
+ log.Println(rinfo.Code, rinfo.Field, err)
|
|
|
+ })
|
|
|
}
|
|
|
e.RulePres = append(e.RulePres, rinfo)
|
|
|
}
|
|
@@ -143,13 +150,17 @@ func (e *ExtractTask) InitRuleBacks() {
|
|
|
if rinfo.IsLua {
|
|
|
rinfo.RuleText = v["s_luascript"].(string)
|
|
|
} else {
|
|
|
- rinfo.RuleText = v["s_rule"].(string)
|
|
|
- tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
- if len(tmp) == 2 {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
- } else {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
- }
|
|
|
+ qu.Try(func() {
|
|
|
+ rinfo.RuleText = v["s_rule"].(string)
|
|
|
+ tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
+ if len(tmp) == 2 {
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
+ } else {
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
+ }
|
|
|
+ }, func(err interface{}) {
|
|
|
+ log.Println(rinfo.Code, rinfo.Field, err)
|
|
|
+ })
|
|
|
}
|
|
|
e.RuleBacks = append(e.RuleBacks, rinfo)
|
|
|
}
|
|
@@ -184,14 +195,18 @@ func (e *ExtractTask) InitRuleCore() {
|
|
|
if rinfo.IsLua {
|
|
|
rinfo.RuleText = v["s_luascript"].(string)
|
|
|
} else {
|
|
|
- rinfo.RuleText = v["s_rule"].(string)
|
|
|
- rinfo.Field = v["s_field"].(string)
|
|
|
- tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
- if len(tmp) == 2 {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
- } else {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
- }
|
|
|
+ qu.Try(func() {
|
|
|
+ rinfo.RuleText = v["s_rule"].(string)
|
|
|
+ rinfo.Field = v["s_field"].(string)
|
|
|
+ tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
+ if len(tmp) == 2 {
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
+ } else {
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
+ }
|
|
|
+ }, func(err interface{}) {
|
|
|
+ log.Println(rinfo.Code, rinfo.Field, err)
|
|
|
+ })
|
|
|
}
|
|
|
rulePres = append(rulePres, rinfo)
|
|
|
}
|
|
@@ -209,14 +224,18 @@ func (e *ExtractTask) InitRuleCore() {
|
|
|
if rinfo.IsLua {
|
|
|
rinfo.RuleText = v["s_luascript"].(string)
|
|
|
} else {
|
|
|
- rinfo.RuleText = v["s_rule"].(string)
|
|
|
- rinfo.Field = v["s_field"].(string)
|
|
|
- tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
- if len(tmp) == 2 {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
- } else {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
- }
|
|
|
+ qu.Try(func() {
|
|
|
+ rinfo.RuleText = v["s_rule"].(string)
|
|
|
+ rinfo.Field = v["s_field"].(string)
|
|
|
+ tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
+ if len(tmp) == 2 {
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
+ } else {
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
+ }
|
|
|
+ }, func(err interface{}) {
|
|
|
+ log.Println(rinfo.Code, rinfo.Field, err)
|
|
|
+ })
|
|
|
}
|
|
|
ruleBacks = append(ruleBacks, rinfo)
|
|
|
}
|
|
@@ -244,24 +263,28 @@ func (e *ExtractTask) InitRuleCore() {
|
|
|
rinfo.IsHasFields = true
|
|
|
}*/
|
|
|
} else {
|
|
|
- rinfo.RuleText = v["s_rule"].(string)
|
|
|
- rinfo.Field = v["s_field"].(string)
|
|
|
- tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
- if len(tmp) == 2 {
|
|
|
- epos := strings.Split(tmp[1], ",")
|
|
|
- posm := map[string]int{}
|
|
|
- for _, v := range epos {
|
|
|
- ks := strings.Split(v, ":")
|
|
|
- if len(ks) == 2 { //(.*)招标公告(.*)__2:projectname,4:area
|
|
|
- posm[ks[1]] = qu.IntAll(ks[0])
|
|
|
- } else { //(.*)招标公告__2
|
|
|
- posm[rinfo.Field] = qu.IntAll(ks[0])
|
|
|
+ qu.Try(func() {
|
|
|
+ rinfo.RuleText = v["s_rule"].(string)
|
|
|
+ rinfo.Field = v["s_field"].(string)
|
|
|
+ tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
+ if len(tmp) == 2 {
|
|
|
+ epos := strings.Split(tmp[1], ",")
|
|
|
+ posm := map[string]int{}
|
|
|
+ for _, v := range epos {
|
|
|
+ ks := strings.Split(v, ":")
|
|
|
+ if len(ks) == 2 { //(.*)招标公告(.*)__2:projectname,4:area
|
|
|
+ posm[ks[1]] = qu.IntAll(ks[0])
|
|
|
+ } else { //(.*)招标公告__2
|
|
|
+ posm[rinfo.Field] = qu.IntAll(ks[0])
|
|
|
+ }
|
|
|
}
|
|
|
+ rinfo.RegCore = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Bextract: true, ExtractPos: posm}
|
|
|
+ } else {
|
|
|
+ rinfo.RegCore = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Bextract: false}
|
|
|
}
|
|
|
- rinfo.RegCore = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Bextract: true, ExtractPos: posm}
|
|
|
- } else {
|
|
|
- rinfo.RegCore = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Bextract: false}
|
|
|
- }
|
|
|
+ }, func(err interface{}) {
|
|
|
+ log.Println(rinfo.Code, rinfo.Field, err)
|
|
|
+ })
|
|
|
}
|
|
|
ruleCores = append(ruleCores, rinfo)
|
|
|
}
|