From 594056f6cc9b4411f7db8fe71967b6fc9394f556 Mon Sep 17 00:00:00 2001 From: huababa1 <2037205722@qq.com> Date: Mon, 7 Jul 2025 19:47:11 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E8=AF=95?= =?UTF-8?q?=E5=8D=B7=E3=80=81=E8=AF=95=E5=8D=B7=E4=BB=BB=E5=8A=A1=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8Cps=E5=A2=9E=E5=8A=A0=E6=B3=A8=E5=86=8C=E8=A1=A8?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/paper/EducationPaperController.java | 9 ++- .../paper/EducationPaperServiceImpl.java | 17 ++++-- .../paper/EducationPaperTaskServiceImpl.java | 55 ++++++++++++++++--- .../service/paper/IEducationPaperService.java | 2 +- .../paper/IEducationPaperTaskService.java | 2 +- .../mapper/exam/EducationPaperMapper.xml | 2 +- .../judgement/controller/utils/ps/PsUtil.java | 8 ++- 7 files changed, 75 insertions(+), 20 deletions(-) diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperController.java index 75eff1f0..34092fd6 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperController.java @@ -127,9 +127,14 @@ public class EducationPaperController */ @Operation(summary = "删除试卷") @DeleteMapping("/{paperIds}") - public CommonResult remove(@PathVariable String[] paperIds) + public CommonResult remove(@PathVariable String paperIds) { - return CommonResult.success(educationPaperService.deleteEducationPaperByPaperIds(paperIds)); + try { + return CommonResult.success(educationPaperService.deleteEducationPaperByPaperIds(paperIds)); + + } catch (RuntimeException e) { + return CommonResult.error(981,e.getMessage()); + } } /** 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 281e1000..91307aa1 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 @@ -23,6 +23,7 @@ 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.exception.QueTypeException; import pc.exam.pp.module.exam.controller.admin.paper.dto.*; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo; @@ -128,16 +129,22 @@ public class EducationPaperServiceImpl implements IEducationPaperService /** * 批量删除试卷 * - * @param paperIds 需要删除的试卷主键 + * @param paperId 需要删除的试卷主键 * @return 结果 */ @Override - @Transactional(rollbackFor = Exception.class) // 所有异常都回滚 - public int deleteEducationPaperByPaperIds(String[] paperIds) + public int deleteEducationPaperByPaperIds(String paperId) throws RuntimeException { + EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(paperId); + String taskId = educationPaper.getTaskId(); + long total = educationPaperPersonMapper.selectEducationPaperPersonByTaskIdTotal(taskId); - educationPaperQuMapper.deleteEducationPaperQuByPaperIds(paperIds); - return educationPaperMapper.deleteEducationPaperByPaperIds(paperIds); + if (total > 0) { + throw new QueTypeException("此任务已分配人员,无法删除!"); + } + + educationPaperQuMapper.deleteEducationPaperQuByPaperId(paperId); + return educationPaperMapper.deleteEducationPaperByPaperId(paperId); } /** 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 6697984a..a2389e93 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 @@ -132,7 +132,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService educationPaperParam.setIsExamPassword("1"); educationPaperParam.setUsb("1"); educationPaperParam.setSaveGrades("0"); - educationPaperParam.setDriver("C"); + educationPaperParam.setDriver("D"); educationPaperParam.setIsNumber("1"); educationPaperParam.setIsConnect("0"); educationPaperParam.setIsAnswerId("1"); @@ -199,13 +199,20 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService List canDeleteTaskIds = new ArrayList<>(); List cannotDeleteTaskIds = new ArrayList<>(); for (String taskId : taskIds) { - // 查询该任务下是否有试卷 - int paperCount = educationPaperMapper.countPapersByTaskId(taskId); - if (paperCount == 0) { - canDeleteTaskIds.add(taskId); + EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectById(taskId); + + if (educationPaperTask.getTaskType().equals("0")||educationPaperTask.getTaskType().equals("1")||educationPaperTask.getTaskType().equals("3")){ + // 查询该任务下是否有试卷 + int paperCount = educationPaperMapper.countPapersByTaskId(taskId); + if (paperCount == 0) { + canDeleteTaskIds.add(taskId); + }else { + cannotDeleteTaskIds.add(taskId); + } }else { - cannotDeleteTaskIds.add(taskId); + canDeleteTaskIds.add(taskId); } + } // 2. 如果没有可删除的任务,直接返回 @@ -233,9 +240,39 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService * @return 结果 */ @Override - public int deleteEducationPaperTaskByTaskId(String taskId) { - monitorMapper.deleteByTaskId(taskId); - return educationPaperTaskMapper.deleteEducationPaperTaskByTaskId(taskId); + public String deleteEducationPaperTaskByTaskId(String taskId) { + EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectById(taskId); + if (educationPaperTask.getTaskType().equals("0")||educationPaperTask.getTaskType().equals("1")||educationPaperTask.getTaskType().equals("3")){ + // 1. 找出没有关联试卷的任务ID + List canDeleteTaskIds = new ArrayList<>(); + List cannotDeleteTaskIds = new ArrayList<>(); + // 查询该任务下是否有试卷 + int paperCount = educationPaperMapper.countPapersByTaskId(taskId); + if (paperCount == 0) { + canDeleteTaskIds.add(taskId); + }else { + cannotDeleteTaskIds.add(taskId); + } + + // 2. 如果没有可删除的任务,直接返回 + if (canDeleteTaskIds.isEmpty()) { + return ("所选的任务下有试卷,不能删除!"); + } + // 3. 执行删除操作 + educationPaperTaskMapper.deleteEducationPaperTaskByTaskIds( + canDeleteTaskIds.toArray(new String[0])); + monitorMapper.deleteByTaskIds(canDeleteTaskIds.toArray(new String[0])); + if (!cannotDeleteTaskIds.isEmpty()){ + List taskNum= educationPaperMapper.selectTaskNumByids(cannotDeleteTaskIds); + return ("以下任务下有试卷:"+taskNum+",不能删除!"); + } + } + + + +// monitorMapper.deleteByTaskId(taskId); +// educationPaperTaskMapper.deleteEducationPaperTaskByTaskId(taskId); + return "删除成功"; } @Override diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java index 16868ba3..4848233a 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java @@ -61,7 +61,7 @@ public interface IEducationPaperService * @param paperIds 需要删除的试卷主键集合 * @return 结果 */ - public int deleteEducationPaperByPaperIds(String[] paperIds); + public int deleteEducationPaperByPaperIds(String paperIds) throws RuntimeException; /** * 删除试卷信息 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 e215695a..ce2b89f8 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 @@ -67,7 +67,7 @@ public interface IEducationPaperTaskService * @param taskId 试卷任务主键 * @return 结果 */ - public int deleteEducationPaperTaskByTaskId(String taskId); + public String deleteEducationPaperTaskByTaskId(String taskId); /** * 获取专业列表 */ diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml index 79000ae5..085dd733 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml @@ -128,7 +128,7 @@ select task_id from education_paper where paper_id=#{paperId} select paper_id ,num from education_paper where task_id=#{taskId} and deleted ='0'