Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
bom_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ce726eaf
authored
Mar 16, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改协程数量
parent
232bb276
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
4 deletions
internal/logic/attr.go
internal/logic/match.go
internal/logic/search.go
internal/logic/attr.go
View file @
ce726eaf
...
@@ -28,7 +28,7 @@ func GetStandardAttrs(bomItems []model.BomItem) []model.BomItem {
...
@@ -28,7 +28,7 @@ func GetStandardAttrs(bomItems []model.BomItem) []model.BomItem {
}
}
params
:=
req
.
BodyJSON
(
attrParams
)
params
:=
req
.
BodyJSON
(
attrParams
)
resp
,
err
:=
req
.
Post
(
configs
.
ApiSetting
.
Attrs
,
params
)
resp
,
err
:=
req
.
Post
(
configs
.
ApiSetting
.
Attrs
,
params
)
fmt
.
Println
(
resp
)
//
fmt.Println(resp)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
}
}
...
...
internal/logic/match.go
View file @
ce726eaf
...
@@ -30,7 +30,7 @@ func MatchGoods(message model.BomMessage) (err error) {
...
@@ -30,7 +30,7 @@ func MatchGoods(message model.BomMessage) (err error) {
if
configs
.
ApiSetting
.
Mode
==
"debug"
{
if
configs
.
ApiSetting
.
Mode
==
"debug"
{
perGoDealNumber
=
200
perGoDealNumber
=
200
}
else
{
}
else
{
perGoDealNumber
=
4
0
perGoDealNumber
=
2
0
}
}
//开启协程处理搜索
//开启协程处理搜索
var
wg
sync
.
WaitGroup
var
wg
sync
.
WaitGroup
...
...
internal/logic/search.go
View file @
ce726eaf
...
@@ -6,7 +6,6 @@ import (
...
@@ -6,7 +6,6 @@ import (
"bom_server/internal/model"
"bom_server/internal/model"
"context"
"context"
"encoding/json"
"encoding/json"
"fmt"
es
"gopkg.in/olivere/elastic.v5"
es
"gopkg.in/olivere/elastic.v5"
"regexp"
"regexp"
"strings"
"strings"
...
@@ -101,7 +100,7 @@ func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool) (
...
@@ -101,7 +100,7 @@ func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool) (
}
}
source
=
source
.
From
(
0
)
.
Size
(
1
)
source
=
source
.
From
(
0
)
.
Size
(
1
)
searchRequest
=
es
.
NewSearchRequest
()
.
Source
(
source
)
searchRequest
=
es
.
NewSearchRequest
()
.
Source
(
source
)
fmt
.
Println
(
searchRequest
.
Body
())
//
fmt.Println(searchRequest.Body())
return
searchRequest
return
searchRequest
}
}
...
@@ -116,6 +115,7 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
...
@@ -116,6 +115,7 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
//用于判断下面的miniShould,因为下面的参数里面,如果出现阻值的,用的是should语句
//用于判断下面的miniShould,因为下面的参数里面,如果出现阻值的,用的是should语句
//为了保证所有参数都必须参与搜索,所以要用miniShould去做限制
//为了保证所有参数都必须参与搜索,所以要用miniShould去做限制
//var shouldNumber int
//var shouldNumber int
var
hasSpecialQuery
bool
//商品名称太短的或者没有商品名称的,去搜索参数
//商品名称太短的或者没有商品名称的,去搜索参数
if
len
(
goodsName
)
<=
3
{
if
len
(
goodsName
)
<=
3
{
if
len
(
bomItem
.
AttrList
)
>
0
{
if
len
(
bomItem
.
AttrList
)
>
0
{
...
@@ -131,13 +131,16 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
...
@@ -131,13 +131,16 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
}
}
//需要注意的点 : 因为0.158Ω可以对应 电阻 或者 直流电阻 ,所以当识别出来是电阻 或者 直流电阻 的时候,就不能用must,要用should
//需要注意的点 : 因为0.158Ω可以对应 电阻 或者 直流电阻 ,所以当识别出来是电阻 或者 直流电阻 的时候,就不能用must,要用should
if
strings
.
Contains
(
attr
,
"ZLNZ€"
)
||
strings
.
Contains
(
attr
,
"OM€"
)
{
if
strings
.
Contains
(
attr
,
"ZLNZ€"
)
||
strings
.
Contains
(
attr
,
"OM€"
)
{
hasSpecialQuery
=
true
//query.Should(es.NewTermQuery("attr_bom", attr))
//query.Should(es.NewTermQuery("attr_bom", attr))
q
.
Should
(
es
.
NewTermQuery
(
"attr_bom"
,
attr
))
q
.
Should
(
es
.
NewTermQuery
(
"attr_bom"
,
attr
))
}
else
{
}
else
{
query
.
Must
(
es
.
NewTermQuery
(
"attr_bom"
,
attr
))
query
.
Must
(
es
.
NewTermQuery
(
"attr_bom"
,
attr
))
}
}
}
}
if
hasSpecialQuery
{
query
.
Must
(
q
)
query
.
Must
(
q
)
}
}
else
{
}
else
{
query
=
query
.
Must
(
es
.
NewTermsQuery
(
"attr_bom"
,
"$_$"
))
query
=
query
.
Must
(
es
.
NewTermsQuery
(
"attr_bom"
,
"$_$"
))
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment