Browse Source

绩效结果考核申报生成报表

hlf 1 year ago
parent
commit
7cabfab50f

+ 5 - 0
ims-service/ims-eval/pom.xml

@@ -75,6 +75,11 @@
             <artifactId>poi-ooxml</artifactId>
             <version>3.17-beta1</version>
         </dependency>
+        <dependency>
+            <groupId>com.artofsolving</groupId>
+            <artifactId>jodconverter</artifactId>
+            <version>2.2.1</version>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

+ 42 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/controller/DeptAssessmentDeclarationController.java

@@ -1,19 +1,25 @@
 package com.ims.eval.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ims.common.utils.StringUtils;
 import com.ims.eval.config.CustomException;
 import com.ims.eval.entity.DeptAssessmentDeclaration;
 import com.ims.eval.entity.DeptAssessmentDeclarationContent;
+import com.ims.eval.entity.dto.request.EmployeeDTO;
 import com.ims.eval.entity.dto.result.R;
 import com.ims.eval.service.IDeptAssessmentDeclarationContentService;
 import com.ims.eval.service.IDeptAssessmentDeclarationService;
 import com.ims.eval.util.ExcelUtil;
+import com.ims.eval.util.ExcelUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
 import java.io.InputStream;
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -240,4 +246,40 @@ public class DeptAssessmentDeclarationController {
 			return R.customError(e.getMessage()).data("失败!");
 		}
 	}
+
+	/**
+	 * 生成报表
+	 *
+	 * @param id 主键
+	 * @param response response
+	 * @throws Exception 异常
+	 */
+	@GetMapping(value = "/generateReport/{id}")
+	public void generateReport(@PathVariable("id") String id, HttpServletResponse response) throws Exception {
+		response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+		response.setHeader("Content-disposition", "attachment; filename=".concat(URLEncoder.encode("公司本部部门及员工月度绩效考核结果申报表.xlsx", "UTF-8")));
+		response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
+		response.setHeader("Pragma", "no-cache");
+		response.setDateHeader("Expires", 0);
+		List<EmployeeDTO> employeeDTOList = new ArrayList<>();
+		// 添加员工信息
+		QueryWrapper<DeptAssessmentDeclarationContent> qw = new QueryWrapper<>();
+		if (StringUtils.isNotEmpty(id)) {
+			qw.lambda().like(DeptAssessmentDeclarationContent::getAssessmentDeclarationId, id);
+		}
+		List<DeptAssessmentDeclarationContent> deptAssessmentDeclarationContentList = deptAssessmentDeclarationContentService.list(qw);
+		for (DeptAssessmentDeclarationContent deptAssessmentDeclarationContent : deptAssessmentDeclarationContentList) {
+			EmployeeDTO employeeDTO = new EmployeeDTO();
+			employeeDTO.setName(deptAssessmentDeclarationContent.getEmployeeName());
+			employeeDTO.setCoefficient(deptAssessmentDeclarationContent.getSuggestedValue());
+			employeeDTOList.add(employeeDTO);
+		}
+		DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id);
+		String departmentName = deptAssessmentDeclaration.getDeptName();
+		String month = deptAssessmentDeclaration.getDeclarationMonth();
+		String level = deptAssessmentDeclaration.getDeclarationLevel();
+		String leader = deptAssessmentDeclaration.getDeptLeaderName();
+		String declarationReason = deptAssessmentDeclaration.getDeclarationReason();
+		ExcelUtils.createExcel(employeeDTOList, departmentName, month, level, leader, declarationReason, response.getOutputStream());
+	}
 }

+ 8 - 23
ims-service/ims-eval/src/main/java/com/ims/eval/controller/NoticeManagementController.java

@@ -10,14 +10,15 @@ import com.ims.eval.entity.custom.Path;
 import com.ims.eval.entity.dto.result.R;
 import com.ims.eval.service.IDataDictionaryService;
 import com.ims.eval.service.IEvaluationNoticeService;
