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
d2f1a65d
Commit
d2f1a65d
authored
Apr 01, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化查询方案2
parent
91921606
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
16 deletions
+39
-16
SchemeServiceImpl.java
...java/cn/wisenergy/service/app/impl/SchemeServiceImpl.java
+39
-16
No files found.
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/SchemeServiceImpl.java
View file @
d2f1a65d
...
...
@@ -250,15 +250,15 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
return
R
.
ok
(
volunteerVo
);
}
//6保存用户方案记录、志愿之间的关联关系,扣减查询次数
R
<
Integer
>
bool
=
volunteerManager
.
saveUserVolunteer
(
user
,
list
,
scoreInfo
,
queryVo
.
getBigMajorNames
());
if
(
null
!=
bool
&&
bool
.
getCode
()
==
500
)
{
return
R
.
error
(
bool
.
getMessage
());
}
//
//6保存用户方案记录、志愿之间的关联关系,扣减查询次数
//
R<Integer> bool = volunteerManager.saveUserVolunteer(user, list, scoreInfo, queryVo.getBigMajorNames());
//
if (null != bool && bool.getCode() == 500) {
//
return R.error(bool.getMessage());
//
}
volunteerVo
.
setUserId
(
user
.
getId
());
assert
bool
!=
null
;
volunteerVo
.
setRecordId
(
bool
.
getData
());
//
assert bool != null;
//
volunteerVo.setRecordId(bool.getData());
//设置查询时间
SetQueryTime
(
list
);
...
...
@@ -709,7 +709,6 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
SchemeTypeEnums
.
UNDERGRADUATE_CULTURE
.
getCode
());
list
.
addAll
(
fillList
);
}
}
else
{
//考生的分数是在专科一批中
double
upGrade
=
secondCulture
+
secondRule
.
getUpMark
();
...
...
@@ -1048,14 +1047,14 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
List
<
Volunteer
>
result
=
new
ArrayList
<>();
List
<
Volunteer
>
otherList
=
new
ArrayList
<>();
//分组,每组数量大于
4的,取4
条,小于等于则全取
//分组,每组数量大于
2的,取2
条,小于等于则全取
Map
<
Double
,
List
<
Volunteer
>>
map
=
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
Volunteer:
:
getLowestMark
));
for
(
Map
.
Entry
<
Double
,
List
<
Volunteer
>>
entry
:
map
.
entrySet
())
{
List
<
Volunteer
>
volunteers
=
entry
.
getValue
();
if
(
volunteers
.
size
()
>
4
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
if
(
volunteers
.
size
()
>
2
)
{
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
Random
mRandom
=
new
Random
();
int
number
=
mRandom
.
nextInt
(
volunteers
.
size
());
result
.
add
(
volunteers
.
get
(
number
));
...
...
@@ -1071,19 +1070,43 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
}
}
//分组,每组数量大于2的,取2条,小于等于则全取
Map
<
Double
,
List
<
Volunteer
>>
mapOther
=
otherList
.
stream
().
collect
(
Collectors
.
groupingBy
(
Volunteer:
:
getLowestMark
));
List
<
Volunteer
>
endList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
Double
,
List
<
Volunteer
>>
entry
:
mapOther
.
entrySet
())
{
List
<
Volunteer
>
volunteers
=
entry
.
getValue
();
if
(
volunteers
.
size
()
>
2
)
{
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
Random
mRandom
=
new
Random
();
int
number
=
mRandom
.
nextInt
(
volunteers
.
size
());
result
.
add
(
volunteers
.
get
(
number
));
volunteers
.
remove
(
number
);
}
endList
.
addAll
(
volunteers
);
}
else
{
result
.
addAll
(
volunteers
);
}
if
(
result
.
size
()
>=
total
)
{
return
result
.
subList
(
0
,
total
);
}
}
//从剩下的数据中随机抽取,添满数组
if
(
result
.
size
()
<
total
)
{
int
number
=
total
-
result
.
size
();
List
<
Volunteer
>
volunteers
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
number
;
i
++)
{
Random
mRandom
=
new
Random
();
int
count
=
mRandom
.
nextInt
(
other
List
.
size
());
if
(
result
.
contains
(
other
List
.
get
(
count
)))
{
other
List
.
remove
(
count
);
int
count
=
mRandom
.
nextInt
(
end
List
.
size
());
if
(
result
.
contains
(
end
List
.
get
(
count
)))
{
end
List
.
remove
(
count
);
continue
;
}
volunteers
.
add
(
other
List
.
get
(
count
));
other
List
.
remove
(
count
);
volunteers
.
add
(
end
List
.
get
(
count
));
end
List
.
remove
(
count
);
}
result
.
addAll
(
volunteers
);
}
...
...
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