限制了给辅导员发送心理预警的次数
This commit is contained in:
@@ -18,6 +18,7 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Dify心理问题发送企业微信 知无涯
|
||||
@@ -51,18 +52,32 @@ public class WeChatMentalAlertController extends BaseController {
|
||||
return AjaxResult.error("Token无效或已过期");
|
||||
}
|
||||
|
||||
String studentId = request.getUserId();
|
||||
|
||||
// 查询辅导员信息
|
||||
SysUser teacher = sysUserMapper.selectTeacherByStuNo(request.getUserId());
|
||||
if (teacher == null || !StringUtils.hasText(teacher.getUserName())) {
|
||||
log.error("辅导员信息不完整,学号: {}", request.getUserId());
|
||||
return AjaxResult.error("未分配辅导员或信息不完整");
|
||||
}
|
||||
|
||||
// 获取今天日期
|
||||
LocalDate today = LocalDate.now();
|
||||
|
||||
// 查询该学生今天已触发的心理预警次数
|
||||
int todayCount = studentMentalRatingMapper.countTodayByStudentId(studentId, today);
|
||||
|
||||
/* 保存学生心理问题评级 */
|
||||
StudentMentalRating record = new StudentMentalRating();
|
||||
record.setStudentId(request.getUserId());
|
||||
record.setRating(request.getRating());
|
||||
studentMentalRatingMapper.insert(record);
|
||||
|
||||
// === 判断是否超过当日发送上限(3次)=== 陈冠元
|
||||
if (todayCount > 3) {
|
||||
return AjaxResult.success("预警已记录,因当日已达上限未发送通知");
|
||||
}
|
||||
|
||||
// 构建并发送消息
|
||||
try {
|
||||
String content = buildContent(request, teacher);
|
||||
|
Reference in New Issue
Block a user