+import com.ims.eval.util.FileConversionUtil;
 import com.ims.eval.util.FileUploadUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.http.HttpServletResponse;
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -248,28 +249,12 @@ public class NoticeManagementController {
 	 *
 	 * @param url 文件路径
 	 * @return 结果
-	 * @throws IOException 异常
 	 */
 	@GetMapping(value = "/filePreview")
-	public void convertToHtml(@RequestParam("url") String url, HttpServletResponse response) throws IOException {
-		String prefix = url.substring(0, url.lastIndexOf(".") - 1);
-		String suffix = ".pdf";
-		String filePath = Path.getNoticePath() + prefix + suffix;
-		boolean b = false;
-		if (b) {
-			File file = new File(filePath);
-			BufferedInputStream br = new BufferedInputStream(new FileInputStream(file));
-			byte[] buf = new byte[1024];
-			int len = 0;
-			response.reset();
-			response.setContentType("application/pdf");
-			response.setHeader("Content-Disposition", "inline; filename=" + java.net.URLEncoder.encode(file.getName(), "UTF-8"));
-			OutputStream out = response.getOutputStream();
-			while ((len = br.read(buf)) > 0) {
-				out.write(buf, 0, len);
-			}
-			br.close();
-			out.close();
-		}
+	public R convertToHtml(@RequestParam("url") String url) {
+		String fromFilePath = Path.getNoticePath() + url;
+		String saveFilePath = Path.getNoticePath() + url.substring(0, url.lastIndexOf("/")) + "/";
+		String fileName = FileConversionUtil.conversionToPdf(fromFilePath, saveFilePath);
+		return R.ok().data(fileName);
 	}
 }

+ 17 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/dto/request/EmployeeDTO.java

@@ -0,0 +1,17 @@
+package com.ims.eval.entity.dto.request;
+
+import lombok.Data;
+
+/**
+ * @author hlf
+ * @date 2023/6/2 16:59
+ * 文件说明:绩效结果考核申报生成报表员工类
+ */
+@Data
+public class EmployeeDTO {
+
+	private String name;
+
+	private String coefficient;
+
+}

+ 237 - 5
ims-service/ims-eval/src/main/java/com/ims/eval/util/ExcelUtils.java

@@ -1,16 +1,22 @@
 package com.ims.eval.util;
 
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.ims.eval.entity.dto.request.EmployeeDTO;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
+import java.io.IOException;
+import java.io.OutputStream;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -29,11 +35,12 @@ import java.util.Map;
 public class ExcelUtils {
 
 	/**
-	 *  workbook
+	 * workbook
+	 *
 	 * @param titleList
 	 * @return
 	 */
-	public static HSSFWorkbook getWorkBook(List<String> titleList){
+	public static HSSFWorkbook getWorkBook(List<String> titleList) {
 		//第一步,创建一个workbook,对应一个Excel文件
 		HSSFWorkbook wb = new HSSFWorkbook();
 		// 一个sheet
@@ -53,7 +60,7 @@ public class ExcelUtils {
 	}
 
 
-	public static <T> HSSFWorkbook getWorkBook(List<String> titleList , List<T> dataList) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+	public static <T> HSSFWorkbook getWorkBook(List<String> titleList, List<T> dataList) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
 		if (CollectionUtils.isNotEmpty(dataList)) {
 			T t1 = dataList.get(0);
 			Class<?> t1Class = t1.getClass();
@@ -63,7 +70,7 @@ public class ExcelUtils {
 			}
 			Field[] fields = t1Class.getDeclaredFields();
 			if (fields != null && fields.length > 0) {
-				Map<String , Integer> titleMap = new HashMap<>(titleList.size()); // 存放属性名称对应的下标
+				Map<String, Integer> titleMap = new HashMap<>(titleList.size()); // 存放属性名称对应的下标
 
 				int fieldExcelSize = 0; // 类中ExcelRow 注解的数量
 				for (Field field : fields) {
@@ -79,7 +86,7 @@ public class ExcelUtils {
 						int index = titleList.indexOf(name.trim());
 						if (index != -1) {
 							fieldExcelSize++;
-							titleMap.put(fieldName , index);
+							titleMap.put(fieldName, index);
 						}
 					}
 				}
@@ -126,6 +133,231 @@ public class ExcelUtils {
 		}
 		return null;
 	}
+
+	/**
+	 * 绩效结果考核申报生成报表
+	 *
+	 * @param employees         员工类
+	 * @param departmentName    部门名称
+	 * @param month             申报月份
+	 * @param level             申报等级
+	 * @param leader            部门领导签字
+	 * @param declarationReason 申报理由
+	 * @param outputStream      输出流
+	 * @throws IOException 异常
+	 */
+	public static void createExcel(List<EmployeeDTO> employees, String departmentName, String month, String level, String leader, String declarationReason, OutputStream outputStream) throws IOException {
+		Workbook workbook = new XSSFWorkbook();
+		Sheet sheet = workbook.createSheet("Sheet1");
+
+		// 设置列宽
+		sheet.setColumnWidth(0, 256 * 10);
+		sheet.setColumnWidth(1, 256 * 25);
+		sheet.setColumnWidth(2, 256 * 20);
+		sheet.setColumnWidth(3, 256 * 18);
+
+		//设置合并单元格
+		sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 3));
+		sheet.addMergedRegion(new CellRangeAddress(3, 3, 0, 3));
+		sheet.addMergedRegion(new CellRangeAddress(4, 4, 2, 3));
+
+		// 设置标题
+		Row titleRow = sheet.createRow(0);
+		titleRow.setHeightInPoints(Float.parseFloat("40"));
+		CellStyle titleStyle = createTitleStyle(workbook);
+		Cell titleCell = titleRow.createCell(0);
+		titleCell.setCellValue("公司本部部门及员工月度绩效考核结果申报表");
+		titleCell.setCellStyle(titleStyle);
+
+		// 设置部门名称和部门申报月份
+		Row departmentRow = sheet.createRow(1);
+		departmentRow.setHeightInPoints(Float.parseFloat("26"));
+		CellStyle departmentStyle = createBasicInfoStyle(workbook);
+		Cell departmentCell = departmentRow.createCell(0);
+		departmentCell.setCellValue("部门名称");
+		departmentCell.setCellStyle(departmentStyle);
+		Cell departmentValueCell = departmentRow.createCell(1);
+		departmentValueCell.setCellValue(departmentName);
+		departmentValueCell.setCellStyle(departmentStyle);
+		Cell monthCell = departmentRow.createCell(2);
+		monthCell.setCellValue("申报月份");
+		monthCell.setCellStyle(departmentStyle);
+		Cell monthValueCell = departmentRow.createCell(3);
+		monthValueCell.setCellValue(month + "月");
+		monthValueCell.setCellStyle(departmentStyle);
+
+		// 设置申报等级和部门领导签字
+		Row levelRow = sheet.createRow(2);
+		levelRow.setHeightInPoints(Float.parseFloat("26"));
+		CellStyle levelStyle = createBasicInfoStyle(workbook);
+		Cell levelCell = levelRow.createCell(0);
+		levelCell.setCellValue("申报等级");
+		levelCell.setCellStyle(levelStyle);
+		Cell levelValueCell = levelRow.createCell(1);
+		levelValueCell.setCellValue(level);
+		levelValueCell.setCellStyle(levelStyle);
+		Cell leaderCell = levelRow.createCell(2);
+		leaderCell.setCellValue("部门领导签字");
+		leaderCell.setCellStyle(levelStyle);
+		Cell leaderValueCell = levelRow.createCell(3);
+		leaderValueCell.setCellValue(leader);
+		leaderValueCell.setCellStyle(levelStyle);
+
+		// 设置申报理由
+		Row declarationReasonRow = sheet.createRow(3);
+		declarationReasonRow.setHeightInPoints(Float.parseFloat("80"));
+		CellStyle declarationReasonStyle = createDeclarationReasonStyle(workbook, sheet);
+		Cell declarationReasonCell = declarationReasonRow.createCell(0);
+		declarationReasonCell.setCellValue(declarationReason);
+		declarationReasonCell.setCellStyle(declarationReasonStyle);
+
+		// 设置表格表头
+		Row headerRow = sheet.createRow(4);
+		headerRow.setHeightInPoints(Float.parseFloat("30"));
+		CellStyle headerStyle = createHeaderStyle(workbook, sheet);
+		Cell indexHeader = headerRow.createCell(0);
+		indexHeader.setCellValue("序号");
+		indexHeader.setCellStyle(headerStyle);
+		Cell nameHeader = headerRow.createCell(1);
+		nameHeader.setCellValue("部门员工姓名");
+		nameHeader.setCellStyle(headerStyle);
+		Cell coefficientHeader = headerRow.createCell(2);
+		coefficientHeader.setCellValue("月度考核系数建议值");
+		coefficientHeader.setCellStyle(headerStyle);
+
+		// 设置表格内容数据
+		int rowIndex = 5;
+		for (int i = 0; i < employees.size(); i++) {
+			Row row = sheet.createRow(rowIndex);
+			row.setHeightInPoints(Float.parseFloat("30"));
+			CellStyle cellStyle = createContentStyle(workbook, sheet, rowIndex);
+			Cell indexCell = row.createCell(0);
+			indexCell.setCellValue(i + 1);
+			indexCell.setCellStyle(cellStyle);
+			Cell nameCell = row.createCell(1);
+			nameCell.setCellValue(employees.get(i).getName());
+			nameCell.setCellStyle(cellStyle);
+			Cell coefficientCell = row.createCell(2);
+			coefficientCell.setCellValue(employees.get(i).getCoefficient());
+			coefficientCell.setCellStyle(cellStyle);
+			rowIndex++;
+		}
+
+		workbook.write(outputStream);
+		workbook.close();
+	}
+
+	private static CellStyle createTitleStyle(Workbook workbook) {
+		CellStyle style = workbook.createCellStyle();
+		style.setAlignment(HorizontalAlignment.CENTER);
+		style.setVerticalAlignment(VerticalAlignment.CENTER);
+		Font font = workbook.createFont();
+		font.setFontHeightInPoints((short) 16);
+		font.setColor(IndexedColors.BLACK.getIndex());
+		style.setFont(font);
+		return style;
+	}
+
+	private static CellStyle createBasicInfoStyle(Workbook workbook) {
+		CellStyle style = workbook.createCellStyle();
+		style.setAlignment(HorizontalAlignment.CENTER);
+		style.setVerticalAlignment(VerticalAlignment.CENTER);
+		style.setBorderTop(BorderStyle.THIN);
+		style.setBorderBottom(BorderStyle.THIN);
+		style.setBorderLeft(BorderStyle.THIN);
+		style.setBorderRight(BorderStyle.THIN);
+		Font font = workbook.createFont();
+		font.setFontHeightInPoints((short) 12);
+		font.setColor(IndexedColors.BLACK.getIndex());
+		style.setFont(font);
+		return style;
+	}
+
+	private static CellStyle createDeclarationReasonStyle(Workbook workbook, Sheet sheet) {
+		CellStyle style = workbook.createCellStyle();
+		style.setVerticalAlignment(VerticalAlignment.TOP);
+		style.setAlignment(HorizontalAlignment.LEFT);
+		style.setWrapText(true);
+		style.setBorderTop(BorderStyle.THIN);
+		style.setBorderBottom(BorderStyle.THIN);
+		style.setBorderLeft(BorderStyle.THIN);
+		style.setBorderRight(BorderStyle.THIN);
+		Font font = workbook.createFont();
+		font.setFontHeightInPoints((short) 12);
+		font.setColor(IndexedColors.BLACK.getIndex());
+		style.setFont(font);
+		for (int i = 3; i <= 3; i++) {
+			for (int j = 0; j <= 3; j++) {
+				Row mergedRow = sheet.getRow(i);
+				if (mergedRow == null) {
+					mergedRow = sheet.createRow(i);
+				}
+				Cell mergedCell = mergedRow.getCell(j);
+				if (mergedCell == null) {
+					mergedCell = mergedRow.createCell(j);
+				}
+				mergedCell.setCellStyle(style);
+			}
+		}
+		return style;
+	}
+
+	private static CellStyle createHeaderStyle(Workbook workbook, Sheet sheet) {
+		CellStyle style = workbook.createCellStyle();
+		style.setAlignment(HorizontalAlignment.CENTER);
+		style.setVerticalAlignment(VerticalAlignment.CENTER);
+		style.setBorderTop(BorderStyle.THIN);
+		style.setBorderBottom(BorderStyle.THIN);
+		style.setBorderLeft(BorderStyle.THIN);
+		style.setBorderRight(BorderStyle.THIN);
+		Font font = workbook.createFont();
+		font.setFontHeightInPoints((short) 12);
+		font.setColor(IndexedColors.BLACK.getIndex());
+		style.setFont(font);
+		for (int i = 4; i <= 4; i++) {
+			for (int j = 2; j <= 3; j++) {
+				Row mergedRow = sheet.getRow(i);
+				if (mergedRow == null) {
+					mergedRow = sheet.createRow(i);
+				}
+				Cell mergedCell = mergedRow.getCell(j);
+				if (mergedCell == null) {
+					mergedCell = mergedRow.createCell(j);
+				}
+				mergedCell.setCellStyle(style);
+			}
+		}
+		return style;
+	}
+
+	private static CellStyle createContentStyle(Workbook workbook, Sheet sheet, int rowIndex) {
+		CellStyle style = workbook.createCellStyle();
+		style.setAlignment(HorizontalAlignment.CENTER);
+		style.setVerticalAlignment(VerticalAlignment.CENTER);
+		style.setBorderTop(BorderStyle.THIN);
+		style.setBorderBottom(BorderStyle.THIN);
+		style.setBorderLeft(BorderStyle.THIN);
+		style.setBorderRight(BorderStyle.THIN);
+		Font font = workbook.createFont();
+		font.setFontHeightInPoints((short) 12);
+		font.setColor(IndexedColors.BLACK.getIndex());
+		style.setFont(font);
+		sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 2, 3));
+		for (int i = rowIndex; i <= rowIndex; i++) {
+			for (int j = 2; j <= 3; j++) {
+				Row mergedRow = sheet.getRow(i);
+				if (mergedRow == null) {
+					mergedRow = sheet.createRow(i);
+				}
+				Cell mergedCell = mergedRow.getCell(j);
+				if (mergedCell == null) {
+					mergedCell = mergedRow.createCell(j);
+				}
+				mergedCell.setCellStyle(style);
+			}
+		}
+		return style;
+	}
 }
 
 

