|
@@ -8,11 +8,14 @@ import com.xhkjedu.sstudy.mapper.paper.PaperScantronMapper;
|
8
|
8
|
import com.xhkjedu.sstudy.mapper.paperstudent.PaperClassMapper;
|
9
|
9
|
import com.xhkjedu.sstudy.mapper.paperstudent.PaperStudentMapper;
|
10
|
10
|
import com.xhkjedu.sstudy.mapper.paperstudent.PaperStudentQuestionMapper;
|
|
11
|
+import com.xhkjedu.sstudy.mapper.paperstudent.PaperStudentScantronMapper;
|
11
|
12
|
import com.xhkjedu.sstudy.model.paper.TPaper;
|
12
|
13
|
import com.xhkjedu.sstudy.model.paper.TPaperQtypeQuestion;
|
|
14
|
+import com.xhkjedu.sstudy.model.paper.TPaperScantron;
|
13
|
15
|
import com.xhkjedu.sstudy.model.paperstudent.TPaperClass;
|
14
|
16
|
import com.xhkjedu.sstudy.model.paperstudent.TPaperStudent;
|
15
|
17
|
import com.xhkjedu.sstudy.model.paperstudent.TPaperStudentQuestion;
|
|
18
|
+import com.xhkjedu.sstudy.model.paperstudent.TPaperStudentScantron;
|
16
|
19
|
import com.xhkjedu.sstudy.utils.ArithUtil;
|
17
|
20
|
import com.xhkjedu.sstudy.vo.paperstudent.PaperClassParam;
|
18
|
21
|
import com.xhkjedu.sstudy.vo.paperstudent.PaperGroupParam;
|
|
@@ -23,9 +26,7 @@ import com.xhkjedu.sstudy.vo.subjectbook.PointVo;
|
23
|
26
|
import com.xhkjedu.utils.N_Utils;
|
24
|
27
|
import com.xhkjedu.vo.ResultVo;
|
25
|
28
|
import lombok.extern.slf4j.Slf4j;
|
26
|
|
-import org.apache.commons.lang3.StringUtils;
|
27
|
29
|
import org.springframework.beans.factory.annotation.Autowired;
|
28
|
|
-import org.springframework.dao.DuplicateKeyException;
|
29
|
30
|
import org.springframework.stereotype.Service;
|
30
|
31
|
import org.springframework.transaction.annotation.Transactional;
|
31
|
32
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
@@ -58,144 +59,61 @@ public class PaperClassService {
|
58
|
59
|
private PaperScantronMapper paperScantronMapper;
|
59
|
60
|
@Resource
|
60
|
61
|
private PaperStudentQuestionMapper paperStudentQuestionMapper;
|
|
62
|
+ @Resource
|
|
63
|
+ private PaperStudentScantronMapper paperStudentScantronMapper;
|
61
|
64
|
|
62
|
|
- /**
|
63
|
|
- *功能描述
|
64
|
|
- * @author WN
|
65
|
|
- * @date 2020/6/9
|
66
|
|
- * @param * @param paperGroupVo
|
67
|
|
- * @return void
|
68
|
|
- */
|
69
|
|
- @Transactional(rollbackFor = Exception.class)
|
70
|
|
- public ResultVo savePaperGroup(PaperGroupParam paperGroupParam){
|
71
|
|
- ResultVo resultVo = null;
|
72
|
|
- try {
|
73
|
|
- //获取试卷详细信息
|
74
|
|
- TPaper paper = paperMapper.selectByPrimaryKey(paperGroupParam.getPaperid());
|
75
|
|
- if (paper.getPaperstate() == 22) return new ResultVo(0,"保存成功");
|
76
|
|
- //班级
|
77
|
|
- List<TPaperClass> classlst = paperGroupParam.getClasslst().stream().distinct().collect(Collectors.toList());
|
78
|
|
- List<Map> jtrclist = paperGroupParam.getJtrclist();
|
79
|
|
-
|
80
|
|
- if (N_Utils.isListEmpty(classlst) && N_Utils.isListEmpty(jtrclist)) {
|
81
|
|
- return new ResultVo(1, "发布作业未选择班级");
|
82
|
|
- }else{
|
83
|
|
-
|
84
|
|
- //保存作业分组、作业学生
|
85
|
|
- resultVo = this.savePaperStudent(paperGroupParam,classlst,paper);
|
86
|
|
- if(resultVo.getCode()==1){
|
87
|
|
- return resultVo;
|
88
|
|
- }else{
|
89
|
|
- //获取作业是否全是非主观题
|
90
|
|
- int count = 0;
|
91
|
|
- if(paper.getPapertype()==1){
|
92
|
|
- //题库作业
|
93
|
|
- count = paperQtypeQuestionMapper.getQuestionCountCtype(paperGroupParam.getPaperid());
|
94
|
|
- }else{
|
95
|
|
- //答题卡作业
|
96
|
|
- count = paperScantronMapper.getQuestionCountCtype(paperGroupParam.getPaperid());
|
97
|
|
- }
|
98
|
|
-
|
99
|
|
- //保存作业分组、作业学生成功后,修改作业状态
|
100
|
|
- Integer hashb = 0;
|
101
|
|
- if (N_Utils.isListNotEmpty(jtrclist)) hashb = 1;
|
102
|
|
- paperMapper.updatePaperState(22,paperGroupParam.getPaperid(),count,hashb);
|
103
|
|
-
|
104
|
|
- resultVo.setObj(count);//如果count=0则,代表全部是选择题
|
105
|
|
- }
|
106
|
|
- }
|
107
|
|
-
|
108
|
|
- }catch (Exception e){
|
109
|
|
- log.error("发布作业失败:" + e.getMessage());
|
110
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
111
|
|
- return new ResultVo(1,"发布失败");
|
112
|
|
- }
|
113
|
|
- return resultVo;
|
114
|
|
- }
|
115
|
|
-
|
116
|
|
- private ResultVo savePaperStudent(PaperGroupParam paperGroupParam, List<TPaperClass> classlst, TPaper paper) {
|
117
|
|
- List<TPaperClass> savegroup = new ArrayList<>();//班级分组
|
118
|
|
- List<TPaperStudent> saveps = new ArrayList<>();//班级分组学生
|
119
|
|
-
|
120
|
|
- Integer schoolid = paperGroupParam.getSchoolid();
|
121
|
|
- Integer paperid = paperGroupParam.getPaperid();
|
122
|
|
- Integer starttime = paperGroupParam.getStarttime();
|
123
|
|
- Integer stoptime = paperGroupParam.getStoptime();
|
124
|
|
- Integer showtype = paperGroupParam.getShowtype();
|
125
|
|
- Integer createid = paperGroupParam.getCreateid();
|
126
|
|
- Integer papernum = paper.getPapernum();
|
127
|
|
- Double paperscore = paper.getPaperscore();
|
128
|
|
- for (TPaperClass pg : classlst) {
|
129
|
|
- List<Integer> groups = pg.getGroups();
|
130
|
|
- Integer classid = pg.getClassid();
|
131
|
|
- //处理作业分组数据
|
132
|
|
- setPaperGroup(savegroup, saveps, schoolid, paperid, starttime, stoptime, showtype
|
133
|
|
- , createid, papernum, paperscore, classid, groups);
|
134
|
|
- }
|
135
|
|
-
|
136
|
|
- //集团校班级学生
|
137
|
|
- List<Map> jtrclist = paperGroupParam.getJtrclist();
|
138
|
|
- for (Map schoolmap : jtrclist) {
|
139
|
|
- schoolid = Integer.parseInt(schoolmap.get("schoolid").toString());
|
140
|
|
- List<Map> classlist = (List<Map>) schoolmap.get("classlist");
|
141
|
|
- for (Map classmap : classlist) {
|
142
|
|
- Integer classid = Integer.parseInt(classmap.get("classid").toString());
|
143
|
|
- List<Integer> groups = (List<Integer>) classmap.get("groups");
|
144
|
|
- //处理作业分组数据
|
145
|
|
- setPaperGroup(savegroup, saveps, schoolid, paperid, starttime, stoptime, showtype
|
146
|
|
- , createid, papernum, paperscore, classid, groups);
|
147
|
|
- }
|
148
|
|
- }
|
149
|
|
-
|
150
|
|
- //批量保存作业班级,作业班级学生信息
|
151
|
|
- try {
|
152
|
|
- paperClassMapper.insertList(savegroup);
|
153
|
|
- } catch (Exception e) {
|
154
|
|
- if (e instanceof DuplicateKeyException) {
|
155
|
|
- return new ResultVo(0, "保存成功");
|
156
|
|
- }
|
157
|
|
- }
|
158
|
|
- paperStudentMapper.saveBatchPaperStudent(saveps);
|
159
|
|
- return new ResultVo(0, "保存成功");
|
160
|
|
- }
|
161
|
|
-
|
162
|
|
- //处理作业分组数据
|
163
|
|
- private void setPaperGroup(List<TPaperClass> savegroup, List<TPaperStudent> saveps
|
164
|
|
- , Integer schoolid, Integer paperid, Integer starttime, Integer stoptime
|
165
|
|
- , Integer showtype, Integer createid, Integer papernum, Double paperscore
|
166
|
|
- , Integer classid, List<Integer> groups) {
|
167
|
|
- if (N_Utils.isListNotEmpty(groups)) {
|
|
65
|
+ //处理作业分组数据(附件)
|
|
66
|
+ private Integer setPaperGroup(Integer stunum
|
|
67
|
+ , List<TPaperScantron> pquestions, Integer timestamp, Integer schoolid
|
|
68
|
+ , Integer paperid, Integer starttime, Integer stoptime, Integer showtype, Integer createid
|
|
69
|
+ , Integer papernum, Double paperscore, Integer classid, List<PaperStudentParam> students, Integer hasfc) {
|
|
70
|
+ List<TPaperStudentScantron> savestuque=new ArrayList<>();
|
|
71
|
+ if (N_Utils.isListNotEmpty(students)) {
|
168
|
72
|
TPaperClass pg = new TPaperClass();
|
169
|
|
- pg.setClassid(classid);
|
170
|
73
|
pg.setPaperid(paperid);
|
171
|
|
- pg.setPgstate(22);//布置作业
|
|
74
|
+ pg.setClassid(classid);
|
|
75
|
+ pg.setPgstate(22);
|
172
|
76
|
pg.setStarttime(starttime);
|
173
|
77
|
pg.setStoptime(stoptime);
|
174
|
78
|
pg.setShowtype(showtype);
|
175
|
79
|
pg.setCreateid(createid);
|
176
|
80
|
pg.setSchoolid(schoolid);
|
177
|
|
- pg.setCreatetime(N_Utils.getSecondTimestamp());
|
|
81
|
+ pg.setCreatetime(timestamp);
|
178
|
82
|
pg.setChecked(0);
|
|
83
|
+ pg.setHasfc(hasfc);
|
|
84
|
+ paperClassMapper.insertSelective(pg);
|
179
|
85
|
|
180
|
|
- savegroup.add(pg);
|
181
|
|
- String groupids = StringUtils.join(groups, ",");
|
182
|
|
- //获取选中班级分组下所有学生
|
183
|
|
- List<Integer> stus = classMapper.listStudentidsByGroupids(groupids);
|
184
|
|
-
|
185
|
|
- for (Integer stu : stus) {
|
|
86
|
+ //根据studentid集合去重
|
|
87
|
+ List<PaperStudentParam> students2 = students.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(PaperStudentParam::getStudentid))), ArrayList::new));
|
|
88
|
+ for (PaperStudentParam s : students2) {
|
186
|
89
|
TPaperStudent ps = new TPaperStudent();
|
187
|
90
|
ps.setPaperid(paperid);
|
188
|
91
|
ps.setClassid(classid);
|
189
|
|
- ps.setStudentid(stu);
|
190
|
|
- ps.setPapernum(papernum);
|
191
|
|
- ps.setPaperscore(paperscore);
|
|
92
|
+ ps.setStudentid(s.getStudentid());
|
192
|
93
|
ps.setCreateid(createid);
|
193
|
|
- ps.setSchoolid(schoolid);
|
194
|
94
|
ps.setCreatetime(N_Utils.getSecondTimestamp());
|
195
|
|
-
|
196
|
|
- saveps.add(ps);
|
|
95
|
+ ps.setSchoolid(schoolid);
|
|
96
|
+ ps.setPapernum(papernum);
|
|
97
|
+ ps.setPaperscore(paperscore);
|
|
98
|
+ Integer psid = savePaperStu(ps);
|
|
99
|
+ for (TPaperScantron q : pquestions) {
|
|
100
|
+ TPaperStudentScantron sq=new TPaperStudentScantron();
|
|
101
|
+ sq.setPaperid(paperid);
|
|
102
|
+ sq.setClassid(classid);
|
|
103
|
+ sq.setStudentid(s.getStudentid());
|
|
104
|
+ sq.setPsid(psid);
|
|
105
|
+ sq.setPscaid(q.getPscaid());
|
|
106
|
+ sq.setQscore(q.getPsscore());
|
|
107
|
+ sq.setQn(q.getQn());
|
|
108
|
+ sq.setQorder(q.getPsorder());
|
|
109
|
+ sq.setSchoolid(schoolid);
|
|
110
|
+ savestuque.add(sq);
|
|
111
|
+ }
|
|
112
|
+ stunum += 1;
|
197
|
113
|
}
|
|
114
|
+ if(N_Utils.isListNotEmpty(savestuque)) paperStudentScantronMapper.saveBatchStudentScantron(savestuque);
|
198
|
115
|
}
|
|
116
|
+ return stunum;
|
199
|
117
|
}
|
200
|
118
|
|
201
|
119
|
/**
|
|
@@ -326,7 +244,7 @@ public class PaperClassService {
|
326
|
244
|
return new ResultVo(1, "发布作业未选择班级");
|
327
|
245
|
} else {
|
328
|
246
|
Integer stunum = 0;
|
329
|
|
- List<TPaperQtypeQuestion> pquestions = new ArrayList<>();//试卷中所有试题
|
|
247
|
+ List pquestions;//试卷中所有试题
|
330
|
248
|
Integer timestamp = N_Utils.getSecondTimestamp();
|
331
|
249
|
Integer papertype = paper.getPapertype();
|
332
|
250
|
Integer schoolid = paperGroupParam.getSchoolid();
|
|
@@ -337,7 +255,9 @@ public class PaperClassService {
|
337
|
255
|
Integer createid = paperGroupParam.getCreateid();
|
338
|
256
|
Integer papernum = paper.getPapernum();
|
339
|
257
|
Double paperscore = paper.getPaperscore();
|
340
|
|
- if (papertype == 3) {
|
|
258
|
+ if (papertype == 2) {//附件
|
|
259
|
+ pquestions = paperScantronMapper.listPaperScansByPaperid(paperid);
|
|
260
|
+ } else {
|
341
|
261
|
pquestions = paperQtypeQuestionMapper.listQuestionByPaperid(paperid);
|
342
|
262
|
}
|
343
|
263
|
//遍历班级,班级学生
|
|
@@ -346,8 +266,13 @@ public class PaperClassService {
|
346
|
266
|
Integer hasfc = c.getHasfc();
|
347
|
267
|
List<PaperStudentParam> students = c.getStudents();
|
348
|
268
|
//处理作业分组数据
|
349
|
|
- stunum = setPaperGroup2(stunum, pquestions, timestamp, papertype, schoolid, paperid
|
350
|
|
- , starttime, stoptime, showtype, createid, papernum, paperscore, classid, students,hasfc);
|
|
269
|
+ if (papertype == 2) {//附件
|
|
270
|
+ stunum = setPaperGroup(stunum, pquestions, timestamp, schoolid, paperid
|
|
271
|
+ , starttime, stoptime, showtype, createid, papernum, paperscore, classid, students, hasfc);
|
|
272
|
+ } else {
|
|
273
|
+ stunum = setPaperGroup2(stunum, pquestions, timestamp, papertype, schoolid, paperid
|
|
274
|
+ , starttime, stoptime, showtype, createid, papernum, paperscore, classid, students, hasfc);
|
|
275
|
+ }
|
351
|
276
|
}
|
352
|
277
|
|
353
|
278
|
//集团校班级学生
|
|
@@ -356,11 +281,20 @@ public class PaperClassService {
|
356
|
281
|
List<Map> classlist = (List<Map>) schoolmap.get("classlist");
|
357
|
282
|
for (Map classmap : classlist) {
|
358
|
283
|
Integer classid = Integer.parseInt(classmap.get("classid").toString());
|
359
|
|
- Integer hasfc = Integer.parseInt(classmap.get("hasfc").toString());
|
|
284
|
+ Integer hasfc = 0;
|
|
285
|
+ Object fc = classmap.get("hasfc");
|
|
286
|
+ if (N_Utils.isNotEmpty(fc)) {
|
|
287
|
+ hasfc = N_Utils.str2Int(fc.toString());
|
|
288
|
+ }
|
360
|
289
|
List<PaperStudentParam> students = JSON.parseArray(JSON.toJSONString(classmap.get("students")), PaperStudentParam.class);
|
361
|
290
|
//处理作业分组数据
|
362
|
|
- stunum = setPaperGroup2(stunum, pquestions, timestamp, papertype, schoolid, paperid
|
363
|
|
- , starttime, stoptime, showtype, createid, papernum, paperscore, classid, students,hasfc);
|
|
291
|
+ if (papertype == 2) {//附件
|
|
292
|
+ stunum = setPaperGroup(stunum, pquestions, timestamp, schoolid, paperid
|
|
293
|
+ , starttime, stoptime, showtype, createid, papernum, paperscore, classid, students, hasfc);
|
|
294
|
+ } else {
|
|
295
|
+ stunum = setPaperGroup2(stunum, pquestions, timestamp, papertype, schoolid, paperid
|
|
296
|
+ , starttime, stoptime, showtype, createid, papernum, paperscore, classid, students, hasfc);
|
|
297
|
+ }
|
364
|
298
|
}
|
365
|
299
|
}
|
366
|
300
|
|