| | |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import com.ruoyi.system.service.InformationNotificationService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.openxml4j.util.ZipSecureFile; |
| | | import org.apache.poi.xwpf.usermodel.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | |
| | | @Override |
| | | public int wordInsertUrl(Map<String, Object> map, String url) { |
| | | XWPFTemplate template = XWPFTemplate.compile(url).render(map); |
| | | XWPFTemplate template; |
| | | synchronized (ZipSecureFile.class) { |
| | | double originalMinInflateRatio = ZipSecureFile.getMinInflateRatio(); |
| | | try { |
| | | // 兼容报告中压缩率较高的纯色/透明 PNG,编译后立即恢复 POI 安全阈值。 |
| | | ZipSecureFile.setMinInflateRatio(0.001D); |
| | | template = XWPFTemplate.compile(url); |
| | | } finally { |
| | | ZipSecureFile.setMinInflateRatio(originalMinInflateRatio); |
| | | } |
| | | } |
| | | template.render(map); |
| | | try { |
| | | template.writeAndClose(Files.newOutputStream(Paths.get(url))); |
| | | } catch (IOException e) { |