From b23f8cd1438c2b3c6f7e334502de619ffbb7fdc7 Mon Sep 17 00:00:00 2001
From: linzhijie <19970921lzj>
Date: 星期三, 24 三月 2021 19:24:01 +0800
Subject: [PATCH] 报告邮件标题跟随语言变换

---
 src/main/java/com/ots/project/exam/controller/TExamPaperController.java |  193 +++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 149 insertions(+), 44 deletions(-)

diff --git a/src/main/java/com/ots/project/exam/controller/TExamPaperController.java b/src/main/java/com/ots/project/exam/controller/TExamPaperController.java
index 96b2286..3fe7a04 100644
--- a/src/main/java/com/ots/project/exam/controller/TExamPaperController.java
+++ b/src/main/java/com/ots/project/exam/controller/TExamPaperController.java
@@ -1,4 +1,5 @@
 package com.ots.project.exam.controller;
+
 import com.alibaba.fastjson.JSONArray;
 import com.ots.common.utils.StringUtils;
 import com.ots.common.utils.bean.BeanUtils;
@@ -38,6 +39,7 @@
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.multipart.MultipartFile;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -45,29 +47,46 @@
 import java.util.Objects;
 import java.util.stream.Collectors;
 
+/**
+ * 浜у搧鍖呭垪琛–ontroller
+ *
+ * @author ots
+ * @date 2019-11-20
+ */
 @Controller
 @RequestMapping("/exam/product")
 public class TExamPaperController extends BaseController {
     private String prefix = "exam/product";
+
     @Autowired
     private ITExamPaperService tExamPaperService;
+
     @Autowired
     private ITTextContentService tTextContentService;
+
     @Autowired
     private ITExamLevelService itExamLevelService;
+
     @Autowired
     private IDictDataService dictDataService;
+
     @Autowired
     private IExamUtilService examUtilService;
+
     @Autowired
     private ITReportTemplateService reportTemplateService;
+
     protected final static ModelMapper modelMapper = ModelMapperSingle.Instance();
+
     @RequiresPermissions("exam:product:view")
     @GetMapping()
     public String product() {
         return prefix + "/product";
     }
-    
+
+    /**
+     * 鏌ヨ浜у搧鍖呭垪琛ㄥ垪琛�
+     */
     @RequiresPermissions("exam:product:list")
     @PostMapping("/list")
     @ResponseBody
@@ -76,7 +95,10 @@
         List<TExamPaper> list = tExamPaperService.selectTExamPaperList(tExamPaper);
         return getDataTable(list);
     }
-    
+
+    /**
+     * 瀵煎嚭浜у搧鍖呭垪琛ㄥ垪琛�
+     */
     @RequiresPermissions("exam:product:export")
     @PostMapping("/export")
     @ResponseBody
@@ -85,17 +107,23 @@
         ExcelUtil<TExamPaper> util = new ExcelUtil<TExamPaper>(TExamPaper.class);
         return util.exportExcel(list, "product");
     }
-    
+
+    /**
+     * 鏂板浜у搧鍖呭垪琛�
+     */
     @GetMapping("/add/{id}")
     public String add(@PathVariable("id") Long id, ModelMap mmap) {
-        
+        // 杩欏彞浠g爜涓轰簡鎻愮ず浼犺繃鏉ョ殑id鏄痩evelId
         Long levelId = id;
         TExamLevel tExamLevel = itExamLevelService.selectTExamLevelById(levelId);
         mmap.put("tExamLevel", tExamLevel);
         mmap.put("templateList", reportTemplateService.getReportTemplates(ShiroUtils.getSysUser()));
         return prefix + "/add-" + tExamLevel.getQuestionTemplateId();
     }
-    
+
+    /**
+     * 鏂板淇濆瓨浜у搧鍖呭垪琛�
+     */
     @RequiresPermissions("exam:product:add")
     @Log(title = "浜у搧鍖呭垪琛�", businessType = BusinessType.INSERT)
     @PostMapping("/add")
@@ -103,21 +131,27 @@
     public AjaxResult addSave(TExamPaper tExamPaper) {
         return toAjax(tExamPaperService.insertTExamPaper(tExamPaper));
     }