+ 122 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/util/FileConversionUtil.java

@@ -0,0 +1,122 @@
+package com.ims.eval.util;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.io.FileTypeUtil;
+import com.artofsolving.jodconverter.DocumentConverter;
+import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
+import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
+import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author hlf
+ * @date 2023/6/1 17:30
+ * 文件说明:
+ */
+public class FileConversionUtil {
+
+	//启动OpenOffice服务
+	static {
+		List<String> command = new ArrayList<>();
+		//OpenOffice的安装目录下的soffice路径D:\OpenOffice 4\program\soffice.exe
+		command.add("D:\\OpenOffice 4\\program\\soffice.exe");
+		command.add("-headless");
+		command.add("-accept=\"socket,host=127.0.0.1,port=8100;urp;\" -nofirststartwizard");
+		command.add("-nofirststartwizard");
+		command.forEach(v -> System.out.print(v + " "));
+		System.out.println();
+		ProcessBuilder builder = new ProcessBuilder();
+		//正常信息和错误信息合并输出
+		builder.redirectErrorStream(true);
+		builder.command(command);
+		//开始执行命令
+		try {
+			builder.start();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * office文件转换成pdf文件
+	 *
+	 * @param fromFilePath 要转换文件的文件路径
+	 * @param saveFilePath 转换完后文件的保存路径
+	 * @return 返回最后转换后的文件名
+	 */
+	public static String conversionToPdf(String fromFilePath, String saveFilePath) {
+		String timesuffix = DateUtil.format(new Date(), "yyyyMMddHHmmss");
+		String docFileName;
+		String resultFileName;
+		// 识别文件类型
+		String fileType = "";
+		try (FileInputStream fromFileInputStream = new FileInputStream(fromFilePath)) {
+			fileType = FileTypeUtil.getType(fromFileInputStream);
+		} catch (FileNotFoundException e) {
+			return "待转换的文件不存在";
+		} catch (IOException e) {
+			return "文件读取失败";
+		}
+		if ("doc".equals(fileType)) {
+			docFileName = "doc_" + timesuffix + ".doc";
+			resultFileName = "doc_" + timesuffix + ".pdf";
+		} else if ("docx".equals(fileType)) {
+			docFileName = "docx_" + timesuffix + ".docx";
+			resultFileName = "docx_" + timesuffix + ".pdf";
+		} else if ("xls".equals(fileType)) {
+			docFileName = "xls_" + timesuffix + ".xls";
+			resultFileName = "xls_" + timesuffix + ".pdf";
+		} else if ("xlsx".equals(fileType)) {
+			docFileName = "xlsx_" + timesuffix + ".xlsx";
+			resultFileName = "xlsx_" + timesuffix + ".pdf";
+		} else if ("ppt".equals(fileType)) {
+			docFileName = "ppt_" + timesuffix + ".ppt";
+			resultFileName = "ppt_" + timesuffix + ".pdf";
+		} else if ("pptx".equals(fileType)) {
+			docFileName = "pptx_" + timesuffix + ".pptx";
+			resultFileName = "pptx_" + timesuffix + ".pdf";
+		} else {
+			return "转换错误,文件后缀不是doc、docx、xls、xlsx、ppt、pptx";
+		}
+		// 将待转文件拷贝一份写入到saveFilePath下
+		File docInputFile = new File(saveFilePath + File.separatorChar + docFileName);
+		File resultOutputFile = new File(saveFilePath + File.separatorChar + resultFileName);
+		if (resultOutputFile.exists()) {
+			resultOutputFile.delete();
+		}
+		try (OutputStream os = Files.newOutputStream(docInputFile.toPath())) {
+			try (FileInputStream fromFileInputStream = new FileInputStream(fromFilePath)) {
+				int bytesRead = 0;
+				byte[] buffer = new byte[1024 * 8];
+				while ((bytesRead = fromFileInputStream.read(buffer)) != -1) {
+					os.write(buffer, 0, bytesRead);
+				}
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		// 连接OpenOffice服务。需提前开启OpenOffice服务,否则会报错
+		OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
+		try {
+			connection.connect();
+		} catch (Exception e) {
+			System.out.println("连接OpenOffice服务失败,请检查是否启动OpenOffice服务");
+		}
+		// 转化,将saveFilePath下的拷贝的原始文件转化为pdf
+		DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
+		try {
+			converter.convert(docInputFile, resultOutputFile);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		// 转换完之后删除拷贝的原始文件
+		docInputFile.delete();
+		connection.disconnect();
+		return resultFileName;
+	}
+}