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
d06eb99e
authored
Mar 12, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复完成:
parent
f4087c27
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
9 deletions
cmd/queue/bom.go
internal/logic/attr.go
internal/logic/bom_item.go
internal/logic/encap.go
internal/logic/match.go
internal/logic/search.go
cmd/queue/bom.go
View file @
d06eb99e
...
...
@@ -28,7 +28,6 @@ func init() {
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
(
err
error
)
{
fmt
.
Println
(
"开始"
)
var
message
model
.
BomMessage
if
err
=
json
.
Unmarshal
(
dataByte
,
&
message
);
err
!=
nil
{
log
.
Error
(
err
)
...
...
internal/logic/attr.go
View file @
d06eb99e
...
...
@@ -26,6 +26,7 @@ func GetStandardAttrs(bomItems []model.BomItem) []model.BomItem {
}
params
:=
req
.
BodyJSON
(
attrParams
)
resp
,
err
:=
req
.
Post
(
configs
.
ApiSetting
.
Attrs
,
params
)
//fmt.Println(resp)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
...
...
@@ -60,7 +61,6 @@ func GetStandardAttrs(bomItems []model.BomItem) []model.BomItem {
var
attrsSlice
[]
string
for
_
,
attr
:=
range
item
.
AttrList
{
attrs
:=
GetStandardEsAttr
(
attr
)
fmt
.
Println
(
attrs
)
if
attr
!=
""
{
attrsSlice
=
append
(
attrsSlice
,
attrs
...
)
}
...
...
internal/logic/bom_item.go
View file @
d06eb99e
...
...
@@ -71,6 +71,7 @@ func UpdateBomItem(bomId, bomItemId int) (err error) {
//先去查主表的信息
bom
:=
GetBomInfo
(
bomId
)
bomItem
:=
GetBomItem
(
bomId
,
bomItemId
)
bomItem
.
Amount
=
bom
.
Amount
if
bom
.
BomID
==
0
||
bomItem
.
BomID
==
0
{
return
errors
.
New
(
"该bom单不存在商品"
)
}
...
...
internal/logic/encap.go
View file @
d06eb99e
...
...
@@ -20,5 +20,8 @@ func TransformEncap(encap string) (attrValue string) {
pureNumber
=
encapCheck
}
}
if
len
(
pureNumber
)
<
4
{
return
""
}
return
pureNumber
}
internal/logic/match.go
View file @
d06eb99e
...
...
@@ -152,6 +152,7 @@ func UpdateSingleBomMatching(bomSn string, bomItemId int, goodsId string) (bomIt
}
//还要返回对应的信息
bomItemInfo
=
GetBomItem
(
bom
.
BomID
,
bomItemId
)
bomItemInfo
.
Amount
=
bom
.
Amount
bomMatching
:=
GetBomMatching
(
bom
.
BomID
,
bomItemId
)
bomItemInfo
.
Matching
=
bomMatching
return
...
...
internal/logic/search.go
View file @
d06eb99e
...
...
@@ -6,7 +6,6 @@ import (
"bom_server/internal/model"
"context"
"encoding/json"
"fmt"
es
"gopkg.in/olivere/elastic.v5"
"regexp"
"strings"
...
...
@@ -80,10 +79,10 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
//构建请求参数
func
getSearchParams
(
index
string
,
bomItem
model
.
BomItem
,
sort
int
,
flag
bool
)
(
searchRequest
*
es
.
SearchRequest
)
{
fmt
.
Println
(
"商品名称 : "
,
bomItem
.
GoodsName
)
fmt
.
Println
(
"参数列表 : "
,
bomItem
.
AttrList
)
//
fmt.Println("商品名称 : ", bomItem.GoodsName)
//
fmt.Println("参数列表 : ", bomItem.AttrList)
bomItem
.
Encap
=
TransformEncap
(
bomItem
.
Encap
)
fmt
.
Println
(
"封装 : "
,
bomItem
.
Encap
)
//
fmt.Println("封装 : ", bomItem.Encap)
query
:=
getTermQuery
(
bomItem
,
sort
,
flag
)
source
:=
es
.
NewSearchSource
()
.
Query
(
query
)
if
sort
==
1
{
...
...
@@ -101,7 +100,7 @@ func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool) (
}
source
=
source
.
From
(
0
)
.
Size
(
1
)
searchRequest
=
es
.
NewSearchRequest
()
.
Source
(
source
)
fmt
.
Println
(
searchRequest
.
Body
())
//
fmt.Println(searchRequest.Body())
return
searchRequest
}
...
...
@@ -119,9 +118,9 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
//var params []interface{}
for
_
,
attr
:=
range
bomItem
.
AttrList
{
//需要注意的点 : 因为0.158Ω可以对应 电阻 或者 直流电阻 ,所以当识别出来是电阻 或者 直流电阻 的时候,就不能用must,要用should
if
strings
.
Contains
(
attr
,
"ZLNZ€"
)
||
strings
.
Contains
(
attr
,
"OM€"
)
{
if
strings
.
Contains
(
attr
,
"ZLNZ€"
)
||
strings
.
Contains
(
attr
,
"OM€"
)
{
query
.
Should
(
es
.
NewTermQuery
(
"attr_bom"
,
attr
))
}
else
{
}
else
{
query
.
Must
(
es
.
NewTermQuery
(
"attr_bom"
,
attr
))
}
}
...
...
@@ -141,6 +140,7 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
query
=
query
.
Must
(
es
.
NewTermQuery
(
"encap"
,
bomItem
.
Encap
))
}
//搜索库存
//fmt.Println("总数量:", bomItem.Number, bomItem.Amount)
query
=
query
.
Should
(
es
.
NewConstantScoreQuery
(
es
.
NewRangeQuery
(
"stock"
)
.
Gte
(
bomItem
.
Number
*
bomItem
.
Amount
)))
}
else
{
query
=
query
.
Must
(
es
.
NewTermQuery
(
"auto_goods_name"
,
bomItem
.
GoodsName
))
...
...
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