diff --git a/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/LoginUser.java b/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/LoginUser.java index 1a44cab9..66e7a4a6 100644 --- a/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/LoginUser.java +++ b/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/LoginUser.java @@ -20,7 +20,7 @@ public class LoginUser { public static final String INFO_KEY_NICKNAME = "nickname"; public static final String INFO_KEY_DEPT_ID = "deptId"; - + public static final String INFO_KEY_QUEUE = "queueName"; /** * 用户编号 */ diff --git a/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/util/SecurityFrameworkUtils.java b/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/util/SecurityFrameworkUtils.java index 65b59d27..b266b3f5 100644 --- a/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/util/SecurityFrameworkUtils.java +++ b/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/util/SecurityFrameworkUtils.java @@ -100,6 +100,27 @@ public class SecurityFrameworkUtils { LoginUser loginUser = getLoginUser(); return loginUser != null ? loginUser.getTenantId() : null; } + /** + * 获得当前用户的队列名,从上下文中 + * + * @return 队列名 + */ + @Nullable + public static String getLoginQueueName() { + LoginUser loginUser = getLoginUser(); + return loginUser != null ? MapUtil.getStr(loginUser.getInfo(), LoginUser.INFO_KEY_QUEUE) : null; + } + /** + * 获得当前用户的用户类型,从上下文中 + * + * @return 用户类型 + */ + @Nullable + public static Integer getLoginUserType() { + LoginUser loginUser = getLoginUser(); + return loginUser != null ? loginUser.getUserType() : null; + + } /** * 获得当前用户的昵称,从上下文中 diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperPersonController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperPersonController.java index 380ee481..9fe6791a 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperPersonController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperPersonController.java @@ -89,10 +89,10 @@ public class EducationPaperPersonController /** * 根据试卷任务获取人员分配列表 */ - @GetMapping(value = "/{taskId}") + @GetMapping( "/getList") public CommonResult> getInfo(ExamPersonVo examPersonVo) { - PageResult list = educationPaperPersonService.selectEducationPaperPersonByTaskId(examPersonVo.getTaskId()); + PageResult list = educationPaperPersonService.selectEducationPaperPersonByTaskId(examPersonVo); return CommonResult.success(BeanUtils.toBean(list, PersonRepDto.class)); } /** @@ -100,7 +100,7 @@ public class EducationPaperPersonController */ @GetMapping(value = "/getSessionStu") public CommonResult> getSessionStu(ExamPersonVo examPersonVo) { - PageResult list = educationPaperPersonService.selectEducationPaperPersonBySessionId(examPersonVo.getSessionId()); + PageResult list = educationPaperPersonService.selectEducationPaperPersonBySessionId(examPersonVo); return CommonResult.success(BeanUtils.toBean(list, PersonRepDto.class)); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperQuController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperQuController.java index 47bedfd7..5cca20fd 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperQuController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperQuController.java @@ -81,7 +81,7 @@ public class EducationPaperQuController /** - * 获取试卷详细信息 + * 学生端根据id获取试卷 */ @GetMapping(value = "/getPaper") public CommonResult getPaper(@RequestParam(value = "paperId") String paperId) diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSchemeController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSchemeController.java index cb6e771d..58bfdf62 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSchemeController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSchemeController.java @@ -5,9 +5,13 @@ import org.springframework.web.bind.annotation.*; import pc.exam.pp.framework.common.pojo.CommonResult; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme; import pc.exam.pp.module.exam.service.paper.IEducationPaperSchemeService; +import pc.exam.pp.module.exam.service.paper.IEducationPaperService; import java.util.List; +import static pc.exam.pp.module.infra.enums.ErrorCodeConstants.DEMO03_PAPER_TASK_DEL_EXISTS; +import static pc.exam.pp.module.infra.enums.ErrorCodeConstants.DEMO03_PAPER_TASK_ADD_EXISTS; + /** * 试卷方案Controller * @@ -20,7 +24,8 @@ public class EducationPaperSchemeController { @Autowired private IEducationPaperSchemeService educationPaperSchemeService; - +@Autowired +private IEducationPaperService educationPaperService; /** * 查询试卷方案列表 */ @@ -58,6 +63,10 @@ public class EducationPaperSchemeController public CommonResult add(@RequestBody EducationPaperScheme educationPaperScheme) { + List strings = educationPaperService.selectPaperByTaskId(educationPaperScheme.getTaskId()); + if (strings!=null&&strings.size()>0){ + return CommonResult.error(DEMO03_PAPER_TASK_ADD_EXISTS); + } return CommonResult.success(educationPaperSchemeService.insertEducationPaperScheme(educationPaperScheme)); } @@ -74,8 +83,13 @@ public class EducationPaperSchemeController * 删除试卷方案 */ @DeleteMapping("/{schemeIds}") - public CommonResult remove(@PathVariable String[] schemeIds) + public CommonResult remove(@PathVariable String schemeIds) { - return CommonResult.success(educationPaperSchemeService.deleteEducationPaperSchemeBySchemeIds(schemeIds)); + EducationPaperScheme educationPaperScheme = educationPaperSchemeService.selectEducationPaperSchemeBySchemeId(schemeIds); + List strings = educationPaperService.selectPaperByTaskId(educationPaperScheme.getTaskId()); + if (strings!=null&&strings.size()>0){ + return CommonResult.error(DEMO03_PAPER_TASK_DEL_EXISTS); + } + return CommonResult.success(educationPaperSchemeService.deleteEducationPaperSchemeBySchemeId(schemeIds)); } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSessionController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSessionController.java index 1fe2f769..5c878f8f 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSessionController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperSessionController.java @@ -140,6 +140,14 @@ public class EducationPaperSessionController ); } + /** + * 获取试卷场次答题时间 + */ + @GetMapping(value = "/getTime/{taskId}") + public CommonResult getAnswerTime(@PathVariable("taskId") String taskId) + { + return CommonResult.success(educationPaperSessionService.getAnswerTime(taskId)); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java index ac5dcc09..87c7e656 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java @@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.*; import pc.exam.pp.framework.common.pojo.CommonResult; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.common.util.object.BeanUtils; +import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; import pc.exam.pp.framework.tenant.core.context.TenantContextHolder; import pc.exam.pp.module.exam.controller.admin.paper.dto.SchemeParam; import pc.exam.pp.module.exam.controller.admin.paper.dto.StatusDto; @@ -37,7 +38,19 @@ public class EducationPaperTaskController @GetMapping("/list") public CommonResult> list(PaperTaskPageVo educationPaperTask) { + PageResult pageResult = educationPaperTaskService.selectEducationPaperTaskList(educationPaperTask); + + + + return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class)); + + } + + @GetMapping("/stulist") + public CommonResult> stulist(PaperTaskPageVo educationPaperTask) + { + PageResult pageResult =educationPaperTaskService.selectEducationPaperTaskListByStu(educationPaperTask); return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class)); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPaperVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPaperVo.java index e68f9b08..c391fbb6 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPaperVo.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPaperVo.java @@ -1,15 +1,19 @@ package pc.exam.pp.module.exam.controller.admin.paper.vo; import lombok.Data; +import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; import java.util.List; @Data public class ExamPaperVo { + String paperId; List questionList; List educationPaperSchemeList; - String paperId; + EducationPaperParam educationPaperParam; + + StuInfoPaper stuInfoPaper; public ExamPaperVo() { } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPersonVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPersonVo.java index d6c9f56e..baca64db 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPersonVo.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/ExamPersonVo.java @@ -1,15 +1,17 @@ package pc.exam.pp.module.exam.controller.admin.paper.vo; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; import pc.exam.pp.framework.common.pojo.PageParam; @Schema(description = "试卷人员vo") @Data -@EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ExamPersonVo extends PageParam { +public class ExamPersonVo { /* 试卷任务Id */ @@ -18,4 +20,29 @@ public class ExamPersonVo extends PageParam { 场次Id */ private String sessionId; + + + private static final Integer PAGE_NO = 1; + private static final Integer PAGE_SIZE = 10; + + /** + * 每页条数 - 不分页 + * + * 例如说,导出接口,可以设置 {@link #pageSize} 为 -1 不分页,查询所有数据。 + */ + public static final Integer PAGE_SIZE_NONE = -1; + + @Schema(description = "页码,从 1 开始", requiredMode = Schema.RequiredMode.REQUIRED,example = "1") + @NotNull(message = "页码不能为空") + @Min(value = 1, message = "页码最小值为 1") + private Integer pageNo = PAGE_NO; + + @Schema(description = "每页条数,最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") + @NotNull(message = "每页条数不能为空") + @Min(value = 1, message = "每页条数最小值为 1") + @Max(value = 100, message = "每页条数最大值为 100") + private Integer pageSize = PAGE_SIZE; + public Integer getOffset() { + return (this.pageNo - 1) * this.pageSize; + } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/SessionStuPageReqVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/SessionStuPageReqVO.java index f4913bd8..a0a818df 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/SessionStuPageReqVO.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/SessionStuPageReqVO.java @@ -1,6 +1,9 @@ package pc.exam.pp.module.exam.controller.admin.paper.vo; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -15,8 +18,7 @@ import static pc.exam.pp.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_ @Data @NoArgsConstructor @AllArgsConstructor -@EqualsAndHashCode(callSuper = true) -public class SessionStuPageReqVO extends PageParam { +public class SessionStuPageReqVO { @Schema(description = "用户账号,模糊匹配", example = "exam") private String username; @@ -50,4 +52,28 @@ public class SessionStuPageReqVO extends PageParam { + private static final Integer PAGE_NO = 1; + private static final Integer PAGE_SIZE = 10; + + /** + * 每页条数 - 不分页 + * + * 例如说,导出接口,可以设置 {@link #pageSize} 为 -1 不分页,查询所有数据。 + */ + public static final Integer PAGE_SIZE_NONE = -1; + + @Schema(description = "页码,从 1 开始", requiredMode = Schema.RequiredMode.REQUIRED,example = "1") + @NotNull(message = "页码不能为空") + @Min(value = 1, message = "页码最小值为 1") + private Integer pageNo = PAGE_NO; + + @Schema(description = "每页条数,最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") + @NotNull(message = "每页条数不能为空") + @Min(value = 1, message = "每页条数最小值为 1") + @Max(value = 100, message = "每页条数最大值为 100") + private Integer pageSize = PAGE_SIZE; + public Integer getOffset() { + return (this.pageNo - 1) * this.pageSize; + } + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/StuInfoPaper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/StuInfoPaper.java new file mode 100644 index 00000000..6542296e --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/StuInfoPaper.java @@ -0,0 +1,28 @@ +package pc.exam.pp.module.exam.controller.admin.paper.vo; + +import lombok.Data; + +import java.sql.Time; + +@Data +public class StuInfoPaper { + //考生名称 + private String nickName; + //学校 + private String schoolName; + //考生场次 + private String batch; + //准考证 + private String userName; + //身份证 + private String sfz; + //任务名称 + private String taskName; + //试卷总分 + private String paperScore; + //题目数量 + private String queNum; + + private Time answerTime; + +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java index f39615f0..242496ed 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java @@ -2,20 +2,31 @@ package pc.exam.pp.module.exam.controller.admin.question; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; +import jakarta.validation.Valid; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.hssf.record.DVALRecord; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import pc.exam.pp.framework.common.pojo.CommonResult; import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; import pc.exam.pp.module.exam.controller.admin.question.dto.ExamQuestionDto; +import pc.exam.pp.module.exam.controller.admin.question.dto.TenantDto; import pc.exam.pp.module.exam.controller.admin.question.vo.QuestionVo; +import pc.exam.pp.module.exam.controller.admin.question.vo.TenantVo; +import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExaminePageReqVO; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; import pc.exam.pp.module.exam.service.question.IExamQuestionService; import java.util.List; +import static pc.exam.pp.framework.common.pojo.CommonResult.error; import static pc.exam.pp.framework.common.pojo.CommonResult.success; +import static pc.exam.pp.module.system.enums.ErrorCodeConstants.QESESTION_NOT_NULL; +import static pc.exam.pp.module.system.enums.ErrorCodeConstants.QESESTION_AUDIT_ERROR; /** * 试题(hyc)Controller @@ -43,6 +54,41 @@ public class ExamQuestionController return success(pageResult); } + /** + * 查询除了审核状态通过的其他状态的试题(试题推送) + * @param questionVo + * @return + */ + @GetMapping("/sendList") + public CommonResult> sendList(QuestionVo questionVo) + { + PageResult pageResult; + if (StringUtils.isNotBlank(questionVo.getAudit())){ + pageResult= examQuestionService.selectExamQuestionList(questionVo); + }else { + pageResult = examQuestionService.selectExamQuestionListSend(questionVo); + } + + return success(pageResult); + } + + /** + * 查询试题(试题审核) + * @return + */ + @GetMapping("/auditList") + @TenantIgnore + public CommonResult> auditList(@Valid QuestionExaminePageReqVO pageReqVO) + { + + PageResult pageResult= examQuestionService.selectExamQuestionListNoAudit(pageReqVO); + + // pageResult= examQuestionService.selectExamQuestionListAudit(pageReqVO); + + return success(pageResult); + } + + /** * 导出试题(hyc)列表 */ @@ -64,7 +110,16 @@ public class ExamQuestionController { return success(examQuestionService.selectExamQuestionByQuId(quId)); } - + /** + * 获取试题(hyc)详细信息 无租户id + */ + //@PreAu + @GetMapping(value = "/notId/{quId}") + @TenantIgnore + public CommonResult getInfoNotId(@PathVariable("quId") String quId) + { + return success(examQuestionService.selectExamQuestionByQuId(quId)); + } /** * 新增试题(hyc) */ @@ -80,7 +135,6 @@ public class ExamQuestionController /** * 修改试题(hyc) */ - //@PreAuthorize("@ss.hasPermi('system:question:edit')") @PutMapping public CommonResult edit(@RequestBody ExamQuestion examQuestion) { @@ -90,14 +144,61 @@ public class ExamQuestionController /** * 删除试题(hyc) */ - //@PreAuthorize("@ss.hasPermi('system:question:remove')") @DeleteMapping("/{ids}") public CommonResult remove(@PathVariable String[] ids) { return success(examQuestionService.deleteExamQuestionByQuIds(ids)); } + /** + *获得学校列表 + * @return + */ + @GetMapping("/getSchoolName") + @TenantIgnore + public CommonResult> getSchoolName(TenantDto tenantDto) + { + return success(examQuestionService.getSchoolName(tenantDto)); + } + /** + * 服务端审核通过试题 + * @param quIds + * @return + */ + @PostMapping("/auditQue") + @TenantIgnore + public CommonResult auditQue(@RequestBody List quIds) { + if (CollectionUtils.isEmpty(quIds)) { + return CommonResult.error(QESESTION_NOT_NULL); + } + int b = examQuestionService.auditQueByIds(quIds); + if (b>0){ + return success("审核成功"); + } + else { + return error(QESESTION_AUDIT_ERROR); + } + } + /** + * 服务端审核不通过试题 + * @param quIds + * @return + */ + @PostMapping("/noauditQue") + @TenantIgnore + public CommonResult noAuditQue(@RequestBody List quIds) { + if (CollectionUtils.isEmpty(quIds)) { + return CommonResult.error(QESESTION_NOT_NULL); + } + int b = examQuestionService.noAuditQue(quIds); + if (b>0){ + return success("操作成功"); + + }else { + return error(QESESTION_AUDIT_ERROR); + } + } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/dto/TenantDto.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/dto/TenantDto.java new file mode 100644 index 00000000..0af029ef --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/dto/TenantDto.java @@ -0,0 +1,36 @@ +package pc.exam.pp.module.exam.controller.admin.question.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import pc.exam.pp.framework.common.pojo.PageParam; +@Data +public class TenantDto { + + private String name; + private static final Integer PAGE_NO = 1; + private static final Integer PAGE_SIZE = 10; + + /** + * 每页条数 - 不分页 + * + * 例如说,导出接口,可以设置 {@link #pageSize} 为 -1 不分页,查询所有数据。 + */ + public static final Integer PAGE_SIZE_NONE = -1; + + @Schema(description = "页码,从 1 开始", requiredMode = Schema.RequiredMode.REQUIRED,example = "1") + @NotNull(message = "页码不能为空") + @Min(value = 1, message = "页码最小值为 1") + private Integer pageNo = PAGE_NO; + + @Schema(description = "每页条数,最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") + @NotNull(message = "每页条数不能为空") + @Min(value = 1, message = "每页条数最小值为 1") + @Max(value = 100, message = "每页条数最大值为 100") + private Integer pageSize = PAGE_SIZE; + public Integer getOffset() { + return (this.pageNo - 1) * this.pageSize; + } +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/TenantVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/TenantVo.java new file mode 100644 index 00000000..48ca8b24 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/TenantVo.java @@ -0,0 +1,14 @@ +package pc.exam.pp.module.exam.controller.admin.question.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TenantVo { + private String id; + private String name; + private String ququeName; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/questionexamine/QuestionExamineController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/questionexamine/QuestionExamineController.java new file mode 100644 index 00000000..2cc93118 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/questionexamine/QuestionExamineController.java @@ -0,0 +1,99 @@ +package pc.exam.pp.module.exam.controller.admin.questionexamine; + +import org.springframework.web.bind.annotation.*; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import jakarta.validation.constraints.*; +import jakarta.validation.*; +import jakarta.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import pc.exam.pp.framework.common.pojo.PageParam; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.common.pojo.CommonResult; +import pc.exam.pp.framework.common.util.object.BeanUtils; +import static pc.exam.pp.framework.common.pojo.CommonResult.success; + +import pc.exam.pp.framework.excel.core.util.ExcelUtils; + +import pc.exam.pp.framework.apilog.core.annotation.ApiAccessLog; +import static pc.exam.pp.framework.apilog.core.enums.OperateTypeEnum.*; + +import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; +import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExaminePageReqVO; +import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExamineRespVO; +import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExamineSaveReqVO; +import pc.exam.pp.module.exam.dal.dataobject.QuestionExamineDO; +import pc.exam.pp.module.exam.service.questionexamine.QuestionExamineService; + +@Tag(name = "管理后台 - 试题交互中间") +@RestController +@RequestMapping("/education/question-examine") +@Validated +public class QuestionExamineController { + + @Resource + private QuestionExamineService questionExamineService; + + @PostMapping("/create") + @Operation(summary = "创建试题交互中间") + public CommonResult createQuestionExamine(@Valid @RequestBody QuestionExamineSaveReqVO createReqVO) { + return success(questionExamineService.createQuestionExamine(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新试题交互中间") + public CommonResult updateQuestionExamine(@Valid @RequestBody QuestionExamineSaveReqVO updateReqVO) { + questionExamineService.updateQuestionExamine(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除试题交互中间") + @Parameter(name = "id", description = "编号", required = true) + public CommonResult deleteQuestionExamine(@RequestParam("id") String id) { + questionExamineService.deleteQuestionExamine(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得试题交互中间") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + public CommonResult getQuestionExamine(@RequestParam("id") String id) { + QuestionExamineDO questionExamine = questionExamineService.getQuestionExamine(id); + return success(BeanUtils.toBean(questionExamine, QuestionExamineRespVO.class)); + } + + + + + + @GetMapping("/page") + @Operation(summary = "获得试题交互中间分页") + public CommonResult> getQuestionExaminePage(@Valid QuestionExaminePageReqVO pageReqVO) { + PageResult pageResult = questionExamineService.getQuestionExaminePage(pageReqVO); + return success(BeanUtils.toBean(pageResult, QuestionExamineRespVO.class)); + } + + + + + @GetMapping("/export-excel") + @Operation(summary = "导出试题交互中间 Excel") + @ApiAccessLog(operateType = EXPORT) + public void exportQuestionExamineExcel(@Valid QuestionExaminePageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = questionExamineService.getQuestionExaminePage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "试题交互中间.xls", "数据", QuestionExamineRespVO.class, + BeanUtils.toBean(list, QuestionExamineRespVO.class)); + } + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/questionexamine/vo/QuestionExaminePageReqVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/questionexamine/vo/QuestionExaminePageReqVO.java new file mode 100644 index 00000000..e2fd6f22 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/questionexamine/vo/QuestionExaminePageReqVO.java @@ -0,0 +1,34 @@ +package pc.exam.pp.module.exam.controller.admin.questionexamine.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import pc.exam.pp.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static pc.exam.pp.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 试题交互中间分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class QuestionExaminePageReqVO extends PageParam { + +@Schema(description = "试题id", example = "18177") +private String quId; + +@Schema(description = "租户") +private String source; + +@Schema(description = "创建人") +private String createTeacher; + +@Schema(description = "种类(0新增试题1错题)", example = "2") +private String type; + +@Schema(description = "创建时间") +@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) +private LocalDateTime[] createTime; + +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/questionexamine/vo/QuestionExamineRespVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/questionexamine/vo/QuestionExamineRespVO.java new file mode 100644 index 00000000..e31e29b5 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/questionexamine/vo/QuestionExamineRespVO.java @@ -0,0 +1,39 @@ +package pc.exam.pp.module.exam.controller.admin.questionexamine.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 试题交互中间 Response VO") +@Data +@ExcelIgnoreUnannotated +public class QuestionExamineRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "11417") + @ExcelProperty("主键") + private String examineId; + + @Schema(description = "试题id", example = "18177") + @ExcelProperty("试题id") + private String quId; + + @Schema(description = "租户") + @ExcelProperty("租户") + private String source; + + @Schema(description = "创建人") + @ExcelProperty("创建人") + private String createTeacher; + + @Schema(description = "种类(0新增试题1错题)", example = "2") + @ExcelProperty("种类(0新增试题1错题)") + private String type; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/questionexamine/vo/QuestionExamineSaveReqVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/questionexamine/vo/QuestionExamineSaveReqVO.java new file mode 100644 index 00000000..3a9a1940 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/questionexamine/vo/QuestionExamineSaveReqVO.java @@ -0,0 +1,27 @@ +package pc.exam.pp.module.exam.controller.admin.questionexamine.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import jakarta.validation.constraints.*; + +@Schema(description = "管理后台 - 试题交互中间新增/修改 Request VO") +@Data +public class QuestionExamineSaveReqVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "11417") + private String examineId; + + @Schema(description = "试题id", example = "18177") + private String quId; + + @Schema(description = "租户") + private String source; + + @Schema(description = "创建人") + private String createTeacher; + + @Schema(description = "种类(0新增试题1错题)", example = "2") + private String type; + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/RabbitMQController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/RabbitMQController.java index 6699be5b..2e402d0f 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/RabbitMQController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/RabbitMQController.java @@ -2,15 +2,28 @@ package pc.exam.pp.module.exam.controller.admin.rabbitmq; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import pc.exam.pp.framework.common.pojo.CommonResult; +import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; +import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; +import pc.exam.pp.framework.tenant.core.service.TenantFrameworkService; +import pc.exam.pp.module.exam.controller.admin.rabbitmq.vo.PushRequestVo; import pc.exam.pp.module.exam.controller.admin.rabbitmq.vo.RabbitMQSendInfoVO; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; import pc.exam.pp.module.exam.service.question.ExamQuestionServiceImpl; import pc.exam.pp.module.exam.utils.rabbitmq.RabbitmqUtils; +import java.util.ArrayList; import java.util.List; +import static pc.exam.pp.module.system.enums.ErrorCodeConstants.RABBITMQ_NOT_EXISTS; +import static pc.exam.pp.module.system.enums.ErrorCodeConstants.RABBITMQ_NAME_NOT_NULL; +import static pc.exam.pp.module.system.enums.ErrorCodeConstants.RABBITMQ_CONNECT_EXISTS; + + @RestController @RequestMapping("/rabbitmq") @Tag( name = "rabbitmq 消息队列") @@ -20,14 +33,26 @@ public class RabbitMQController { private RabbitmqUtils rabbitMqService; @Resource private ExamQuestionServiceImpl examQuestionService; + + /** * 连接Rabbitmq - * @param queueName 队列名称 * @return 连接状态 */ @PostMapping("/connect") - public String connect(@RequestParam String queueName) { - return rabbitMqService.connect(queueName,"name"); +// public String connect(@RequestParam String queueName) { + public CommonResult connect() { + String queueName = SecurityFrameworkUtils.getLoginQueueName(); + int connect = rabbitMqService.connect(queueName); + if (connect == 0 ){ + return CommonResult.success("已经连接"); + } + if (connect ==1){ + return CommonResult.success("连接成功"); + } + + return CommonResult.error(RABBITMQ_CONNECT_EXISTS); + } /** @@ -46,19 +71,105 @@ public class RabbitMQController { */ @PostMapping("/send") public int sendMessage(@RequestBody RabbitMQSendInfoVO rabbitMQSendInfoVO) { + rabbitMQSendInfoVO.setQueueName(SecurityFrameworkUtils.getLoginQueueName()); return examQuestionService.uploadExamQuestionToRabbitMQ(rabbitMQSendInfoVO); } /** - * 全部接收消息 - * @param queueName 队列名称-客户端代码 + * 全部接收消息(学校中心或服务器接收中心服务器推送的试题) + 队列名称-客户端代码 * @return 接收结果 */ @GetMapping("/receiveAll") - public List receiveMessage(@RequestParam String queueName) { - return examQuestionService.getExamQuestionToRabbitMQ(queueName); +// public List receiveMessage(@RequestParam String queueName) { + public CommonResult receiveMessage() { + String queueName = SecurityFrameworkUtils.getLoginQueueName(); + boolean examQuestionToRabbitMQ = examQuestionService.getExamQuestionToRabbitMQInsertData(queueName); + if (examQuestionToRabbitMQ){ + return CommonResult.success("接收成功"); + }else { + return CommonResult.error(RABBITMQ_NOT_EXISTS); + } } + /** + * 服务器连接学校 + * @param queueNames + * @return + */ + @PostMapping("/connectSchoolAll") + public CommonResult connectSchoolAll(@RequestBody List queueNames) { + if (CollectionUtils.isEmpty(queueNames)) { + return CommonResult.error(RABBITMQ_NAME_NOT_NULL); + } + List failedQueues = new ArrayList<>(); + + for (String queueName : queueNames) { + boolean examQuestionToRabbitMQ = rabbitMqService.connectSchool(queueName); + if (!examQuestionToRabbitMQ) { + failedQueues.add(queueName); + } + } + + if (failedQueues.isEmpty()) { + return CommonResult.success("全部连接成功"); + } else { + return CommonResult.error(1_005_005_023,"以下学校全部连接失败:" + String.join(", ", failedQueues)); + } + + } + /** + * 接收学校的试题 + * @param queueNames + * @return + */ + @PostMapping("/receiveSchoolAll") + public CommonResult receiveSchoolMessage(@RequestBody List queueNames) { + if (CollectionUtils.isEmpty(queueNames)) { + return CommonResult.error(RABBITMQ_NAME_NOT_NULL); + } + List failedQueues = new ArrayList<>(); + + for (String queueName : queueNames) { + boolean examQuestionToRabbitMQ = examQuestionService.getExamQuestionToRabbitMQ(queueName); + if (!examQuestionToRabbitMQ) { + failedQueues.add(queueName); + } + } + + if (failedQueues.isEmpty()) { + return CommonResult.success("全部接收成功"); + } else { + return CommonResult.error(1_005_005_023,"以下学校接收失败:" + String.join(", ", failedQueues)); + } + + + } + + /** + * 服务器推送学校试题 到mqtt + * @param request + * @return + */ + @PostMapping("/doPush") + @TenantIgnore + public CommonResult doPush(@RequestBody PushRequestVo request) { + List queueNames = request.getQueueNames(); + List questionIds = request.getQuestionIds(); + System.out.println(queueNames); + System.out.println(questionIds); + for (String queueName : queueNames) { + RabbitMQSendInfoVO rabbitMQSendInfoVO=new RabbitMQSendInfoVO(); + rabbitMQSendInfoVO.setType("0"); + rabbitMQSendInfoVO.setQuIds(questionIds); + rabbitMQSendInfoVO.setQueueName(queueName); + examQuestionService.uploadExamQuestionToRabbitMQBySource(rabbitMQSendInfoVO); + } + + return CommonResult.success("推送成功"); + } + + /** * 关闭 * @return 关闭结果 diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/vo/PushRequestVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/vo/PushRequestVo.java new file mode 100644 index 00000000..b62e47c0 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/rabbitmq/vo/PushRequestVo.java @@ -0,0 +1,11 @@ +package pc.exam.pp.module.exam.controller.admin.rabbitmq.vo; + +import lombok.Data; + +import java.util.List; + +@Data +public class PushRequestVo { + private List queueNames; + private List questionIds; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperParam.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperParam.java index 32d6ec9e..1f123d6f 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperParam.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperParam.java @@ -1,12 +1,15 @@ package pc.exam.pp.module.exam.dal.dataobject; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import lombok.experimental.Accessors; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import java.sql.Time; + /** * 通用参数对象 education_paper_param * @@ -77,4 +80,9 @@ public class EducationPaperParam private String isConnect; private String isSession; + + private String isTime; + @JsonFormat(pattern = "HH:mm:ss", timezone = "Asia/Shanghai") + private Time examTime = Time.valueOf("01:00:00"); // 默认 1 小时 + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java index 6c5dfadd..c345cac9 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java @@ -118,5 +118,7 @@ public class ExamQuestion extends TenantBaseDO { @TableField(exist = false) private String type; + @TableField(exist = false) + private String schoolName; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/QuestionExamineDO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/QuestionExamineDO.java new file mode 100644 index 00000000..4b144795 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/QuestionExamineDO.java @@ -0,0 +1,55 @@ + +package pc.exam.pp.module.exam.dal.dataobject; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import org.apache.ibatis.type.JdbcType; +import pc.exam.pp.framework.mybatis.core.dataobject.BaseDO; + +/** + * 试题交互中间 DO + * + * @author 管理员 + */ +@TableName("education_question_examine") +@KeySequence("education_question_examine_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class QuestionExamineDO { + + +/** + * 试题id + */ +@TableId(type = IdType.INPUT) +private String quId; +/** + * 租户 + */ +private Long source; +/** + * 创建人 + */ +private String createTeacher; +/** + * 种类(0新增试题1错题) + */ +private String type; + +@TableField(fill = FieldFill.INSERT) +private LocalDateTime createTime; + +@TableField(fill = FieldFill.INSERT_UPDATE) +private LocalDateTime updateTime; + +/** + * 审核人,目前使用 SysUser 的 id 编号 + */ +@TableField(fill = FieldFill.INSERT_UPDATE, jdbcType = JdbcType.VARCHAR) +private String updater; +} \ 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/EducationPaperPersonMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperPersonMapper.java index 39693fdd..c63cca34 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperPersonMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperPersonMapper.java @@ -9,6 +9,7 @@ import pc.exam.pp.framework.mybatis.core.query.MPJLambdaWrapperX; import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; import pc.exam.pp.module.exam.controller.admin.paper.dto.PersonRepDto; import pc.exam.pp.module.exam.controller.admin.paper.vo.DeleteRequestVo; +import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPersonVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.SessionStuPageReqVO; import pc.exam.pp.module.exam.controller.admin.paper.vo.StudentSessionReqVO; import pc.exam.pp.module.exam.controller.admin.student.vo.StudentPageReqVO; @@ -32,10 +33,9 @@ public interface EducationPaperPersonMapper /** * 查询试卷人员分配 * - * @param taskId 试卷人员分配主键 * @return 试卷人员分配 */ - List selectEducationPaperPersonByTaskId(String taskId); + List selectEducationPaperPersonByTaskId(ExamPersonVo examPersonVo); /** * 查询试卷人员分配列表 @@ -86,7 +86,7 @@ public interface EducationPaperPersonMapper String selectUserClassName(Long classId); - List selectEducationPaperPersonBySessionId(String sessionId); + List selectEducationPaperPersonBySessionId(ExamPersonVo examPersonVo); List selectEducationPaperPersonByNotInSessionId(SessionStuPageReqVO sessionStuPageReqVO); @@ -108,4 +108,16 @@ public interface EducationPaperPersonMapper List selectEducationPaperPersonBySessionIdNotIn(SessionStuPageReqVO sessionStuPageReqVO); List selectStuIdByTaskId(String taskId); + + List selectTaskIdByStuid(Long loginUserId); + + long selectEducationPaperPersonBySessionIdTotal(String sessionId); + + long selectEducationPaperPersonByTaskIdTotal(String taskId); + + + long selectEducationPaperPersonByNotInSessionIdTotal(SessionStuPageReqVO sessionStuPageReqVO); + + long selectEducationPaperPersonBySessionIdNotInTotal(SessionStuPageReqVO sessionStuPageReqVO); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperSessionMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperSessionMapper.java index 917cd178..eb81bf58 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperSessionMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperSessionMapper.java @@ -1,5 +1,6 @@ package pc.exam.pp.module.exam.dal.mysql.paper; +import java.sql.Time; import java.util.List; import org.apache.ibatis.annotations.Mapper; @@ -90,4 +91,6 @@ public interface EducationPaperSessionMapper extends BaseMapperX ); } + /** + * 查询除了审核状态为通过的其他试题 + * @param questionVo + * @return + */ + default PageResult selectExamQuestionListNO(QuestionVo questionVo) { + return selectPage(questionVo, new LambdaQueryWrapperX() + .likeIfPresent(ExamQuestion::getQuLevel, questionVo.getQuLevel()) + .likeIfPresent(ExamQuestion::getCourseName, questionVo.getCourseName()) + .likeIfPresent(ExamQuestion::getPointNames, questionVo.getPointNames()) + .likeIfPresent(ExamQuestion::getSpecialtyName, questionVo.getSpecialtyName()) + .likeIfPresent(ExamQuestion::getSubjectName, questionVo.getSubjectName()) + .neIfPresent(ExamQuestion::getAudit, 0) // 改为 audit != 0 + .likeIfPresent(ExamQuestion::getStatus, questionVo.getStatus()) + ); + } /** * 新增试题(hyc) @@ -81,4 +99,22 @@ public interface ExamQuestionMapper extends BaseMapperX public int deleteExamQuestionByQuIds(@Param("ids") String[] ids); List selectExamQuestionListByQuIds(List quIds); + + void setQuestionAuditByids(@Param("quIds")List quIds); + + List getSchoolName(TenantDto tenantDto); + + + long getSchoolNameTotal(TenantDto tenantDto); + + int auditQueByIds(@Param("quIds")List quIds); + + int noAuditQue(@Param("quIds")List quIds); + + + ExamQuestion selectExamQuestionByQuIdAndTenantId(@Param("quId") String quId, @Param("source")Long source); + + List seleAllQueueName(); + + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/questionexamine/QuestionExamineMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/questionexamine/QuestionExamineMapper.java new file mode 100644 index 00000000..e018e032 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/questionexamine/QuestionExamineMapper.java @@ -0,0 +1,35 @@ +package pc.exam.pp.module.exam.dal.mysql.questionexamine; + + +import java.util.*; + +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; +import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import org.apache.ibatis.annotations.Mapper; +import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExaminePageReqVO; +import pc.exam.pp.module.exam.dal.dataobject.QuestionExamineDO; + +/** +* 试题交互中间 Mapper +* +* @author 管理员 +*/ +@Mapper +public interface QuestionExamineMapper extends BaseMapperX { + +default PageResult selectPage(QuestionExaminePageReqVO reqVO) { +return selectPage(reqVO, new LambdaQueryWrapperX() +.eqIfPresent(QuestionExamineDO::getQuId, reqVO.getQuId()) +.eqIfPresent(QuestionExamineDO::getSource, reqVO.getSource()) +.eqIfPresent(QuestionExamineDO::getCreateTeacher, reqVO.getCreateTeacher()) +.eqIfPresent(QuestionExamineDO::getType, reqVO.getType()) +.betweenIfPresent(QuestionExamineDO::getCreateTime, reqVO.getCreateTime()) +.orderByDesc(QuestionExamineDO::getCreateTime)); +} + + void insertOrUpdateList(List questionExamineDOS); + + String selectSchoolName(Long source); + +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/job/QuestionDownJob.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/job/QuestionDownJob.java new file mode 100644 index 00000000..b23585c7 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/job/QuestionDownJob.java @@ -0,0 +1,65 @@ +package pc.exam.pp.module.exam.job; + +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import pc.exam.pp.framework.quartz.core.handler.JobHandler; +import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; +import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; +import pc.exam.pp.module.exam.service.question.IExamQuestionService; +import pc.exam.pp.module.exam.utils.rabbitmq.RabbitmqUtils; + +import java.util.ArrayList; +import java.util.List; + +@Component +@Slf4j +public class QuestionDownJob implements JobHandler { + @Resource + private RabbitmqUtils rabbitMqService; + @Resource + private ExamQuestionMapper examQuestionMapper; + @Resource + private IExamQuestionService examQuestionService; + @Override + public String execute(String param) throws Exception { + + + List queueNames= examQuestionMapper.seleAllQueueName(); + log.info(queueNames.toString()+"所有学校队列名"); + if (queueNames!=null){ + List failedQueues = new ArrayList<>(); + List successQueues = new ArrayList<>(); + List failedQueues1 = new ArrayList<>(); + List successQueues2 = new ArrayList<>(); + for (String queueName : queueNames) { + boolean examQuestionToRabbitMQ = rabbitMqService.connectSchool(queueName); + if (!examQuestionToRabbitMQ) { + failedQueues.add(queueName); + }else { + successQueues.add(queueName); + } + } + for (String queueName : successQueues) { + try { + boolean examQuestionToRabbitMQ = examQuestionService.getExamQuestionToRabbitMQ(queueName); + if (!examQuestionToRabbitMQ) { + failedQueues1.add(queueName); + } else { + successQueues2.add(queueName); + } + } catch (Exception e) { + log.error("拉取队列 {} 时异常:{}", queueName, e.getMessage()); + failedQueues1.add(queueName); + } + } + log.info(failedQueues.toString()+"连接失败的学校"); + log.info(successQueues.toString()+"连接成功的学校"); + log.info(failedQueues1.toString()+"拉取失败的学校"); + log.info(successQueues2.toString()+"拉取成功的学校"); + rabbitMqService.disconnect(); + } + + return null; + } +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperParamServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperParamServiceImpl.java index 9701c15d..d26358f5 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperParamServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperParamServiceImpl.java @@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperParamMapper; +import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperTaskMapper; import java.util.List; @@ -19,7 +20,8 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi { @Autowired private EducationPaperParamMapper educationPaperParamMapper; - + @Autowired + private EducationPaperTaskMapper educationPaperTaskMapper; /** * 查询通用参数 * diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java index f2da8756..16dffda0 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java @@ -15,6 +15,7 @@ import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.common.util.json.JsonUtils; import pc.exam.pp.module.exam.controller.admin.paper.dto.PersonRepDto; import pc.exam.pp.module.exam.controller.admin.paper.vo.DeleteRequestVo; +import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPersonVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.SessionStuPageReqVO; import pc.exam.pp.module.exam.controller.admin.paper.vo.StudentSessionReqVO; import pc.exam.pp.module.exam.controller.admin.student.vo.StudentPageReqVO; @@ -61,13 +62,13 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer /** * 查询试卷人员分配 * - * @param taskId 试卷人员分配主键 * @return 试卷人员分配 */ @Override - public PageResult selectEducationPaperPersonByTaskId(String taskId) + public PageResult selectEducationPaperPersonByTaskId(ExamPersonVo examPersonVo) { - List educationPaperPeoples= educationPaperPersonMapper.selectEducationPaperPersonByTaskId(taskId); + List educationPaperPeoples= educationPaperPersonMapper.selectEducationPaperPersonByTaskId(examPersonVo); + long total= educationPaperPersonMapper.selectEducationPaperPersonByTaskIdTotal(examPersonVo.getTaskId()); List personRepDtos=new ArrayList<>(); if (educationPaperPeoples!=null&&educationPaperPeoples.size()>0){ for (EducationPaperPerson educationPaperPerson : educationPaperPeoples) { @@ -84,13 +85,14 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer } PageResult pageResult=new PageResult<>(); pageResult.setList(personRepDtos); - pageResult.setTotal((long) personRepDtos.size()); + pageResult.setTotal(total); return pageResult; } @Override - public PageResult selectEducationPaperPersonBySessionId(String sessionId) { - List educationPaperPeoples= educationPaperPersonMapper.selectEducationPaperPersonBySessionId(sessionId); + public PageResult selectEducationPaperPersonBySessionId(ExamPersonVo examPersonVo) { + List educationPaperPeoples= educationPaperPersonMapper.selectEducationPaperPersonBySessionId(examPersonVo); + long total= educationPaperPersonMapper.selectEducationPaperPersonBySessionIdTotal(examPersonVo.getSessionId()); List personRepDtos=new ArrayList<>(); if (educationPaperPeoples!=null&&educationPaperPeoples.size()>0){ for (EducationPaperPerson educationPaperPerson : educationPaperPeoples) { @@ -107,7 +109,7 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer } PageResult pageResult=new PageResult<>(); pageResult.setList(personRepDtos); - pageResult.setTotal((long) personRepDtos.size()); + pageResult.setTotal(total); return pageResult; } @@ -120,13 +122,16 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer sessionStuPageReqVO.setClassId(classId); } List personRepDtos; - + long total; String sessionId = sessionStuPageReqVO.getSessionId(); if (StringUtils.isNotBlank(sessionId)){ personRepDtos = educationPaperPersonMapper.selectEducationPaperPersonByNotInSessionId(sessionStuPageReqVO); + total=educationPaperPersonMapper.selectEducationPaperPersonByNotInSessionIdTotal(sessionStuPageReqVO); } else { personRepDtos = educationPaperPersonMapper.selectEducationPaperPersonBySessionIdNotIn(sessionStuPageReqVO); + total=educationPaperPersonMapper.selectEducationPaperPersonBySessionIdNotInTotal(sessionStuPageReqVO); + } if (personRepDtos!=null&&personRepDtos.size()>0){ for (PersonRepDto personRepDto : personRepDtos) { @@ -135,7 +140,7 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer } PageResult pageResult=new PageResult<>(); pageResult.setList(personRepDtos); - pageResult.setTotal((long) personRepDtos.size()); + pageResult.setTotal(total); return pageResult; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java index 12df0e9b..79c868d7 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java @@ -1,15 +1,13 @@ package pc.exam.pp.module.exam.service.paper; +import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; -import pc.exam.pp.module.exam.dal.dataobject.EducationPaperQu; -import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme; -import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; -import pc.exam.pp.module.exam.dal.dataobject.SysFileUpload; -import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperMapper; -import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperQuMapper; -import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperSchemeMapper; +import pc.exam.pp.module.exam.controller.admin.paper.vo.StuInfoPaper; +import pc.exam.pp.module.exam.dal.dataobject.*; +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.dal.mysql.question.SysFileMapper; @@ -33,7 +31,15 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService @Autowired private EducationPaperSchemeMapper educationPaperSchemeMapper; @Autowired + private EducationPaperParamMapper educationPaperParamMapper; + @Autowired + private EducationPaperSessionMapper educationPaperSessionMapper; + @Autowired + private EducationPaperPersonMapper educationPaperPersonMapper; + @Autowired private SysFileMapper sysFileMapper; + @Autowired + private EducationPaperTaskMapper educationPaperTaskMapper; /** * 查询试卷试题 * @@ -108,8 +114,7 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService @Override public ExamPaperVo selectPaperQuListByPaperId(String paperId) { - - List quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId); + List quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId); List examQuestionList=examQuestionMapper.selectExamQuestionListByQuIds(quIds); if (examQuestionList!=null&&examQuestionList.size()>0){ @@ -121,12 +126,35 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService } String taskid=educationPaperMapper.selectTaskIdByPaperId(paperId); + EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskid); + List educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskid); - List educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskid); + //试卷试题数 + List educationPaperQus = educationPaperQuMapper.selectPaperQuListByPaperId(paperId); + + + String nickname = SecurityFrameworkUtils.getLoginUserNickname(); + Long userId=SecurityFrameworkUtils.getLoginUserId(); + //设置进入试卷 考生考试信息确认参数 + StuInfoPaper stuInfoPaper=new StuInfoPaper(); + stuInfoPaper.setQueNum(String.valueOf(educationPaperQus.size())); + stuInfoPaper.setNickName(nickname); + + EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(paperId); + EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(taskid, String.valueOf(userId)); + EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskid); + if (educationPaperPerson!=null){ + stuInfoPaper.setBatch(educationPaperPerson.getBatch()); + } + stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime()); + stuInfoPaper.setPaperScore(educationPaper.getPaperScore()); + stuInfoPaper.setTaskName(educationPaperTask.getTaskName()); ExamPaperVo examPaperVo=new ExamPaperVo(); examPaperVo.setPaperId(paperId); examPaperVo.setExamQuestionList(examQuestionList); examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); + examPaperVo.setEducationPaperParam(educationPaperParam); + examPaperVo.setStuInfoPaper(stuInfoPaper); return examPaperVo; } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java index 5e83d839..7df74146 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java @@ -5,11 +5,13 @@ import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; import pc.exam.pp.framework.tenant.core.context.TenantContextHolder; import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo; +import pc.exam.pp.module.exam.controller.admin.paper.vo.StuInfoPaper; import pc.exam.pp.module.exam.dal.dataobject.*; import pc.exam.pp.module.exam.dal.mysql.paper.*; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; @@ -327,12 +329,24 @@ public class EducationPaperServiceImpl implements IEducationPaperService EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskid); - String taskSpecialty = educationPaperTask.getTaskSpecialty(); + EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskid); + String taskSpecialty = educationPaperTask.getTaskSpecialty(); //根据试卷任务id查找方案集合 List educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskid); List examQuestionIds = new ArrayList<>(); + + int totalScore = 0; for (EducationPaperScheme educationPaperScheme : educationPaperSchemeList) { + + try { + totalScore += Integer.parseInt(educationPaperScheme.getSubtotalScore()); + } catch (NumberFormatException e) { + // 非数字按 0 处理 + totalScore += 0; + // 可选:记录日志(避免静默忽略) + throw new RuntimeException("非数字 subtotal_score: {}"+ educationPaperScheme.getSubtotalScore()); + } //获取试卷方案对象 String pointNames = educationPaperScheme.getPointNames(); //知识点id @@ -374,10 +388,14 @@ public class EducationPaperServiceImpl implements IEducationPaperService educationPaper.setPaperId(uuid); educationPaper.setTaskId(taskid); educationPaper.setNum(formattedNumber); + educationPaper.setPaperScore(String.valueOf(totalScore)); educationPaper.setTenantId(TenantContextHolder.getRequiredTenantId()); + + + + educationPaperMapper.insertEducationPaper(educationPaper); - System.out.println(examQuestionIds+"examQuestionIdsexamQuestionIds"); //构建试卷试题对象 List educationPaperQus=new ArrayList<>(); @@ -404,10 +422,33 @@ public class EducationPaperServiceImpl implements IEducationPaperService } } - ExamPaperVo examPaperVo=new ExamPaperVo(); + + + //设置进入试卷 考生考试信息确认参数 + String nickname = SecurityFrameworkUtils.getLoginUserNickname(); + Long userId=SecurityFrameworkUtils.getLoginUserId(); + + EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(taskid, String.valueOf(userId)); + StuInfoPaper stuInfoPaper=new StuInfoPaper(); + stuInfoPaper.setQueNum(String.valueOf(educationPaperQus.size())); + stuInfoPaper.setNickName(nickname); + + if (educationPaperPerson!=null){ + stuInfoPaper.setBatch(educationPaperPerson.getBatch()); + } + stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime()); + stuInfoPaper.setPaperScore(educationPaper.getPaperScore()); + stuInfoPaper.setTaskName(educationPaperTask.getTaskName()); + + + + + ExamPaperVo examPaperVo=new ExamPaperVo(); examPaperVo.setExamQuestionList(examQuestionList); examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); + examPaperVo.setEducationPaperParam(educationPaperParam); examPaperVo.setPaperId(uuid); + examPaperVo.setStuInfoPaper(stuInfoPaper); return examPaperVo; diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperSessionServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperSessionServiceImpl.java index 5733ecc6..27789336 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperSessionServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperSessionServiceImpl.java @@ -9,6 +9,7 @@ import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperPersonMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperSessionMapper; import pc.exam.pp.module.exam.utils.uuid.IdUtils; +import java.sql.Time; import java.util.List; /** @@ -104,4 +105,9 @@ public class EducationPaperSessionServiceImpl implements IEducationPaperSessionS public int changeStatus(String sessionId, String status) { return educationPaperSessionMapper.changeStatus(sessionId,status); } + + @Override + public Time getAnswerTime(String taskId) { + return educationPaperSessionMapper.getAnswerTime(taskId); + } } 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 cd5bd47c..c8d8f7b1 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 @@ -2,16 +2,19 @@ package pc.exam.pp.module.exam.service.paper; import com.alibaba.excel.util.StringUtils; +import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; import pc.exam.pp.framework.tenant.core.context.TenantContextHolder; import pc.exam.pp.module.exam.controller.admin.paper.dto.SchemeParam; import pc.exam.pp.module.exam.controller.admin.paper.dto.TempDto; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperTaskPageVo; +import pc.exam.pp.module.exam.controller.admin.paper.vo.StuInfoPaper; import pc.exam.pp.module.exam.dal.dataobject.*; import pc.exam.pp.module.exam.dal.mysql.paper.*; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; @@ -19,6 +22,7 @@ import pc.exam.pp.module.exam.dal.mysql.question.SysFileMapper; import pc.exam.pp.module.exam.utils.date.DateUtils; import pc.exam.pp.module.exam.utils.uuid.IdUtils; +import java.sql.Time; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; @@ -49,6 +53,8 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService @Autowired private EducationPaperTaskMapper educationPaperTaskMapper; + @Autowired + private EducationPaperPersonMapper educationPaperPersonMapper; @Autowired private SysFileMapper sysFileMapper; @@ -126,8 +132,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService educationPaperParam.setIsNumber("1"); educationPaperParam.setIsConnect("0"); educationPaperParam.setIsAnswerId("1"); - - + educationPaperParam.setIsTime("0"); educationPaperParam.setDirectory("KSWJ"); educationPaperParam.setUploadTime("5"); educationPaperParam.setIsDel("0"); @@ -387,12 +392,14 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService @Override public ExamPaperVo selectPaperQuByPaperId(String taskId) { - String paperId= educationPaperTaskMapper.selectPaperQuByPaperId(taskId); + EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); + String paperId= educationPaperTaskMapper.selectPaperQuByPaperId(taskId); List examQuestionList=new ArrayList<>(); List educationPaperSchemeList=new ArrayList<>(); + List quIds=new ArrayList<>(); if (StringUtils.isNotBlank(paperId)){ - List quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId); + quIds =educationPaperQuMapper.selectPaperQuByPaperId(paperId); examQuestionList=examQuestionMapper.selectExamQuestionListByQuIds(quIds); if (examQuestionList!=null&&examQuestionList.size()>0){ for (ExamQuestion examQuestion : examQuestionList) { @@ -404,10 +411,49 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService } educationPaperSchemeList= educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId); } - ExamPaperVo examPaperVo=new ExamPaperVo(); - examPaperVo.setExamQuestionList(examQuestionList); - examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); - examPaperVo.setPaperId(paperId); - return examPaperVo; + + String nickname = SecurityFrameworkUtils.getLoginUserNickname(); + Long userId=SecurityFrameworkUtils.getLoginUserId(); + + EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskId); + EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(paperId); + //设置进入试卷 考生考试信息确认参数 + StuInfoPaper stuInfoPaper=new StuInfoPaper(); + stuInfoPaper.setQueNum(String.valueOf(quIds.size())); + stuInfoPaper.setNickName(nickname); + stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime()); + stuInfoPaper.setPaperScore(educationPaper.getPaperScore()); + stuInfoPaper.setTaskName(educationPaperTask.getTaskName()); + + EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(taskId, String.valueOf(userId)); + if (educationPaperPerson!=null){ + stuInfoPaper.setBatch(educationPaperPerson.getBatch()); + } + + ExamPaperVo examPaperVo=new ExamPaperVo(); + examPaperVo.setExamQuestionList(examQuestionList); + examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); + examPaperVo.setPaperId(paperId); + examPaperVo.setEducationPaperParam(educationPaperParam); + examPaperVo.setStuInfoPaper(stuInfoPaper); + return examPaperVo; + } + + @Override + public PageResult selectEducationPaperTaskListByStu(PaperTaskPageVo educationPaperTask) { + PageResult educationPaperTasks = educationPaperTaskMapper.selectEducationPaperTaskList(educationPaperTask); + Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); + + List list = educationPaperTasks.getList(); + List taskIds= educationPaperPersonMapper.selectTaskIdByStuid(loginUserId); + if (list!=null&&list.size()>0&&taskIds!=null&&taskIds.size()>0){ + list = list.stream() + .filter(task -> taskIds.contains(task.getTaskId())) + .collect(Collectors.toList()); + educationPaperTasks.setList(list); + return educationPaperTasks; + }else { + return null; + } } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperPersonService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperPersonService.java index b3ba1684..a6e1dff2 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperPersonService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperPersonService.java @@ -4,6 +4,7 @@ package pc.exam.pp.module.exam.service.paper; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.module.exam.controller.admin.paper.dto.PersonRepDto; import pc.exam.pp.module.exam.controller.admin.paper.vo.DeleteRequestVo; +import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPersonVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.SessionStuPageReqVO; import pc.exam.pp.module.exam.controller.admin.paper.vo.StudentSessionReqVO; import pc.exam.pp.module.exam.controller.admin.student.vo.StudentPageReqVO; @@ -22,10 +23,9 @@ public interface IEducationPaperPersonService /** * 查询试卷人员分配 * - * @param taskId 试卷人员分配主键 * @return 试卷人员分配 */ - PageResult selectEducationPaperPersonByTaskId(String taskId); + PageResult selectEducationPaperPersonByTaskId(ExamPersonVo examPersonVo); /** * 查询试卷人员分配列表 @@ -67,7 +67,7 @@ public interface IEducationPaperPersonService */ public int deleteEducationPaperPersonByTaskId(String taskId); - PageResult selectEducationPaperPersonBySessionId(String sessionId); + PageResult selectEducationPaperPersonBySessionId(ExamPersonVo examPersonVo); PageResult selectEducationPaperPersonBySearch(SessionStuPageReqVO sessionStuPageReqVO); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperSessionService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperSessionService.java index 2266a8c5..b2ec1352 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperSessionService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperSessionService.java @@ -5,6 +5,7 @@ import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.module.exam.controller.admin.paper.vo.EducationPaperSessionVo; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperSession; +import java.sql.Time; import java.util.List; /** @@ -64,4 +65,6 @@ public interface IEducationPaperSessionService public int deleteEducationPaperSessionBySessionId(String sessionId); int changeStatus(String sessionId, String status); + + Time getAnswerTime(String taskId); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperTaskService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperTaskService.java index e14bc365..b0d65d31 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperTaskService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperTaskService.java @@ -84,5 +84,8 @@ public interface IEducationPaperTaskService boolean changeStatus(String taskId, String status); ExamPaperVo selectPaperQuByPaperId(String taskId); + + PageResult selectEducationPaperTaskListByStu(PaperTaskPageVo educationPaperTask); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java index 1a5a5da6..fce5e0d5 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java @@ -1,18 +1,27 @@ package pc.exam.pp.module.exam.service.question; import com.alibaba.excel.util.StringUtils; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; import pc.exam.pp.module.exam.controller.admin.question.dto.ExamQuestionDto; +import pc.exam.pp.module.exam.controller.admin.question.dto.TenantDto; import pc.exam.pp.module.exam.controller.admin.question.vo.QuestionVo; +import pc.exam.pp.module.exam.controller.admin.question.vo.TenantVo; +import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExaminePageReqVO; import pc.exam.pp.module.exam.controller.admin.rabbitmq.vo.RabbitMQSendInfoVO; import pc.exam.pp.module.exam.dal.dataobject.*; import pc.exam.pp.module.exam.dal.mysql.question.*; +import pc.exam.pp.module.exam.dal.mysql.questionexamine.QuestionExamineMapper; +import pc.exam.pp.module.exam.service.questionexamine.QuestionExamineService; import pc.exam.pp.module.exam.utils.date.DateUtils; import pc.exam.pp.module.exam.utils.rabbitmq.RabbitmqUtils; import pc.exam.pp.module.exam.utils.uuid.IdUtils; +import java.util.ArrayList; import java.util.List; /** @@ -37,6 +46,8 @@ public class ExamQuestionServiceImpl implements IExamQuestionService @Autowired private ExamQuestionKeywordMapper examQuestionKeywordMapper; @Autowired + private QuestionExamineMapper questionExamineMapper; + @Autowired private RabbitmqUtils rabbitMqService; /** * 查询试题(hyc) @@ -130,7 +141,6 @@ public class ExamQuestionServiceImpl implements IExamQuestionService break; default: fileUpload.setFileName(null); - // 可以设置一个默认文件名,或者保持原样(null 或空) break; } } @@ -342,13 +352,21 @@ public class ExamQuestionServiceImpl implements IExamQuestionService public int uploadExamQuestionToRabbitMQ(RabbitMQSendInfoVO rabbitMQSendInfoVO) { // 1、判断上传题目数量 int quCount = rabbitMQSendInfoVO.getQuIds().size(); - for (String quId : rabbitMQSendInfoVO.getQuIds()) { - // 2、根据试题ID查找试题详情 - ExamQuestion examQuestion_obj = selectExamQuestionByQuId(quId); - examQuestion_obj.setType(rabbitMQSendInfoVO.getType()); - // 3、上传至Rabbitmq - rabbitMqService.sendMessage(rabbitMQSendInfoVO.getQueueName(), examQuestion_obj); + List quIds = rabbitMQSendInfoVO.getQuIds(); + if (quIds!=null&&quIds.size()>0){ + examQuestionMapper.setQuestionAuditByids(quIds); + for (String quId : quIds) { + // 2、根据试题ID查找试题详情 + ExamQuestion examQuestion_obj = selectExamQuestionByQuId(quId); + examQuestion_obj.setType(rabbitMQSendInfoVO.getType()); + examQuestion_obj.setSource(SecurityFrameworkUtils.getLoginTenantId()); + examQuestion_obj.setCreateTeacher(SecurityFrameworkUtils.getLoginUserNickname()); + System.out.println(rabbitMQSendInfoVO.getQueueName()); + // 3、上传至Rabbitmq + rabbitMqService.sendMessage(rabbitMQSendInfoVO.getQueueName(), examQuestion_obj); + } } + return quCount; } @@ -358,15 +376,136 @@ public class ExamQuestionServiceImpl implements IExamQuestionService * @return 试题内容 */ @Override - public List getExamQuestionToRabbitMQ(String queueName) { + public boolean getExamQuestionToRabbitMQ(String queueName) { // 最先判断类型 // TODO 1、拉取数据,保存至数据库 2、回调服务器是否拉取成功(中心服务器) // 1、获取上传的rabbit的试题数组 - List examQuestions = rabbitMqService.receiveAllMessages(queueName); - // 2、保存至数据库 - for (ExamQuestion examQuestion : examQuestions) { - insertExamQuestion(examQuestion); + List examQuestions = null; + try { + examQuestions = rabbitMqService.receiveAllMessages(queueName); + } catch (Exception e) { + return false; } - return rabbitMqService.receiveAllMessages(queueName); + if(examQuestions!=null&&examQuestions.size()>0){ + // 2、保存至数据库 + List questionExamineDOS=new ArrayList<>(); + for (ExamQuestion examQuestion : examQuestions) { + QuestionExamineDO questionExamineDO=new QuestionExamineDO(); + questionExamineDO.setQuId(examQuestion.getQuId()); + questionExamineDO.setSource(examQuestion.getSource()); + questionExamineDO.setCreateTeacher(examQuestion.getCreateTeacher()); + questionExamineDO.setType(examQuestion.getType()); + questionExamineDOS.add(questionExamineDO); +// insertExamQuestion(examQuestion); + } + questionExamineMapper.insertOrUpdateList(questionExamineDOS); + } + + + return true; + } + + @Override + public PageResult selectExamQuestionListSend(QuestionVo questionVo) { + return examQuestionMapper.selectExamQuestionListNO(questionVo); + } + + @Override + public PageResult selectExamQuestionListAudit(QuestionExaminePageReqVO questionVo) { + return null; + } + +// @Override +// public PageResult selectExamQuestionListAudit(QuestionVo questionVo) { +// questionExamineMapper.selectPage() +// +// return null; +// } + + @Override + public PageResult selectExamQuestionListNoAudit(QuestionExaminePageReqVO questionVo) { + PageResult questionExamineDOPageResult = questionExamineMapper.selectPage(questionVo); + List list = questionExamineDOPageResult.getList(); + List examQuestionList=new ArrayList<>(); + if (list!=null&&list.size()>0){ + for (QuestionExamineDO questionExamineDO : list) { + String schoolName =questionExamineMapper.selectSchoolName(questionExamineDO.getSource()); + ExamQuestion examQuestion = examQuestionMapper.selectExamQuestionByQuIdAndTenantId(questionExamineDO.getQuId(),questionExamineDO.getSource()); + examQuestion.setCreateTeacher(questionExamineDO.getCreateTeacher()); + examQuestion.setSchoolName(schoolName); + examQuestion.setSource(questionExamineDO.getSource()); + examQuestion.setType(questionExamineDO.getType()); + examQuestion.setCreateTime(questionExamineDO.getCreateTime()); + examQuestionList.add(examQuestion); + } + } + PageResult examQuestionPageResult=new PageResult<>(); + examQuestionPageResult.setList(examQuestionList); + examQuestionPageResult.setTotal((long) examQuestionList.size()); + + + return examQuestionPageResult; + } + + @Override + public PageResult getSchoolName(TenantDto tenantDto) { + List schoolName = examQuestionMapper.getSchoolName(tenantDto); + long total = examQuestionMapper.getSchoolNameTotal(tenantDto); + PageResult pageResult=new PageResult<>(); + pageResult.setList(schoolName); + pageResult.setTotal(total); + return pageResult; + } + + @Override + public int auditQueByIds(List quIds) { + + + return examQuestionMapper.auditQueByIds(quIds); + } + + @Override + public int noAuditQue(List quIds) { + return examQuestionMapper.noAuditQue(quIds); + } + + public boolean getExamQuestionToRabbitMQInsertData(String queueName) { + // 最先判断类型 + // TODO 1、拉取数据,保存至数据库 2、回调服务器是否拉取成功(中心服务器) + // 1、获取上传的rabbit的试题数组 + List examQuestions = null; + try { + examQuestions = rabbitMqService.receiveAllMessages(queueName); + } catch (Exception e) { + return false; + } + if(examQuestions!=null&&examQuestions.size()>0){ + examQuestionMapper.insertOrUpdate(examQuestions); + } + + return true; + + } + + + public int uploadExamQuestionToRabbitMQBySource(RabbitMQSendInfoVO rabbitMQSendInfoVO) { + // 1、判断上传题目数量 + int quCount = rabbitMQSendInfoVO.getQuIds().size(); + List quIds = rabbitMQSendInfoVO.getQuIds(); + if (quIds!=null&&quIds.size()>0){ + for (String quId : quIds) { + QuestionExamineDO questionExamineDO = questionExamineMapper.selectById(quId); + + // 2、根据试题ID和租户查找试题详情 + ExamQuestion examQuestion_obj = examQuestionMapper.selectExamQuestionByQuIdAndTenantId(quId,questionExamineDO.getSource()); +// examQuestion_obj.setType(rabbitMQSendInfoVO.getType()); +// examQuestion_obj.setSource(SecurityFrameworkUtils.getLoginTenantId()); +// examQuestion_obj.setCreateTeacher(SecurityFrameworkUtils.getLoginUserNickname()); + // 3、上传至Rabbitmq + rabbitMqService.sendMessage(rabbitMQSendInfoVO.getQueueName(), examQuestion_obj); + } + } + + return quCount; } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java index a5166254..c93e141c 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java @@ -2,7 +2,10 @@ package pc.exam.pp.module.exam.service.question; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.module.exam.controller.admin.question.dto.ExamQuestionDto; +import pc.exam.pp.module.exam.controller.admin.question.dto.TenantDto; import pc.exam.pp.module.exam.controller.admin.question.vo.QuestionVo; +import pc.exam.pp.module.exam.controller.admin.question.vo.TenantVo; +import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExaminePageReqVO; import pc.exam.pp.module.exam.controller.admin.rabbitmq.vo.RabbitMQSendInfoVO; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; @@ -78,5 +81,21 @@ public interface IExamQuestionService * @param queueName 客户端ID * @return 结果 */ - public List getExamQuestionToRabbitMQ(String queueName); + public boolean getExamQuestionToRabbitMQ(String queueName); + + PageResult selectExamQuestionListSend(QuestionVo questionVo); + + PageResult selectExamQuestionListAudit(QuestionExaminePageReqVO questionVo); + + PageResult selectExamQuestionListNoAudit(QuestionExaminePageReqVO questionVo); + + + PageResult getSchoolName(TenantDto tenantDto); + + int auditQueByIds(List quIds); + + int noAuditQue(List quIds); + + + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/questionexamine/QuestionExamineService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/questionexamine/QuestionExamineService.java new file mode 100644 index 00000000..7594d0b8 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/questionexamine/QuestionExamineService.java @@ -0,0 +1,56 @@ +package pc.exam.pp.module.exam.service.questionexamine; + +import java.util.*; +import jakarta.validation.*; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.common.pojo.PageParam; +import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExaminePageReqVO; +import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExamineSaveReqVO; +import pc.exam.pp.module.exam.dal.dataobject.QuestionExamineDO; + +/** + * 试题交互中间 Service 接口 + * + * @author 管理员 + */ +public interface QuestionExamineService { + + /** + * 创建试题交互中间 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + String createQuestionExamine(@Valid QuestionExamineSaveReqVO createReqVO); + + /** + * 更新试题交互中间 + * + * @param updateReqVO 更新信息 + */ + void updateQuestionExamine(@Valid QuestionExamineSaveReqVO updateReqVO); + + /** + * 删除试题交互中间 + * + * @param id 编号 + */ + void deleteQuestionExamine(String id); + + /** + * 获得试题交互中间 + * + * @param id 编号 + * @return 试题交互中间 + */ + QuestionExamineDO getQuestionExamine(String id); + + /** + * 获得试题交互中间分页 + * + * @param pageReqVO 分页查询 + * @return 试题交互中间分页 + */ + PageResult getQuestionExaminePage(QuestionExaminePageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/questionexamine/QuestionExamineServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/questionexamine/QuestionExamineServiceImpl.java new file mode 100644 index 00000000..f27561d6 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/questionexamine/QuestionExamineServiceImpl.java @@ -0,0 +1,74 @@ +package pc.exam.pp.module.exam.service.questionexamine; + + +import org.springframework.stereotype.Service; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import pc.exam.pp.framework.common.exception.ErrorCode; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.common.util.object.BeanUtils; + +import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExaminePageReqVO; +import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExamineSaveReqVO; +import pc.exam.pp.module.exam.dal.dataobject.QuestionExamineDO; +import pc.exam.pp.module.exam.dal.mysql.questionexamine.QuestionExamineMapper; + +import static pc.exam.pp.framework.common.exception.util.ServiceExceptionUtil.exception; +import static pc.exam.pp.module.system.enums.ErrorCodeConstants.QUESTION_EXAMINE_NOT_EXISTS; +/** +* 试题交互中间 Service 实现类 +* +* @author 管理员 +*/ +@Service +@Validated +public class QuestionExamineServiceImpl implements QuestionExamineService { + + @Resource + private QuestionExamineMapper questionExamineMapper; + + @Override + public String createQuestionExamine(QuestionExamineSaveReqVO createReqVO) { + // 插入 + QuestionExamineDO questionExamine = BeanUtils.toBean(createReqVO, QuestionExamineDO.class); + questionExamineMapper.insert(questionExamine); + // 返回 + return questionExamine.getQuId(); + } + + @Override + public void updateQuestionExamine(QuestionExamineSaveReqVO updateReqVO) { + // 校验存在 + validateQuestionExamineExists(updateReqVO.getExamineId()); + // 更新 + QuestionExamineDO updateObj = BeanUtils.toBean(updateReqVO, QuestionExamineDO.class); + questionExamineMapper.updateById(updateObj); + } + + @Override + public void deleteQuestionExamine(String id) { + // 校验存在 + validateQuestionExamineExists(id); + // 删除 + questionExamineMapper.deleteById(id); + } + + private void validateQuestionExamineExists(String id) { + if (questionExamineMapper.selectById(id) == null) { + throw exception(QUESTION_EXAMINE_NOT_EXISTS); + } + } + + @Override + public QuestionExamineDO getQuestionExamine(String id) { + return questionExamineMapper.selectById(id); + } + + @Override + public PageResult getQuestionExaminePage(QuestionExaminePageReqVO pageReqVO) { + return questionExamineMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/utils/rabbitmq/RabbitmqUtils.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/utils/rabbitmq/RabbitmqUtils.java index 897166fe..1b117436 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/utils/rabbitmq/RabbitmqUtils.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/utils/rabbitmq/RabbitmqUtils.java @@ -19,7 +19,7 @@ import java.util.List; /** * rabbitmq 工具 - * QUEUE_NAME dept_id + "_Queue" + * QUEUE_NAME tenant_id + "_Queue" */ @Service public class RabbitmqUtils { @@ -45,12 +45,11 @@ public class RabbitmqUtils { /** * * @param queueName 客户端对应队列 - * @param deptName 客户端名称 * @return 客户端连接状态 */ - public String connect(String queueName, String deptName) { + public int connect(String queueName) { if (isConnected()) { - return "已经连接"; + return 0; } ConnectionFactory factory = new ConnectionFactory(); @@ -66,13 +65,36 @@ public class RabbitmqUtils { channel = connection.createChannel(); // 声明一个队列,如果已经存在就不会重复创建 channel.queueDeclare(queueName, true, false, false, null); - return deptName + "_连接成功"; + return 1; } catch (Exception e) { e.printStackTrace(); - return deptName + "_连接失败: " + e.getMessage(); + return 2; } } + public boolean connectSchool(String queueName) { + if (isConnected()) { + return true; + } + ConnectionFactory factory = new ConnectionFactory(); + factory.setHost(rabbitProps.getHost()); + factory.setPort(rabbitProps.getPort()); + factory.setUsername(rabbitProps.getUsername()); + factory.setPassword(rabbitProps.getPassword()); + factory.setVirtualHost(rabbitProps.getVirtualHost()); + + try { + // 创建连接和通道 + connection = factory.newConnection(); + channel = connection.createChannel(); + // 声明一个队列,如果已经存在就不会重复创建 + channel.queueDeclare(queueName, true, false, false, null); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } /** * 向队列中发送一条消息 */ diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperParamMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperParamMapper.xml index dba90b11..548212df 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperParamMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperParamMapper.xml @@ -15,6 +15,11 @@ + + + + + @@ -26,7 +31,7 @@ - select param_id, task_id, is_number,is_content,is_answer_id,is_exam_password, exam_password, usb, save_grades, driver, directory, upload_time, is_del,is_repeat ,is_answer,is_look,is_connect,is_session from education_paper_param + select param_id, task_id, is_number,is_content,is_answer_id,is_exam_password, exam_password, usb, save_grades, driver, directory, upload_time, is_time,exam_time,is_del,is_repeat ,is_answer,is_look,is_connect,is_session from education_paper_param - + + + + - @@ -111,6 +107,81 @@ select person_id from education_paper_person where task_id=#{taskId} + + + + + + + + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperSessionMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperSessionMapper.xml index 5951dc28..bf1cfd76 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperSessionMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperSessionMapper.xml @@ -32,6 +32,10 @@ where task_id =#{taskId} + + insert into education_paper_session diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml index 749b91e7..a786f9e0 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml @@ -41,7 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + + + + select qu_id, qu_bank_id, qu_bank_name, chapterId_dict_text,subject_name, qu_level, content, content_text, analysis, point_names, keywords, manual, create_time, creator, update_time, updater, deleted ,status,audit ,course_name, specialty_name from exam_question @@ -75,6 +79,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" CASE WHEN a.sort IS NOT NULL THEN 0 ELSE 1 END, a.sort ASC + + + + @@ -170,6 +202,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + UPDATE exam_question + SET audit = '2' + WHERE qu_id IN + + #{id} + + + + UPDATE exam_question + SET audit = '0' + WHERE qu_id IN + + #{id} + + + + + UPDATE exam_question + SET audit = '3' + WHERE qu_id IN + + #{id} + + \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/QuestionExamineMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/QuestionExamineMapper.xml new file mode 100644 index 00000000..5165aebf --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/QuestionExamineMapper.xml @@ -0,0 +1,27 @@ + + + + + + + INSERT INTO education_question_examine (qu_id,source, create_teacher,type,create_time) + VALUES + + ( #{item.quId}, #{item.source}, #{item.createTeacher}, #{item.type},now()) + + ON DUPLICATE KEY UPDATE + source = VALUES(source), + create_teacher = VALUES(create_teacher), + type = VALUES(type), + create_time=now() + + + + + + + \ No newline at end of file diff --git a/exam-module-infra/exam-module-infra-api/src/main/java/pc/exam/pp/module/infra/enums/ErrorCodeConstants.java b/exam-module-infra/exam-module-infra-api/src/main/java/pc/exam/pp/module/infra/enums/ErrorCodeConstants.java index 7befb3f3..0da6c87f 100644 --- a/exam-module-infra/exam-module-infra-api/src/main/java/pc/exam/pp/module/infra/enums/ErrorCodeConstants.java +++ b/exam-module-infra/exam-module-infra-api/src/main/java/pc/exam/pp/module/infra/enums/ErrorCodeConstants.java @@ -72,9 +72,11 @@ public interface ErrorCodeConstants { ErrorCode DEMO03_PAPER_STUDENT_EXISTS = new ErrorCode(1_001_301_001, "请选择学生"); // ========== 试卷参数 1-001-401-000 ========== - ErrorCode DEMO03_PAPER_SESSION_EXISTS = new ErrorCode(1_001_401_001, "请开启考场设置"); - + ErrorCode DEMO03_PAPER_SESSION_EXISTS = new ErrorCode(1_001_401_001, "请开启考场设置!"); + // ========== 试卷方案 1-001-901-900 ========== + ErrorCode DEMO03_PAPER_TASK_DEL_EXISTS = new ErrorCode(1-001-901-901, "该方案下已有试卷不能删除!"); + ErrorCode DEMO03_PAPER_TASK_ADD_EXISTS = new ErrorCode(1-001-901-901, "该方案下已有试卷不能新增!"); // ========== 监控管理 1-001-606-000 ========== ErrorCode DEMO03_MONITOR_TIME_EXISTS = new ErrorCode(1-001-606-001, "该考试不在考场时间范围内!"); ErrorCode DEMO03_MONITOR_SESSION_EXISTS = new ErrorCode(1-001-606-002, "考生状态未在考试中!请联系管理员"); diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/auto_tools/AutoToolsServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/auto_tools/AutoToolsServiceImpl.java index 36b0f88e..39954e21 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/auto_tools/AutoToolsServiceImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/auto_tools/AutoToolsServiceImpl.java @@ -7,6 +7,7 @@ import jakarta.annotation.Resource; import lombok.Data; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipFile; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import pc.exam.pp.framework.common.pojo.CommonResult; @@ -26,6 +27,7 @@ import pc.exam.pp.module.judgement.controller.service.mysql.IMysqlServerice; import pc.exam.pp.module.judgement.service.c_programming.JudgementService; import pc.exam.pp.module.judgement.service.choice.JudgementChoiceService; import pc.exam.pp.module.judgement.service.wps_word.JudgementWpsWordService; +import pc.exam.pp.module.judgement.utils.EndStuMonitorUtils; import pc.exam.pp.module.judgement.utils.JudgementCUtils; import pc.exam.pp.module.judgement.utils.multipartFile.CustomMultipartFile; import pc.exam.pp.module.judgement.utils.zipfile.FolderZipper; @@ -66,7 +68,8 @@ public class AutoToolsServiceImpl implements AutoToolsService{ StuPaperScoreMapper stuPaperScoreMapper; @Resource JudgementChoiceService judgementChoiceService; - + @Autowired + private EndStuMonitorUtils endStuMonitorUtils; @Override public String downloadStudentFile(String fileUrl, String filePath) { try { @@ -157,6 +160,8 @@ public class AutoToolsServiceImpl implements AutoToolsService{ */ @Override public CommonResult judgementScore(Long stuId, String paperId) throws Exception { + //监控管理 生成选择题文件路径 + endStuMonitorUtils.endStuMonitor(String.valueOf(stuId), paperId); // 获取平台文件参数 ConfigDO config = configService.getConfigByKey("file_down_path"); double score = 0; @@ -281,8 +286,6 @@ public class AutoToolsServiceImpl implements AutoToolsService{ System.out.println(judgement+"mysql得分"); break; } - - } } @@ -304,6 +307,9 @@ public class AutoToolsServiceImpl implements AutoToolsService{ stuPaperScoreDO.setPaperId(paperId); stuPaperScoreDO.setAllScore(new BigDecimal(score)); stuPaperScoreService.insertStuPaperScore(stuPaperScoreDO); + + //更新学生分数 + endStuMonitorUtils.endStuMonitor(String.valueOf(stuId),paperId,score); // end、删除文件 zip_file.delete(); folder.delete(); diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/EndStuMonitorUtils.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/EndStuMonitorUtils.java index 2dc64423..c9557876 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/EndStuMonitorUtils.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/EndStuMonitorUtils.java @@ -17,8 +17,10 @@ import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperParamMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperTaskMapper; import pc.exam.pp.module.exam.dal.mysql.student.StuPaperFileMapper; +import pc.exam.pp.module.exam.utils.uuid.IdUtils; import pc.exam.pp.module.infra.service.file.FileService; +import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -49,12 +51,12 @@ public class EndStuMonitorUtils { String taskId = educationPaper.getTaskId(); - String key = "userCache:" + taskId + ":" + stuId; String keychoice = "keychoice:" + taskId + ":" + stuId; StuMonitorQuVo stuMonitorQuVo = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(keychoice), StuMonitorQuVo.class); String fileurl = null; + String fileName = IdUtils.simpleUUID()+".txt"; try { - String fileName = "StuMonitorQu.txt"; + FileWriter writer = new FileWriter(fileName); writer.write(JsonUtils.toJsonString(stuMonitorQuVo)); writer.close(); @@ -65,7 +67,7 @@ public class EndStuMonitorUtils { // 1. 生成 JSON 内容 String content = JsonUtils.toJsonString(stuMonitorQuVo); - // 2. 转换为 UTF-8 字节数组(关键修复!) + // 2. 转换为 UTF-8 字节数组 byte[] bytes = content.getBytes(StandardCharsets.UTF_8); fileurl = fileService.createFile(fileName, path, bytes); System.out.println(fileurl); @@ -94,6 +96,15 @@ public class EndStuMonitorUtils { } catch (IOException e) { System.out.println(e); + } finally { + // 删除临时文件 + File file = new File(fileName); + if (file.exists()) { + boolean deleted = file.delete(); + if (!deleted) { + System.out.println("临时文件删除失败: " + fileName); + } + } } return fileurl; diff --git a/exam-module-system/exam-module-system-api/src/main/java/pc/exam/pp/module/system/enums/ErrorCodeConstants.java b/exam-module-system/exam-module-system-api/src/main/java/pc/exam/pp/module/system/enums/ErrorCodeConstants.java index fe3dfa43..8b9b8f2d 100644 --- a/exam-module-system/exam-module-system-api/src/main/java/pc/exam/pp/module/system/enums/ErrorCodeConstants.java +++ b/exam-module-system/exam-module-system-api/src/main/java/pc/exam/pp/module/system/enums/ErrorCodeConstants.java @@ -203,5 +203,15 @@ public interface ErrorCodeConstants { ErrorCode XLSX_PARENT_IS_CHILD = new ErrorCode(1_002_032_007, "不能设置自己的子XLSX节点为父XLSX节点"); + // ========== 试题交互中间 ========== + ErrorCode QUESTION_EXAMINE_NOT_EXISTS = new ErrorCode(1_004_004_010, "试题交互中间不存在"); + + // ========== 试题中间 ========== + ErrorCode QESESTION_NOT_NULL = new ErrorCode(1_008_008_012, "审核试题不能为空"); + ErrorCode QESESTION_AUDIT_ERROR = new ErrorCode(1_008_008_022, "操作试题失败"); + // ========== rabbit ========== + ErrorCode RABBITMQ_CONNECT_EXISTS = new ErrorCode(1_005_005_111, "连接失败"); + ErrorCode RABBITMQ_NOT_EXISTS = new ErrorCode(1_005_005_011, "接收试题出错"); + ErrorCode RABBITMQ_NAME_NOT_NULL = new ErrorCode(1_005_005_012, "队列名不能为空"); ErrorCode MONITOR_NOT_EXISTS = new ErrorCode(1_003_301_001, "找不到值!"); } diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java index 676cde1e..e0f997c7 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java @@ -70,4 +70,5 @@ public class TenantSaveReqVO { @Schema(description = "授权专业数量") private List tenantSpecialtyPointsVOList; + private String queueName; } diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/UserController.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/UserController.java index 2f780d8a..364b7811 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/UserController.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/UserController.java @@ -8,6 +8,7 @@ import pc.exam.pp.framework.common.pojo.PageParam; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.common.util.object.BeanUtils; import pc.exam.pp.framework.excel.core.util.ExcelUtils; +import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListByUserReqVo; import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo; import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO; @@ -15,9 +16,11 @@ import pc.exam.pp.module.exam.service.classs.ClassService; import pc.exam.pp.module.system.controller.admin.user.vo.user.*; import pc.exam.pp.module.system.convert.user.UserConvert; import pc.exam.pp.module.system.dal.dataobject.dept.DeptDO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantDO; import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO; import pc.exam.pp.module.system.enums.common.SexEnum; import pc.exam.pp.module.system.service.dept.DeptService; +import pc.exam.pp.module.system.service.tenant.TenantService; import pc.exam.pp.module.system.service.user.AdminUserService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -52,6 +55,8 @@ public class UserController { private ClassService classService; @Resource private DeptService deptService; + @Resource + private TenantService tenantService; @PostMapping("/create") @Operation(summary = "新增用户") diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserSaveReqVO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserSaveReqVO.java index 17968f93..7ab33c53 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserSaveReqVO.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserSaveReqVO.java @@ -92,4 +92,6 @@ public class UserSaveReqVO { || (ObjectUtil.isAllNotEmpty(password)); // 新增时,必须都传递 password } + + private String queueName; } diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/convert/tenant/TenantConvert.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/convert/tenant/TenantConvert.java index 84b7da6d..cd58b8b6 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/convert/tenant/TenantConvert.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/convert/tenant/TenantConvert.java @@ -20,6 +20,7 @@ public interface TenantConvert { reqVO.setUsername(bean.getUsername()); reqVO.setPassword(bean.getPassword()); reqVO.setNickname(bean.getContactName()).setMobile(bean.getContactMobile()); + reqVO.setQueueName(bean.getQueueName()); // 租户创建的用户,默认是管理员用户 reqVO.setUserType("0"); return reqVO; diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/tenant/TenantDO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/tenant/TenantDO.java index 02d20ea4..ba5007b8 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/tenant/TenantDO.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/tenant/TenantDO.java @@ -77,4 +77,7 @@ public class TenantDO extends BaseDO { */ private Integer accountCount; + + private String queueName; + } diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/AdminUserDO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/AdminUserDO.java index 4167ee50..31b233a8 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/AdminUserDO.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/AdminUserDO.java @@ -116,5 +116,6 @@ public class AdminUserDO extends TenantBaseDO { private LocalDateTime loginDate; + private String queueName; } diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/oauth2/OAuth2TokenServiceImpl.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/oauth2/OAuth2TokenServiceImpl.java index b0ffca87..8456a5ac 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/oauth2/OAuth2TokenServiceImpl.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/oauth2/OAuth2TokenServiceImpl.java @@ -200,7 +200,9 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService { if (userType.equals(UserTypeEnum.ADMIN.getValue())) { AdminUserDO user = adminUserService.getUser(userId); return MapUtil.builder(LoginUser.INFO_KEY_NICKNAME, user.getNickname()) - .put(LoginUser.INFO_KEY_DEPT_ID, StrUtil.toStringOrNull(user.getDeptId())).build(); + .put(LoginUser.INFO_KEY_DEPT_ID, StrUtil.toStringOrNull(user.getDeptId())) + .put(LoginUser.INFO_KEY_QUEUE, StrUtil.toStringOrNull(user.getQueueName())) + .build(); } else if (userType.equals(UserTypeEnum.MEMBER.getValue())) { // 注意:目前 Member 暂时不读取,可以按需实现 return Collections.emptyMap(); diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.java index c7a0c899..83ae7619 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.java @@ -12,6 +12,7 @@ import pc.exam.pp.framework.common.util.object.BeanUtils; import pc.exam.pp.framework.tenant.config.TenantProperties; import pc.exam.pp.framework.tenant.core.context.TenantContextHolder; import pc.exam.pp.framework.tenant.core.util.TenantUtils; +import pc.exam.pp.module.exam.utils.rabbitmq.RabbitmqUtils; import pc.exam.pp.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO; @@ -63,7 +64,8 @@ public class TenantServiceImpl implements TenantService { @SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection") @Autowired(required = false) // 由于 exam.tenant.enable 配置项,可以关闭多租户的功能,所以这里只能不强制注入 private TenantProperties tenantProperties; - + @Resource + private RabbitmqUtils rabbitMqService; @Resource private TenantMapper tenantMapper; @@ -117,6 +119,12 @@ public class TenantServiceImpl implements TenantService { tenantMapper.insert(tenant); // 创建租户对应的专业的授权点数 Long tenantId = tenant.getId(); + + String queueName=tenantId.toString()+"_Queue"; + tenant.setQueueName(queueName); + + tenantMapper.updateById(tenant); + for (TenantSpecialtyPointsVO specialtyPointsVO : createReqVO.getTenantSpecialtyPointsVOList()) { // 新增数据 specialtyPointsVO.setTenantId(tenantId); @@ -124,6 +132,9 @@ public class TenantServiceImpl implements TenantService { BeanUtils.copyProperties(specialtyPointsVO, tenantSpcialtyDO); tenantSpecialtyMapper.insert(tenantSpcialtyDO); } + createReqVO.setQueueName(queueName); + //创建rabbitmq通道 + rabbitMqService.connect(queueName); // 创建租户的管理员 TenantUtils.execute(tenant.getId(), () -> { // 创建角色 diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/user/AdminUserServiceImpl.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/user/AdminUserServiceImpl.java index 80882a8d..79921625 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/user/AdminUserServiceImpl.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/user/AdminUserServiceImpl.java @@ -11,6 +11,7 @@ import pc.exam.pp.framework.common.util.collection.CollectionUtils; import pc.exam.pp.framework.common.util.object.BeanUtils; import pc.exam.pp.framework.common.util.validation.ValidationUtils; import pc.exam.pp.framework.datapermission.core.util.DataPermissionUtils; +import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; import pc.exam.pp.framework.web.core.util.WebFrameworkUtils; import pc.exam.pp.module.exam.controller.admin.classs.vo.ClassSaveReqVO; import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListByUserReqVo; @@ -27,6 +28,7 @@ import pc.exam.pp.module.system.controller.admin.user.vo.profile.UserProfileUpda import pc.exam.pp.module.system.controller.admin.user.vo.user.*; import pc.exam.pp.module.system.dal.dataobject.dept.DeptDO; import pc.exam.pp.module.system.dal.dataobject.dept.UserPostDO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantDO; import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO; import pc.exam.pp.module.system.dal.dataobject.user.TeacherClassDO; import pc.exam.pp.module.system.dal.dataobject.user.TeacherSpecialtyDO; @@ -110,6 +112,7 @@ public class AdminUserServiceImpl implements AdminUserService { @LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_CREATE_SUB_TYPE, bizNo = "{{#user.id}}", success = SYSTEM_USER_CREATE_SUCCESS) public Long createUser(UserSaveReqVO createReqVO) { + // 1.1 校验账户配合 tenantService.handleTenantInfo(tenant -> { long count = userMapper.selectCount(); @@ -123,7 +126,9 @@ public class AdminUserServiceImpl implements AdminUserService { // 2.1 插入用户 AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class); user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 - user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码 + user.setPassword(encodePassword(createReqVO.getPassword())); // + user.setQueueName(createReqVO.getQueueName()); + userMapper.insert(user); // 2.2 插入关联岗位 if (CollectionUtil.isNotEmpty(user.getPostIds())) { @@ -197,7 +202,10 @@ public class AdminUserServiceImpl implements AdminUserService { AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class); user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码s + + user.setQueueName(SecurityFrameworkUtils.getLoginQueueName()); userMapper.insert(user); + // 2.2 插入关联岗位 if (CollectionUtil.isNotEmpty(user.getPostIds())) { userPostMapper.insertBatch(convertList(user.getPostIds(), @@ -218,6 +226,7 @@ public class AdminUserServiceImpl implements AdminUserService { // 3. 记录操作日志上下文 LogRecordContext.putVariable("user", user); + return user.getId(); } diff --git a/exam-server/src/main/resources/application.yaml b/exam-server/src/main/resources/application.yaml index a8b7efd5..e0a97337 100644 --- a/exam-server/src/main/resources/application.yaml +++ b/exam-server/src/main/resources/application.yaml @@ -346,6 +346,7 @@ exam: - education_paper_scheme - education_paper_session - exam_mysql_keyword + - education_question_examine ignore-caches: - user_role_ids - permission_menu_ids