Commit b5ee4d66 authored by hongguangwu's avatar hongguangwu

MVP1.7.11-是否自动生成解除劳动合同书 0否1是

parent f7080489
......@@ -74,6 +74,9 @@ public class TSocialFriendWordController {
@Autowired
private OSSUtil ossUtil;
@Autowired
private WordToImageUtil wordToImageUtil;
@Autowired
private TAttaInfoMapper attaInfoMapper;
......@@ -111,7 +114,7 @@ public class TSocialFriendWordController {
backLog.setSocialId("test");
backLog.setType(CommonConstants.EIGHT_INT);
backLog.setCreateTime(LocalDateTime.now());
String friendUrl = WordToImageUtil.replaceTextInWord(templateUrl.openStream()
String friendUrl = wordToImageUtil.replaceTextInWord(templateUrl.openStream()
, replacements, imageStream, restTemplate, socialFriendConfig, backLog);
return R.ok(friendUrl);
}
......
......@@ -84,6 +84,8 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
@Autowired
private ExcelToImage excelToImage;
@Autowired
private WordToImageUtil wordToImageUtil;
@Autowired
private OSSUtil ossUtil;
@Autowired
......@@ -352,7 +354,7 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
backLog.setSocialId(vo.getEmpIdcard());
backLog.setType(type);
backLog.setCreateTime(LocalDateTime.now());
String friendUrl = WordToImageUtil.replaceTextInWord(templateUrl.openStream()
String friendUrl = wordToImageUtil.replaceTextInWord(templateUrl.openStream()
, replacements, imageStream, restTemplate, socialFriendConfig, backLog);
// System.out.println("看看URL111:"+friendUrl)
tSocialFriendBackLogService.save(backLog);
......
......@@ -12,21 +12,14 @@ import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFriendBackLog;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
import java.util.Iterator;
/**
* @Author fxj
......
......@@ -12,6 +12,7 @@ import org.jodconverter.core.office.OfficeException;
import org.jodconverter.core.office.OfficeManager;
import org.jodconverter.local.LocalConverter;
import org.jodconverter.local.office.LocalOfficeManager;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.imageio.ImageIO;
......@@ -34,12 +35,13 @@ import java.util.Map;
* @description word工具类
* @date 2025-5-26 16:03:05
*/
@Component
public class WordToImageUtil {
private static final String PDF_TEMP ="\\test126666.docx";
private static final String IMAGE_TEMP ="\\document_with_seal.png";
private static final String TO_IMAGE_TEMP ="\\ToImgTemp.png";
public static String replaceTextInWord(InputStream templateFile, Map<String, String> replacements
public String replaceTextInWord(InputStream templateFile, Map<String, String> replacements
, InputStream imageStream, RestTemplate restTemplate, SocialFriendConfig socialFriendConfig
, TSocialFriendBackLog backLog) {
String projectRoot = System.getProperty(CommonConstants.USER_DIR);
......@@ -115,7 +117,7 @@ public class WordToImageUtil {
e.printStackTrace();
}
}
public static String convertAndAddSeal(String inputDocx, InputStream sealImagePath, String outputImagePath
public String convertAndAddSeal(String inputDocx, InputStream sealImagePath, String outputImagePath
, String projectRoot, RestTemplate restTemplate, SocialFriendConfig socialFriendConfig
, TSocialFriendBackLog backLog) throws IOException, OfficeException {
......@@ -169,7 +171,7 @@ public class WordToImageUtil {
return "---";
}
private static File compressImage(String projectRoot, File originalFile) throws IOException {
private File compressImage(String projectRoot, File originalFile) throws IOException {
BufferedImage image = ImageIO.read(originalFile);
int quality = 100; // 从100%开始
File compressedFile = new File(projectRoot, TO_IMAGE_TEMP);
......@@ -187,7 +189,7 @@ public class WordToImageUtil {
return originalFile;
}
private static BufferedImage convertPdfToImage(String pdfPath) throws IOException {
private BufferedImage convertPdfToImage(String pdfPath) throws IOException {
try (PDDocument document = PDDocument.load(new File(pdfPath))) {
PDFRenderer pdfRenderer = new PDFRenderer(document);
// 渲染第一页为图像,分辨率为 300 DPI
......@@ -195,7 +197,7 @@ public class WordToImageUtil {
}
}
private static BufferedImage addSealToImage(BufferedImage image, InputStream sealImagePath) throws IOException {
private BufferedImage addSealToImage(BufferedImage image, InputStream sealImagePath) throws IOException {
BufferedImage seal = ImageIO.read(sealImagePath);
BufferedImage combined = new BufferedImage(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment