Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vehicle-quality-review
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王飞
vehicle-quality-review
Commits
0e318103
Commit
0e318103
authored
Jul 01, 2024
by
wdy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
标准下检验项排序
parent
2ce14da7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
StandardInspectionItemRelationServiceImpl.java
...rvice/impl/StandardInspectionItemRelationServiceImpl.java
+22
-1
No files found.
quality-review/src/main/java/com/ruoyi/service/impl/StandardInspectionItemRelationServiceImpl.java
View file @
0e318103
...
...
@@ -9,7 +9,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Transactional
...
...
@@ -21,6 +25,23 @@ public class StandardInspectionItemRelationServiceImpl extends ServiceImpl<Stand
@Override
public
List
<
DictDataVO
>
getByStandardId
(
Long
standardId
)
{
return
standardInspectionItemRelationMapper
.
getListByStandardId
(
standardId
);
List
<
DictDataVO
>
list
=
standardInspectionItemRelationMapper
.
getListByStandardId
(
standardId
);
// 定义期望的排序关键字
List
<
String
>
desiredOrder
=
Arrays
.
asList
(
"sraif"
,
"grfis"
,
"trfis"
);
// 使用流API对list进行排序
List
<
DictDataVO
>
sortedList
=
new
ArrayList
<>();
// 首先,创建一个映射表,键为dictValue,值为DictDataVO对象
Map
<
String
,
DictDataVO
>
map
=
list
.
stream
().
collect
(
Collectors
.
toMap
(
DictDataVO:
:
getDictValue
,
vo
->
vo
));
// 然后,根据desiredOrder中的顺序从映射表中提取元素
for
(
String
order
:
desiredOrder
)
{
if
(
map
.
containsKey
(
order
))
{
sortedList
.
add
(
map
.
get
(
order
));
}
}
return
sortedList
;
}
}
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