-    
+
+    /**
+     * 淇敼浜у搧鍖呭垪琛�
+     */
     @GetMapping("/edit/{id}")
     public String edit(@PathVariable("id") Long id, ModelMap mmap) {
         TExamPaper tExamPaper = tExamPaperService.selectTExamPaperById(id);
-        
+        //鑾峰彇棰樼洰鐨勫唴瀹瑰睍绀�
         List<ExamPaperTitleItem> examPaperTitleItemList = tExamPaperService.getExamPaperTitleContent(tExamPaper);
         mmap.put("examPaperTitleItemList", examPaperTitleItemList);
         mmap.put("templateList", reportTemplateService.getReportTemplates(ShiroUtils.getSysUser()));
         mmap.put("tExamPaper", tExamPaper);
-        
+        // 璺冲埌鍏蜂綋鐨勯〉闈�
         TExamLevel tExamLevel = itExamLevelService.selectTExamLevelById(tExamPaper.getLevelId());
         mmap.put("tExamLevel", tExamLevel);
         return prefix + "/edit-" + tExamLevel.getQuestionTemplateId();
     }
-    
+
+    /**
+     * 淇敼淇濆瓨浜у搧鍖呭垪琛�
+     */
     @RequiresPermissions("exam:product:edit")
     @Log(title = "浜у搧鍖呭垪琛�", businessType = BusinessType.UPDATE)
     @PostMapping("/edit")
@@ -125,7 +159,10 @@
     public AjaxResult editSave(TExamPaper tExamPaper) {
         return toAjax(tExamPaperService.updateTExamPaper(tExamPaper));
     }
-    
+
+    /**
+     * 鍒犻櫎浜у搧鍖呭垪琛�
+     */
     @RequiresPermissions("exam:product:remove")
     @Log(title = "浜у搧鍖呭垪琛�", businessType = BusinessType.DELETE)
     @PostMapping("/remove")
@@ -133,13 +170,17 @@
     public AjaxResult remove(String ids) {
         return toAjax(tExamPaperService.deleteTExamPaperByIds(ids));
     }
-    
+
+    /**
+     * 閫夐鐩紝ABCD鐨勯鐩�
+     */
     @GetMapping("/addQuestion/{levelId}/{langType}")
     public String addQuestion(@PathVariable("levelId") Long levelId, @PathVariable("langType") String langType, ModelMap mmap) {
         mmap.put("level", levelId);
         mmap.put("langType", langType);
         return prefix + "/add_question";
     }
+
     @GetMapping("/addIntelligenceTitleQuestion/{levelId}/{langType}")
     public String addIntelligenceTitleQuestion(@PathVariable("levelId") Long levelId, @PathVariable("langType") String langType, ModelMap mmap) {
         mmap.put("level", levelId);
@@ -147,6 +188,7 @@
         mmap.put("template", "intelligence_title");
         return prefix + "/add_question";
     }
+
     @GetMapping("/addIntelligenceQuestion/{levelId}/{langType}")
     public String addIntelligenceQuestion(@PathVariable("levelId") Long levelId, @PathVariable("langType") String langType, ModelMap mmap) {
         mmap.put("level", levelId);
@@ -154,57 +196,78 @@
         mmap.put("template", "intelligence");
         return prefix + "/add_question";
     }
-    
+
+    /**
+     * 閫夐鐩紝ABCD鐨勯鐩�
+     */
     @GetMapping("/addTitle/{questionTemplateId}/{langType}")
     public String addTitle(@PathVariable("questionTemplateId") String questionTemplateId, @PathVariable("langType") String langType, ModelMap mmap) {
         mmap.put("questionTemplateId", questionTemplateId);
         mmap.put("langType", langType);
         return prefix + "/add_title";
     }
-    
+
+    /**
+     * 鏂板娴嬭瘯鍖呯鐞�
+     */
     @GetMapping("/getProdList")
     public String getProdList(String langType,String testType,ModelMap mmap) {
         mmap.put("langType", langType);
         mmap.put("testType", testType);
         return prefix + "/prodtree";
     }
-    
+
+    /**
+     * 鍔犺浇瀛楀吀鍒楄〃鏍�
+     */
     @GetMapping("/treeData/{langType}/{testType}")
     @ResponseBody
     public List<Ztree> treeData(@PathVariable("langType") String langType,@PathVariable("testType") String testType) {
         System.out.println(langType);
         List<Ztree> ztrees = tExamPaperService.selectProdTree(testType);
-        
+        // 澶氳瑷�缈昏瘧
         ztrees.stream().forEach(ztree -> {
             ztree.setName(ExamUtil.getLangString(langType, ztree.getName()));
         });
         return ztrees;
     }
