[测评系统]--测评系统核心代码库
linzhijie
2021-04-12 ccbe40edcd772214ac3df40be1f582b6acea63f4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package com.ots.project.tool.report.CAQ;
import com.ots.common.enums.LangTypeEnum;
import com.ots.common.enums.ReportTypeEnum;
import com.ots.common.utils.StringUtils;
import com.ots.project.exam.domain.TLibraryCode;
import com.ots.project.tool.report.CAQ.condition.WaterDropletContentPAbstract;
import com.ots.project.tool.report.CAQ.condition.WaterDropletContentPCombined;
import com.ots.project.tool.report.CAQ.condition.WaterDropletContentPNumeric;
import com.ots.project.tool.report.MAQ.base.BaseCondition;
import com.ots.project.tool.report.MAQ.condition.SimpleMessage;
import com.ots.project.tool.report.ReportResultData;
import lombok.Getter;
import lombok.Setter;
import java.util.*;
import java.util.stream.Collectors;
 
@Getter
@Setter
public class CAQReport {
    
    private String fullName;
    
    private String reportDate;
    
    private String testToken;
 
    /**
     * 获取报告字典的code跟value
     * @param thaiCalculationMap
     * @param type
     * @param langType
     * @return
     */
    public ReportResultData getTemplateParameters(Map<String, String> thaiCalculationMap, ReportTypeEnum type, LangTypeEnum langType) {
        Map<String, Object> infoMap = new HashMap();
        infoMap.put("fullName", fullName);
        infoMap.put("reportDate", reportDate);
        infoMap.put("testToken", testToken);
        Map textMap = new HashMap();
        Map waterDropsMap = new HashMap();
        //遍历初始化code字典值的value
        getParamList(type).stream().forEach(p -> {
            TLibraryCode calculate = p.calculate(thaiCalculationMap, langType);
            //保存置换后文本字典 例:LIBCAQ0015 : 该候选人在抽象推理能力部分20题中回答正确的题数:<BoldText>14</BoldText>
            textMap.put(p.getName(), Objects.isNull(calculate) || StringUtils.isBlank(calculate.getLangTypeContext(langType)) ? "N/A NONE" : calculate.getLangTypeContext(langType));
            //保存图片字典 例子:P_Abstract_context_waterDrops : 26.0
            if (Objects.nonNull(p.getMAQwaterDropsImages())) {
                waterDropsMap.putAll(p.getMAQwaterDropsImages());
            }
        });
        //保存之前传进来的题目ID跟一些个人信息
        textMap.putAll(thaiCalculationMap);
        ReportResultData reportResultData = new ReportResultData();
        reportResultData.setTextMap(textMap);
        reportResultData.setImageMap(waterDropsMap);
        return reportResultData;
    }
    public List<BaseCondition> getParamList(ReportTypeEnum reportTypeEnum) {
        return init(reportTypeEnum);
    }
 
    /**
     * 初始化字典
     * @param reportTypeEnum
     * @return
     */
    private List<BaseCondition> init(ReportTypeEnum reportTypeEnum) {
        List<BaseCondition> paramList = new ArrayList<>();
        
        paramList.addAll(getSimpleMessageCoreIds().stream().map(p -> {
            SimpleMessage simpleMessage = new SimpleMessage(p);
            return simpleMessage;
        }).collect(Collectors.toList()));
        paramList.add(new WaterDropletContentPCombined());
        paramList.add(new WaterDropletContentPAbstract());
        paramList.add(new WaterDropletContentPNumeric());
        return paramList;
    }
 
    /**
     * 初始化简单的字典code
     * @return
     */
    private List<String> getSimpleMessageCoreIds() {
        return Arrays.asList("LIBCAQ0005", "LIBCAQ0006", "LIBCAQ0007", "LIBCAQ0008", "LIBCAQ0010", "LIBCAQ0020"
                ,"LIBCAQ0030","LIBCAQ0040","LIBCAQ0050","LIBCAQ0060","LIBCAQ0070","LIBCAQ0080"
                ,"LIBCAQ0090","LIBCAQ0095","LIBCAQ0100","LIBCAQ0100","LIBCAQ0110","LIBCAQ0150"
                ,"LIBCAQ0001","LIBCAQ0003","LIBCAQ0004","LIBCAQ0011","LIBCAQ0015"
        );
    }
}