linzhijie
2021-03-11 93af1c6ffb9ae0e894689ad3a37b548e57d54cff
src/main/java/com/ots/project/exam/controller/TExamReportController.java
@@ -1,4 +1,5 @@
package com.ots.project.exam.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ArrayUtil;
@@ -63,7 +64,6 @@
import org.apache.commons.collections.map.HashedMap;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
@@ -77,6 +77,7 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
@@ -93,8 +94,15 @@
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import static com.ots.project.tool.report.reportCalculation.request.CalculationTypeEnum.JAQ;
/**
 * 评测报告Controller
 *
 * @author ots
 * @date 2019-12-26
 */
@Controller
@RequestMapping("/exam/report")
public class TExamReportController extends BaseController {
@@ -114,46 +122,63 @@
    private IExamUtilService iExamUtilService;
    @Autowired
    private IEntTestPackageService entTestPackageService;
    @Autowired
    private ITExamPaperService itExamPaperService;
    @Autowired
    private IEntDemographyInfoService entDemographyInfoService;
    @Autowired
    ReportCalculationServices calculationServices;
    @Autowired
    MemberService memberService;
    @Autowired
    ITQuestionService itQuestionService;
    @Autowired
    private TExamPaperServiceImpl examPaperService;
    @Autowired
    private ISysUserExtendService sysUserExtendService;
    /**
     * 企业报告授权,审批报表
     *
     * @return
     */
    @RequiresPermissions("exam:report:viewVerify")
    @GetMapping("/viewVerify")
    public String reportVerify() {
        return prefix + "/verifyReport";
    }
    /**
     * 查询评测报告列表
     */
    @RequiresPermissions("exam:report:viewVerify")
    @PostMapping("/verifyList")
    @ResponseBody
    public TableDataInfo verifyList(TExamReport tExamReport) {
        startPage();
        tExamReport.setStatus("1");
        tExamReport.setStatus("1");//测试包状态
        List<TExamReport> list = tExamReportService.selectTExamReportList(tExamReport);
        // 多语言
        String langType = dictService.getLangType(LocaleContextHolder.getLocale().toString());
        for (TExamReport tExamReportTemp : list) {
            tExamReportTemp.setProductName(ExamUtil.getLangString(langType, tExamReportTemp.getProductName()));
        }
        return getDataTable(list);
    }
    @RequiresPermissions("exam:report:view")
    @GetMapping()
    public String report() {
        return prefix + "/report";
    }
    @RequiresPermissions("exam:test_package:testreport")
    @GetMapping("/reportView/{testId}/{prodId}")
    public String reportView(@PathVariable String testId, @PathVariable String prodId, ModelMap mmap) {
@@ -161,6 +186,7 @@
        mmap.put("testId", testId);
        return prefix + "/report";
    }
    @RequiresPermissions("exam:test_package:testreport")
    @GetMapping("/member/reportView/{testId}/{memberId}")
    public String memberReportView(@PathVariable Long testId, @PathVariable String memberId, ModelMap mmap) {
@@ -170,7 +196,10 @@
        mmap.put("memberId", memberId);
        return prefix + "/report";
    }
    /**
     * 查询评测报告列表(头部)
     */
    @RequiresPermissions("exam:hrEmailReport:view")
    @PostMapping("/hrLog")
    @ResponseBody
@@ -179,7 +208,10 @@
        List<TExamReport> tExamReports = tExamReportService.selectTExamReportList(tExamReport);
        return getDataTable(tExamReports);
    }
    /**
     * 查询评测报告列表(头部)
     */
    @RequiresPermissions("exam:report:list")
    @PostMapping("/list")
    @ResponseBody
@@ -189,12 +221,15 @@
        if (Objects.isNull(tExamReport.getProductId())) {
            return getDataTable(list);
        }
        // 多语言取本地那种
        String langType = dictService.getLangType(LocaleContextHolder.getLocale().toString());
        list = tExamReportService.selectTExamReportList(tExamReport);
        if (Objects.isNull(list) || list.isEmpty()) {
            return getDataTable(list);
        }
        Map<String, String> filed = JSON.parseObject(list.get(0).getContent(), LinkedHashMap.class);
        Map<String, String> title = new LinkedHashMap<>();
        int i = 0;
@@ -213,11 +248,18 @@
        }
        title.put("测试包编码", String.valueOf(i++));
        title.put("答卷编码", String.valueOf(i++));
        List<Map<String, String>> filedList = new ArrayList<>();
        filedList.add(title);
        return getDataTable(filedList);
    }
    /**
     * 查询评测报告列表(数据列)
     *
     * @param tExamReport
     * @return
     */
    @RequiresPermissions("exam:report:list")
    @PostMapping("/listData")
    @ResponseBody
@@ -227,16 +269,20 @@
            return getDataTable(list);
        }
        startPage();
        // 完成的
        tExamReport.setFinish(1);
        list = tExamReportService.selectViewReportList(tExamReport);
        // 多语言翻译
        for (TExamReport tExamReportTemp : list) {
            tExamReportTemp.setProductName(examUtilService.getLangOrLocalLangString("", tExamReportTemp.getProductName()));
        }
        return getDataTable(list);
    }
    /**
     * 导出评测报告列表
     */
    @RequiresPermissions("exam:report:export")
    @PostMapping("/export")
    @ResponseBody
@@ -245,147 +291,172 @@
        ExcelUtil<TExamReport> util = new ExcelUtil<TExamReport>(TExamReport.class);
        return util.exportExcel(list, "report");
    }
    /**
     * 导出评测人员用户答题记录
     *
     * @param tExamReport
     * @return
     */
