浏览代码

模版

wn
王宁 2 个月前
父节点
当前提交
25b656c42b

+ 1
- 1
smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsPaperQtypeQuestionMapper.java 查看文件

@@ -23,7 +23,7 @@ public interface MsPaperQtypeQuestionMapper extends TkMapper<MsPaperQtypeQuestio
23 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 查看文件

@@ -59,6 +59,6 @@ public class MsTemplate extends BaseBean {
59 59
     private Integer createtime;
60 60
 
61 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 查看文件

@@ -42,4 +42,7 @@ public class MsTemplateBlock extends BaseBean {
42 42
 
43 43
     @Transient
44 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 查看文件

@@ -5,6 +5,7 @@ import lombok.Data;
5 5
 
6 6
 import javax.persistence.Id;
7 7
 import javax.persistence.Table;
8
+import javax.persistence.Transient;
8 9
 
9 10
 /**
10 11
  * @Description 阅卷模板题块定客观题表
@@ -23,4 +24,7 @@ public class MsTemplateBlockQuestion extends BaseBean {
23 24
     private String qn;
24 25
     //定位坐标
25 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 查看文件

@@ -238,7 +238,7 @@ public class MsExamService {
238 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 243
             for (MsPaperQtypeQuestion q : queslist) {
244 244
                 Integer eptqid = q.getMptqid();

+ 1
- 1
smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperQtypeService.java 查看文件

@@ -720,7 +720,7 @@ public class MsPaperQtypeService {
720 720
     private List<MsPaperQtypeQuestion> listChangeQuestionAnswer(List<MsPaperQtypeQuestion> questions,Integer mpid){
721 721
         List<MsPaperQtypeQuestion> changelist = new ArrayList<>();
722 722
         //获取试卷中原试题答案
723
-        List<MsPaperQtypeQuestion> yqlist = msPaperQtypeQuestionMapper.listQuestionsByEpid(mpid);
723
+        List<MsPaperQtypeQuestion> yqlist = msPaperQtypeQuestionMapper.listQuestionsByMpid(mpid);
724 724
         for(MsPaperQtypeQuestion tq : questions){
725 725
             if(N_Utils.isTrueInteger(tq.getMptqid()) && N_Utils.isNotEmpty(tq.getQanswer())){
726 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 查看文件

@@ -2,14 +2,16 @@ package com.xhkjedu.smarking.service.paper;
2 2
 
3 3
 import com.xhkjedu.smarking.mapper.exam.MsSubjectMapper;
4 4
 import com.xhkjedu.smarking.mapper.paper.*;
5
-import com.xhkjedu.smarking.model.paper.MsTemplate;
5
+import com.xhkjedu.smarking.model.paper.*;
6 6
 import com.xhkjedu.utils.N_Utils;
7 7
 import org.springframework.stereotype.Service;
8 8
 import org.springframework.transaction.annotation.Transactional;
9 9
 
10 10
 import javax.annotation.Resource;
11
+import java.util.ArrayList;
11 12
 import java.util.List;
12 13
 import java.util.Map;
14
+import java.util.stream.Collectors;
13 15
 
14 16
 /**
15 17
  * @Description 阅卷扫描模板表 服务实现类
@@ -25,6 +27,12 @@ public class MsTemplateService {
25 27
     @Resource
26 28
     private MsTemplateBlockQuestionMapper msTemplateBlockQuestionMapper;
27 29
     @Resource
30
+    private MsPaperQtypeQuestionMapper msPaperQtypeQuestionMapper;
31
+    @Resource
32
+    private MsPaperBlockMapper msPaperBlockMapper;
33
+    @Resource
34
+    private MsPaperBlockQuestionMapper msPaperBlockQuestionMapper;
35
+    @Resource
28 36
     private MsSubjectMapper msSubjectMapper;
29 37
 
30 38
     /*
@@ -49,7 +57,7 @@ public class MsTemplateService {
49 57
     public MsTemplate add(MsTemplate msTemplate){
50 58
         msTemplate.setCreatetime(N_Utils.getSecondTimestamp());
51 59
         msTemplate.setCurrstep(1);
52
-        msTemplateMapper.insert(msTemplate);
60
+        msTemplateMapper.insertUseGeneratedKeys(msTemplate);
53 61
         int mtid = msTemplate.getId();
54 62
         msTemplate.setMtid(mtid);
55 63
 
@@ -61,15 +69,86 @@ public class MsTemplateService {
61 69
     @Transactional(rollbackFor = Exception.class)
62 70
     public MsTemplate updateTemplate(MsTemplate msTemplate){
63 71
         msTemplateMapper.updateTemplateForCurrstep(msTemplate);
64
-
72
+        Integer mpid = msTemplate.getMpid();
65 73
         //如果当前保存为6,则需要保存客观题信息
66 74
         if(msTemplate.getCurrstep() == 6){
67
-            //保存题块信息
68
-
69
-            //保存模块板题块信息
75
+            //模版题块信息
76
+            List<MsTemplateBlock> tblocks = msTemplate.getTblocks();
77
+            savePaperBlock(tblocks,msTemplate);
70 78
         }
71 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 查看文件

@@ -64,7 +64,7 @@
64 64
 
65 65
     <!--试卷中所有试题基础信息-->
66 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 68
     </select>
69 69
 
70 70
 

正在加载...
取消
保存