Browse Source

模版

wn
王宁 2 months ago
parent
commit
25b656c42b

+ 1
- 1
smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsPaperQtypeQuestionMapper.java View File

23
     int updateBatchQuestionComplexity(@Param("list") List<MsPaperQtypeQuestion> list);
23
     int updateBatchQuestionComplexity(@Param("list") List<MsPaperQtypeQuestion> list);
24
 
24
 
25
     //试卷中所有试题基础信息
25
     //试卷中所有试题基础信息
26
-    List<MsPaperQtypeQuestion> listQuestionsByEpid(@Param("mpid")Integer mpid);
26
+    List<MsPaperQtypeQuestion> listQuestionsByMpid(@Param("mpid")Integer mpid);
27
 
27
 
28
 
28
 
29
 }
29
 }

+ 1
- 1
smarking/src/main/java/com/xhkjedu/smarking/model/paper/MsTemplate.java View File

59
     private Integer createtime;
59
     private Integer createtime;
60
 
60
 
61
     @Transient
61
     @Transient
62
-    private List<MsTemplateBlock> templateblocks;
62
+    private List<MsTemplateBlock> tblocks;
63
 
63
 
64
 }
64
 }

+ 3
- 0
smarking/src/main/java/com/xhkjedu/smarking/model/paper/MsTemplateBlock.java View File

42
 
42
 
43
     @Transient
43
     @Transient
44
     private List<MsTemplateBlockQuestion> tbquestions;
44
     private List<MsTemplateBlockQuestion> tbquestions;
45
+    //排序/首题号
46
+    @Transient
47
+    private Integer blockorder;
45
 }
48
 }

+ 4
- 0
smarking/src/main/java/com/xhkjedu/smarking/model/paper/MsTemplateBlockQuestion.java View File

5
 
5
 
6
 import javax.persistence.Id;
6
 import javax.persistence.Id;
7
 import javax.persistence.Table;
7
 import javax.persistence.Table;
8
+import javax.persistence.Transient;
8
 
9
 
