【修改】学生性别字段,学生进入监控返回时间戳
This commit is contained in:
@@ -87,13 +87,15 @@ public void exportMonitorExcel(@Valid MonitorPageReqVO pageReqVO, HttpServletRes
|
||||
|
||||
@PostMapping("/stuMonitor")
|
||||
@Operation(summary = "学生端进入考试返回值")
|
||||
public CommonResult<String> getStuMonitor(@Valid @RequestBody StuMonitorPaperVo stuMonitorPaperVo) {
|
||||
Boolean stuMonitor = monitorService.getStuMonitor(stuMonitorPaperVo);
|
||||
if (stuMonitor)
|
||||
public CommonResult getStuMonitor(@Valid @RequestBody StuMonitorPaperVo stuMonitorPaperVo) {
|
||||
long stuMonitor = monitorService.getStuMonitor(stuMonitorPaperVo);
|
||||
if (stuMonitor>0)
|
||||
{
|
||||
return success("进入考试成功");
|
||||
return success(stuMonitor);
|
||||
}else {
|
||||
return error(DEMO03_MONITOR_TIME_EXISTS);
|
||||
|
||||
}
|
||||
return error(DEMO03_MONITOR_TIME_EXISTS);
|
||||
|
||||
}
|
||||
@PostMapping("/stuMonitorQu")
|
||||
|
@@ -25,4 +25,6 @@ public class StuInfoPaper {
|
||||
|
||||
private Time answerTime;
|
||||
|
||||
private String sex;
|
||||
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||
import pc.exam.pp.framework.common.util.object.BeanUtils;
|
||||
import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialRolesVo;
|
||||
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo;
|
||||
import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo;
|
||||
|
@@ -53,7 +53,7 @@ import java.util.List;
|
||||
*/
|
||||
PageResult<MonitorDO> getMonitorPage(MonitorPageReqVO pageReqVO);
|
||||
|
||||
Boolean getStuMonitor(StuMonitorPaperVo stuMonitorPaperVo);
|
||||
long getStuMonitor(StuMonitorPaperVo stuMonitorPaperVo);
|
||||
|
||||
Boolean updateStuMonitor(StuMonitorQuVo stuMonitorQuVo);
|
||||
|
||||
|
@@ -13,6 +13,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Time;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
@@ -111,11 +112,9 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
return monitorMapper.selectPage(pageReqVO);
|
||||
}
|
||||
@Override
|
||||
public Boolean getStuMonitor(StuMonitorPaperVo stuMonitorPaperVo) {
|
||||
public long getStuMonitor(StuMonitorPaperVo stuMonitorPaperVo) {
|
||||
String key = "userCache:"+stuMonitorPaperVo.getTaskId()+":" + stuMonitorPaperVo.getStuId();
|
||||
MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key),MonitorDO.class);
|
||||
// MonitorDO info=new MonitorDO();
|
||||
|
||||
if (StringUtils.isNotBlank(stuMonitorPaperVo.getPaperId())){
|
||||
EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(stuMonitorPaperVo.getPaperId());
|
||||
String counts = educationPaper.getCounts();
|
||||
@@ -140,52 +139,72 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
if (info.getRemainingTime()==null){
|
||||
stringRedisTemplate.opsForValue().set("userCache:"+stuMonitorPaperVo.getTaskId()+":"+stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info));
|
||||
monitorMapper.updateById(info);
|
||||
return true;
|
||||
return 24 * 60 * 60L; // (1天)
|
||||
}else {
|
||||
EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(stuMonitorPaperVo.getTaskId(), stuMonitorPaperVo.getStuId());
|
||||
EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(educationPaperPerson.getSessionId());
|
||||
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(stuMonitorPaperVo.getTaskId());
|
||||
//测评时长
|
||||
Time examTime = educationPaperParam.getExamTime();
|
||||
|
||||
//判断是否开启测评时长限制
|
||||
//开启测评时长限制 开启场次 判断场次时间 ,,,,没开启测评时长限制 开启场次 -判断场次时间
|
||||
if ("0".equals(educationPaperParam.getIsSession())){
|
||||
//获得场次开始时间, 结束时间 判断是否在 时间范围内
|
||||
|
||||
EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(stuMonitorPaperVo.getTaskId(), stuMonitorPaperVo.getStuId());
|
||||
EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(educationPaperPerson.getSessionId());
|
||||
|
||||
|
||||
//结束时间
|
||||
Date endTime = educationPaperSession.getEndTime();
|
||||
//开始时间
|
||||
Date startTime = educationPaperSession.getStartTime();
|
||||
//开始考试前分钟,允许入场
|
||||
String allowEntry = educationPaperSession.getAllowEntry();
|
||||
//开始考试后分钟,禁止入场
|
||||
String endAllowEntry = educationPaperSession.getEndAllowEntry();
|
||||
//结束时间
|
||||
Date endTime = educationPaperSession.getEndTime();
|
||||
//开始时间
|
||||
Date startTime = educationPaperSession.getStartTime();
|
||||
//开始考试前分钟,允许入场
|
||||
String allowEntry = educationPaperSession.getAllowEntry();
|
||||
//开始考试后分钟,禁止入场
|
||||
String endAllowEntry = educationPaperSession.getEndAllowEntry();
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime start = DateUtil.toLocalDateTime(startTime);
|
||||
LocalDateTime end = DateUtil.toLocalDateTime(endTime);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime start = DateUtil.toLocalDateTime(startTime);
|
||||
LocalDateTime end = DateUtil.toLocalDateTime(endTime);
|
||||
|
||||
// 考试开始前允许入场时间(分钟)
|
||||
int allowEntryMin = Integer.parseInt(allowEntry);
|
||||
// 考试开始前允许入场时间(分钟)
|
||||
int allowEntryMin = Integer.parseInt(allowEntry);
|
||||
|
||||
// 考试开始后允许入场时间(分钟)
|
||||
int endAllowEntryMin = Integer.parseInt(endAllowEntry);
|
||||
// 考试开始后允许入场时间(分钟)
|
||||
int endAllowEntryMin = Integer.parseInt(endAllowEntry);
|
||||
|
||||
// 入场允许范围: [start , end + endAllowEntryMin]
|
||||
LocalDateTime entryEnd = end.plusMinutes(endAllowEntryMin);
|
||||
// 入场允许范围: [start-allowEntryMin , end + endAllowEntryMin]
|
||||
LocalDateTime entryStart = start.minusMinutes(allowEntryMin);
|
||||
LocalDateTime entryEnd = end.plusMinutes(endAllowEntryMin);
|
||||
//包含边界值
|
||||
boolean isWithinEntryTime = !now.isBefore(entryStart) && !now.isAfter(entryEnd);
|
||||
System.out.println("是否在允许入场时间段内:" + isWithinEntryTime);
|
||||
|
||||
boolean isWithinEntryTime = now.isAfter(start) && now.isBefore(entryEnd);
|
||||
System.out.println("是否在允许入场时间段内:" + isWithinEntryTime);
|
||||
if (isWithinEntryTime){
|
||||
long remainingSeconds = ChronoUnit.SECONDS.between(LocalDateTime.now(),
|
||||
DateUtil.toLocalDateTime(endTime));
|
||||
info.setRemainingTime(remainingSeconds > 0 ? remainingSeconds : 0);
|
||||
|
||||
if (isWithinEntryTime){
|
||||
long remainingSeconds = ChronoUnit.SECONDS.between(LocalDateTime.now(),
|
||||
DateUtil.toLocalDateTime(endTime));
|
||||
info.setRemainingTime(remainingSeconds > 0 ? remainingSeconds : 0);
|
||||
|
||||
|
||||
//判分后删除
|
||||
// stringRedisTemplate.opsForValue().set("userCache:"+stuMonitorPaperVo.getTaskId()+":"+stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info), remainingSeconds, TimeUnit.SECONDS);
|
||||
stringRedisTemplate.opsForValue().set("userCache:"+stuMonitorPaperVo.getTaskId()+":"+stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info));
|
||||
|
||||
monitorMapper.updateById(info);
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
//判分后删除
|
||||
stringRedisTemplate.opsForValue().set("userCache:"+stuMonitorPaperVo.getTaskId()+":"+stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info));
|
||||
monitorMapper.updateById(info);
|
||||
return remainingSeconds > 0 ? remainingSeconds : 0;
|
||||
}else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//开启测评时长限制 没开启场次 -直接返回测评时长
|
||||
|
||||
if ("1".equals(educationPaperParam.getIsSession())&&"0".equals(educationPaperParam.getIsTime())){
|
||||
|
||||
info.setRemainingTime((long) examTime.toLocalTime().toSecondOfDay());
|
||||
|
||||
|
||||
return (long) examTime.toLocalTime().toSecondOfDay();
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -301,6 +320,12 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
monitorDO1.setStuId(stuId);
|
||||
monitorDO1.setUsername(personRepDto.getUsername());
|
||||
monitorDO1.setNickname(personRepDto.getNickname());
|
||||
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
|
||||
Time examTime = educationPaperParam.getExamTime();
|
||||
//如果开启了 时长限制 或者考场
|
||||
if ("0".equals(educationPaperParam.getIsTime())||"0".equals(educationPaperParam.getIsSession())){
|
||||
monitorDO1.setRemainingTime((long) examTime.toLocalTime().toSecondOfDay());
|
||||
}
|
||||
stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(monitorDO1));
|
||||
}else {
|
||||
info.setExamStatus(status);
|
||||
|
@@ -173,12 +173,13 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer
|
||||
for (String studentId : studentIds) {
|
||||
// 查询是否存在该 taskId + studentId 的记录,且 sessionId 为 null
|
||||
EducationPaperPerson existing = educationPaperPersonMapper.selectByTaskIdAndPersonId(taskId, studentId);
|
||||
//学生已在试卷任务里,给学生设置考场
|
||||
if (existing != null && (existing.getSessionId() == null || existing.getSessionId().isEmpty())) {
|
||||
// 更新已有记录的 sessionId 和 batch
|
||||
existing.setSessionId(sessionId);
|
||||
existing.setBatch(batch);
|
||||
educationPaperPersonMapper.updateByTaskIdAndStuId(existing);
|
||||
//todo 本来没有设置考场的,这里要更新缓存的 剩余时间
|
||||
// 本来没有设置考场的,这里要更新缓存的 剩余时间
|
||||
EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(sessionId);
|
||||
String key = "userCache:" + taskId+":"+studentId;
|
||||
MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key),MonitorDO.class);
|
||||
@@ -206,6 +207,7 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer
|
||||
|
||||
|
||||
}
|
||||
//把学生加到试卷任务里
|
||||
if (existing == null) {
|
||||
EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskId);
|
||||
String name= educationPaperTaskMapper.selectEducationPaperTaskNameByid(taskId);
|
||||
@@ -222,10 +224,12 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer
|
||||
info.setUsername(personRepDto.getUsername());
|
||||
info.setNickname(personRepDto.getNickname());
|
||||
//判断是否开启测评时长限制
|
||||
Time examTime = educationPaperParam.getExamTime();
|
||||
//开启测评时长限制
|
||||
if ("0".equals(educationPaperParam.getIsTime())){
|
||||
Time examTime = educationPaperParam.getExamTime();
|
||||
info.setRemainingTime((long) examTime.toLocalTime().toSecondOfDay());
|
||||
}
|
||||
|
||||
//设置学生班级
|
||||
if (StringUtils.isNotBlank(personRepDto.getClassId().toString())){
|
||||
String className=educationPaperTaskMapper.selectStuClassNameByClassId(personRepDto.getClassId());
|
||||
|
@@ -154,6 +154,7 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService
|
||||
stuInfoPaper.setTaskName(educationPaperTask.getTaskName());
|
||||
stuInfoPaper.setUserName(SecurityFrameworkUtils.getLoginUserName());
|
||||
stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ());
|
||||
stuInfoPaper.setSex(SecurityFrameworkUtils.getLoginUserSEX());
|
||||
ExamPaperVo examPaperVo=new ExamPaperVo();
|
||||
examPaperVo.setPaperId(paperId);
|
||||
examPaperVo.setExamQuestionList(examQuestionList);
|
||||
|
@@ -444,7 +444,7 @@ public class EducationPaperServiceImpl implements IEducationPaperService
|
||||
Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId();
|
||||
String schoolName= examQuestionMapper.selectSchoolnameBytId(loginTenantId);
|
||||
stuInfoPaper.setSchoolName(schoolName);
|
||||
|
||||
stuInfoPaper.setSex(SecurityFrameworkUtils.getLoginUserSEX());
|
||||
ExamPaperVo examPaperVo=new ExamPaperVo();
|
||||
examPaperVo.setExamQuestionList(examQuestionList);
|
||||
examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList);
|
||||
|
@@ -437,6 +437,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
|
||||
stuInfoPaper.setUserName(SecurityFrameworkUtils.getLoginUserName());
|
||||
stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ());
|
||||
stuInfoPaper.setSchoolName(schoolName);
|
||||
stuInfoPaper.setSex(SecurityFrameworkUtils.getLoginUserSEX());
|
||||
ExamPaperVo examPaperVo=new ExamPaperVo();
|
||||
examPaperVo.setExamQuestionList(examQuestionList);
|
||||
examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList);
|
||||
|
@@ -65,6 +65,7 @@
|
||||
FROM exam_knowledge_points
|
||||
WHERE FIND_IN_SET(#{id}, ancestors)
|
||||
and deleted='0'
|
||||
and status='0'
|
||||
ORDER BY order_num;
|
||||
|
||||
</select>
|
||||
|
@@ -54,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</update>
|
||||
|
||||
<update id="deleteKnowledgePointsBySpIds" parameterType="String">
|
||||
-- delete from knowledge_points
|
||||
delete from knowledge_points
|
||||
update exam_knowledge_points
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
deleted = 1
|
||||
|
Reference in New Issue
Block a user