diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/exception/MonitorSpecialtyException.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/exception/MonitorSpecialtyException.java new file mode 100644 index 00000000..cb2b0cc0 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/exception/MonitorSpecialtyException.java @@ -0,0 +1,9 @@ +package pc.exam.pp.module.exam.controller.admin.exception; + +public class MonitorSpecialtyException extends RuntimeException { + + public MonitorSpecialtyException(String message) { + super(message); + } + +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/monitor/MonitorController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/monitor/MonitorController.java index b972f637..1d319076 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/monitor/MonitorController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/monitor/MonitorController.java @@ -88,7 +88,12 @@ public class MonitorController { @PostMapping("/stuMonitor") @Operation(summary = "学生端进入考试返回值") public CommonResult getStuMonitor(@Valid @RequestBody StuMonitorPaperVo stuMonitorPaperVo) { - long stuMonitor = monitorService.getStuMonitor(stuMonitorPaperVo); + long stuMonitor = 0; + try { + stuMonitor = monitorService.getStuMonitor(stuMonitorPaperVo); + } catch (RuntimeException e) { + return error(1-001-606-001,e.getMessage()); + } if (stuMonitor>0) { return success(stuMonitor); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/monitor/TentSpecialy.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/monitor/TentSpecialy.java new file mode 100644 index 00000000..c33d9584 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/monitor/TentSpecialy.java @@ -0,0 +1,21 @@ +package pc.exam.pp.module.exam.dal.dataobject.monitor; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.*; +import lombok.experimental.Accessors; +import pc.exam.pp.framework.tenant.core.db.TenantBaseDO; + +@Data +@TableName(value = "exam_tenant_specialty") +@Accessors(chain = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TentSpecialy extends TenantBaseDO { + private String id; + private String specialtyId; + private String points; + + @TableField(exist = false) + private String name; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java index 11c58e2b..0f4c1063 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java @@ -8,7 +8,9 @@ import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; import org.apache.ibatis.annotations.Mapper; import pc.exam.pp.module.exam.controller.admin.monitor.vo.MonitorPageReqVO; import pc.exam.pp.module.exam.controller.admin.paper.vo.DeleteRequestVo; +import pc.exam.pp.module.exam.dal.dataobject.EducationPaper; import pc.exam.pp.module.exam.dal.dataobject.monitor.MonitorDO; +import pc.exam.pp.module.exam.dal.dataobject.monitor.TentSpecialy; import java.util.Arrays; import java.util.List; @@ -58,4 +60,15 @@ return selectPage(reqVO, new LambdaQueryWrapperX() List selectByStuIdAndTaskId(Long stuId); List selectStuIdByTaskId(String taskId); + + /** + * 查找授权点位 + * @return + */ + List selectTent(Long loginTenantId); + + void deleteByTaskIds(@Param("taskIds") String[] taskIds); + + void deleteByTaskId(String taskId); + } \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperMapper.java index 2ffc2a01..a6d3ddfa 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperMapper.java @@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Param; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; +import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto; import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperIdAndNum; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo; @@ -177,6 +178,9 @@ public interface EducationPaperMapper extends BaseMapperX List selectTaskNumByids(@Param("cannotDeleteTaskIds")List cannotDeleteTaskIds); + // //查询所有正在考试的 试卷id + @TenantIgnore + List selectSpecilayCounts(Long loginTenantId); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperTaskMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperTaskMapper.java index 594914f7..d4b13a13 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperTaskMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperTaskMapper.java @@ -12,6 +12,9 @@ import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperTaskPageVo; import pc.exam.pp.module.exam.dal.dataobject.ExamPaperKnowledgePoints; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; import pc.exam.pp.module.exam.dal.dataobject.ExamPaperKnowledgePoints; +import pc.exam.pp.module.exam.service.monitor.vo.CourseInVo; +import pc.exam.pp.module.exam.service.monitor.vo.SpecialtyVo; +import pc.exam.pp.module.exam.service.monitor.vo.TaskInVo; /** * 试卷任务Mapper接口 @@ -146,4 +149,13 @@ public interface EducationPaperTaskMapper extends BaseMapperX selectTaskCounts(@Param("taskId")String taskId + ,@Param("loginTenantId") long loginTenantId); + + //所有正在考试的试卷中授权课程的统计信息 + List selectPaperCounts(@Param("allInPaperIds") List allInPaperIds + ,@Param("loginTenantId") long loginTenantId); + //查询该试卷涉及的所有课程(课程ID + 名称) + List selectPaperCountBypaperId(@Param("paperId") String paperId); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java index d08a359a..7fe36bda 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java @@ -1,13 +1,18 @@ package pc.exam.pp.module.exam.dal.mysql.specialty; +import org.apache.ibatis.annotations.MapKey; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo; import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo; import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints; +import pc.exam.pp.module.exam.dal.dataobject.monitor.TentSpecialy; import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty; +import pc.exam.pp.module.exam.service.monitor.vo.IdParentPair; +import pc.exam.pp.module.exam.service.monitor.vo.SpecialtyRelation; import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -114,4 +119,12 @@ public interface ExamSpecialtyMapper extends BaseMapperX , @Param("chapteridDictText")String chapteridDictText , @Param("pointNames") String pointNames); + List selectAllSpecialtyRelations(); // 返回 sp_id 和 parent_id + + + + List selectAllIdToParent(Long loginTenantId); + + + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorService.java index e0cbe482..87ea11f1 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorService.java @@ -53,7 +53,7 @@ import java.util.List; */ PageResult getMonitorPage(MonitorPageReqVO pageReqVO); //学生端进入考试返回值 - long getStuMonitor(StuMonitorPaperVo stuMonitorPaperVo); + long getStuMonitor(StuMonitorPaperVo stuMonitorPaperVo) throws RuntimeException; //学生端考试过程传试题 Boolean updateStuMonitor(StuMonitorQuVo stuMonitorQuVo); //学生端结束考试返回值 diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java index 823eb990..caeb1424 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java @@ -1,7 +1,6 @@ package pc.exam.pp.module.exam.service.monitor; import cn.hutool.core.date.DateUtil; -import cn.hutool.core.date.LocalDateTimeUtil; import com.alibaba.excel.util.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.springframework.beans.factory.annotation.Autowired; @@ -11,32 +10,29 @@ import org.springframework.stereotype.Service; import jakarta.annotation.Resource; 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; import java.time.temporal.ChronoUnit; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.common.util.json.JsonUtils; 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.exception.MonitorSpecialtyException; import pc.exam.pp.module.exam.controller.admin.monitor.vo.*; import pc.exam.pp.module.exam.controller.admin.paper.dto.PersonRepDto; import pc.exam.pp.module.exam.dal.dataobject.*; import pc.exam.pp.module.exam.dal.dataobject.monitor.MonitorDO; +import pc.exam.pp.module.exam.dal.dataobject.monitor.TentSpecialy; import pc.exam.pp.module.exam.dal.mysql.monitor.MonitorMapper; import pc.exam.pp.module.exam.dal.mysql.paper.*; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; -import pc.exam.pp.module.exam.utils.uuid.IdUtils; +import pc.exam.pp.module.exam.dal.mysql.specialty.ExamSpecialtyMapper; +import pc.exam.pp.module.exam.service.monitor.vo.*; //import pc.exam.pp.module.infra.service.file.FileService; import static pc.exam.pp.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -68,6 +64,11 @@ public class MonitorServiceImpl implements MonitorService { private EducationPaperParamMapper educationPaperParamMapper; @Resource private EducationPaperSessionMapper educationPaperSessionMapper; + @Resource + private EducationPaperSchemeMapper educationPaperSchemeMapper; + @Resource + private ExamSpecialtyMapper examSpecialtyMapper; + // @Resource // private FileService fileService; @@ -113,12 +114,116 @@ public class MonitorServiceImpl implements MonitorService { return monitorMapper.selectPage(pageReqVO); } @Override - public long getStuMonitor(StuMonitorPaperVo stuMonitorPaperVo) { - String key = "userCache:"+stuMonitorPaperVo.getTaskId()+":" + stuMonitorPaperVo.getStuId(); + public long getStuMonitor(StuMonitorPaperVo stuMonitorPaperVo) throws RuntimeException { + String key = "userCache:"+stuMonitorPaperVo.getTaskId()+":" + stuMonitorPaperVo.getStuId(); MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key),MonitorDO.class); if (info==null){ return 0L; } + //获取属性 判断 专业/课程点位 + Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId(); + + if (!"1".equals(String.valueOf(loginTenantId))) { + // 查询授权课程/专业列表 + List tentSpecialyList = monitorMapper.selectTent(loginTenantId); + List tentSpecialies = filterSpecialtyList(tentSpecialyList); + + if (tentSpecialies.isEmpty()) { + throw new MonitorSpecialtyException("授权课程的点位为空,请增加课程点位!"); + } + + // 构建授权数量映射:specialtyId -> 授权个数 + Map authMap = tentSpecialies.stream() + .collect(Collectors.toMap( + TentSpecialy::getSpecialtyId, + t -> { + try { + return Integer.parseInt(t.getPoints()); + } catch (Exception e) { + return 0; + } + } + )); + + // 查询 exam_specialty 所有 sp_id -> parent_id 映射(用来判断是否为专业) + List pairList = examSpecialtyMapper.selectAllIdToParent(loginTenantId); + + // 转换为 Map + Map idToParentMap = pairList.stream() + .collect(Collectors.toMap( + p -> String.valueOf(p.getSpId()), + p -> p.getParentId() == null ? null : String.valueOf(p.getParentId()) + )); + + // 分类授权:哪些是专业,哪些是课程 + Set authSpecialtyIds = new HashSet<>(); + Set authCourseIds = new HashSet<>(); + for (TentSpecialy t : tentSpecialies) { + String specialtyId = t.getSpecialtyId(); + String parentId = idToParentMap.get(specialtyId); + if (parentId == null || "0".equals(parentId)) { + authSpecialtyIds.add(specialtyId); // 是专业 + } else { + authCourseIds.add(specialtyId); // 是课程 + } + } + + + + // 只有授权了“专业”,才去查 taskInVo 并校验 + if (!authSpecialtyIds.isEmpty()) { + //查询 该试卷任务 设计的 专业 + List taskInVo = educationPaperTaskMapper.selectTaskCounts(stuMonitorPaperVo.getTaskId(),loginTenantId); + + for (SpecialtyVo specialtyVo : taskInVo) { + String specialtyId = specialtyVo.getSpecialtyId(); + if (!authSpecialtyIds.contains(specialtyId)) continue; + + String specialtyName = specialtyVo.getSpecialtyName(); + Integer currentCount = specialtyVo.getCounts(); + Integer authCount = authMap.getOrDefault(specialtyId, 0); + + if (currentCount > authCount) { + int over = currentCount - authCount; + throw new MonitorSpecialtyException("专业: " + specialtyName + " 正在考试数量(" + currentCount + ") 授权数量(" + authCount + "),超出:" + over); + } + } + } + + // 只有授权了“课程”,才去查 courseInVos 并校验 + if (!authCourseIds.isEmpty()) { + //查询所有正在考试的 试卷id + List allInPaperIds = educationPaperMapper.selectSpecilayCounts(loginTenantId); + // 所有正在考试的试卷中授权课程的统计信息 + List courseInVos = educationPaperTaskMapper.selectPaperCounts(allInPaperIds, loginTenantId); + + //获取当前学生正在考试的试卷 ID + String paperId = stuMonitorPaperVo.getPaperId(); + + //查询该试卷涉及的所有课程(课程ID + 名称) + List courseList = educationPaperTaskMapper.selectPaperCountBypaperId(paperId); + + //将 courseInVos 转为 Map,便于通过 courseId 查询次数 + Map courseCountMap = courseInVos.stream() + .collect(Collectors.toMap(CourseInVo::getCourseId, CourseInVo::getCounts, (a, b) -> b)); + + //校验当前试卷的每门课程是否超过授权限制 + for (CourseInVo course : courseList) { + String courseId = course.getCourseId(); + if (!authCourseIds.contains(courseId)) continue; + + String courseName = course.getCourseName(); + Integer currentCount = courseCountMap.getOrDefault(courseId, 0); + Integer authCount = authMap.getOrDefault(courseId, 0); + + if (currentCount > authCount) { + int over = currentCount - authCount; + throw new MonitorSpecialtyException("课程: " + courseName + " 正在考试数量(" + currentCount + ") 授权数量(" + authCount + "),超出:" + over); + } + } + } + } + if (StringUtils.isNotBlank(stuMonitorPaperVo.getPaperId())){ EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(stuMonitorPaperVo.getPaperId()); String counts = educationPaper.getCounts(); @@ -216,7 +321,6 @@ public class MonitorServiceImpl implements MonitorService { return (long) examTime.toLocalTime().toSecondOfDay(); - } return 0L; @@ -394,5 +498,38 @@ public class MonitorServiceImpl implements MonitorService { return true; } + public List filterSpecialtyList(List inputList) { + if (inputList == null || inputList.isEmpty()) { + return Collections.emptyList(); + } + + // 构建传入列表中的 specialtyId Set(这些是传进来的 ID) + Set inputSpecialtyIds = inputList.stream() + .map(TentSpecialy::getSpecialtyId) + .collect(Collectors.toSet()); + + // 查询所有课程 -> 专业 的关系 + List allRelations = examSpecialtyMapper.selectAllSpecialtyRelations(); + + // 构建课程ID -> 父专业ID 的映射 + Map courseToParentMap = allRelations.stream() + .filter(r -> r.getParentId() != null) + .collect(Collectors.toMap(SpecialtyRelation::getSpId, SpecialtyRelation::getParentId)); + + // 开始过滤:只保留以下情况之一 + return inputList.stream() + .filter(item -> { + String specialtyId = item.getSpecialtyId(); + String parentId = courseToParentMap.get(specialtyId); + // 1. 如果这个是专业(它不是任何课程的 sp_id) → 保留 + if (parentId == null) return true; + // 2. 如果它是课程,但父级不在输入列表中 → 保留 + return !inputSpecialtyIds.contains(parentId); + }) + .collect(Collectors.toList()); + } + + + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/CourseInVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/CourseInVo.java new file mode 100644 index 00000000..5b4ca05a --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/CourseInVo.java @@ -0,0 +1,17 @@ +package pc.exam.pp.module.exam.service.monitor.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CourseInVo { + //试卷id + private String courseId; + + private String courseName; + //个数 + private Integer counts; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/IdParentPair.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/IdParentPair.java new file mode 100644 index 00000000..c106e2b5 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/IdParentPair.java @@ -0,0 +1,14 @@ +package pc.exam.pp.module.exam.service.monitor.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class IdParentPair { + private Long spId; + private Long parentId; +} + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/SpecialtyRelation.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/SpecialtyRelation.java new file mode 100644 index 00000000..23ab6bd7 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/SpecialtyRelation.java @@ -0,0 +1,13 @@ +package pc.exam.pp.module.exam.service.monitor.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SpecialtyRelation { + private String spId; + private String parentId; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/SpecialtyVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/SpecialtyVo.java new file mode 100644 index 00000000..4fea069d --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/SpecialtyVo.java @@ -0,0 +1,19 @@ +package pc.exam.pp.module.exam.service.monitor.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SpecialtyVo { + + //专业id + private String specialtyId; + + private String specialtyName; + //个数 + private Integer counts; + + +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/TaskInVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/TaskInVo.java new file mode 100644 index 00000000..92556f3f --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/vo/TaskInVo.java @@ -0,0 +1,16 @@ +package pc.exam.pp.module.exam.service.monitor.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TaskInVo { + //试卷任务id + private String taskId; + + //个数 + private Integer counts; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java index ea328021..6697984a 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java @@ -215,6 +215,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService // 3. 执行删除操作 educationPaperTaskMapper.deleteEducationPaperTaskByTaskIds( canDeleteTaskIds.toArray(new String[0])); + monitorMapper.deleteByTaskIds(canDeleteTaskIds.toArray(new String[0])); if (!cannotDeleteTaskIds.isEmpty()){ List taskNum= educationPaperMapper.selectTaskNumByids(cannotDeleteTaskIds); return ("以下任务下有试卷:"+taskNum+",不能删除!"); @@ -233,6 +234,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService */ @Override public int deleteEducationPaperTaskByTaskId(String taskId) { + monitorMapper.deleteByTaskId(taskId); return educationPaperTaskMapper.deleteEducationPaperTaskByTaskId(taskId); } @@ -351,7 +353,10 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService //获得 试卷试题 List educationPaperQus = educationPaperQuMapper.selectPaperQuListByPaperId(paperId); + int number=educationPaperMapper.selectCountPaperList(); + // 格式化为8位,不足前面补0 + String formattedNumber = String.format("%08d", ++number); String newpaperId = IdUtils.simpleUUID(); //不为空,构建新试卷试题 @@ -361,14 +366,16 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService //插入数据库 educationPaperQuMapper.insertEducationPaperQuList(educationPaperQus); + educationPaper.setCounts("0"); educationPaper.setPaperId(newpaperId); educationPaper.setTaskId(newtaskId); + educationPaper.setNum(formattedNumber); - + //构建新试卷 + educationPaperMapper.insertEducationPaper(educationPaper); } - //构建新试卷 - educationPaperMapper.insertEducationPaperList(educationPapers); + } } if (options.contains("3")) { @@ -404,6 +411,10 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService Map paperIdMapping = new HashMap<>(); if (educationPapers!=null&&educationPapers.size()>0){ for (EducationPaper paper : educationPapers) { + int number=educationPaperMapper.selectCountPaperList(); + + // 格式化为8位,不足前面补0 + String formattedNumber = String.format("%08d", ++number); String newPaperId = IdUtils.simpleUUID(); paperIdMapping.put(paper.getPaperId(), newPaperId); @@ -411,7 +422,8 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService List questions = educationPaperQuMapper.selectPaperQuListByPaperId(paper.getPaperId()); questions.forEach(qu -> qu.setPaperId(newPaperId)); educationPaperQuMapper.insertEducationPaperQuList(questions); - + paper.setNum(formattedNumber); + paper.setCounts("0"); paper.setPaperId(newPaperId); paper.setTaskId(newtaskId); educationPaperMapper.insertEducationPaper(paper); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml index 939f0342..b70d063d 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml @@ -137,6 +137,14 @@ select task_id from education_paper where paper_id=#{paperId} #{taskId} + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperTaskMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperTaskMapper.xml index ad8c513f..8eb01a8c 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperTaskMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperTaskMapper.xml @@ -134,6 +134,65 @@ LIMIT 1; + + + + insert into education_paper_task diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml index ce563c68..7e0320b7 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml @@ -4,6 +4,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + + + + + + + UPDATE exam_monitor + SET deleted = '2' + WHERE task_id IN + + #{taskId} + + + + UPDATE exam_monitor + SET deleted = '2' + WHERE task_id =#{taskId} + + select stu_id from exam_monitor where task_id =#{taskId} and deleted ='0' and exam_status ='0' + + + + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml index 2e8b3379..0baea37d 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml @@ -137,6 +137,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND q3.deleted = '0' LIMIT 1; + +