[测评系统]--测评系统核心代码库
wzp
2024-09-04 df19dcb31b846d96e26ab2c161652c51a0ec7de4
src/main/java/com/ots/common/utils/poi/WordUtil.java
@@ -23,6 +23,7 @@
import com.ots.project.tool.report.CIAQ.chart.CIAQChart;
import com.ots.project.tool.report.JAQ.condition.JAQTeam;
import com.ots.project.tool.report.LAQ.chart.LAQAllChart;
import com.ots.project.tool.report.LAQ.chart.LAQAllPng;
import com.ots.project.tool.report.LAQ.chart.LAQChart;
import com.ots.project.tool.report.MAQTR.chart.MAQTRChart;
import com.ots.project.tool.report.PAQ.chart.PAQChart;
@@ -1286,7 +1287,17 @@
                // 获取开始时间
                long startTime = System.currentTimeMillis();
//                if(textMap.containsKey("allList"))
//                {
//                    PdfUtil.convertPDF(EssConfig.getProfile() + "/" + reportName);
//                }
//                else
//                {
//
//                }
                PdfUtil.dockerConvertPDF(EssConfig.getProfile(),EssConfig.getDocx2pdfPath(),reportName);
                // 获取结束时间
                long endTime = System.currentTimeMillis();
                // 计算耗时(单位:毫秒)
@@ -1326,69 +1337,69 @@
     * @return
     */
    private static List<String> reportNameList = new ArrayList<>();
    public static String makeReportFileForLAQ(String fileName, TReportTemplate tReportTemplate, Map<String, Object> textMap, Map<Integer, Map<Integer, List<String[]>>> autoTableMap, List<String> deleteFileStrList,Integer index,Integer totalNum,Boolean cleanFlag) {
        String returnMessage = "导出模板转移错误:";
        InputStream in = null;
        FileOutputStream out = null;
        String zipFilePath = "";
        String reportName = "";
        if(cleanFlag)
        {
            reportNameList = new ArrayList<>();
        }
        try {
            String reportType = tReportTemplate.getReportType();
            reportName = textMap.get("sendEmailFileName") + "_" + reportType + "_" + ReportTypeNameEnum.valueOf(tReportTemplate.getTemplateType()).getCode() + "_" + ReportTypeNameEnum.valueOf(tReportTemplate.getLangType()).getCode() + ".docx";
            reportName = reportName.replaceAll(" ", "_");
            reportNameList.add(reportName);
            //模板文件需要加锁
            out = getDownLoadFileOutputStream(reportName);
            long startTime1 = System.currentTimeMillis();
            setChageWord(fileName, out, textMap, tReportTemplate.getReportType(), tReportTemplate.getDataPath(), autoTableMap);
            // 获取结束时间
            long endTime1 = System.currentTimeMillis();
            // 计算耗时(单位:毫秒)
            long duration1 = endTime1 - startTime1;
            log.info("setChageWord 程序执行耗时:" + duration1 + " 毫秒,生成报告:"+reportName);
            out.flush();
//            if(ReportTypeEnum.LAQ.getCode().equals(reportType)){
//                // 获取开始时间
//                long startTime = System.currentTimeMillis();
//    public static String makeReportFileForLAQ(String fileName, TReportTemplate tReportTemplate, Map<String, Object> textMap, Map<Integer, Map<Integer, List<String[]>>> autoTableMap, List<String> deleteFileStrList,Integer index,Integer totalNum,Boolean cleanFlag) {
//        String returnMessage = "导出模板转移错误:";
//        InputStream in = null;
//        FileOutputStream out = null;
//        String zipFilePath = "";
//        String reportName = "";
//
//                PdfUtil.dockerConvertPDF(EssConfig.getProfile(),EssConfig.getDocx2pdfPath(),reportName);
//                // 获取结束时间
//                long endTime = System.currentTimeMillis();
//                // 计算耗时(单位:毫秒)
//                long duration = endTime - startTime;
//                log.info("dockerConvertPDF 程序执行耗时:" + duration + " 毫秒,生成报告:"+reportName);
//        if(cleanFlag)
//        {
//            reportNameList = new ArrayList<>();
//        }
//
//        try {
//
//            String reportType = tReportTemplate.getReportType();
//            reportName = textMap.get("sendEmailFileName") + "_" + reportType + "_" + ReportTypeNameEnum.valueOf(tReportTemplate.getTemplateType()).getCode() + "_" + ReportTypeNameEnum.valueOf(tReportTemplate.getLangType()).getCode() + ".docx";
//            reportName = reportName.replaceAll(" ", "_");
//
//            reportNameList.add(reportName);
//
//            //模板文件需要加锁
//            out = getDownLoadFileOutputStream(reportName);
//
//            long startTime1 = System.currentTimeMillis();
//            setChageWord(fileName, out, textMap, tReportTemplate.getReportType(), tReportTemplate.getDataPath(), autoTableMap);
//            // 获取结束时间
//            long endTime1 = System.currentTimeMillis();
//            // 计算耗时(单位:毫秒)
//            long duration1 = endTime1 - startTime1;
//            log.info("setChageWord 程序执行耗时:" + duration1 + " 毫秒,生成报告:"+reportName);
//
//            out.flush();
//
////            if(ReportTypeEnum.LAQ.getCode().equals(reportType)){
////                // 获取开始时间
////                long startTime = System.currentTimeMillis();
////
////                PdfUtil.dockerConvertPDF(EssConfig.getProfile(),EssConfig.getDocx2pdfPath(),reportName);
////                // 获取结束时间
////                long endTime = System.currentTimeMillis();
////                // 计算耗时(单位:毫秒)
////                long duration = endTime - startTime;
////                log.info("dockerConvertPDF 程序执行耗时:" + duration + " 毫秒,生成报告:"+reportName);
////            }
//            if(Objects.equals(index, totalNum))
//            {
//                //并行转换
//                execLAQ2PDF(reportNameList);
//            }
            if(Objects.equals(index, totalNum))
            {
                //并行转换
                execLAQ2PDF(reportNameList);
            }
            zipFilePath = getPdfPath(reportName);
            deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName);
        } catch (Exception ex) {
            returnMessage = returnMessage + ex.getMessage();
            deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName);
            log.error("导出模板转移错误:{}\n检查文件:" + fileName, returnMessage, ex);
        } finally {
            closeChannel(out);
            closeChannel(in);
        }
        return zipFilePath;
    }
