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
7f363b05
authored
May 28, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改匹配项
parent
4ce8c399
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
50 additions
and
34 deletions
cmd/cmd.exe~
internal/logic/bom.go
internal/logic/bom_matching.go
internal/logic/match.go
internal/service/oss.go
server/http/bom.go
server/http/bom_matching.go
server/http/main.go
cmd/cmd.exe~
View file @
7f363b05
The file could not be displayed because it is too large.
internal/logic/bom.go
View file @
7f363b05
...
...
@@ -15,6 +15,12 @@ func GetBomInfo(bomId int) (bom model.Bom) {
return
bom
}
func
GetBomBySn
(
bomSn
string
)
(
bom
model
.
Bom
)
{
//先去根据bomSn查出bomId
model
.
Db
.
Table
(
"lie_bom"
)
.
Where
(
"bom_sn = ?"
,
bomSn
)
.
First
(
&
bom
)
return
}
//获取一个完整bom数据
func
GetBomInfoWithItems
(
bomId
int
)
(
bom
model
.
Bom
)
{
var
(
...
...
internal/logic/bom_matching.go
View file @
7f363b05
...
...
@@ -23,6 +23,8 @@ func GetBomMatching(bomId, bomItemId int) (bomMatching model.BomItemMatching) {
return
bomMatching
}
//根据matchingList去修改
func
BatchSaveMatchings
(
bomId
int
,
matchingList
[]
model
.
BomItemMatching
)
(
err
error
)
{
bomIdStr
:=
strconv
.
FormatInt
(
int64
(
bomId
),
10
)
...
...
internal/logic/match.go
View file @
7f363b05
...
...
@@ -114,14 +114,15 @@ func SearchGoods(bomId int, bomItems []model.BomItem, deliveryType, sort int, wg
}
//更新单个matching
func
UpdateSingleBomMatching
(
bom
Id
int
,
bomItemId
int
,
goodsId
string
)
(
bomItemInfo
model
.
BomItem
,
err
error
)
{
func
UpdateSingleBomMatching
(
bom
Sn
string
,
bomItemId
int
,
goodsId
string
)
(
bomItemInfo
model
.
BomItem
,
err
error
)
{
responseData
,
err
:=
GetGoodsInfo
(
goodsId
)
if
err
!=
nil
{
return
}
var
bomMatchingList
[]
model
.
BomItemMatching
//先去获取对应的matching
matching
:=
GetBomMatching
(
bomId
,
bomItemId
)
bom
:=
GetBomBySn
(
bomSn
)
matching
:=
GetBomMatching
(
bom
.
BomID
,
bomItemId
)
if
len
(
responseData
.
Data
)
>
0
{
for
_
,
goods
:=
range
responseData
.
Data
{
var
goodsMap
GoodsMap
...
...
@@ -139,35 +140,20 @@ func UpdateSingleBomMatching(bomId int, bomItemId int, goodsId string) (bomItemI
bomMatchingList
=
append
(
bomMatchingList
,
bomMatching
)
}
}
err
=
BatchSaveMatchings
(
bom
Id
,
bomMatchingList
)
err
=
BatchSaveMatchings
(
bom
.
BomID
,
bomMatchingList
)
if
err
!=
nil
{
return
}
//还要返回对应的信息
bomItemInfo
=
GetBomItem
(
bom
Id
,
bomItemId
)
bomMatching
:=
GetBomMatching
(
bom
Id
,
bomItemId
)
bomItemInfo
=
GetBomItem
(
bom
.
BomID
,
bomItemId
)
bomMatching
:=
GetBomMatching
(
bom
.
BomID
,
bomItemId
)
bomItemInfo
.
Matching
=
bomMatching
return
}
//通过搜索去匹配单个matching
func
SaveSingleBomMatchingBySearch
(
bomId
int
,
bomItemId
,
deliveryType
,
sort
int
)
(
err
error
)
{
//client, err := es.NewClient(es.SetURL(configs.ESSetting.Url))
//if err != nil {
// panic(err)
//}
//defer client.Stop()
//var bomItems []model.BomItem
//bomItems = append(bomItems, bomItem)
////直接模糊匹配
//goodsMapList, err := getUpdateGoodsData(bomId, bomItems, deliveryType, client, true)
//if err != nil {
// return
//}
//err = UpdateGoodsData(goodsMapList)
//if err != nil {
// return
//}
func
SaveBomMatchingByGoodsName
(
bomId
int
,
bomItemId
int
,
goodsName
string
)
(
bomItemInfo
model
.
BomItem
,
err
error
)
{
return
}
...
...
internal/service/oss.go
View file @
7f363b05
...
...
@@ -32,8 +32,8 @@ func UploadToOss(path, fileType string) (ossPath string, err error) {
"k2"
:
php2go
.
Md5
(
php2go
.
Md5
(
nowStr
)
+
uploadKey
),
"FileType"
:
fileType
,
}
req
.
Debug
=
tru
e
file
,
err
:=
os
.
Open
(
"Bom_48.xlsx"
)
req
.
Debug
=
fals
e
file
,
err
:=
os
.
Open
(
path
)
defer
file
.
Close
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
...
...
@@ -42,7 +42,7 @@ func UploadToOss(path, fileType string) (ossPath string, err error) {
resp
,
err
:=
req
.
Post
(
url
,
req
.
FileUpload
{
File
:
file
,
FieldName
:
"upload"
,
FileName
:
"Bom_48.xlsx"
,
FileName
:
path
,
},
params
)
if
err
!=
nil
{
return
...
...
server/http/bom.go
View file @
7f363b05
...
...
@@ -4,10 +4,12 @@ import (
"bom_server/internal/common"
"bom_server/internal/service"
"github.com/gin-gonic/gin"
"strconv"
)
func
Export
(
c
*
gin
.
Context
)
{
bomId
:=
c
.
GetInt
(
"bom_id"
)
bomIdStr
:=
c
.
PostForm
(
"bom_id"
)
bomId
,
_
:=
strconv
.
Atoi
(
bomIdStr
)
ossPath
,
err
:=
service
.
Export
(
bomId
)
var
response
common
.
Response
if
err
!=
nil
{
...
...
server/http/bom_matching.go
View file @
7f363b05
...
...
@@ -9,7 +9,7 @@ import (
//刷新价格和库存接口
func
RefreshBomMatchingGoods
(
c
*
gin
.
Context
)
{
bomIdStr
,
_
:=
c
.
GetQuery
(
"bom_id"
)
bomIdStr
:=
c
.
PostForm
(
"bom_id"
)
bomId
,
_
:=
strconv
.
Atoi
(
bomIdStr
)
var
response
common
.
Response
...
...
@@ -31,15 +31,35 @@ func RefreshBomMatchingGoods(c *gin.Context) {
return
}
//
新增或者修改bom_matching
//
修改单个匹配项
func
UpdateBomMatching
(
c
*
gin
.
Context
)
{
bomSn
:=
c
.
PostForm
(
"bom_sn"
)
goodsId
:=
c
.
PostForm
(
"goods_id"
)
bomItemIdStr
:=
c
.
PostForm
(
"bom_item_id"
)
bomItemId
,
_
:=
strconv
.
Atoi
(
bomItemIdStr
)
var
response
common
.
Response
bomItemInfo
,
err
:=
logic
.
UpdateSingleBomMatching
(
bomSn
,
bomItemId
,
goodsId
)
if
err
!=
nil
{
response
.
Errcode
=
-
1
response
.
Errmsg
=
err
.
Error
()
}
else
{
response
.
Errcode
=
0
response
.
Errmsg
=
"ok"
response
.
Data
=
bomItemInfo
}
c
.
JSON
(
200
,
response
)
return
}
//通过型号去新增匹配项
func
SaveBomMatchingByGoodsName
(
c
*
gin
.
Context
)
{
bomIdStr
,
_
:=
c
.
GetQuery
(
"bom_id"
)
goods
Id
,
_
:=
c
.
GetQuery
(
"goods_id
"
)
goods
Name
,
_
:=
c
.
GetQuery
(
"goods_name
"
)
bomItemIdStr
,
_
:=
c
.
GetQuery
(
"bom_item_id"
)
bomId
,
_
:=
strconv
.
Atoi
(
bomIdStr
)
bomItemId
,
_
:=
strconv
.
Atoi
(
bomItemIdStr
)
var
response
common
.
Response
bomItemInfo
,
err
:=
logic
.
UpdateSingleBomMatching
(
bomId
,
bomItemId
,
goodsId
)
bomItemInfo
,
err
:=
logic
.
SaveBomMatchingByGoodsName
(
bomId
,
bomItemId
,
goodsName
)
if
err
!=
nil
{
response
.
Errcode
=
-
1
response
.
Errmsg
=
err
.
Error
()
...
...
server/http/main.go
View file @
7f363b05
...
...
@@ -19,9 +19,9 @@ func InitRouter() *gin.Engine {
//跨域设置
//配置列表
router
.
GE
T
(
"/bom/export"
,
Export
)
router
.
GE
T
(
"/bom_matching/refresh"
,
RefreshBomMatchingGoods
)
router
.
GE
T
(
"/bom_matching/update"
,
UpdateBomMatching
)
router
.
POS
T
(
"/bom/export"
,
Export
)
router
.
POS
T
(
"/bom_matching/refresh"
,
RefreshBomMatchingGoods
)
router
.
POS
T
(
"/bom_matching/update"
,
UpdateBomMatching
)
//router.GET("/config/list", ListConfigApi)
//router.POST("/config/rollback", RollbackConfigApi)
...
...
@@ -32,7 +32,7 @@ func InitRouter() *gin.Engine {
func
InitApiServer
()
(
err
error
)
{
router
:=
InitRouter
()
apiPort
:=
strconv
.
Itoa
(
808
0
)
apiPort
:=
strconv
.
Itoa
(
6001
0
)
s
:=
&
http
.
Server
{
Addr
:
":"
+
apiPort
,
Handler
:
router
,
...
...
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