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
5e7012e7
authored
Dec 09, 2022
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复状态问题
parent
4ac71f84
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
27 deletions
cmd/main.go
internal/logic/search.go
cmd/main.go
View file @
5e7012e7
...
...
@@ -9,6 +9,28 @@ import (
)
func
main
()
{
//str := `[{"took":589,"_scroll_id":"","hits":{"total":0,"max_score":null,"hits":[]},"suggest":null,"aggregations":null,"timed_out":false,"_shards":{"total":52,"successful":52,"failed":0}},{"took":589,"_scroll_id":"","hits":{"total":6,"max_score":null,"hits":[{"_score":null,"_shard":"","_node":"","_index":"arrow","_type":"goods","_id":"1162089540906902661","_uid":"","_routing":"","_parent":"","_version":null,"sort":[1],"highlight":null,"_source":{"goods_id":1162089540906902661,"old_goods_id":18001413253,"goods_name":"PDTC114YT215","auto_goods_name":"PDTC114YT215","brand_id":"3337","brand_name":"NEXPERIA","supplier_name":"arrow","class_id1":13396,"class_id2":13413,"class_id3":727,"spu_id":"2151033534835851509","sale_time":1620895410,"moq":1,"goods_details":"","create_time":1620895410,"update_time":1670501715,"single_price":0.0995,"stock":15,"goods_status":1,"status":1,"sort":31,"encoded":"","encap":"866990","canal_new":"","stock_sort":3,"single_price_sort":3,"has_price_us":1,"standard_brand_id":"162","standard_brand_name":"NEXPERIA","alike_spu_name":"","alike_spu_id":"","brand_sort":999,"attr_pf":"NPN - 预偏压 50V 250mW TO-236AB","es_update_time":1670501718},"fields":null,"_explanation":null,"matched_queries":null,"inner_hits":null,"_nested":null}]},"suggest":null,"aggregations":null,"timed_out":false,"_shards":{"total":52,"successful":52,"failed":0}},{"took":617,"_scroll_id":"","hits":{"total":6,"max_score":null,"hits":[{"_score":null,"_shard":"","_node":"","_index":"arrow","_type":"goods","_id":"1151126873221432303","_uid":"","_routing":"","_parent":"","_version":null,"sort":[1],"highlight":null,"_source":{"goods_id":1151126873221432303,"old_goods_id":18000127410,"goods_name":"MJD44H11T4G","auto_goods_name":"MJD44H11T4G","brand_id":"266","brand_name":"ON","supplier_name":"arrow","class_id1":13396,"class_id2":13412,"class_id3":727,"spu_id":"2151051928465175908","sale_time":1511268732,"moq":1,"goods_details":"","create_time":1511268732,"update_time":1670467507,"single_price":0.341,"stock":1151,"goods_status":1,"status":1,"sort":31,"encoded":"","encap":"TO-252","canal_new":"","stock_sort":3,"single_price_sort":3,"has_price_us":1,"standard_brand_id":"177","standard_brand_name":"ON","alike_spu_name":"","alike_spu_id":"","brand_sort":999,"attr_pf":"NPN 80V 1µA 1.75W DPAK","es_update_time":1670467508},"fields":null,"_explanation":null,"matched_queries":null,"inner_hits":null,"_nested":null}]},"suggest":null,"aggregations":null,"timed_out":false,"_shards":{"total":52,"successful":52,"failed":0}},{"took":587,"_scroll_id":"","hits":{"total":0,"max_score":null,"hits":[]},"suggest":null,"aggregations":null,"timed_out":false,"_shards":{"total":52,"successful":52,"failed":0}},{"took":680,"_scroll_id":"","hits":{"total":11,"max_score":null,"hits":[{"_score":null,"_shard":"","_node":"","_index":"mouser","_type":"goods","_id":"1151052563279798228","_uid":"","_routing":"","_parent":"","_version":null,"sort":[1],"highlight":null,"_source":{"goods_id":1151052563279798228,"old_goods_id":25002361773,"goods_name":"FH1210S05SVA54","auto_goods_name":"FH1210S05SVA54","brand_id":"2141","brand_name":"HIROSE","supplier_name":"mouser","class_id1":13883,"class_id2":13893,"class_id3":1114,"spu_id":"2151038936358016701","sale_time":1510525632,"moq":1,"goods_details":"","create_time":1510525632,"update_time":1670441423,"single_price":0.5747,"stock":10513,"goods_status":1,"status":1,"sort":31,"encoded":"","encap":"","canal_new":"","stock_sort":3,"single_price_sort":3,"has_price_us":1,"standard_brand_id":"94","standard_brand_name":"HRS","alike_spu_name":"","alike_spu_id":"","brand_sort":999,"attr_pf":"触头,垂直 - 单侧 10 0.020\"(0.50mm)","es_update_time":1670441436},"fields":null,"_explanation":null,"matched_queries":null,"inner_hits":null,"_nested":null}]},"suggest":null,"aggregations":null,"timed_out":false,"_shards":{"total":52,"successful":52,"failed":0}}]`
//arr := gjson.Parse(str).Array()
////common.PrintDebug(arr)
//
//for K, _ := range arr {
//
// //println(arr[K].Raw)
// goods_info := arr[K].Raw
// gjArray := gjson.Get(goods_info, "hits.hits.#._source").Array()
// for _, b := range gjArray {
// println(b.String())
// println(b.Get("goods_name").String())
//
// common.PrintDebug("search-返回数据:")
// common.PrintDebug(b.Get("goods_name").String())
// break
// }
//}
//
//return
var
path
string
flag
.
StringVar
(
&
path
,
"config"
,
"../conf/config.ini"
,
"../conf/config.ini"
)
flag
.
Parse
()
...
...
internal/logic/search.go
View file @
5e7012e7
...
...
@@ -48,15 +48,6 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
return
nil
,
err
}
res
,
err
:=
search
.
Do
(
context
.
Background
())
common
.
PrintDebug
(
res
.
Responses
)
v
,
err
:=
json
.
Marshal
(
res
.
Responses
)
common
.
PrintDebug
(
"格式化数据:"
+
string
(
v
))
gjArray
:=
gjson
.
Get
(
string
(
v
),
"hits.hits.#._source"
)
.
Array
()
if
err
!=
nil
{
return
}
...
...
@@ -64,28 +55,33 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
return
}
for
key
,
item
:=
range
gjArray
{
v
,
_
:=
json
.
Marshal
(
res
.
Responses
)
common
.
PrintDebug
(
"格式化数据:"
+
string
(
v
))
arr
:=
gjson
.
Parse
(
string
(
v
))
.
Array
()
common
.
PrintDebug
(
"search-返回数据:"
)
common
.
PrintDebug
(
item
)
for
key
,
_
:=
range
arr
{
goods_info
:=
arr
[
key
]
.
Raw
gjArray
:=
gjson
.
Get
(
goods_info
,
"hits.hits.#._source"
)
.
Array
()
for
_
,
item
:=
range
gjArray
{
println
(
item
.
Get
(
"goods_name"
)
.
String
())
if
item
.
Get
(
"goods_name"
)
.
String
()
==
""
{
if
item
.
Get
(
"goods_name"
)
.
String
()
==
""
{
break
}
var
goodsMap
GoodsMap
goodsMap
.
GoodsId
=
item
.
Get
(
"goods_id"
)
.
String
()
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
)
common
.
PrintDebug
(
"search-返回数据:"
)
common
.
PrintDebug
(
goodsMap
)
break
}
var
goodsMap
GoodsMap
goodsMap
.
GoodsId
=
item
.
Get
(
"goods_id"
)
.
String
()
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
)
common
.
PrintDebug
(
"search-返回数据:"
)
common
.
PrintDebug
(
goodsMap
)
break
}
////因为是多重查询,所以会有多套结果
...
...
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