Browse Source

学科素养

ywx
王宁 1 week ago
parent
commit
d1c2e95c4b
17 changed files with 1021 additions and 665 deletions
  1. 40
    1
      smarking/src/main/java/com/xhkjedu/smarking/controller/report/XksyReportController.java
  2. 2
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportclass/MsrClassQuestionMapper.java
  3. 12
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportsubject/MsrSubjectPointMapper.java
  4. 8
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportsubject/MsrSubjectPointRankgroupMapper.java
  5. 8
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportsubject/MsrSubjectPointSectionMapper.java
  6. 9
    0
      smarking/src/main/java/com/xhkjedu/smarking/model/report/reportsubject/MsrSubjectPoint.java
  7. 678
    0
      smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperAnalyzeService.java
  8. 15
    651
      smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperQtypeService.java
  9. 42
    0
      smarking/src/main/java/com/xhkjedu/smarking/service/report/generate/ReportGeneratePointService.java
  10. 121
    7
      smarking/src/main/java/com/xhkjedu/smarking/service/report/report/MsrSubjectPointService.java
  11. 5
    5
      smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java
  12. 6
    0
      smarking/src/main/java/com/xhkjedu/smarking/vo/report/reportother/ExamReportParams.java
  13. 1
    1
      smarking/src/main/resources/mapper/paper/MsTemplateMapper.xml
  14. 9
    0
      smarking/src/main/resources/mapper/report/reportclass/MsrClassQuestionMapper.xml
  15. 53
    0
      smarking/src/main/resources/mapper/report/reportsubject/MsrSubjectPointMapper.xml
  16. 6
    0
      smarking/src/main/resources/mapper/report/reportsubject/MsrSubjectPointRankgroupMapper.xml
  17. 6
    0
      smarking/src/main/resources/mapper/report/reportsubject/MsrSubjectPointSectionMapper.xml

+ 40
- 1
smarking/src/main/java/com/xhkjedu/smarking/controller/report/XksyReportController.java View File

@@ -22,6 +22,19 @@ public class XksyReportController {
22 22
     @Resource
23 23
     private MsrSubjectPointService msrSubjectPointService;
24 24
 
25
+    /*
26
+     * @Description 标定知识点-试题知识点
27
+     * @Date 2025/1/2 16:34:45
28
+     * @Author WN
29
+     * @Param [params]
30
+     * @Return com.xhkjedu.vo.ResultVo
31
+     **/
32
+    @PostMapping("/zsd")
33
+    public ResultVo listXksyQuestionPoints(@RequestBody ExamReportParams params){
34
+        N_Utils.validation(new Object[]{params.getExamid(),"考试id",1,params.getSubjectid(),"科目id",2});
35
+        return new ResultVo(0,"获取成功",msrSubjectPointService.listXksyQuestionPoints(params));
36
+    }
37
+
25 38
     /*
26 39
      * @Description 知识点整体分析
27 40
      * @Date 2024/12/31 16:46:51
@@ -29,9 +42,35 @@ public class XksyReportController {
29 42
      * @Param [params]
30 43
      * @Return com.xhkjedu.vo.ResultVo
31 44
      **/
32
-    @PostMapping("/zstzt")
45
+    @PostMapping("/zsd_zt")
33 46
     public ResultVo listXksyPointZt(@RequestBody ExamReportParams params){
34 47
         N_Utils.validation(new Object[]{params.getExamid(),"考试id",1,params.getSubjectid(),"科目id",2,params.getPointlevel(),"知识点层级",1});
35 48
         return new ResultVo(0,"获取成功",msrSubjectPointService.listXksyPointZt(params));
36 49
     }
50
+
51
+    /*
52
+     * @Description 单个知识点分析-所有知识点
53
+     * @Date 2025/1/2 9:18:13
54
+     * @Author WN
55
+     * @Param [params]
56
+     * @Return com.xhkjedu.vo.ResultVo
57
+     **/
58
+    @PostMapping("/zsd_one_all")
59
+    public ResultVo listXksyPointOneForPoints(@RequestBody ExamReportParams params){
60
+        N_Utils.validation(new Object[]{params.getExamid(),"考试id",1,params.getSubjectid(),"科目id",2});
61
+        return new ResultVo(0,"获取成功",msrSubjectPointService.listXksyPointOneForPoints(params));
62
+    }
63
+
64
+    /*
65
+     * @Description 单个知识点分析-详细分析
66
+     * @Date 2025/1/2 15:36:20
67
+     * @Author WN
68
+     * @Param [params]
69
+     * @Return com.xhkjedu.vo.ResultVo
70
+     **/
71
+    @PostMapping("/zsd_one_xq")
72
+    public ResultVo listXksyPointOneForPointDetail(@RequestBody ExamReportParams params){
73
+        N_Utils.validation(new Object[]{params.getExamid(),"考试id",1,params.getSubjectid(),"科目id",2, params.getPointlevel(),"知识点级别",1,params.getPointid(),"知识点id",1});
74
+        return new ResultVo(0,"获取成功",msrSubjectPointService.listXksyPointOneForPointDetail(params));
75
+    }
37 76
 }

+ 2
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportclass/MsrClassQuestionMapper.java View File

@@ -38,4 +38,6 @@ public interface MsrClassQuestionMapper extends TkMapper<MsrClassQuestion> {
38 38
     List<Map<String,Object>> listQuestionsFroMtzlSt(@Param("param") ExamReportParams param);
39 39
     //命题质量-试题分析-单试题常用分析指标
40 40
     Map<String,Object> listQuestionByMptqidForMtzlSt(@Param("param") ExamReportParams param);
41
+    //学科素养-单个知识点分析-知识点下试题
42
+    List<Map<String,Object>> listQuestionsForXksyOnePoint(@Param("param") ExamReportParams param);
41 43
 }

+ 12
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportsubject/MsrSubjectPointMapper.java View File

@@ -7,6 +7,7 @@ import com.xhkjedu.smarking.vo.report.reportsubject.PointVo;
7 7
 import org.apache.ibatis.annotations.Param;
8 8
 
9 9
 import java.util.List;
10
+import java.util.Map;
10 11
 
11 12
 /**
12 13
  * @Description 阅卷报告-学科知识点表 Mapper 接口
@@ -17,7 +18,18 @@ public interface MsrSubjectPointMapper extends TkMapper<MsrSubjectPoint> {
17 18
 
18 19
     //科目知识点
19 20
     List<PointVo> listSubjectPoints(@Param("subjectid") String subjectid, @Param("examid") Integer examid);
21
+    //学科素养-标定知识点-试题知识点
22
+    List<Map<String,Object>> listQuestionPointsForXhsy(@Param("param")ExamReportParams param);
20 23
 
21 24
     //学科素养-知识点整体分析-级别下知识点
22 25
     List<MsrSubjectPoint> listXksyPointsZt(@Param("param")ExamReportParams param);
26
+    //学科素养-单个知识点分析-所有知识点
27
+    List<Map<String,Object>> listXksyPointsAll(@Param("param")ExamReportParams param);
28
+    //学科素养-单个知识点分析-知识点详情
29
+    MsrSubjectPoint getXksyPointByPointid(@Param("param")ExamReportParams param);
30
+    //学科素养-单个知识点分析-各班知识点对比
31
+    List<Map<String,Object>> listXksyPointsForAllClass(@Param("param")ExamReportParams param);
32
+
33
+    //删除知识点相关报告
34
+    void deletePointAnalyze(@Param("examid") Integer examid,@Param("subjectid") String subjectid);
23 35
 }

+ 8
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportsubject/MsrSubjectPointRankgroupMapper.java View File

@@ -2,6 +2,11 @@ package com.xhkjedu.smarking.mapper.report.reportsubject;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectPointRankgroup;
5
+import com.xhkjedu.smarking.vo.report.reportother.ExamReportParams;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+import java.util.Map;
5 10
 
6 11
 /**
7 12
  * @Description 阅卷报告-学科知识点分段区间表 Mapper 接口
@@ -9,4 +14,7 @@ import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectPointRankgroup;
9 14
  * @Date 2024-12-09
10 15
  */
11 16
 public interface MsrSubjectPointRankgroupMapper extends TkMapper<MsrSubjectPointRankgroup> {
17
+
18
+    //学科素养-单个知识点分析-知识点考试分组分析
19
+    List<Map<String,Object>> listXksyPointOneRankgroup(@Param("param")ExamReportParams param);
12 20
 }

+ 8
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportsubject/MsrSubjectPointSectionMapper.java View File

@@ -2,6 +2,11 @@ package com.xhkjedu.smarking.mapper.report.reportsubject;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectPointSection;
5
+import com.xhkjedu.smarking.vo.report.reportother.ExamReportParams;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+import java.util.Map;
5 10
 
6 11
 /**
7 12
  * @Description 阅卷报告-学科知识点分段区间表 Mapper 接口
@@ -9,4 +14,7 @@ import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectPointSection;
9 14
  * @Date 2024-12-09
10 15
  */
11 16
 public interface MsrSubjectPointSectionMapper extends TkMapper<MsrSubjectPointSection> {
17
+
18
+    //学科素养-单个知识点分析-知识点与总分的相关性曲线
19
+    List<Map<String, Object>> listXhsySections(@Param("param")ExamReportParams param);
12 20
 }

+ 9
- 0
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportsubject/MsrSubjectPoint.java View File

@@ -55,4 +55,13 @@ public class MsrSubjectPoint extends BaseBean {
55 55
     private String mptqids;
56 56
     //对应题目
57 57
     private String qns;
58
+
59
+    //满分人数
60
+    private Integer mfnum;
61
+    //满分人ids
62
+    private String mfids;
63
+    //零分人数
64
+    private Integer lfnum;
65
+    //零分人ids
66
+    private String lfids;
58 67
 }

+ 678
- 0
smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperAnalyzeService.java View File

