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
b49243be
authored
Dec 09, 2022
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复状态问题
parent
1bf9ad55
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
16 deletions
internal/logic/goods.go
internal/logic/search.go
internal/logic/goods.go
View file @
b49243be
...
...
@@ -131,8 +131,7 @@ func GetGoodsInfo(goodsIdsStr string) (goodsList []model.ApiGoods, err error) {
goods
.
Mpl
=
int
(
data
.
Get
(
"mpl"
)
.
Int
())
goods
.
Encap
=
data
.
Get
(
"encap"
)
.
String
()
goods
.
SupplierID
=
int
(
data
.
Get
(
"supplier_id"
)
.
Int
())
//goods.Status = int(data.Get("status").Int())
goods
.
Status
=
1
goods
.
Status
=
int
(
data
.
Get
(
"status"
)
.
Int
())
goods
.
GoodsType
=
int
(
data
.
Get
(
"goods_type"
)
.
Int
())
goods
.
AcType
=
int
(
data
.
Get
(
"ac_type"
)
.
Int
())
var
ladderPrice
[]
model
.
LadderPrice
...
...
internal/logic/search.go
View file @
b49243be
...
...
@@ -6,6 +6,7 @@ import (
"bom_server/internal/model"
"context"
"encoding/json"
"github.com/tidwall/gjson"
es
"gopkg.in/olivere/elastic.v5"
"strings"
)
...
...
@@ -50,27 +51,23 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
common
.
PrintDebug
(
res
.
Responses
)
v
,
err
:=
json
.
Marshal
(
res
.
Responses
)
gjArray
:=
gjson
.
Get
(
string
(
v
),
"hits.hits.#._source"
)
.
Array
()
if
err
!=
nil
{
return
}
if
len
(
res
.
Responses
)
==
0
{
return
}
//因为是多重查询,所以会有多套结果
for
key
,
responses
:=
range
res
.
Responses
{
//有数据进行转换
if
responses
.
Hits
!=
nil
{
for
_
,
hit
:=
range
responses
.
Hits
.
Hits
{
var
goods
model
.
Goods
err
:=
json
.
Unmarshal
(
*
hit
.
Source
,
&
goods
)
if
err
!=
nil
{
return
nil
,
err
}
if
goods
.
GoodsName
==
""
{
for
key
,
item
:=
range
gjArray
{
if
item
.
Get
(
"goods_name"
)
.
String
()
==
""
{
break
}
var
goodsMap
GoodsMap
goodsMap
.
GoodsId
=
hit
.
Id
goodsMap
.
GoodsId
=
item
.
Get
(
"goods_id"
)
.
String
()
goodsMap
.
Amount
=
bomItems
[
key
]
.
Amount
goodsMap
.
Number
=
bomItems
[
key
]
.
Number
goodsMap
.
GoodsName
=
bomItems
[
key
]
.
GoodsName
...
...
@@ -78,10 +75,40 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
goodsMap
.
BomId
=
bomId
goodsMap
.
DeliveryType
=
deliveryType
goodsMapList
=
append
(
goodsMapList
,
goodsMap
)
common
.
PrintDebug
(
goodsMap
)
break
}
}
}
////因为是多重查询,所以会有多套结果
//for key, responses := range res.Responses {
// //有数据进行转换
// if responses.Hits != nil {
// for _, hit := range responses.Hits.Hits {
// //var goods model.Goods
// err := json.Unmarshal(*hit.Source, &goods)
// if err != nil {
// return nil, err
// }
// source := *hit.Source
// goodsNameObj := gjson.Get(source, "hit.Source.GoodsName")
// if goodsNameObj.String() == "" {
// break
// }
// var goodsMap GoodsMap
// goodsMap.GoodsId = hit.Id
// goodsMap.Amount = bomItems[key].Amount
// goodsMap.Number = bomItems[key].Number
// goodsMap.GoodsName = bomItems[key].GoodsName
// goodsMap.BomItemId = bomItems[key].BomItemID
// goodsMap.BomId = bomId
// goodsMap.DeliveryType = deliveryType
// goodsMapList = append(goodsMapList, goodsMap)
// break
// }
// }
//}
common
.
PrintDebug
(
"search end"
)
return
...
...
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