|
@@ -8,6 +8,8 @@ import com.xhkjedu.sstudy.mapper.question.ZQuestionUpdateMapper;
|
8
|
8
|
import com.xhkjedu.sstudy.model.question.TQuestion;
|
9
|
9
|
import com.xhkjedu.sstudy.model.question.TQuestionDirector;
|
10
|
10
|
import com.xhkjedu.sstudy.model.question.TQuestionPoint;
|
|
11
|
+import com.xhkjedu.sstudy.model.subjectbook.TSubject;
|
|
12
|
+import com.xhkjedu.sstudy.model.subjectbook.TSubjectQuestiontype;
|
11
|
13
|
import com.xhkjedu.sstudy.utils.StudyUtil;
|
12
|
14
|
import com.xhkjedu.sstudy.vo.question.QuestionVo;
|
13
|
15
|
import com.xhkjedu.sstudy.vo.subjectbook.DirectorVo;
|
|
@@ -17,11 +19,11 @@ import org.springframework.stereotype.Service;
|
17
|
19
|
import org.springframework.transaction.annotation.Transactional;
|
18
|
20
|
|
19
|
21
|
import javax.annotation.Resource;
|
20
|
|
-import java.lang.reflect.Type;
|
21
|
22
|
import java.math.BigDecimal;
|
22
|
23
|
import java.util.ArrayList;
|
23
|
24
|
import java.util.List;
|
24
|
25
|
import java.util.Map;
|
|
26
|
+import java.util.TreeMap;
|
25
|
27
|
|
26
|
28
|
/**
|
27
|
29
|
* @Description
|
|
@@ -47,123 +49,145 @@ public class ZQuestionUpdateService {
|
47
|
49
|
* @Date 2022/8/17 8:52
|
48
|
50
|
**/
|
49
|
51
|
@Transactional(rollbackFor = Exception.class)
|
50
|
|
- public void saveQuestions(){
|
51
|
|
- List<QuestionVo> list = zQuestionUpdateMapper.listQuestions();
|
52
|
|
-
|
53
|
|
- List<TQuestion> questions = new ArrayList<>();
|
54
|
|
- List<TQuestionDirector> directors = new ArrayList<>();
|
55
|
|
- List<TQuestionPoint> points = new ArrayList<>();
|
56
|
|
- int timestamp = N_Utils.getSecondTimestamp();
|
57
|
|
- for(int k=0;k<list.size();k++){
|
58
|
|
-// System.out.println("第几题:"+(k+1));
|
59
|
|
- QuestionVo qvo=list.get(k);
|
60
|
|
- TQuestion q = new TQuestion();
|
61
|
|
- String qid = StudyUtil.getId();
|
62
|
|
-
|
63
|
|
- //处理子题
|
64
|
|
- String qoption = qvo.getQoption();
|
65
|
|
- String qanswer = qvo.getQanswer();
|
66
|
|
- List<Map> optionlist = JSON.parseArray(qoption, Map.class);
|
67
|
|
- List<String> answerlist = JSON.parseArray(qanswer,String.class);
|
68
|
|
-
|
69
|
|
- q.setQuestionid(qid);
|
70
|
|
- q.setQstem(qvo.getQstem());
|
71
|
|
- q.setQstemtxt(qvo.getQstemtxt());
|
72
|
|
- q.setQanalyze(qvo.getQanalyze());
|
73
|
|
- q.setScore(qvo.getScore());
|
74
|
|
- q.setComplexity(qvo.getComplexity());
|
75
|
|
- q.setSubjectid(qvo.getSubjectid());
|
76
|
|
- q.setCount(qvo.getCount());
|
77
|
|
- q.setQlevel(2);
|
78
|
|
- q.setSnum(optionlist.size());
|
79
|
|
- q.setSorder(0);
|
80
|
|
- q.setQstate(1);
|
81
|
|
- q.setSource(qvo.getSource());
|
82
|
|
- q.setYear(qvo.getYear());
|
83
|
|
- q.setRegion(qvo.getRegion());
|
84
|
|
- q.setSchoolname(qvo.getSchoolname());
|
85
|
|
- q.setCreateid(qvo.getCreateid());
|
86
|
|
- q.setCreatetime(timestamp);
|
87
|
|
- q.setBelong(qvo.getBelong());
|
88
|
|
- q.setSchoolid(qvo.getSchoolid());
|
89
|
|
- if(qvo.getCtype() == 7 || qvo.getCtype() == 8 ){
|
90
|
|
- q.setCtype(16);
|
91
|
|
- q.setQtypeid("1QEQRU9B74");
|
92
|
|
- q.setQtypename("完形填空(复合)");
|
93
|
|
- }
|
94
|
|
- if(qvo.getCtype() == 10){
|
95
|
|
- q.setCtype(17);
|
96
|
|
- q.setQtypeid("1QEQRV3BG1");
|
97
|
|
- q.setQtypename("任务型阅读(复合)");
|
98
|
|
- }
|
99
|
|
- questions.add(q);//母题
|
100
|
|
-
|
101
|
|
- List<PointVo> pointVoList = qvo.getPoints();
|
102
|
|
- for(PointVo pointVo:pointVoList){
|
103
|
|
- TQuestionPoint tp = new TQuestionPoint();
|
104
|
|
- tp.setQpid(StudyUtil.getId());
|
105
|
|
- tp.setQuestionid(qid);
|
106
|
|
- tp.setPointid(pointVo.getPointid());
|
107
|
|
- tp.setCreateid(qvo.getCreateid());
|
108
|
|
- tp.setCreatetime(timestamp);
|
109
|
|
- points.add(tp);
|
|
52
|
+ public void saveQuestions() throws Exception{
|
|
53
|
+ //需要处理试题的科目
|
|
54
|
+ List<TSubject> subjects = zQuestionUpdateMapper.listSubjects();
|
|
55
|
+ if(N_Utils.isListEmpty(subjects)){
|
|
56
|
+ throw new Exception("无需要处理试题");
|
|
57
|
+ }
|
|
58
|
+ for(TSubject s : subjects){
|
|
59
|
+ List<TSubjectQuestiontype> qtypelist = zQuestionUpdateMapper.listSubjectQtype(s.getLevel(),s.getSubjectid());
|
|
60
|
+ Map<Integer, TSubjectQuestiontype> tmap = new TreeMap();
|
|
61
|
+ if(N_Utils.isListEmpty(qtypelist)){
|
|
62
|
+ throw new Exception(s.getSubjectname() + "未设置题型");
|
110
|
63
|
}
|
111
|
|
- List<DirectorVo> directorVoList = qvo.getDirectors();
|
112
|
|
- for(DirectorVo d : directorVoList){
|
113
|
|
- TQuestionDirector td = new TQuestionDirector();
|
114
|
|
- td.setQdid(StudyUtil.getId());
|
115
|
|
- td.setQuestionid(qid);
|
116
|
|
- td.setLsbid(d.getLsbid());
|
117
|
|
- td.setDirectorid(d.getDirectorid());
|
118
|
|
- td.setCreateid(qvo.getCreateid());
|
119
|
|
- td.setCreatetime(timestamp);
|
120
|
|
- directors.add(td);
|
|
64
|
+ for(TSubjectQuestiontype t : qtypelist){
|
|
65
|
+ tmap.put(t.getCtype(),t);
|
121
|
66
|
}
|
122
|
67
|
|
|
68
|
+ List<QuestionVo> list = zQuestionUpdateMapper.listQuestions(s.getLevel(),s.getSubjectid());
|
|
69
|
+
|
|
70
|
+ List<TQuestion> questions = new ArrayList<>();
|
|
71
|
+ List<TQuestionDirector> directors = new ArrayList<>();
|
|
72
|
+ List<TQuestionPoint> points = new ArrayList<>();
|
|
73
|
+ int timestamp = N_Utils.getSecondTimestamp();
|
|
74
|
+ for(int k=0;k<list.size();k++){
|
|
75
|
+// System.out.println("第几题:"+(k+1));
|
|
76
|
+ QuestionVo qvo=list.get(k);
|
|
77
|
+ TQuestion q = new TQuestion();
|
|
78
|
+ String qid = StudyUtil.getId();
|
|
79
|
+
|
|
80
|
+ //处理子题
|
|
81
|
+ String qoption = qvo.getQoption();
|
|
82
|
+ String qanswer = qvo.getQanswer();
|
|
83
|
+ List<Map> optionlist = JSON.parseArray(qoption, Map.class);
|
|
84
|
+ List<String> answerlist = JSON.parseArray(qanswer,String.class);
|
|
85
|
+
|
|
86
|
+ q.setQuestionid(qid);
|
|
87
|
+ q.setQstem(qvo.getQstem());
|
|
88
|
+ q.setQstemtxt(qvo.getQstemtxt());
|
|
89
|
+ q.setQanalyze(qvo.getQanalyze());
|
|
90
|
+ q.setScore(qvo.getScore());
|
|
91
|
+ q.setComplexity(qvo.getComplexity());
|
|
92
|
+ q.setSubjectid(qvo.getSubjectid());
|
|
93
|
+ q.setCount(qvo.getCount());
|
|
94
|
+ q.setQlevel(2);
|
|
95
|
+ q.setSnum(optionlist.size());
|
|
96
|
+ q.setSorder(0);
|
|
97
|
+ q.setQstate(1);
|
|
98
|
+ q.setSource(qvo.getSource());
|
|
99
|
+ q.setYear(qvo.getYear());
|
|
100
|
+ q.setRegion(qvo.getRegion());
|
|
101
|
+ q.setSchoolname(qvo.getSchoolname());
|
|
102
|
+ q.setCreateid(qvo.getCreateid());
|
|
103
|
+ q.setCreatetime(timestamp);
|
|
104
|
+ q.setBelong(qvo.getBelong());
|
|
105
|
+ q.setSchoolid(qvo.getSchoolid());
|
|
106
|
+ if(qvo.getCtype() == 7 || qvo.getCtype() == 8 ){
|
|
107
|
+ TSubjectQuestiontype st = tmap.get(16);
|
|
108
|
+ q.setCtype(16);
|
|
109
|
+ q.setQtypeid(st.getQtypeid());
|
|
110
|
+ q.setQtypename(st.getQtypename());
|
|
111
|
+ }
|
|
112
|
+ if(qvo.getCtype() == 10){
|
|
113
|
+ TSubjectQuestiontype st = tmap.get(17);
|
|
114
|
+ q.setCtype(17);
|
|
115
|
+ q.setQtypeid(st.getQtypeid());
|
|
116
|
+ q.setQtypename(st.getQtypename());
|
|
117
|
+ }
|
|
118
|
+ questions.add(q);//母题
|
123
|
119
|
|
124
|
|
- for(int i=0;i<optionlist.size();i++){
|
125
|
|
- Map map = optionlist.get(i);
|
126
|
|
- String sqstem = map.get("sqstem").toString();
|
127
|
|
- String sqoptions = map.get("sqoptions").toString();
|
128
|
|
- String sanswer = answerlist.get(i);
|
129
|
|
- List<String> sanswerlist = new ArrayList<>();
|
130
|
|
- sanswerlist.add(sanswer);
|
131
|
|
- Double sscore = getDivide(qvo.getScore(),optionlist.size());
|
132
|
|
-
|
133
|
|
- TQuestion sq = new TQuestion();
|
134
|
|
- sq.setQuestionid(StudyUtil.getId());
|
135
|
|
- sq.setQuestionpid(qid);
|
136
|
|
- sq.setQstem(sqstem);
|
137
|
|
- sq.setQstemtxt(sqstem);
|
138
|
|
- sq.setQoption(sqoptions);
|
139
|
|
- sq.setQanswer(JSON.toJSONString(sanswerlist));
|
140
|
|
- sq.setScore(sscore);
|
141
|
|
- sq.setComplexity(qvo.getComplexity());
|
142
|
|
- sq.setSubjectid(qvo.getSubjectid());
|
143
|
|
- sq.setCount(0);
|
144
|
|
- sq.setQlevel(3);
|
145
|
|
- sq.setSnum(0);
|
146
|
|
- sq.setSorder(i+1);
|
147
|
|
- sq.setQstate(1);
|
148
|
|
- sq.setSource(qvo.getSource());
|
149
|
|
- sq.setYear(qvo.getYear());
|
150
|
|
- sq.setRegion(qvo.getRegion());
|
151
|
|
- sq.setSchoolname(qvo.getSchoolname());
|
152
|
|
- sq.setCreateid(qvo.getCreateid());
|
153
|
|
- sq.setCreatetime(timestamp);
|
154
|
|
- sq.setBelong(qvo.getBelong());
|
155
|
|
- sq.setSchoolid(qvo.getSchoolid());
|
156
|
|
- sq.setCtype(1);
|
157
|
|
- sq.setQtypeid("1NJCIQ");
|
158
|
|
- sq.setQtypename("单选题");
|
159
|
|
-
|
160
|
|
- questions.add(sq);
|
|
120
|
+ List<PointVo> pointVoList = qvo.getPoints();
|
|
121
|
+ for(PointVo pointVo:pointVoList){
|
|
122
|
+ TQuestionPoint tp = new TQuestionPoint();
|
|
123
|
+ tp.setQpid(StudyUtil.getId());
|
|
124
|
+ tp.setQuestionid(qid);
|
|
125
|
+ tp.setPointid(pointVo.getPointid());
|
|
126
|
+ tp.setCreateid(qvo.getCreateid());
|
|
127
|
+ tp.setCreatetime(timestamp);
|
|
128
|
+ points.add(tp);
|
|
129
|
+ }
|
|
130
|
+ List<DirectorVo> directorVoList = qvo.getDirectors();
|
|
131
|
+ for(DirectorVo d : directorVoList){
|
|
132
|
+ TQuestionDirector td = new TQuestionDirector();
|
|
133
|
+ td.setQdid(StudyUtil.getId());
|
|
134
|
+ td.setQuestionid(qid);
|
|
135
|
+ td.setLsbid(d.getLsbid());
|
|
136
|
+ td.setDirectorid(d.getDirectorid());
|
|
137
|
+ td.setCreateid(qvo.getCreateid());
|
|
138
|
+ td.setCreatetime(timestamp);
|
|
139
|
+ directors.add(td);
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+ for(int i=0;i<optionlist.size();i++){
|
|
144
|
+ Map map = optionlist.get(i);
|
|
145
|
+ String sqstem = map.get("sqstem").toString();
|
|
146
|
+ String sqoptions = map.get("sqoptions").toString();
|
|
147
|
+ String sanswer = answerlist.get(i);
|
|
148
|
+ List<String> sanswerlist = new ArrayList<>();
|
|
149
|
+ sanswerlist.add(sanswer);
|
|
150
|
+ Double sscore = getDivide(qvo.getScore(),optionlist.size());
|
|
151
|
+
|
|
152
|
+ TQuestion sq = new TQuestion();
|
|
153
|
+ sq.setQuestionid(StudyUtil.getId());
|
|
154
|
+ sq.setQuestionpid(qid);
|
|
155
|
+ sq.setQstem(sqstem);
|
|
156
|
+ sq.setQstemtxt(sqstem);
|
|
157
|
+ sq.setQoption(sqoptions);
|
|
158
|
+ sq.setQanswer(JSON.toJSONString(sanswerlist));
|
|
159
|
+ sq.setScore(sscore);
|
|
160
|
+ sq.setComplexity(qvo.getComplexity());
|
|
161
|
+ sq.setSubjectid(qvo.getSubjectid());
|
|
162
|
+ sq.setCount(0);
|
|
163
|
+ sq.setQlevel(3);
|
|
164
|
+ sq.setSnum(0);
|
|
165
|
+ sq.setSorder(i+1);
|
|
166
|
+ sq.setQstate(1);
|
|
167
|
+ sq.setSource(qvo.getSource());
|
|
168
|
+ sq.setYear(qvo.getYear());
|
|
169
|
+ sq.setRegion(qvo.getRegion());
|
|
170
|
+ sq.setSchoolname(qvo.getSchoolname());
|
|
171
|
+ sq.setCreateid(qvo.getCreateid());
|
|
172
|
+ sq.setCreatetime(timestamp);
|
|
173
|
+ sq.setBelong(qvo.getBelong());
|
|
174
|
+ sq.setSchoolid(qvo.getSchoolid());
|
|
175
|
+
|
|
176
|
+ TSubjectQuestiontype st = tmap.get(1);
|
|
177
|
+ sq.setCtype(1);
|
|
178
|
+ sq.setQtypeid(st.getQtypeid());
|
|
179
|
+ sq.setQtypename(st.getQtypename());
|
|
180
|
+
|
|
181
|
+ questions.add(sq);
|
|
182
|
+ }
|
161
|
183
|
}
|
|
184
|
+
|
|
185
|
+ questionMapper.saveBathQuestion(questions);
|
|
186
|
+ questionDirectorMapper.batchSave(directors);
|
|
187
|
+ questionPointMapper.batchSave(points);
|
162
|
188
|
}
|
163
|
|
-
|
164
|
|
- questionMapper.saveBathQuestion(questions);
|
165
|
|
- questionDirectorMapper.batchSave(directors);
|
166
|
|
- questionPointMapper.batchSave(points);
|
|
189
|
+
|
|
190
|
+
|
167
|
191
|
}
|
168
|
192
|
|
169
|
193
|
private Double getDivide(Double score,Integer num){
|