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
eff729bf
authored
Jun 30, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
接入商品更新队列
parent
635dd3d6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
10 deletions
.gitignore
cmd/queue/bom.go
internal/logic/attr.go
internal/logic/bom_matching.go
internal/logic/goods.go
server/server.exe~
.gitignore
View file @
eff729bf
...
@@ -7,6 +7,7 @@ bom_server
...
@@ -7,6 +7,7 @@ bom_server
*.properties
*.properties
*.iml
*.iml
*.exe
*.exe
*.exe~
/logs
/logs
/components
/components
/storage/app
/storage/app
...
@@ -24,6 +25,7 @@ cmd/cmd.exe~
...
@@ -24,6 +25,7 @@ cmd/cmd.exe~
cmd/cmd
cmd/cmd
/cmd/dong/logs/*.log
/cmd/dong/logs/*.log
server/server
server/server
server.exe
/sh
/sh
*.ini
*.ini
gowatch.yml
gowatch.yml
cmd/queue/bom.go
View file @
eff729bf
...
@@ -22,7 +22,7 @@ func init() {
...
@@ -22,7 +22,7 @@ func init() {
// "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
// "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
//}
//}
//
//
//str := `{"bom_id":6
42
,"delivery_type":1,"sort":1}`
//str := `{"bom_id":6
66
,"delivery_type":1,"sort":1}`
//rabbitmq.Send(queueExchange, str)
//rabbitmq.Send(queueExchange, str)
}
}
...
...
internal/logic/attr.go
View file @
eff729bf
...
@@ -153,17 +153,8 @@ func searchAttr(bomItem model.BomItem, search *es.MultiSearchService) (result *e
...
@@ -153,17 +153,8 @@ func searchAttr(bomItem model.BomItem, search *es.MultiSearchService) (result *e
//切割参数
//切割参数
func
splitAttrs
(
attrs
string
)
(
result
[]
string
)
{
func
splitAttrs
(
attrs
string
)
(
result
[]
string
)
{
result
=
strings
.
Split
(
attrs
,
" "
)
result
=
strings
.
Split
(
attrs
,
" "
)
if
len
(
result
)
>
1
{
return
}
result
=
strings
.
Split
(
attrs
,
","
)
result
=
strings
.
Split
(
attrs
,
","
)
if
len
(
result
)
>
1
{
return
}
result
=
strings
.
Split
(
attrs
,
"|"
)
result
=
strings
.
Split
(
attrs
,
"|"
)
if
len
(
result
)
>
1
{
return
}
result
=
strings
.
Split
(
attrs
,
","
)
result
=
strings
.
Split
(
attrs
,
","
)
if
len
(
result
)
>
1
{
if
len
(
result
)
>
1
{
return
return
...
...
internal/logic/bom_matching.go
View file @
eff729bf
...
@@ -32,6 +32,7 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er
...
@@ -32,6 +32,7 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er
bomIdStr
:=
strconv
.
FormatInt
(
int64
(
bomId
),
10
)
bomIdStr
:=
strconv
.
FormatInt
(
int64
(
bomId
),
10
)
tableEnd
:=
string
(
bomIdStr
[
len
(
bomIdStr
)
-
1
])
tableEnd
:=
string
(
bomIdStr
[
len
(
bomIdStr
)
-
1
])
tableName
:=
"lie_bom_item_matching_"
+
tableEnd
tableName
:=
"lie_bom_item_matching_"
+
tableEnd
//批量更新每一条记录之前,要去批量更新item表的item_status
//批量更新每一条记录之前,要去批量更新item表的item_status
for
_
,
matching
:=
range
matchingList
{
for
_
,
matching
:=
range
matchingList
{
//先去数据库查询是否存在该记录,有的话修改,没有就新增
//先去数据库查询是否存在该记录,有的话修改,没有就新增
...
@@ -60,6 +61,8 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er
...
@@ -60,6 +61,8 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
//更新商品价格和库存的队列
go
UpdateGoodsPriceAndStockQueue
(
matching
.
GoodsName
)
}
}
return
nil
return
nil
}
}
...
...
internal/logic/goods.go
View file @
eff729bf
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"bom_server/configs"
"bom_server/configs"
"bom_server/internal/model"
"bom_server/internal/model"
"encoding/json"
"encoding/json"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req"
"github.com/imroc/req"
"github.com/tidwall/gjson"
"github.com/tidwall/gjson"
"strings"
"strings"
...
@@ -225,3 +226,14 @@ func MatchGoodsInfo(goods model.ApiGoods, goodsMap GoodsMap) (bomMatching model.
...
@@ -225,3 +226,14 @@ func MatchGoodsInfo(goods model.ApiGoods, goodsMap GoodsMap) (bomMatching model.
}
}
return
return
}
}
func
UpdateGoodsPriceAndStockQueue
(
goodsName
string
){
queueExchange
:=
rabbitmq
.
QueueExchange
{
"keyword_search_queue"
,
""
,
""
,
"direct"
,
configs
.
RabbitMQSetting
.
Url
,
}
rabbitmq
.
Send
(
queueExchange
,
goodsName
)
}
server/server.exe~
0 → 100644
View file @
eff729bf
The file could not be displayed because it is too large.
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