//    @RequiresPermissions("exam:report:export")
//    @PostMapping("/exportReport")
//    @ResponseBody
//    public AjaxResult exportReport(TExamReport tExamReport) {
//        DataMap<Integer, Object[]> dataMap = new DataMap<>();
//        List<TExamReport> list = tExamReportService.selectTExamReportList(tExamReport);
//
//        // 拼接生成report的键值对
//        User sysUser = ShiroUtils.getSysUser();
//        boolean isRight = Objects.equals(UserTypeEnum.SYS_USER.getUserType(), sysUser.getUserType());
//
//        int keyPosition = -1;
//        int keySize = 0;
//        List<DataMap> reportList = new ArrayList<>();
//        List<DataMap> reportTaiList = new ArrayList<>();
//        List<DataMap> reportLocalList = new ArrayList<>();
//        Map<String, String> mapPara = new HashedMap();
//        Set<String> langTypeSet = new HashSet<>();
//        for (TExamReport it : list) {
//            List<DataReport> dataReportList = new ArrayList<>();
//
//            // 读出人口学变量
//            setLocalDataReportByParamId(mapPara, it, dataReportList);
//
//            // 得到人口学有多少种语言
//            setDataReportLangSet(mapPara, langTypeSet);
//
//            // 取最多值那个
//            if (dataReportList.size() > keySize) {
//                keySize = dataReportList.size();
//                keyPosition++;
//            }
//
//            DataMap<String, String> dataReportMap = new DataMap<>();
//
//            // 非泰国团队的内容
//            setContentMap(it, dataReportList, dataReportMap, reportLocalList);
//
//            // 泰国团队的内容
//            setTaiInterfaceContentMap(it, dataReportMap, isRight, reportTaiList);
//
//            reportList.add(dataReportMap);
//        }
//
//        // 取key最多的,防止打乱
//        Object[] keys = reportTaiList.get(keyPosition).getKeys().toArray();
//
//        Object[] keysAll = reportList.get(keyPosition).getKeys().toArray();
//
//        List<Object[]> keyDemography = new ArrayList<>();
//
//        // 3行,3种语言
//        setAllLangLocalDataValue(keyPosition, reportLocalList, mapPara, langTypeSet, keyDemography);
//
//        int position = 0;
//        for (;position < keyDemography.size(); position++) {
//            // 表头另外的东西,答题不一致等等,如中文自夸_T1
//            setExtracHead(dataMap, keys, keyDemography, position);
//        }
//
//        for (int i = 0; i < reportList.size(); i++) {
//            DataMap<String,String> valueDataMap = reportList.get(i);
//            List<String> valueList = new ArrayList<>();
//            for (Object key : keysAll) {
//                valueList.add(valueDataMap.get(key.toString()));
//            }
//            dataMap.put(i + position, valueList.toArray());
//        }
//
//        ExcelUtil<DataMap> util = new ExcelUtil<DataMap>(DataMap.class);
//        // 导出数据报告只选一个测试包
//        return util.exportExcelByDataMap(dataMap, examUtilService.getLangOrLocalLangString("", list.get(0).getProductName()) + "_DateReport");
//    }
    // 导出数据报告
    @RequiresPermissions("exam:report:export")
    @PostMapping("/exportDataReport/{ids}")
    @ResponseBody
    public AjaxResult exportReport(TExamReport tExamReport, @PathVariable("ids") String[] ids) throws IOException {
        List<TExamReport> tExamReportList = tExamReportService.selectTExamReportByIds(ids);
        // 拼接生成report的键值对
        User sysUser = ShiroUtils.getSysUser();
        boolean isRight = Objects.equals(UserTypeEnum.SYS_USER.getUserType(), sysUser.getUserType());
        // 人口学变量
        // 三行
        DataReportHead dataReportHead = new DataReportHead();
        String fileNameResult = EssConfig.getDownloadPath() + examUtilService.getLangOrLocalLangString("", tExamReportList.get(0).getProductName()) + "_DateReport.xlsx";
        // 把sheet放在map里面
        Map<String, List<List<Object>>> reportResultMap = new HashMap<>();
        Map<String, Map<String, String>> demograpyMap = new HashMap<>();
        // 人口学
        setDemograyMap(tExamReportList, dataReportHead, demograpyMap);
        // 报告类型
        String reportType = getReportType(tExamReport);
        // 模版的内容
        setDataReportHeader(dataReportHead, reportResultMap, reportType, isRight);
        // Map<sheet名, Map<姓名, Map<key, value>>> 数据
        Map<String, Map<String, Map<String, String>>> sheetExcelMap = new HashMap<>();
        // 如果是JAQ要调用泰国团队的接口,如果不是,去表里面找
        setDealTaiData(ids, tExamReportList, reportType, sheetExcelMap);
        // 构造值
        setRportListValue(reportResultMap, demograpyMap, sheetExcelMap, reportType);
        // 弄成和他们原来一样
        setSysHeadToEnglish(tExamReportList, reportResultMap, reportType);
        // 写文件
        writeFile(fileNameResult, reportResultMap);
        // 返回下载
        return AjaxResult.success(examUtilService.getLangOrLocalLangString("", tExamReportList.get(0).getProductName()) + "_DateReport.xlsx");
    }
    private void setDealTaiData(@PathVariable("ids") String[] ids, List<TExamReport> tExamReportList, String reportType, Map<String, Map<String, Map<String, String>>> sheetExcelMap) throws IOException {
        if (Objects.equals(reportType, ReportTypeEnum.JAQ.getCode())) {
            // 要删除的文件
            List<TExamReport> tExamReports = tExamReportService.selectTExamReportByIds(ids);
            Map<String, TExamReport> tokenReportMap = new HashMap<>();
            for (TExamReport tExamReport : tExamReports) {
                tokenReportMap.put(tExamReport.getTokenId(), tExamReport);
            }
            // JAQ 调用泰国团队数据
            ReportAPIResult reportAPIResult = getThaiJAQData(tExamReports);
            // 泰国数据
            // JAQ Output Data
            Map<String, String> thaiData = reportAPIResult.getData();
            Map<String, Map<String, String>> excelOutPutMap = new HashMap<>();
            excelOutPutMap.put("JAQ", thaiData);
            sheetExcelMap.put("JAQ Output Data", excelOutPutMap);
            // JAQ Input Data
            Map<String, Map<String, String>> excelInputMap = new HashMap<>();
            List<JAQPersons> persons = (List<JAQPersons>) reportAPIResult.getAnswerData().get("persons");
            for (JAQPersons jaqPersons : persons) {
                Map<String, String> personInfo = jaqPersons.getPersonInfo();
                Map<String, String> personPoints = jaqPersons.getPersonPoints();
                String name = personInfo.get("fullName");
                Map<String, String> excelValueMap = new HashMap<>();
                excelValueMap.putAll(personInfo);
                excelValueMap.putAll(personPoints);
                excelValueMap.put("Name", name);
                excelInputMap.put(name, excelValueMap);
                tExamReportService.setExcelMapextraValue(tokenReportMap.get(excelValueMap.get("accessCode")), excelValueMap);
                tExamReportService.setExcelMapextraValue(tokenReportMap.get(excelValueMap.get("accessCode")), thaiData);
                tExamReportService.setExcelMapextraValue(tokenReportMap.get(excelValueMap.get("accessCode")), thaiData); // 为方便开发,不管性能
            }
            // 输出sheet的额外值
            sheetExcelMap.put("JAQ Input Data", excelInputMap);
        } else {
            Map<String, Map<String, String>> excelMap = new HashMap<>();
@@ -393,19 +464,21 @@
            sheetExcelMap.put("Sheet1", excelMap);
        }
    }
    private void setSysHeadToEnglish(List<TExamReport> tExamReportList, Map<String, List<List<Object>>> reportResultMap, String reportType) {
        Set<String> heavyDischargeDemography = new HashSet<>();
        Map<String, String> systemEnglisMap = new HashMap<>();
        for (TExamReport tExamReportIt : tExamReportList) {
            // 读出人口学变量,降维
            List<DemographyDataReportDto> demographyDataReportDtoList = setLocalDataReportByParamId(tExamReportIt);
            for (DemographyDataReportDto demographyDataReportDto : demographyDataReportDtoList) {
                // 排重用
                if (heavyDischargeDemography.contains(demographyDataReportDto.getParamId())) {
                    continue;
                } else {
                    heavyDischargeDemography.add(demographyDataReportDto.getParamId());
                }
                List<DemographyDto> demographyDtoList = JsonUtil.parseArray(demographyDataReportDto.getLangCode(), DemographyDto.class);
                for (DemographyDto demographyDto : demographyDtoList) {
                    if (Objects.equals(demographyDto.getLangType(), "English")) {
@@ -414,6 +487,7 @@
                }
            }
        }
        for (Map.Entry<String, List<List<Object>>> entryReport : reportResultMap.entrySet()) {
            List<Object> headSystem = entryReport.getValue().get(0);
            for (int i = 0; i < headSystem.size(); i++) {
@@ -423,11 +497,13 @@
            }
        }
    }
    private void setRportListValue(Map<String, List<List<Object>>> reportResultMap, Map<String, Map<String, String>> demograpyMap, Map<String, Map<String, Map<String, String>>> sheetExcelMap, String reportType) {
        for (Map.Entry<String, Map<String, Map<String, String>>> sheetEntry : sheetExcelMap.entrySet()) {
            for (Map.Entry<String, Map<String, String>> entry : sheetEntry.getValue().entrySet()) {
                // 接口
                ReportResultData resultData = getReportResultData(reportType, entry);
                Map<String, Object> textMap = new HashMap<>();
                textMap.putAll(resultData.getTextMap());
                textMap.putAll(demograpyMap.get(textMap.get("reportId")));
@@ -435,20 +511,20 @@
            }
        }
    }
    private void writeFile(String fileNameResult, Map<String, List<List<Object>>> reportResultMap) {
        for (Map.Entry<String, List<List<Object>>> entryReport : reportResultMap.entrySet()) {
            ExcelWriter writer = cn.hutool.poi.excel.ExcelUtil.getBigWriter(fileNameResult, entryReport.getKey());
            ExcelWriter writer = cn.hutool.poi.excel.ExcelUtil.getWriter(fileNameResult, entryReport.getKey());
            StyleSet styleSet = writer.getStyleSet();
            styleSet.setBorder(BorderStyle.NONE, IndexedColors.OLIVE_GREEN);
            writer.write(entryReport.getValue(), true);
            SXSSFSheet sheet = (SXSSFSheet) writer.getSheet();
            sheet.trackAllColumnsForAutoSizing();
            writer.autoSizeColumnAll();
            writer.close();
        }
    }
    private void setReportResultList(List<Object> demographyHeadSystem, List<List<Object>> reportResultList, Map<String, Object> textMap) {
        // 开始取值
        List<Object> reportValue = new ArrayList<>();
        for (Object key : demographyHeadSystem) {
            Object value = textMap.get(key.toString().trim().replace("%", ""));
@@ -458,14 +534,17 @@
                reportValue.add("");
            }
        }
        reportResultList.add(reportValue);
    }
    private ReportResultData getReportResultData(String reportType, Map.Entry<String, Map<String, String>> entry) {
        TExamReport tExamQueryReport = new TExamReport();
        String langType = examUtilService.getLocalLangType("");
        ReportResultData resultData = tExamReportService.getReportResultData(reportType, langType, entry, tExamQueryReport);
        return resultData;
    }
    private Map<String, LangTypeEnum> getStringLangTypeEnumMap() {
        Map<String, LangTypeEnum> langTypeEnumMap = new HashMap<>();
        for (LangTypeEnum langTypeEnumTemp : LangTypeEnum.values()) {
@@ -473,6 +552,7 @@
        }
        return langTypeEnumMap;
    }
    private String getReportType(TExamReport tExamReport) {
        String reportType = ReportTypeEnum.RuiLin.getCode();
        TExamPaper tExamPaper = itExamPaperService.selectTExamPaperById(tExamReport.getProductId());
@@ -481,16 +561,21 @@
            if (Objects.isNull(tReportTemplate.getReportType())) {
                continue;
            }
            // 取第一个模版的配置
            reportType = ReportTypeEnum.valueOf(tReportTemplate.getReportType()).getCode();
            // 如果是SAQ走SAQ的模版
            if (Objects.equals(tReportTemplate.getTemplateType(), "SAQ")) {
                reportType = ReportTypeEnum.valueOf(tReportTemplate.getTemplateType()).getCode();
            }
            break;
        }
        return reportType;
    }
    private void setDataReportHeader(DataReportHead dataReportHead, Map<String, List<List<Object>>> reportResultMap, String reportType, boolean isRight) {
        if (Objects.equals(reportType, ReportTypeEnum.RuiLin.getCode())) {
            setDataReportHeaderRuilin(dataReportHead, reportResultMap, isRight);
@@ -504,6 +589,7 @@
            setDataReportHeadMaq(dataReportHead, reportResultMap, isRight);
        }
    }
    private void setDataReportHeadMaq(DataReportHead dataReportHead, Map<String, List<List<Object>>> reportResultMap, boolean isRight) {
        ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "MAQHead.xlsx"));
        List<String> sheetNames = reader.getSheetNames();
