|
@@ -9,13 +9,6 @@ import (
|
|
"strings"
|
|
"strings"
|
|
)
|
|
)
|
|
|
|
|
|
-var (
|
|
|
|
- bidCommonwealth_blacklistPatterns = g.Config().MustGet(gctx.New(), "bidCommonwealth.blacklistPatterns").Strings()
|
|
|
|
- bidCommonwealth_whitelistPatterns = g.Config().MustGet(gctx.New(), "bidCommonwealth.whitelistPatterns").Strings()
|
|
|
|
- quoteModeRules = g.Config().MustGet(gctx.New(), "quoteMode.rules").Maps()
|
|
|
|
- quoteModeTableKReg = g.Config().MustGet(gctx.New(), "quoteMode.tableK").String()
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
type Rule struct{}
|
|
type Rule struct{}
|
|
|
|
|
|
func (r *Rule) Execute(b *BidInfo) (string, int) {
|
|
func (r *Rule) Execute(b *BidInfo) (string, int) {
|
|
@@ -29,7 +22,7 @@ func (r *Rule) Execute(b *BidInfo) (string, int) {
|
|
} else if b.Type == 2 {
|
|
} else if b.Type == 2 {
|
|
bidCommonwealth = r.bidCommonwealth(b)
|
|
bidCommonwealth = r.bidCommonwealth(b)
|
|
}
|
|
}
|
|
- if quoteMode == QuoteMode_Whole && (b.Bidamount < g.Config().MustGet(gctx.New(), "quoteMode.minBidamount").Float64()) {
|
|
|
|
|
|
+ if quoteMode == QuoteMode_Whole && (b.Bidamount > 0 && b.Bidamount < g.Config().MustGet(gctx.New(), "quoteMode.minBidamount").Float64()) {
|
|
quoteMode = ""
|
|
quoteMode = ""
|
|
}
|
|
}
|
|
log.Println(b.Id, "规则", "报价模式", quoteMode, "中标联合体", bidCommonwealth)
|
|
log.Println(b.Id, "规则", "报价模式", quoteMode, "中标联合体", bidCommonwealth)
|
|
@@ -38,6 +31,7 @@ func (r *Rule) Execute(b *BidInfo) (string, int) {
|
|
|
|
|
|
// 识别报价模式
|
|
// 识别报价模式
|
|
func (r *Rule) quoteMode(b *BidInfo) (string, map[string]bool) {
|
|
func (r *Rule) quoteMode(b *BidInfo) (string, map[string]bool) {
|
|
|
|
+ quoteModeRules := g.Config().MustGet(gctx.New(), "quoteMode.rules").Maps()
|
|
for _, v := range quoteModeRules {
|
|
for _, v := range quoteModeRules {
|
|
vv := gvar.New(v).MapStrVar()
|
|
vv := gvar.New(v).MapStrVar()
|
|
mustTableKv := vv["mustTableKv"].Maps()
|
|
mustTableKv := vv["mustTableKv"].Maps()
|
|
@@ -48,7 +42,7 @@ func (r *Rule) quoteMode(b *BidInfo) (string, map[string]bool) {
|
|
mustTableKvMap := map[int]bool{}
|
|
mustTableKvMap := map[int]bool{}
|
|
for k, v := range row {
|
|
for k, v := range row {
|
|
if tableV := vv["tableV"].String(); tableV != "" {
|
|
if tableV := vv["tableV"].String(); tableV != "" {
|
|
- matchedK, _ := regexp.MatchString(quoteModeTableKReg, k)
|
|
|
|
|
|
+ matchedK, _ := regexp.MatchString(g.Config().MustGet(gctx.New(), "quoteMode.tableK").String(), k)
|
|
if !matchedK {
|
|
if !matchedK {
|
|
if tableK := vv["tableK"].String(); tableK != "" {
|
|
if tableK := vv["tableK"].String(); tableK != "" {
|
|
matchedK, _ = regexp.MatchString(tableK, k)
|
|
matchedK, _ = regexp.MatchString(tableK, k)
|
|
@@ -107,11 +101,15 @@ func (r *Rule) quoteMode(b *BidInfo) (string, map[string]bool) {
|
|
for _, v := range quoteModeRules {
|
|
for _, v := range quoteModeRules {
|
|
vv := gvar.New(v).MapStrVar()
|
|
vv := gvar.New(v).MapStrVar()
|
|
modeName := vv["mode"].String()
|
|
modeName := vv["mode"].String()
|
|
|
|
+ detail := b.Detail
|
|
|
|
+ for _, v := range vv["clearPatterns"].Strings() {
|
|
|
|
+ detail = regexp.MustCompile(v).ReplaceAllString(detail, "")
|
|
|
|
+ }
|
|
excludePatterns := vv["excludePatterns"].Strings()
|
|
excludePatterns := vv["excludePatterns"].Strings()
|
|
- if len(excludePatterns) > 0 && !r.matchAnyPattern(b.Id, b.Detail, excludePatterns) {
|
|
|
|
|
|
+ if len(excludePatterns) > 0 && !r.matchAnyPattern(b.Id, detail, excludePatterns) {
|
|
return modeName, nil
|
|
return modeName, nil
|
|
}
|
|
}
|
|
- lines := strings.Split(b.Detail, "\n")
|
|
|
|
|
|
+ lines := strings.Split(detail, "\n")
|
|
for _, lineVal := range lines {
|
|
for _, lineVal := range lines {
|
|
if r.matchAnyPattern(b.Id, lineVal, vv["patterns"].Strings()) {
|
|
if r.matchAnyPattern(b.Id, lineVal, vv["patterns"].Strings()) {
|
|
return modeName, nil
|
|
return modeName, nil
|
|
@@ -124,10 +122,14 @@ func (r *Rule) quoteMode(b *BidInfo) (string, map[string]bool) {
|
|
// 识别中标联合体
|
|
// 识别中标联合体
|
|
func (r *Rule) bidCommonwealth(b *BidInfo) int {
|
|
func (r *Rule) bidCommonwealth(b *BidInfo) int {
|
|
// Step 1: 排除黑名单
|
|
// Step 1: 排除黑名单
|
|
- if r.matchAnyPattern(b.Id, b.Detail, bidCommonwealth_blacklistPatterns) {
|
|
|
|
|
|
+ if r.matchAnyPattern(b.Id, b.Detail, g.Config().MustGet(gctx.New(), "bidCommonwealth.blacklistPatterns").Strings()) {
|
|
return -1
|
|
return -1
|
|
}
|
|
}
|
|
- if r.matchAnyPattern(b.Id, b.Detail, bidCommonwealth_whitelistPatterns) {
|
|
|
|
|
|
+ detail := b.Detail
|
|
|
|
+ for _, v := range g.Config().MustGet(gctx.New(), "bidCommonwealth.clearPatterns").Strings() {
|
|
|
|
+ detail = regexp.MustCompile(v).ReplaceAllString(detail, "")
|
|
|
|
+ }
|
|
|
|
+ if r.matchAnyPattern(b.Id, b.Detail, g.Config().MustGet(gctx.New(), "bidCommonwealth.whitelistPatterns").Strings()) {
|
|
return 1
|
|
return 1
|
|
}
|
|
}
|
|
return -1
|
|
return -1
|