|
@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.sim.config.SimConfig;
|
|
|
import com.ruoyi.sim.config.SimDebugConfig;
|
|
|
+import com.ruoyi.sim.constant.ArBuilder;
|
|
|
import com.ruoyi.sim.domain.*;
|
|
|
import com.ruoyi.sim.domain.vo.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -17,6 +18,8 @@ import org.springframework.stereotype.Service;
|
|
|
import com.ruoyi.sim.mapper.RealExamMapper;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import static com.ruoyi.sim.constant.ErrorConst.*;
|
|
|
+
|
|
|
/**
|
|
|
* 考试Service业务层处理
|
|
|
*
|
|
@@ -295,7 +298,7 @@ public class RealExamService {
|
|
|
if (StringUtils.equals(RealExamCollection.Type.EXERCISE, examCollectionType)) {
|
|
|
// 已经open的考试。
|
|
|
if (realExamCollectionService.existOpenedByType(RealExamCollection.Type.EXAM)) {
|
|
|
- return AjaxResult.error("存在打开的考试,无法开启训练!<br/>请向教员说明情况。");
|
|
|
+ return ArBuilder.error(T_60001, M_60001);
|
|
|
}
|
|
|
} else {
|
|
|
l.info("type EXERCISE,没有打开的考试,校验正确");
|
|
@@ -304,13 +307,13 @@ public class RealExamService {
|
|
|
if (StringUtils.equals(RealExamCollection.Type.SELF_EXERCISE, examCollectionType)) {
|
|
|
// 已经open的考试。
|
|
|
if (realExamCollectionService.existOpenedByType(RealExamCollection.Type.EXAM)) {
|
|
|
- return AjaxResult.error("存在打开的考试,无法开启练习!<br/>请向教员说明情况。");
|
|
|
+ return ArBuilder.error(T_60002, M_60002);
|
|
|
} else {
|
|
|
l.info("type SELF_EXERCISE,没有打开的考试,校验正确");
|
|
|
}
|
|
|
// 已经open的训练。
|
|
|
if (realExamCollectionService.existOpenedByType(RealExamCollection.Type.EXERCISE)) {
|
|
|
- return AjaxResult.error("存在打开的训练,无法开启练习!<br/>请向教员说明情况。");
|
|
|
+ return ArBuilder.error(T_60003, M_60003);
|
|
|
} else {
|
|
|
l.info("type SELF_EXERCISE,没有打开的训练,校验正确");
|
|
|
}
|
|
@@ -333,14 +336,14 @@ public class RealExamService {
|
|
|
if (StringUtils.equals(re.getExamStatus(), RealExam.State.SUBMITTED) ||
|
|
|
StringUtils.equals(re.getExamStatus(), RealExam.State.CALCULATING_SCORE) ||
|
|
|
StringUtils.equals(re.getExamStatus(), RealExam.State.GOT_REPORT)) {
|
|
|
- return AjaxResult.error("已经交卷,禁止重复开始考试!");
|
|
|
+ return ArBuilder.error(T_60005, M_60005);
|
|
|
} else {
|
|
|
l.info("没有重复交卷校验正确");
|
|
|
}
|
|
|
RealExamCollection rec = realExamCollectionService.selectRealExamCollectionByExamCollectionId(re.getExamCollectionId());
|
|
|
// Check:考试集合数据有效性。
|
|
|
if (rec == null) {
|
|
|
- return AjaxResult.error("考试集合数据异常!");
|
|
|
+ return ArBuilder.error(T_60006, M_60006);
|
|
|
} else {
|
|
|
l.info("考试集合数据校验正确");
|
|
|
}
|
|
@@ -348,26 +351,26 @@ public class RealExamService {
|
|
|
if (StringUtils.equals(rec.getExamCollectionType(), RealExamCollection.Type.SELF_EXERCISE)) {
|
|
|
l.info("练习类型考试集合,不需要检查 考试集合 开关状态。");
|
|
|
} else {
|
|
|
- return AjaxResult.error("教师端对应考试/训练尚未打开!<br/>请向教员说明情况。");
|
|
|
+ return ArBuilder.error(T_60007, M_60007);
|
|
|
}
|
|
|
} else {
|
|
|
l.info("考试集合开启校验正确");
|
|
|
}
|
|
|
// Check:检查参数examCollectionType有效性
|
|
|
if (!StringUtils.equals(examCollectionType, rec.getExamCollectionType())) {
|
|
|
- return AjaxResult.error("考试集合类型不对应!");
|
|
|
+ return ArBuilder.error(T_60008, M_60008);
|
|
|
} else {
|
|
|
l.info("考试集合类型校验正确");
|
|
|
}
|
|
|
// Check:检查参数studentBindIp有效性
|
|
|
if (StringUtils.isBlank(ip)) {
|
|
|
- return AjaxResult.error("IP地址无效");
|
|
|
+ return ArBuilder.error(T_40001, M_40001);
|
|
|
} else {
|
|
|
l.info("IP地址检验正确");
|
|
|
}
|
|
|
Seat seat = seatService.uniqueByBindIp(ip);
|
|
|
if (seat == null) {
|
|
|
- return AjaxResult.error("没有IP对应座次数据!");
|
|
|
+ return ArBuilder.error(T_40002, M_40002);
|
|
|
} else {
|
|
|
l.info("座次数据检验正确");
|
|
|
}
|
|
@@ -424,7 +427,7 @@ public class RealExamService {
|
|
|
l.info("Who模拟器校验正确");
|
|
|
}
|
|
|
if (ar.isSuccess()) {
|
|
|
-
|
|
|
+ l.info("isSuccess {}", ar);
|
|
|
} else if (ar.isError()) { // 其他的异常情况。
|
|
|
return ar;
|
|
|
}
|
|
@@ -444,12 +447,14 @@ public class RealExamService {
|
|
|
// Check: seat_id 和 current_sim_id
|
|
|
{
|
|
|
RealExam reF = selectRealExamByExamId(examId);
|
|
|
- if (reF == null ||
|
|
|
- reF.getSeatId() == null ||
|
|
|
- reF.getSeatId() == 0L ||
|
|
|
- reF.getSimId() == null ||
|
|
|
- reF.getSimId() == 0) {
|
|
|
- return AjaxResult.error("开始考试异常!<br/>请刷新页面重试!");
|
|
|
+ if (reF == null) {
|
|
|
+ return ArBuilder.error(T60010, M60010);
|
|
|
+ }
|
|
|
+ if (reF.getSeatId() == null || reF.getSeatId() == 0L) {
|
|
|
+ return ArBuilder.error(T_40010, M_40010);
|
|
|
+ }
|
|
|
+ if (reF.getSimId() == null || reF.getSimId() == 0) {
|
|
|
+ return ArBuilder.error(T_40011, M_40011);
|
|
|
}
|
|
|
}
|
|
|
// Step:查询模拟器在线状态,纯DB查询。
|
|
@@ -524,7 +529,7 @@ public class RealExamService {
|
|
|
l.info("开始考试成功");
|
|
|
return AjaxResult.success("开始考试成功!");
|
|
|
} else {
|
|
|
- return AjaxResult.error("开始考试失败,<br/>请重新尝试开始考试!");
|
|
|
+ return ArBuilder.error(T60009, M60009);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -556,7 +561,7 @@ public class RealExamService {
|
|
|
public AjaxResult checkExamId(final Long examId) {
|
|
|
// Check:检查 examId 是否正确存在
|
|
|
if (!exist(examId)) {
|
|
|
- return AjaxResult.error("对应考试Id不存在!");
|
|
|
+ return ArBuilder.error(T_60004, M_60004);
|
|
|
} else {
|
|
|
return AjaxResult.success();
|
|
|
}
|