@@ -0,0 +1,678 @@
1
+package com.xhkjedu.smarking.service.paper;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.xhkjedu.smarking.mapper.paper.MsPaperAnalyzeMapper;
5
+import com.xhkjedu.smarking.mapper.paper.MsPaperQtypeMapper;
6
+import com.xhkjedu.smarking.mapper.paper.MsPaperQtypeQuestionMapper;
7
+import com.xhkjedu.smarking.mapper.paper.MsPaperQtypeQuestionPointMapper;
8
+import com.xhkjedu.smarking.model.paper.MsPaper;
9
+import com.xhkjedu.smarking.model.paper.MsPaperAnalyze;
10
+import com.xhkjedu.smarking.model.paper.MsPaperQtypeQuestion;
11
+import com.xhkjedu.smarking.model.paper.MsPaperQtypeQuestionPoint;
12
+import com.xhkjedu.smarking.vo.paper.*;
13
+import com.xhkjedu.utils.N_Utils;
14
+import org.springframework.stereotype.Service;
15
+
16
+import javax.annotation.Resource;
17
+import java.util.*;
18
+import java.util.stream.Collectors;
19
+
20
+/**
21
+ * @Description:试卷分析
22
+ * @Author: WN
23
+ * @Date: 2025/1/2 17:01:04
24
+ **/
25
+@Service
26
+public class MsPaperAnalyzeService {
27
+    @Resource
28
+    private MsPaperQtypeMapper msPaperQtypeMapper;
29
+    @Resource
30
+    private MsPaperQtypeQuestionMapper msPaperQtypeQuestionMapper;
31
+    @Resource
32
+    private MsPaperQtypeQuestionPointMapper msPaperQtypeQuestionPointMapper;
33
+    @Resource
34
+    private MsPaperAnalyzeMapper msPaperAnalyzeMapper;
35
+
36
+    // 保存试卷分析--题库
37
+    public void savePaperAnalyzeForQuestion(MsPaper paper) {
38
+        Integer mpid = paper.getMpid();
39
+
40
+        // 总体分析(主观题、客观题)
41
+        List<MsPaperQtypeVo> qtypelist = msPaperQtypeMapper.listPaperQtypeQuestions(paper.getMpid());// 试卷题型试题信息
42
+        List<MsPaperQtypeQuestion> uplist = new ArrayList<>();// 改试卷中客观题选项数量
43
+        List<MsPaperQtypeQuestion> upComplexitylist = new ArrayList<>();// 改试卷中客观题难易度
44
+        List<MsPaperQtypeQuestionPoint> upQpointlist = new ArrayList<>();// 保存试卷中试题知识点关联关系
45
+
46
+        List<QuestionOrderVo> pointqlist = new ArrayList<>();// 用于存放知识点,以及知识点下得分
47
+        List<MsPaperQtypeQuestionVo> mquestions = new ArrayList<>();// 存放单题和母题
48
+        List<QuestionOrderVo> complexitylist = new ArrayList<>();// 试题难易度存放试题
49
+        List<QuestionPointVo> quesplist = new ArrayList<>();// 单题、母题对应知识点
50
+
51
+        // 处理出试卷中所有试题、知识点
52
+        List<Map<String, Object>> typelist = new ArrayList<>();// 题型分析
53
+        for (MsPaperQtypeVo qt : qtypelist) {
54
+            List<Integer> qorderlist = new ArrayList<>();
55
+            List<QuestionOrderVo> qtypeqlist = new ArrayList<>();
56
+            List<MsPaperQtypeQuestionVo> tqlist = qt.getQuestions();
57
+            int hasmt = 0;
58
+            for (MsPaperQtypeQuestionVo q : tqlist) {
59
+                int ctype = q.getCtype();
60
+                // 单题的pid设置为默认值,方便后续进行单题和母题处理
61
+                if (q.getQlevel() == 1) {
62
+                    q.setQuestionpid("000");
63
+                    // 判断试题是否是客观题
64
+                    if (N_Utils.isObjectiveQuestion(ctype)) {
65
+                        // 判断试题是否是客观题,暂时用mctype进行标识
66
+                        q.setMctype(111);
67
+                    } else {
68
+                        q.setMctype(112);
69
+                    }
70
+                    // 设置知识点
71
+                    mquestions.add(q);
72
+                    // 获取试题知识点
73
+                    List<Map<String, Object>> qpoints = q.getPoints();
74
+                    // 处理试题知识点占分
75
+                    setPaperQuestionPointScore(pointqlist, quesplist, qpoints, q, null, null);
76
+                    setPaperQuestionPointRelation(qpoints, q, null, upQpointlist, mpid);
77
+                    setPaperQuestionQtypeScore(qtypeqlist, q, null, null);// 处理试题题型
78
+                    setPaperQuestionComplexityScore(complexitylist, q, null, null, upComplexitylist);// 处理试题难易度
79
+
80
+                }
81
+                if (q.getQlevel() == 3) {
82
+                    hasmt++;
83
+                }
84
+                if (!qorderlist.contains(q.getQorder())) {
85
+                    qorderlist.add(q.getQorder());
86
+                }
87
+                // 为了处理客观题中选项数量
88
+                if (ctype == 1 || ctype == 2 || ctype == 4 || ctype == 5 || ctype == 6) {
89
+                    List<String> strlst = JSON.parseArray(q.getQoption(), String.class);
90
+                    MsPaperQtypeQuestion eqq = new MsPaperQtypeQuestion();
91
+                    eqq.setMptqid(q.getMptqid());
92
+                    eqq.setOptionnum(strlst.size());
93
+                    uplist.add(eqq);
94
+                }
95
+            }
96
+
97
+            if (hasmt > 0) {
98
+                // 说明该题型下有复合题,复合体进行知识点、题型下试题题号及id进行操作
99
+                LinkedHashMap<String, List<MsPaperQtypeQuestionVo>> quesMap = tqlist.stream().collect(Collectors.groupingBy(MsPaperQtypeQuestionVo::getQuestionpid,
100
+                                                                                                                            LinkedHashMap::new, Collectors.toList()));
101
+                for (Map.Entry<String, List<MsPaperQtypeQuestionVo>> entry : quesMap.entrySet()) {
102
+                    if (!entry.getKey().equals("000")) {
103
+                        // 说明该题为母题,
104
+                        MsPaperQtypeQuestionVo mq = new MsPaperQtypeQuestionVo();
105
+                        List<MsPaperQtypeQuestionVo> sonques = entry.getValue();
106
+                        int k = 0;// 如果k大于1说明有小题是主观题,则母题为主观题
107
+                        double score = 0;
108
+                        for (MsPaperQtypeQuestionVo sq : sonques) {
109
+                            if (!N_Utils.isObjectiveQuestion(sq.getCtype())) {
110
+                                k++;
111
+                            }
112
+                            score = N_Utils.getDoubleSum(score, sq.getQscore());
113
+                        }
114
+
115
+                        MsPaperQtypeQuestionVo qobj = sonques.get(0);
116
+                        mq.setQuestionid(qobj.getQuestionpid());
117
+                        mq.setComplexity(qobj.getMcomplexity());
118
+                        mq.setQorder(qobj.getQorder());
119
+                        mq.setQscore(score);
120
+                        mq.setQtypename(qobj.getMqtypename());
121
+                        if (k == 0) {
122
+                            mq.setMctype(111);
123
+                        } else {
124
+                            mq.setMctype(112);
125
+                        }
126
+                        mq.setQlevel(qobj.getMqlevel());
127
+                        mq.setSonques(sonques);
128
+                        // 获取所有子题的试题题号
129
+                        String[] qnstr = sonques.stream().map(MsPaperQtypeQuestionVo::getQn).toArray(String[]::new);
130
+                        // 所有子题的试题eptqid
131
+                        List<Integer> eptqids = sonques.stream().map(MsPaperQtypeQuestionVo::getMptqid).collect(Collectors.toList());
132
+                        Integer[] eptqidstr = eptqids.toArray(new Integer[0]);
133
+
134
+                        // 获取知识点
135
+                        List<Map<String, Object>> qpoints = sonques.get(0).getPoints();
136
+                        mq.setPoints(qpoints);
137
+                        mquestions.add(mq);
138
+                        setPaperQuestionPointScore(pointqlist, quesplist, qpoints, mq, qnstr, eptqids);
139
+                        setPaperQuestionPointRelation(qpoints, mq, eptqids, upQpointlist, mpid);
140
+                        setPaperQuestionQtypeScore(qtypeqlist, mq, qnstr, eptqidstr);// 处理试题题型
141
+                        setPaperQuestionComplexityScore(complexitylist, mq, qnstr, eptqidstr, upComplexitylist);// 处理试题难易度
142
+                    }
143
+                }
144
+            }
145
+
146
+            // 试题题型分析数据
147
+            double storerate = N_Utils.getDoubleDivideAndMulitiply(qt.getMptscore(), paper.getPscore());
148
+            Map<String, Object> tmap = new TreeMap<>();
149
+            tmap.put("qtid", qt.getMptid());
150
+            tmap.put("qtname", qt.getMptname());
151
+            tmap.put("num", qt.getMptnum());
152
+            tmap.put("score", qt.getMptscore());
153
+            tmap.put("srate", storerate);
154
+            qtypeqlist = qtypeqlist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList());
155
+            tmap.put("ques", qtypeqlist);
156
+            typelist.add(tmap);
157
+        }
158
+
159
+        // 进行客观题选项处理
160
+        if (N_Utils.isListNotEmpty(uplist)) {
161
+            msPaperQtypeQuestionMapper.updateBatchQuestionOptionnum(uplist);
162
+        }
163
+
164
+        // 试题总体分布进行分析
165
+        // 客观题集合
166
+        List<MsPaperQtypeQuestionVo> ktlst = mquestions.stream().filter(q -> q.getMctype() == 111).collect(Collectors.toList());
167
+        int ktnum = ktlst.size();
168
+        double ktscore = ktlst.stream().mapToDouble(MsPaperQtypeQuestionVo::getQscore).sum();
169
+        double ktnrate = N_Utils.getIntegerDivideAndMulitiply(ktnum, paper.getPnum());
170
+        double ktsrate = N_Utils.getDoubleDivideAndMulitiply(ktscore, paper.getPscore());
171
+        List<MsPaperQsVo> ranglist = new ArrayList<>();
172
+        ranglist.add(new MsPaperQsVo("客观题", ktscore, ktnum, ktsrate, ktnrate));
173
+        MsPaperQsVo zgq = new MsPaperQsVo();
174
+        zgq.setQtname("主观题");
175
+        zgq.setNum(paper.getPnum() - ktnum);
176
+        zgq.setNrate(N_Utils.getDoubleReduce(100.0, ktnrate));
177
+        zgq.setScore(N_Utils.getDoubleReduce(paper.getPscore(), ktscore));
178
+        zgq.setSrate(N_Utils.getDoubleReduce(100.0, ktsrate));
179
+        ranglist.add(zgq);
180
+        Map<String, Object> ztmap = new TreeMap<>();
181
+        ztmap.put("pnum", paper.getPnum());
182
+        ztmap.put("pscore", paper.getPscore());
183
+        ztmap.put("ranglist", ranglist);
184
+
185
+        // 设置试卷中试题难易度
186
+        msPaperQtypeQuestionMapper.updateBatchQuestionComplexity(upComplexitylist);
187
+
188
+        // 难易度
189
+        List<Map<String, Object>> clist = new ArrayList<>();
190
+        if (N_Utils.isListNotEmpty(complexitylist)) {
191
+            Map<String, List<QuestionOrderVo>> complxmap = complexitylist.stream().collect(Collectors.groupingBy(QuestionOrderVo::getId, Collectors.toList()));
192
+            for (Map.Entry<String, List<QuestionOrderVo>> entry : complxmap.entrySet()) {
193
+                List<QuestionOrderVo> pgblist = entry.getValue();
194
+                Double score = pgblist.stream().mapToDouble(QuestionOrderVo::getScore).sum();
195
+                score = N_Utils.formatDouble(score, 1);
196
+                Double srate = N_Utils.getDoubleDivideAndMulitiply(score, paper.getPscore());
197
+                Map<String, Object> prate = new TreeMap<>();
198
+                prate.put("level", Integer.parseInt(entry.getKey()));
199
+                prate.put("score", score);
200
+                prate.put("srate", srate);
201
+                prate.put("ques", pgblist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList()));
202
+                clist.add(prate);
203
+            }
204
+        }
205
+
206
+        // 保存试卷试题知识点关系
207
+        msPaperQtypeQuestionPointMapper.deleteByMpid(mpid);
208
+        msPaperQtypeQuestionPointMapper.insertList(upQpointlist);
209
+
210
+        // 知识点分析
211
+        List<Map<String, Object>> pointlist = new ArrayList<>();
212
+        if (N_Utils.isListNotEmpty(pointqlist)) {
213
+            LinkedHashMap<String, List<QuestionOrderVo>> pointmap = pointqlist.stream().collect(Collectors.groupingBy(QuestionOrderVo::getId, LinkedHashMap::new,
214
+                                                                                                                      Collectors.toList()));
215
+            // 根据指示进行分组,
216
+            for (Map.Entry<String, List<QuestionOrderVo>> entry : pointmap.entrySet()) {
217
+                List<QuestionOrderVo> pgblist = entry.getValue();
218
+                // 获取知识点的总分
219
+                Double score = pgblist.stream().mapToDouble(QuestionOrderVo::getScore).sum();
220
+                score = N_Utils.formatDouble(score, 1);
221
+                Double srate = N_Utils.getDoubleDivideAndMulitiply(score, paper.getPscore());
222
+                Map<String, Object> prate = new LinkedHashMap<>();
223
+                prate.put("pointid", entry.getKey());
224
+                prate.put("pointname", pgblist.get(0).getName());
225
+                prate.put("score", score);
226
+                prate.put("srate", srate);
227
+                prate.put("ques", pgblist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList()));
228
+                pointlist.add(prate);
229
+            }
230
+        }
231
+
232
+        MsPaperAnalyze epa = new MsPaperAnalyze();
233
+        epa.setMpid(paper.getMpid());
234
+        epa.setAlljson(JSON.toJSONString(ztmap));// 总体分析
235
+        epa.setQnumjson(JSON.toJSONString(typelist));// 试题栏题型分析
236
+        epa.setComplexityjson(JSON.toJSONString(clist));// 难易度分析
237
+        epa.setPointjson(JSON.toJSONString(pointlist));// 知识点分析
238
+        epa.setQuespointjson(JSON.toJSONString(quesplist));
239
+
240
+        // 判断试卷你是否有分析,如果没有直接保存
241
+        MsPaperAnalyze existEpa = msPaperAnalyzeMapper.getObjByMpId(paper.getMpid());
242
+        if (existEpa == null || !N_Utils.isTrueInteger(existEpa.getMpaid())) {
243
+            msPaperAnalyzeMapper.insertUseGeneratedKeys(epa);
244
+        } else {
245
+            epa.setMpaid(existEpa.getMpaid());
246
+            msPaperAnalyzeMapper.updateByPrimaryKey(epa);
247
+        }
248
+    }
249
+
250
+    // 设置知识点
251
+    private void setPaperQuestionPointScore(List<QuestionOrderVo> pointqlist, List<QuestionPointVo> quesplist, List<Map<String, Object>> qpoints, MsPaperQtypeQuestionVo dq,
252
+                                            String[] qnstr, List<Integer> mptqids) {
253
+        if (N_Utils.isListNotEmpty(qpoints)) {
254
+            if (qpoints.size() == 1) {
255
+                // 试题只有一个知识点
256
+                Map<String, Object> pointmap = qpoints.get(0);
257
+                QuestionOrderVo qpoint = new QuestionOrderVo();
258
+                qpoint.setId(pointmap.get("pointid").toString());
259
+                qpoint.setName(pointmap.get("pointname").toString());
260
+                qpoint.setOrder(dq.getQorder());
261
+                qpoint.setScore(dq.getQscore());
262
+                qpoint.setQlevel(dq.getQlevel());
263
+                qpoint.setQuestionid(dq.getQuestionid());
264
+                if (qnstr == null) {
265
+                    qpoint.setQns(new String[]{dq.getQn()});
266
+                } else {
267
+                    qpoint.setQns(qnstr);
268
+                }
269
+
270
+                if (N_Utils.isListEmpty(mptqids)) {
271
+                    qpoint.setMptqids(new Integer[]{dq.getMptqid()});
272
+                } else {
273
+                    Integer[] mptqidstr = mptqids.toArray(new Integer[0]);
274
+                    qpoint.setMptqids(mptqidstr);
275
+                }
276
+                pointqlist.add(qpoint);
277
+
278
+                // 试题对应知识点
279
+                QuestionPointVo questionPointVo = new QuestionPointVo();
280
+                questionPointVo.setOrder(dq.getQorder());
281
+                questionPointVo.setScore(dq.getQscore());
282
+                questionPointVo.setQlevel(dq.getQlevel());
283
+                questionPointVo.setQuestionid(dq.getQuestionid());
284
+                List<Map<String, Object>> pointids = new ArrayList<>();
285
+                Map<String, Object> map = new HashMap<>();
286
+                map.put("pointid", pointmap.get("pointid").toString());
287
+                map.put("score", dq.getQscore());
288
+                pointids.add(map);
289
+                questionPointVo.setPointids(pointids);
290
+
291
+                if (N_Utils.isListEmpty(mptqids)) {
292
+                    List<Integer> saveids = new ArrayList<>();
293
+                    saveids.add(dq.getMptqid());
294
+                    questionPointVo.setMptqids(saveids);
295
+                    questionPointVo.setMptqid(dq.getMptqid());
296
+                } else {
297
+                    questionPointVo.setMptqids(mptqids);
298
+                    questionPointVo.setMptqid(0);
299
+                }
300
+                quesplist.add(questionPointVo);
301
+            } else {
302
+
303
+                // 试题有多个知识点
304
+                // 计算每个知识点所占分值(平均分配)
305
+                Double[] avgps = N_Utils.getPointAvgScore(qpoints.size(), dq.getQscore());
306
+                List<Map<String, Object>> pointids = new ArrayList<>();
307
+                for (int m = 0; m < qpoints.size(); m++) {
308
+                    Map<String, Object> pointmap = qpoints.get(m);
309
+                    QuestionOrderVo qpoint = new QuestionOrderVo();
310
+                    qpoint.setId(pointmap.get("pointid").toString());
311
+                    qpoint.setName(pointmap.get("pointname").toString());
312
+                    qpoint.setOrder(dq.getQorder());
313
+                    qpoint.setQlevel(dq.getQlevel());
314
+                    qpoint.setQuestionid(dq.getQuestionid());
315
+
316
+
317
+                    Map<String, Object> quesmap = new HashMap<>();// 试题对应知识点
318
+                    quesmap.put("pointid", pointmap.get("pointid").toString());
319
+
320
+                    if (avgps.length == 2 && (m + 1) == qpoints.size()) {
321
+                        // 不能整除分,并且是最后一个知识点
322
+                        qpoint.setScore(avgps[1]);
323
+                        quesmap.put("score", avgps[1]);
324
+                    } else {
325
+                        qpoint.setScore(avgps[0]);
326
+                        quesmap.put("score", avgps[0]);
327
+                    }
328
+                    pointids.add(quesmap);
329
+
330
+                    // 题号集合
331
+                    if (qnstr == null) {
332
+                        qpoint.setQns(new String[]{dq.getQn()});
333
+                    } else {
334
+                        qpoint.setQns(qnstr);
335
+                    }
336
+                    // 试卷中试题id集合
337
+                    if (N_Utils.isListEmpty(mptqids)) {
338
+                        qpoint.setMptqids(new Integer[]{dq.getMptqid()});
339
+                    } else {
340
+                        Integer[] eptqidstr = mptqids.toArray(new Integer[0]);
341
+                        qpoint.setMptqids(eptqidstr);
342
+                    }
343
+                    pointqlist.add(qpoint);
344
+                }
345
+
346
+                // 试题对应知识点
347
+                QuestionPointVo questionPointVo = new QuestionPointVo();
348
+                questionPointVo.setOrder(dq.getQorder());
349
+                questionPointVo.setScore(dq.getQscore());
350
+                questionPointVo.setQlevel(dq.getQlevel());
351
+                questionPointVo.setQuestionid(dq.getQuestionid());
352
+                questionPointVo.setPointids(pointids);
353
+                if (N_Utils.isListEmpty(mptqids)) {
354
+                    List<Integer> saveids = new ArrayList<>();
355
+                    saveids.add(dq.getMptqid());
356
+                    questionPointVo.setMptqids(saveids);
357
+                    questionPointVo.setMptqid(dq.getMptqid());
358
+
359
+                } else {
360
+                    questionPointVo.setMptqids(mptqids);
361
+                    questionPointVo.setMptqid(0);
362
+                }
363
+                quesplist.add(questionPointVo);
364
+
365
+            }
366
+
367
+        } else {
368
+            QuestionPointVo questionPointVo = new QuestionPointVo();
369
+            questionPointVo.setOrder(dq.getQorder());
370
+            questionPointVo.setScore(dq.getQscore());
371
+            questionPointVo.setQlevel(dq.getQlevel());
372
+            questionPointVo.setQuestionid(dq.getQuestionid());
373
+            questionPointVo.setPointids(null);
374
+            if (N_Utils.isListEmpty(mptqids)) {
375
+                List<Integer> saveids = new ArrayList<>();
376
+                saveids.add(dq.getMptqid());
377
+                questionPointVo.setMptqids(saveids);
378
+                questionPointVo.setMptqid(dq.getMptqid());
379
+            } else {
380
+                questionPointVo.setMptqids(mptqids);
381
+                questionPointVo.setMptqid(0);
382
+            }
383
+
384
+            quesplist.add(questionPointVo);
385
+        }
386
+    }
387
+
388
+    // 设置知识点--试卷试题知识点关联关系
389
+    private void setPaperQuestionPointRelation(List<Map<String, Object>> qpoints, MsPaperQtypeQuestionVo dq, List<Integer> mptqids, List<MsPaperQtypeQuestionPoint> upQpointlist,
390
+                                               Integer mpid) {
391
+        if (N_Utils.isListNotEmpty(qpoints)) {
392
+            // 试题对应知识点关系
393
+            int i = 0;
394
+            for (Map<String, Object> pointmap : qpoints) {
395
+                String pointid = pointmap.get("pointid").toString();
396
+                String pointname = pointmap.get("pointname").toString();
397
+
398
+                if (N_Utils.isListEmpty(mptqids)) {
399
+                    MsPaperQtypeQuestionPoint upPoint = new MsPaperQtypeQuestionPoint();
400
+                    upPoint.setMpid(mpid);
401
+                    upPoint.setMptqid(dq.getMptqid());
402
+                    upPoint.setPointid(pointid);
403
+                    upPoint.setPointname(pointname);
404
+                    upPoint.setMporder(i++);
405
+
406
+                    upQpointlist.add(upPoint);
407
+                } else {
408
+                    for (Integer mptqid : mptqids) {
409
+                        MsPaperQtypeQuestionPoint upPoint = new MsPaperQtypeQuestionPoint();
410
+                        upPoint.setMpid(mpid);
411
+                        upPoint.setMptqid(mptqid);
412
+                        upPoint.setPointid(pointid);
413
+                        upPoint.setPointname(pointname);
414
+                        upPoint.setMporder(i++);
415
+
416
+                        upQpointlist.add(upPoint);
417
+                    }
418
+                }
419
+            }
420
+        }
421
+
422
+    }
423
+
424
+    // 设置题型下试题题号及分值
425
+    private void setPaperQuestionQtypeScore(List<QuestionOrderVo> qtypelist, MsPaperQtypeQuestionVo dq, String[] qnstr, Integer[] mptqidstr) {
426
+        QuestionOrderVo qtype = new QuestionOrderVo();
427
+        qtype.setId(dq.getQtypeid());
428
+        qtype.setName(dq.getQtypename());
429
+        qtype.setComplexity(dq.getComplexity());
430
+        qtype.setOrder(dq.getQorder());
431
+        qtype.setScore(dq.getQscore());
432
+        qtype.setQlevel(dq.getQlevel());
433
+        qtype.setQuestionid(dq.getQuestionid());
434
+        if (qnstr == null) {
435
+            qtype.setQns(new String[]{dq.getQn()});
436
+        } else {
437
+            qtype.setQns(qnstr);
438
+        }
439
+        if (mptqidstr == null) {
440
+            qtype.setMptqids(new Integer[]{dq.getMptqid()});
441
+        } else {
442
+            qtype.setMptqids(mptqidstr);
443
+        }
444
+
445
+        qtypelist.add(qtype);
446
+    }
447
+
448
+    // 设置试题难易度
449
+    private void setPaperQuestionComplexityScore(List<QuestionOrderVo> complexityList, MsPaperQtypeQuestionVo dq, String[] qnstr, Integer[] mptqidstr,
450
+                                                 List<MsPaperQtypeQuestion> upComplexitylist) {
451
+        QuestionOrderVo qtype = new QuestionOrderVo();
452
+        qtype.setId(dq.getComplexity().toString());// 存放试题难易度
453
+        qtype.setOrder(dq.getQorder());
454
+        qtype.setScore(dq.getQscore());
455
+        qtype.setQlevel(dq.getQlevel());
456
+        qtype.setQuestionid(dq.getQuestionid());
457
+        if (qnstr == null) {
458
+            qtype.setQns(new String[]{dq.getQn()});
459
+        } else {
460
+            qtype.setQns(qnstr);
461
+        }
462
+
463
+        if (mptqidstr == null) {
464
+            qtype.setMptqids(new Integer[]{dq.getMptqid()});
465
+        } else {
466
+            qtype.setMptqids(mptqidstr);
467
+        }
468
+
469
+        complexityList.add(qtype);
470
+        // 设置试题难易度
471
+        if (mptqidstr == null) {
472
+            MsPaperQtypeQuestion upComplexity = new MsPaperQtypeQuestion();
473
+            upComplexity.setMptqid(dq.getMptqid());
474
+            upComplexity.setComplexity(dq.getComplexity());
475
+
476
+            upComplexitylist.add(upComplexity);
477
+        } else {
478
+            for (Integer mptqid : mptqidstr) {
479
+                MsPaperQtypeQuestion upComplexity = new MsPaperQtypeQuestion();
480
+                upComplexity.setMptqid(mptqid);
481
+                upComplexity.setComplexity(dq.getComplexity());
482
+
483
+                upComplexitylist.add(upComplexity);
484
+            }
485
+        }
486
+
487
+
488
+    }
489
+
490
+    // 保存试卷分析--附件
491
+    public void savePaperAnalyzeForFj(MsPaper paper) {
492
+        List<MsPaperQtypeVo> fjtypelist = msPaperQtypeMapper.listPaperQtypeQuesitonsForFj(paper.getMpid());
493
+        List<MsPaperQtypeQuestionVo> queslist = new ArrayList<>();
494
+        for (MsPaperQtypeVo fj : fjtypelist) {
495
+            List<MsPaperQtypeQuestionVo> qlist = fj.getQuestions();
496
+            queslist.addAll(qlist);
497
+        }
498
+
499
+        List<QuestionOrderVo> pointqlist = new ArrayList<>();// 用于存放知识点,以及知识点下得分
500
+        List<QuestionPointVo> quesplist = new ArrayList<>();// 单题对应知识点
501
+
502
+        // 总体分析(主观题、客观题)
503
+        // 处理题型1单选题2多选题3主观题4判断对错5判断√×6判断TF11综合题12听力13填空题
504
+        int znum = 0;
505
+        double zscore = 0;
506
+        int knum = 0;
507
+        double kscore = 0;
508
+        for (MsPaperQtypeQuestionVo q : queslist) {
509
+            if (N_Utils.isObjectiveQuestion(q.getCtype())) {
510
+                knum++;
511
+                kscore = kscore + q.getQscore();
512
+            } else {
513
+                znum++;
514
+                zscore = zscore + q.getQscore();
515
+            }
516
+
517
+            List<Map<String, Object>> qpoints = q.getPoints();
518
+            if(qpoints != null) {
519
+                // 存放知识点
520
+                setPaperQuestionPointScore(pointqlist, quesplist, qpoints, q, null, null);
521
+            }
522
+        }
523
+
524
+        double znumrate = N_Utils.getIntegerDivideAndMulitiply(znum, paper.getPnum());
525
+        double knumrate = N_Utils.getDoubleReduce(100.0, znumrate);
526
+
527
+        double zscorerate = N_Utils.getDoubleDivideAndMulitiply(zscore, paper.getPscore());
528
+        double kscorerate = N_Utils.getDoubleReduce(100.0, zscorerate);
529
+
530
+        List<Map<String, Object>> ranglist = new ArrayList<>();
531
+        Map<String, Object> zgmap = new TreeMap<>();
532
+        zgmap.put("qtname", "主观题");
533
+        zgmap.put("score", zscore);
534
+        zgmap.put("num", znum);
535
+        zgmap.put("srate", zscorerate);
536
+        zgmap.put("nrate", znumrate);
537
+        ranglist.add(zgmap);
538
+        Map<String, Object> kgmap = new TreeMap<>();
539
+        kgmap.put("qtname", "客观题");
540
+        kgmap.put("score", kscore);
541
+        kgmap.put("num", knum);
542
+        kgmap.put("srate", kscorerate);
543
+        kgmap.put("nrate", knumrate);
544
+        ranglist.add(kgmap);
545
+
546
+        Map<String, Object> ztmap = new TreeMap<>();
547
+        ztmap.put("pnum", paper.getPnum());
548
+        ztmap.put("pscore", paper.getPscore());
549
+        ztmap.put("ranglist", ranglist);
550
+
551
+        // 题型分布(按照名称进行分组)
552
+        fjtypelist.sort(Comparator.comparing(MsPaperQtypeVo::getMptorder));
553
+        Map<String, List<MsPaperQtypeVo>> qtypemap = fjtypelist.stream().collect(Collectors.groupingBy(MsPaperQtypeVo::getMptname, Collectors.toList()));
554
+        List<Map<String, Object>> qtlist = new ArrayList<>();
555
+        for (Map.Entry<String, List<MsPaperQtypeVo>> entry : qtypemap.entrySet()) {
556
+            List<MsPaperQtypeVo> aq = entry.getValue();
557
+            int num = aq.stream().mapToInt(MsPaperQtypeVo::getMptnum).sum();
558
+            double tscore = aq.stream().mapToDouble(MsPaperQtypeVo::getMptscore).sum();
559
+            tscore = N_Utils.formatDouble(tscore, 1);
560
+            double storerate = N_Utils.getDoubleDivideAndMulitiply(tscore, paper.getPscore());
561
+            // 获取小题题号
562
+
563
+            List<Integer> orderlist = new ArrayList<>();
564
+            List<Integer> mptqidlist = new ArrayList<>();
565
+            List<String> qnlist = new ArrayList<>();
566
+            List<Double> scorelist = new ArrayList<>();
567
+            List<String> qnamelist = new ArrayList<>();
568
+            for (MsPaperQtypeVo t : aq) {
569
+                List<MsPaperQtypeQuestionVo> qlist = t.getQuestions();
570
+                for (MsPaperQtypeQuestionVo q : qlist) {
571
+                    orderlist.add(q.getQorder());
572
+                    mptqidlist.add(q.getMptqid());
573
+                    qnlist.add(q.getQn());
574
+                    scorelist.add(q.getQscore());
575
+                    qnamelist.add(q.getQtypename());
576
+                }
577
+            }
578
+
579
+            Map<String, Object> anmap = new TreeMap<>();// 题型对应试题的id和基础信息
580
+            anmap.put("orders", orderlist);
581
+            anmap.put("mptqids", mptqidlist);
582
+            anmap.put("qns", qnlist);
583
+            anmap.put("scores", scorelist);
584
+            anmap.put("qtypenames", qnamelist);
585
+
586
+            Map<String, Object> tmap = new TreeMap<>();
587
+            tmap.put("qtname", entry.getKey());
588
+            tmap.put("qtid", aq.get(0).getMptid());
589
+            tmap.put("num", num);
590
+            tmap.put("score", tscore);
591
+            tmap.put("srate", storerate);
592
+            tmap.put("ques", anmap);
593
+            qtlist.add(tmap);
594
+        }
595
+
596
+        // 试卷中试题难易度
597
+        String complexityJson = null;
598
+        List<MsPaperQtypeQuestionVo> hasComplexitys = queslist.stream().filter(q -> N_Utils.isTrueInteger(q.getComplexity())).collect(Collectors.toList());
599
+        if (!hasComplexitys.isEmpty()) {
600
+            Map<Integer, List<MsPaperQtypeQuestionVo>> complexmap = queslist.stream().collect(Collectors.groupingBy(MsPaperQtypeQuestionVo::getComplexity, Collectors.toList()));
601
+            List<Map<String, Object>> clist = new ArrayList<>();
602
+            for (Map.Entry<Integer, List<MsPaperQtypeQuestionVo>> entry : complexmap.entrySet()) {
603
+                List<MsPaperQtypeQuestionVo> pgblist = entry.getValue();
604
+                // 处理需要保存的ques集合
605
+                List<Map<String, Object>> quesList = new ArrayList<>();
606
+                for (MsPaperQtypeQuestionVo q : pgblist) {
607
+                    Map<String, Object> qmap = new TreeMap<>();
608
+                    qmap.put("id", entry.getKey());
609
+                    qmap.put("mptqid", q.getMptqid());
610
+                    qmap.put("order", q.getQorder());
611
+                    qmap.put("qlevel", 1);
612
+                    qmap.put("qns", q.getQn());
613
+                    qmap.put("score", q.getQscore());
614
+
615
+                    quesList.add(qmap);
616
+                }
617
+
618
+                Double score = pgblist.stream().mapToDouble(MsPaperQtypeQuestionVo::getQscore).sum();
619
+                score = N_Utils.formatDouble(score, 1);
620
+                Double srate = N_Utils.getDoubleDivideAndMulitiply(score, paper.getPscore());
621
+                Map<String, Object> prate = new TreeMap<>();
622
+                prate.put("level", entry.getKey());
623
+                prate.put("score", score);
624
+                prate.put("srate", srate);
625
+                prate.put("ques", quesList);
626
+                clist.add(prate);
627
+            }
628
+            complexityJson = JSON.toJSONString(clist);
629
+        }
630
+
631
+        // 试卷中试题知识点
632
+        String pointJson = null;
633
+        String quesPointJson = null;
634
+        if (N_Utils.isListNotEmpty(pointqlist)) {
635
+            List<Map<String, Object>> pointlist = new ArrayList<>();
636
+            LinkedHashMap<String, List<QuestionOrderVo>> pointmap = pointqlist.stream().collect(Collectors.groupingBy(QuestionOrderVo::getId, LinkedHashMap::new,
637
+                                                                                                                      Collectors.toList()));
638
+            // 根据指示进行分组,
639
+            for (Map.Entry<String, List<QuestionOrderVo>> entry : pointmap.entrySet()) {
640
+                List<QuestionOrderVo> pgblist = entry.getValue();
641
+                // 获取知识点的总分
642
+                Double score = pgblist.stream().mapToDouble(QuestionOrderVo::getScore).sum();
643
+                score = N_Utils.formatDouble(score, 1);
644
+                Double srate = N_Utils.getDoubleDivideAndMulitiply(score, paper.getPscore());
645
+                Map<String, Object> prate = new LinkedHashMap<>();
646
+                prate.put("pointid", entry.getKey());
647
+                prate.put("pointname", pgblist.get(0).getName());
648
+                prate.put("score", score);
649
+                prate.put("srate", srate);
650
+                prate.put("ques", pgblist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList()));
651
+                pointlist.add(prate);
652
+            }
653
+
654
+            pointJson = JSON.toJSONString(pointlist);
655
+            quesPointJson = JSON.toJSONString(quesplist);
656
+        }
657
+
658
+        MsPaperAnalyze epa = new MsPaperAnalyze();
659
+        epa.setMpid(paper.getMpid());
660
+        epa.setAlljson(JSON.toJSONString(ztmap));
661
+        epa.setQnumjson(JSON.toJSONString(qtlist));
662
+        epa.setComplexityjson(complexityJson);
663
+        epa.setPointjson(pointJson);
664
+        epa.setQuespointjson(quesPointJson);
665
+
666
+        // 判断试卷你是否有分析,如果没有直接保存
667
+        MsPaperAnalyze existEpa = msPaperAnalyzeMapper.getObjByMpId(paper.getMpid());
668
+        if (existEpa == null || !N_Utils.isTrueInteger(existEpa.getMpaid())) {
669
+            msPaperAnalyzeMapper.insertUseGeneratedKeys(epa);
670
+        } else {
671
+            epa.setMpaid(existEpa.getMpaid());
672
+            msPaperAnalyzeMapper.updateByPrimaryKey(epa);
673
+        }
674
+    }
675
+
676
+}
677
+
678
+

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