@@ -524,6 +610,7 @@
            deleteNoRightKeys(dataReportHead, isRight, readList, i);
        }
    }
    private void setDataReportHeadSaq(DataReportHead dataReportHead, Map<String, List<List<Object>>> reportResultMap, boolean isRight) {
        ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "SAQHead.xlsx"));
        List<String> sheetNames = reader.getSheetNames();
@@ -544,18 +631,20 @@
            deleteNoRightKeys(dataReportHead, isRight, readList, i);
        }
    }
    private void setDataReportHeadJaq(DataReportHead dataReportHead, Map<String, List<List<Object>>> reportResultMap) {
        ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "JAQHead.xlsx"));
        List<String> sheetNames = reader.getSheetNames();
        // JAQ不要人口学,所以要clear
        List<Object> headSystem = dataReportHead.getHeadSystem();
        List<Object> headEnglish = dataReportHead.getHeadEnglish();
        for (String sheetName : sheetNames) {
            ExcelReader readerSheet = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "JAQHead.xlsx"), sheetName);
            List<List<Object>> readList = readerSheet.read();
            if (Objects.equals("JAQ Input Data", sheetName)) {
                List<Object> head = readList.get(0);
                // Name   AccessCode   Phone   Department + 人口学
                String[] heads = {"Name", "AccessCode", "Phone", "Department"};
                List<Object> headList = CollUtil.toList(heads);
                Set headExtends = new HashSet(headList);
@@ -564,6 +653,7 @@
                        headList.add(headSystem.get(i));
                    }
                }
                head.addAll(0, headList);
            }
            List<List<Object>> reportResultList = new ArrayList<>();
@@ -572,14 +662,17 @@
            reportResultList.add(readList.get(i++));
        }
    }
    private void setDataReportHeadCaq(DataReportHead dataReportHead, Map<String, List<List<Object>>> reportResultMap, boolean isRight) {
        ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "CAQHead.xlsx"));
        List<String> sheetNames = reader.getSheetNames();
        for (String sheetName : sheetNames) {
            ExcelReader readerSheet = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "CAQHead.xlsx"), sheetName);
            List<List<Object>> readList = readerSheet.read();
            List<List<Object>> reportResultList = new ArrayList<>();
            reportResultMap.put(sheetName, reportResultList);
            int i = 0;
            dataReportHead.getHeadSystem().addAll(readList.get(i++));
            reportResultList.add(dataReportHead.getHeadSystem());
@@ -590,6 +683,7 @@
            deleteNoRightKeys(dataReportHead, isRight, readList, i);
        }
    }
    private void setDataReportHeaderRuilin(DataReportHead dataReportHead, Map<String, List<List<Object>>> reportResultMap, boolean isRight) {
        ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "RuiLinHead.xlsx"));
        List<String> sheetNames = reader.getSheetNames();
