Pārlūkot izejas kodu

优化生成报告,是否生成pdf添加配置

tags/正式3.13.5
王宁 pirms 11 mēnešiem
vecāks
revīzija
7acbe5a886

+ 7
- 0
sexam/src/main/java/com/xhkjedu/sexam/config/ConfigKey.java Parādīt failu

@@ -76,4 +76,11 @@ public class ConfigKey {
76 76
         ConfigKey.ipregiondb = ipregiondb;
77 77
     }
78 78
 
79
+    public static boolean examHaspdf;//考试是否生产pdf报告
80
+
81
+    @Value("${exam.haspdf}")
82
+    public void setExamHaspdf(boolean examHaspdf){
83
+        ConfigKey.examHaspdf = examHaspdf;
84
+    }
85
+
79 86
 }

+ 2
- 1
sexam/src/main/java/com/xhkjedu/sexam/controller/exam/EBaseController.java Parādīt failu

@@ -275,6 +275,7 @@ public class EBaseController {
275 275
         try {
276 276
             eBase.setExammode(exammode);
277 277
             eBaseService.updateExamStateEnd(eBase);
278
+
278 279
             eReportGenerateService.generateExamReport(eBase.getExamid(), eBase.getCreateid());
279 280
             return new ResultVo(0, "结束成功");
280 281
         } catch (Exception e) {
@@ -458,7 +459,7 @@ public class EBaseController {
458 459
             eBaseService.generateExamReport(examid, createid);
459 460
             return new ResultVo(0, "生成成功");
460 461
         } catch (Exception e) {
461
-            log.error("生成失败:"+e.getMessage());
462
+            log.error("生成失败:" + e.getMessage());
462 463
             return new ResultVo(1, "生成失败");
463 464
         }
464 465
     }

+ 1
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/exam/EBaseService.java Parādīt failu

@@ -72,6 +72,7 @@ public class EBaseService {
72 72
             model.setStushowrank(0);
73 73
             model.setDeleted(1);
74 74
             model.setReportstate(0);
75
+            model.setStuzero(1);//0分学生是否参与统计0不统计1统计
75 76
             model.setCreatetime(N_Utils.getSecondTimestamp());
76 77
 
77 78
             //考试关联班级,获取班级关联学校

+ 61
- 54
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateQuestionService.java Parādīt failu

@@ -59,65 +59,72 @@ public class EReportGenerateQuestionService {
59 59
     @Resource
60 60
     private ERStudentComplexityMapper erStudentComplexityMapper;
61 61
 
62
-    public void setClassQuestion(Integer examid, List<Map> subjects, List<Map> classes, EBase base){
63
-        Integer stuzero = base.getStuzero();//0分学生是否参与统计0不统计1统计(默认)
64
-        // 考试所有学生提交试卷作答情况 2023-12-27添加0分学生是否参与统计
65
-        List<EPaperStudentQuestion> stulist = ePaperStudentQuestionMapper.listExamStudentsAnswer(examid);
66
-        if (N_Utils.isListNotEmpty(stulist)) {
67
-            List<ERclassQtype> rtypelist = new ArrayList<>();// 班级题型
68
-            List<ERStudentQtype> stutypelist = new ArrayList<>();// 学生题型
69
-            List<ERclassQuestion> rqueslist = new ArrayList<>();// 班级试题
70
-            List<ERclassPoint> rpointlist = new ArrayList<>();// 班级知识点
71
-            List<ERstudentPoint> stupointlist = new ArrayList<>();// 学生知识点
72
-            List<ERclassComplexity> complist = new ArrayList<>();// 班级难易度
73
-            List<ERStudentComplexity> stucomplist = new ArrayList<>();// 学生难易度
74
-
75
-            for (Map map : subjects) {
76
-                String subjectid = map.get("subjectid").toString();
77
-                Integer epid = Integer.parseInt(map.get("epid").toString());// 获取试卷id
78
-                Integer ptype = Integer.parseInt(map.get("ptype").toString());// 试卷类型1题库2附件
79
-                ExamPaperClassVo examPaperClassVo = new ExamPaperClassVo();
80
-                examPaperClassVo.setExamid(examid);
81
-                examPaperClassVo.setEpid(epid);
82
-                examPaperClassVo.setSubjectid(subjectid);
83
-                examPaperClassVo.setClasses(classes);
84
-
85
-                // 获取试卷本身的分析
86
-                Map panalyze = ePaperAnalyzeMapper.getPaperAnalzyeByEpid(epid);
87
-                // 获取指定试卷学生作答情况
88
-                List<EPaperStudentQuestion> paperstulist = stulist.stream().filter(s -> s.getEpid().equals(epid)).collect(Collectors.toList());
89
-                if (N_Utils.isListNotEmpty(paperstulist)) {
90
-                    if (ptype == 1) {
91
-                        // 处理题型下试题:题库显示题号时为母题的题号即order(qn是英语为顺延题号其他学科为母题号和子题排序拼接)
92
-                        String qtypejson = panalyze.get("qnumjson").toString();// 原试卷题型分析
93
-                        List<Map> qtypelist = JSON.parseArray(qtypejson, Map.class);
94
-                        setPaperQuestionTkQtypes(qtypelist, paperstulist, rtypelist, rqueslist, stutypelist, examPaperClassVo, stuzero);
95
-
96
-                        // 处理知识点
97
-                        setEPaperQuestionPoints(panalyze, paperstulist, rpointlist, stupointlist, examPaperClassVo, stuzero);
98
-
99
-                        // 处理难易度
100
-                        String complexityjson = panalyze.get("complexityjson").toString();
101
-                        List<Map> complexitylist = JSON.parseArray(complexityjson, Map.class);
102
-                        setEPaperQuestionComplexitys(complexitylist, paperstulist, complist, stucomplist, examPaperClassVo, stuzero);
62
+    public void setClassQuestion(Integer examid, List<Map> subjects, List<Map> classes, EBase base) throws Exception {
63
+
64
+        try {
65
+            Integer stuzero = base.getStuzero();//0分学生是否参与统计0不统计1统计(默认)
66
+            // 考试所有学生提交试卷作答情况 2023-12-27添加0分学生是否参与统计
67
+            List<EPaperStudentQuestion> stulist = ePaperStudentQuestionMapper.listExamStudentsAnswer(examid);
68
+            if (N_Utils.isListNotEmpty(stulist)) {
69
+                List<ERclassQtype> rtypelist = new ArrayList<>();// 班级题型
70
+                List<ERStudentQtype> stutypelist = new ArrayList<>();// 学生题型
71
+                List<ERclassQuestion> rqueslist = new ArrayList<>();// 班级试题
72
+                List<ERclassPoint> rpointlist = new ArrayList<>();// 班级知识点
73
+                List<ERstudentPoint> stupointlist = new ArrayList<>();// 学生知识点
74
+                List<ERclassComplexity> complist = new ArrayList<>();// 班级难易度
75
+                List<ERStudentComplexity> stucomplist = new ArrayList<>();// 学生难易度
76
+
77
+                for (Map map : subjects) {
78
+                    String subjectid = map.get("subjectid").toString();
79
+                    Integer epid = Integer.parseInt(map.get("epid").toString());// 获取试卷id
80
+                    Integer ptype = Integer.parseInt(map.get("ptype").toString());// 试卷类型1题库2附件
81
+                    ExamPaperClassVo examPaperClassVo = new ExamPaperClassVo();
82
+                    examPaperClassVo.setExamid(examid);
83
+                    examPaperClassVo.setEpid(epid);
84
+                    examPaperClassVo.setSubjectid(subjectid);
85
+                    examPaperClassVo.setClasses(classes);
86
+
87
+                    // 获取试卷本身的分析
88
+                    Map panalyze = ePaperAnalyzeMapper.getPaperAnalzyeByEpid(epid);
89
+                    // 获取指定试卷学生作答情况
90
+                    List<EPaperStudentQuestion> paperstulist = stulist.stream().filter(s -> s.getEpid().equals(epid)).collect(Collectors.toList());
91
+                    if (N_Utils.isListNotEmpty(paperstulist)) {
92
+                        if (ptype == 1) {
93
+                            // 处理题型下试题:题库显示题号时为母题的题号即order(qn是英语为顺延题号其他学科为母题号和子题排序拼接)
94
+                            String qtypejson = panalyze.get("qnumjson").toString();// 原试卷题型分析
95
+                            List<Map> qtypelist = JSON.parseArray(qtypejson, Map.class);
96
+                            setPaperQuestionTkQtypes(qtypelist, paperstulist, rtypelist, rqueslist, stutypelist, examPaperClassVo, stuzero);
97
+
98
+                            // 处理知识点
99
+                            setEPaperQuestionPoints(panalyze, paperstulist, rpointlist, stupointlist, examPaperClassVo, stuzero);
100
+
101
+                            // 处理难易度
102
+                            String complexityjson = panalyze.get("complexityjson").toString();
103
+                            List<Map> complexitylist = JSON.parseArray(complexityjson, Map.class);
104
+                            setEPaperQuestionComplexitys(complexitylist, paperstulist, complist, stucomplist, examPaperClassVo, stuzero);
103 105
 
104
-                    } else {
105
-                        // 处理题型及题型下试题:附件显示题号为qn(order)作为排序使用
106
-                        String qtypejson = panalyze.get("qnumjson").toString();// 原试卷题型分析
107
-                        List<Map> qtypelist = JSON.parseArray(qtypejson, Map.class);
108
-                        setPaperQuestionFjQtypes(qtypelist, paperstulist, rtypelist, rqueslist, stutypelist, examPaperClassVo,stuzero);
106
+                        } else {
107
+                            // 处理题型及题型下试题:附件显示题号为qn(order)作为排序使用
108
+                            String qtypejson = panalyze.get("qnumjson").toString();// 原试卷题型分析
109
+                            List<Map> qtypelist = JSON.parseArray(qtypejson, Map.class);
110
+                            setPaperQuestionFjQtypes(qtypelist, paperstulist, rtypelist, rqueslist, stutypelist, examPaperClassVo,stuzero);
111
+                        }
109 112
                     }
110 113
                 }
111
-            }
112 114
 
113
-            eRclassQtypeMapper.insertList(rtypelist);
114
-            eRstudentQtypeMapper.insertList(stutypelist);
115
-            eRclassQuestionMapper.insertList(rqueslist);
116
-            if (N_Utils.isListNotEmpty(complist)) eRclassComplexityMapper.insertList(complist);
117
-            if (N_Utils.isListNotEmpty(stucomplist)) erStudentComplexityMapper.insertList(stucomplist);
118
-            if (N_Utils.isListNotEmpty(rpointlist)) eRclassPointMapper.insertList(rpointlist);
119
-            if (N_Utils.isListNotEmpty(stupointlist)) eRstudentPointMapper.insertList(stupointlist);
115
+                eRclassQtypeMapper.insertList(rtypelist);
116
+                eRstudentQtypeMapper.insertList(stutypelist);
117
+                eRclassQuestionMapper.insertList(rqueslist);
118
+                if (N_Utils.isListNotEmpty(complist)) eRclassComplexityMapper.insertList(complist);
119
+                if (N_Utils.isListNotEmpty(stucomplist)) erStudentComplexityMapper.insertList(stucomplist);
120
+                if (N_Utils.isListNotEmpty(rpointlist)) eRclassPointMapper.insertList(rpointlist);
121
+                if (N_Utils.isListNotEmpty(stupointlist)) eRstudentPointMapper.insertList(stupointlist);
122
+            }
123
+        }catch (Exception e){
124
+            log.error("生成试题相关报告出错:" + e.getMessage());
125
+            throw new Exception("生成试题相关报告失败");
120 126
         }
127
+
121 128
     }
122 129
 
123 130
     // 题型、试题、知识点、难易度--处理学生选项情况和得分情况

+ 5
- 2
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java Parādīt failu

@@ -1,6 +1,7 @@
1 1
 package com.xhkjedu.sexam.service.report;
2 2
 
3 3
 import com.alibaba.fastjson.JSON;
4
+import com.xhkjedu.sexam.config.ConfigKey;
4 5
 import com.xhkjedu.sexam.mapper.exam.EBaseMapper;
5 6
 import com.xhkjedu.sexam.mapper.exam.EClassMapper;
6 7
 import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentMapper;
@@ -296,7 +297,9 @@ public class EReportGenerateService {
296 297
 
297 298
         setAction(examid, userMap);//行为分析
298 299
         eBaseMapper.updateExamState(examid,3);
299
-        htmlToPdf(examid, classes, schoolStudents, userMap2);//考试报告html转pdf
300
+        if(ConfigKey.examHaspdf){
301
+            htmlToPdf(examid, classes, schoolStudents, userMap2);//考试报告html转pdf
302
+        }
300 303
     }
301 304
 
302 305
     /**
@@ -1905,7 +1908,7 @@ public class EReportGenerateService {
1905 1908
 
1906 1909
     //题型、试题、知识点
1907 1910
     @Transactional(rollbackFor = Exception.class)
1908
-    public void saveClassQuestions(Integer examid) {
1911
+    public void saveClassQuestions(Integer examid) throws Exception {
1909 1912
         List<Map> classes = eClassMapper.listByExamId(examid);
1910 1913
         Integer exammode = eReportGenerateMapper.getExamModeById(examid);
1911 1914
         List<Map> subjects = eReportGenerateMapper.listSubject(examid, exammode);

+ 2
- 0
sexam/src/main/resources/application.properties Parādīt failu

@@ -96,6 +96,8 @@ exam.face=https://face.xhkjedu.com/
96 96
 
97 97
 #配置考试结束时间范围
98 98
 exam.endtime=30
99
+#是否生产pdf报告true生成false不生成
100
+exam.haspdf=false
99 101
 
100 102
 #开启spring的aop配置,默认true
101 103
 spring.aop.auto=true

Notiek ielāde…
Atcelt
Saglabāt