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
6d55a733
authored
May 29, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善
parent
8fed8855
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
6 deletions
cmd/cmd.exe~
cmd/queue/bom.go
internal/logic/bom_item.go
internal/logic/bom_matching.go
internal/logic/match.go
cmd/cmd.exe~
View file @
6d55a733
The file could not be displayed because it is too large.
cmd/queue/bom.go
View file @
6d55a733
...
@@ -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":1
7
5,"delivery_type":1,"sort":1}`
str
:=
`{"bom_id":1
9
5,"delivery_type":1,"sort":1}`
rabbitmq
.
Send
(
queueExchange
,
str
)
rabbitmq
.
Send
(
queueExchange
,
str
)
}
}
...
...
internal/logic/bom_item.go
View file @
6d55a733
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"bom_server/internal/model"
"bom_server/internal/model"
"encoding/json"
"encoding/json"
"errors"
"errors"
"fmt"
es
"gopkg.in/olivere/elastic.v5"
es
"gopkg.in/olivere/elastic.v5"
"strconv"
"strconv"
)
)
...
@@ -45,6 +46,12 @@ func UpdateNoMatchBomItem(bomItems []model.BomItem) (err error) {
...
@@ -45,6 +46,12 @@ func UpdateNoMatchBomItem(bomItems []model.BomItem) (err error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
matchingDelStatus
:=
2
err
=
model
.
Db
.
Table
(
"lie_bom_item_matching_"
+
tableEnd
)
.
Where
(
"bom_item_id IN (?)"
,
updateIdList
)
.
Updates
(
map
[
string
]
interface
{}{
"status"
:
matchingDelStatus
})
.
Error
if
err
!=
nil
{
return
}
return
nil
return
nil
}
}
...
@@ -81,12 +88,17 @@ func UpdateBomItem(bomId, bomItemId int) (err error) {
...
@@ -81,12 +88,17 @@ func UpdateBomItem(bomId, bomItemId int) (err error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
err
=
UpdateGoodsData
(
goodsMapList
)
fmt
.
Println
(
goodsMapList
)
if
len
(
goodsMapList
)
==
0
{
if
len
(
goodsMapList
)
==
0
{
err
=
UpdateNoMatchBomItem
(
bomItems
)
err
=
UpdateNoMatchBomItem
(
bomItems
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
}
else
{
err
=
UpdateGoodsData
(
goodsMapList
)
if
err
!=
nil
{
return
}
}
}
return
return
}
}
internal/logic/bom_matching.go
View file @
6d55a733
...
@@ -33,7 +33,10 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er
...
@@ -33,7 +33,10 @@ func BatchSaveMatchings(bomId int, matchingList []model.BomItemMatching) (err er
tableEnd
:=
string
(
bomIdStr
[
len
(
bomIdStr
)
-
1
])
tableEnd
:=
string
(
bomIdStr
[
len
(
bomIdStr
)
-
1
])
tableName
:=
"lie_bom_item_matching_"
+
tableEnd
tableName
:=
"lie_bom_item_matching_"
+
tableEnd
var
isBuyBomItemIdList
,
noBuyBomItemIdList
[]
int
var
isBuyBomItemIdList
,
noBuyBomItemIdList
[]
int
for
_
,
matching
:=
range
matchingList
{
for
k
,
matching
:=
range
matchingList
{
if
k
==
1
||
k
==
2
||
k
==
3
{
time
.
Sleep
(
2
*
time
.
Second
)
}
//先去数据库查询是否存在该记录,有的话修改,没有就新增
//先去数据库查询是否存在该记录,有的话修改,没有就新增
var
match
model
.
BomItemMatching
var
match
model
.
BomItemMatching
model
.
Db
.
Table
(
tableName
)
.
Where
(
"bom_item_id = ?"
,
matching
.
BomItemID
)
.
First
(
&
match
)
model
.
Db
.
Table
(
tableName
)
.
Where
(
"bom_item_id = ?"
,
matching
.
BomItemID
)
.
First
(
&
match
)
...
...
internal/logic/match.go
View file @
6d55a733
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
"context"
"context"
"encoding/json"
"encoding/json"
"errors"
"errors"
"
fmt
"
"
github.com/prometheus/common/log
"
es
"gopkg.in/olivere/elastic.v5"
es
"gopkg.in/olivere/elastic.v5"
"math"
"math"
"regexp"
"regexp"
...
@@ -53,9 +53,9 @@ func MatchGoods(message model.BomMessage) (err error) {
...
@@ -53,9 +53,9 @@ func MatchGoods(message model.BomMessage) (err error) {
}
}
go
func
()
{
go
func
()
{
if
err
:=
SearchGoods
(
bomId
,
bomData
,
message
.
DeliveryType
,
message
.
Sort
,
&
wg
);
err
!=
nil
{
if
err
:=
SearchGoods
(
bomId
,
bomData
,
message
.
DeliveryType
,
message
.
Sort
,
&
wg
);
err
!=
nil
{
fmt
.
Println
(
err
)
log
.
Error
(
err
)
}
}
}()
}()
}
}
wg
.
Wait
()
wg
.
Wait
()
//全部处理完以后要去修改主表的同步状态
//全部处理完以后要去修改主表的同步状态
...
...
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