package com.ots.project.tool.report.MAQNEW.condition;
|
import com.ots.common.enums.LangTypeEnum;
|
import com.ots.common.utils.StringUtils;
|
import com.ots.project.exam.domain.TLibraryCode;
|
import com.ots.project.tool.CacheServiceFactory;
|
import com.ots.project.tool.report.MAQNEW.base.BaseCondition_V2;
|
import lombok.Getter;
|
import lombok.Setter;
|
import lombok.extern.slf4j.Slf4j;
|
import java.util.HashMap;
|
import java.util.Map;
|
import java.util.Objects;
|
import static com.ots.common.enums.LangTypeEnum.*;
|
|
@Getter
|
@Setter
|
@Slf4j
|
public class KeyPointsStrengths_V2 extends BaseCondition_V2 {
|
private String name = "KeyPointsStrengths_V2";
|
public TLibraryCode calculate(Map<String, String> map, LangTypeEnum langType) {
|
try {
|
Map<String, String> paramMap = new HashMap();
|
paramMap.put("LIBMAQV21010,LIBMAQV21055", map.get("P_Flex01"));
|
paramMap.put("LIBMAQV22010,LIBMAQV22055", map.get("P_Creat02"));
|
paramMap.put("LIBMAQV23010,LIBMAQV23055", map.get("P_Analyt03"));
|
paramMap.put("LIBMAQV210010,LIBMAQV210055", map.get("P_Plan10"));
|
paramMap.put("LIBMAQV216010,LIBMAQV216055", map.get("P_Team16"));
|
paramMap.put("LIBMAQV221010,LIBMAQV221055", map.get("P_Confid21"));
|
paramMap.put("LIBMAQV215010,LIBMAQV215055", map.get("P_Influ15"));
|
Map<String, Boolean> calculateMap = new HashMap();
|
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
|
if (checkParamsNonNull(entry.getValue()) && Double.valueOf(entry.getValue()) >= 70) {
|
calculateMap.put(entry.getKey(), true);
|
}
|
}
|
if (calculateMap.isEmpty()) {
|
calculateMap.put("LIBMAQV233052", true);
|
}
|
TLibraryCode maqReportLibrary = spliceTrueObject(calculateMap, map, langType);
|
return maqReportLibrary;
|
} catch (Exception ex) {
|
log.error("KeyPointsStrengths error:{}", ex.getMessage(), ex);
|
return null;
|
}
|
}
|
@Override
|
public Map<String, String> getMAQwaterDropsImages() {
|
return null;
|
}
|
protected TLibraryCode spliceTrueObject(Map<String, Boolean> calculateMap, Map<String, String> map, LangTypeEnum langType) {
|
TLibraryCode result = new TLibraryCode();
|
StringBuilder context = new StringBuilder();
|
for (Map.Entry<String, Boolean> entry : calculateMap.entrySet()) {
|
Boolean value = entry.getValue();
|
if (value) {
|
TLibraryCode ret = getMaqReportLibrary2(map, entry.getKey(), langType);
|
context.append(ret.getLangTypeContext(langType));
|
context.append("%line-feed%");
|
}
|
}
|
result.setLangTypeContext(context.toString(), langType);
|
if (StringUtils.isBlank(context)) {
|
if (langType == English) {
|
context.append("No caution was found.");
|
} else if (langType == Chinese) {
|
context.append("没有发现优势项。");
|
} else if (langType == Thai) {
|
context.append("No caution was found.");
|
}
|
result.setLangTypeContext(context.toString(), langType);
|
}
|
return result;
|
}
|
public TLibraryCode getMaqReportLibrary2(Map<String, String> map, String codeId, LangTypeEnum langType) {
|
StringBuilder content = new StringBuilder();
|
String[] split = codeId.split(",");
|
for (int i = 0; i < split.length; i++) {
|
TLibraryCode maqReportLibrary = CacheServiceFactory.getInstance().getMAQReportLibrary(split[i]);
|
if (Objects.isNull(maqReportLibrary)) {
|
log.error("************** LibraryCode 没有配置 code = {} ***********", split[i]);
|
} else {
|
if (i == 0) {
|
content.append("<BoldText>");
|
content.append("<YellowText>");
|
content.append(maqReportLibrary.getLangTypeContext(langType));
|
content.append("</YellowText>");
|
content.append("</BoldText>");
|
} else {
|
content.append(maqReportLibrary.getLangTypeContext(langType));
|
}
|
}
|
}
|
TLibraryCode result = new TLibraryCode();
|
result.setLangTypeContext(content.toString(), langType);
|
dynamicParameterSubstitution2(map, result, langType);
|
return result;
|
}
|
public void dynamicParameterSubstitution2(Map<String, String> map, TLibraryCode maqReportLibrary, LangTypeEnum langType) {
|
map.forEach((key, value) -> {
|
String content = maqReportLibrary.getLangTypeContext(langType);
|
String replaceStr = "%" + key + "%";
|
maqReportLibrary.setLangTypeContext(content.replace(replaceStr, value), langType);
|
});
|
}
|
}
|