diff --git a/srs-admin/src/main/java/com/srs/web/controller/common/WeChatMentalAlertController.java b/srs-admin/src/main/java/com/srs/web/controller/common/WeChatMentalAlertController.java index 9aa2976..2118080 100644 --- a/srs-admin/src/main/java/com/srs/web/controller/common/WeChatMentalAlertController.java +++ b/srs-admin/src/main/java/com/srs/web/controller/common/WeChatMentalAlertController.java @@ -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; @@ -37,6 +40,9 @@ public class WeChatMentalAlertController extends BaseController { private TokenService tokenService; @Autowired private StudentMentalRatingMapper studentMentalRatingMapper; + //岗位 + @Autowired + private ISysPostService sysPostService; /** * 处理心理预警通知请求 @@ -114,11 +120,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())); + } + } /** * 根据学号获取全部记录 */ diff --git a/srs-system/src/main/java/com/srs/system/domain/StudentMentalRating.java b/srs-system/src/main/java/com/srs/system/domain/StudentMentalRating.java index b26f57d..a237e76 100644 --- a/srs-system/src/main/java/com/srs/system/domain/StudentMentalRating.java +++ b/srs-system/src/main/java/com/srs/system/domain/StudentMentalRating.java @@ -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; diff --git a/srs-system/src/main/java/com/srs/system/domain/vo/StudentMentalRatingVo.java b/srs-system/src/main/java/com/srs/system/domain/vo/StudentMentalRatingVo.java new file mode 100644 index 0000000..10ffbe9 --- /dev/null +++ b/srs-system/src/main/java/com/srs/system/domain/vo/StudentMentalRatingVo.java @@ -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; +} diff --git a/srs-system/src/main/java/com/srs/system/mapper/StudentMentalRatingMapper.java b/srs-system/src/main/java/com/srs/system/mapper/StudentMentalRatingMapper.java index bcc0f32..5d19015 100644 --- a/srs-system/src/main/java/com/srs/system/mapper/StudentMentalRatingMapper.java +++ b/srs-system/src/main/java/com/srs/system/mapper/StudentMentalRatingMapper.java @@ -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.util.List; @@ -22,8 +23,26 @@ public interface StudentMentalRatingMapper { */ int updateRatingByStudentId(StudentMentalRating record); - /** 全部记录 */ - List selectAll(); + /** + * 查询辅导员负责的每个学生的最新心理评级记录(带条件查询) + * @param teacherId 教师ID + * @param stuNo 学号 + * @param stuName 学生姓名 + * @return 学生心理评级列表 + */ + List selectLatestByTeacherIdWithConditions(@Param("teacherId") String teacherId, + @Param("stuNo") String stuNo, + @Param("stuName") String stuName); + + /** + * 查询所有学生的最新心理评级记录(带条件查询) + * @param stuNo 学号 + * @param stuName 学生姓名 + * @return 学生心理评级列表 + */ + List selectLatestAllWithConditions(@Param("stuNo") String stuNo, + @Param("stuName") String stuName); + /** 单学号全部记录 */ List selectByStuNo(@Param("stuNo") String stuNo); diff --git a/srs-system/src/main/resources/mapper/system/StudentMentalRatingMapper.xml b/srs-system/src/main/resources/mapper/system/StudentMentalRatingMapper.xml index 88cd1e5..6e0f6d8 100644 --- a/srs-system/src/main/resources/mapper/system/StudentMentalRatingMapper.xml +++ b/srs-system/src/main/resources/mapper/system/StudentMentalRatingMapper.xml @@ -21,25 +21,76 @@ WHERE student_id = #{studentId} - - + 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 + + AND a.stu_no = #{stuNo} + + + AND a.stu_name LIKE CONCAT('%', #{stuName}, '%') + + ORDER BY smr.created_time DESC - - + 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 + + AND a.stu_no = #{stuNo} + + + AND a.stu_name LIKE CONCAT('%', #{stuName}, '%') + + ORDER BY smr.created_time DESC + + + + + + + +