-    
+
+    /**
+     * 鎵归噺瀵煎叆娴嬭瘯浜哄憳鍚嶅崟
+     */
     @RequiresPermissions("exam:product:import")
     @PostMapping("/importJobData/{langType}/{levelId}/{levelName}")
     @ResponseBody
     public AjaxResult importJobData(MultipartFile file, @PathVariable("langType") String langType, @PathVariable("levelId") Long levelId, @PathVariable("levelName") String leveltName, boolean updateSupport) throws Exception {
         ExcelUtil<QuestionJobImport> util = new ExcelUtil<>(QuestionJobImport.class);
         QuestionJobImport questionJobImport = util.importJobExcel(file.getInputStream(),levelId, leveltName, langType);
+
         List<TQuestion> questionList = questionJobImport.getQuestionList();
-        
+
+        // 澶ч鐩job_title
         for (TQuestion tQuestion : questionList) {
             tQuestion.setTemplate("job_title");
         }
-        
-        
+        // 缈昏瘧澶氳瑷�
+        // 鏇存柊銆佸叆搴撻�昏緫, 澶氳瑷�
         updateBatchImportData(langType, JsonUtil.toJsonStr(questionJobImport.getMultilingualList()), questionList);
+
         if (StringUtils.isEmpty(questionJobImport.getLangType())) {
             return AjaxResult.success(questionJobImport);
         }
+
         if (Objects.isNull(questionJobImport) || Objects.isNull(questionJobImport.getQuestionList()) || questionJobImport.getQuestionList().isEmpty()) {
             return AjaxResult.error("瀵煎叆澶辫触");
         }
-        
+
+        // 缈昏瘧澶氳瑷�
         return AjaxResult.success(questionJobImport);
     }
-    
+
+
+    /**
+     * 鎵归噺瀵煎叆娴嬭瘯浜哄憳鍚嶅崟妯℃澘涓嬭浇
+     */
     @RequiresPermissions("exam:product:view")
     @GetMapping("/importTemplate")
     @ResponseBody
@@ -212,7 +275,10 @@
         ExcelUtil<QuestionJobImport> util = new ExcelUtil<>(QuestionJobImport.class);
         return util.importTemplateQuestionExcel("JAQ棰樼洰妯℃澘.xlsx");
     }
-    
+
+    /**
+     * 鎵归噺瀵煎叆娴嬭瘯浜哄憳鍚嶅崟妯℃澘涓嬭浇
+     */
     @RequiresPermissions("exam:product:view")
     @GetMapping("/importMAQTemplate")
     @ResponseBody
@@ -220,7 +286,10 @@
         ExcelUtil<QuestionPersonalityImport> util = new ExcelUtil<>(QuestionPersonalityImport.class);
         return util.importTemplateQuestionExcel("MAQ棰樼洰妯℃澘.xlsx");
     }
-    
+
+    /**
+     * 鎵归噺瀵煎叆娴嬭瘯浜哄憳鍚嶅崟
+     */
     @RequiresPermissions("exam:product:import")
     @PostMapping("/importMAQData/{langType}")
     @ResponseBody
@@ -230,18 +299,23 @@
         if (StringUtils.isEmpty(questionPersonalityImport.getLangType())) {
             return AjaxResult.success(questionPersonalityImport);
         }
+
         List<TQuestion> questionList = questionPersonalityImport.getQuestionList();
-        
+
+        // 鏍¢獙鏈夋晥鎬�
         if (Objects.isNull(questionPersonalityImport) || Objects.isNull(questionList) || questionList.isEmpty()) {
             return AjaxResult.error("瀵煎叆澶辫触");
         }
-        
+        // 鏇存柊銆佸叆搴撻�昏緫, 澶氳瑷�
         updateBatchImportData(langType, JsonUtil.toJsonStr(questionPersonalityImport.getMultilingualList()), questionList);
+
         return AjaxResult.success(questionPersonalityImport);
     }
-    
+
+    // 鏇存柊銆佸叆搴撻�昏緫, 澶氳瑷�
     private void updateBatchImportData(@PathVariable String langType, String multilinguag, List<TQuestion> questionList) {
         tExamPaperService.updateInsertQuestion(questionList, multilinguag);
+
         for (TQuestion tQuestion : questionList) {
             tQuestion.setTitle(examUtilService.getLangOrLocalLangString(langType, tQuestion.getTitle()));
             List<String> selectInput = tQuestion.getSelectInput();
@@ -254,14 +328,23 @@
             }
         }
     }
