Browse Source

pdf报告保存设置,暂未对接mq

tags/正式版本
王宁 2 years ago
parent
commit
ecab8b1c2b

+ 1
- 17
sexam/src/main/java/com/xhkjedu/sexam/controller/exam/EBaseController.java View File

@@ -460,8 +460,7 @@ public class EBaseController {
460 460
         Integer createid = eBase.getCreateid();
461 461
         N_Utils.validation(new Object[]{examid, "考试id", 1, createid, "操作人", 1});
462 462
         try {
463
-            eReportGenerateService.generateExamReport(examid, createid);
464
-            eBaseService.updateExamReport(examid);
463
+            eBaseService.generateExamReport(examid, createid);
465 464
             return new ResultVo(0, "生成成功");
466 465
         } catch (Exception e) {
467 466
             return new ResultVo(1, "生成失败");
@@ -500,19 +499,4 @@ public class EBaseController {
500 499
         return new ResultVo(0, "获取考试状态成功", examstate);
501 500
     }
502 501
 
503
-    /**
504
-     * @Description  生成报告pdf
505
-     * @Param [eBase]
506
-     * @Return com.xhkjedu.vo.ResultVo
507
-     * @Author wn
508
-     * @Date 2022/10/8 11:29
509
-     **/
510
-    @PostMapping("/srep")
511
-    public ResultVo saveReportPath(@RequestBody EBase eBase) {
512
-        Integer examid = eBase.getExamid();
513
-        String reportpath = eBase.getReportpath();
514
-        N_Utils.validation(new Object[]{examid, "考试id", 1,reportpath,"报告地址",2});
515
-        eBaseService.updateExamReportPath(examid,reportpath);
516
-        return new ResultVo(0, "保存报告成功");
517
-    }
518 502
 }

+ 6
- 8
sexam/src/main/java/com/xhkjedu/sexam/mapper/exam/EBaseMapper.java View File

@@ -21,14 +21,12 @@ public interface EBaseMapper extends TkMapper<EBase> {
21 21
     //修改考试状态
22 22
     void updateExamState(@Param("examid") Integer examid, @Param("examstate") int examstate);
23 23
 
24
-    //修改考试状态和报告时间
25
-    void updateExamStateAndReport(@Param("e")EBase e);
26
-
27
-    //修改是否需要生成报告pdf
28
-    void updateExamReport(@Param("examid") Integer examid, @Param("reportneed") int reportneed);
29
-
30
-    //修改生成报告pdf地址
31
-    void updateExamReportPath(@Param("examid") Integer examid, @Param("reportneed") int reportneed,@Param("reportpath") String reportpath);
24
+    //结束考试更改状态和报告状态
25
+    void updateExamStateAndReportState(@Param("examid") Integer examid, @Param("examstate") int examstate);
26
+    //修改报告pdf后
27
+    void updateExamReportSchoolState(@Param("examid") Integer examid, @Param("reportstate") int reportstate,@Param("reportschool")String reportschool);
28
+    //更改pdf报告生成状态
29
+    void updateExamReportState(@Param("examid") Integer examid, @Param("reportstate") int reportstate);
32 30
 
33 31
     //考试基本信息
34 32
     Map findById(@Param("examid") Integer examid);

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/exam/EClassMapper.java View File

@@ -44,4 +44,7 @@ public interface EClassMapper extends TkMapper<EClass> {
44 44
 
45 45
     //班级选择列表
46 46
     List<Map> listBj(@Param("schoolid") Integer schoolid, @Param("teacherid") Integer teacherid);
47
+
48
+    //批量更新班级pdf报告地址
49
+    void updateBatchReportpath(@Param("list")List<EClass> list);
47 50
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/exam/EClassStudentMapper.java View File

@@ -25,4 +25,7 @@ public interface EClassStudentMapper extends TkMapper<EClassStudent> {
25 25
 
26 26
     //更加考试id和学生id获取班级id
27 27
     Integer getClassidByStudentidAndExamid(@Param("examid")Integer examid,@Param("studentid")Integer studentid);
28
+
29
+    //批量生成学生pdf报告
30
+    void updateBatchReportstupath(@Param("list")List<EClassStudent> list);
28 31
 }

+ 4
- 4
sexam/src/main/java/com/xhkjedu/sexam/model/exam/EBase.java View File

@@ -51,11 +51,11 @@ public class EBase extends BaseBean {
51 51
     //学校id
52 52
     private Integer schoolid;
53 53
 
54
-    private Integer reporttime;//生成报告时间(网页端)
54
+    //pdf报告状态0未生成1正在生成中2完成
55
+    private Integer reportstate;
55 56
 
56
-    private Integer reportneed;//是否需要生成报告(pdf)
57
-
58
-    private String reportpath;//报告地址
57
+    //学校报告地址
58
+    private String reportschool;
59 59
 
60 60
     @Transient
61 61
     //班级ids

+ 6
- 0
sexam/src/main/java/com/xhkjedu/sexam/model/exam/EClass.java View File

@@ -24,4 +24,10 @@ public class EClass extends BaseBean {
24 24
 
25 25
     //班级名称
26 26
     private String classname;
27
+
28
+    //班级pdf报告地址
29
+    private String reportclass;
30
+
31
+    //班级学生报告地址
32
+    private String reportstu;
27 33
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/model/exam/EClassStudent.java View File

@@ -23,6 +23,9 @@ public class EClassStudent extends BaseBean {
23 23
     //学生id
24 24
     private Integer studentid;
25 25
 
26
+    //学生pdf报告
27
+    private String reportstu;
28
+
26 29
     @Transient
27 30
     //学生姓名
28 31
     private String studentname;

+ 20
- 11
sexam/src/main/java/com/xhkjedu/sexam/service/exam/EBaseService.java View File

@@ -67,7 +67,7 @@ public class EBaseService {
67 67
             //考试
68 68
             model.setExamstate(0);
69 69
             model.setDeleted(1);
70
-            model.setReportneed(0);
70
+            model.setReportstate(0);
71 71
             model.setCreatetime(N_Utils.getSecondTimestamp());
72 72
             eBaseMapper.insertUseGeneratedKeys(model);
73 73
             Integer examid = model.getId();
@@ -264,10 +264,9 @@ public class EBaseService {
264 264
         try {
265 265
             ePaperStudentMapper.updateStuscoreByExamId(eBase.getExamid());//更新未已提交未批阅完成学生得分
266 266
             eReportGenerateService.generateExamReport(eBase.getExamid(), eBase.getCreateid());
267
-            eBase.setReporttime(N_Utils.getSecondTimestamp());
268
-            eBase.setReportneed(1);
269
-            eBase.setExamstate(2);
270
-            eBaseMapper.updateExamStateAndReport(eBase);
267
+            eBaseMapper.updateExamState(eBase.getExamid(),2);
268
+//            eBaseMapper.updateExamStateAndReportState(eBase.getExamid(),2);
269
+            //结束考试时自动生成报告pdf,调用mq
271 270
         } catch (Exception e) {
272 271
             log.error("结束考试失败", e);
273 272
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -400,13 +399,23 @@ public class EBaseService {
400 399
         return eBaseMapper.getExamStateAnseredById(examid);
401 400
     }
402 401
 
403
-    //修改是否需要生成报告pdf
404
-    public void updateExamReport(Integer examid){
405
-        eBaseMapper.updateExamReport(examid,1);
402
+    //生成报告
403
+    public void generateExamReport(Integer examid,Integer createid) throws Exception{
404
+        eReportGenerateService.generateExamReport(examid, createid);
405
+        //生成网页报告后生成pdf报告,发送mq
406
+//        eBaseMapper.updateExamReportState(examid,1);
406 407
     }
407 408
 
408
-    //修改生成报告pdf地址
409
-    public void updateExamReportPath(Integer examid,String reportpath){
410
-        eBaseMapper.updateExamReportPath(examid,0,reportpath);
409
+    //修改生成的报告pdf地址
410
+    @Transactional(rollbackFor = Exception.class)
411
+    public void updateExamReportstate(Map map){
412
+        Integer converted = Integer.parseInt(map.get("converted").toString());
413
+        Integer examid = Integer.parseInt(map.get("examid").toString());
414
+        String reportschool = "";
415
+        if(converted == 2){
416
+            reportschool = map.get("reportschool").toString();
417
+            //更改班级报告、学生报告
418
+        }
419
+        eBaseMapper.updateExamReportSchoolState(examid,converted,reportschool);
411 420
     }
412 421
 }

+ 9
- 9
sexam/src/main/resources/mapper/exam/EBaseMapper.xml View File

@@ -40,17 +40,17 @@
40 40
     <update id="updateExamState">
41 41
         update e_base set examstate=#{examstate} where examid=#{examid}
42 42
     </update>
43
-    <!--修改考试状态和报告时间-->
44
-    <update id="updateExamStateAndReport">
45
-        update e_base set examstate=#{e.examstate},reporttime=#{e.reporttime},reportneed=#{e.reportneed} where examid=#{e.examid}
43
+    <!--结束考试更改状态和报告状态-->
44
+    <update id="updateExamStateAndReportState">
45
+        update e_base set examstate=#{examstate},reportstate=1 where examid=#{examid}
46 46
     </update>
47
-    <!--修改是否需要生成报告pdf-->
48
-    <update id="updateExamReport">
49
-        update e_base set reportneed=#{reportneed} where examid=#{examid}
47
+    <!--更改pdf报告生成状态-->
48
+    <update id="updateExamReportState">
49
+        update e_base set reportstate=#{reportstate} where examid=#{examid}
50 50
     </update>
51
-    <!--修改生成报告pdf地址-->
52
-    <update id="updateExamReportPath">
53
-        update e_base set reportpath=#{reportpath},reportneed=#{reportneed} where examid=#{examid}
51
+    <!--修改报告pdf后-->
52
+    <update id="updateExamReportSchoolState">
53
+        update e_base set reportstate=#{reportstate},reportschool=#{reportschool} where examid=#{examid}
54 54
     </update>
55 55
 
56 56
     <!--发布考试-->

+ 21
- 0
sexam/src/main/resources/mapper/exam/EClassMapper.xml View File

@@ -105,4 +105,25 @@
105 105
         </if>
106 106
         order by c.gradeid,c.classtype,c.classorder,c.classid desc
107 107
     </select>
108
+
109
+    <!--批量更新班级pdf报告地址-->
110
+    <update id="updateBatchReportpath">
111
+        update e_class
112
+        <trim prefix="set" suffixOverrides=",">
113
+            <trim prefix="reportclass = CASE " suffix="END,">
114
+                <foreach collection="list" index="index" item="item">
115
+                    when classid=#{item.classid} and examid=#{item.examid} then reportclass=#{item.reportclass}
116
+                </foreach>
117
+            </trim>
118
+            <trim prefix="reportstu = CASE " suffix="END,">
119
+                <foreach collection="list" index="index" item="item">
120
+                    when classid=#{item.classid} and examid=#{item.examid} then reportstu=#{item.reportstu}
121
+                </foreach>
122
+            </trim>
123
+        </trim>
124
+        where
125
+        <foreach collection="list" item="item" index="index" separator="or">
126
+            classid=#{item.classid} and examid=#{item.examid}
127
+        </foreach>
128
+    </update>
108 129
 </mapper>

+ 16
- 0
sexam/src/main/resources/mapper/exam/EClassStudentMapper.xml View File

@@ -52,4 +52,20 @@
52 52
     <select id="getClassidByStudentidAndExamid" resultType="java.lang.Integer">
53 53
         select classid from e_class_student where examid=#{examid} and studentid=#{studentid} limit 1
54 54
     </select>
55
+
56
+    <!--批量生成学生pdf报告-->
57
+    <update id="updateBatchReportstupath">
58
+        update e_class_student
59
+        <trim prefix="set" suffixOverrides=",">
60
+            <trim prefix="reportstu = CASE " suffix="END,">
61
+                <foreach collection="list" index="index" item="item">
62
+                    when studentid=#{item.studentid} and examid=#{item.examid} then reportstu=#{item.reportstu}
63
+                </foreach>
64
+            </trim>
65
+        </trim>
66
+        where
67
+        <foreach collection="list" item="item" index="index" separator="or">
68
+            studentid=#{item.studentid} and examid=#{item.examid}
69
+        </foreach>
70
+    </update>
55 71
 </mapper>

Loading…
Cancel
Save