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
a794ff74
authored
Jul 29, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
封装优化
parent
fcadb0ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
4 deletions
internal/logic/attr.go
internal/logic/encap.go
internal/logic/attr.go
View file @
a794ff74
...
...
@@ -108,10 +108,11 @@ func searchAttr(bomItem model.BomItem, search *es.MultiSearchService) (result *e
//单独针对封装进行转换
if
bomItem
.
Encap
!=
""
{
//先提取出纯数字
numberR
,
_
:=
regexp
.
Compile
(
mapping
.
PureNumberRegular
)
pureNumber
:=
numberR
.
FindString
(
bomItem
.
Encap
)
//再去找对应属性
attrValue
:=
"封装"
+
"€"
+
pureNumber
//numberR, _ := regexp.Compile(mapping.PureNumberRegular)
//pureNumber := numberR.FindString(bomItem.Encap)
////再去找对应属性
//attrValue := "封装" + "€" + pureNumber
attrValue
:=
TransformEncap
(
bomItem
.
Encap
)
if
!
php2go
.
InArray
(
attrValue
,
attrsSlice
)
{
subQuery
:=
es
.
NewTermQuery
(
"attrs.attr_value"
,
attrValue
)
nestedQuery
:=
es
.
NewNestedQuery
(
"attrs"
,
subQuery
)
...
...
internal/logic/encap.go
0 → 100644
View file @
a794ff74
package
logic
import
(
"bom_server/internal/mapping"
"bom_server/internal/pkg/gredis"
"github.com/gomodule/redigo/redis"
"regexp"
)
//转换封装
func
TransformEncap
(
encap
string
)
(
attrValue
string
)
{
numberR
,
_
:=
regexp
.
Compile
(
mapping
.
PureNumberRegular
)
pureNumber
:=
numberR
.
FindString
(
encap
)
//判断是多少位数字,如果是3位,则代表可能需要往前面补零
if
len
(
pureNumber
)
==
3
{
encapCheck
:=
"0"
+
pureNumber
//补全完以后,去sku_map2尝试获取值,如果存在的话,就代表是正确的封装
attrName
,
_
:=
redis
.
String
(
gredis
.
HGet
(
"sku_map2"
,
encapCheck
))
if
attrName
!=
""
{
pureNumber
=
encapCheck
}
}
//再去找对应属性
attrValue
=
"封装"
+
"€"
+
pureNumber
return
attrValue
}
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