@@ -1,6 +1,5 @@
1 1
 package com.xhkjedu.smarking.service.paper;
2 2
 
3
-import com.alibaba.fastjson.JSON;
4 3
 import com.xhkjedu.exception.MissingParametersException;
5 4
 import com.xhkjedu.smarking.mapper.exam.MsSubjectMapper;
6 5
 import com.xhkjedu.smarking.mapper.paper.*;
@@ -22,7 +21,10 @@ import org.springframework.stereotype.Service;
22 21
 import org.springframework.transaction.annotation.Transactional;
23 22
 
24 23
 import javax.annotation.Resource;
25
-import java.util.*;
24
+import java.util.ArrayList;
25
+import java.util.List;
26
+import java.util.Map;
27
+import java.util.TreeMap;
26 28
 import java.util.stream.Collectors;
27 29
 
28 30
 /**
@@ -57,6 +59,8 @@ public class MsPaperQtypeService {
57 59
     private MsPaperStudentMapper msPaperStudentMapper;
58 60
     @Resource
59 61
     private MsPaperCheckTeacherMapper msPaperCheckTeacherMapper;
62
+    @Resource
63
+    private MsPaperAnalyzeService msPaperAnalyzeService;
60 64
     private final ConvertUtil convertUtil;
61 65
 
62 66
     public MsPaperQtypeService(ConvertUtil convertUtil) {
@@ -104,14 +108,14 @@ public class MsPaperQtypeService {
104 108
         List<String> imgs = new ArrayList<>();
105 109
         // 保存试卷分析
106 110
         if (paper.getPtype() == 1) {
107
-            savePaperAnalyzeForQuestion(paper);
111
+            msPaperAnalyzeService.savePaperAnalyzeForQuestion(paper);
108 112
         } else {
109 113
             List<MsPaperFile> pfiles = paper.getPfiles();// 附件
110 114
             if (paper.getYjstate() == 1) {
111 115
                 setPaperFiles(paper, pfiles, imgs);
112 116
                 msPaperFileMapper.insertList(pfiles);
113 117
             }
114
-            savePaperAnalyzeForFj(paper);
118
+            msPaperAnalyzeService.savePaperAnalyzeForFj(paper);
115 119
         }
116 120
 
117 121
         // 更改科目状态
@@ -215,459 +219,7 @@ public class MsPaperQtypeService {
215 219
         msPaperQtypeQuestionMapper.insertList(qtqs);
216 220
     }
217 221
 
218
-    // 保存试卷分析--题库
219
-    private void savePaperAnalyzeForQuestion(MsPaper paper) {
220
-        Integer mpid = paper.getMpid();
221
-
222
-        // 总体分析(主观题、客观题)
223
-        List<MsPaperQtypeVo> qtypelist = msPaperQtypeMapper.listPaperQtypeQuestions(paper.getMpid());// 试卷题型试题信息
224
-        List<MsPaperQtypeQuestion> uplist = new ArrayList<>();// 改试卷中客观题选项数量
225
-        List<MsPaperQtypeQuestion> upComplexitylist = new ArrayList<>();// 改试卷中客观题难易度
226
-        List<MsPaperQtypeQuestionPoint> upQpointlist = new ArrayList<>();// 保存试卷中试题知识点关联关系
227
-
228
-        List<QuestionOrderVo> pointqlist = new ArrayList<>();// 用于存放知识点,以及知识点下得分
229
-        List<MsPaperQtypeQuestionVo> mquestions = new ArrayList<>();// 存放单题和母题
230
-        List<QuestionOrderVo> complexitylist = new ArrayList<>();// 试题难易度存放试题
231
-        List<QuestionPointVo> quesplist = new ArrayList<>();// 单题、母题对应知识点
232
-
233
-        // 处理出试卷中所有试题、知识点
234
-        List<Map<String, Object>> typelist = new ArrayList<>();// 题型分析
235
-        for (MsPaperQtypeVo qt : qtypelist) {
236
-            List<Integer> qorderlist = new ArrayList<>();
237
-            List<QuestionOrderVo> qtypeqlist = new ArrayList<>();
238
-            List<MsPaperQtypeQuestionVo> tqlist = qt.getQuestions();
239
-            int hasmt = 0;
240
-            for (MsPaperQtypeQuestionVo q : tqlist) {
241
-                int ctype = q.getCtype();
242
-                // 单题的pid设置为默认值,方便后续进行单题和母题处理
243
-                if (q.getQlevel() == 1) {
244
-                    q.setQuestionpid("000");
245
-                    // 判断试题是否是客观题
246
-                    if (N_Utils.isObjectiveQuestion(ctype)) {
247
-                        // 判断试题是否是客观题,暂时用mctype进行标识
248
-                        q.setMctype(111);
249
-                    } else {
250
-                        q.setMctype(112);
251
-                    }
252
-                    // 设置知识点
253
-                    mquestions.add(q);
254
-                    // 获取试题知识点
255
-                    List<Map<String, Object>> qpoints = q.getPoints();
256
-                    // 处理试题知识点占分
257
-                    setPaperQuestionPointScore(pointqlist, quesplist, qpoints, q, null, null);
258
-                    setPaperQuestionPointRelation(qpoints, q, null, upQpointlist, mpid);
259
-                    setPaperQuestionQtypeScore(qtypeqlist, q, null, null);// 处理试题题型
260
-                    setPaperQuestionComplexityScore(complexitylist, q, null, null, upComplexitylist);// 处理试题难易度
261
-
262
-                }
263
-                if (q.getQlevel() == 3) {
264
-                    hasmt++;
265
-                }
266
-                if (!qorderlist.contains(q.getQorder())) {
267
-                    qorderlist.add(q.getQorder());
268
-                }
269
-                // 为了处理客观题中选项数量
270
-                if (ctype == 1 || ctype == 2 || ctype == 4 || ctype == 5 || ctype == 6) {
271
-                    List<String> strlst = JSON.parseArray(q.getQoption(), String.class);
272
-                    MsPaperQtypeQuestion eqq = new MsPaperQtypeQuestion();
273
-                    eqq.setMptqid(q.getMptqid());
274
-                    eqq.setOptionnum(strlst.size());
275
-                    uplist.add(eqq);
276
-                }
277
-            }
278
-
279
-            if (hasmt > 0) {
280
-                // 说明该题型下有复合题,复合体进行知识点、题型下试题题号及id进行操作
281
-                LinkedHashMap<String, List<MsPaperQtypeQuestionVo>> quesMap = tqlist.stream().collect(Collectors.groupingBy(MsPaperQtypeQuestionVo::getQuestionpid,
282
-                                                                                                                            LinkedHashMap::new, Collectors.toList()));
283
-                for (Map.Entry<String, List<MsPaperQtypeQuestionVo>> entry : quesMap.entrySet()) {
284
-                    if (!entry.getKey().equals("000")) {
285
-                        // 说明该题为母题,
286
-                        MsPaperQtypeQuestionVo mq = new MsPaperQtypeQuestionVo();
287
-                        List<MsPaperQtypeQuestionVo> sonques = entry.getValue();
288
-                        int k = 0;// 如果k大于1说明有小题是主观题,则母题为主观题
289
-                        double score = 0;
290
-                        for (MsPaperQtypeQuestionVo sq : sonques) {
291
-                            if (!N_Utils.isObjectiveQuestion(sq.getCtype())) {
292
-                                k++;
293
-                            }
294
-                            score = N_Utils.getDoubleSum(score, sq.getQscore());
295
-                        }
296
-
297
-                        MsPaperQtypeQuestionVo qobj = sonques.get(0);
298
-                        mq.setQuestionid(qobj.getQuestionpid());
299
-                        mq.setComplexity(qobj.getMcomplexity());
300
-                        mq.setQorder(qobj.getQorder());
301
-                        mq.setQscore(score);
302
-                        mq.setQtypename(qobj.getMqtypename());
303
-                        if (k == 0) {
304
-                            mq.setMctype(111);
305
-                        } else {
306
-                            mq.setMctype(112);
307
-                        }
308
-                        mq.setQlevel(qobj.getMqlevel());
309
-                        mq.setSonques(sonques);
310
-                        // 获取所有子题的试题题号
311
-                        String[] qnstr = sonques.stream().map(MsPaperQtypeQuestionVo::getQn).toArray(String[]::new);
312
-                        // 所有子题的试题eptqid
313
-                        List<Integer> eptqids = sonques.stream().map(MsPaperQtypeQuestionVo::getMptqid).collect(Collectors.toList());
314
-                        Integer[] eptqidstr = eptqids.toArray(new Integer[0]);
315
-
316
-                        // 获取知识点
317
-                        List<Map<String, Object>> qpoints = sonques.get(0).getPoints();
318
-                        mq.setPoints(qpoints);
319
-                        mquestions.add(mq);
320
-                        setPaperQuestionPointScore(pointqlist, quesplist, qpoints, mq, qnstr, eptqids);
321
-                        setPaperQuestionPointRelation(qpoints, mq, eptqids, upQpointlist, mpid);
322
-                        setPaperQuestionQtypeScore(qtypeqlist, mq, qnstr, eptqidstr);// 处理试题题型
323
-                        setPaperQuestionComplexityScore(complexitylist, mq, qnstr, eptqidstr, upComplexitylist);// 处理试题难易度
324
-                    }
325
-                }
326
-            }
327 222
 
328
-            // 试题题型分析数据
329
-            double storerate = N_Utils.getDoubleDivideAndMulitiply(qt.getMptscore(), paper.getPscore());
330
-            Map<String, Object> tmap = new TreeMap<>();
331
-            tmap.put("qtid", qt.getMptid());
332
-            tmap.put("qtname", qt.getMptname());
333
-            tmap.put("num", qt.getMptnum());
334
-            tmap.put("score", qt.getMptscore());
335
-            tmap.put("srate", storerate);
336
-            qtypeqlist = qtypeqlist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList());
337
-            tmap.put("ques", qtypeqlist);
338
-            typelist.add(tmap);
339
-        }
340
-
341
-        // 进行客观题选项处理
342
-        if (N_Utils.isListNotEmpty(uplist)) {
343
-            msPaperQtypeQuestionMapper.updateBatchQuestionOptionnum(uplist);
344
-        }
345
-
346
-        // 试题总体分布进行分析
347
-        // 客观题集合
348
-        List<MsPaperQtypeQuestionVo> ktlst = mquestions.stream().filter(q -> q.getMctype() == 111).collect(Collectors.toList());
349
-        int ktnum = ktlst.size();
350
-        double ktscore = ktlst.stream().mapToDouble(MsPaperQtypeQuestionVo::getQscore).sum();
351
-        double ktnrate = N_Utils.getIntegerDivideAndMulitiply(ktnum, paper.getPnum());
352
-        double ktsrate = N_Utils.getDoubleDivideAndMulitiply(ktscore, paper.getPscore());
353
-        List<MsPaperQsVo> ranglist = new ArrayList<>();
354
-        ranglist.add(new MsPaperQsVo("客观题", ktscore, ktnum, ktsrate, ktnrate));
355
-        MsPaperQsVo zgq = new MsPaperQsVo();
356
-        zgq.setQtname("主观题");
357
-        zgq.setNum(paper.getPnum() - ktnum);
358
-        zgq.setNrate(N_Utils.getDoubleReduce(100.0, ktnrate));
359
-        zgq.setScore(N_Utils.getDoubleReduce(paper.getPscore(), ktscore));
360
-        zgq.setSrate(N_Utils.getDoubleReduce(100.0, ktsrate));
361
-        ranglist.add(zgq);
362
-        Map<String, Object> ztmap = new TreeMap<>();
363
-        ztmap.put("pnum", paper.getPnum());
364
-        ztmap.put("pscore", paper.getPscore());
365
-        ztmap.put("ranglist", ranglist);
366
-
367
-        // 设置试卷中试题难易度
368
-        msPaperQtypeQuestionMapper.updateBatchQuestionComplexity(upComplexitylist);
369
-
370
-        // 难易度
371
-        List<Map<String, Object>> clist = new ArrayList<>();
372
-        if (N_Utils.isListNotEmpty(complexitylist)) {
373
-            Map<String, List<QuestionOrderVo>> complxmap = complexitylist.stream().collect(Collectors.groupingBy(QuestionOrderVo::getId, Collectors.toList()));
374
-            for (Map.Entry<String, List<QuestionOrderVo>> entry : complxmap.entrySet()) {
375
-                List<QuestionOrderVo> pgblist = entry.getValue();
376
-                Double score = pgblist.stream().mapToDouble(QuestionOrderVo::getScore).sum();
377
-                score = N_Utils.formatDouble(score, 1);
378
-                Double srate = N_Utils.getDoubleDivideAndMulitiply(score, paper.getPscore());
379
-                Map<String, Object> prate = new TreeMap<>();
380
-                prate.put("level", Integer.parseInt(entry.getKey()));
381
-                prate.put("score", score);
382
-                prate.put("srate", srate);
383
-                prate.put("ques", pgblist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList()));
384
-                clist.add(prate);
385
-            }
386
-        }
387
-
388
-        // 保存试卷试题知识点关系
389
-        msPaperQtypeQuestionPointMapper.deleteByMpid(mpid);
390
-        msPaperQtypeQuestionPointMapper.insertList(upQpointlist);
391
-
392
-        // 知识点分析
393
-        List<Map<String, Object>> pointlist = new ArrayList<>();
394
-        if (N_Utils.isListNotEmpty(pointqlist)) {
395
-            LinkedHashMap<String, List<QuestionOrderVo>> pointmap = pointqlist.stream().collect(Collectors.groupingBy(QuestionOrderVo::getId, LinkedHashMap::new,
396
-                                                                                                                      Collectors.toList()));
397
-            // 根据指示进行分组,
398
-            for (Map.Entry<String, List<QuestionOrderVo>> entry : pointmap.entrySet()) {
399
-                List<QuestionOrderVo> pgblist = entry.getValue();
400
-                // 获取知识点的总分
401
-                Double score = pgblist.stream().mapToDouble(QuestionOrderVo::getScore).sum();
402
-                score = N_Utils.formatDouble(score, 1);
403
-                Double srate = N_Utils.getDoubleDivideAndMulitiply(score, paper.getPscore());
404
-                Map<String, Object> prate = new LinkedHashMap<>();
405
-                prate.put("pointid", entry.getKey());
406
-                prate.put("pointname", pgblist.get(0).getName());
407
-                prate.put("score", score);
408
-                prate.put("srate", srate);
409
-                prate.put("ques", pgblist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList()));
410
-                pointlist.add(prate);
411
-            }
412
-        }
413
-
414
-        MsPaperAnalyze epa = new MsPaperAnalyze();
415
-        epa.setMpid(paper.getMpid());
416
-        epa.setAlljson(JSON.toJSONString(ztmap));// 总体分析
417
-        epa.setQnumjson(JSON.toJSONString(typelist));// 试题栏题型分析
418
-        epa.setComplexityjson(JSON.toJSONString(clist));// 难易度分析
419
-        epa.setPointjson(JSON.toJSONString(pointlist));// 知识点分析
420
-        epa.setQuespointjson(JSON.toJSONString(quesplist));
421
-
422
-        // 判断试卷你是否有分析,如果没有直接保存
423
-        MsPaperAnalyze existEpa = msPaperAnalyzeMapper.getObjByMpId(paper.getMpid());
424
-        if (existEpa == null || !N_Utils.isTrueInteger(existEpa.getMpaid())) {
425
-            msPaperAnalyzeMapper.insertUseGeneratedKeys(epa);
426
-        } else {
427
-            epa.setMpaid(existEpa.getMpaid());
428
-            msPaperAnalyzeMapper.updateByPrimaryKey(epa);
429
-        }
430
-    }
431
-
432
-    // 设置知识点
433
-    private void setPaperQuestionPointScore(List<QuestionOrderVo> pointqlist, List<QuestionPointVo> quesplist, List<Map<String, Object>> qpoints, MsPaperQtypeQuestionVo dq,
434
-                                            String[] qnstr, List<Integer> mptqids) {
435
-        if (N_Utils.isListNotEmpty(qpoints)) {
436
-            if (qpoints.size() == 1) {
437
-                // 试题只有一个知识点
438
-                Map<String, Object> pointmap = qpoints.get(0);
439
-                QuestionOrderVo qpoint = new QuestionOrderVo();
440
-                qpoint.setId(pointmap.get("pointid").toString());
441
-                qpoint.setName(pointmap.get("pointname").toString());
442
-                qpoint.setOrder(dq.getQorder());
443
-                qpoint.setScore(dq.getQscore());
444
-                qpoint.setQlevel(dq.getQlevel());
445
-                qpoint.setQuestionid(dq.getQuestionid());
446
-                if (qnstr == null) {
447
-                    qpoint.setQns(new String[]{dq.getQn()});
448
-                } else {
449
-                    qpoint.setQns(qnstr);
450
-                }
451
-
452
-                if (N_Utils.isListEmpty(mptqids)) {
453
-                    qpoint.setMptqids(new Integer[]{dq.getMptqid()});
454
-                } else {
455
-                    Integer[] mptqidstr = mptqids.toArray(new Integer[0]);
456
-                    qpoint.setMptqids(mptqidstr);
457
-                }
458
-                pointqlist.add(qpoint);
459
-
460
-                // 试题对应知识点
461
-                QuestionPointVo questionPointVo = new QuestionPointVo();
462
-                questionPointVo.setOrder(dq.getQorder());
463
-                questionPointVo.setScore(dq.getQscore());
464
-                questionPointVo.setQlevel(dq.getQlevel());
465
-                questionPointVo.setQuestionid(dq.getQuestionid());
466
-                List<Map<String, Object>> pointids = new ArrayList<>();
467
-                Map<String, Object> map = new HashMap<>();
468
-                map.put("pointid", pointmap.get("pointid").toString());
469
-                map.put("score", dq.getQscore());
470
-                pointids.add(map);
471
-                questionPointVo.setPointids(pointids);
472
-
473
-                if (N_Utils.isListEmpty(mptqids)) {
474
-                    List<Integer> saveids = new ArrayList<>();
475
-                    saveids.add(dq.getMptqid());
476
-                    questionPointVo.setMptqids(saveids);
477
-                    questionPointVo.setMptqid(dq.getMptqid());
478
-                } else {
479
-                    questionPointVo.setMptqids(mptqids);
480
-                    questionPointVo.setMptqid(0);
481
-                }
482
-                quesplist.add(questionPointVo);
483
-            } else {
484
-
485
-                // 试题有多个知识点
486
-                // 计算每个知识点所占分值(平均分配)
487
-                Double[] avgps = N_Utils.getPointAvgScore(qpoints.size(), dq.getQscore());
488
-                List<Map<String, Object>> pointids = new ArrayList<>();
489
-                for (int m = 0; m < qpoints.size(); m++) {
490
-                    Map<String, Object> pointmap = qpoints.get(m);
491
-                    QuestionOrderVo qpoint = new QuestionOrderVo();
492
-                    qpoint.setId(pointmap.get("pointid").toString());
493
-                    qpoint.setName(pointmap.get("pointname").toString());
494
-                    qpoint.setOrder(dq.getQorder());
495
-                    qpoint.setQlevel(dq.getQlevel());
496
-                    qpoint.setQuestionid(dq.getQuestionid());
497
-
498
-
499
-                    Map<String, Object> quesmap = new HashMap<>();// 试题对应知识点
500
-                    quesmap.put("pointid", pointmap.get("pointid").toString());
501
-
502
-                    if (avgps.length == 2 && (m + 1) == qpoints.size()) {
503
-                        // 不能整除分,并且是最后一个知识点
504
-                        qpoint.setScore(avgps[1]);
505
-                        quesmap.put("score", avgps[1]);
506
-                    } else {
507
-                        qpoint.setScore(avgps[0]);
508
-                        quesmap.put("score", avgps[0]);
509
-                    }
510
-                    pointids.add(quesmap);
511
-
512
-                    // 题号集合
513
-                    if (qnstr == null) {
514
-                        qpoint.setQns(new String[]{dq.getQn()});
515
-                    } else {
516
-                        qpoint.setQns(qnstr);
517
-                    }
518
-                    // 试卷中试题id集合
519
-                    if (N_Utils.isListEmpty(mptqids)) {
520
-                        qpoint.setMptqids(new Integer[]{dq.getMptqid()});
521
-                    } else {
522
-                        Integer[] eptqidstr = mptqids.toArray(new Integer[0]);
523
-                        qpoint.setMptqids(eptqidstr);
524
-                    }
525
-                    pointqlist.add(qpoint);
526
-                }
527
-
528
-                // 试题对应知识点
529
-                QuestionPointVo questionPointVo = new QuestionPointVo();
530
-                questionPointVo.setOrder(dq.getQorder());
531
-                questionPointVo.setScore(dq.getQscore());
532
-                questionPointVo.setQlevel(dq.getQlevel());
533
-                questionPointVo.setQuestionid(dq.getQuestionid());
534
-                questionPointVo.setPointids(pointids);
535
-                if (N_Utils.isListEmpty(mptqids)) {
536
-                    List<Integer> saveids = new ArrayList<>();
537
-                    saveids.add(dq.getMptqid());
538
-                    questionPointVo.setMptqids(saveids);
539
-                    questionPointVo.setMptqid(dq.getMptqid());
540
-
541
-                } else {
542
-                    questionPointVo.setMptqids(mptqids);
543
-                    questionPointVo.setMptqid(0);
544
-                }
545
-                quesplist.add(questionPointVo);
546
-
547
-            }
548
-
549
-        } else {
550
-            QuestionPointVo questionPointVo = new QuestionPointVo();
551
-            questionPointVo.setOrder(dq.getQorder());
552
-            questionPointVo.setScore(dq.getQscore());
553
-            questionPointVo.setQlevel(dq.getQlevel());
554
-            questionPointVo.setQuestionid(dq.getQuestionid());
555
-            questionPointVo.setPointids(null);
556
-            if (N_Utils.isListEmpty(mptqids)) {
557
-                List<Integer> saveids = new ArrayList<>();
558
-                saveids.add(dq.getMptqid());
559
-                questionPointVo.setMptqids(saveids);
560
-                questionPointVo.setMptqid(dq.getMptqid());
561
-            } else {
562
-                questionPointVo.setMptqids(mptqids);
563
-                questionPointVo.setMptqid(0);
564
-            }
565
-
566
-            quesplist.add(questionPointVo);
567
-        }
568
-    }
569
-
570
-    // 设置知识点--试卷试题知识点关联关系
571
-    private void setPaperQuestionPointRelation(List<Map<String, Object>> qpoints, MsPaperQtypeQuestionVo dq, List<Integer> mptqids, List<MsPaperQtypeQuestionPoint> upQpointlist,
572
-                                               Integer mpid) {
573
-        if (N_Utils.isListNotEmpty(qpoints)) {
574
-            // 试题对应知识点关系
575
-            int i = 0;
576
-            for (Map<String, Object> pointmap : qpoints) {
577
-                String pointid = pointmap.get("pointid").toString();
578
-                String pointname = pointmap.get("pointname").toString();
579
-
580
-                if (N_Utils.isListEmpty(mptqids)) {
581
-                    MsPaperQtypeQuestionPoint upPoint = new MsPaperQtypeQuestionPoint();
582
-                    upPoint.setMpid(mpid);
583
-                    upPoint.setMptqid(dq.getMptqid());
584
-                    upPoint.setPointid(pointid);
585
-                    upPoint.setPointname(pointname);
586
-                    upPoint.setMporder(i++);
587
-
588
-                    upQpointlist.add(upPoint);
589
-                } else {
590
-                    for (Integer mptqid : mptqids) {
591
-                        MsPaperQtypeQuestionPoint upPoint = new MsPaperQtypeQuestionPoint();
592
-                        upPoint.setMpid(mpid);
593
-                        upPoint.setMptqid(mptqid);
594
-                        upPoint.setPointid(pointid);
595
-                        upPoint.setPointname(pointname);
596
-                        upPoint.setMporder(i++);
597
-
598
-                        upQpointlist.add(upPoint);
599
-                    }
600
-                }
601
-            }
602
-        }
603
-
604
-    }
605
-
606
-    // 设置题型下试题题号及分值
607
-    private void setPaperQuestionQtypeScore(List<QuestionOrderVo> qtypelist, MsPaperQtypeQuestionVo dq, String[] qnstr, Integer[] mptqidstr) {
608
-        QuestionOrderVo qtype = new QuestionOrderVo();
609
-        qtype.setId(dq.getQtypeid());
610
-        qtype.setName(dq.getQtypename());
611
-        qtype.setComplexity(dq.getComplexity());
612
-        qtype.setOrder(dq.getQorder());
613
-        qtype.setScore(dq.getQscore());
614
-        qtype.setQlevel(dq.getQlevel());
615
-        qtype.setQuestionid(dq.getQuestionid());
616
-        if (qnstr == null) {
617
-            qtype.setQns(new String[]{dq.getQn()});
618
-        } else {
619
-            qtype.setQns(qnstr);
620
-        }
621
-        if (mptqidstr == null) {
622
-            qtype.setMptqids(new Integer[]{dq.getMptqid()});
623
-        } else {
624
-            qtype.setMptqids(mptqidstr);
625
-        }
626
-
627
-        qtypelist.add(qtype);
628
-    }
629
-
630
-    // 设置试题难易度
631
-    private void setPaperQuestionComplexityScore(List<QuestionOrderVo> complexityList, MsPaperQtypeQuestionVo dq, String[] qnstr, Integer[] mptqidstr,
632
-                                                 List<MsPaperQtypeQuestion> upComplexitylist) {
633
-        QuestionOrderVo qtype = new QuestionOrderVo();
634
-        qtype.setId(dq.getComplexity().toString());// 存放试题难易度
635
-        qtype.setOrder(dq.getQorder());
636
-        qtype.setScore(dq.getQscore());
637
-        qtype.setQlevel(dq.getQlevel());
638
-        qtype.setQuestionid(dq.getQuestionid());
639
-        if (qnstr == null) {
640
-            qtype.setQns(new String[]{dq.getQn()});
641
-        } else {
642
-            qtype.setQns(qnstr);
643
-        }
644
-
645
-        if (mptqidstr == null) {
646
-            qtype.setMptqids(new Integer[]{dq.getMptqid()});
647
-        } else {
648
-            qtype.setMptqids(mptqidstr);
649
-        }
650
-
651
-        complexityList.add(qtype);
652
-        // 设置试题难易度
653
-        if (mptqidstr == null) {
654
-            MsPaperQtypeQuestion upComplexity = new MsPaperQtypeQuestion();
655
-            upComplexity.setMptqid(dq.getMptqid());
656
-            upComplexity.setComplexity(dq.getComplexity());
657
-
658
-            upComplexitylist.add(upComplexity);
659
-        } else {
660
-            for (Integer mptqid : mptqidstr) {
661
-                MsPaperQtypeQuestion upComplexity = new MsPaperQtypeQuestion();
662
-                upComplexity.setMptqid(mptqid);
663
-                upComplexity.setComplexity(dq.getComplexity());
664
-
665
-                upComplexitylist.add(upComplexity);
666
-            }
667
-        }
668
-
669
-
670
-    }
671 223
 
672 224
     // 设置附件
673 225
     private void setPaperFiles(MsPaper paper, List<MsPaperFile> pfiles, List<String> imgs) {
@@ -694,191 +246,7 @@ public class MsPaperQtypeService {
694 246
 
695 247
     }
696 248
 
697
-    // 保存试卷分析--附件
698
-    private void savePaperAnalyzeForFj(MsPaper paper) {
699
-        List<MsPaperQtypeVo> fjtypelist = msPaperQtypeMapper.listPaperQtypeQuesitonsForFj(paper.getMpid());
700
-        List<MsPaperQtypeQuestionVo> queslist = new ArrayList<>();
701
-        for (MsPaperQtypeVo fj : fjtypelist) {
702
-            List<MsPaperQtypeQuestionVo> qlist = fj.getQuestions();
703
-            queslist.addAll(qlist);
704
-        }
705 249
 
706
-        List<QuestionOrderVo> pointqlist = new ArrayList<>();// 用于存放知识点,以及知识点下得分
707
-        List<QuestionPointVo> quesplist = new ArrayList<>();// 单题对应知识点
708
-
709
-        // 总体分析(主观题、客观题)
710
-        // 处理题型1单选题2多选题3主观题4判断对错5判断√×6判断TF11综合题12听力13填空题
711
-        int znum = 0;
712
-        double zscore = 0;
713
-        int knum = 0;
714
-        double kscore = 0;
715
-        for (MsPaperQtypeQuestionVo q : queslist) {
716
-            if (N_Utils.isObjectiveQuestion(q.getCtype())) {
717
-                knum++;
718
-                kscore = kscore + q.getQscore();
719
-            } else {
720
-                znum++;
721
-                zscore = zscore + q.getQscore();
722
-            }
723
-
724
-            List<Map<String, Object>> qpoints = q.getPoints();
725
-            if(qpoints != null) {
726
-                // 存放知识点
727
-                setPaperQuestionPointScore(pointqlist, quesplist, qpoints, q, null, null);
728
-            }
729
-        }
730
-
731
-        double znumrate = N_Utils.getIntegerDivideAndMulitiply(znum, paper.getPnum());
732
-        double knumrate = N_Utils.getDoubleReduce(100.0, znumrate);
733
-
734
-        double zscorerate = N_Utils.getDoubleDivideAndMulitiply(zscore, paper.getPscore());
735
-        double kscorerate = N_Utils.getDoubleReduce(100.0, zscorerate);
736
-
737
-        List<Map<String, Object>> ranglist = new ArrayList<>();
738
-        Map<String, Object> zgmap = new TreeMap<>();
739
-        zgmap.put("qtname", "主观题");
740
-        zgmap.put("score", zscore);
741
-        zgmap.put("num", znum);
742
-        zgmap.put("srate", zscorerate);
743
-        zgmap.put("nrate", znumrate);
744
-        ranglist.add(zgmap);
745
-        Map<String, Object> kgmap = new TreeMap<>();
746
-        kgmap.put("qtname", "客观题");
747
-        kgmap.put("score", kscore);
748
-        kgmap.put("num", knum);
749
-        kgmap.put("srate", kscorerate);
750
-        kgmap.put("nrate", knumrate);
751
-        ranglist.add(kgmap);
752
-
753
-        Map<String, Object> ztmap = new TreeMap<>();
754
-        ztmap.put("pnum", paper.getPnum());
755
-        ztmap.put("pscore", paper.getPscore());
756
-        ztmap.put("ranglist", ranglist);
757
-
758
-        // 题型分布(按照名称进行分组)
759
-        fjtypelist.sort(Comparator.comparing(MsPaperQtypeVo::getMptorder));
760
-        Map<String, List<MsPaperQtypeVo>> qtypemap = fjtypelist.stream().collect(Collectors.groupingBy(MsPaperQtypeVo::getMptname, Collectors.toList()));
761
-        List<Map<String, Object>> qtlist = new ArrayList<>();
762
-        for (Map.Entry<String, List<MsPaperQtypeVo>> entry : qtypemap.entrySet()) {
763
-            List<MsPaperQtypeVo> aq = entry.getValue();
764
-            int num = aq.stream().mapToInt(MsPaperQtypeVo::getMptnum).sum();
765
-            double tscore = aq.stream().mapToDouble(MsPaperQtypeVo::getMptscore).sum();
766
-            tscore = N_Utils.formatDouble(tscore, 1);
767
-            double storerate = N_Utils.getDoubleDivideAndMulitiply(tscore, paper.getPscore());
768
-            // 获取小题题号
769
-
770
-            List<Integer> orderlist = new ArrayList<>();
771
-            List<Integer> mptqidlist = new ArrayList<>();
772
-            List<String> qnlist = new ArrayList<>();
773
-            List<Double> scorelist = new ArrayList<>();
774
-            List<String> qnamelist = new ArrayList<>();
775
-            for (MsPaperQtypeVo t : aq) {
776
-                List<MsPaperQtypeQuestionVo> qlist = t.getQuestions();
777
-                for (MsPaperQtypeQuestionVo q : qlist) {
778
-                    orderlist.add(q.getQorder());
779
-                    mptqidlist.add(q.getMptqid());
780
-                    qnlist.add(q.getQn());
781
-                    scorelist.add(q.getQscore());
782
-                    qnamelist.add(q.getQtypename());
783
-                }
784
-            }
785
-
786
-            Map<String, Object> anmap = new TreeMap<>();// 题型对应试题的id和基础信息
787
-            anmap.put("orders", orderlist);
788
-            anmap.put("mptqids", mptqidlist);
789
-            anmap.put("qns", qnlist);
790
-            anmap.put("scores", scorelist);
791
-            anmap.put("qtypenames", qnamelist);
792
-
793
-            Map<String, Object> tmap = new TreeMap<>();
794
-            tmap.put("qtname", entry.getKey());
795
-            tmap.put("qtid", aq.get(0).getMptid());
796
-            tmap.put("num", num);
797
-            tmap.put("score", tscore);
798
-            tmap.put("srate", storerate);
799
-            tmap.put("ques", anmap);
800
-            qtlist.add(tmap);
801
-        }
802
-
803
-        // 试卷中试题难易度
804
-        String complexityJson = null;
805
-        List<MsPaperQtypeQuestionVo> hasComplexitys = queslist.stream().filter(q -> N_Utils.isTrueInteger(q.getComplexity())).collect(Collectors.toList());
806
-        if (!hasComplexitys.isEmpty()) {
807
-            Map<Integer, List<MsPaperQtypeQuestionVo>> complexmap = queslist.stream().collect(Collectors.groupingBy(MsPaperQtypeQuestionVo::getComplexity, Collectors.toList()));
808
-            List<Map<String, Object>> clist = new ArrayList<>();
809
-            for (Map.Entry<Integer, List<MsPaperQtypeQuestionVo>> entry : complexmap.entrySet()) {
810
-                List<MsPaperQtypeQuestionVo> pgblist = entry.getValue();
811
-                // 处理需要保存的ques集合
812
-                List<Map<String, Object>> quesList = new ArrayList<>();
813
-                for (MsPaperQtypeQuestionVo q : pgblist) {
814
-                    Map<String, Object> qmap = new TreeMap<>();
815
-                    qmap.put("id", entry.getKey());
816
-                    qmap.put("mptqid", q.getMptqid());
817
-                    qmap.put("order", q.getQorder());
818
-                    qmap.put("qlevel", 1);
819
-                    qmap.put("qns", q.getQn());
820
-                    qmap.put("score", q.getQscore());
821
-
822
-                    quesList.add(qmap);
823
-                }
824
-
825
-                Double score = pgblist.stream().mapToDouble(MsPaperQtypeQuestionVo::getQscore).sum();
826
-                score = N_Utils.formatDouble(score, 1);
827
-                Double srate = N_Utils.getDoubleDivideAndMulitiply(score, paper.getPscore());
828
-                Map<String, Object> prate = new TreeMap<>();
829
-                prate.put("level", entry.getKey());
830
-                prate.put("score", score);
831
-                prate.put("srate", srate);
832
-                prate.put("ques", quesList);
833
-                clist.add(prate);
834
-            }
835
-            complexityJson = JSON.toJSONString(clist);
836
-        }
837
-
838
-        // 试卷中试题知识点
839
-        String pointJson = null;
840
-        String quesPointJson = null;
841
-        if (N_Utils.isListNotEmpty(pointqlist)) {
842
-            List<Map<String, Object>> pointlist = new ArrayList<>();
843
-            LinkedHashMap<String, List<QuestionOrderVo>> pointmap = pointqlist.stream().collect(Collectors.groupingBy(QuestionOrderVo::getId, LinkedHashMap::new,
844
-                                                                                                                      Collectors.toList()));
845
-            // 根据指示进行分组,
846
-            for (Map.Entry<String, List<QuestionOrderVo>> entry : pointmap.entrySet()) {
847
-                List<QuestionOrderVo> pgblist = entry.getValue();
848
-                // 获取知识点的总分
849
-                Double score = pgblist.stream().mapToDouble(QuestionOrderVo::getScore).sum();
850
-                score = N_Utils.formatDouble(score, 1);
851
-                Double srate = N_Utils.getDoubleDivideAndMulitiply(score, paper.getPscore());
852
-                Map<String, Object> prate = new LinkedHashMap<>();
853
-                prate.put("pointid", entry.getKey());
854
-                prate.put("pointname", pgblist.get(0).getName());
855
-                prate.put("score", score);
856
-                prate.put("srate", srate);
857
-                prate.put("ques", pgblist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList()));
858
-                pointlist.add(prate);
859
-            }
860
-
861
-            pointJson = JSON.toJSONString(pointlist);
862
-            quesPointJson = JSON.toJSONString(quesplist);
863
-        }
864
-
865
-        MsPaperAnalyze epa = new MsPaperAnalyze();
866
-        epa.setMpid(paper.getMpid());
867
-        epa.setAlljson(JSON.toJSONString(ztmap));
868
-        epa.setQnumjson(JSON.toJSONString(qtlist));
869
-        epa.setComplexityjson(complexityJson);
870
-        epa.setPointjson(pointJson);
871
-        epa.setQuespointjson(quesPointJson);
872
-
873
-        // 判断试卷你是否有分析,如果没有直接保存
874
-        MsPaperAnalyze existEpa = msPaperAnalyzeMapper.getObjByMpId(paper.getMpid());
875
-        if (existEpa == null || !N_Utils.isTrueInteger(existEpa.getMpaid())) {
876
-            msPaperAnalyzeMapper.insertUseGeneratedKeys(epa);
877
-        } else {
878
-            epa.setMpaid(existEpa.getMpaid());
879
-            msPaperAnalyzeMapper.updateByPrimaryKey(epa);
880
-        }
881
-    }
882 250
 
883 251
 
884 252
     /*
@@ -1090,9 +458,7 @@ public class MsPaperQtypeService {
1090 458
 
1091 459
         // 保存完知识点难易度后,更新试卷分析
1092 460
         MsPaper apaper = msPaperMapper.selectByPrimaryKey(mpid);
1093
-        savePaperAnalyzeForFj(apaper);
1094
-
1095
-        // 生成考试报告中知识点难易度相关分析
461
+        msPaperAnalyzeService.savePaperAnalyzeForFj(apaper);
1096 462
     }
1097 463
 
1098 464
     /*
@@ -1142,7 +508,7 @@ public class MsPaperQtypeService {
1142 508
             List<MsPaperQtypeQuestionVo> qlist = qt.getQuestions();
1143 509
             List<MsPaperQtypeQuestionVo> rtnqlist = new ArrayList<>();//保存处理后的试题
1144 510
             String qpid = "";//母题id
1145
-            List<MsPaperQtypeQuestionVo> sonqlist = new ArrayList<>();
511
+            List<MsPaperQtypeQuestionVo> sonqlist;
1146 512
             for(MsPaperQtypeQuestionVo q : qlist){
1147 513
                 //试题类型1单题2母题3子题
1148 514
                 if(q.getQlevel() == 3){
@@ -1161,7 +527,7 @@ public class MsPaperQtypeService {
1161 527
                         mq.setQlevel(q.getMqlevel());
1162 528
                         mq.setHashear(q.getMhashear());
1163 529
                         mq.setHearfile(q.getMhearfile());
1164
-                        Double mscore = sonqlist.stream().collect(Collectors.summingDouble(MsPaperQtypeQuestionVo:: getQscore));
530
+                        Double mscore = sonqlist.stream().mapToDouble(MsPaperQtypeQuestionVo::getQscore).sum();
1165 531
                         mq.setQscore(mscore);
1166 532
 
1167 533
                         for(MsPaperQtypeQuestionVo sonQ : sonqlist){
@@ -1302,7 +668,7 @@ public class MsPaperQtypeService {
1302 668
         setPaperNumAndScore(paper);
1303 669
         msPaperMapper.updateByPrimaryKeySelective(paper);
1304 670
 
1305
-        savePaperAnalyzeForFj(paper);
671
+        msPaperAnalyzeService.savePaperAnalyzeForFj(paper);
1306 672
 
1307 673
         if (exam.getPstate() != 2) {
1308 674
             // 更改科目状态
@@ -1384,7 +750,7 @@ public class MsPaperQtypeService {
1384 750
         // 试卷中小题重新排序
1385 751
         chandleQuestionOrder(paper);
1386 752
 
1387
-        savePaperAnalyzeForFj(paper);
753
+        msPaperAnalyzeService.savePaperAnalyzeForFj(paper);
1388 754
         deletePaperOtherInfo(mpid);
1389 755
 
1390 756
         return new ResultVo(0, "保存成功", paper.getMpid());
@@ -1414,7 +780,7 @@ public class MsPaperQtypeService {
1414 780
         chandlePaperNumQtypeOrder(paper);
1415 781
 
1416 782
         // 重新生成试卷分析
1417
-        savePaperAnalyzeForFj(paper);
783
+        msPaperAnalyzeService.savePaperAnalyzeForFj(paper);
1418 784
         return new ResultVo(0, "删除成功", paper.getMpid());
1419 785
     }
1420 786
 
@@ -1638,8 +1004,6 @@ public class MsPaperQtypeService {
1638 1004
         if (paper == null || !N_Utils.isTrueInteger(paper.getPnum())) {
1639 1005
             paper = msPaperMapper.selectByPrimaryKey(mpid);
1640 1006
         }
1641
-        savePaperAnalyzeForFj(paper);
1007
+        msPaperAnalyzeService.savePaperAnalyzeForFj(paper);
1642 1008
     }
1643
-
1644
-
1645 1009
 }

+ 42
- 0
smarking/src/main/java/com/xhkjedu/smarking/service/report/generate/ReportGeneratePointService.java View File

@@ -2,11 +2,13 @@ package com.xhkjedu.smarking.service.report.generate;
2 2
 
3 3
 import com.alibaba.fastjson.JSON;
4 4
 import com.xhkjedu.smarking.mapper.paper.MsPaperAnalyzeMapper;
5
+import com.xhkjedu.smarking.mapper.paper.MsPaperMapper;
5 6
 import com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentPointMapper;
6 7
 import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectPointMapper;
7 8
 import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectPointRankgroupMapper;
8 9
 import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectPointSectionMapper;
9 10
 import com.xhkjedu.smarking.model.exam.MsClassStudent;
11
+import com.xhkjedu.smarking.model.paper.MsPaper;
10 12
 import com.xhkjedu.smarking.model.paper.MsPaperAnalyze;
11 13
 import com.xhkjedu.smarking.model.paper.MsPaperQtypeQuestion;
12 14
 import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
@@ -15,6 +17,7 @@ import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectPoint;
15 17
 import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectPointRankgroup;
16 18
 import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectPointSection;
17 19
 import com.xhkjedu.smarking.model.stupaper.MsPaperStudentQuestion;
20
+import com.xhkjedu.smarking.service.paper.MsPaperAnalyzeService;
18 21
 import com.xhkjedu.smarking.utils.MarkingUtil;
19 22
 import com.xhkjedu.smarking.vo.paper.QuestionPointVo;
20 23
 import com.xhkjedu.smarking.vo.report.reportother.RankGroupVo;
@@ -49,6 +52,10 @@ public class ReportGeneratePointService {
49 52
     private MsrSubjectPointRankgroupMapper msrSubjectPointRankgroupMapper;
50 53
     @Resource
51 54
     private MsrStudentPointMapper msrStudentPointMapper;
55
+    @Resource
56
+    private MsPaperMapper msPaperMapper;
57
+    @Resource
58
+    private MsPaperAnalyzeService msPaperAnalyzeService;
52 59
 
53 60
     //知识点分析,题库知识点按母题分析
54 61
     public void generatePoint(List<MsPaperStudentQuestion> stuSubjectQuestions, List<MsPaperQtypeQuestion> qtypeQuestions,List<MsClassStudent> classStus,
@@ -248,6 +255,24 @@ public class ReportGeneratePointService {
248 255
         classPoint.setJbzs(MarkingUtil.jbzs(stuScores, subjectPoint.getFullscore()));
249 256
         classPoint.setQns(subjectPoint.getQns());
250 257
         classPoint.setMptqids(subjectPoint.getMptqids());
258
+        //满分人
259
+        List<PointStudentVo> fullScoreStus = pointStuScores.stream().filter(q -> q.getStuscore().equals(subjectPoint.getFullscore())).collect(Collectors.toList());
260
+        if(fullScoreStus.isEmpty()){
261
+            classPoint.setMfnum(0);
262
+        }else{
263
+            classPoint.setMfnum(fullScoreStus.size());
264
+            classPoint.setMfids(fullScoreStus.stream().map(q -> q.getStudentid().toString()).collect(Collectors.joining(",")));
265
+        }
266
+
267
+        //零分人
268
+        List<PointStudentVo> zeroScoreStus = pointStuScores.stream().filter(q -> q.getStuscore()==0).collect(Collectors.toList());
269
+        if(fullScoreStus.isEmpty()){
270
+            classPoint.setLfnum(0);
271
+        }else{
272
+            classPoint.setLfnum(zeroScoreStus.size());
273
+            classPoint.setLfids(zeroScoreStus.stream().map(q -> q.getStudentid().toString()).collect(Collectors.joining(",")));
274
+        }
275
+
251 276
         return classPoint;
252 277
     }
253 278
 
@@ -590,4 +615,21 @@ public class ReportGeneratePointService {
590 615
             }
591 616
         }
592 617
     }
618
+
619
+
620
+    public void handleQuestionPointAndAnalyze(Integer mpid){
621
+        //获取试卷基础信息
622
+        MsPaper paper = msPaperMapper.selectByPrimaryKey(mpid);
623
+        //先生产学生报告
624
+        if(paper.getPtype() == 1){
625
+            msPaperAnalyzeService.savePaperAnalyzeForQuestion(paper);
626
+        }else{
627
+            msPaperAnalyzeService.savePaperAnalyzeForFj(paper);
628
+        }
629
+
630
+        //删除试卷试题信息
631
+        msrSubjectPointMapper.deletePointAnalyze(paper.getExamid(),paper.getSubjectid());
632
+
633
+
634
+    }
593 635
 }

+ 121
- 7
smarking/src/main/java/com/xhkjedu/smarking/service/report/report/MsrSubjectPointService.java View File

@@ -1,12 +1,14 @@
1 1
 package com.xhkjedu.smarking.service.report.report;
2 2
 
3 3
 import com.xhkjedu.smarking.mapper.exam.MsClassMapper;
4
+import com.xhkjedu.smarking.mapper.report.reportclass.MsrClassQuestionMapper;
4 5
 import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectPointMapper;
5 6
 import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectPointRankgroupMapper;
6 7
 import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectPointSectionMapper;
7 8
 import com.xhkjedu.smarking.model.exam.MsClass;
8 9
 import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectPoint;
9 10
 import com.xhkjedu.smarking.vo.report.reportother.ExamReportParams;
11
+import com.xhkjedu.utils.N_Utils;
10 12
 import org.springframework.stereotype.Service;
11 13
 
12 14
 import javax.annotation.Resource;
@@ -31,18 +33,68 @@ public class MsrSubjectPointService {
31 33
     private MsrSubjectPointSectionMapper msrSubjectPointSectionMapper;
32 34
     @Resource
33 35
     private MsClassMapper msClassMapper;
36
+    @Resource
37
+    private MsrClassQuestionMapper msrClassQuestionMapper;
34 38
 
35
-    //学科素养报告-标定知识点
36
-    public void listXksyQuestionPoints(ExamReportParams params){
37
-
39
+    //学科素养报告-标定知识点-试题知识点
40
+    public List<Map<String,Object>> listXksyQuestionPoints(ExamReportParams params){
41
+        //获取已标定试题知识点
42
+        return msrSubjectPointMapper.listQuestionPointsForXhsy(params);
38 43
     }
39 44
 
40 45
     //学科素养报告-知识点整体分析
41 46
     public Map<String,Object> listXksyPointZt(ExamReportParams params){
42 47
         //层级下所有知识点
43 48
         List<MsrSubjectPoint> points = msrSubjectPointMapper.listXksyPointsZt(params);
49
+        if(points.isEmpty()) return null;
50
+
44 51
         //获取全体学员的知识点
45 52
         List<MsrSubjectPoint> schoolPoints = points.stream().filter(p -> p.getClassid()==0).collect(Collectors.toList());
53
+        //根据全体的情况,做出分析诊断
54
+        //把知识点按照,满分排序
55
+        List<MsrSubjectPoint> fullScorePoints = schoolPoints.stream().sorted((p1,p2) -> p2.getFullscore().compareTo(p1.getFullscore())).collect(Collectors.toList());
56
+        //把知识点按照平均得分率排序
57
+        List<MsrSubjectPoint> avgRatePoints = schoolPoints.stream().sorted((p1,p2) -> p2.getAvgrate().compareTo(p1.getAvgrate())).collect(Collectors.toList());
58
+        String[] scoreFirst;
59
+        String[] scorelast;
60
+        String[] rateFrist;
61
+        String[] rateLast;
62
+        if(schoolPoints.size() >=4){
63
+            //前后各取两个
64
+            List<MsrSubjectPoint> firstScore = fullScorePoints.stream().limit(2).collect(Collectors.toList());
65
+            scoreFirst = new String[]{firstScore.get(0).getPointname(), firstScore.get(1).getPointname()};
66
+            List<MsrSubjectPoint> lastScore = fullScorePoints.stream().skip(fullScorePoints.size() - 2).collect(Collectors.toList());
67
+            scorelast = new String[]{lastScore.get(0).getPointname(), lastScore.get(1).getPointname()};
68
+
69
+            List<MsrSubjectPoint> firstRate = avgRatePoints.stream().limit(2).collect(Collectors.toList());
70
+            rateFrist = new String[]{firstRate.get(0).getPointname(), firstRate.get(1).getPointname()};
71
+            List<MsrSubjectPoint> lastRate = avgRatePoints.stream().skip(avgRatePoints.size() - 2).collect(Collectors.toList());
72
+            rateLast = new String[]{lastRate.get(0).getPointname(), lastRate.get(1).getPointname()};
73
+
74
+        }else if(fullScorePoints.size() <4 && avgRatePoints.size() >=2){
75
+            //前后各取1个
76
+            List<MsrSubjectPoint> firstScore = fullScorePoints.stream().limit(1).collect(Collectors.toList());
77
+            scoreFirst = new String[]{firstScore.get(0).getPointname()};
78
+            List<MsrSubjectPoint> lastScore = fullScorePoints.stream().skip(fullScorePoints.size() - 1).collect(Collectors.toList());
79
+            scorelast = new String[]{lastScore.get(0).getPointname()};
80
+
81
+            List<MsrSubjectPoint> firstRate = avgRatePoints.stream().limit(1).collect(Collectors.toList());
82
+            rateFrist = new String[]{firstRate.get(0).getPointname()};
83
+            List<MsrSubjectPoint> lastRate = avgRatePoints.stream().skip(avgRatePoints.size() - 1).collect(Collectors.toList());
84
+            rateLast = new String[]{lastRate.get(0).getPointname()};
85
+
86
+        }else{
87
+            //仅前获取一个
88
+            scoreFirst = new String[]{fullScorePoints.get(0).getPointname()};
89
+            scorelast = null;
90
+            rateFrist = new String[]{avgRatePoints.get(0).getPointname()};
91
+            rateLast = null;
92
+        }
93
+        Map<String,Object> zdjgMap = new HashMap<>();
94
+        zdjgMap.put("maxScore",scoreFirst);
95
+        zdjgMap.put("minScore",scorelast);
96
+        zdjgMap.put("maxRate",rateFrist);
97
+        zdjgMap.put("minRate",rateLast);
46 98
 
47 99
         //知识点结构平均得分率表格表头
48 100
         List<Map<String,Object>> pointTitles = schoolPoints.stream().map(p -> { Map<String,Object> map = new HashMap<>();
@@ -74,15 +126,77 @@ public class MsrSubjectPointService {
74 126
         }
75 127
 
76 128
         Map<String,Object> rtnMap = new HashMap<>();
77
-        rtnMap.put("schoolPoints",schoolPoints);
78
-        rtnMap.put("pointTitles",pointTitles);
79
-        rtnMap.put("pointClassList",pointClassList);
129
+        rtnMap.put("schoolPoints",schoolPoints);//全体知识点数据
130
+        rtnMap.put("zdjgMap",zdjgMap);//诊断结果
131
+        rtnMap.put("pointTitles",pointTitles);//平均得分率表格表头
132
+        rtnMap.put("pointClassList",pointClassList);//平均得分率数据
80 133
         return rtnMap;
81 134
     }
82 135
 
83 136
     //学科素养报告-单个知识点分析-知识点及知识点下试题
84
-    public void listXksyPointDg(ExamReportParams params){
137
+    public Map<Object,List<Map<String,Object>>> listXksyPointOneForPoints(ExamReportParams params){
138
+        //获取所有知识点,把知识点按层级分组
139
+        List<Map<String,Object>> points = msrSubjectPointMapper.listXksyPointsAll(params);
140
+        return points.stream().collect(Collectors.groupingBy(t -> t.get("pointlevel")));
141
+    }
142
+
143
+    //学科素养报告-单个知识点分析-知识点详情
144
+    public Map<String,Object> listXksyPointOneForPointDetail(ExamReportParams params){
145
+        //获取知识点点对应的试题数据
146
+        MsrSubjectPoint point = msrSubjectPointMapper.getXksyPointByPointid(params);
147
+        params.setMptqids(point.getMptqids());
148
+        //获取试题,试题详情图片暂未处理
149
+        List<Map<String,Object>> questions = msrClassQuestionMapper.listQuestionsForXksyOnePoint(params);
150
+        //结果图,把知识点情况取出
151
+        Map<String,Object> pointMap = new HashMap<>();
152
+        pointMap.put("spid",point.getSpid());
153
+        pointMap.put("fullscore",point.getFullscore());
154
+        pointMap.put("schoolavgscore",point.getAvgscore());
155
+        pointMap.put("schoolavgrate",point.getAvgrate());
156
+        pointMap.put("mfnum",point.getMfnum());
157
+        pointMap.put("lfnum",point.getLfnum());
158
+        questions.add(0,pointMap);
85 159
 
160
+        //知识点与总分的相关性曲线
161
+        List<Map<String,Object>> pointSections = msrSubjectPointSectionMapper.listXhsySections(params);
162
+        //知识点考生分组分析
163
+        List<Map<String,Object>> rankgroups = msrSubjectPointRankgroupMapper.listXksyPointOneRankgroup(params);
164
+        //表格头部信息
165
+        List<Object> groupRankTitles = rankgroups.stream().filter(r ->N_Utils.isEmpty(r.get("rsection"))).map(r -> r.get("rgroup")).distinct().collect(Collectors.toList());
166
+        List<Object> rsections = rankgroups.stream().map(m -> m.get("rsection")).distinct().collect(Collectors.toList());
167
+        //分组分数分布表
168
+        List<Map<String,Object>> groupRankList = new ArrayList<>();
169
+        for(Object rsection : rsections){
170
+            if(N_Utils.isNotEmpty(rsection)){
171
+                List<Map<String,Object>> rsectionList = rankgroups.stream().filter(m -> m.get("rsection").equals(rsection)).collect(Collectors.toList());
172
+                Map<String,Object> rsMap = new HashMap<>();
173
+                rsMap.put("rsection",rsection);
174
+                rsMap.put("groupranks",rsectionList);
175
+                groupRankList.add(rsMap);
176
+            }else{
177
+                List<Map<String,Object>> rsectionList = rankgroups.stream().filter(m -> N_Utils.isEmpty(m.get("rsection"))).collect(Collectors.toList());
178
+                Map<String,Object> rsMap = new HashMap<>();
179
+                rsMap.put("rsection","合计");
180
+                rsMap.put("groupranks",rsectionList);
181
+                groupRankList.add(rsMap);
182
+
183
+                Map<String,Object> dflMap = new HashMap<>();
184
+                dflMap.put("rsection","得分率");
185
+                dflMap.put("groupranks",rsectionList);
186
+                groupRankList.add(dflMap);
187
+            }
188
+        }
189
+        //各班知识点对比
190
+        List<Map<String,Object>> classPointList = msrSubjectPointMapper.listXksyPointsForAllClass(params);
191
+
192
+        //返回试题基础信息
193
+        Map<String,Object> rtnMap = new HashMap<>();
194
+        rtnMap.put("questions",questions);//知识点下试题
195
+        rtnMap.put("pointSections",pointSections);//知识点与总分的相关性
196
+        rtnMap.put("groupRankTitles",groupRankTitles);//分组分数分布-表头
197
+        rtnMap.put("groupRankList",groupRankList);//分组分数分布-数据
198
+        rtnMap.put("classPointList",classPointList);//各班知识点对比
199
+        return rtnMap;
86 200
     }
87 201
 
88 202
 }

+ 5
- 5
smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java View File

@@ -786,10 +786,10 @@ public class MarkingUtil {
786 786
     }
787 787
 
788 788
     public static void main(String[] args) {
789
-        List<String> options = Arrays.asList("A","B","D","F","","C","E");
790
-        List<String> newOptions = options.stream().map(s -> s != null && !s.isEmpty() ? s : "未作答").sorted().collect(Collectors.toList());
791
-        for (String option : newOptions) {
792
-            System.out.println(option);
793
-        }
789
+       List<RankGroupVo> list = fdScore(1.0,5);
790
+       for (RankGroupVo rgvo : list) {
791
+           System.out.println(rgvo.getGroupname() + ";" + rgvo.getMinvalue() + "-" + rgvo.getMaxvalue());
792
+
793
+       }
794 794
     }
795 795
 }

+ 6
- 0
smarking/src/main/java/com/xhkjedu/smarking/vo/report/reportother/ExamReportParams.java View File

@@ -31,4 +31,10 @@ public class ExamReportParams {
31 31
     private Integer rgtype;//客观题选项 2客/主分值
32 32
 
33 33
     private Integer pointlevel;//1一级知识点2二级知识点3三级知识点
34
+
35
+    private String pointid;//知识点ID
36
+
37
+    private String mptqids;//多个试题id
38
+
39
+    private Integer spid;//id
34 40
 }

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

@@ -4,7 +4,7 @@
4 4
 
5 5
     <!--根据msid查询试卷模板列表-->
6 6
     <select id="listTemplatesByMpid" resultType="java.util.Map">
7
-        select t.mtid,t.mpid,t.currstep,t.tstate,t.createtime,t.tfront,t.tback from ms_template t
7
+        select t.mtid,t.mpid,t.currstep,t.tstate,t.createtime,t.tfront,t.tback,t.blankindex,t.anglefront,t.angleback from ms_template t
8 8
         left join ms_paper p on t.mpid=p.mpid
9 9
         where p.mpid=#{mpid} order by t.createtime desc
10 10
     </select>

+ 9
- 0
smarking/src/main/resources/mapper/report/reportclass/MsrClassQuestionMapper.xml View File

@@ -130,6 +130,15 @@
130 130
         and cq.subjectid=#{param.subjectid} and cq.classid=0 and cq.mptqid=#{param.mptqid}
131 131
     </select>
132 132
 
133
+    <!--学科素养-单个知识点分析-知识点下试题-->
134
+    <select id="listQuestionsForXksyOnePoint" resultType="java.util.Map">
135
+        select distinct cq.cqid,cq.mptqid,cq.qn,cq.fullscore,cq.schoolavgscore,cq.schoolavgrate,cq.mfnum,
136
+                        cq.lfnum,cq.qtype,q.stemcoor,q.quecoor
137
+        from msr_class_question cq left join ms_paper_qtype_question q on cq.mptqid=q.mptqid
138
+        where cq.examid=#{param.examid} and cq.subjectid=#{param.subjectid} and cq.classid=0
139
+        and cq.mptqid in (${param.mptqids}) order by cq.cqid
140
+    </select>
141
+
133 142
 
134 143
 
135 144
 </mapper>

+ 53
- 0
smarking/src/main/resources/mapper/report/reportsubject/MsrSubjectPointMapper.xml View File

@@ -9,9 +9,62 @@
9 9
         and p.schoolid=(select schoolid from ms_exam where examid=#{examid} limit 1))) order by p.pointlevel,p.pointorder
10 10
     </select>
11 11
 
12
+    <!--学科素养-标定知识点-试题知识点-->
13
+    <resultMap id="questionPoints" type="java.util.Map">
14
+        <result property="mptqid" column="mptqid"/>
15
+        <result property="fullscore" column="fullscore"/>
16
+        <result property="schoolavgscore" column="schoolavgscore"/>
17
+        <result property="schoolavgrate" column="schoolavgrate"/>
18
+        <result property="questionid" column="questionid"/>
19
+        <result property="questionpid" column="questionpid"/>
20
+        <collection property="points" ofType="java.util.Map" javaType="java.util.ArrayList">
21
+            <result property="pointid" column="pointid"/>
22
+            <result property="pointname" column="pointname"/>
23
+            <result property="mpid" column="mpid"/>
24
+        </collection>
25
+    </resultMap>
26
+    <select id="listQuestionPointsForXhsy" resultMap="questionPoints">
27
+        select distinct cq.mptqid,cq.fullscore,cq.schoolavgscore,cq.schoolavgrate,q.questionid,
28
+        q.questionpid,qp.pointid,qp.pointname,qp.mpid
29
+        from msr_class_question cq
30
+        left join ms_paper_qtype_question q on cq.mptqid=q.mptqid
31
+        left join ms_paper_qtype_question_point qp on cq.mptqid=qp.mptqid
32
+        where cq.examid=#{param.examid} and cq.subjectid=#{param.subjectid} and cq.classid=0 order by cq.qorder
33
+    </select>
34
+
12 35
     <!--学科素养-知识点整体分析-级别下知识点-->
13 36
     <select id="listXksyPointsZt" resultType="com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectPoint">
14 37
         select * from msr_subject_point where examid=#{param.examid} and subjectid=#{param.subjectid} and pointlevel=#{param.pointlevel} order by spid
15 38
     </select>
16 39
 
40
+    <!--学科素养-单个知识点分析-所有知识点-->
41
+    <select id="listXksyPointsAll" resultType="java.util.Map">
42
+        select spid,pointid,pointname,pointlevel from msr_subject_point
43
+        where examid=#{param.examid} and subjectid=#{param.subjectid} and classid=0 order by pointlevel,spid
44
+    </select>
45
+
46
+    <!--学科素养-单个知识点分析-知识点详情-->
47
+    <select id="getXksyPointByPointid" resultType="com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectPoint">
48
+        select spid,fullscore,avgscore,avgrate,mptqids,mfnum,lfnum from msr_subject_point where examid=#{param.examid} and subjectid=#{param.subjectid} and classid=0
49
+        and pointlevel=#{param.pointlevel} and pointid=#{param.pointid} limit 1
50
+    </select>
51
+
52
+    <!--学科素养-单个知识点分析-各班知识点对比-->
53
+    <select id="listXksyPointsForAllClass" resultType="java.util.Map">
54
+        select p.classid,p.fullscore,p.maxscore,p.minscore,p.avgscore,p.avgrate,
55
+        p.bzc,p.cyxs,c.classname from msr_subject_point p
56
+        left join ms_class c on p.examid=c.examid and p.subjectid=c.subjectid and p.classid=c.classid
57
+        where p.examid=#{param.examid} and p.subjectid=#{param.subjectid} and p.pointid=#{param.pointid} and p.pointlevel=#{param.pointlevel}
58
+        order by p.spid
59
+    </select>
60
+
61
+    <!--删除知识点相关报告-->
62
+    <delete id="deletePointAnalyze">
63
+        delete from msr_student_point where examid = #{examid} and subjectid=#{subjectid};
64
+        delete from msr_subject_point where examid = #{examid} and subjectid=#{subjectid};
65
+        delete from msr_subject_point_section where examid = #{examid} and subjectid=#{subjectid};
66
+        delete from msr_subject_question_rankgroup where examid = #{examid} and subjectid=#{subjectid};
67
+        delete from msr_subject_question_section where examid = #{examid} and subjectid=#{subjectid};
68
+    </delete>
69
+
17 70
 </mapper>

+ 6
- 0
smarking/src/main/resources/mapper/report/reportsubject/MsrSubjectPointRankgroupMapper.xml View File

@@ -1,4 +1,10 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectPointRankgroupMapper">
4
+
5
+    <!--学科素养-单个知识点分析-知识点考试分组分析-->
6
+    <select id="listXksyPointOneRankgroup" resultType="java.util.Map">
7
+        select spgid,rgroup,rsection,stunum,stuids from msr_subject_point_rankgroup where examid=#{param.examid}
8
+            and subjectid=#{param.subjectid}  and pointlevel=#{param.pointlevel} and pointid=#{param.pointid} order by spgid
9
+    </select>
4 10
 </mapper>

+ 6
- 0
smarking/src/main/resources/mapper/report/reportsubject/MsrSubjectPointSectionMapper.xml View File

@@ -1,4 +1,10 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectPointSectionMapper">
4
+
5
+    <!--学科素养-单个知识点分析-知识点与总分的相关性曲线-->
6
+    <select id="listXhsySections" resultType="java.util.Map">
7
+        select fdfw,avgscore,avgrate from msr_subject_point_section where subjectid = #{param.subjectid} and
8
+        examid=#{param.examid} and pointid=#{param.pointid} and pointlevel = #{param.pointlevel} order by spsid
9
+    </select>
4 10
 </mapper>

Loading…
Cancel
Save