@@ -605,11 +699,14 @@
            deleteNoRightKeys(dataReportHead, isRight, readList, i);
            reportResultMap.put(sheetName, reportResultList);
        }
    }
    private void deleteNoRightKeys(DataReportHead dataReportHead, boolean isRight, List<List<Object>> readList, int i) {
        if (!isRight) {
//        if (true) {
            // 需要剔除的行
            Set<Object> rightSet = new HashSet();
            for (; i < readList.size(); i++) {
                List<Object> objects = readList.get(i);
@@ -623,6 +720,7 @@
            deleteNoRight(rightSet, dataReportHead.getHeadThai());
        }
    }
    private void deleteNoRight(Set<Object> rightSet, List<Object> headSystem) {
        if (CollUtil.isEmpty(headSystem)) {
            return;
@@ -634,27 +732,32 @@
            }
        }
    }
    private void setDemograyMap(List<TExamReport> tExamReportList, DataReportHead dataReportHead, Map<String, Map<String, String>> demograpyMap) {
        Set<String> heavyDischargeDemography = new HashSet<>();
        for (TExamReport tExamReportIt : tExamReportList) {
            // 读出人口学变量,降维
            List<DemographyDataReportDto> demographyDataReportDtoList = setLocalDataReportByParamId(tExamReportIt);
            Map<String, String> demograpyValueMap = new HashMap<>();
            for (DemographyDataReportDto demographyDataReportDto : demographyDataReportDtoList) {
                demograpyValueMap.put(demographyDataReportDto.getParamId(), demographyDataReportDto.getParamValue());
                // 排重用
                if (heavyDischargeDemography.contains(demographyDataReportDto.getParamId())) {
                    continue;
                } else {
                    heavyDischargeDemography.add(demographyDataReportDto.getParamId());
                }
                // 添加各种语言的表头
                setDataReportDemography(dataReportHead, demographyDataReportDto);
            }
            // 人口学键和值
            demograpyMap.put(tExamReportIt.getId().toString(), demograpyValueMap);
        }
    }
    private void setDataReportDemography(DataReportHead dataReportHead, DemographyDataReportDto demographyDataReportDto) {
        dataReportHead.getHeadSystem().add(demographyDataReportDto.getParamId());
        List<DemographyDto> demographyDtoList = JsonUtil.parseArray(demographyDataReportDto.getLangCode(), DemographyDto.class);
@@ -662,8 +765,9 @@
        findLandCode(dataReportHead.getHeadEnglish(), demographyDtoList, "English");
        findLandCode(dataReportHead.getHeadThai(), demographyDtoList, "Thai");
    }
    private void findLandCode(List<Object> demographyHeadLang, List<DemographyDto> demographyDtoList, String lang) {
        // 找出中文的
        boolean isLang = false;
        for (DemographyDto demographyDto : demographyDtoList) {
            if (Objects.equals(demographyDto.getLangType(), lang)) {
@@ -671,17 +775,20 @@
                isLang = true;
            }
        }
        if (!isLang) {
            demographyHeadLang.add("");
        }
    }
    private void setExtracHead(DataMap<Integer, Object[]> dataMap, Object[] keys, List<Object[]> keyDemography, int position) {
        // ISP_T1   IM_T1   Inconsistency_T1
        if (position == 1) {
            keys[0] = "ISP_T1";
            keys[1] = "IM_T1";
            keys[2] = "Inconsistency_T1";
        }
        if (position == 2) {
            keys[0] = "自夸_T1";
            keys[1] = "印象管理_T1";
@@ -690,15 +797,18 @@
        }
        dataMap.put(position, ArrayUtil.addAll(keyDemography.get(position), keys));
    }
    private void setAllLangLocalDataValue(int keyPosition, List<DataMap> reportLocalList, Map<String, String> mapPara, Set<String> langTypeSet, List<Object[]> keyDemography) {
        // 系统变量名哪一行,第一行
        setAllLangLocalRowValue(keyPosition, reportLocalList, mapPara, keyDemography, langTypeSet.iterator().next(), "系统内变量名");
        Map<String, Map<String, String>> multiLanguageMap = new HashedMap();
        setLangSystemV(multiLanguageMap);
        for (String langType : langTypeSet) {
            setAllLangLocalRowValue(keyPosition, reportLocalList, mapPara, keyDemography, langType, multiLanguageMap.get("Chinese").get(langType));
        }
    }
    private void setLangSystemV(Map<String, Map<String, String>> multiLanguageMap) {
        Map<String, String> langTypeChineseMap = new HashedMap();
        langTypeChineseMap.put("English", "导出后变量名(英文)");
@@ -706,22 +816,25 @@
        langTypeChineseMap.put("Thai", "导出后变量名(泰文)");
        multiLanguageMap.put("Chinese", langTypeChineseMap);
    }
    private void setClientV(Map<String, String> langTypeChineseMap) {
        langTypeChineseMap.put("English", "Client");
        langTypeChineseMap.put("Chinese", "企业客户名称");
        langTypeChineseMap.put("Thai", "Client");
    }
    private void setAllLangLocalRowValue(int keyPosition, List<DataMap> reportLocalList, Map<String, String> mapPara, List<Object[]> keyDemography, String langType, String systemVariable) {
        DataMap<String, String> reportLocalMap = reportLocalList.get(keyPosition);
        // 一行,行的paramid
        List<String> rowList = reportLocalMap.getKeys();
        List<String> rowValues = new ArrayList<>();
        // rowValues.add("系统变量");
        rowValues.add(systemVariable);
        for (String row : rowList) {
            // json串
            String rows = mapPara.get(row);
            // 做成map
            List<Map<String, String>> langMapList = JsonUtil.parseObject(rows, ArrayList.class);
            String langCode = "";
            for (Map<String, String> langMap : langMapList) {
@@ -731,12 +844,14 @@
            }
            rowValues.add(langCode);
        }
        // 企业用户
        Map<String, String> clientLangMap = new HashedMap();
        setClientV(clientLangMap);
        rowValues.add(clientLangMap.get(langType));
        keyDemography.add(rowValues.toArray());
    }
    private void setDataReportLangSet(Map<String, String> mapPara, Set<String> langTypeSet) {
        for (Map.Entry<String, String> entry : mapPara.entrySet()) {
            List<Map<String, String>> langMapList = JsonUtil.parseObject(entry.getValue(), ArrayList.class);
@@ -745,6 +860,7 @@
            }
        }
    }
    private List<DemographyDataReportDto> setLocalDataReportByParamId(TExamReport it) {
        EntDemographyInfo entDemographyInfoAsParam = new EntDemographyInfo();
        entDemographyInfoAsParam.setMemberId(it.getMemberId().longValue());
@@ -760,25 +876,32 @@
        }
        return demographyDataReportDtoList;
    }
    private void setTaiInterfaceContentMap(TExamReport it, DataMap<String, String> dataReportMap, boolean isRight, List<DataMap> reportTaiList) {
        try {
            DataMap<String, String> dataReportTaiMap = new DataMap<>();
            List<ReportAPIResult> reportAPIResultList = JsonUtil.parseArray(it.getInterfaceContent(), ReportAPIResult.class);
            DataReport dataReportTai = new DataReport();
            // 第一段
            set1PartDataReport(dataReportMap, dataReportTaiMap, isRight, reportAPIResultList, dataReportTai);
            // 第二段,不要权限,
            setNoRightPart(dataReportMap, dataReportTaiMap, reportAPIResultList, dataReportTai);
            // 第二段,要权限
            set2PartDataReport(dataReportMap, dataReportTaiMap, isRight, reportAPIResultList, dataReportTai);
            // 要权限,最后那一点Report
            setEndPartDataReport(dataReportMap, dataReportTaiMap, reportAPIResultList, dataReportTai, isRight);
            // 泰国团队的数据
            reportTaiList.add(dataReportTaiMap);
        } catch (Exception e) {
            logger.error("  id:" + it.getId() + "  memberName" + it.getMemberName() + "  " + it.getInterfaceContent());
        }
    }
    private void setEndPartDataReport(DataMap<String, String> dataReportMap, DataMap<String, String> dataReportTaiMap, List<ReportAPIResult> reportAPIResultList, DataReport dataReportTai, boolean isRight) {
        if (!isRight) {
            return;
@@ -793,6 +916,7 @@
            setDataReportValueMap(dataReportTaiMap, dataReportTai);
        }
    }
    private void set2PartDataReport(DataMap<String, String> dataReportMap, DataMap<String, String> dataReportTaiMap, boolean isRight, List<ReportAPIResult> reportAPIResultList, DataReport dataReportTai) {
        if (isRight) {
            List<String> keepPartOrderList = new ArrayList<>();
@@ -804,7 +928,7 @@
                setDataReportValueMap(dataReportMap, dataReportTai);
                setDataReportValueMap(dataReportTaiMap, dataReportTai);
            }
            // 然后题目
            Map<String, String> answerDataMap = new LinkedHashMap<>();
            Map<String, String> answerDataNoOrder = reportAPIResultList.get(1).getAnswerData();
            answerDataNoOrder.entrySet().stream().sorted(Map.Entry.comparingByKey())
@@ -817,6 +941,7 @@
            }
        }
    }
    private void setNoRightPart(DataMap<String, String> dataReportMap, DataMap<String, String> dataReportTaiMap, List<ReportAPIResult> reportAPIResultList, DataReport dataReportTai) {
        List<String> keepPartOrderList = new ArrayList<>();
        keepPartOrderList.addAll(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_ManStr,P_Confid21,P_Mind22,P_SDE23,P_IM24,P_INCON25,P_Open26,P_Consci27,P_Extro28,P_Agree29,P_EmSt30,P_Task31,P_People32,P_Judg33,STDA,DA,SLDA,SLAG,AG,STAG".split(",")));
@@ -828,20 +953,22 @@
            setDataReportValueMap(dataReportTaiMap, dataReportTai);
        }
    }
    private void set1PartDataReport(DataMap<String, String> dataReportMap, DataMap<String, String> dataReportTaiMap, boolean isRight, List<ReportAPIResult> reportAPIResultList, DataReport dataReportTai) {
        if (isRight) {
            // 要权限,第一段
            List<String> keepPartOrderList = new ArrayList<>();
            keepPartOrderList.addAll(Arrays.asList("P_SDE_T1,P_IM_T1,P_INCON_T1,Signal,INC1T1,INC2T1,INC3T1,INC4T1,INC5T1,INC6T1,INC7T1,INC8T1".split(",")));
            Map<String, String> taiDataMap = reportAPIResultList.get(0).getData();
            taiDataMap.put("Signal", reportAPIResultList.get(0).getSignal());
            // 第一段的泰国返回
            for (String keepPartOrder : keepPartOrderList) {
                dataReportTai.setField(keepPartOrder);
                dataReportTai.setValue(taiDataMap.get(keepPartOrder));
                setDataReportValueMap(dataReportMap, dataReportTai);
                setDataReportValueMap(dataReportTaiMap, dataReportTai);
            }
            Map<String, String> answerDataMap = new LinkedHashMap<>();
            Map<String, String> answerDataNoOrder = reportAPIResultList.get(0).getAnswerData();
            answerDataNoOrder.entrySet().stream().sorted(
@@ -850,10 +977,11 @@
                        public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
                            int key1 = Integer.valueOf(o1.getKey().substring(3));
                            int key2 = Integer.valueOf(o2.getKey().substring(3));
                            return key1 - key2;
                            return key1 - key2;  // 降序排序,如果想升序就反过来
                        }
                    }
            ).forEachOrdered(x -> answerDataMap.put(x.getKey(), x.getValue()));
            for (Map.Entry<String, String> entry : answerDataMap.entrySet()) {
                dataReportTai.setField(entry.getKey());
                dataReportTai.setValue(entry.getValue());
@@ -862,43 +990,52 @@
            }
        }
    }
    private void setContentMap(TExamReport it, List<DataReport> dataReportList, DataMap<String, String> dataReportMap, List<DataMap> reportLocalList) {
        DataMap<String, String> dataReportLocalMap = new DataMap<>();
        // 系统变量
        dataReportMap.put("variableNamesInTheSystem", "");
        dataReportList.stream().forEach(dataReport -> {
            // 判断权限
            if (StringUtils.isNotEmpty(dataReport.getRight())) {
                if (StringUtils.equals((UserTypeEnum.SYS_USER.getUserType()), dataReport.getRight())) {
                    setDataReportMap(dataReportMap, dataReport);
                    setDataReportMap(dataReportLocalMap, dataReport);
                }
            } else {
                setDataReportMap(dataReportMap, dataReport);
                setDataReportMap(dataReportLocalMap, dataReport);
            }
        });
        dataReportMap.put("Client", it.getUserName());
        reportLocalList.add(dataReportLocalMap);
    }
    private void setDataReportMap(DataMap<String, String> filed, DataReport dataReport) {
        filed.put(dataReport.getField(), iExamUtilService.getLangOrLocalLangString(dataReport.getLangType(), dataReport.getValue()));
    }
    private void setDataReportValueMap(DataMap<String, String> filed, DataReport dataReport) {
        filed.put(dataReport.getField(), dataReport.getValue());
    }
    // 简单报告
    @RequiresPermissions("exam:report:basisExport")
    @PostMapping("/exportBasisReport/{ids}/{langType}")
    @ResponseBody
    public AjaxResult exportBasisReport(@PathVariable("ids") String[] ids, @PathVariable("langType") String langType) {
        List<TExamReport> tExamReportList = tExamReportService.selectTExamReportByIds(ids);
        List<TReportTemplate> tReportTemplateList = itReportTemplateService.selectTReportTemplates(tExamReportList.get(0).getReportTemplateId());
        Map<String, ReportTypeEnum> reportTypeEnumMap = new HashMap<>();
        for (com.ots.common.enums.ReportTypeEnum reportTypeEnumTemp : ReportTypeEnum.values()) {
            reportTypeEnumMap.put(reportTypeEnumTemp.getCode(), reportTypeEnumTemp);
        }
        // 导出基础版本
        String questionTemplateId = tExamReportList.get(0).getQuestionTemplateId();
        String templateType = "Brief";
        String reportType = "";
@@ -906,7 +1043,7 @@
        String fileName = "";
        TReportTemplate tReportTemplate = tExamReportService.getReportTemplate(questionTemplateId, langType, templateType);
        try {
            // 处理睿邻
            for (TReportTemplate tReportTemplateTemp : tReportTemplateList) {
                if (Objects.equals(tReportTemplateTemp.getReportType(), "RuiLin")) {
                    tReportTemplate = tReportTemplateTemp;
@@ -915,6 +1052,7 @@
                    break;
                }
            }
            reportType = tReportTemplate.getReportType();
            path = itReportTemplateService.selectTReportTemplateFilePath(tReportTemplate);
            if (StringUtils.isEmpty(path)) {
@@ -924,6 +1062,7 @@
            e.printStackTrace();
            return AjaxResult.error(MessageUtils.message("jsp.exam.report.noTemplate"));
        }
        List<String> deleteFileStrList = new ArrayList<>();
        List<String> deleteStrList = new ArrayList<>();
        List<String> fileNameList = new ArrayList<>();
@@ -931,7 +1070,8 @@
        tExamReportService.setExportBaseOrDetailReportData(tExamReportList, deleteStrList, fileNameList, tReportTemplate);
        return wordUtil.exportBaseOrDetailReport(path, deleteFileStrList, fileNameList);
    }
    // 详细报告
    @RequiresPermissions("exam:report:detailReportexport")
    @PostMapping("/exportDetailedReport/{ids}/{langType}")
    @ResponseBody
@@ -942,39 +1082,47 @@
            tExamReport.setId(Long.valueOf(id));
            tExamReportList.add(tExamReport);
        }
        // 附件的位置,具体邮件附件的位置
        List<String> fileNameResult = new ArrayList<>();
        // 要删除的文件
        List<String> deleteStrList = new ArrayList<>();
        List<String> exportFileList = new ArrayList<>();
        List<TExamReport> tExamReports = tExamReportService.selectTExamReportByIds(ids);
        TExamReport tExamReport = tExamReports.get(0);
        String reportType = getReportType(tExamReport);
        if (Objects.equals("JAQ", reportType)) {
            dealJAQReport(deleteStrList, exportFileList, tExamReports);
        } else {
            // MAQ,SAQ,CAQ
            dealReprotFile(tExamReportList, fileNameResult, deleteStrList, exportFileList, reportType);
        }
        WordUtil wordUtil = new WordUtil();
        return wordUtil.exportBaseOrDetailReport("DataReport", deleteStrList, exportFileList);
    }
    // jaq报告 dealJAQReport
    private void dealJAQReport(List<String> deleteStrList, List<String> exportFileList, List<TExamReport> tExamReports) throws IOException {
        TExamReport tExamReport = tExamReports.get(0);
        ReportAPIResult reportAPIResult = getThaiJAQData(tExamReports);
        // 泰国数据
        Map<String, String> thaiData = reportAPIResult.getData();
        // 生成JAQ报告
        List<TReportTemplate> tReportTemplateList = itReportTemplateService.selectTReportTemplates(tExamReport.getReportTemplateId());
        Map<String, Object> textMap = new HashMap<>();
        // 构造表
        textMap.putAll(thaiData);
        WordUtil wordUtil = new WordUtil();
        textMap.put("sendEmailFileName", "JAQ");
        RelatedParty relatedParty = memberService.queryProdidByToken(tExamReport.getTokenId());
        for (TReportTemplate tReportTemplate : tReportTemplateList) {
            // 对第一张表的文字进行翻译
            Map<String, String> jaqMap = getJaqQuestionByPermanentIdMap(tReportTemplate, tExamReport);
            changTable1(textMap, tReportTemplate, thaiData);
            changTable2(textMap, tReportTemplate, thaiData);
@@ -987,12 +1135,14 @@
            textMap.put("superiorPosition", relatedParty.getSuperiorPosition());
            String zipFileName = wordUtil.makeReportFile(tReportTemplate.getLocation(), tReportTemplate, textMap, null, deleteStrList);
            exportFileList.add(zipFileName);
            // 删除要删的
            wordUtil.deleteFileByStr(deleteStrList);
        }
    }
    private void changTable4(Map<String, Object> textMap, TReportTemplate tReportTemplate, Map<String, String> jaqMap, Map<String, String> thaiData) {
        // 替换值
        for (Integer i = 1; i <= 3; i++) {
            textMap.put("T4com1item" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), jaqMap.get(thaiData.get("T4com1item" + i.toString()))));
            textMap.put("T4com2item" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), jaqMap.get(thaiData.get("T4com2item" + i.toString()))));
