Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
刘栋
/
infynova-udi
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
605580c6
authored
May 16, 2024
by
刘栋
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
UDI-匹配规则更新
parent
bb59e340
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
16 deletions
saas-udi-service/src/main/java/com/infynova/udi/service/helper/MatchHelper.java
saas-udi-service/src/main/resources/mapper/UdiMapper.xml
saas-udi-service/src/main/java/com/infynova/udi/service/helper/MatchHelper.java
View file @
605580c6
...
...
@@ -132,35 +132,48 @@ public class MatchHelper {
private
void
match
(
Long
taskId
,
MatchData
matchData
){
// 查询udi
//Page<UdiVo> voPage = this.queryUdi(udiPageNo,pageSize,matchData);
List
<
UdiMatchRateVo
>
matchRateVoList
=
new
ArrayList
<>();
List
<
UdiMatchRateVo
>
matchRateVoAllList
=
new
ArrayList
<>();
boolean
haveHundredFlag
=
false
;
if
(
StringUtils
.
isNotBlank
(
matchData
.
getUdiCode
())){
// 去匹配udiCode
matchRateVoList
=
this
.
queryUdiNew
(
matchData
);
matchRateVoList
.
forEach
(
i
->
i
.
setSource
(
1
));
}
else
if
(
StringUtils
.
isNotBlank
(
matchData
.
getYiBaoCode
())){
List
<
UdiMatchRateVo
>
matchRateVoList
=
this
.
queryUdiNew
(
matchData
);
this
.
setSource
(
matchRateVoList
,
1
);
matchRateVoAllList
.
addAll
(
matchRateVoList
);
haveHundredFlag
=
this
.
haveHundred
(
matchRateVoList
);
}
if
(!
haveHundredFlag
&&
StringUtils
.
isNotBlank
(
matchData
.
getYiBaoCode
())){
// 去匹配YiBaoCode
matchRateVoList
=
this
.
queryYiBaoCode
(
matchData
);
matchRateVoList
.
forEach
(
i
->
i
.
setSource
(
2
));
}
else
if
(
StringUtils
.
isNotBlank
(
matchData
.
getCompanyName
())
||
StringUtils
.
isNotBlank
(
matchData
.
getProductFactoryCode
())){
List
<
UdiMatchRateVo
>
matchRateVoList
=
this
.
queryYiBaoCode
(
matchData
);
this
.
setSource
(
matchRateVoList
,
2
);
matchRateVoAllList
.
addAll
(
matchRateVoList
);
haveHundredFlag
=
this
.
haveHundred
(
matchRateVoList
);
}
if
(!
haveHundredFlag
&&
(
StringUtils
.
isNotBlank
(
matchData
.
getCompanyName
())
||
StringUtils
.
isNotBlank
(
matchData
.
getProductFactoryCode
()))
){
// 厂家+产品货号/编号
matchRateVoList
=
matchESHelper
.
three
(
matchData
.
getCompanyName
(),
matchData
.
getProductFactoryCode
());
matchRateVoList
.
forEach
(
i
->
i
.
setSource
(
3
));
}
else
if
(
StringUtils
.
isNotBlank
(
matchData
.
getBrandName
())
List
<
UdiMatchRateVo
>
matchRateVoList
=
matchESHelper
.
three
(
matchData
.
getCompanyName
(),
matchData
.
getProductFactoryCode
());
this
.
setSource
(
matchRateVoList
,
3
);
matchRateVoAllList
.
addAll
(
matchRateVoList
);
haveHundredFlag
=
this
.
haveHundred
(
matchRateVoList
);
}
if
(!
haveHundredFlag
&&
(
StringUtils
.
isNotBlank
(
matchData
.
getBrandName
())
||
StringUtils
.
isNotBlank
(
matchData
.
getProductName
())
||
StringUtils
.
isNotBlank
(
matchData
.
getSpecification
())
||
StringUtils
.
isNotBlank
(
matchData
.
getModel
()))
{
||
StringUtils
.
isNotBlank
(
matchData
.
getModel
()))
)
{
// 品牌+名称+规格+型号;
matchRateVoList
=
matchESHelper
.
four
(
matchData
.
getBrandName
(),
List
<
UdiMatchRateVo
>
matchRateVoList
=
matchESHelper
.
four
(
matchData
.
getBrandName
(),
matchData
.
getProductName
(),
matchData
.
getSpecification
(),
matchData
.
getModel
());
matchRateVoList
.
forEach
(
i
->
i
.
setSource
(
4
));
this
.
setSource
(
matchRateVoList
,
4
);
matchRateVoAllList
.
addAll
(
matchRateVoList
);
}
// 需要按照匹配率高低排序,留20条
List
<
UdiMatchRateVo
>
matchRateVoSortList
=
this
.
getTopNMatchRates
(
matchRateVoAllList
,
20
);
// 计算匹配率
List
<
MatchTemp
>
matchTempList
=
new
ArrayList
<>();
boolean
hundredRate
=
false
;
for
(
UdiMatchRateVo
udiVo
:
matchRateVoList
)
{
for
(
UdiMatchRateVo
udiVo
:
matchRateVo
Sort
List
)
{
// 核心匹配率逻辑
BigDecimal
matchRate
=
udiVo
.
getMatchRatio
();
if
(
matchRate
.
compareTo
(
ONE_HUNDRED_RATE
)
==
0
){
...
...
@@ -207,6 +220,30 @@ public class MatchHelper {
}
}
/**
* 判断是否有百分之百的数据存在
* @param list
* @return
*/
private
boolean
haveHundred
(
List
<
UdiMatchRateVo
>
list
){
for
(
UdiMatchRateVo
udiMatchRateVo
:
list
)
{
BigDecimal
matchRatio
=
udiMatchRateVo
.
getMatchRatio
();
if
(
matchRatio
.
compareTo
(
ONE_HUNDRED_RATE
)
==
0
){
return
true
;
}
}
return
false
;
}
private
List
<
UdiMatchRateVo
>
getTopNMatchRates
(
List
<
UdiMatchRateVo
>
matchRateVoAllList
,
int
n
){
// 按照 matchRatio 字段降序排序,并且保留前 n 条数据
// todo 是否需要根据id进行去重?
return
matchRateVoAllList
.
stream
()
.
sorted
((
vo1
,
vo2
)
->
vo2
.
getMatchRatio
().
compareTo
(
vo1
.
getMatchRatio
()))
.
limit
(
n
)
.
collect
(
Collectors
.
toList
());
}
/**
* 查询udi
...
...
@@ -260,7 +297,7 @@ public class MatchHelper {
}
}
return
udiMapper
.
get
Udi
CodeRegex
(
yiBaoCode
,
yiBaoCodeRegexList
);
return
udiMapper
.
get
YiBao
CodeRegex
(
yiBaoCode
,
yiBaoCodeRegexList
);
}
private
void
setSource
(
List
<
UdiMatchRateVo
>
list
,
Integer
source
){
...
...
saas-udi-service/src/main/resources/mapper/UdiMapper.xml
View file @
605580c6
...
...
@@ -101,7 +101,7 @@
FROM product as p
WHERE p.yi_bao_code = #{yiBaoCode}
OR p.yi_bao_code like CONCAT(#{yiBaoCode},'%')
<foreach
collection=
"
udi
CodeList"
item=
"item"
open=
""
close=
""
separator=
""
>
<foreach
collection=
"
yiBao
CodeList"
item=
"item"
open=
""
close=
""
separator=
""
>
OR p.yi_bao_code like CONCAT(#{item},'%')
</foreach>
ORDER BY match_ratio DESC , p.yi_bao_code DESC
...
...
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