Parcourir la source

考试修改完善

tags/正式版本
雍文秀 il y a 2 ans
Parent
révision
93f5a2af08

+ 26
- 4
sexam/src/main/java/com/xhkjedu/sexam/service/exam/EBaseService.java Voir le fichier

@@ -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());

+ 1
- 1
sexam/src/main/resources/mapper/exam/EBaseMapper.xml Voir le fichier

@@ -19,7 +19,7 @@
19 19
         select b.examid,b.examname,b.examdate,b.gradeid,b.examtype,b.exammode,b.monitored,b.showrank
20 20
         ,b.examstate,u.username createname,group_concat(distinct es.subjectname order by es.esid separator '|')subjectname
21 21
         ,count(distinct case when es.begintime is null or es.begintime='' then es.esid else null end)esnum
22
-        ,min(es.esstate)esstate,min(ifnull(ep.correcttype,0))correcttype
22
+        ,min(es.esstate)esstate,min(es.pstate)pstate,min(ifnull(ep.correcttype,0))correcttype
23 23
         ,(case when b.exammode=1 then (count(distinct es.esid)-count(distinct ei.esid))
24 24
         else (select sum(ec.classnum)*count(distinct es.esid)-(select count(ps.epsid) from e_paper_student ps
25 25
         where ps.examid=b.examid and ps.sstate in(0,1)) from e_class ec

+ 1
- 1
sexam/src/main/resources/mapper/exam/ESubjectMapper.xml Voir le fichier

@@ -110,7 +110,7 @@
110 110
         update e_base eb left join e_subject es on eb.examid = es.examid
111 111
         set es.pstate=1
112 112
         where eb.examstate>=1 and eb.deleted=1 and eb.exammode=1
113
-        and es.pstate=0 and concat(es.sdate,' ',es.begintime)&lt;=now()
113
+        and es.pstate=0 and es.sdate=current_date() and concat(es.sdate,' ',es.begintime)&lt;=now()
114 114
     </update>
115 115
     <!--试卷结束考试-->
116 116
     <update id="endPaper">

Chargement…
Annuler
Enregistrer