[测评系统]--测评系统核心代码库
linzhijie
2021-07-28 3d285bc2a61024e6e4fb805c13286243430e38e3
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package com.ots.project.tool.report.PAQ;
 
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.MAQNEW.base.BaseCondition_V2;
import com.ots.project.tool.report.MAQNEW.base.MAQConditionVO_V2;
import com.ots.project.tool.report.MAQNEW.base.MAQSummaryCondition_V2;
import com.ots.project.tool.report.MAQNEW.condition.*;
import com.ots.project.tool.report.ReportResultData;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
 
import java.util.*;
import java.util.stream.Collectors;
 
@Data
@Slf4j
public class PAQReport {
    private String questionnaireTaker;
    private String questionnaireID;
    private String reportGenerationDate;
    private String userName;
    private String questionnaireEmail;
    private String questionnaireStartTime;
    private String questionnaireEndTime;
    private ReportTypeEnum reportTypeEnum;
 
    private LangTypeEnum langType;
 
    /**
     * 根据报告类型初始化数据
     * @param reportTypeEnum
     * @return
     */
    public List<BaseCondition_V2> getParamList(ReportTypeEnum reportTypeEnum) {
        return init(reportTypeEnum);
    }
 
    /**
     * 根据报告类型初始化所有
     * @param reportTypeEnum
     * @return
     */
    private List<BaseCondition_V2> init(ReportTypeEnum reportTypeEnum) {
        List<BaseCondition_V2> paramList = new ArrayList<>();
 
        //普通信息
        paramList.addAll(getSimpleMessageCoreIds().stream().map(p -> {
            SimpleMessage_V2 simpleMessage = new SimpleMessage_V2(p);
            return simpleMessage;
        }).collect(Collectors.toList()));
 
        //测试结果有效性诊断
        paramList.add(new ResponseFidelityDiagnosisTitle_V2());
        paramList.add(new ResponseFidelityDiagnosis_V2());
 
        //表格计算数值
        paramList.addAll(getScoreCharacteristicsList().stream().map(p -> {
            ScoreCharacteristics_V2 scoreCharacteristics = new ScoreCharacteristics_V2(p);
            return scoreCharacteristics;
        }).collect(Collectors.toList()));
 
        return paramList;
    }
 
    /**
     * 表格计算数值
     * @return
     */
    private List<String> getScoreCharacteristicsList() {
        return Arrays.asList("P_Flex01", "P_Creat02", "P_Analyt03", "P_Indep04", "P_Achiev05",
                "P_Initi06", "P_Persis07", "P_Thorou08", "P_Depend09", "P_Plan10",
                "P_Integr11", "P_Energy12", "P_Social13", "P_Lead14", "P_Influ15",
                "P_Team16", "P_Empath17", "P_Polite18", "P_Regula19", "P_ManStr20",
                "P_Confid21", "P_Mind22", "P_SDE23", "P_IM24", "P_INCON25",
                "P_Open26", "P_Consci27", "P_Extrov28", "P_Agree29", "P_EmSt30",
                "P_Task31", "P_People32", "P_Judg33");
    }
 
    /**
     * 普通文本替换library
     * @return
     */
    private List<String> getSimpleMessageCoreIds() {
        return Arrays.asList(
                "LIBPAQGS0001", "LIBPAQGS0002", "LIBPAQGS0005", "LIBPAQGS0008", "LIBPAQGS0009",
                "LIBPAQGS0011","LIBPAQGS0015","LIBPAQGS0017","LIBPAQGS0018","LIBPAQGS8800",
                "LIBPAQGS8801", "LIBPAQGS88011", "LIBPAQGS88012", "LIBPAQGS88013", "LIBPAQGS8802",
                "LIBPAQGS88021", "LIBPAQGS88022", "LIBPAQGS88023", "LIBPAQGS8803", "LIBPAQGS88031",
                "LIBPAQGS88032", "LIBPAQGS88033", "LIBPAQGS8804", "LIBPAQGS88041", "LIBPAQGS88042",
                "LIBPAQGS88043", "LIBPAQGS8805", "LIBPAQGS88051", "LIBPAQGS88052", "LIBPAQGS88053",
                "LIBPAQGS8806", "LIBPAQGS88061", "LIBPAQGS88062", "LIBPAQGS88063");
    }
 
    /**
     * 获取报告字典替换值
     * @param thaiCalculationMap
     * @param type
     * @param langType
     * @return
     */
    public ReportResultData getTemplateParameters(Map<String, String> thaiCalculationMap, ReportTypeEnum type, LangTypeEnum langType) {
        this.reportTypeEnum = type;
        this.langType = langType;
        
        Map textMap = new HashMap();
        //Map waterDropsMap = new HashMap();
        //基本信息字段
        textMap.put("questionnaireTaker", getQuestionnaireTaker());
        textMap.put("questionnaireID", getQuestionnaireID());
        textMap.put("reportGenerationDate", getReportGenerationDate());
        textMap.put("userName", getUserName());
        textMap.put("questionnaireEmail", getQuestionnaireEmail());
        textMap.put("questionnaireStartTime", getQuestionnaireStartTime());
        textMap.put("questionnaireEndTime", getQuestionnaireEndTime());
        //根据报告类型获取报告字典
        getParamList(type).stream().forEach(p -> {
            //获取对应语言报告字典
            TLibraryCode calculate = p.calculate(thaiCalculationMap, langType);
            List<TLibraryCode> tLibraryCodes = p.calculateList(thaiCalculationMap, langType);
            if(tLibraryCodes != null && tLibraryCodes.size() > 0){
                //表格多位 计算分数值赋值 例如
                // 表格的:%ResponseFidelityDiagnosis_V2_0%
                // 表格的:%ResponseFidelityDiagnosis_V2_1%
                // 表格的:%ResponseFidelityDiagnosis_V2_2%
                for (int i = 0; i < tLibraryCodes.size(); i++) {
                    TLibraryCode tLibraryCode = tLibraryCodes.get(i);
                    textMap.put(p.getName() + "_" + i, Objects.isNull(tLibraryCode) || StringUtils.isBlank(tLibraryCode.getLangTypeContext(langType)) ? "N/A NONE" : tLibraryCode.getLangTypeContext(langType));
                }
            }else{
                //普通报告字典赋值
                textMap.put(p.getName(), Objects.isNull(calculate) || StringUtils.isBlank(calculate.getLangTypeContext(langType)) ? "N/A NONE" : calculate.getLangTypeContext(langType));
            }
        });
        textMap.putAll(thaiCalculationMap);
        ReportResultData reportResultData = new ReportResultData();
        reportResultData.setTextMap(textMap);
        return reportResultData;
    }
}