[测评系统]--测评系统核心代码库
林致杰
2023-10-19 77f6cf1868777a27c033af7d6d4f2fe9d2afc30d
LAQ支持,新增python转换
6个文件已修改
57 ■■■■ 已修改文件
src/main/java/com/ots/common/utils/poi/WordUtil.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ots/framework/config/EssConfig.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ots/project/tool/PdfUtil.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ots/project/tool/report/LAQ/LAQTemplate.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ots/project/tool/report/LAQ/chart/LAQChart.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ots/project/tool/report/LAQ/condition/ScoreInterpretationBLA.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ots/common/utils/poi/WordUtil.java
@@ -24,6 +24,7 @@
import org.apache.commons.collections.map.HashedMap;
import org.apache.poi.ooxml.POIXMLDocument;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*;
import org.apache.xmlbeans.XmlCursor;
@@ -1183,6 +1184,8 @@
            if(ReportTypeEnum.PAQ.getCode().equals(reportType) || ReportTypeEnum.MAQTR.getCode().equals(reportType)
                    || ReportTypeEnum.CIAQ.getCode().equals(reportType)){
                PdfUtil.convertPDF(EssConfig.getProfile() + "/" + reportName);
            }else if(ReportTypeEnum.LAQ.getCode().equals(reportType)){
                PdfUtil.convertPythonPDF(EssConfig.getDocx2pdf(),EssConfig.getProfile() + "/" + reportName);
            }else{
                ShellTool.execLibreofficeCommand("pdf", EssConfig.getProfile() + "/" + reportName, EssConfig.getProfile() + "/");
                // ShellTool shellTool = ShellTool.builder();
@@ -1282,6 +1285,7 @@
     */
    private static void setChageWord(String fileName, OutputStream out, Map<String, Object> textMap, String reportType,String dataPath, Map<Integer, Map<Integer, List<String[]>>> autoTableMap) throws IOException, InvalidFormatException, DocumentException {
        //String filePath = getTemplateDownLoadPathByUpLoad(fileName);
        ZipSecureFile.setMinInflateRatio(0.001);
        XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage(getTemplateDownLoadPathByUpLoad(fileName)));
src/main/java/com/ots/framework/config/EssConfig.java
@@ -15,6 +15,7 @@
    private boolean demoEnabled;
    
    private static String profile;
    private static String docx2pdf;
    
    private static boolean addressEnabled;
    private static String imagePath;
@@ -91,4 +92,12 @@
    public static String getUploadImagePath() {
        return getProfile() + "/images";
    }
    public static String getDocx2pdf() {
        return docx2pdf;
    }
    public static void setDocx2pdf(String docx2pdf) {
        EssConfig.docx2pdf = docx2pdf;
    }
}
src/main/java/com/ots/project/tool/PdfUtil.java
@@ -3,9 +3,7 @@
import com.aspose.words.*;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.*;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Arrays;
@@ -49,6 +47,35 @@
    }
    /**
     * 执行python脚本 docx转pdf
     * @param filePath
     */
    public static void convertPythonPDF(String pythonScript,String filePath){
        try {
            File file = new File(filePath);
            if(!file.exists()){
                file.mkdirs();
            }
            //手动替换输出pdf名称
            String output = filePath.replaceAll(".docx", ".pdf");
            String[] args1 = new String[] { "python3", pythonScript, filePath, output };
            // 执行py文件
            Process proc = Runtime.getRuntime().exec(args1);
            BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream(), "GBK"));
            String line = null;
            log.info("python执行命令:{}", Arrays.toString(args1));
            log.info("python执行返回");
            while ((line = in.readLine()) != null) {
                log.info(line);
            }
            in.close();
            proc.waitFor();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * aspose-words:jdk17:23.4 版本
     */
    public static void registerWord() throws Exception {
src/main/java/com/ots/project/tool/report/LAQ/LAQTemplate.java
@@ -4,6 +4,7 @@
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
 * @description: LAQ导入模板
@@ -20,7 +21,9 @@
    private String email;
    @Excel(name = "Scored on")
    private String ScoredOn;
    private Date scoredOn;
    private String scoredOnStr;
    @Excel(name = "Company")
    private String company;
src/main/java/com/ots/project/tool/report/LAQ/chart/LAQChart.java
@@ -66,12 +66,12 @@
            MapDataUtil.objectToMap(laqTemplate,textMap);
            LAQReport report = new LAQReport();
            ReportResultData resultData = report.getTemplateParameters(textMap, ReportTypeEnum.LAQ, LangTypeEnum.codeOf("English"));
//            ReportResultData resultData = report.getTemplateParameters(textMap, ReportTypeEnum.LAQ, LangTypeEnum.codeOf("English"));
//            TReportTemplate template = null;
//            String zipFileName = WordUtil.makeReportFile("D:\\测评系统\\需求\\LAQ\\report\\LAQ英文报告-20230926.docx", template, textMap, new HashMap<>(), deleteStrList);
//            fileNameList.add(zipFileName);
            ZipSecureFile.setMinInflateRatio(0.001);
            try (OutputStream os = new FileOutputStream("D:\\测评系统\\需求\\2023\\5.领导潜力报告\\report\\LAQ.docx");XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage("D:\\测评系统\\需求\\2023\\5.领导潜力报告\\report\\LAQ英文报告-20230926.docx"))){
            try (OutputStream os = new FileOutputStream("D:\\测评系统\\需求\\2023\\5.领导潜力报告\\report\\LAQ编译报告英文.docx");XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage("D:\\测评系统\\需求\\2023\\5.领导潜力报告\\report\\LAQ英文版.docx"))){
                Map<Integer,List<SeriesData>> seriesDatas = initData(textMap);
                changeChart(document,seriesDatas,textMap);
                document.write(os);
src/main/java/com/ots/project/tool/report/LAQ/condition/ScoreInterpretationBLA.java
@@ -14,7 +14,7 @@
@Setter
@Slf4j
public class ScoreInterpretationBLA extends BaseCondition_V2 {
    private String name = "BehaviorCharacteristicsV1";
    private String name = "ScoreInterpretationBLA";
    private Double BLA;
    @Override