|
@@ -3,15 +3,26 @@ package com.xhkjedu.smarking.service.paper;
|
3
|
3
|
import com.xhkjedu.exception.MissingParametersException;
|
4
|
4
|
import com.xhkjedu.smarking.mapper.exam.MsSubjectMapper;
|
5
|
5
|
import com.xhkjedu.smarking.mapper.paper.MsPaperBackMapper;
|
|
6
|
+import com.xhkjedu.smarking.mapper.paper.MsPaperFileMapper;
|
6
|
7
|
import com.xhkjedu.smarking.mapper.paper.MsPaperMapper;
|
|
8
|
+import com.xhkjedu.smarking.mapper.paper.MsPaperQtypeQuestionMapper;
|
|
9
|
+import com.xhkjedu.smarking.mapper.system.SchoolMapper;
|
|
10
|
+import com.xhkjedu.smarking.model.paper.MsPaper;
|
7
|
11
|
import com.xhkjedu.smarking.model.paper.MsPaperBack;
|
|
12
|
+import com.xhkjedu.smarking.model.paper.MsPaperFile;
|
|
13
|
+import com.xhkjedu.smarking.utils.MarkingUtil;
|
|
14
|
+import com.xhkjedu.smarking.vo.paper.MsPaperParams;
|
|
15
|
+import com.xhkjedu.smarking.vo.paper.PaperFileVo;
|
|
16
|
+import com.xhkjedu.smarking.vo.system.SchoolCloudVo;
|
8
|
17
|
import com.xhkjedu.utils.N_Utils;
|
|
18
|
+import lombok.extern.slf4j.Slf4j;
|
9
|
19
|
import org.springframework.stereotype.Service;
|
10
|
20
|
import org.springframework.transaction.annotation.Transactional;
|
11
|
21
|
|
12
|
22
|
import javax.annotation.Resource;
|
13
|
23
|
import java.util.List;
|
14
|
24
|
import java.util.Map;
|
|
25
|
+import java.util.stream.Collectors;
|
15
|
26
|
|
16
|
27
|
/**
|
17
|
28
|
* @Description 阅卷试卷表 服务实现类
|
|
@@ -19,6 +30,7 @@ import java.util.Map;
|
19
|
30
|
* @Date 2024-10-15
|
20
|
31
|
*/
|
21
|
32
|
@Service
|
|
33
|
+@Slf4j
|
22
|
34
|
public class MsPaperService {
|
23
|
35
|
@Resource
|
24
|
36
|
private MsPaperMapper msPaperMapper;
|
|
@@ -26,6 +38,12 @@ public class MsPaperService {
|
26
|
38
|
private MsPaperBackMapper msPaperBackMapper;
|
27
|
39
|
@Resource
|
28
|
40
|
private MsSubjectMapper msSubjectMapper;
|
|
41
|
+ @Resource
|
|
42
|
+ private MsPaperQtypeQuestionMapper msPaperQtypeQuestionMapper;
|
|
43
|
+ @Resource
|
|
44
|
+ private MsPaperFileMapper msPaperFileMapper;
|
|
45
|
+ @Resource
|
|
46
|
+ private SchoolMapper schoolMapper;
|
29
|
47
|
|
30
|
48
|
/*
|
31
|
49
|
* @Description 列表--教师出卷
|
|
@@ -34,10 +52,10 @@ public class MsPaperService {
|
34
|
52
|
* @Param [teacherid, esstate]
|
35
|
53
|
* @Return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
|
36
|
54
|
**/
|
37
|
|
- public List<Map<String,Object>> listExamPapersByTeacherid(Integer teacherid, Integer pstate){
|
|
55
|
+ public List<Map<String, Object>> listExamPapersByTeacherid(Integer teacherid, Integer pstate) {
|
38
|
56
|
int timestamp = N_Utils.getSecondTimestamp();
|
39
|
57
|
String strtime = N_Utils.getStrtimeTimestamp(timestamp, "yyyy-MM-dd HH:mm:ss");
|
40
|
|
- return msPaperMapper.listExamPapersByTeacherid(teacherid,pstate,strtime);
|
|
58
|
+ return msPaperMapper.listExamPapersByTeacherid(teacherid, pstate, strtime);
|
41
|
59
|
}
|
42
|
60
|
|
43
|
61
|
/*
|
|
@@ -50,12 +68,12 @@ public class MsPaperService {
|
50
|
68
|
@Transactional(rollbackFor = Exception.class)
|
51
|
69
|
public void savePaperBack(MsPaperBack paperBack) {
|
52
|
70
|
Integer examstate = msPaperMapper.getExamStateByMpid(paperBack.getMpid());
|
53
|
|
- if (examstate == 1 ) throw new MissingParametersException("考试已开始禁止操作");
|
54
|
|
- if (examstate >= 2 ) throw new MissingParametersException("考试已结束禁止操作");
|
|
71
|
+ if (examstate == 1) throw new MissingParametersException("考试已开始禁止操作");
|
|
72
|
+ if (examstate >= 2) throw new MissingParametersException("考试已结束禁止操作");
|
55
|
73
|
int timestamp = N_Utils.getSecondTimestamp();
|
56
|
74
|
paperBack.setCreatetime(timestamp);
|
57
|
75
|
msPaperBackMapper.insertUseGeneratedKeys(paperBack);
|
58
|
|
- //更改试卷科目状态
|
|
76
|
+ // 更改试卷科目状态
|
59
|
77
|
msSubjectMapper.updatePstateByMpid(paperBack.getMpid(), 3);
|
60
|
78
|
}
|
61
|
79
|
|
|
@@ -66,13 +84,100 @@ public class MsPaperService {
|
66
|
84
|
* @Param [mpid]
|
67
|
85
|
* @Return java.util.List<java.util.Map>
|
68
|
86
|
**/
|
69
|
|
- public List<Map<String,Object>> listPaperBacksByEpid(Integer mpid){
|
|
87
|
+ public List<Map<String, Object>> listPaperBacksByEpid(Integer mpid) {
|
70
|
88
|
return msPaperBackMapper.listPaperBacksByMpid(mpid);
|
71
|
89
|
}
|
72
|
90
|
|
73
|
|
- //获取考试ID
|
74
|
|
- public Integer getExamidByMpid(Integer mpid){
|
|
91
|
+ // 获取考试ID
|
|
92
|
+ public Integer getExamidByMpid(Integer mpid) {
|
75
|
93
|
return msPaperMapper.getExamidByMpid(mpid);
|
76
|
94
|
}
|
77
|
95
|
|
|
96
|
+ /*
|
|
97
|
+ * @Description 试卷试题-获取试卷中所有试题题号及坐标
|
|
98
|
+ * @Date 2024/12/4 14:39:15
|
|
99
|
+ * @Author WN
|
|
100
|
+ * @Param [mpid]
|
|
101
|
+ * @Return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
|
|
102
|
+ **/
|
|
103
|
+ public List<Map<String, Object>> listPaperQuestionCoors(Integer mpid) {
|
|
104
|
+ return msPaperQtypeQuestionMapper.listQuestionsForShow(mpid);
|
|
105
|
+ }
|
|
106
|
+
|
|
107
|
+ /*
|
|
108
|
+ * @Description 试卷试题-保存切割
|
|
109
|
+ * @Date 2024/12/4 15:20:31
|
|
110
|
+ * @Author WN
|
|
111
|
+ * @Param [params]
|
|
112
|
+ * @Return void
|
|
113
|
+ **/
|
|
114
|
+ @Transactional(rollbackFor = Exception.class)
|
|
115
|
+ public void savePaperQuestionCoors(MsPaperParams params) {
|
|
116
|
+ // 保存试题切割信息
|
|
117
|
+ msPaperQtypeQuestionMapper.updateBatchQuestionCoor(params.getQuestions());
|
|
118
|
+ // 保存试卷切割状态
|
|
119
|
+ msPaperMapper.updatePaperCutState(params.getMpid(), 1);
|
|
120
|
+ }
|
|
121
|
+
|
|
122
|
+ /*
|
|
123
|
+ * @Description 试卷原卷-保存
|
|
124
|
+ * @Date 2024/10/17 16:00:37
|
|
125
|
+ * @Author WN
|
|
126
|
+ * @Param [paper]
|
|
127
|
+ * @Return com.xhkjedu.vo.ResultVo
|
|
128
|
+ **/
|
|
129
|
+ @Transactional(rollbackFor = Exception.class)
|
|
130
|
+ public void savePaperFiles(MsPaper paper) {
|
|
131
|
+ Integer mpid = paper.getMpid();
|
|
132
|
+ List<MsPaperFile> pfiles = paper.getPfiles();
|
|
133
|
+ // 删除已保存主观题答案图片
|
|
134
|
+ msPaperFileMapper.deleteByMpidAndType(mpid, 1);
|
|
135
|
+ Integer timestamp = N_Utils.getSecondTimestamp();
|
|
136
|
+ PaperFileVo paperFileVo = null;
|
|
137
|
+ if (pfiles.get(0).getFilepath().contains("base64,")) {
|
|
138
|
+ List<String> base64list = pfiles.stream().map(MsPaperFile::getFilepath).collect(Collectors.toList());
|
|
139
|
+
|
|
140
|
+ SchoolCloudVo schoolCloudVo = schoolMapper.getSchoolCloudcode(mpid);
|
|
141
|
+ String saveFloder = schoolCloudVo.getCloudcode() + "/" + schoolCloudVo.getSchoolid() + "/marking/paper/";
|
|
142
|
+ paperFileVo = MarkingUtil.uploadBatchBase64ImgPdf(base64list, saveFloder);
|
|
143
|
+ }
|
|
144
|
+
|
|
145
|
+ for (int i = 0; i < pfiles.size(); i++) {
|
|
146
|
+ MsPaperFile pf = pfiles.get(i);
|
|
147
|
+ pf.setMpid(mpid);
|
|
148
|
+ pf.setCreateid(paper.getCreateid());
|
|
149
|
+ pf.setCreatetime(timestamp);
|
|
150
|
+ pf.setFiletype(1);
|
|
151
|
+ pf.setFileorder(i + 1);
|
|
152
|
+ if (paperFileVo != null) {
|
|
153
|
+ pf.setSourcepath(paperFileVo.getPdfpath());
|
|
154
|
+ pf.setFilepath(paperFileVo.getImgs().get(i));
|
|
155
|
+ }
|
|
156
|
+ }
|
|
157
|
+ paper.setHasfile(1);
|
|
158
|
+ msPaperMapper.updateByPrimaryKeySelective(paper);
|
|
159
|
+ msPaperFileMapper.insertList(pfiles);
|
|
160
|
+ }
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+ /*
|
|
164
|
+ * @Description 试卷原卷-删除
|
|
165
|
+ * @Date 2024/12/4 15:34:23
|
|
166
|
+ * @Author WN
|
|
167
|
+ * @Param [mpid]
|
|
168
|
+ * @Return void
|
|
169
|
+ **/
|
|
170
|
+ @Transactional(rollbackFor = Exception.class)
|
|
171
|
+ public void deletePaperFiles(Integer mpid) {
|
|
172
|
+ // 删除试卷文件
|
|
173
|
+ msPaperFileMapper.deleteByMpidAndType(mpid, 1);
|
|
174
|
+ // 获取试卷切割状态
|
|
175
|
+ Integer cutstate = msPaperMapper.getPaperCutStateByMpid(mpid);
|
|
176
|
+ if (N_Utils.isTrueInteger(cutstate)) {
|
|
177
|
+ // 说明试卷已切割,清除切割信息
|
|
178
|
+ msPaperMapper.updatePaperCutState(mpid, 0);// 保存试卷切割状态
|
|
179
|
+ msPaperQtypeQuestionMapper.updateQuestionCoorByMpid(mpid);// 清除试题切割信息
|
|
180
|
+ }
|
|
181
|
+ }
|
|
182
|
+
|
78
|
183
|
}
|