|
@@ -11,6 +11,7 @@ import (
|
|
|
qu "qfw/util"
|
|
|
"qfw/util/redis"
|
|
|
"regexp"
|
|
|
+ "sort"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"sync"
|
|
@@ -336,21 +337,27 @@ func (e *ExtractTask) PreInfo(doc map[string]interface{}) (j, jf *ju.Job, isSite
|
|
|
IsFile: isextFile,
|
|
|
}
|
|
|
}
|
|
|
- //是否配置站点
|
|
|
codeSite := j.SpiderCode
|
|
|
- exp, isSite := e.Luacodes.Load(codeSite)
|
|
|
+ //是否启用站点
|
|
|
+ if value, ok := e.SiteMerge.Load(codeSite); ok {
|
|
|
+ isSite = value.(bool)
|
|
|
+ }
|
|
|
if isSite {
|
|
|
- if exp.(map[string]interface{})["e.SiteClearFn"] != nil {
|
|
|
- e.SiteClearFn = exp.(map[string]interface{})["e.SiteClearFn"].(map[string][]string)
|
|
|
- }
|
|
|
- if exp.(map[string]interface{})["e.SiteTag"] != nil {
|
|
|
- e.SiteTag = exp.(map[string]interface{})["e.SiteTag"].(map[string][]*Tag)
|
|
|
- }
|
|
|
- if exp.(map[string]interface{})["e.SiteRuleCores"] != nil {
|
|
|
- e.SiteRuleCores = exp.(map[string]interface{})["e.SiteRuleCores"].(map[string]map[string][]*RuleCore)
|
|
|
- }
|
|
|
- if exp.(map[string]interface{})["e.SiteRuleBacks"] != nil {
|
|
|
- e.SiteRuleBacks = exp.(map[string]interface{})["e.SiteRuleBacks"].([]*RegLuaInfo)
|
|
|
+ //是否配置站点
|
|
|
+ exp, isSite := e.Luacodes.Load(codeSite)
|
|
|
+ if isSite {
|
|
|
+ if exp.(map[string]interface{})["e.SiteClearFn"] != nil {
|
|
|
+ e.SiteClearFn = exp.(map[string]interface{})["e.SiteClearFn"].(map[string][]string)
|
|
|
+ }
|
|
|
+ if exp.(map[string]interface{})["e.SiteTag"] != nil {
|
|
|
+ e.SiteTag = exp.(map[string]interface{})["e.SiteTag"].(map[string][]*Tag)
|
|
|
+ }
|
|
|
+ if exp.(map[string]interface{})["e.SiteRuleCores"] != nil {
|
|
|
+ e.SiteRuleCores = exp.(map[string]interface{})["e.SiteRuleCores"].(map[string]map[string][]*RuleCore)
|
|
|
+ }
|
|
|
+ if exp.(map[string]interface{})["e.SiteRuleBacks"] != nil {
|
|
|
+ e.SiteRuleBacks = exp.(map[string]interface{})["e.SiteRuleBacks"].([]*RegLuaInfo)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
qu.Try(func() {
|
|
@@ -587,6 +594,7 @@ func (e *ExtractTask) ExtractDetail(j *ju.Job, isSite bool, codeSite string) {
|
|
|
if istrue, ok := data[len(data)-1].(bool); istrue && ok {
|
|
|
j.Result[key][i].IsTrue = true
|
|
|
} else {
|
|
|
+ j.Result[key][i].Value = data[0]
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
@@ -795,8 +803,8 @@ 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"]}
|
|
|
- if k == "bidamount" && field.ExtFrom=="第一候选人"{
|
|
|
+ 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
|
|
|
}
|
|
|
if isSite {
|
|
@@ -1039,7 +1047,7 @@ func getKvByLuaFields(vc *RuleCore, j *ju.Job, et *ExtractTask) (map[string][]ma
|
|
|
if len(j.Winnerorder) > 1 {
|
|
|
if vc.Field == "bidamount" {
|
|
|
for _, v := range j.Winnerorder {
|
|
|
- if v["price"] == nil{
|
|
|
+ if v["price"] == nil {
|
|
|
continue
|
|
|
}
|
|
|
kvmap[vc.Field] = append(kvmap[vc.Field], map[string]interface{}{
|
|
@@ -1059,7 +1067,7 @@ func getKvByLuaFields(vc *RuleCore, j *ju.Job, et *ExtractTask) (map[string][]ma
|
|
|
"code": "CL_中标候选人",
|
|
|
"field": vc.Field,
|
|
|
"ruletext": "中标候选人",
|
|
|
- "extfrom": j.Winnerorder[0]["sortstr"],
|
|
|
+ "extfrom": j.Winnerorder[0]["sortstr"],
|
|
|
"sourcevalue": price,
|
|
|
"value": price,
|
|
|
"type": "winnerorder",
|
|
@@ -1588,22 +1596,54 @@ func AnalysisSaveResult(j, jf *ju.Job, e *ExtractTask) {
|
|
|
tmp["fieldall"] = auxinfo
|
|
|
for _, val := range result {
|
|
|
for _, v := range val { //取第一个非负数,项目名称除外
|
|
|
+ //存0是否有效
|
|
|
+ if (v.Field == "bidamount" || v.Field == "budget") && v.IsTrue {
|
|
|
+ tmp[v.Field] = v.Value
|
|
|
+ break
|
|
|
+ }
|
|
|
if v.Score > -1 {
|
|
|
tmp[v.Field] = v.Value
|
|
|
break
|
|
|
} else if v.Field == "projectname" {
|
|
|
tmp[v.Field] = v.Value
|
|
|
break
|
|
|
- } else if v.Field == "bidamount" || v.Field == "budget" {
|
|
|
- if v.IsTrue {
|
|
|
- tmp[v.Field] = v.Value
|
|
|
- break
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if len(j.PackageInfo) > 0 { //分包信息
|
|
|
tmp["package"] = j.PackageInfo
|
|
|
+ //包预算,中标金额合并大于抽取就覆盖
|
|
|
+ var tmpBidamount, tmpBudget float64
|
|
|
+ //s_winner逗号分隔拼接,分包中标人
|
|
|
+ var tmpstr,savewinner []string
|
|
|
+ //包预算,中标金额合并大于抽取就覆盖
|
|
|
+ for b, v := range j.PackageInfo {
|
|
|
+ if v["winner"]!= nil && v["winner"]!=""{
|
|
|
+ tmpstr = append(tmpstr,b)
|
|
|
+ }
|
|
|
+ if v["budget"] != nil {
|
|
|
+ tmpBudget += qu.Float64All(v["budget"])
|
|
|
+ }
|
|
|
+ if v["bidamount"] != nil {
|
|
|
+ tmpBidamount += qu.Float64All(v["bidamount"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if qu.Float64All(tmp["budget"]) < tmpBudget {
|
|
|
+ tmp["budget"] = tmpBudget
|
|
|
+ }
|
|
|
+ if qu.Float64All(tmp["bidamount"]) < tmpBidamount {
|
|
|
+ tmp["bidamount"] = tmpBidamount
|
|
|
+ }
|
|
|
+ //s_winner逗号分隔拼接,分包中标人
|
|
|
+ sort.Strings(tmpstr)
|
|
|
+ for _,v := range tmpstr{
|
|
|
+ savewinner = append(savewinner,qu.ObjToString(j.PackageInfo[v]["winner"]))
|
|
|
+ }
|
|
|
+ tmp["s_winner"] = strings.Join(savewinner,",")
|
|
|
+
|
|
|
+ }else if tmp["winner"]!= nil && tmp["winner"]!=""{
|
|
|
+ //没有分包取winner
|
|
|
+ tmp["s_winner"] = tmp["winner"]
|
|
|
}
|
|
|
if len(j.Winnerorder) > 0 { //候选人信息
|
|
|
tmp["winnerorder"] = j.Winnerorder
|
|
@@ -2044,20 +2084,23 @@ func resetWinnerorder(j *ju.Job) {
|
|
|
// }
|
|
|
//}
|
|
|
if maxlen > 0 {
|
|
|
- winners = append(winners,&ju.ExtField{Code:"winnerorder",Field:"winner",ExtFrom:"j.Winnerorder",Value:j.Winnerorder[0]["entname"],Score:0.5} )
|
|
|
- if j.Winnerorder[0]["price"]!= nil{
|
|
|
- bidamounts = append(bidamounts,&ju.ExtField{Code:"winnerorder",Field:"bidamount",ExtFrom:"j.Winnerorder",Value:j.Winnerorder[0]["price"],Score:0.5} )
|
|
|
+ winners = append(winners, &ju.ExtField{Code: "winnerorder", Field: "winner", ExtFrom: "j.Winnerorder", Value: j.Winnerorder[0]["entname"], Score: 0.5})
|
|
|
+ if j.Winnerorder[0]["price"] != nil {
|
|
|
+ tmpPrice := clear.ObjToMoney([]interface{}{j.Winnerorder[0]["price"],""})
|
|
|
+ if tmpPrice[len(tmpPrice)-1].(bool){
|
|
|
+ bidamounts = append(bidamounts, &ju.ExtField{Code: "winnerorder", Field: "bidamount", ExtFrom: "j.Winnerorder",SourceValue:j.Winnerorder[0]["price"], Value: tmpPrice[0], Score: 0.5})
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- if j.Result["winner"] == nil{
|
|
|
+ if j.Result["winner"] == nil && len(winners) > 0 {
|
|
|
j.Result["winner"] = winners
|
|
|
- }else {
|
|
|
- j.Result["winner"] = append(j.Result["winner"],winners... )
|
|
|
+ } else {
|
|
|
+ j.Result["winner"] = append(j.Result["winner"], winners...)
|
|
|
}
|
|
|
- if j.Result["bidamount"]==nil{
|
|
|
+ if j.Result["bidamount"] == nil && len(bidamounts) > 0 {
|
|
|
j.Result["bidamount"] = bidamounts
|
|
|
- }else {
|
|
|
- j.Result["bidamount"] = append(j.Result["bidamount"],bidamounts... )
|
|
|
+ } else {
|
|
|
+ j.Result["bidamount"] = append(j.Result["bidamount"], bidamounts...)
|
|
|
}
|
|
|
//j.Result["winner"] = winners
|
|
|
//中标金额
|