Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
V
volunteer_service
Project
Project
Details
Activity
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
licc
volunteer_service
Commits
2d0cf026
Commit
2d0cf026
authored
Feb 07, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化方案查询
parent
12c10f66
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
12 deletions
+37
-12
Volunteer.java
...model/src/main/java/cn/wisenergy/model/app/Volunteer.java
+0
-1
SchemeServiceImpl.java
...java/cn/wisenergy/service/app/impl/SchemeServiceImpl.java
+37
-11
No files found.
wisenergy-model/src/main/java/cn/wisenergy/model/app/Volunteer.java
View file @
2d0cf026
...
...
@@ -144,5 +144,4 @@ public class Volunteer implements Serializable {
private
Date
queryTime
;
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/SchemeServiceImpl.java
View file @
2d0cf026
...
...
@@ -711,23 +711,49 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
*/
private
List
<
Volunteer
>
getVolunteerList
(
List
<
Volunteer
>
list
,
Integer
total
)
{
List
<
Volunteer
>
result
=
new
ArrayList
<>();
result
.
add
(
list
.
get
(
0
));
List
<
Volunteer
>
otherList
=
new
ArrayList
<>();
List
<
String
>
grades
=
new
ArrayList
<>();
grades
.
add
(
list
.
get
(
0
).
getLowestMark
());
for
(
Volunteer
volunteer
:
list
)
{
if
(!
grades
.
contains
(
volunteer
.
getLowestMark
())
&&
result
.
size
()
<=
total
)
{
grades
.
add
(
volunteer
.
getLowestMark
());
result
.
add
(
volunteer
);
Map
<
String
,
List
<
Volunteer
>>
map
=
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
Volunteer:
:
getLowestMark
));
for
(
Map
.
Entry
<
String
,
List
<
Volunteer
>>
entry
:
map
.
entrySet
())
{
List
<
Volunteer
>
volunteerList
=
entry
.
getValue
();
if
(
volunteerList
.
size
()
>
2
)
{
result
.
addAll
(
volunteerList
.
subList
(
0
,
2
));
otherList
.
addAll
(
volunteerList
.
subList
(
2
,
volunteerList
.
size
()));
}
else
{
otherList
.
add
(
volunteer
);
result
.
addAll
(
volunteerList
);
}
if
(
result
.
size
()
>=
total
)
{
return
result
.
subList
(
0
,
total
);
}
}
if
(
result
.
size
()
<
total
)
{
int
number
=
total
-
result
.
size
();
List
<
Volunteer
>
volunteers
=
otherList
.
subList
(
0
,
number
);
result
.
addAll
(
volunteers
);
List
<
Volunteer
>
otherListB
=
new
ArrayList
<>();
Map
<
String
,
List
<
Volunteer
>>
mapB
=
otherList
.
stream
().
collect
(
Collectors
.
groupingBy
(
Volunteer:
:
getLowestMark
));
for
(
Map
.
Entry
<
String
,
List
<
Volunteer
>>
entry
:
map
.
entrySet
())
{
List
<
Volunteer
>
volunteerList
=
entry
.
getValue
();
if
(
volunteerList
.
size
()
>
2
)
{
result
.
addAll
(
volunteerList
.
subList
(
0
,
2
));
otherListB
.
addAll
(
volunteerList
.
subList
(
2
,
volunteerList
.
size
()));
}
else
{
result
.
addAll
(
volunteerList
);
}
if
(
result
.
size
()
>=
total
)
{
return
result
.
subList
(
0
,
total
);
}
}
if
(
result
.
size
()
<
total
)
{
int
number
=
total
-
result
.
size
();
List
<
Volunteer
>
volunteers
=
otherListB
.
subList
(
0
,
number
);
result
.
addAll
(
volunteers
);
}
}
return
result
;
}
...
...
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