-    
+
+    /**
+     * 鎵归噺瀵煎叆娴嬭瘯浜哄憳鍚嶅崟妯℃澘涓嬭浇
+     */
     @RequiresPermissions("exam:product:changeDeleted")
     @PostMapping("/changeDeleted")
     @ResponseBody
     public AjaxResult changeDeleted(TExamPaper tExamPaper) {
         return toAjax(tExamPaperService.updateDeleted(tExamPaper));
     }
-    
+
+    /**
+     * 浜у搧鍖呮柊澧炶瑷�鍏ュ彛锛屼骇鍝佸寘澶氳瑷�娣诲姞鍏ュ彛
+     * @param uuid
+     * @param mmap
+     * @return
+     */
     @GetMapping("/addLang/{uuid}/{langType}")
     public String addLang(@PathVariable("uuid") Long uuid, @PathVariable("langType") String langType, ModelMap mmap) {
         TExamPaper tExamPaper = tExamPaperService.selectTExamPaperById(uuid);
@@ -269,21 +352,27 @@
         tExamPaper.setLangName(getDitcByType("lang_type", langType));
         tExamPaper.setUuid(uuid);
         tExamPaper.setOperatingLanguage("addLang");
-        
+
+        //鑾峰彇棰樼洰鐨勫唴瀹瑰睍绀�
         List<ExamPaperTitleItem> examPaperTitleItemList = getExamPaperTitleItems(mmap, tExamPaper);
+
         mmap.put("templateList", reportTemplateService.getReportTemplates(ShiroUtils.getSysUser()));
         mmap.put("tExamPaper", tExamPaper);
-        
+        // 璺冲埌鍏蜂綋鐨勯〉闈�
         TExamLevel tExamLevel = itExamLevelService.selectTExamLevelById(tExamPaper.getLevelId());
         mmap.put("tExamLevel", tExamLevel);
-        
+        // 鎵归噺瀵煎叆鐨勬椂鍊欏睍绀洪鐩殑缁村害锛孞ob鎵嶉渶瑕侊紝缁村害閮芥槸涓�鏍风殑
         nmapPutQuestionItem(mmap, examPaperTitleItemList);
-        
+        // 澶氳瑷�娓呯悊鏁版嵁
         tExamPaper.setName("");
         tExamPaper.setGuide("");
+
         return prefix + "/edit-" + tExamLevel.getQuestionTemplateId();
     }
-    
+
+    /**
+     * 鏍规嵁璇█淇敼棰樼洰, 椤甸潰涓婄殑鏂板璇█璋冪敤锛屼骇鍝佸寘淇敼澶氳瑷�棰樼洰鍏ュ彛
+     */
     @GetMapping("/editLang/{uuid}/{langType}")
     public String editLang(@PathVariable("uuid") Long uuid, @PathVariable("langType") String langType, ModelMap mmap) {
         TExamPaper tExamPaper = tExamPaperService.selectTExamPaperById(uuid);
@@ -291,33 +380,44 @@
         tExamPaper.setId(uuid);
         tExamPaper.setLangType(langType);
         tExamPaper.setOperatingLanguage("editLang");
-        
+
+        // 澶氳瑷�
         tExamPaper.setName(ExamUtil.getStringByLang(tExamPaper.getLangType(), tExamPaper.getName()));
+
         tExamPaper.setGuide(ExamUtil.getStringByLang(tExamPaper.getLangType(), tExamPaper.getGuide()));
+
         tExamPaper.setLangName(getDitcByType("lang_type", langType));
         List<ExamPaperTitleItem> examPaperTitleItemList = getExamPaperTitleItems(mmap, tExamPaper);
-        
+
+        // 鎵归噺瀵煎叆鐨勬椂鍊欏睍绀洪鐩殑缁村害锛孞ob鎵嶉渶瑕侊紝缁村害閮芥槸涓�鏍风殑
         nmapPutQuestionItem(mmap, examPaperTitleItemList);
-        
+
+        // 澶氳瑷�
         mmap.put("tExamPaper", tExamPaper);
         mmap.put("templateList", reportTemplateService.getReportTemplates(ShiroUtils.getSysUser()));
-        
+        // 璺冲埌鍏蜂綋鐨勯〉闈�
         TExamLevel tExamLevel = itExamLevelService.selectTExamLevelById(tExamPaper.getLevelId());
         mmap.put("tExamLevel", tExamLevel);
+
         return prefix + "/edit-" + tExamLevel.getQuestionTemplateId();
     }
