From 3a8e1524dcf0eeb610d38123d5f0a3ef838379cd Mon Sep 17 00:00:00 2001
From: linzhijie <19970921lzj>
Date: 星期一, 12 四月 2021 15:44:53 +0800
Subject: [PATCH] Merge branch '20210406-maqv2' into 20210412-youhua

---
 src/main/java/com/ots/project/exam/service/impl/TExamPaperServiceImpl.java |   53 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/ots/project/exam/service/impl/TExamPaperServiceImpl.java b/src/main/java/com/ots/project/exam/service/impl/TExamPaperServiceImpl.java
index 7a54b0a..db0c951 100644
--- a/src/main/java/com/ots/project/exam/service/impl/TExamPaperServiceImpl.java
+++ b/src/main/java/com/ots/project/exam/service/impl/TExamPaperServiceImpl.java
@@ -1,8 +1,9 @@
 package com.ots.project.exam.service.impl;
-
 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 +33,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;
@@ -39,10 +41,8 @@
 import org.springframework.context.i18n.LocaleContextHolder;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-
 import java.util.*;
 import java.util.stream.Collectors;
-
 import static com.ots.project.tool.report.reportCalculation.request.CalculationTypeEnum.*;
 import static com.ots.project.tool.report.reportCalculation.request.ReportTypeEnum.firstPath;
 import static com.ots.project.tool.report.reportCalculation.request.ReportTypeEnum.secondPath;
@@ -859,14 +859,21 @@
         }
 
         // 璋冪敤鍙戦�佺▼搴忓彂缁欑敤鎴�
-        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();
+        //娴嬭瘯鑰呮帴鏀舵姤鍛婃ā鏉夸紭鍏堜娇鐢ㄦ祴璇曞寘淇濆瓨鐨勬姤鍛婃ā鏉�
+        String memberContent = tExamReportResult.getMemberTemplate();
+
         StringBuilder remark = new StringBuilder();
         remark.append("澶辫触閭锛�");
 
         if (justMember) {
             // 鐢ㄦ埛鍙戦偖浠�
-            sendMemberEmail(tExamReport, fileNameResult, tExamReportResult, title, content, remark);
+            sendMemberEmail(tExamReport, fileNameResult, tExamReportResult, title, memberContent, remark);
         }
         if (justHr) {
             // 鍙戦�佺粰Hr,浣嗗彇testEmail
@@ -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;
+    }
+
 }

--
Gitblit v1.9.1