linzhijie
2021-03-24 b23f8cd1438c2b3c6f7e334502de619ffbb7fdc7
src/main/java/com/ots/project/exam/service/impl/TExamPaperServiceImpl.java
@@ -3,6 +3,8 @@
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ots.common.enums.LangTypeEnum;
import com.ots.common.enums.ReportTitle;
import com.ots.common.enums.SenderCode;
import com.ots.common.enums.UserTypeEnum;
import com.ots.common.utils.DateUtils;
@@ -32,6 +34,7 @@
import com.ots.project.tool.report.reportCalculation.request.*;
import com.ots.project.tool.report.reportCalculation.response.ReportAPIResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.velocity.runtime.directive.Foreach;
import org.modelmapper.ModelMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -859,7 +862,11 @@
        }
        // 调用发送程序发给用户
        String title = tExamReportResult.getMemberName() + MessageUtils.message("jsp.exam.quesiton.reportTilte");
        //String title = tExamReportResult.getMemberName() + MessageUtils.message("jsp.exam.quesiton.reportTilte");
        String title = getTitle(tExamReportResult);
        log.error("报告标题:{}",title);
        String content = tExamReportResult.getMailContent();
        StringBuilder remark = new StringBuilder();
        remark.append("失败邮箱:");
@@ -1246,4 +1253,40 @@
    }
    /***
     * 获取报告填写语言,返回标题
     */
    private String getTitle(TExamReport tExamReportResult){
        String title = tExamReportResult.getMemberName() + MessageUtils.message("jsp.exam.quesiton.reportTilte");
        //报告内容跟测试产品名称不为空
        if(StringUtils.isNotEmpty(tExamReportResult.getContent()) && StringUtils.isNotEmpty(tExamReportResult.getProductName())){
            JSONArray content = JSONObject.parseArray(tExamReportResult.getContent());
            //获取语言
            String langType = content.getJSONObject(0).getString("langType");
            String field = ReportTitle.getField(langType);
            String name = "";
            for (int i = 0; i < content.size(); i++) {
                JSONObject jsonObject = content.getJSONObject(i);
                if(StringUtils.isNotEmpty(field) && field.equals(jsonObject.getString("field"))){
                    name = jsonObject.getString("value");
                    break;
                }
            }
            //获取产品名称
            JSONObject productNameObj = JSONObject.parseObject(tExamReportResult.getProductName());
            String productName = productNameObj.getString(langType);
            if(StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(productName) && StringUtils.isNotEmpty(langType)){
                //泰文是先报告名称后姓名 其他相反
                if(langType.equals(LangTypeEnum.Thai.getCode())){
                    title = String.format(ReportTitle.getReportTitle(langType),productName,name);
                }else{
                    title = String.format(ReportTitle.getReportTitle(langType),name,productName);
                }
            }
        }
        return title;
    }
}