Accept Merge Request #141: (hyc -> master)
Merge Request: 【修改】试卷、试卷任务删除增加判断逻辑,ps增加注册表版本 Created By: @华允传 Accepted By: @华允传 URL: https://g-iswv8783.coding.net/p/education/d/pengchen-exam-java/git/merge/141
This commit is contained in:
@@ -127,9 +127,14 @@ public class EducationPaperController
|
|||||||
*/
|
*/
|
||||||
@Operation(summary = "删除试卷")
|
@Operation(summary = "删除试卷")
|
||||||
@DeleteMapping("/{paperIds}")
|
@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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -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.security.core.util.SecurityFrameworkUtils;
|
||||||
import pc.exam.pp.framework.tenant.core.aop.TenantIgnore;
|
import pc.exam.pp.framework.tenant.core.aop.TenantIgnore;
|
||||||
import pc.exam.pp.framework.tenant.core.context.TenantContextHolder;
|
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.dto.*;
|
||||||
import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo;
|
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.PaperPageVo;
|
||||||
@@ -128,16 +129,22 @@ public class EducationPaperServiceImpl implements IEducationPaperService
|
|||||||
/**
|
/**
|
||||||
* 批量删除试卷
|
* 批量删除试卷
|
||||||
*
|
*
|
||||||
* @param paperIds 需要删除的试卷主键
|
* @param paperId 需要删除的试卷主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class) // 所有异常都回滚
|
public int deleteEducationPaperByPaperIds(String paperId) throws RuntimeException
|
||||||
public int deleteEducationPaperByPaperIds(String[] paperIds)
|
|
||||||
{
|
{
|
||||||
|
EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(paperId);
|
||||||
|
String taskId = educationPaper.getTaskId();
|
||||||
|
long total = educationPaperPersonMapper.selectEducationPaperPersonByTaskIdTotal(taskId);
|
||||||
|
|
||||||
educationPaperQuMapper.deleteEducationPaperQuByPaperIds(paperIds);
|
if (total > 0) {
|
||||||
return educationPaperMapper.deleteEducationPaperByPaperIds(paperIds);
|
throw new QueTypeException("此任务已分配人员,无法删除!");
|
||||||
|
}
|
||||||
|
|
||||||
|
educationPaperQuMapper.deleteEducationPaperQuByPaperId(paperId);
|
||||||
|
return educationPaperMapper.deleteEducationPaperByPaperId(paperId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -132,7 +132,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
|
|||||||
educationPaperParam.setIsExamPassword("1");
|
educationPaperParam.setIsExamPassword("1");
|
||||||
educationPaperParam.setUsb("1");
|
educationPaperParam.setUsb("1");
|
||||||
educationPaperParam.setSaveGrades("0");
|
educationPaperParam.setSaveGrades("0");
|
||||||
educationPaperParam.setDriver("C");
|
educationPaperParam.setDriver("D");
|
||||||
educationPaperParam.setIsNumber("1");
|
educationPaperParam.setIsNumber("1");
|
||||||
educationPaperParam.setIsConnect("0");
|
educationPaperParam.setIsConnect("0");
|
||||||
educationPaperParam.setIsAnswerId("1");
|
educationPaperParam.setIsAnswerId("1");
|
||||||
@@ -199,13 +199,20 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
|
|||||||
List<String> canDeleteTaskIds = new ArrayList<>();
|
List<String> canDeleteTaskIds = new ArrayList<>();
|
||||||
List<String> cannotDeleteTaskIds = new ArrayList<>();
|
List<String> cannotDeleteTaskIds = new ArrayList<>();
|
||||||
for (String taskId : taskIds) {
|
for (String taskId : taskIds) {
|
||||||
// 查询该任务下是否有试卷
|
EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectById(taskId);
|
||||||
int paperCount = educationPaperMapper.countPapersByTaskId(taskId);
|
|
||||||
if (paperCount == 0) {
|
if (educationPaperTask.getTaskType().equals("0")||educationPaperTask.getTaskType().equals("1")||educationPaperTask.getTaskType().equals("3")){
|
||||||
canDeleteTaskIds.add(taskId);
|
// 查询该任务下是否有试卷
|
||||||
|
int paperCount = educationPaperMapper.countPapersByTaskId(taskId);
|
||||||
|
if (paperCount == 0) {
|
||||||
|
canDeleteTaskIds.add(taskId);
|
||||||
|
}else {
|
||||||
|
cannotDeleteTaskIds.add(taskId);
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
cannotDeleteTaskIds.add(taskId);
|
canDeleteTaskIds.add(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 如果没有可删除的任务,直接返回
|
// 2. 如果没有可删除的任务,直接返回
|
||||||
@@ -233,9 +240,39 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteEducationPaperTaskByTaskId(String taskId) {
|
public String deleteEducationPaperTaskByTaskId(String taskId) {
|
||||||
monitorMapper.deleteByTaskId(taskId);
|
EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectById(taskId);
|
||||||
return educationPaperTaskMapper.deleteEducationPaperTaskByTaskId(taskId);
|
if (educationPaperTask.getTaskType().equals("0")||educationPaperTask.getTaskType().equals("1")||educationPaperTask.getTaskType().equals("3")){
|
||||||
|
// 1. 找出没有关联试卷的任务ID
|
||||||
|
List<String> canDeleteTaskIds = new ArrayList<>();
|
||||||
|
List<String> 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<String> taskNum= educationPaperMapper.selectTaskNumByids(cannotDeleteTaskIds);
|
||||||
|
return ("以下任务下有试卷:"+taskNum+",不能删除!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// monitorMapper.deleteByTaskId(taskId);
|
||||||
|
// educationPaperTaskMapper.deleteEducationPaperTaskByTaskId(taskId);
|
||||||
|
return "删除成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -61,7 +61,7 @@ public interface IEducationPaperService
|
|||||||
* @param paperIds 需要删除的试卷主键集合
|
* @param paperIds 需要删除的试卷主键集合
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteEducationPaperByPaperIds(String[] paperIds);
|
public int deleteEducationPaperByPaperIds(String paperIds) throws RuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除试卷信息
|
* 删除试卷信息
|
||||||
|
@@ -67,7 +67,7 @@ public interface IEducationPaperTaskService
|
|||||||
* @param taskId 试卷任务主键
|
* @param taskId 试卷任务主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteEducationPaperTaskByTaskId(String taskId);
|
public String deleteEducationPaperTaskByTaskId(String taskId);
|
||||||
/**
|
/**
|
||||||
* 获取专业列表
|
* 获取专业列表
|
||||||
*/
|
*/
|
||||||
|
@@ -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'
|
select paper_id ,num from education_paper where task_id=#{taskId} and deleted ='0'
|
||||||
</select>
|
</select>
|
||||||
<select id="countPapersByTaskId" resultType="java.lang.Integer">
|
<select id="countPapersByTaskId" resultType="java.lang.Integer">
|
||||||
select count(*) from education_paper where task_id =#{taskId}
|
select count(*) from education_paper where task_id =#{taskId} and deleted ='0'
|
||||||
</select>
|
</select>
|
||||||
<select id="selectTaskNumByids" resultType="java.lang.String">
|
<select id="selectTaskNumByids" resultType="java.lang.String">
|
||||||
select task_num from education_paper_task
|
select task_num from education_paper_task
|
||||||
|
@@ -30,7 +30,13 @@ public class PsUtil {
|
|||||||
public static String findPhotoshopExe() {
|
public static String findPhotoshopExe() {
|
||||||
String[] regPaths = {
|
String[] regPaths = {
|
||||||
"HKLM\\SOFTWARE\\Classes\\Applications\\Photoshop.exe\\shell\\edit\\command",
|
"HKLM\\SOFTWARE\\Classes\\Applications\\Photoshop.exe\\shell\\edit\\command",
|
||||||
"HKLM\\SOFTWARE\\WOW6432Node\\Classes\\Applications\\Photoshop.exe\\shell\\edit\\command"
|
"HKLM\\SOFTWARE\\WOW6432Node\\Classes\\Applications\\Photoshop.exe\\shell\\edit\\command",
|
||||||
|
"HKCU\\SOFTWARE\\Classes\\Applications\\Photoshop.exe\\shell\\edit\\command",
|
||||||
|
"HKLM\\SOFTWARE\\Adobe\\Photoshop",
|
||||||
|
"HKLM\\SOFTWARE\\WOW6432Node\\Adobe\\Photoshop",
|
||||||
|
"HKCR\\Photoshop.Image.13\\shell\\edit\\command",
|
||||||
|
"HKCR\\Photoshop.Image.13\\protocol\\StdFileEditing\\server",
|
||||||
|
"HKCR\\Photoshop.Image.13\\DefaultIcon",
|
||||||
};
|
};
|
||||||
|
|
||||||
for (String path : regPaths) {
|
for (String path : regPaths) {
|
||||||
|
Reference in New Issue
Block a user