//
//            zipFilePath = getPdfPath(reportName);
//
//            deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName);
//        } catch (Exception ex) {
//            returnMessage = returnMessage + ex.getMessage();
//            deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName);
//            log.error("导出模板转移错误:{}\n检查文件:" + fileName, returnMessage, ex);
//        } finally {
//            closeChannel(out);
//            closeChannel(in);
//        }
//        return zipFilePath;
//    }
    private static void execLAQ2PDF(List<String> reportNames)
@@ -1553,6 +1564,12 @@
        //设置图表控件
        changChart(textMap, document, reportType,dataPath);
        //如果是LAQ的全景图,设置图表
        if (StringUtils.equals(reportType, ReportTypeEnum.LAQ.getCode())&& textMap.containsKey("allList")){
            LAQAllPng.changeChart(document,textMap);
        }
        document.write(out);
    }
@@ -1709,16 +1726,16 @@
            } else if (StringUtils.equals(reportType, ReportTypeEnum.CIAQ.getCode())) {
                CIAQChart.changeChart(document, textMap);
            } else if (StringUtils.equals(reportType, ReportTypeEnum.LAQ.getCode())) {
                if(!textMap.containsKey("allList"))
                if(textMap.containsKey("allList"))
                {
                    System.out.println("个人用户报告");
                    LAQChart.changeChart(document, textMap);
                    log.info("【生成全景图报告】");
                    //如果包含allList,则渲染全景图图表
                    LAQAllChart.changeChart(document,textMap);
                }
                else
                {
                    System.out.println("全景图报告");
                    //如果包含allList,则渲染全景图图表
                    LAQAllChart.changeChart(document,textMap);
                    log.info("生成的是个人用户报告");
                    LAQChart.changeChart(document, textMap);
                }
            } else if(StringUtils.equals(reportType, ReportTypeEnum.API_Fan.getCode()))
            {