@@ -1003,25 +1153,32 @@
            textMap.put("T4com7item" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), jaqMap.get(thaiData.get("T4com7item" + i.toString()))));
            textMap.put("T4com8item" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), jaqMap.get(thaiData.get("T4com8item" + i.toString()))));
        }
        Map<String, String> tagMap = getTranslationCapability();
        // 替换值
        for (Integer i = 1; i <= 12; i++) {
            textMap.put("T4com" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), tagMap.get(thaiData.get("T4com" + i.toString()))));
        }
    }
    private void changTable3(Map<String, Object> textMap, TReportTemplate tReportTemplate, Map<String, String> jaqMap, Map<String, String> thaiData) {
        // 替换值
        for (Integer i = 1; i <= 25; i++) {
            textMap.put("T3item" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), jaqMap.get(thaiData.get("T3item" + i.toString()))));
        }
        WordUtil.changeJAQStyle(textMap, 2, 25, "T3Line");
        // 胜任力那一列替换
        Map<String, String> tagMap = getTranslationCapability();
        // 替换值
        for (Integer i = 1; i <= 25; i++) {
            textMap.put("T3com" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), tagMap.get(thaiData.get("T3com" + i.toString()))));
        }
    }
    @NotNull
    private Map<String, String> getJaqQuestionByPermanentIdMap(TReportTemplate tReportTemplate, TExamReport tExamReport) {
        List<QuestionReport> questionReports = JsonUtil.toJsonListObject(tExamReport.getQuestionReport(), QuestionReport.class);
@@ -1029,22 +1186,27 @@
        for (QuestionReport questionReport : questionReports) {
            jaqMap.put(questionReport.getPermanentId(), questionReport.getQuestionTitle());
        }
        // 取特定的那种语言生成报告
        List<TQuestion> tQuestions = itQuestionService.selectTQuestionByPermanentIds(new ArrayList<>(jaqMap.keySet()));
        for (TQuestion tQuestion : tQuestions) {
            QuestionObject questionObject = JsonUtil.parseObject(tQuestion.getContent(), QuestionObject.class);
            jaqMap.put(tQuestion.getPermanentId(), ExamUtil.getLangString(tReportTemplate.getLangType(), questionObject.getTitleContent()));
        }
        return jaqMap;
    }
    private void changTable1(Map<String, Object> textMap, TReportTemplate tReportTemplate, Map<String, String> thaiData) {
        Map<String, String> tagMap = getTranslationCapability();
        // 替换值
        for (Integer i = 1; i <= 12; i++) {
            String textValue = thaiData.get("T1com" + i.toString());
            textMap.put("T1com" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), tagMap.get(textValue)));
        }
    }
    private Map<String, String> getTranslationCapability() {
        ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(FileUtil.file(EssConfig.getReportTemplates() + "JAQTable1Tag.xlsx"));
        List<List<Object>> readList = reader.read();
@@ -1059,30 +1221,37 @@
        }
        return tagMap;
    }
    private void changTable2(Map<String, Object> textMap, TReportTemplate tReportTemplate, Map<String, String> thaiData) {
        Map<String, String> tagMap = getTranslationCapability();
        //JAQ上颜色
        WordUtil.changeJAQStyle(textMap, 1, 12, "T2Line");
        // 替换值
        for (Integer i = 1; i <= 12; i++) {
            textMap.put("T2com" + i.toString(), ExamUtil.getLangString(tReportTemplate.getLangType(), tagMap.get(thaiData.get("T2com" + i.toString()))));
        }
    }
    private ReportAPIResult getThaiJAQData(List<TExamReport> tExamReports) {
        List<JAQPersons> persons = new ArrayList<>();
        Integer personCout = 0;
        for (TExamReport tExamReport : tExamReports) {
            // 人的信息
            Map<String, String> personInfo = new LinkedHashMap<>();
            personInfo.put("accessCode", tExamReport.getTokenId());
            personInfo.put("fullName", tExamReport.getMemberName());
            // 答题的人
            JAQPersons person = new JAQPersons();
            person.setPersonInfo(personInfo);
            // 答题的选项
            Map<String, String> personPoints = new LinkedHashMap<>();
            person.setPersonPoints(personPoints);
            // 造数据,记得屏蔽,造jaq数据
//            makeJAQData(personPoints);
            List<QuestionReport> questionReportList = JsonUtil.parseArray(tExamReport.getQuestionReport(), QuestionReport.class);
            for (QuestionReport questionReport : questionReportList) {
@@ -1094,6 +1263,7 @@
            persons.add(person);
            personCout++;
        }
        Map<String, List<JAQPersons>> data = new LinkedHashMap<>();
        data.put("persons", persons);
        HolderInfo info = new HolderInfo();
@@ -1113,6 +1283,7 @@
        reportAPIResult.setAnswerData(data);
        return reportAPIResult;
    }
    private void makeJAQData(Map<String, String> personPoints) {
        String topics = "JAQ0001a,JAQ0001b,JAQ0002a,JAQ0002b,JAQ0003a,JAQ0003b,JAQ0004a,JAQ0004b,JAQ0005a,JAQ0005b,JAQ0006a,JAQ0006b,JAQ0007a,JAQ0007b,JAQ0008a,JAQ0008b,JAQ0009a,JAQ0009b,JAQ0010a,JAQ0010b,JAQ0011a,JAQ0011b,JAQ0012a,JAQ0012b,JAQ0013a,JAQ0013b,JAQ0014a,JAQ0014b,JAQ0015a,JAQ0015b,JAQ0016a,JAQ0016b,JAQ0017a,JAQ0017b,JAQ0018a,JAQ0018b,JAQ0019a,JAQ0019b,JAQ0020a,JAQ0020b,JAQ0021a,JAQ0021b,JAQ0022a,JAQ0022b,JAQ0023a,JAQ0023b,JAQ0024a,JAQ0024b,JAQ0025a,JAQ0025b,JAQ0026a,JAQ0026b,JAQ0027a,JAQ0027b,JAQ0028a,JAQ0028b,JAQ0029a,JAQ0029b,JAQ0030a,JAQ0030b,JAQ0031a,JAQ0031b,JAQ0032a,JAQ0032b,JAQ0033a,JAQ0033b,JAQ0034a,JAQ0034b,JAQ0035a,JAQ0035b,JAQ0036a,JAQ0036b,JAQ0037a,JAQ0037b,JAQ0038a,JAQ0038b,JAQ0039a,JAQ0039b,JAQ0040a,JAQ0040b,JAQ0041a,JAQ0041b,JAQ0042a,JAQ0042b,JAQ0043a,JAQ0043b,JAQ0044a,JAQ0044b,JAQ0045a,JAQ0045b,JAQ0046a,JAQ0046b,JAQ0047a,JAQ0047b,JAQ0048a,JAQ0048b,JAQ0049a,JAQ0049b,JAQ0050a,JAQ0050b,JAQ0051a,JAQ0051b,JAQ0052a,JAQ0052b,JAQ0053a,JAQ0053b,JAQ0054a,JAQ0054b,JAQ0055a,JAQ0055b,JAQ0056a,JAQ0056b,JAQ0057a,JAQ0057b,JAQ0058a,JAQ0058b,JAQ0059a,JAQ0059b,JAQ0060a,JAQ0060b,JAQ0061a,JAQ0061b,JAQ0062a,JAQ0062b,JAQ0063a,JAQ0063b,JAQ0064a,JAQ0064b,JAQ0065a,JAQ0065b,JAQ0066a,JAQ0066b,JAQ0067a,JAQ0067b,JAQ0068a,JAQ0068b,JAQ0069a,JAQ0069b,JAQ0070a,JAQ0070b,JAQ0071a,JAQ0071b,JAQ0072a,JAQ0072b,JAQ0073a,JAQ0073b,JAQ0074a,JAQ0074b,JAQ0075a,JAQ0075b,JAQ0076a,JAQ0076b,JAQ0077a,JAQ0077b,JAQ0078a,JAQ0078b,JAQ0079a,JAQ0079b,JAQ0080a,JAQ0080b,JAQ0081a,JAQ0081b,JAQ0082a,JAQ0082b,JAQ0083a,JAQ0083b,JAQ0084a,JAQ0084b,JAQ0085a,JAQ0085b,JAQ0086a,JAQ0086b,JAQ0087a,JAQ0087b,JAQ0088a,JAQ0088b,JAQ0089a,JAQ0089b,JAQ0090a,JAQ0090b,JAQ0091a,JAQ0091b,JAQ0092a,JAQ0092b,JAQ0093a,JAQ0093b,JAQ0094a,JAQ0094b,JAQ0095a,JAQ0095b,JAQ0096a,JAQ0096b,JAQ0097a,JAQ0097b,JAQ0098a,JAQ0098b,JAQ0099a,JAQ0099b,JAQ0100a,JAQ0100b,JAQ0101a,JAQ0101b,JAQ0102a,JAQ0102b,JAQ0103a,JAQ0103b,JAQ0104a,JAQ0104b,JAQ0105a,JAQ0105b,JAQ0106a,JAQ0106b,JAQ0107a,JAQ0107b,JAQ0108a,JAQ0108b,JAQ0109a,JAQ0109b,JAQ0110a,JAQ0110b,JAQ0111a,JAQ0111b,JAQ0112a,JAQ0112b,JAQ0113a,JAQ0113b,JAQ0114a,JAQ0114b,JAQ0115a,JAQ0115b,JAQ0116a,JAQ0116b,JAQ0117a,JAQ0117b,JAQ0118a,JAQ0118b,JAQ0119a,JAQ0119b,JAQ0120a,JAQ0120b,JAQ0121a,JAQ0121b,JAQ0122a,JAQ0122b,JAQ0123a,JAQ0123b,JAQ0124a,JAQ0124b,JAQ0125a,JAQ0125b,JAQ0126a,JAQ0126b,JAQ0127a,JAQ0127b,JAQ0128a,JAQ0128b,JAQ0129a,JAQ0129b,JAQ0130a,JAQ0130b,JAQ0131a,JAQ0131b,JAQ0132a,JAQ0132b,JAQ0133a,JAQ0133b,JAQ0134a,JAQ0134b,JAQ0135a,JAQ0135b";
        String[] split = topics.split(",");
@@ -1120,14 +1291,17 @@
            personPoints.put(item, "2");
        });
    }
    private void dealReprotFile(List<TExamReport> tExamReportList, List<String> fileNameResult, List<String> deleteStrList, List<String> exportFileList, String reportType) {
        for (TExamReport tExamReport : tExamReportList) {
            fileNameResult.clear();
            // 重新调用泰国团队的接口,里面会更新数据库
            TExamReport tExamReportComplete = tExamReportService.selectTExamReportById(tExamReport.getId());
            itExamPaperService.recallThaiInterface(tExamReportComplete, reportType);
            // 开始生成报告
            TExamReport tExamReportResult = tExamReportService.getReportFromTemplate(tExamReport, fileNameResult, deleteStrList);
            if (tExamReportResult == null) {
                continue;
            }
@@ -1135,31 +1309,41 @@
                String[] exportFiles = exportFile.split("/");
                exportFileList.add(exportFiles[exportFiles.length - 1]);
            }
            // 更新历史地址
            updateHisReportAddress(fileNameResult, deleteStrList, tExamReportResult);
        }
    }
    private void updateHisReportAddress(List<String> fileNameResult, List<String> deleteStrList, TExamReport tExamReportResult) {
        // 下载历史文件
        if (StringUtils.isEmpty(tExamReportResult.getReportAddress())) {
            return;
        }
        TExamReport tExamReportUpdate = new TExamReport();
        tExamReportUpdate.setId(tExamReportResult.getId());
        tExamReportUpdate.setReportAddress(JsonUtil.toJSONString(fileNameResult));
        tExamReportUpdate.setReportAddressNew(JsonUtil.toJSONString(fileNameResult));
        tExamReportService.updateTExamReport(tExamReportUpdate);
    }
    private Map<String, Map<String, String>> getDataFromExcel() {
        ExcelUtil<String> excelUtil = new ExcelUtil<>(String.class);
        return excelUtil.getMAQFromExcel();
    }
    /**
     * 新增评测报告
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }
    /**
     * 新增保存评测报告
     */
    @RequiresPermissions("exam:report:add")
    @Log(title = "评测报告", businessType = BusinessType.INSERT)
    @PostMapping("/add")
