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
e47d9d92
Commit
e47d9d92
authored
Feb 08, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化方案查询 新增用户uuid字段
parent
c921ec7e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
24 deletions
+60
-24
UsersMapper.xml
wisenergy-mapper/src/main/resources/mapper/UsersMapper.xml
+5
-2
User.java
...ergy-model/src/main/java/cn/wisenergy/model/app/User.java
+17
-11
VolunteerVo.java
...odel/src/main/java/cn/wisenergy/model/vo/VolunteerVo.java
+6
-0
SchemeServiceImpl.java
...java/cn/wisenergy/service/app/impl/SchemeServiceImpl.java
+32
-11
No files found.
wisenergy-mapper/src/main/resources/mapper/UsersMapper.xml
View file @
e47d9d92
...
...
@@ -7,6 +7,7 @@
<result
column=
"user_name"
property=
"userName"
/>
<result
column=
"password"
property=
"password"
/>
<result
column=
"phone"
property=
"phone"
/>
<result
column=
"uuid"
property=
"uuid"
/>
<result
column=
"head_image"
property=
"headImage"
/>
<result
column=
"sex"
property=
"sex"
/>
<result
column=
"school"
property=
"school"
/>
...
...
@@ -27,11 +28,11 @@
</sql>
<sql
id=
"cols_exclude_id"
>
user_name,password, phone,head_image,sex,school, exam_type,source,is_delete,create_time,update_time
user_name,password, phone,
uuid,
head_image,sex,school, exam_type,source,is_delete,create_time,update_time
</sql>
<sql
id=
"vals"
>
#{userName},#{password},#{phone},#{headImage},#{sex},#{school},#{examType}, #{source},
#{userName},#{password},#{phone},#{
uuid},#{
headImage},#{sex},#{school},#{examType}, #{source},
#{isDelete},now(),now()
</sql>
...
...
@@ -39,6 +40,7 @@
<if
test=
"userName != null"
>
user_name = #{userName},
</if>
<if
test=
"password != null"
>
password =#{password},
</if>
<if
test=
"phone != null"
>
phone =#{phone},
</if>
<if
test=
"uuid != null"
>
uuid =#{uuid},
</if>
<if
test=
"headImage != null"
>
head_image =#{headImage},
</if>
<if
test=
"sex != null"
>
sex =#{sex},
</if>
<if
test=
"school != null"
>
school =#{school},
</if>
...
...
@@ -53,6 +55,7 @@
<if
test=
"userName != null"
>
and user_name = #{userName}
</if>
<if
test=
"password != null"
>
and password =#{password}
</if>
<if
test=
"phone != null"
>
and phone =#{phone}
</if>
<if
test=
"uuid != null"
>
and uuid =#{uuid}
</if>
<if
test=
"headImage != null"
>
and head_image =#{headImage}
</if>
<if
test=
"sex != null"
>
and sex =#{sex}
</if>
<if
test=
"school != null"
>
and school =#{school}
</if>
...
...
wisenergy-model/src/main/java/cn/wisenergy/model/app/User.java
View file @
e47d9d92
...
...
@@ -24,37 +24,43 @@ public class User implements Serializable {
/**
* 主键id
*/
@ApiModelProperty
(
name
=
"id"
,
value
=
"用户主键id"
)
@ApiModelProperty
(
name
=
"id"
,
value
=
"用户主键id"
)
private
Integer
id
;
/**
* 用户名称
*/
@ApiModelProperty
(
name
=
"name"
,
value
=
"用户名"
)
@ApiModelProperty
(
name
=
"name"
,
value
=
"用户名"
)
private
String
userName
;
/**
* 密码
*/
@ApiModelProperty
(
name
=
"password"
,
value
=
"用户密码"
)
@ApiModelProperty
(
name
=
"password"
,
value
=
"用户密码"
)
private
String
password
;
/**
* 电话号码
*/
@ApiModelProperty
(
name
=
"phone"
,
value
=
"手机号"
)
@ApiModelProperty
(
name
=
"phone"
,
value
=
"手机号"
)
private
String
phone
;
/**
* 头像
*/
@ApiModelProperty
(
name
=
"headImage"
,
value
=
"头像"
)
@ApiModelProperty
(
name
=
"headImage"
,
value
=
"头像"
)
private
String
headImage
;
/**
* 微信uuid
*/
@ApiModelProperty
(
name
=
"微信uuid"
,
value
=
"uuid"
)
private
String
uuid
;
/**
* 性别
*/
@ApiModelProperty
(
name
=
"sex"
,
value
=
"用户性别:0:男,1:女"
)
@ApiModelProperty
(
name
=
"sex"
,
value
=
"用户性别:0:男,1:女"
)
private
Integer
sex
;
/**
...
...
@@ -66,29 +72,29 @@ public class User implements Serializable {
/**
* 学生类型
*/
@ApiModelProperty
(
name
=
"examType"
,
value
=
"考生类型 1:文化课考生 2:美术生 3:体育生 4:文学编导考生"
)
@ApiModelProperty
(
name
=
"examType"
,
value
=
"考生类型 1:文化课考生 2:美术生 3:体育生 4:文学编导考生"
)
private
Integer
examType
;
/**
* 来源 1:电脑端 2: 手机端
*/
@ApiModelProperty
(
name
=
"source"
,
value
=
"来源 1:电脑端 2: 手机端"
)
@ApiModelProperty
(
name
=
"source"
,
value
=
"来源 1:电脑端 2: 手机端"
)
private
Integer
source
;
/**
* 是否删除
*/
@ApiModelProperty
(
name
=
"isDelete"
,
value
=
"是否删除 0:正常 1:删除"
)
@ApiModelProperty
(
name
=
"isDelete"
,
value
=
"是否删除 0:正常 1:删除"
)
private
Integer
isDelete
;
/**
* 创建时间
*/
@ApiModelProperty
(
name
=
"createTime"
,
value
=
"创建时间"
)
@ApiModelProperty
(
name
=
"createTime"
,
value
=
"创建时间"
)
private
Date
createTime
;
/**
* 修改时间
*/
@ApiModelProperty
(
name
=
"updateTime"
,
value
=
"修改时间"
)
@ApiModelProperty
(
name
=
"updateTime"
,
value
=
"修改时间"
)
private
Date
updateTime
;
}
wisenergy-model/src/main/java/cn/wisenergy/model/vo/VolunteerVo.java
View file @
e47d9d92
...
...
@@ -28,6 +28,12 @@ public class VolunteerVo {
@ApiModelProperty
(
value
=
"方案记录id"
,
name
=
"recordId"
)
private
Integer
recordId
;
/**
* 返回志愿总数
*/
@ApiModelProperty
(
value
=
"返回志愿总数"
,
name
=
"total"
)
private
Integer
total
;
/**
* 志愿信息列表
*/
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/SchemeServiceImpl.java
View file @
e47d9d92
...
...
@@ -243,7 +243,7 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
//6保存用户方案记录、志愿之间的关联关系,扣减查询次数
R
<
Integer
>
bool
=
volunteerManager
.
saveUserVolunteer
(
user
,
list
,
scoreInfo
,
queryVo
.
getBigMajorNames
());
if
(
null
!=
bool
&&
bool
.
getCode
()
==
500
)
{
if
(
null
!=
bool
&&
bool
.
getCode
()
==
500
)
{
return
R
.
error
(
"保存方案查询记录失败!"
);
}
...
...
@@ -253,6 +253,7 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
assert
bool
!=
null
;
volunteerVo
.
setRecordId
(
bool
.
getData
());
volunteerVo
.
setVolunteers
(
list
);
volunteerVo
.
setTotal
(
list
.
size
());
return
R
.
ok
(
volunteerVo
);
}
...
...
@@ -714,16 +715,23 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
private
List
<
Volunteer
>
getVolunteerList
(
List
<
Volunteer
>
list
,
Integer
total
)
{
List
<
Volunteer
>
result
=
new
ArrayList
<>();
List
<
Volunteer
>
otherList
=
new
ArrayList
<>();
//分组,每组数量大于2的,取两条,小于等于则全取
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
()));
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
);
}
otherList
.
addAll
(
volunteers
);
}
else
{
result
.
addAll
(
volunteer
List
);
result
.
addAll
(
volunteer
s
);
}
if
(
result
.
size
()
>=
total
)
{
...
...
@@ -731,17 +739,22 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
}
}
//从剩下来的数据中再重复上步操作
if
(
result
.
size
()
<
total
)
{
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
())
{
for
(
Map
.
Entry
<
String
,
List
<
Volunteer
>>
entry
:
map
B
.
entrySet
())
{
List
<
Volunteer
>
volunteerList
=
entry
.
getValue
();
if
(
volunteerList
.
size
()
>
2
)
{
result
.
addAll
(
volunteerList
.
subList
(
0
,
2
));
otherListB
.
addAll
(
volunteerList
.
subList
(
2
,
volunteerList
.
size
()));
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
Random
mRandom
=
new
Random
();
int
number
=
mRandom
.
nextInt
(
volunteerList
.
size
());
result
.
add
(
volunteerList
.
get
(
number
));
volunteerList
.
remove
(
number
);
}
otherListB
.
addAll
(
volunteerList
);
}
else
{
result
.
addAll
(
volunteerList
);
}
...
...
@@ -751,12 +764,20 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
}
}
//从剩下的数据中随机抽取,添满数组
if
(
result
.
size
()
<
total
)
{
int
number
=
total
-
result
.
size
();
List
<
Volunteer
>
volunteers
=
otherListB
.
subList
(
0
,
number
);
List
<
Volunteer
>
volunteers
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
number
;
i
++)
{
Random
mRandom
=
new
Random
();
int
count
=
mRandom
.
nextInt
(
otherListB
.
size
());
volunteers
.
add
(
otherListB
.
get
(
count
));
otherListB
.
remove
(
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