feat(system): 新增学生心理评级查询功能
- 添加了 StudentMentalRatingVo 类用于查询结果封装 - 在 StudentMentalRatingMapper 中新增了两个查询方法: - selectLatestByTeacherIdWithConditions:查询辅导员负责的每个学生的最新心理评级记录 - selectLatestAllWithConditions:查询所有学生的最新心理评级记录 - 更新了 WeChatMentalAlertController,添加了新的查询接口 - 优化了查询逻辑,支持条件查询和分页功能
This commit is contained in:
@@ -4,11 +4,14 @@ import com.srs.common.core.controller.BaseController;
|
|||||||
import com.srs.common.core.domain.AjaxResult;
|
import com.srs.common.core.domain.AjaxResult;
|
||||||
import com.srs.common.core.domain.entity.SysUser;
|
import com.srs.common.core.domain.entity.SysUser;
|
||||||
import com.srs.common.core.domain.model.LoginUser;
|
import com.srs.common.core.domain.model.LoginUser;
|
||||||
|
import com.srs.common.core.page.TableDataInfo;
|
||||||
import com.srs.common.utils.WeChatUtil;
|
import com.srs.common.utils.WeChatUtil;
|
||||||
import com.srs.framework.web.service.TokenService;
|
import com.srs.framework.web.service.TokenService;
|
||||||
import com.srs.system.domain.StudentMentalRating;
|
import com.srs.system.domain.StudentMentalRating;
|
||||||
|
import com.srs.system.domain.vo.StudentMentalRatingVo;
|
||||||
import com.srs.system.mapper.StudentMentalRatingMapper;
|
import com.srs.system.mapper.StudentMentalRatingMapper;
|
||||||
import com.srs.system.mapper.SysUserMapper;
|
import com.srs.system.mapper.SysUserMapper;
|
||||||
|
import com.srs.system.service.ISysPostService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@@ -37,6 +40,9 @@ public class WeChatMentalAlertController extends BaseController {
|
|||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private StudentMentalRatingMapper studentMentalRatingMapper;
|
private StudentMentalRatingMapper studentMentalRatingMapper;
|
||||||
|
//岗位
|
||||||
|
@Autowired
|
||||||
|
private ISysPostService sysPostService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理心理预警通知请求
|
* 处理心理预警通知请求
|
||||||
@@ -114,11 +120,27 @@ public class WeChatMentalAlertController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取全部学生心理评级记录
|
* 获取全部学生心理评级记录
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* 获取全部学生心理评级记录(支持条件查询和分页)
|
||||||
|
*/
|
||||||
@GetMapping("/rating/all")
|
@GetMapping("/rating/all")
|
||||||
public AjaxResult allRatings() {
|
public TableDataInfo allRatings(StudentMentalRatingVo queryVo) {
|
||||||
return AjaxResult.success(studentMentalRatingMapper.selectAll());
|
// 获取当前登录用户信息
|
||||||
}
|
String teacherId = getUsername();
|
||||||
|
Long userId = getUserId();
|
||||||
|
// 判断是否为学工
|
||||||
|
boolean isJwc = RoleBool.isJwc(userId, sysPostService);
|
||||||
|
|
||||||
|
startPage();
|
||||||
|
|
||||||
|
if (isJwc) {
|
||||||
|
return getDataTable(studentMentalRatingMapper.selectLatestAllWithConditions(
|
||||||
|
queryVo.getStuNo(), queryVo.getStuName()));
|
||||||
|
} else {
|
||||||
|
return getDataTable(studentMentalRatingMapper.selectLatestByTeacherIdWithConditions(
|
||||||
|
teacherId, queryVo.getStuNo(), queryVo.getStuName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 根据学号获取全部记录
|
* 根据学号获取全部记录
|
||||||
*/
|
*/
|
||||||
|
@@ -2,6 +2,7 @@ package com.srs.system.domain;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.srs.common.core.domain.BaseEntity;
|
import com.srs.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -11,7 +12,6 @@ import java.util.Date;
|
|||||||
public class StudentMentalRating extends BaseEntity {
|
public class StudentMentalRating extends BaseEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private String studentId;
|
private String studentId;
|
||||||
private String rating;
|
private String rating;
|
||||||
|
@@ -0,0 +1,42 @@
|
|||||||
|
package com.srs.system.domain.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 宁博
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class StudentMentalRatingVo {
|
||||||
|
/**
|
||||||
|
* 学号
|
||||||
|
*/
|
||||||
|
private String stuNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 学生姓名
|
||||||
|
*/
|
||||||
|
private String stuName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班级名称
|
||||||
|
*/
|
||||||
|
private String className;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 心理评级
|
||||||
|
*/
|
||||||
|
private String rating;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createdTime;
|
||||||
|
}
|
@@ -1,6 +1,7 @@
|
|||||||
package com.srs.system.mapper;
|
package com.srs.system.mapper;
|
||||||
|
|
||||||
import com.srs.system.domain.StudentMentalRating;
|
import com.srs.system.domain.StudentMentalRating;
|
||||||
|
import com.srs.system.domain.vo.StudentMentalRatingVo;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -22,8 +23,26 @@ public interface StudentMentalRatingMapper {
|
|||||||
*/
|
*/
|
||||||
int updateRatingByStudentId(StudentMentalRating record);
|
int updateRatingByStudentId(StudentMentalRating record);
|
||||||
|
|
||||||
/** 全部记录 */
|
/**
|
||||||
List<StudentMentalRating> selectAll();
|
* 查询辅导员负责的每个学生的最新心理评级记录(带条件查询)
|
||||||
|
* @param teacherId 教师ID
|
||||||
|
* @param stuNo 学号
|
||||||
|
* @param stuName 学生姓名
|
||||||
|
* @return 学生心理评级列表
|
||||||
|
*/
|
||||||
|
List<StudentMentalRatingVo> selectLatestByTeacherIdWithConditions(@Param("teacherId") String teacherId,
|
||||||
|
@Param("stuNo") String stuNo,
|
||||||
|
@Param("stuName") String stuName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有学生的最新心理评级记录(带条件查询)
|
||||||
|
* @param stuNo 学号
|
||||||
|
* @param stuName 学生姓名
|
||||||
|
* @return 学生心理评级列表
|
||||||
|
*/
|
||||||
|
List<StudentMentalRatingVo> selectLatestAllWithConditions(@Param("stuNo") String stuNo,
|
||||||
|
@Param("stuName") String stuName);
|
||||||
|
|
||||||
|
|
||||||
/** 单学号全部记录 */
|
/** 单学号全部记录 */
|
||||||
List<StudentMentalRating> selectByStuNo(@Param("stuNo") String stuNo);
|
List<StudentMentalRating> selectByStuNo(@Param("stuNo") String stuNo);
|
||||||
|
@@ -21,25 +21,76 @@
|
|||||||
WHERE student_id = #{studentId}
|
WHERE student_id = #{studentId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<!-- 心理查询全部:知无涯 -->
|
|
||||||
<select id="selectAll" resultType="com.srs.system.domain.StudentMentalRating">
|
<!-- 查询辅导员负责的每个学生的最新心理评级记录(带条件查询) -->
|
||||||
SELECT id,
|
<select id="selectLatestByTeacherIdWithConditions" resultType="com.srs.system.domain.vo.StudentMentalRatingVo">
|
||||||
student_id AS studentId,
|
SELECT
|
||||||
rating,
|
a.stu_no,
|
||||||
created_time AS createdTime,
|
a.stu_name,
|
||||||
updated_time AS updatedTime
|
a.class_name,
|
||||||
|
smr.rating,
|
||||||
|
smr.created_time
|
||||||
|
FROM view_stu_info a
|
||||||
|
LEFT JOIN student_mental_rating smr ON a.stu_no = smr.student_id
|
||||||
|
INNER JOIN (
|
||||||
|
SELECT student_id, MAX(created_time) as max_time
|
||||||
FROM student_mental_rating
|
FROM student_mental_rating
|
||||||
ORDER BY created_time DESC
|
WHERE rating IS NOT NULL
|
||||||
|
GROUP BY student_id
|
||||||
|
) latest ON smr.student_id = latest.student_id AND smr.created_time = latest.max_time
|
||||||
|
WHERE a.t_no = #{teacherId}
|
||||||
|
AND smr.rating IS NOT NULL
|
||||||
|
AND smr.student_id IS NOT NULL
|
||||||
|
<if test="stuNo != null and stuNo != ''">
|
||||||
|
AND a.stu_no = #{stuNo}
|
||||||
|
</if>
|
||||||
|
<if test="stuName != null and stuName != ''">
|
||||||
|
AND a.stu_name LIKE CONCAT('%', #{stuName}, '%')
|
||||||
|
</if>
|
||||||
|
ORDER BY smr.created_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 根据学号查询心理:知无涯 -->
|
<!-- 查询所有学生的最新心理评级记录(带条件查询) -->
|
||||||
<select id="selectByStuNo" resultType="com.srs.system.domain.StudentMentalRating">
|
<select id="selectLatestAllWithConditions" resultType="com.srs.system.domain.vo.StudentMentalRatingVo">
|
||||||
SELECT id,
|
SELECT
|
||||||
student_id AS studentId,
|
a.stu_no,
|
||||||
rating,
|
a.stu_name,
|
||||||
created_time AS createdTime,
|
a.class_name,
|
||||||
updated_time AS updatedTime
|
smr.rating,
|
||||||
|
smr.created_time
|
||||||
|
FROM view_stu_info a
|
||||||
|
LEFT JOIN student_mental_rating smr ON a.stu_no = smr.student_id
|
||||||
|
INNER JOIN (
|
||||||
|
SELECT student_id, MAX(created_time) as max_time
|
||||||
FROM student_mental_rating
|
FROM student_mental_rating
|
||||||
|
WHERE rating IS NOT NULL
|
||||||
|
GROUP BY student_id
|
||||||
|
) latest ON smr.student_id = latest.student_id AND smr.created_time = latest.max_time
|
||||||
|
WHERE smr.rating IS NOT NULL
|
||||||
|
AND smr.student_id IS NOT NULL
|
||||||
|
<if test="stuNo != null and stuNo != ''">
|
||||||
|
AND a.stu_no = #{stuNo}
|
||||||
|
</if>
|
||||||
|
<if test="stuName != null and stuName != ''">
|
||||||
|
AND a.stu_name LIKE CONCAT('%', #{stuName}, '%')
|
||||||
|
</if>
|
||||||
|
ORDER BY smr.created_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 根据学号查询心理:知无涯 -->
|
||||||
|
<select id="selectByStuNo" parameterType="string" resultType="com.srs.system.domain.vo.StudentMentalRatingVo">
|
||||||
|
SELECT
|
||||||
|
a.stu_no,
|
||||||
|
a.stu_name,
|
||||||
|
a.class_name,
|
||||||
|
smr.rating,
|
||||||
|
smr.created_time
|
||||||
|
FROM view_stu_info a
|
||||||
|
LEFT JOIN student_mental_rating smr ON a.stu_no = smr.student_id
|
||||||
WHERE student_id = #{stuNo}
|
WHERE student_id = #{stuNo}
|
||||||
ORDER BY created_time DESC
|
ORDER BY created_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
Reference in New Issue
Block a user