@@ -1167,14 +1351,20 @@
    public AjaxResult addSave(TExamReport tExamReport) {
        return toAjax(tExamReportService.insertTExamReport(tExamReport));
    }
    /**
     * 修改评测报告
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        TExamReport tExamReport = tExamReportService.selectTExamReportById(id);
        mmap.put("tExamReport", tExamReport);
        return prefix + "/edit";
    }
    /**
     * 修改保存评测报告
     */
    @RequiresPermissions("exam:report:edit")
    @Log(title = "评测报告", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
@@ -1182,7 +1372,10 @@
    public AjaxResult editSave(TExamReport tExamReport) {
        return toAjax(tExamReportService.updateTExamReport(tExamReport));
    }
    /**
     * 删除评测报告
     */
    @RequiresPermissions("exam:report:remove")
    @Log(title = "评测报告", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
@@ -1190,7 +1383,10 @@
    public AjaxResult remove(String ids) {
        return toAjax(tExamReportService.deleteTExamReportByIds(ids));
    }
    /**
     * 审批状态修改
     */
    @Log(title = "企业用户审批", businessType = BusinessType.UPDATE)
    @RequiresPermissions("exam:report:edit")
    @PostMapping("/changeStatus")
@@ -1198,7 +1394,10 @@
    public AjaxResult changeStatus(TExamReport tExamReport) {
        return toAjax(tExamReportService.changeStatus(tExamReport));
    }
    /**
     * 批量更新审批状态
     */
    @RequiresPermissions("exam:report:edit")
    @Log(title = "批量更新审批状态", businessType = BusinessType.DELETE)
    @PostMapping("/batchVerify")
@@ -1206,13 +1405,14 @@
    public AjaxResult batchVerify(String ids) {
        return toAjax(tExamReportService.updateTexamReportByIds(ids, "1"));
    }
    @GetMapping("/langType/{userIds}/{productId}")
    public String getLangType(@PathVariable("userIds") Long[] userIds, @PathVariable("productId") Long productId, ModelMap mmap) {
        List<DictData> dictDataList = tExamReportService.getType(userIds[0]);
        try {
            TExamPaper tExamPaper = itExamPaperService.selectTExamPaperById(productId);
            List<TReportTemplate> tReportTemplateList = itReportTemplateService.selectTReportTemplates(tExamPaper.getReportTemplateId());
            // 睿邻的只有中文
            for (TReportTemplate tReportTemplate : tReportTemplateList) {
                if ("RuiLin".equals(tReportTemplate.getReportType())) {
                    for (DictData dictData : dictDataList) {
@@ -1226,31 +1426,39 @@
                }
            }
        } catch (Exception e) {
        }
        mmap.put("dictDatas", dictDataList);
        return prefix + "/report::langTypeDiv";
    }
    @PostMapping("/testerReport/{memberId}")
    @ResponseBody
    public AjaxResult getTesterReport(@PathVariable Integer memberId) {
        TExamReport tExamReport = new TExamReport();
        tExamReport.setMemberId(memberId);
        // 附件的位置,具体邮件附件的位置
        List<String> fileNameResult = new ArrayList<>();
        // 要删除的文件
        List<String> deleteStrList = new ArrayList<>();
        WordUtil wordUtil = new WordUtil();
        TExamReport tExamReportResult = tExamReportService.getReportFromTemplate(tExamReport, fileNameResult, deleteStrList);
        if (tExamReportResult == null) {
            return AjaxResult.success("答题未完成!");
        }
        List<String> exportFileList = new ArrayList<>();
        for (String exportFile : fileNameResult) {
            String[] exportFiles = exportFile.split("/");
            exportFileList.add(exportFiles[exportFiles.length - 1]);
        }
        return wordUtil.exportBaseOrDetailReport(tExamReportResult.getMemberName(), deleteStrList, exportFileList);
    }
    @PostMapping("/exportSendedReport/{ids}")
    @ResponseBody
    public AjaxResult getTesterReport(@PathVariable String[] ids) {
@@ -1265,6 +1473,7 @@
                    fileNameList.add(addresses[addresses.length - 1]);
                }
            }
            return wordUtil.exportZipKeepFiles(MessageUtils.message("jsp.exam.report.sendedReport"), new ArrayList<>(), fileNameList);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
@@ -1273,7 +1482,10 @@
        }
        return AjaxResult.error(MessageUtils.message("jsp.exam.report.noHisReport"));
    }
    /**
     * 查询评测邀请发送任务列表
     */
    @RequiresPermissions("exam:hrEmailReport:view")
    @PostMapping("/hrSendlogList")
    @ResponseBody
@@ -1281,12 +1493,13 @@
        startPage();
        tExamReport.setFinish(1);
        tExamReport.setSendHrStatusList(Arrays.asList(1, 3));
        User sysUser = ShiroUtils.getSysUser();
        String userType = sysUser.getUserType();
        if (UserTypeEnum.ENT_USER.getUserType().equals(userType)) {
            tExamReport.setUserId(sysUser.getUserId());
        }
        //分销商可以看到分销商下的企业信息
        if (UserTypeEnum.DIS_USER.getUserType().equals(userType)) {
            SysUserExtend sysUserExtend = new SysUserExtend();
            sysUserExtend.setParentUserId(sysUser.getUserId());
@@ -1298,12 +1511,14 @@
        List<TExamReport> list = tExamReportService.selectTExamReportList(tExamReport);
        return getDataTable(list);
    }
    @RequiresPermissions("exam:hrEmailReport:view")
    @GetMapping("/hrSendlog/{testId}")
    public String hrSendlog(@PathVariable Long testId,ModelMap mmap) {
        mmap.put("testId",testId);
        return "exam/hrSendlog/hrSendlog";
    }
    @RequiresPermissions("exam:hremail:reissue")
    @GetMapping("/sendEmail/{id}")
    @ResponseBody