+
     private List<ExamPaperTitleItem> getExamPaperTitleItems(ModelMap mmap, TExamPaper tExamPaper) {
-        
+        //鑾峰彇棰樼洰鐨勫唴瀹瑰睍绀�
         List<ExamPaperTitleItem> examPaperTitleItemList = tExamPaperService.getExamPaperTitleContent(tExamPaper);
-        
+        // begin 閲嶅棰樼洰
         List<ExamPaperTitleItem> contentOriginalList = getExamDuplicateTitleItems(tExamPaper, examPaperTitleItemList);
-        
+        // end 閲嶅棰樼洰
         mmap.put("examPaperTitleItemList", contentOriginalList);
+
         nmapPutQuestionItem(mmap, examPaperTitleItemList);
+
         return examPaperTitleItemList;
     }
+
     private List<ExamPaperTitleItem> getExamDuplicateTitleItems(TExamPaper tExamPaper, List<ExamPaperTitleItem> examPaperTitleItemList) {
         List<ExamPaperTitleItem> contentOriginalList = JSONArray.parseArray(tExamPaper.getContent(), ExamPaperTitleItem.class);
+
         Map<Integer, QuestionItem> questionItemMap = new HashMap<>();
         for (ExamPaperTitleItem examPaperTitleItem : examPaperTitleItemList) {
             List<QuestionItem> questionItems = examPaperTitleItem.getQuestionItems();
@@ -325,11 +425,12 @@
                 questionItemMap.put(questionItem.getQuestionId(), questionItem);
             }
         }
+
         for (ExamPaperTitleItem examPaperTitleItem : contentOriginalList) {
             List<QuestionItem> questionItems = examPaperTitleItem.getQuestionItems();
             for (QuestionItem questionItem : questionItems) {
                 Integer partOrder = questionItem.getPartOrder();
-                
+                // 澶嶅埗棰樼洰閲岄潰涓嶅瓨鍦ㄧ殑灞炴�у悗鍐嶅鍒�
                 QuestionItem questionItemSource = questionItemMap.get(questionItem.getId());
                 questionItemSource.setTemplate(questionItem.getTemplate());
                 questionItemSource.setParentQuestionId(questionItem.getParentQuestionId());
@@ -339,26 +440,30 @@
         }
         return contentOriginalList;
     }
+
     private void nmapPutQuestionItem(ModelMap mmap, List<ExamPaperTitleItem> examPaperTitleItemList) {
-        
+        // 鎵归噺瀵煎叆鐨勬椂鍊欏睍绀洪鐩殑缁村害锛孞ob鎵嶉渶瑕侊紝缁村害閮芥槸涓�鏍风殑
         List<QuestionItem> questionItems = examPaperTitleItemList.get(0).getQuestionItems();
         mmap.put("questionItems", questionItems);
         mmap.put("parts", JsonUtil.toJsonStr(examPaperTitleItemList.get(0).getParts()));
     }
+
     @GetMapping("/deleteLang/{uuid}/{langType}")
     @ResponseBody
     public AjaxResult deleteLang(@PathVariable("uuid") Long uuid, @PathVariable("langType") String langType) {
-        
+        // 澶氳瑷�鐨勬椂鍊檜uid灏辨槸id
         TExamPaper tExamPaper = tExamPaperService.selectTExamPaperById(uuid);
         tExamPaper.setLangType(langType);
         return toAjax(tExamPaperService.deleteProductContent(tExamPaper));
     }
+
     private String getDitcByType(String type, String dictType) {
         List<DictData> langTypeList = dictDataService.selectDictDataByType(type);
         Map<String, String> lanTypeMap = langTypeList.stream().collect(Collectors.toMap(DictData::getDictValue, DictData::getDictLabel));
         return lanTypeMap.get(dictType);
     }
-    
+
+    // 寮瑰嚭璇█
     @GetMapping("/langType/{id}")
     public String getLangType(@PathVariable("id") Long id,  ModelMap mmap) {
         List<DictData> dictDataList = tExamPaperService.getType(id);

--
Gitblit v1.9.1