9
 /**
10
 /**
10
  * @Description 阅卷模板题块定客观题表
11
  * @Description 阅卷模板题块定客观题表
23
     private String qn;
24
     private String qn;
24
     //定位坐标
25
     //定位坐标
25
     private String localcoor;
26
     private String localcoor;
27
+
28
+    @Transient
29
+    private Integer bqorder; //题号/合并后名称
26
 }
30
 }

+ 1
- 1
smarking/src/main/java/com/xhkjedu/smarking/service/exam/MsExamService.java View File

238
             msPaperStudentMapper.insertList(studentList);//保存考试学生信息
238
             msPaperStudentMapper.insertList(studentList);//保存考试学生信息
239
 
239
 
240
             //获取试卷中所有试题
240
             //获取试卷中所有试题
241
-            List<MsPaperQtypeQuestion> queslist = msPaperQtypeQuestionMapper.listQuestionsByEpid(epid);
241
+            List<MsPaperQtypeQuestion> queslist = msPaperQtypeQuestionMapper.listQuestionsByMpid(epid);
242
             //获取该还是卷下试题学生信息
242
             //获取该还是卷下试题学生信息
243
             for (MsPaperQtypeQuestion q : queslist) {
243
             for (MsPaperQtypeQuestion q : queslist) {
244
                 Integer eptqid = q.getMptqid();
244
                 Integer eptqid = q.getMptqid();

+ 1
- 1
smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperQtypeService.java View File

720
     private List<MsPaperQtypeQuestion> listChangeQuestionAnswer(List<MsPaperQtypeQuestion> questions,Integer mpid){
720
     private List<MsPaperQtypeQuestion> listChangeQuestionAnswer(List<MsPaperQtypeQuestion> questions,Integer mpid){
721
         List<MsPaperQtypeQuestion> changelist = new ArrayList<>();
721
         List<MsPaperQtypeQuestion> changelist = new ArrayList<>();
722
         //获取试卷中原试题答案
722
         //获取试卷中原试题答案
723
-        List<MsPaperQtypeQuestion> yqlist = msPaperQtypeQuestionMapper.listQuestionsByEpid(mpid);
723
+        List<MsPaperQtypeQuestion> yqlist = msPaperQtypeQuestionMapper.listQuestionsByMpid(mpid);
724
         for(MsPaperQtypeQuestion tq : questions){
724
         for(MsPaperQtypeQuestion tq : questions){
725
             if(N_Utils.isTrueInteger(tq.getMptqid()) && N_Utils.isNotEmpty(tq.getQanswer())){
725
             if(N_Utils.isTrueInteger(tq.getMptqid()) && N_Utils.isNotEmpty(tq.getQanswer())){
726
                 MsPaperQtypeQuestion yq = yqlist.stream().filter(y -> y.getMptqid().equals(tq.getMptqid())).findFirst().orElse(null);
726
                 MsPaperQtypeQuestion yq = yqlist.stream().filter(y -> y.getMptqid().equals(tq.getMptqid())).findFirst().orElse(null);

+ 85
- 6
smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsTemplateService.java View File

2
 
2
 
3
 import com.xhkjedu.smarking.mapper.exam.MsSubjectMapper;
3
 import com.xhkjedu.smarking.mapper.exam.MsSubjectMapper;
4
 import com.xhkjedu.smarking.mapper.paper.*;
4
 import com.xhkjedu.smarking.mapper.paper.*;
5
-import com.xhkjedu.smarking.model.paper.MsTemplate;
5
+import com.xhkjedu.smarking.model.paper.*;
6
 import com.xhkjedu.utils.N_Utils;
6
 import com.xhkjedu.utils.N_Utils;
7
 import org.springframework.stereotype.Service;
7
 import org.springframework.stereotype.Service;
8
 import org.springframework.transaction.annotation.Transactional;
8
 import org.springframework.transaction.annotation.Transactional;
9
 
9
 
10
 import javax.annotation.Resource;
10
 import javax.annotation.Resource;
11
+import java.util.ArrayList;
11
 import java.util.List;
12
 import java.util.List;
12
 import java.util.Map;
13
 import java.util.Map;
14
+import java.util.stream.Collectors;
13
 
15
 
14
 /**
16
 /**
15
  * @Description 阅卷扫描模板表 服务实现类
17
  * @Description 阅卷扫描模板表 服务实现类
25
     @Resource
27
     @Resource
26
     private MsTemplateBlockQuestionMapper msTemplateBlockQuestionMapper;
28
     private MsTemplateBlockQuestionMapper msTemplateBlockQuestionMapper;
27
     @Resource
29
     @Resource
30
+    private MsPaperQtypeQuestionMapper msPaperQtypeQuestionMapper;
31
+    @Resource
32
+    private MsPaperBlockMapper msPaperBlockMapper;
33
+    @Resource
34
+    private MsPaperBlockQuestionMapper msPaperBlockQuestionMapper;
35
+    @Resource
28
     private MsSubjectMapper msSubjectMapper;
36
     private MsSubjectMapper msSubjectMapper;
29
 
37
 
30
     /*
38
     /*
49
     public MsTemplate add(MsTemplate msTemplate){
57
     public MsTemplate add(MsTemplate msTemplate){
50
         msTemplate.setCreatetime(N_Utils.getSecondTimestamp());
58
         msTemplate.setCreatetime(N_Utils.getSecondTimestamp());
51
         msTemplate.setCurrstep(1);
59
         msTemplate.setCurrstep(1);
52
-        msTemplateMapper.insert(msTemplate);
60
+        msTemplateMapper.insertUseGeneratedKeys(msTemplate);
53
         int mtid = msTemplate.getId();
61
         int mtid = msTemplate.getId();
54
         msTemplate.setMtid(mtid);
62
         msTemplate.setMtid(mtid);
55
 
63
 
61
     @Transactional(rollbackFor = Exception.class)
69
     @Transactional(rollbackFor = Exception.class)
62
     public MsTemplate updateTemplate(MsTemplate msTemplate){
70
     public MsTemplate updateTemplate(MsTemplate msTemplate){
63
         msTemplateMapper.updateTemplateForCurrstep(msTemplate);
71
         msTemplateMapper.updateTemplateForCurrstep(msTemplate);
64
-
72
+        Integer mpid = msTemplate.getMpid();
65
         //如果当前保存为6,则需要保存客观题信息
73
         //如果当前保存为6,则需要保存客观题信息
66
         if(msTemplate.getCurrstep() == 6){
74
         if(msTemplate.getCurrstep() == 6){
67
-            //保存题块信息
68
-
69
-            //保存模块板题块信息
75
+            //模版题块信息
76
+            List<MsTemplateBlock> tblocks = msTemplate.getTblocks();
77
+            savePaperBlock(tblocks,msTemplate);
70
         }
78
         }
71
         return msTemplate;
79
         return msTemplate;
72
     }
80
     }
73
 
81
 
82
+    private void savePaperBlock(List<MsTemplateBlock> tblocks,MsTemplate msTemplate){
83
+        Integer mpid = msTemplate.getMpid();
84
+        Integer timestamp = N_Utils.getSecondTimestamp();
85
+        Integer createid = msTemplate.getCreateid();
86
+
87
+        //客观题题块试题信息
88
+        List<MsPaperBlockQuestion> savePbquestions = new ArrayList<>();
89
+        //客观题模块试题信息
90
+        List<MsTemplateBlockQuestion> saveTbquestions = new ArrayList<>();
91
+        //获取试卷中所有试题信息
92
+        List<MsPaperQtypeQuestion> questions = msPaperQtypeQuestionMapper.listQuestionsByMpid(mpid);
93
+        int i = 1;
94
+        for(MsTemplateBlock tblock : tblocks){
95
+            //获取客观题单题
96
+            List<MsTemplateBlockQuestion> tbquestions = tblock.getTbquestions();
97
+            //获取客观题题号
98
+            List<String> tbqns = tbquestions.stream().map(MsTemplateBlockQuestion::getQn).collect(Collectors.toList());
99
+            //包含的试题信息
100
+            List<MsPaperQtypeQuestion> selQuestions = questions.stream().filter(q -> tbqns.contains(q.getQn())).collect(Collectors.toList());
101
+            if(selQuestions == null || selQuestions.size() == 0 || selQuestions.size() != tbquestions.size()){
102
+                throw new RuntimeException("试题信息和试卷不匹配");
103
+            }
104
+
105
+            Double tbqScores = selQuestions.stream().mapToDouble(MsPaperQtypeQuestion::getQscore).sum();//题块下试题总分值
106
+
107
+            //保存试卷题块信息
108
+            MsPaperBlock paperBlock = new MsPaperBlock();
109
+            paperBlock.setMpid(mpid);
110
+            paperBlock.setBlockname("客观题题块" + (i++));
111
+            paperBlock.setBlocktype(1);
112
+            paperBlock.setBlockorder(tblock.getBlockorder());
113
+            paperBlock.setBqnum(tbquestions.size());
114
+            paperBlock.setBqscore(tbqScores);
115
+            paperBlock.setCreateid(createid);
116
+            paperBlock.setCreatetime(timestamp);
117
+            msPaperBlockMapper.insertUseGeneratedKeys(paperBlock);
118
+            Integer mblockid = paperBlock.getId();//题块ID
119
+
120
+            //保存模块题块信息
121
+            tblock.setBlockname(paperBlock.getBlockname());
122
+            tblock.setMttype(1);
123
+            tblock.setMblockid(mblockid);
124
+            tblock.setCreateid(createid);
125
+            tblock.setCreatetime(timestamp);
126
+            msTemplateBlockMapper.insertUseGeneratedKeys(tblock);
127
+            Integer mtbid = tblock.getId();
128
+
129
+            for(MsTemplateBlockQuestion tbquestion : tbquestions) {
130
+                tbquestion.setMtbid(mtbid);
131
+                saveTbquestions.add(tbquestion);
132
+
133
+                MsPaperQtypeQuestion q = selQuestions.stream().filter(q1 -> q1.getQn().equals(tbquestion.getQn())).findFirst().get();
134
+
135
+                MsPaperBlockQuestion pbquestion = new MsPaperBlockQuestion();
136
+                pbquestion.setMblockid(mblockid);
137
+                pbquestion.setMpid(mpid);
138
+                pbquestion.setMbqtype(1);
139
+                pbquestion.setMptqid(q.getMptqid());
140
+                pbquestion.setBqn(tbquestion.getQn());
141
+                pbquestion.setBqscore(q.getQscore());
142
+                pbquestion.setBqorder(tbquestion.getBqorder());
143
+                pbquestion.setCreateid(createid);
144
+                pbquestion.setCreatetime(timestamp);
145
+                savePbquestions.add(pbquestion);
146
+            }
147
+        }
148
+
149
+        msPaperBlockQuestionMapper.insertList(savePbquestions);
150
+        msTemplateBlockQuestionMapper.insertList(saveTbquestions);
151
+    }
152
+
74
 
153
 
75
 }
154
 }

+ 1
- 1
smarking/src/main/resources/mapper/paper/MsPaperQtypeQuestionMapper.xml View File

64
 
64
 
65
     <!--试卷中所有试题基础信息-->
65
     <!--试卷中所有试题基础信息-->
66
     <select id="listQuestionsByEpid" resultType="com.xhkjedu.smarking.model.paper.MsPaperQtypeQuestion">
66
     <select id="listQuestionsByEpid" resultType="com.xhkjedu.smarking.model.paper.MsPaperQtypeQuestion">
67
-        select * from ms_paper_qtype_question where epid=#{epid} order by qorder
67
+        select * from ms_paper_qtype_question where mpid=#{mpid} order by qorder
68
     </select>
68
     </select>
69
 
69
 
70
 
70
 

Loading…
Cancel
Save