Browse Source

网关配置请求超时时间

重新生成试卷分析
tags/正式版本
王宁 2 years ago
parent
commit
c263c40bbf

+ 20
- 0
gateway/src/main/java/com/xhkjedu/gateway/config/ConfigKey.java View File

@@ -0,0 +1,20 @@
1
+package com.xhkjedu.gateway.config;
2
+
3
+import org.springframework.beans.factory.annotation.Value;
4
+import org.springframework.stereotype.Component;
5
+
6
+/**
7
+ * @Description  读取配置文件类
8
+ * @Date 2022/10/17 14:26
9
+ **/
10
+@Component
11
+public class ConfigKey {
12
+
13
+    public static Integer rqovertime;
14
+
15
+    @Value("${rq.overtime}")
16
+    public void setRqovertime(Integer rqovertime) {
17
+        ConfigKey.rqovertime = rqovertime;
18
+    }
19
+
20
+}

+ 1
- 1
gateway/src/main/java/com/xhkjedu/gateway/config/CustomizeCircuitBreakerConfig.java View File

@@ -35,7 +35,7 @@ public class CustomizeCircuitBreakerConfig {
35 35
 
36 36
         return factory -> factory.configureDefault(id -> new Resilience4JConfigBuilder(id)
37 37
                 //超时规则,设置为20s
38
-                .timeLimiterConfig(TimeLimiterConfig.custom().timeoutDuration(Duration.ofMillis(20000)).build())
38
+                .timeLimiterConfig(TimeLimiterConfig.custom().timeoutDuration(Duration.ofMillis(ConfigKey.rqovertime)).build())
39 39
                 //设置断路器配置
40 40
                 .circuitBreakerConfig(circuitBreakerConfig).build());
41 41
 

+ 3
- 0
gateway/src/main/resources/application.properties View File

@@ -50,3 +50,6 @@ spring.cloud.gateway.routes[5].filters[1].args.fallbackUri=forward:/fallback
50 50
 eureka.client.service-url.defaultZone=http://localhost:8081/eureka/
51 51
 #设置eureka输出日志级别
52 52
 logging.level.com.netflix=error
53
+
54
+#请求超时时间30s
55
+rq.overtime = 30000

+ 1
- 1
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperQtypeService.java View File

@@ -565,7 +565,7 @@ public class EPaperQtypeService {
565 565
         //保存之前先清除之前的试卷分析
566 566
         ePaperAnalyzeMapper.deleteByEpid(ePaper.getEpid());
567 567
         //总体分析(主观题、客观题)
568
-        //处理题型1单选题2多选题3主观题4判断对错5判断√×6判断TF7完形填空8阅读理解10任务型阅读11综合题12听力
568
+        //处理题型1单选题2多选题3主观题4判断对错5判断√×6判断TF11综合题12听力13填空题
569 569
         int znum = 0;
570 570
         double zscore = 0;
571 571
         int knum = 0;

+ 7
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/paper/PaperQtypeMapper.java View File

@@ -2,7 +2,14 @@ package com.xhkjedu.sstudy.mapper.paper;
2 2
 
3 3
 import com.xhkjedu.sstudy.base.TkMapper;
4 4
 import com.xhkjedu.sstudy.model.paper.TPaperQtype;
5
+import com.xhkjedu.sstudy.vo.paper.PaperQtypeVo;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
5 9
 
6 10
 public interface PaperQtypeMapper extends TkMapper<TPaperQtype> {
7 11
     Integer deleteByPaperid(Integer paperid);
12
+
13
+    //试卷中试题
14
+    List<PaperQtypeVo> listPaperQtypeQuestions(@Param("paperid")Integer paperid);
8 15
 }

+ 6
- 3
sstudy/src/main/java/com/xhkjedu/sstudy/model/paper/TPaperAnalyze.java View File

@@ -16,9 +16,6 @@ public class TPaperAnalyze extends BaseBean {
16 16
     //作业id
17 17
     private Integer paperid;
18 18
 
19
-    //学校id
20
-    private Integer schoolid;
21
-
22 19
     //难易度json
23 20
     private String complexityjson;
24 21
 
@@ -27,4 +24,10 @@ public class TPaperAnalyze extends BaseBean {
27 24
 
28 25
     //知识点分布json
29 26
     private String pointjson;
27
+
28
+    //总体分析:主观题+客观题
29
+    private String alljson;
30
+
31
+    //试题知识点占分
32
+    private String quespointjson;
30 33
 }

+ 1
- 1
sstudy/src/main/java/com/xhkjedu/sstudy/model/paper/TPaperQtypeQuestion.java View File

@@ -44,7 +44,7 @@ public class TPaperQtypeQuestion extends BaseBean {
44 44
     private String questionpid;
45 45
 
46 46
     //复合题母题分值
47
-    private double mscore;
47
+    private Double mscore;
48 48
 
49 49
     //母题题型id
50 50
     private String mqtypeid;

+ 442
- 23
sstudy/src/main/java/com/xhkjedu/sstudy/service/paper/PaperService.java View File

@@ -8,6 +8,7 @@ import com.xhkjedu.sstudy.mapper.paper.*;
8 8
 import com.xhkjedu.sstudy.mapper.paperstudent.PaperStudentMapper;
9 9
 import com.xhkjedu.sstudy.model.paper.*;
10 10
 import com.xhkjedu.sstudy.model.paperstudent.TPaperStudent;
11
+import com.xhkjedu.sstudy.utils.StudyUtil;
11 12
 import com.xhkjedu.sstudy.vo.paper.*;
12 13
 import com.xhkjedu.sstudy.vo.paperstudent.PaperSearchVo;
13 14
 import com.xhkjedu.sstudy.vo.question.QuestionVo;
@@ -88,7 +89,7 @@ public class PaperService {
88 89
                 //保存答题卡信息
89 90
                 savePaperScantronQtype(paper,qtypes);
90 91
                 //保存分析
91
-                //savePaperScantronAnalyze(paperid,paper.getSchoolid());
92
+                savePaperScantronAnalyze(paper,qtypes,scanlist);
92 93
             }
93 94
 
94 95
         }catch (Exception e){
@@ -138,8 +139,7 @@ public class PaperService {
138 139
                 paperScantronQtypeMapper.deleteByPaperid(paper.getPaperid());   //保存答题卡信息
139 140
                 savePaperScantronQtype(paper, qtypes);
140 141
                 //删除分析信息
141
-                //paperAnalyzeMapper.deleteByPaperid(paper.getPaperid());
142
-                //savePaperScantronAnalyze(paper.getPaperid(), paper.getSchoolid());  //保存分析
142
+                savePaperScantronAnalyze(paper,qtypes,scanlist);  //保存分析
143 143
 
144 144
                 rtn = true;
145 145
             }
@@ -151,8 +151,6 @@ public class PaperService {
151 151
         return rtn;
152 152
     }
153 153
 
154
-
155
-
156 154
     /**
157 155
      * 保存作业
158 156
      * @Param [paper]
@@ -219,14 +217,94 @@ public class PaperService {
219 217
     }
220 218
 
221 219
     //保存答题卡分析
222
-    private Integer savePaperScantronAnalyze(Integer paperid,Integer schoolid){
223
-        List<Map<String, Object>> list = paperScantronMapper.listQtypeAnalyze(paperid);
220
+    private Integer savePaperScantronAnalyze(TPaper paper,List<TPaperScantronQtype> qtypes,List<TPaperScantron> scanlist){
221
+        int znum = 0;
222
+        double zscore = 0;
223
+        int knum = 0;
224
+        double kscore = 0;
225
+        for(TPaperScantron q : scanlist){
226
+            if(N_Utils.isObjectiveQuestion(q.getCtype())){
227
+                knum ++;
228
+                kscore = kscore + q.getPsscore();
229
+            }else{
230
+                znum ++;
231
+                zscore = zscore + q.getPsscore();
232
+            }
233
+        }
234
+
235
+        double znumrate = N_Utils.getIntegerDivideAndMulitiply(znum, paper.getPapernum());
236
+        double knumrate = N_Utils.getDoubleReduce(100.0, znumrate);
237
+
238
+        double zscorerate = N_Utils.getDoubleDivideAndMulitiply(zscore, paper.getPapernum());
239
+        double kscorerate = N_Utils.getDoubleReduce(100.0,zscorerate);
240
+
241
+        List<Map> ranglist = new ArrayList<>();
242
+        Map zgmap = new TreeMap();
243
+        zgmap.put("qtname","主观题");
244
+        zgmap.put("score",zscore);
245
+        zgmap.put("num",znum);
246
+        zgmap.put("srate",zscorerate);
247
+        zgmap.put("nrate",znumrate);
248
+        ranglist.add(zgmap);
249
+        Map kgmap = new TreeMap();
250
+        kgmap.put("qtname","客观题");
251
+        kgmap.put("score",kscore);
252
+        kgmap.put("num",knum);
253
+        kgmap.put("srate",kscorerate);
254
+        kgmap.put("nrate",knumrate);
255
+        ranglist.add(kgmap);
256
+
257
+        Map ztmap = new TreeMap<>();
258
+        ztmap.put("pnum", paper.getPapernum());
259
+        ztmap.put("pscore",paper.getPaperscore());
260
+        ztmap.put("ranglist",ranglist);
261
+
262
+        //题型分布(按照名称进行分组)
263
+        qtypes.stream().sorted(Comparator.comparing(TPaperScantronQtype::getPstorder)).collect(Collectors.toList());
264
+        Map<String,List<TPaperScantronQtype>> qtypemap =  qtypes.stream().collect(Collectors.groupingBy(TPaperScantronQtype:: getQtypename, Collectors.toList()));
265
+        List<Map> qtlist = new ArrayList<>();
266
+        for(Map.Entry<String, List<TPaperScantronQtype>> entry : qtypemap.entrySet()){
267
+            List<TPaperScantronQtype> aq = entry.getValue();
268
+            int num = aq.stream().mapToInt(TPaperScantronQtype::getPstnum).sum();
269
+            double tscore = aq.stream().collect(Collectors.summingDouble(TPaperScantronQtype:: getPstscore));
270
+            double storerate = N_Utils.getDoubleDivideAndMulitiply(tscore, paper.getPaperscore());
271
+            //获取小题题号
272
+            List<Integer> orderlist = new ArrayList<>();
273
+            List<Integer> eptqidlist = new ArrayList<>();
274
+            List<Double> scorelist = new ArrayList<>();
275
+            List<String> qnamelist = new ArrayList<>();
276
+            for(TPaperScantronQtype t : aq){
277
+                List<TPaperScantron> qlist = t.getScantrons();
278
+                for(TPaperScantron q : qlist){
279
+                    orderlist.add(q.getPsorder());
280
+                    eptqidlist.add(q.getId());
281
+                    scorelist.add(q.getPsscore());
282
+                    qnamelist.add(q.getQtypename());
283
+                }
284
+            }
285
+
286
+            Map anmap = new TreeMap();//题型对应试题的id和基础信息
287
+            anmap.put("orders",orderlist);
288
+            anmap.put("eptqids",eptqidlist);
289
+            anmap.put("scores",scorelist);
290
+            anmap.put("qtypenames",qnamelist);
291
+
292
+            Map tmap = new TreeMap();
293
+            tmap.put("qtname",entry.getKey());
294
+            tmap.put("qtid",aq.get(0).getPsqtypeid());
295
+            tmap.put("num",num);
296
+            tmap.put("score",tscore);
297
+            tmap.put("srate",storerate);
298
+            tmap.put("ques",anmap);
299
+            qtlist.add(tmap);
300
+        }
224 301
 
225 302
         TPaperAnalyze paperAnalyze = new TPaperAnalyze();
226
-        paperAnalyze.setPaperid(paperid);
227
-        paperAnalyze.setQtypejson(JSON.toJSONString(list));
303
+        paperAnalyze.setPaperid(paper.getPaperid());
304
+        paperAnalyze.setQtypejson(JSON.toJSONString(qtlist));
305
+        paperAnalyze.setAlljson(JSON.toJSONString(ztmap));
228 306
 
229
-        paperAnalyze.setSchoolid(schoolid);
307
+        paperAnalyzeMapper.deleteByPaperid(paper.getPaperid());//先删除原分析
230 308
         paperAnalyzeMapper.insertUseGeneratedKeys(paperAnalyze);
231 309
         return paperAnalyze.getId();
232 310
     }
@@ -271,7 +349,7 @@ public class PaperService {
271 349
             paperid = savePaper(paper);//保存作业
272 350
             paper.setPaperid(paperid);
273 351
             savePaperQtype(paper, qtypes);//保存作业题型信息
274
-            //generatePaperAnalyze(paperid, paper.getSchoolid());//生成作业分析
352
+            generatePaperAnalyze(paper);//生成作业分析
275 353
         }catch (Exception e){
276 354
             log.error("保存结构性试题作业失败:" + e.getMessage());
277 355
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -402,23 +480,364 @@ public class PaperService {
402 480
      * @Date 2020/6/10 9:57
403 481
      * @return java.lang.Integer
404 482
      **/
405
-    private Integer generatePaperAnalyze(Integer paperid, Integer schoolid) {
406
-        //1.题型统计
407
-        List<Map<String, Object>> rateList = paperQtypeQuestionMapper.paperTypeAnalyze(paperid);
408
-        //2.难易度统计
409
-        List<Map<String, Object>> complexityRateList = paperQtypeQuestionMapper.complexityRateAnalyze(paperid);
410
-        //3.知识点统计
411
-        List<Map<String, Object>> pointRateList = paperQtypeQuestionMapper.pointRateAnalyze(paperid);
483
+    private Integer generatePaperAnalyze(TPaper paper) {
484
+        //获取是试卷试题
485
+        List<PaperQtypeVo> qtypelist = paperQtypeMapper.listPaperQtypeQuestions(paper.getPaperid());
486
+        List<QuestionOrderVo> pointqlist = new ArrayList<>();//用于存放知识点,以及知识点下得分
487
+        List<PaperQtypeQuesVo> mquestions = new ArrayList<>();//存放单题和母题
488
+        List<QuestionOrderVo> complexitylist = new ArrayList<>();//试题难易度存放试题
489
+        List<QuestionPointVo> quesplist = new ArrayList<>();//单题、母题对应知识点
490
+
491
+        //处理出试卷中所有试题、知识点
492
+        List<Map> typelist = new ArrayList<>();//题型分析
493
+        for(PaperQtypeVo qt : qtypelist){
494
+            List<Integer> qorderlist = new ArrayList<>();
495
+            List<QuestionOrderVo> qtypeqlist = new ArrayList<>();
496
+            List<PaperQtypeQuesVo> tqlist = qt.getQuelist();
497
+            int hasmt = 0;
498
+            for(PaperQtypeQuesVo q : tqlist){
499
+                int ctype = q.getCtype();
500
+                //单题的pid设置为默认值,方便后续进行单题和母题处理
501
+                if(q.getQlevel()==1){
502
+                    q.setQuestionpid("000");
503
+                    //判断试题是否是客观题
504
+                    if(N_Utils.isObjectiveQuestion(ctype)){
505
+                        //判断试题是否是客观题,暂时用mctype进行标识
506
+                        q.setMctype(111);
507
+                    }else{
508
+                        q.setMctype(112);
509
+                    }
510
+                    //设置知识点
511
+                    mquestions.add(q);
512
+                    //获取试题知识点
513
+                    List<Map> qpoints = q.getPoints();
514
+                    //处理试题知识点占分
515
+                    setPaperQuestionPointScore(pointqlist,quesplist,qpoints,q,null,null);
516
+                    setPaperQuestionQtypeScore(qtypeqlist,q,null,null);//处理试题题型
517
+                    setPaperQuestionComplexityScore(complexitylist,q,null,null);//处理试题难易度
518
+                }
519
+                if(q.getQlevel() == 3){
520
+                    hasmt ++;
521
+                }
522
+                if(!qorderlist.contains(q.getPtqorder())){
523
+                    qorderlist.add(q.getPtqorder());
524
+                }
525
+            }
526
+
527
+            if(hasmt > 0){
528
+                //说明该题型下有复合题,复合体进行知识点、题型下试题题号及id进行操作
529
+                Map<String,List<PaperQtypeQuesVo>> quesMap = tqlist.stream().collect(Collectors.groupingBy(PaperQtypeQuesVo:: getQuestionpid, Collectors.toList()));
530
+                for(Map.Entry<String, List<PaperQtypeQuesVo>> entry : quesMap.entrySet()){
531
+                    if(!entry.getKey().equals("000")){
532
+                        //说明该题为母题,
533
+                        PaperQtypeQuesVo mq = new PaperQtypeQuesVo();
534
+                        List<PaperQtypeQuesVo> sonques = entry.getValue();
535
+                        int k = 0;//如果k大于1说明有小题是主观题,则母题为主观题
536
+                        double score = 0;
537
+                        for(PaperQtypeQuesVo sq : sonques){
538
+                            if(!N_Utils.isObjectiveQuestion(sq.getCtype())){
539
+                                k++;
540
+                            }
541
+                            score = N_Utils.getDoubleSum(score,sq.getPtqscore());
542
+                        }
543
+
544
+                        PaperQtypeQuesVo qobj = sonques.get(0);
545
+                        mq.setQuestionid(qobj.getQuestionpid());
546
+                        mq.setComplexity(qobj.getMcomplexity());
547
+                        mq.setPtqorder(qobj.getPtqorder());
548
+                        mq.setPtqscore(score);
549
+                        mq.setQtypename(qobj.getMqtypename());
550
+                        if(k == 0){
551
+                            mq.setMctype(111);
552
+                        }else{
553
+                            mq.setMctype(112);
554
+                        }
555
+                        mq.setQlevel(qobj.getMqlevel());
556
+                        mq.setSonques(sonques);
557
+                        //获取所有子题的试题题号
558
+                        List<String> qns = sonques.stream().map(PaperQtypeQuesVo::getQn).collect(Collectors.toList());
559
+                        String[] qnstr = qns.stream().toArray(String[]::new);
560
+                        //所有子题的试题eptqid
561
+                        List<Integer> eptqids = sonques.stream().map(PaperQtypeQuesVo::getPtqid).collect(Collectors.toList());
562
+                        Integer[] eptqidstr = eptqids.stream().toArray(Integer[]::new);
563
+
564
+                        //获取知识点
565
+                        List<Map> qpoints = sonques.get(0).getPoints();
566
+                        mq.setPoints(qpoints);
567
+                        mquestions.add(mq);
568
+                        setPaperQuestionPointScore(pointqlist,quesplist,qpoints,mq,qnstr,eptqids);
569
+                        setPaperQuestionQtypeScore(qtypeqlist,mq,qnstr,eptqidstr);//处理试题题型
570
+                        setPaperQuestionComplexityScore(complexitylist,mq,qnstr,eptqidstr);//处理试题难易度
571
+                    }
572
+                }
573
+            }
574
+
575
+            //试题题型分析数据
576
+            double storerate = N_Utils.getDoubleDivideAndMulitiply(qt.getPtscore(), paper.getPaperscore());
577
+            Map tmap = new TreeMap();
578
+            tmap.put("qtid",qt.getPtid());
579
+            tmap.put("qtname",qt.getQtypename());
580
+            tmap.put("num",qt.getPtnum());
581
+            tmap.put("score",qt.getPtscore());
582
+            tmap.put("srate",storerate);
583
+            qtypeqlist = qtypeqlist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList());
584
+            tmap.put("ques",qtypeqlist);
585
+            typelist.add(tmap);
586
+        }
587
+
588
+        //试题总体分布进行分析
589
+        //客观题集合
590
+        List<PaperQtypeQuesVo> ktlst = mquestions.stream().filter(q->q.getMctype() == 111).collect(Collectors.toList());
591
+        int ktnum = ktlst.size();
592
+        double ktscore = ktlst.stream().collect(Collectors.summingDouble(PaperQtypeQuesVo:: getPtqscore));
593
+        double ktnrate = N_Utils.getIntegerDivideAndMulitiply(ktnum, paper.getPapernum());
594
+        double ktsrate = N_Utils.getDoubleDivideAndMulitiply(ktscore, paper.getPaperstate());
595
+        List<PaperQsVo> ranglist = new ArrayList<>();
596
+        ranglist.add(new PaperQsVo("客观题", ktscore, ktnum, ktsrate, ktnrate));
597
+        PaperQsVo zgq = new PaperQsVo();
598
+        zgq.setQtname("主观题");
599
+        zgq.setNum(paper.getPapernum() - ktnum);
600
+        zgq.setNrate(N_Utils.getDoubleReduce(100.0,ktnrate));
601
+        zgq.setScore(N_Utils.getDoubleReduce(paper.getPaperscore(),ktscore));
602
+        zgq.setSrate(N_Utils.getDoubleReduce(100.0,ktsrate));
603
+        ranglist.add(zgq);
604
+        Map ztmap = new TreeMap<>();
605
+        ztmap.put("pnum", paper.getPapernum());
606
+        ztmap.put("pscore",paper.getPaperscore());
607
+        ztmap.put("ranglist",ranglist);
608
+
609
+        //难易度
610
+        List<Map> clist = new ArrayList<>();
611
+        if(N_Utils.isListNotEmpty(complexitylist)){
612
+            Map<String,List<QuestionOrderVo>> complxmap =  complexitylist.stream().collect(Collectors.groupingBy(QuestionOrderVo:: getId, Collectors.toList()));
613
+            for(Map.Entry<String, List<QuestionOrderVo>> entry : complxmap.entrySet()){
614
+                List<QuestionOrderVo> pgblist = entry.getValue();
615
+                Double score = pgblist.stream().mapToDouble(s -> s.getScore()).sum();
616
+                Double srate = N_Utils.getDoubleDivideAndMulitiply(score,paper.getPaperscore());
617
+                Map prate = new TreeMap();
618
+                prate.put("level",Integer.parseInt(entry.getKey()));
619
+                prate.put("score",score);
620
+                prate.put("srate",srate);
621
+                prate.put("ques",pgblist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList()));
622
+                clist.add(prate);
623
+            }
624
+        }
625
+
626
+        //知识点分析
627
+        List<Map> pointlist = new ArrayList<>();
628
+        if(N_Utils.isListNotEmpty(pointqlist)){
629
+            Map<String,List<QuestionOrderVo>> pointmap = pointqlist.stream().collect(Collectors.groupingBy(QuestionOrderVo::getId,Collectors.toList()));
630
+            //根据指示进行分组,
631
+            for(Map.Entry<String, List<QuestionOrderVo>> entry : pointmap.entrySet()){
632
+                List<QuestionOrderVo> pgblist = entry.getValue();
633
+                //获取知识点的总分
634
+                Double score = pgblist.stream().mapToDouble(s -> s.getScore()).sum();
635
+                Double srate = N_Utils.getDoubleDivideAndMulitiply(score,paper.getPaperscore());
636
+                Map prate = new TreeMap();
637
+                prate.put("pointid",entry.getKey());
638
+                prate.put("pointname",pgblist.get(0).getName());
639
+                prate.put("score",score);
640
+                prate.put("srate",srate);
641
+                prate.put("ques",pgblist.stream().sorted(Comparator.comparing(QuestionOrderVo::getOrder)).collect(Collectors.toList()));
642
+                pointlist.add(prate);
643
+            }
644
+        }
645
+
412 646
         TPaperAnalyze paperAnalyze = new TPaperAnalyze();
413
-        paperAnalyze.setPaperid(paperid);
414
-        paperAnalyze.setQtypejson(JSON.toJSONString(rateList));
415
-        paperAnalyze.setComplexityjson(JSON.toJSONString(complexityRateList));
416
-        paperAnalyze.setPointjson(JSON.toJSONString(pointRateList));
417
-        paperAnalyze.setSchoolid(schoolid);
647
+        paperAnalyze.setPaperid(paper.getPaperid());
648
+        paperAnalyze.setAlljson(JSON.toJSONString(ztmap));//总体分析
649
+        paperAnalyze.setQtypejson(JSON.toJSONString(typelist));//试题栏题型分析
650
+        paperAnalyze.setComplexityjson(JSON.toJSONString(clist));//难易度分析
651
+        paperAnalyze.setPointjson(JSON.toJSONString(pointlist));//知识点分析
652
+        paperAnalyze.setQuespointjson(JSON.toJSONString(quesplist));
653
+
654
+        paperAnalyzeMapper.deleteByPaperid(paper.getPaperid());
418 655
         paperAnalyzeMapper.insertUseGeneratedKeys(paperAnalyze);
419 656
         return paperAnalyze.getId();
420 657
     }
421 658
 
659
+    //设置知识点
660
+    private void setPaperQuestionPointScore(List<QuestionOrderVo> pointqlist,List<QuestionPointVo> quesplist,List<Map> qpoints,PaperQtypeQuesVo dq,String[] qnstr,List<Integer> eptqids){
661
+        if(N_Utils.isListNotEmpty(qpoints)){
662
+            if(qpoints.size() == 1){
663
+                //试题只有一个知识点
664
+                Map pointmap = qpoints.get(0);
665
+                QuestionOrderVo qpoint = new QuestionOrderVo();
666
+                qpoint.setId(pointmap.get("pointid").toString());
667
+                qpoint.setName(pointmap.get("pointname").toString());
668
+                qpoint.setOrder(dq.getPtqorder());
669
+                qpoint.setScore(dq.getPtqscore());
670
+                qpoint.setQlevel(dq.getQlevel());
671
+                qpoint.setQuestionid(dq.getQuestionid());
672
+                if(qnstr == null){
673
+                    qpoint.setQns(new String[]{dq.getQn()});
674
+                }else{
675
+                    qpoint.setQns(qnstr);
676
+                }
677
+
678
+                if(N_Utils.isListEmpty(eptqids)){
679
+                    qpoint.setPtqids(new Integer[]{dq.getPtqid()});
680
+                }else{
681
+                    Integer[] eptqidstr = eptqids.stream().toArray(Integer[]::new);
682
+                    qpoint.setPtqids(eptqidstr);
683
+                }
684
+                pointqlist.add(qpoint);
685
+
686
+                //试题对应知识点
687
+                QuestionPointVo questionPointVo = new QuestionPointVo();
688
+                questionPointVo.setOrder(dq.getPtqorder());
689
+                questionPointVo.setScore(dq.getPtqscore());
690
+                questionPointVo.setQlevel(dq.getQlevel());
691
+                questionPointVo.setQuestionid(dq.getQuestionid());
692
+                List<Map> pointids = new ArrayList<>();
693
+                Map map = new HashMap();
694
+                map.put("pointid",pointmap.get("pointid").toString());
695
+                map.put("score",dq.getPtqscore());
696
+                pointids.add(map);
697
+                questionPointVo.setPointids(pointids);
698
+
699
+                if(N_Utils.isListEmpty(eptqids)){
700
+                    List<Integer> saveids = new ArrayList<>();
701
+                    saveids.add(dq.getPtqid());
702
+                    questionPointVo.setPtqids(saveids);
703
+                    questionPointVo.setPtqid(dq.getPtqid());
704
+                }else{
705
+                    questionPointVo.setPtqids(eptqids);
706
+                    questionPointVo.setPtqid(0);
707
+                }
708
+                quesplist.add(questionPointVo);
709
+            }else{
710
+
711
+                //试题有多个知识点
712
+                //计算每个知识点所占分值(平均分配)
713
+                Double[] avgps = StudyUtil.getPointAvgScore(qpoints.size(), dq.getPtqscore());
714
+                List<Map> pointids = new ArrayList<>();
715
+                for(int m = 0; m<qpoints.size();m++){
716
+                    Map pointmap = qpoints.get(m);
717
+                    QuestionOrderVo qpoint = new QuestionOrderVo();
718
+                    qpoint.setId(pointmap.get("pointid").toString());
719
+                    qpoint.setName(pointmap.get("pointname").toString());
720
+                    qpoint.setOrder(dq.getPtqorder());
721
+                    qpoint.setQlevel(dq.getQlevel());
722
+                    qpoint.setQuestionid(dq.getQuestionid());
723
+
724
+
725
+                    Map quesmap = new HashMap();//试题对应知识点
726
+                    quesmap.put("pointid",pointmap.get("pointid").toString());
727
+
728
+                    if(avgps.length == 2 && (m+1) == qpoints.size()){
729
+                        //不能整除分,并且是最后一个知识点
730
+                        qpoint.setScore(avgps[1]);
731
+                        quesmap.put("score",avgps[1]);
732
+                    }else{
733
+                        qpoint.setScore(avgps[0]);
734
+                        quesmap.put("score",avgps[0]);
735
+                    }
736
+                    pointids.add(quesmap);
737
+
738
+                    //题号集合
739
+                    if(qnstr == null){
740
+                        qpoint.setQns(new String[]{dq.getQn()});
741
+                    }else{
742
+                        qpoint.setQns(qnstr);
743
+                    }
744
+                    //试卷中试题id集合
745
+                    if(N_Utils.isListEmpty(eptqids)){
746
+                        qpoint.setPtqids(new Integer[]{dq.getPtqid()});
747
+                    }else{
748
+                        Integer[] eptqidstr = eptqids.stream().toArray(Integer[]::new);
749
+                        qpoint.setPtqids(eptqidstr);
750
+                    }
751
+                    pointqlist.add(qpoint);
752
+                }
753
+
754
+                //试题对应知识点
755
+                QuestionPointVo questionPointVo = new QuestionPointVo();
756
+                questionPointVo.setOrder(dq.getPtqorder());
757
+                questionPointVo.setScore(dq.getPtqscore());
758
+                questionPointVo.setQlevel(dq.getQlevel());
759
+                questionPointVo.setQuestionid(dq.getQuestionid());
760
+                questionPointVo.setPointids(pointids);
761
+                if(N_Utils.isListEmpty(eptqids)){
762
+                    List<Integer> saveids = new ArrayList<>();
763
+                    saveids.add(dq.getPtqid());
764
+                    questionPointVo.setPtqids(saveids);
765
+                    questionPointVo.setPtqid(dq.getPtqid());
766
+
767
+                }else{
768
+                    questionPointVo.setPtqids(eptqids);
769
+                    questionPointVo.setPtqid(0);
770
+                }
771
+                quesplist.add(questionPointVo);
772
+
773
+            }
774
+        } else{
775
+            QuestionPointVo questionPointVo = new QuestionPointVo();
776
+            questionPointVo.setOrder(dq.getPtqorder());
777
+            questionPointVo.setScore(dq.getPtqscore());
778
+            questionPointVo.setQlevel(dq.getQlevel());
779
+            questionPointVo.setQuestionid(dq.getQuestionid());
780
+            questionPointVo.setPointids(null);
781
+            if(N_Utils.isListEmpty(eptqids)){
782
+                List<Integer> saveids = new ArrayList<>();
783
+                saveids.add(dq.getPtqid());
784
+                questionPointVo.setPtqids(saveids);
785
+                questionPointVo.setPtqid(dq.getPtqid());
786
+            }else{
787
+                questionPointVo.setPtqids(eptqids);
788
+                questionPointVo.setPtqid(0);
789
+            }
790
+
791
+            quesplist.add(questionPointVo);
792
+        }
793
+    }
794
+
795
+    //设置题型下试题题号及分值
796
+    private void setPaperQuestionQtypeScore(List<QuestionOrderVo> qtypelist,PaperQtypeQuesVo dq,String[] qnstr,Integer[] eptqidstr){
797
+        QuestionOrderVo qtype = new QuestionOrderVo();
798
+        qtype.setId(dq.getQtypeid());
799
+        qtype.setName(dq.getQtypename());
800
+        qtype.setComplexity(dq.getComplexity());
801
+        qtype.setOrder(dq.getPtqorder());
802
+        qtype.setScore(dq.getPtqscore());
803
+        qtype.setQlevel(dq.getQlevel());
804
+        qtype.setQuestionid(dq.getQuestionid());
805
+        if(qnstr == null){
806
+            qtype.setQns(new String[]{dq.getQn()});
807
+        }else{
808
+            qtype.setQns(qnstr);
809
+        }
810
+        if(eptqidstr == null){
811
+            qtype.setPtqids(new Integer[]{dq.getPtqid()});
812
+        }else{
813
+            qtype.setPtqids(eptqidstr);
814
+        }
815
+
816
+        qtypelist.add(qtype);
817
+    }
818
+
819
+    //设置试题难易度
820
+    private void setPaperQuestionComplexityScore(List<QuestionOrderVo> complexityList,PaperQtypeQuesVo dq,String[] qnstr,Integer[] eptqidstr){
821
+        QuestionOrderVo qtype = new QuestionOrderVo();
822
+        qtype.setId(dq.getComplexity().toString());//存放试题难易度
823
+        qtype.setOrder(dq.getPtqorder());
824
+        qtype.setScore(dq.getPtqscore());
825
+        qtype.setQlevel(dq.getQlevel());
826
+        qtype.setQuestionid(dq.getQuestionid());
827
+        if(qnstr == null){
828
+            qtype.setQns(new String[]{dq.getQn()});
829
+        }else{
830
+            qtype.setQns(qnstr);
831
+        }
832
+        if(eptqidstr == null){
833
+            qtype.setPtqids(new Integer[]{dq.getPtqid()});
834
+        }else{
835
+            qtype.setPtqids(eptqidstr);
836
+        }
837
+
838
+        complexityList.add(qtype);
839
+    }
840
+
422 841
     /**
423 842
      *功能描述  详情--答题卡
424 843
      * @author WN

+ 25
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/utils/StudyUtil.java View File

@@ -14,6 +14,7 @@ import org.springframework.util.MultiValueMap;
14 14
 import org.springframework.web.client.RestClientException;
15 15
 import org.springframework.web.client.RestTemplate;
16 16
 
17
+import java.math.BigDecimal;
17 18
 import java.util.ArrayList;
18 19
 import java.util.LinkedHashMap;
19 20
 import java.util.List;
@@ -110,4 +111,28 @@ public class StudyUtil {
110 111
         }
111 112
         return types;
112 113
     }
114
+
115
+    /**
116
+     * @Description 分值平均后得到的值,如果整除返回数组元素1,未整除返回元素数量2
117
+     * @Param [num, score] 数量,分值
118
+     * @Return java.lang.Double[] 第一个未平均分值,第二个值为最后一个数的分值
119
+     * @Author wn
120
+     * @Date 2022/8/18 11:07
121
+     **/
122
+    public static Double[] getPointAvgScore(int num, Double score) {
123
+        BigDecimal bScore = new BigDecimal(Double.toString(score));
124
+        BigDecimal bNum = new BigDecimal(Integer.toString(num));
125
+
126
+        BigDecimal avg = bScore.divide(bNum, 1, BigDecimal.ROUND_DOWN);
127
+        BigDecimal avgAllScore = avg.multiply(bNum);//平均分乘以数量得到的分值
128
+        if (bScore.equals(avgAllScore)) {
129
+            //说明整除
130
+            return new Double[]{avg.doubleValue()};
131
+        } else {
132
+            //未整除,计算最后剩余分值,subtract总分减去平均分和数量的积
133
+            // 平均分加上剩余得分得到最后一个分值
134
+            BigDecimal lastScore = avg.add(bScore.subtract(avgAllScore));
135
+            return new Double[]{avg.doubleValue(), lastScore.doubleValue()};
136
+        }
137
+    }
113 138
 }

+ 34
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/vo/paper/PaperQsVo.java View File

@@ -0,0 +1,34 @@
1
+package com.xhkjedu.sstudy.vo.paper;
2
+
3
+import lombok.Data;
4
+
5
+/**
6
+ * @Description
7
+ * @Author WN
8
+ * Date 2022/10/17 16:58
9
+ **/
10
+@Data
11
+public class PaperQsVo {
12
+    private String qtname;//名称
13
+
14
+    private double score;//分值
15
+
16
+    private int num;//数量
17
+
18
+    private double srate;//分值占比
19
+
20
+    private double nrate;//数量占比
21
+
22
+    private String qns;//小题题号
23
+    public PaperQsVo(){
24
+
25
+    }
26
+
27
+    public PaperQsVo(String qtname, double score, int num, double srate, double nrate){
28
+        this.qtname = qtname;
29
+        this.score = score;
30
+        this.num = num;
31
+        this.srate = srate;
32
+        this.nrate = nrate;
33
+    }
34
+}

+ 57
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/vo/paper/PaperQtypeQuesVo.java View File

@@ -0,0 +1,57 @@
1
+package com.xhkjedu.sstudy.vo.paper;
2
+
3
+import lombok.Data;
4
+
5
+import java.util.ArrayList;
6
+import java.util.List;
7
+import java.util.Map;
8
+
9
+/**
10
+ * @Description
11
+ * @Author WN
12
+ * Date 2022/10/17 15:52
13
+ **/
14
+@Data
15
+public class PaperQtypeQuesVo {
16
+    private Integer ptqid;
17
+
18
+    private String questionid;
19
+
20
+    private String qtypeid;
21
+
22
+    private String qtypename;
23
+
24
+    private Integer ctype;
25
+
26
+    private Integer qlevel;
27
+
28
+    private Integer sorder;
29
+
30
+    private Integer snum;
31
+
32
+    private Integer complexity;
33
+
34
+    private Double ptqscore;
35
+
36
+    private Integer ptqorder;
37
+
38
+    private String qn;
39
+
40
+    private String questionpid;
41
+
42
+    private Double mscore;
43
+
44
+    private String mqtypeid;
45
+
46
+    private String mqtypename;
47
+
48
+    private Integer mctype;
49
+
50
+    private Integer mqlevel;
51
+
52
+    private Integer mcomplexity;
53
+
54
+    private List<Map> points = new ArrayList<>();//知识点
55
+
56
+    private List<PaperQtypeQuesVo> sonques = new ArrayList<>();
57
+}

+ 4
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/vo/paper/PaperQtypeVo.java View File

@@ -3,10 +3,12 @@ package com.xhkjedu.sstudy.vo.paper;
3 3
 import com.xhkjedu.sstudy.vo.question.QuestionVo;
4 4
 import lombok.Data;
5 5
 
6
+import java.util.ArrayList;
6 7
 import java.util.List;
7 8
 
8 9
 @Data
9 10
 public class PaperQtypeVo {
11
+    private Integer ptid;
10 12
     //题型id
11 13
     private String qtypeid;
12 14
 
@@ -27,4 +29,6 @@ public class PaperQtypeVo {
27 29
 
28 30
     //试题集合
29 31
     private List<QuestionVo> questions;
32
+
33
+    private List<PaperQtypeQuesVo> quelist = new ArrayList<>();
30 34
 }

+ 33
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/vo/paper/QuestionOrderVo.java View File

@@ -0,0 +1,33 @@
1
+package com.xhkjedu.sstudy.vo.paper;
2
+
3
+import lombok.Data;
4
+
5
+/**
6
+ * @Description
7
+ * @Author WN
8
+ * Date 2022/10/17 16:43
9
+ **/
10
+@Data
11
+public class QuestionOrderVo {
12
+    private String id;
13
+
14
+    private String name;
15
+
16
+    private Integer complexity;
17
+
18
+    //试题类型1单题2母题
19
+    private Integer qlevel;
20
+
21
+    private Double score;//试题分值
22
+
23
+    //试题题号(单题、母题) (子题不占题号)
24
+    private Integer order;
25
+
26
+    private String questionid;//试题id(单题id,母题id)
27
+
28
+    //试题题号对应子题在试卷中id(单题时数组长度为1)
29
+    private Integer[] ptqids;
30
+
31
+    //试题题号对应子题在试卷中显示的题号(单题时数组长度为1)
32
+    private String[] qns;
33
+}

+ 22
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/vo/paper/QuestionPointVo.java View File

@@ -0,0 +1,22 @@
1
+package com.xhkjedu.sstudy.vo.paper;
2
+
3
+import lombok.Data;
4
+
5
+import java.util.List;
6
+import java.util.Map;
7
+
8
+/**
9
+ * @Description
10
+ * @Author WN
11
+ * Date 2022/10/17 16:45
12
+ **/
13
+@Data
14
+public class QuestionPointVo {
15
+    private Integer order;//试题排序
16
+    private Integer ptqid;//试卷中试题id单题,母子题的情况下为0
17
+    private String questionid;//试题id
18
+    private Double score;//单题、母题分值
19
+    private Integer qlevel;//试题级别1单题2母题
20
+    private List<Integer> ptqids;//试题子题集合
21
+    private List<Map> pointids;//知识点id和知识点分值
22
+}

+ 53
- 0
sstudy/src/main/resources/mapper/paper/PaperQtypeMapper.xml View File

@@ -5,4 +5,57 @@
5 5
     <delete id="deleteByPaperid">
6 6
         DELETE FROM t_paper_qtype WHERE paperid=#{paperid}
7 7
     </delete>
8
+
9
+    <resultMap id="qtypesQuestions" type="com.xhkjedu.sstudy.vo.paper.PaperQtypeVo">
10
+        <result column="ptid" property="ptid"></result>
11
+        <result column="qtypeid" property="qtypeid"></result>
12
+        <result column="qtypename" property="qtypename"></result>
13
+        <result column="ptorder" property="ptorder"></result>
14
+        <result column="ptscore" property="ptscore"></result>
15
+        <result column="ptnum" property="ptnum"></result>
16
+        <collection property="quelist" ofType="com.xhkjedu.sstudy.vo.paper.PaperQtypeQuesVo" javaType="java.util.List">
17
+            <result column="ptqid" property="ptqid"></result>
18
+            <result column="questionid" property="questionid"></result>
19
+            <result column="qtypeid" property="qtypeid"></result>
20
+            <result column="qtypename" property="qtypename"></result>
21
+            <result column="ctype" property="ctype"></result>
22
+            <result column="qlevel" property="qlevel"></result>
23
+            <result column="sorder" property="sorder"></result>
24
+            <result column="snum" property="snum"></result>
25
+            <result column="complexity" property="complexity"></result>
26
+            <result column="ptqscore" property="ptqscore"></result>
27
+            <result column="ptqorder" property="ptqorder"></result>
28
+            <result column="qn" property="qn"></result>
29
+            <result column="questionpid" property="questionpid"></result>
30
+            <result column="mscore" property="mscore"></result>
31
+            <result column="mqtypeid" property="mqtypeid"></result>
32
+            <result column="mqtypename" property="mqtypename"></result>
33
+            <result column="mctype" property="mctype"></result>
34
+            <result column="mqlevel" property="mqlevel"></result>
35
+            <result column="mcomplexity" property="mcomplexity"></result>
36
+            <collection property="points" ofType="java.util.Map" javaType="java.util.List"
37
+                        column="{questionid=questionid,qlevel=qlevel,questionpid=questionpid" select="listQuestionPoints">
38
+                <result column="pointid" property="pointid"></result>
39
+                <result column="pointname" property="pointname"></result>
40
+            </collection>
41
+        </collection>
42
+    </resultMap>
43
+
44
+    <!--试题详情-->
45
+    <select id="listPaperQtypeQuestions" resultMap="qtypesQuestions">
46
+        select t.ptid,t.qtypeid,t.qtypename,t.ptorder,t.ptscore,t.ptnum,tq.ptqid,tq.questionid,q.qtypeid,q.qtypename,q.ctype,
47
+               q.qlevel,q.sorder,q.snum,q.complexity,tq.ptqscore,tq.ptqorder,tq.qn,tq.questionpid,tq.mscore,tq.mqtypeid,
48
+               tq.mqtypename,q1.ctype mctype,q1.qlevel mqlevel,q1.complexity mcomplexity
49
+                from t_paper_qtype_question tq left join t_paper_qtype t on t.ptid=tq.ptid
50
+                left join t_question q on tq.questionid=q.questionid
51
+                left JOIN t_question q1 on tq.questionpid=q1.questionid
52
+         where t.paperid=#{paperid} order by t.ptorder,tq.ptqorder,q.sorder
53
+    </select>
54
+    <!--试题关联知识点-->
55
+    <select id="listQuestionPoints" resultType="java.util.Map">
56
+        select qp.pointid,p.pointname from t_question_point qp
57
+        left join t_point p on qp.pointid=p.pointid
58
+        where qp.questionid=#{questionpid} group by qp.pointid order by p.pointorder
59
+    </select>
60
+
8 61
 </mapper>

+ 1
- 1
sstudy/src/main/resources/mapper/paper/PaperScantronMapper.xml View File

@@ -9,7 +9,7 @@
9 9
         GROUP_CONCAT(ps.psorder) AS orders
10 10
         FROM t_paper_scantron_qtype psq LEFT JOIN t_paper_scantron ps ON psq.psqtypeid=ps.psqtypeid
11 11
         LEFT JOIN t_paper p ON  psq.paperid=p.paperid
12
-        WHERE p.papertype=2 AND psq.paperid=#{paperid} GROUP BY psq.qtypeid ORDER BY psq.pstorder
12
+        WHERE p.papertype=2 AND psq.paperid=#{paperid} GROUP BY psq.qtypename ORDER BY psq.pstorder
13 13
     </select>
14 14
     <!--获取答题卡详情-->
15 15
     <select id="findById" resultType="com.xhkjedu.sstudy.model.paper.TPaperScantron">

Loading…
Cancel
Save