|
@@ -0,0 +1,175 @@
|
|
1
|
+package com.xhkjedu.sstudy.service.question;
|
|
2
|
+
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
|
4
|
+import com.xhkjedu.sstudy.mapper.question.QuestionDirectorMapper;
|
|
5
|
+import com.xhkjedu.sstudy.mapper.question.QuestionMapper;
|
|
6
|
+import com.xhkjedu.sstudy.mapper.question.QuestionPointMapper;
|
|
7
|
+import com.xhkjedu.sstudy.mapper.question.ZQuestionUpdateMapper;
|
|
8
|
+import com.xhkjedu.sstudy.model.question.TQuestion;
|
|
9
|
+import com.xhkjedu.sstudy.model.question.TQuestionDirector;
|
|
10
|
+import com.xhkjedu.sstudy.model.question.TQuestionPoint;
|
|
11
|
+import com.xhkjedu.sstudy.utils.StudyUtil;
|
|
12
|
+import com.xhkjedu.sstudy.vo.question.QuestionVo;
|
|
13
|
+import com.xhkjedu.sstudy.vo.subjectbook.DirectorVo;
|
|
14
|
+import com.xhkjedu.sstudy.vo.subjectbook.PointVo;
|
|
15
|
+import com.xhkjedu.utils.N_Utils;
|
|
16
|
+import org.springframework.stereotype.Service;
|
|
17
|
+import org.springframework.transaction.annotation.Transactional;
|
|
18
|
+
|
|
19
|
+import javax.annotation.Resource;
|
|
20
|
+import java.lang.reflect.Type;
|
|
21
|
+import java.math.BigDecimal;
|
|
22
|
+import java.util.ArrayList;
|
|
23
|
+import java.util.List;
|
|
24
|
+import java.util.Map;
|
|
25
|
+
|
|
26
|
+/**
|
|
27
|
+ * @Description
|
|
28
|
+ * @Author WN
|
|
29
|
+ * Date 2022/8/16 16:50
|
|
30
|
+ **/
|
|
31
|
+@Service
|
|
32
|
+public class ZQuestionUpdateService {
|
|
33
|
+ @Resource
|
|
34
|
+ private ZQuestionUpdateMapper zQuestionUpdateMapper;
|
|
35
|
+ @Resource
|
|
36
|
+ private QuestionMapper questionMapper;
|
|
37
|
+ @Resource
|
|
38
|
+ private QuestionDirectorMapper questionDirectorMapper;
|
|
39
|
+ @Resource
|
|
40
|
+ private QuestionPointMapper questionPointMapper;
|
|
41
|
+
|
|
42
|
+ /**
|
|
43
|
+ * @Description 处理万幸填空阅读理解
|
|
44
|
+ * @Param []
|
|
45
|
+ * @Return void
|
|
46
|
+ * @Author wn
|
|
47
|
+ * @Date 2022/8/17 8:52
|
|
48
|
+ **/
|
|
49
|
+ @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);
|
|
110
|
+ }
|
|
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);
|
|
121
|
+ }
|
|
122
|
+
|
|
123
|
+
|
|
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);
|
|
161
|
+ }
|
|
162
|
+ }
|
|
163
|
+
|
|
164
|
+ questionMapper.saveBathQuestion(questions);
|
|
165
|
+ questionDirectorMapper.batchSave(directors);
|
|
166
|
+ questionPointMapper.batchSave(points);
|
|
167
|
+ }
|
|
168
|
+
|
|
169
|
+ private Double getDivide(Double score,Integer num){
|
|
170
|
+ BigDecimal score1 = new BigDecimal(score);
|
|
171
|
+ BigDecimal num1 = new BigDecimal(num);
|
|
172
|
+ BigDecimal divide = score1.divide(num1, 1, BigDecimal.ROUND_FLOOR);
|
|
173
|
+ return divide.doubleValue();
|
|
174
|
+ }
|
|
175
|
+}
|