|
@@ -151,14 +151,36 @@ public class EBaseService {
|
151
|
151
|
public ResultVo update(EBase model) {
|
152
|
152
|
try {
|
153
|
153
|
EBaseVo exam = eBaseMapper.getExamStateById(model.getExamid());
|
154
|
|
- if (2 <= exam.getExamstate()) return new ResultVo(1, "考试已结束禁止操作");
|
|
154
|
+ if (0 != exam.getExamstate()) return new ResultVo(1, "考试已发布禁止操作");
|
155
|
155
|
int timestamp = N_Utils.getSecondTimestamp() + 30 * 60;
|
156
|
156
|
if (exam.getBegintime() != 0 && exam.getBegintime().compareTo(timestamp) != 1) return new ResultVo(1, "开考前30分钟禁止编辑");
|
|
157
|
+ //2022/11/15 禁止修改年级、科目、考试模式
|
|
158
|
+ model.setGradeid(null);
|
|
159
|
+ model.setExammode(null);
|
157
|
160
|
eBaseMapper.updateByPrimaryKeySelective(model);
|
|
161
|
+
|
158
|
162
|
Integer examid = model.getExamid();
|
159
|
|
- eBaseMapper.deleteClassAndSubjectById(examid);//删除关联的班级和科目
|
160
|
|
- ResultVo vo = saveExam(model, examid);//保存考试基本信息
|
161
|
|
- if (vo != null) return vo;
|
|
163
|
+ List<Integer> classids = model.getClassids();
|
|
164
|
+ //班级集合为空不处理班级
|
|
165
|
+ if (N_Utils.isListEmpty(classids)) return new ResultVo(0, "修改成功");
|
|
166
|
+ if(exam.getExammode() == 2) {//线下考试必须有考号
|
|
167
|
+ Integer num = eClassStudentMapper.getNoExamNoNumByClassIds(classids);//根据班级ids获取没有考号学生数量
|
|
168
|
+ if (num != 0) return new ResultVo(1, "有学生没有考号");
|
|
169
|
+ }
|
|
170
|
+ List<EClassStudent> students = eClassStudentMapper.listByClassIds(classids);
|
|
171
|
+ int stuNum = students.stream().distinct().collect(Collectors.toList()).size();
|
|
172
|
+ if (stuNum < students.size()) return new ResultVo(1, "有重复学生");
|
|
173
|
+
|
|
174
|
+ //考试班级
|
|
175
|
+ List<EClass> classes = eClassMapper.listByClassIds(classids);
|
|
176
|
+ classes.forEach(c -> c.setExamid(examid));
|
|
177
|
+ eClassMapper.insertList(classes);
|
|
178
|
+
|
|
179
|
+ //考试学生
|
|
180
|
+ students.forEach(s -> s.setExamid(examid));
|
|
181
|
+ students = students.stream().filter(s -> !N_Utils.isEmptyInteger(s.getStudentid())).collect(Collectors.toList());
|
|
182
|
+ if(N_Utils.isListNotEmpty(students)) eClassStudentMapper.insertList(students);
|
|
183
|
+
|
162
|
184
|
return new ResultVo(0, "修改成功");
|
163
|
185
|
} catch (Exception e) {
|
164
|
186
|
log.error("修改考试失败", e.getMessage());
|