|
@@ -42,46 +42,50 @@ public class ZQuestionUpdateService {
|
42
|
42
|
private QuestionPointMapper questionPointMapper;
|
43
|
43
|
|
44
|
44
|
/**
|
45
|
|
- * @Description 处理万幸填空阅读理解
|
|
45
|
+ * @Description 处理万幸填空阅读理解
|
46
|
46
|
* @Param []
|
47
|
47
|
* @Return void
|
48
|
48
|
* @Author wn
|
49
|
49
|
* @Date 2022/8/17 8:52
|
50
|
50
|
**/
|
51
|
51
|
@Transactional(rollbackFor = Exception.class)
|
52
|
|
- public void saveQuestions() throws Exception{
|
53
|
|
- //需要处理试题的科目
|
|
52
|
+ public void saveQuestions() throws Exception {
|
|
53
|
+ // 需要处理试题的科目
|
54
|
54
|
List<TSubject> subjects = zQuestionUpdateMapper.listSubjects();
|
55
|
|
- if(N_Utils.isListEmpty(subjects)){
|
|
55
|
+
|
|
56
|
+ if (N_Utils.isListEmpty(subjects)) {
|
56
|
57
|
throw new Exception("无需要处理试题");
|
57
|
58
|
}
|
58
|
|
- for(TSubject s : subjects){
|
59
|
|
- List<TSubjectQuestiontype> qtypelist = zQuestionUpdateMapper.listSubjectQtype(s.getLevel(),s.getSubjectid());
|
|
59
|
+ for (TSubject s : subjects) {
|
|
60
|
+ List<TSubjectQuestiontype> qtypelist = zQuestionUpdateMapper.listSubjectQtype(s.getLevel(), s.getSubjectid());
|
60
|
61
|
Map<Integer, TSubjectQuestiontype> tmap = new TreeMap();
|
61
|
|
- if(N_Utils.isListEmpty(qtypelist)){
|
|
62
|
+ if (N_Utils.isListEmpty(qtypelist)) {
|
62
|
63
|
throw new Exception(s.getSubjectname() + "未设置题型");
|
63
|
64
|
}
|
64
|
|
- for(TSubjectQuestiontype t : qtypelist){
|
65
|
|
- tmap.put(t.getCtype(),t);
|
|
65
|
+ for (TSubjectQuestiontype t : qtypelist) {
|
|
66
|
+ if(!tmap.containsKey(t.getCtype())){
|
|
67
|
+ tmap.put(t.getCtype(), t);
|
|
68
|
+ }
|
66
|
69
|
}
|
67
|
70
|
|
68
|
|
- List<QuestionVo> list = zQuestionUpdateMapper.listQuestions(s.getLevel(),s.getSubjectid());
|
|
71
|
+ List<QuestionVo> list = zQuestionUpdateMapper.listQuestions(s.getLevel(), s.getSubjectid());
|
69
|
72
|
|
70
|
73
|
List<TQuestion> questions = new ArrayList<>();
|
71
|
74
|
List<TQuestionDirector> directors = new ArrayList<>();
|
72
|
75
|
List<TQuestionPoint> points = new ArrayList<>();
|
|
76
|
+ List<String> questionids = new ArrayList<>();
|
73
|
77
|
int timestamp = N_Utils.getSecondTimestamp();
|
74
|
|
- for(int k=0;k<list.size();k++){
|
|
78
|
+ for (int k = 0; k < list.size(); k++) {
|
75
|
79
|
// System.out.println("第几题:"+(k+1));
|
76
|
|
- QuestionVo qvo=list.get(k);
|
|
80
|
+ QuestionVo qvo = list.get(k);
|
77
|
81
|
TQuestion q = new TQuestion();
|
78
|
82
|
String qid = StudyUtil.getId();
|
79
|
83
|
|
80
|
|
- //处理子题
|
|
84
|
+ // 处理子题
|
81
|
85
|
String qoption = qvo.getQoption();
|
82
|
86
|
String qanswer = qvo.getQanswer();
|
83
|
87
|
List<Map> optionlist = JSON.parseArray(qoption, Map.class);
|
84
|
|
- List<String> answerlist = JSON.parseArray(qanswer,String.class);
|
|
88
|
+ List<String> answerlist = JSON.parseArray(qanswer, String.class);
|
85
|
89
|
|
86
|
90
|
q.setQuestionid(qid);
|
87
|
91
|
q.setQstem(qvo.getQstem());
|
|
@@ -104,22 +108,27 @@ public class ZQuestionUpdateService {
|
104
|
108
|
q.setCreatetime(timestamp);
|
105
|
109
|
q.setBelong(qvo.getBelong());
|
106
|
110
|
q.setSchoolid(qvo.getSchoolid());
|
107
|
|
- if(qvo.getCtype() == 7 || qvo.getCtype() == 8 ){
|
108
|
|
- TSubjectQuestiontype st = tmap.get(16);
|
|
111
|
+ TSubjectQuestiontype st = null;
|
|
112
|
+ if (qvo.getCtype() == 7 || qvo.getCtype() == 8) {
|
|
113
|
+ st = tmap.get(16);
|
109
|
114
|
q.setCtype(16);
|
110
|
|
- q.setQtypeid(st.getQtypeid());
|
111
|
|
- q.setQtypename(st.getQtypename());
|
|
115
|
+
|
112
|
116
|
}
|
113
|
|
- if(qvo.getCtype() == 10){
|
114
|
|
- TSubjectQuestiontype st = tmap.get(17);
|
|
117
|
+ if (qvo.getCtype() == 10) {
|
|
118
|
+ st = tmap.get(17);
|
115
|
119
|
q.setCtype(17);
|
116
|
|
- q.setQtypeid(st.getQtypeid());
|
117
|
|
- q.setQtypename(st.getQtypename());
|
118
|
120
|
}
|
119
|
|
- questions.add(q);//母题
|
|
121
|
+
|
|
122
|
+ if(st == null){
|
|
123
|
+ throw new Exception("未设置题型:"+ s.getSubjectname() + ":"+qvo.getQuestionid());
|
|
124
|
+ }
|
|
125
|
+
|
|
126
|
+ q.setQtypeid(st.getQtypeid());
|
|
127
|
+ q.setQtypename(st.getQtypename());
|
|
128
|
+ questions.add(q);// 母题
|
120
|
129
|
|
121
|
130
|
List<PointVo> pointVoList = qvo.getPoints();
|
122
|
|
- for(PointVo pointVo:pointVoList){
|
|
131
|
+ for (PointVo pointVo : pointVoList) {
|
123
|
132
|
TQuestionPoint tp = new TQuestionPoint();
|
124
|
133
|
tp.setQpid(StudyUtil.getId());
|
125
|
134
|
tp.setQuestionid(qid);
|
|
@@ -129,7 +138,7 @@ public class ZQuestionUpdateService {
|
129
|
138
|
points.add(tp);
|
130
|
139
|
}
|
131
|
140
|
List<DirectorVo> directorVoList = qvo.getDirectors();
|
132
|
|
- for(DirectorVo d : directorVoList){
|
|
141
|
+ for (DirectorVo d : directorVoList) {
|
133
|
142
|
TQuestionDirector td = new TQuestionDirector();
|
134
|
143
|
td.setQdid(StudyUtil.getId());
|
135
|
144
|
td.setQuestionid(qid);
|
|
@@ -141,14 +150,14 @@ public class ZQuestionUpdateService {
|
141
|
150
|
}
|
142
|
151
|
|
143
|
152
|
|
144
|
|
- for(int i=0;i<optionlist.size();i++){
|
|
153
|
+ for (int i = 0; i < optionlist.size(); i++) {
|
145
|
154
|
Map map = optionlist.get(i);
|
146
|
155
|
String sqstem = map.get("sqstem").toString();
|
147
|
156
|
String sqoptions = map.get("sqoptions").toString();
|
148
|
157
|
String sanswer = answerlist.get(i);
|
149
|
158
|
List<String> sanswerlist = new ArrayList<>();
|
150
|
159
|
sanswerlist.add(sanswer);
|
151
|
|
- Double sscore = getDivide(qvo.getScore(),optionlist.size());
|
|
160
|
+ Double sscore = getDivide(qvo.getScore(), optionlist.size());
|
152
|
161
|
|
153
|
162
|
TQuestion sq = new TQuestion();
|
154
|
163
|
sq.setQuestionid(StudyUtil.getId());
|
|
@@ -163,7 +172,7 @@ public class ZQuestionUpdateService {
|
163
|
172
|
sq.setCount(0);
|
164
|
173
|
sq.setQlevel(3);
|
165
|
174
|
sq.setSnum(0);
|
166
|
|
- sq.setSorder(i+1);
|
|
175
|
+ sq.setSorder(i + 1);
|
167
|
176
|
sq.setQstate(1);
|
168
|
177
|
sq.setHashear(0);
|
169
|
178
|
sq.setSource(qvo.getSource());
|
|
@@ -175,24 +184,25 @@ public class ZQuestionUpdateService {
|
175
|
184
|
sq.setBelong(qvo.getBelong());
|
176
|
185
|
sq.setSchoolid(qvo.getSchoolid());
|
177
|
186
|
|
178
|
|
- TSubjectQuestiontype st = tmap.get(1);
|
|
187
|
+ TSubjectQuestiontype st1 = tmap.get(1);
|
179
|
188
|
sq.setCtype(1);
|
180
|
|
- sq.setQtypeid(st.getQtypeid());
|
181
|
|
- sq.setQtypename(st.getQtypename());
|
|
189
|
+ sq.setQtypeid(st1.getQtypeid());
|
|
190
|
+ sq.setQtypename(st1.getQtypename());
|
182
|
191
|
|
183
|
192
|
questions.add(sq);
|
184
|
193
|
}
|
|
194
|
+ questionids.add(qvo.getQuestionid());
|
185
|
195
|
}
|
186
|
196
|
|
187
|
197
|
questionMapper.saveBathQuestion(questions);
|
188
|
198
|
questionDirectorMapper.batchSave(directors);
|
189
|
199
|
questionPointMapper.batchSave(points);
|
|
200
|
+ zQuestionUpdateMapper.updateBatchQuestionState(questionids);
|
190
|
201
|
}
|
191
|
202
|
|
192
|
|
-
|
193
|
203
|
}
|
194
|
204
|
|
195
|
|
- private Double getDivide(Double score,Integer num){
|
|
205
|
+ private Double getDivide(Double score, Integer num) {
|
196
|
206
|
BigDecimal score1 = new BigDecimal(score);
|
197
|
207
|
BigDecimal num1 = new BigDecimal(num);
|
198
|
208
|
BigDecimal divide = score1.divide(num1, 1, BigDecimal.ROUND_FLOOR);
|