Compare commits

...

4 Commits

Author SHA1 Message Date
fb9f09c523 Merge remote-tracking branch 'origin/main' 2025-08-26 11:17:44 +08:00
ab0f477db4 修复报错 2025-08-26 11:16:33 +08:00
626b045aa2 Merge branch 'main' of http://47.112.118.149:10082/xgxt_sd/zhxg_java 2025-08-26 10:01:48 +08:00
3541c29739 feat(system): 新增学生心理评级查询功能
- 添加了 StudentMentalRatingVo 类用于查询结果封装
- 在 StudentMentalRatingMapper 中新增了两个查询方法: - selectLatestByTeacherIdWithConditions:查询辅导员负责的每个学生的最新心理评级记录
  - selectLatestAllWithConditions:查询所有学生的最新心理评级记录
- 更新了 WeChatMentalAlertController,添加了新的查询接口
- 优化了查询逻辑,支持条件查询和分页功能
2025-08-26 09:58:54 +08:00
5 changed files with 156 additions and 22 deletions

View File

@@ -4,11 +4,14 @@ import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.core.domain.entity.SysUser;
import com.srs.common.core.domain.model.LoginUser;
import com.srs.common.core.page.TableDataInfo;
import com.srs.common.utils.WeChatUtil;
import com.srs.framework.web.service.TokenService;
import com.srs.system.domain.StudentMentalRating;
import com.srs.system.domain.vo.StudentMentalRatingVo;
import com.srs.system.mapper.StudentMentalRatingMapper;
import com.srs.system.mapper.SysUserMapper;
import com.srs.system.service.ISysPostService;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -38,6 +41,9 @@ public class WeChatMentalAlertController extends BaseController {
private TokenService tokenService;
@Autowired
private StudentMentalRatingMapper studentMentalRatingMapper;
//岗位
@Autowired
private ISysPostService sysPostService;
/**
* 处理心理预警通知请求
@@ -134,11 +140,27 @@ public class WeChatMentalAlertController extends BaseController {
/**
* 获取全部学生心理评级记录
*/
/**
* 获取全部学生心理评级记录(支持条件查询和分页)
*/
@GetMapping("/rating/all")
public AjaxResult allRatings() {
return AjaxResult.success(studentMentalRatingMapper.selectAll());
}
public TableDataInfo allRatings(StudentMentalRatingVo queryVo) {
// 获取当前登录用户信息
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()));
}
}
/**
* 根据学号获取全部记录
*/

View File

@@ -2,6 +2,7 @@ package com.srs.system.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.srs.common.core.domain.BaseEntity;
import lombok.Data;
import java.util.Date;
@@ -11,7 +12,6 @@ import java.util.Date;
public class StudentMentalRating extends BaseEntity {
private static final long serialVersionUID = 1L;
private Long id;
private String studentId;
private String rating;

View File

@@ -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;
}

View File

@@ -1,6 +1,7 @@
package com.srs.system.mapper;
import com.srs.system.domain.StudentMentalRating;
import com.srs.system.domain.vo.StudentMentalRatingVo;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
@@ -23,11 +24,29 @@ public interface StudentMentalRatingMapper {
*/
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<StudentMentalRatingVo> selectByStuNo(@Param("stuNo") String stuNo);
/**
* 查询今天的心理评级记录 陈冠元

View File

@@ -21,25 +21,76 @@
WHERE student_id = #{studentId}
</update>
<!-- 心理查询全部:知无涯 -->
<select id="selectAll" resultType="com.srs.system.domain.StudentMentalRating">
SELECT id,
student_id AS studentId,
rating,
created_time AS createdTime,
updated_time AS updatedTime
<!-- 查询辅导员负责的每个学生的最新心理评级记录(带条件查询) -->
<select id="selectLatestByTeacherIdWithConditions" 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
INNER JOIN (
SELECT student_id, MAX(created_time) as max_time
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 id="selectByStuNo" resultType="com.srs.system.domain.StudentMentalRating">
SELECT id,
student_id AS studentId,
rating,
created_time AS createdTime,
updated_time AS updatedTime
<!-- 查询所有学生的最新心理评级记录(带条件查询) -->
<select id="selectLatestAllWithConditions" 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
INNER JOIN (
SELECT student_id, MAX(created_time) as max_time
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}
ORDER BY created_time DESC
</select>