Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
practical_train
Commits
3b1e1453
"...src/git@gitlab.ruzhoukj.com:wujipeng/practical_train.git" did not exist on "5763962b305329cffa189e2479c11c546bde70d0"
Commit
3b1e1453
authored
Aug 04, 2026
by
wujipeng
Browse files
我的成绩-汇总
parent
c48f5b07
Changes
9
Hide whitespace changes
Inline
Side-by-side
practical-api/practical-business-api/src/main/java/com/platform/business/model/dto/ExamStudentDTO.java
View file @
3b1e1453
...
...
@@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
ExamStudentDTO
extends
ExamStudentEntity
{
private
int
pageNum
;
private
int
pageSize
;
...
...
practical-api/practical-business-api/src/main/java/com/platform/business/model/entity/ExamStudentEntity.java
View file @
3b1e1453
...
...
@@ -29,8 +29,10 @@ public class ExamStudentEntity {
private
int
examId
;
@ApiModelProperty
(
value
=
"学员id"
)
private
String
studentId
;
@ApiModelProperty
(
value
=
"考试成绩"
)
private
Double
score
;
@ApiModelProperty
(
value
=
"考试开始时间"
)
...
...
practical-api/practical-business-api/src/main/java/com/platform/business/model/vo/ExamStudentVO.java
View file @
3b1e1453
package
com.platform.business.model.vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.platform.business.model.entity.ExamStudentEntity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.util.Date
;
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
ExamStudentVO
extends
ExamStudentEntity
{
@ApiModelProperty
(
value
=
"考试名称"
)
private
String
examName
;
@ApiModelProperty
(
value
=
"考试类型"
)
private
String
type
;
@ApiModelProperty
(
value
=
"班级均分"
)
private
Double
avgScore
;
@ApiModelProperty
(
value
=
"排名"
)
private
Integer
rank
;
private
String
studentName
;
private
String
className
;
private
String
examName
;
private
String
idCard
;
private
String
factory
;
private
String
phone
;
private
String
examTime
;
@ApiModelProperty
(
value
=
"考试时间"
)
@JsonFormat
(
pattern
=
"MM-dd"
,
timezone
=
"GMT+8"
)
private
Date
examTime
;
@ApiModelProperty
(
value
=
"总题数"
)
private
Integer
totalNum
;
...
...
practical-business/src/main/java/com/platform/business/controller/ExamStudentController.java
View file @
3b1e1453
package
com.platform.business.controller
;
import
com.platform.business.model.dto.ExamStudentDTO
;
import
com.platform.business.model.vo.ExamStudentVO
;
import
com.platform.business.service.ExamStudentService
;
import
com.platform.business.utils.JwtTokenUtil
;
import
com.platform.controller.BaseController
;
import
com.platform.model.resp.Result
;
import
com.platform.page.TableDataInfo
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java
x.servlet.http.HttpServletRequest
;
import
java
.util.Map
;
@RestController
@RequestMapping
(
"/exam/student"
)
public
class
ExamStudentController
extends
BaseController
{
@Resource
private
ExamStudentService
examStudentService
;
@Resource
private
JwtTokenUtil
jwtTokenUtil
;
@PostMapping
(
"/queryByStudentId"
)
public
TableDataInfo
queryByStudentId
(
@RequestBody
ExamStudentDTO
examStudentDTO
,
HttpServletRequest
httpServletRequest
)
{
String
token
=
httpServletRequest
.
getHeader
(
"Authorization"
);
String
userName
=
jwtTokenUtil
.
getUsernameFromToken
(
token
);
@ApiOperation
(
value
=
"我的成绩-成绩明细"
)
@PostMapping
(
"/page"
)
public
TableDataInfo
page
(
@RequestBody
ExamStudentDTO
examStudentDTO
)
{
startPage
(
examStudentDTO
.
getPageNum
(),
examStudentDTO
.
getPageSize
());
return
getDataTable
(
examStudentService
.
queryByStudentId
(
userName
));
return
getDataTable
(
examStudentService
.
page
(
examStudentDTO
));
}
@ApiOperation
(
value
=
"我的成绩-汇总"
)
@GetMapping
(
"/summary/{studentId}"
)
public
Result
<
Map
<
String
,
String
>>
summary
(
@PathVariable
String
studentId
)
{
return
Result
.
data
(
examStudentService
.
summary
(
studentId
));
}
}
practical-business/src/main/java/com/platform/business/mapper/ExamStudentMapper.java
View file @
3b1e1453
...
...
@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.Map
;
@Mapper
public
interface
ExamStudentMapper
extends
BaseMapper
<
ExamStudentEntity
>
{
...
...
@@ -16,11 +17,14 @@ public interface ExamStudentMapper extends BaseMapper<ExamStudentEntity> {
List
<
ExamStudentVO
>
queryByClassIdAndExamId
(
@Param
(
"classId"
)
Integer
classId
,
@Param
(
"examId"
)
Integer
examId
);
List
<
ExamStudentVO
>
queryByStudentId
(
@Param
(
"studentId"
)
String
studentId
);
List
<
ExamStudentVO
>
page
(
@Param
(
"studentId"
)
String
studentId
);
ExamStudentVO
paperDetail
(
@Param
(
"id"
)
Integer
id
);
List
<
ExamStudentVO
>
queryOneself
(
@Param
(
"userId"
)
String
userId
);
List
<
ExamStudentVO
>
queryOneselfTeacher
(
@Param
(
"userId"
)
String
userId
);
Map
<
String
,
String
>
summary
(
@Param
(
"studentId"
)
String
studentId
);
}
practical-business/src/main/java/com/platform/business/service/ExamStudentService.java
View file @
3b1e1453
package
com.platform.business.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.platform.business.model.dto.ExamStudentDTO
;
import
com.platform.business.model.entity.ExamStudentEntity
;
import
com.platform.business.model.vo.ExamStudentVO
;
import
java.util.List
;
import
java.util.Map
;
public
interface
ExamStudentService
extends
IService
<
ExamStudentEntity
>
{
...
...
@@ -18,7 +20,7 @@ public interface ExamStudentService extends IService<ExamStudentEntity> {
List
<
ExamStudentVO
>
queryByClassIdAndExamId
(
Integer
classId
,
Integer
examId
);
List
<
ExamStudentVO
>
queryByStudentId
(
String
userName
);
List
<
ExamStudentVO
>
page
(
ExamStudentDTO
examStudentDTO
);
ExamStudentVO
paperDetail
(
Integer
id
);
...
...
@@ -26,4 +28,6 @@ public interface ExamStudentService extends IService<ExamStudentEntity> {
List
<
ExamStudentVO
>
queryOneselfTeacher
(
String
userId
);
Map
<
String
,
String
>
summary
(
String
studentId
);
}
practical-business/src/main/java/com/platform/business/service/impl/ExamStaudentServiceImpl.java
View file @
3b1e1453
...
...
@@ -2,21 +2,24 @@ package com.platform.business.service.impl;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.platform.business.mapper.ExamStudentMapper
;
import
com.platform.business.model.dto.ExamStudentDTO
;
import
com.platform.business.model.entity.ExamStudentEntity
;
import
com.platform.business.model.vo.ExamStudentVO
;
import
com.platform.business.model.vo.UserVO
;
import
com.platform.business.service.ExamStudentService
;
import
com.platform.business.service.UserService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
ExamStaudentServiceImpl
extends
ServiceImpl
<
ExamStudentMapper
,
ExamStudentEntity
>
implements
ExamStudentService
{
@Resource
private
UserService
userService
;
@Override
public
List
<
ExamStudentVO
>
queryByExamId
(
int
id
)
{
return
baseMapper
.
queryByExamId
(
id
);
...
...
@@ -29,14 +32,8 @@ public class ExamStaudentServiceImpl extends ServiceImpl<ExamStudentMapper, Exam
}
@Override
public
List
<
ExamStudentVO
>
queryByStudentId
(
String
userName
){
UserVO
userVO
=
userService
.
getUserMessage
(
userName
);
String
studentId
=
userVO
.
getId
();
List
<
ExamStudentVO
>
examStudentVOList
=
baseMapper
.
queryByStudentId
(
studentId
);
for
(
ExamStudentVO
examStudentVO
:
examStudentVOList
){
examStudentVO
.
setStudentName
(
userVO
.
getNickName
());
}
return
examStudentVOList
;
public
List
<
ExamStudentVO
>
page
(
ExamStudentDTO
examStudentDTO
)
{
return
baseMapper
.
page
(
examStudentDTO
.
getStudentId
());
}
@Override
...
...
@@ -53,4 +50,17 @@ public class ExamStaudentServiceImpl extends ServiceImpl<ExamStudentMapper, Exam
public
List
<
ExamStudentVO
>
queryOneselfTeacher
(
String
userId
)
{
return
baseMapper
.
queryOneselfTeacher
(
userId
);
}
@Override
public
Map
<
String
,
String
>
summary
(
String
studentId
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<>();
Map
<
String
,
String
>
summary
=
baseMapper
.
summary
(
studentId
);
if
(
summary
!=
null
&&
!
summary
.
isEmpty
())
{
result
.
put
(
"平均成绩"
,
summary
.
get
(
"overallAvgScore"
));
result
.
put
(
"班级排名"
,
summary
.
get
(
"classRank"
));
result
.
put
(
"最高分"
,
summary
.
get
(
"highestScore"
));
result
.
put
(
"考试次数"
,
summary
.
get
(
"examCount"
));
}
return
result
;
}
}
practical-business/src/main/java/com/platform/business/service/impl/UserServiceImpl.java
View file @
3b1e1453
...
...
@@ -482,41 +482,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
return
userVO
;
}
// @Override
// public UserVO getUserMessage(String userName) {
// // 1. 获取基础用户信息
// UserVO userVO = baseMapper.queryByUserName(userName);
// if (userVO == null) {
// return null;
// }
// // 2. 获取用户所有角色
// List<SysPhoneRoleEntity> allRoles = new ArrayList<>();
// // 获取系统分配的角色
// List<SysPhoneRoleEntity> sysPhoneRoleEntities = sysPhoneRoleService.queryByPhone(userName);
// if (CollectionUtils.isNotEmpty(sysPhoneRoleEntities)) {
// allRoles.addAll(sysPhoneRoleEntities);
// }
// // 获取用户的固有角色(从userVO中)
// String roleName = userVO.getRoleName();
// if (StringUtils.isNotBlank(roleName)) {
// SysPhoneRoleEntity userRole = new SysPhoneRoleEntity();
// userRole.setRoleName(roleName);
// userRole.setPhone(userName);
// allRoles.add(userRole);
// }
// //去重
// allRoles = allRoles.stream().distinct().collect(Collectors.toList());
// // 3. 设置角色列表到userVO
// userVO.setSysPhoneRoleEntities(allRoles);
// // 4. 获取角色对应的菜单权限
// Integer roleId = userVO.getRoleId();
// if (roleId != null) {
// List<SysRoleAndMenuVO> menuList = sysRoleAndMenuService.queryByRoleId(roleId);
// userVO.setSysMenuEntities(menuList);
// }
// return userVO;
// }
@Override
public
UserVO
queryByUserName
(
String
userName
)
{
return
baseMapper
.
queryByUserName
(
userName
);
...
...
practical-business/src/main/resources/com/platform/business/mapper/ExamStudentMapper.xml
View file @
3b1e1453
...
...
@@ -46,29 +46,22 @@
and es.mark_flag = 0
</select>
<select
id=
"
queryByStudentId
"
resultType=
"com.platform.business.model.vo.ExamStudentVO"
>
select
<select
id=
"
page
"
resultType=
"com.platform.business.model.vo.ExamStudentVO"
>
SELECT
es.id,
es.score score,
es.class_id classId,
es.student_id studentId,
c.name className,
e.name examName,
e.exam_time examTime
from
e.name AS examName,
es.score,
e.exam_time AS examTime,
AVG(es.score) OVER (PARTITION BY es.exam_id) AS avgScore,
RANK() OVER (PARTITION BY es.exam_id ORDER BY es.score DESC) AS rank
FROM
exam_student es
left join
class c
on
es.class_id = c.id
left join
exam e
on
es.exam_id = e.id
where
LEFT JOIN
exam e ON es.exam_id = e.id
WHERE
es.student_id = #{studentId}
ORDER BY
STR_TO_DATE(SUBSTRING_INDEX(e.exam_time, '-', 1), '%Y.%m.%d %H:%i:%s')
DESC
e.exam_time
DESC
;
</select>
<select
id=
"paperDetail"
resultType=
"com.platform.business.model.vo.ExamStudentVO"
>
select es.id,
...
...
@@ -110,4 +103,28 @@
e.chief_id = #{userId} or e.invigilation_id like concat('%',#{userId},'%')
);
</select>
<select
id=
"summary"
resultType=
"java.util.Map"
>
SELECT
-- 所有考试的平均分:该学生的所有考试分数的平均值
ROUND(AVG(es.score), 1) AS overallAvgScore,
-- 班级排名:按班级分组,计算每个学生的总平均分,然后按总平均分降序排名
RANK() OVER (PARTITION BY es.class_id ORDER BY AVG(es.score) DESC) AS classRank,
-- 最高分:该学生所有考试中的最高得分
MAX(es.score) AS highestScore,
-- 考试次数:该学生参加的考试总次数
COUNT(es.id) AS examCount
FROM
exam_student es
LEFT JOIN
exam e
ON
es.exam_id = e.id
WHERE
es.student_id = #{studentId}
-- 建议加上分数非空判断,避免拉低平均分或影响排名准确性
AND
es.score IS NOT NULL
GROUP BY
es.class_id;
</select>
</mapper>
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