md
This commit is contained in:
parent
9e1fa7ab14
commit
888f8317dc
13
.idea/libraries/Maven__com_lowagie_itext_2_1_7.xml
Normal file
13
.idea/libraries/Maven__com_lowagie_itext_2_1_7.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: com.lowagie:itext:2.1.7">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/lowagie/itext/2.1.7/itext-2.1.7.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/lowagie/itext/2.1.7/itext-2.1.7-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/lowagie/itext/2.1.7/itext-2.1.7-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: fr.opensagres.xdocreport:fr.opensagres.poi.xwpf.converter.core:2.0.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.poi.xwpf.converter.core/2.0.2/fr.opensagres.poi.xwpf.converter.core-2.0.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.poi.xwpf.converter.core/2.0.2/fr.opensagres.poi.xwpf.converter.core-2.0.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.poi.xwpf.converter.core/2.0.2/fr.opensagres.poi.xwpf.converter.core-2.0.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: fr.opensagres.xdocreport:fr.opensagres.poi.xwpf.converter.pdf:2.0.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.poi.xwpf.converter.pdf/2.0.2/fr.opensagres.poi.xwpf.converter.pdf-2.0.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.poi.xwpf.converter.pdf/2.0.2/fr.opensagres.poi.xwpf.converter.pdf-2.0.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.poi.xwpf.converter.pdf/2.0.2/fr.opensagres.poi.xwpf.converter.pdf-2.0.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: fr.opensagres.xdocreport:fr.opensagres.poi.xwpf.converter.xhtml:2.0.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.poi.xwpf.converter.xhtml/2.0.2/fr.opensagres.poi.xwpf.converter.xhtml-2.0.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.poi.xwpf.converter.xhtml/2.0.2/fr.opensagres.poi.xwpf.converter.xhtml-2.0.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.poi.xwpf.converter.xhtml/2.0.2/fr.opensagres.poi.xwpf.converter.xhtml-2.0.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: fr.opensagres.xdocreport:fr.opensagres.xdocreport.converter:2.0.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.xdocreport.converter/2.0.2/fr.opensagres.xdocreport.converter-2.0.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.xdocreport.converter/2.0.2/fr.opensagres.xdocreport.converter-2.0.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.xdocreport.converter/2.0.2/fr.opensagres.xdocreport.converter-2.0.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: fr.opensagres.xdocreport:fr.opensagres.xdocreport.converter.docx.xwpf:2.0.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.xdocreport.converter.docx.xwpf/2.0.2/fr.opensagres.xdocreport.converter.docx.xwpf-2.0.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.xdocreport.converter.docx.xwpf/2.0.2/fr.opensagres.xdocreport.converter.docx.xwpf-2.0.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.xdocreport.converter.docx.xwpf/2.0.2/fr.opensagres.xdocreport.converter.docx.xwpf-2.0.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: fr.opensagres.xdocreport:fr.opensagres.xdocreport.core:2.0.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.xdocreport.core/2.0.2/fr.opensagres.xdocreport.core-2.0.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.xdocreport.core/2.0.2/fr.opensagres.xdocreport.core-2.0.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.xdocreport.core/2.0.2/fr.opensagres.xdocreport.core-2.0.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: fr.opensagres.xdocreport:fr.opensagres.xdocreport.itext.extension:2.0.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.xdocreport.itext.extension/2.0.2/fr.opensagres.xdocreport.itext.extension-2.0.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.xdocreport.itext.extension/2.0.2/fr.opensagres.xdocreport.itext.extension-2.0.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/fr.opensagres.xdocreport.itext.extension/2.0.2/fr.opensagres.xdocreport.itext.extension-2.0.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: fr.opensagres.xdocreport:xdocreport:2.0.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/xdocreport/2.0.2/xdocreport-2.0.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/xdocreport/2.0.2/xdocreport-2.0.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/fr/opensagres/xdocreport/xdocreport/2.0.2/xdocreport-2.0.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
13
.idea/libraries/Maven__org_apache_poi_ooxml_schemas_1_4.xml
Normal file
13
.idea/libraries/Maven__org_apache_poi_ooxml_schemas_1_4.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.apache.poi:ooxml-schemas:1.4">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/poi/ooxml-schemas/1.4/ooxml-schemas-1.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/poi/ooxml-schemas/1.4/ooxml-schemas-1.4-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/poi/ooxml-schemas/1.4/ooxml-schemas-1.4-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -296,5 +296,24 @@
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-xml:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: xml-apis:xml-apis-ext:1.3.04" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-codec:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:xdocreport:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.xdocreport.converter.docx.xwpf:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.xdocreport.converter:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.xdocreport.core:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.poi.xwpf.converter.pdf:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.poi.xwpf.converter.core:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:ooxml-schemas:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.xdocreport.itext.extension:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.lowagie:itext:2.1.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.poi.xwpf.converter.xhtml:2.0.2" level="project" />
|
||||
<orderEntry type="module-library">
|
||||
<library name="Maven: com.aspose:aspose-words:15.8.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../emis-biz/lib/aspose-words-15.8.0-jdk16.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
@ -255,5 +255,24 @@
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-xml:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: xml-apis:xml-apis-ext:1.3.04" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-codec:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:xdocreport:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.xdocreport.converter.docx.xwpf:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.xdocreport.converter:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.xdocreport.core:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.poi.xwpf.converter.pdf:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.poi.xwpf.converter.core:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:ooxml-schemas:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.xdocreport.itext.extension:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.lowagie:itext:2.1.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: fr.opensagres.xdocreport:fr.opensagres.poi.xwpf.converter.xhtml:2.0.2" level="project" />
|
||||
<orderEntry type="module-library">
|
||||
<library name="Maven: com.aspose:aspose-words:15.8.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/aspose-words-15.8.0-jdk16.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
BIN
emis-biz/lib/aspose-words-15.8.0-jdk16.jar
Normal file
BIN
emis-biz/lib/aspose-words-15.8.0-jdk16.jar
Normal file
Binary file not shown.
@ -65,6 +65,12 @@
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
<version>2.0.9</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>fontbox</artifactId>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
@ -127,7 +133,69 @@
|
||||
<version>1.10.6</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 江苏移动短信-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.poi</groupId>-->
|
||||
<!-- <artifactId>poi</artifactId>-->
|
||||
<!-- <version>4.1.2</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.poi</groupId>-->
|
||||
<!-- <artifactId>poi-scratchpad</artifactId>-->
|
||||
<!-- <version>4.1.2</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.poi</groupId>-->
|
||||
<!-- <artifactId>poi-ooxml</artifactId>-->
|
||||
<!-- <version>4.1.2</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>fr.opensagres.xdocreport</groupId>
|
||||
<artifactId>xdocreport</artifactId>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>fr.opensagres.xdocreport</groupId>
|
||||
<artifactId>fr.opensagres.xdocreport.converter.docx.xwpf</artifactId>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.poi</groupId>-->
|
||||
<!-- <artifactId>ooxml-schemas</artifactId>-->
|
||||
<!-- <version>1.4</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aspose</groupId>
|
||||
<artifactId>aspose-words</artifactId>
|
||||
<version>15.8.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/aspose-words-15.8.0-jdk16.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.aspose</groupId>-->
|
||||
<!-- <artifactId>aspose-words</artifactId>-->
|
||||
<!-- <version>21.1.0</version>-->
|
||||
<!-- <scope>system</scope>-->
|
||||
<!-- <systemPath>${project.basedir}/lib/aspose-words-21.1-jdk17.jar</systemPath>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jodconverter</groupId>-->
|
||||
<!-- <artifactId>jodconverter-local-lo</artifactId>-->
|
||||
<!-- <version>4.4.7</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
<!-- 江苏移动短信-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.mascloud</groupId>-->
|
||||
<!-- <artifactId>massdk</artifactId>-->
|
||||
|
||||
@ -11,9 +11,7 @@
|
||||
package com.xdadan.erp.emis.service.impl;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.DecimalFormat;
|
||||
@ -45,6 +43,7 @@ import com.xdadan.erp.emis.domain.vo.*;
|
||||
import com.xdadan.erp.emis.domain.vo.scan.ScanInfo;
|
||||
import com.xdadan.erp.emis.mapper.*;
|
||||
import com.xdadan.erp.emis.service.*;
|
||||
import com.xdadan.erp.emis.service.warehouse.DocUtils;
|
||||
import com.xdadan.erp.emis.utils.WaybillHelper;
|
||||
import com.xdadan.erp.emis.utils.sensitive.Convert;
|
||||
import com.xdadan.erp.system.service.ISysUserService;
|
||||
@ -2272,10 +2271,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
queryCargo.setWaybillId(emisWaybillOld.getId());
|
||||
List<EmisWaybillCargo> cargoList=emisWaybillCargoMapper.selectEmisWaybillCargoList(queryCargo);
|
||||
|
||||
|
||||
// 生成条码
|
||||
int width=400;
|
||||
int height=80;
|
||||
int height=70;
|
||||
BufferedImage barcodeImageBuffer = BarcodeUtils.getBarCodeWithWord(emisWaybillOld.getIntoWarehouseBillCode(),width,height,100);
|
||||
|
||||
// 填充模版数据
|
||||
@ -2333,9 +2331,15 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
XWPFTemplate template = XWPFTemplate.compile(fis,config).render(fillMap);
|
||||
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;fileName="+ fileName +".docx");
|
||||
response.setHeader("Content-Disposition", "attachment;fileName="+ fileName +".pdf");
|
||||
|
||||
ByteArrayOutputStream bos=new ByteArrayOutputStream();
|
||||
template.write(bos);
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
|
||||
|
||||
DocUtils.wordToPdf(bis, outputStream);
|
||||
response.flushBuffer();
|
||||
template.write(response.getOutputStream());
|
||||
|
||||
|
||||
IOUtils.closeQuietly(fis);
|
||||
IOUtils.closeQuietly(outputStream);
|
||||
|
||||
@ -0,0 +1,187 @@
|
||||
package com.xdadan.erp.emis.service.warehouse;
|
||||
|
||||
|
||||
import com.aspose.words.*;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.data.PictureType;
|
||||
import com.deepoove.poi.data.Pictures;
|
||||
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
||||
import com.xdadan.erp.common.core.pay.vitepay.sdk.Config;
|
||||
import com.xdadan.erp.common.utils.BarcodeUtils;
|
||||
import com.xdadan.erp.common.utils.StringUtils;
|
||||
import com.xdadan.erp.emis.domain.vo.Cargo;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DocUtils {
|
||||
|
||||
// 字体目录
|
||||
public static String FONT_PATH="";
|
||||
|
||||
@Value("${system.fontPath}")
|
||||
public void setFontPath(String fontPath) {
|
||||
DocUtils.FONT_PATH = fontPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充数据
|
||||
* @param input 输入word文件数据流
|
||||
* @param data 需要替换的数据映射
|
||||
* @param output 输出的word文件数据量
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void fillData(InputStream input, Map<String, Object> data, OutputStream output) throws IOException {
|
||||
//使用poi-tl.jar中的类填充数据
|
||||
try(XWPFTemplate template = XWPFTemplate.compile(input) ){
|
||||
template.render(data).writeAndClose(output);
|
||||
}catch (Exception ex){
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
// 查看缺少的字体
|
||||
private static class FontSubstitutionWarningCollector implements IWarningCallback {
|
||||
public void warning(WarningInfo info) {
|
||||
if (info.getWarningType() == WarningType.FONT_SUBSTITUTION) {
|
||||
log.error("==>font miss==>{}", info.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* word转换为pdf
|
||||
* @param wordInput word文件输入流
|
||||
* @param pdfOutput pdf文件输出流
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void wordToPdf(InputStream wordInput, OutputStream pdfOutput) throws Exception {
|
||||
getLicense();
|
||||
//通过aspose-words.jar中的类转换文件
|
||||
Document wordDoc = new Document(wordInput);
|
||||
FontSubstitutionWarningCollector callback = new FontSubstitutionWarningCollector();
|
||||
wordDoc.setWarningCallback(callback);
|
||||
if(!StringUtils.isEmpty(DocUtils.FONT_PATH)) {
|
||||
FontSettings.setFontsFolder(DocUtils.FONT_PATH, false);
|
||||
}
|
||||
PdfSaveOptions pso = new PdfSaveOptions();
|
||||
wordDoc.save(pdfOutput, pso);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private static void getLicense() {
|
||||
try (InputStream is = DocUtils.class.getClassLoader().getResourceAsStream("License.xml")) {
|
||||
License license = new License();
|
||||
license.setLicense(is);
|
||||
}
|
||||
}
|
||||
|
||||
public static void genPdfByDocxTpl(InputStream tplStream,Map fillDataMap,OutputStream os) throws Exception {
|
||||
ByteArrayOutputStream bos=new ByteArrayOutputStream();
|
||||
fillData(tplStream,fillDataMap,bos);
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
|
||||
wordToPdf(bis, os);
|
||||
}
|
||||
|
||||
public static void test() {
|
||||
|
||||
try {
|
||||
int width=400;
|
||||
int height=80;
|
||||
|
||||
BufferedImage barcodeImageBuffer = BarcodeUtils.getBarCodeWithWord("TAN-SHJD-24072701",width,height,100);
|
||||
|
||||
List<Cargo> cargoList= new ArrayList<>();
|
||||
|
||||
Cargo cargo=new Cargo();
|
||||
cargo.setGoodsName("测试");
|
||||
cargo.setCargoQty(1);
|
||||
cargo.setWeight(BigDecimal.valueOf(1.2D));
|
||||
cargo.setWeight(BigDecimal.valueOf(1.2D));
|
||||
cargo.setLength(BigDecimal.valueOf(1.2D));
|
||||
cargo.setWidth(BigDecimal.valueOf(1.2D));
|
||||
cargo.setHeight(BigDecimal.valueOf(1.2D));
|
||||
cargoList.add(cargo);
|
||||
|
||||
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
|
||||
Configure config = Configure.builder()
|
||||
.bind("cargoList", policy).build();
|
||||
|
||||
|
||||
|
||||
XWPFTemplate template = XWPFTemplate.compile("/Users/alan/Downloads/ws_ls_in_tpl.docx",config).render(
|
||||
new HashMap<String, Object>(){{
|
||||
put("wsInNo", "TAN-SHJD-24072701");
|
||||
put("country", "越南");
|
||||
put("warehouse", "柯桥");
|
||||
put("productName", "探路特快");
|
||||
put("estDate", "2024-07-22");
|
||||
put("declareType", "快递报关");
|
||||
put("eDeclareType", "快递清关");
|
||||
|
||||
put("supplier", "供应商");
|
||||
|
||||
put("sendName", "发件人");
|
||||
put("sendTel", "发件电话");
|
||||
put("sendAddress", "发件地址");
|
||||
put("sendCompany", "发件公司");
|
||||
|
||||
put("recvName", "收件人");
|
||||
put("recvTel", "收件电话");
|
||||
put("recvAddress", "收件地址");
|
||||
put("recvCompany", "收件公司");
|
||||
|
||||
put("wsContact", "易大伟");
|
||||
put("wsPhone", "123");
|
||||
put("wsAddress", "南京机场");
|
||||
put("payee", "李晓虎");
|
||||
|
||||
put("barcode", Pictures.ofBufferedImage(barcodeImageBuffer, PictureType.JPEG)
|
||||
.size(width, height).create());
|
||||
|
||||
put("cargoList", cargoList);
|
||||
}});
|
||||
|
||||
|
||||
|
||||
template.writeAndClose(new FileOutputStream("/Users/alan/Downloads/1.docx"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
FileInputStream tpl = new FileInputStream("/Users/alan/Downloads/ws_air_in_tpl.docx");
|
||||
FileOutputStream os = new FileOutputStream("/Users/alan/Downloads/x1.pdf");
|
||||
// wordToPdf(inputStream1, os);
|
||||
Map fillDataMap=new HashMap<String, Object>();
|
||||
fillDataMap.put("wsInNo", "TAN-SHJD-24072702221");
|
||||
fillDataMap.put("country", "越南");
|
||||
fillDataMap.put("warehouse", "柯桥");
|
||||
fillDataMap.put("productName", "探路特快");
|
||||
fillDataMap.put("estDate", "2024-07-22");
|
||||
fillDataMap.put("declareType", "快递报关");
|
||||
fillDataMap.put("eDeclareType", "快递清关");
|
||||
genPdfByDocxTpl(tpl,fillDataMap,os);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package com.xdadan.erp.emis.service.warehouse;
|
||||
|
||||
|
||||
import com.aspose.words.*;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.lowagie.text.Font;
|
||||
import com.lowagie.text.pdf.BaseFont;
|
||||
import fr.opensagres.poi.xwpf.converter.pdf.PdfConverter;
|
||||
import fr.opensagres.poi.xwpf.converter.pdf.PdfOptions;
|
||||
import fr.opensagres.xdocreport.itext.extension.font.IFontProvider;
|
||||
import fr.opensagres.xdocreport.itext.extension.font.ITextFontRegistry;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.util.Map;
|
||||
|
||||
public class DocXdocUtils {
|
||||
/**
|
||||
* 填充数据
|
||||
* @param input 输入word文件数据流
|
||||
* @param data 需要替换的数据映射
|
||||
* @param output 输出的word文件数据量
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void fillData(InputStream input, Map<String, Object> data, OutputStream output) throws IOException {
|
||||
//使用poi-tl.jar中的类填充数据
|
||||
try(XWPFTemplate template = XWPFTemplate.compile(input) ){
|
||||
template.render(data).writeAndClose(output);
|
||||
}catch (Exception ex){
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static PdfOptions getPdfOptions() {
|
||||
PdfOptions pdfOptions = PdfOptions.create();
|
||||
|
||||
pdfOptions.fontProvider(new IFontProvider() {
|
||||
public Font getFont(String familyName, String encoding, float size, int style, Color color) {
|
||||
try {
|
||||
|
||||
BaseFont bfSimfang = BaseFont.createFont("/font/simfang.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
|
||||
BaseFont bfSimSun = BaseFont.createFont("/font/simsun.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
|
||||
BaseFont bfSimHei = BaseFont.createFont("/font/simhei.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
|
||||
|
||||
Font fontSimfang = new Font(bfSimfang, size, style, color);
|
||||
fontSimfang.setFamily("仿宋");
|
||||
|
||||
Font fontSimSun = new Font(bfSimSun, size, style, color);
|
||||
fontSimSun.setFamily("宋体");
|
||||
|
||||
Font fontSimHei = new Font(bfSimHei, size, style, color);
|
||||
fontSimHei.setFamily("黑体");
|
||||
|
||||
System.out.println("===>familyName==>"+familyName);
|
||||
if ("仿宋".equals(familyName)) {
|
||||
return fontSimfang;
|
||||
}
|
||||
else if ("宋体".equals(familyName)) {
|
||||
return fontSimSun;
|
||||
}
|
||||
else if ("黑体".equals(familyName)) {
|
||||
return fontSimHei;
|
||||
}
|
||||
|
||||
return fontSimSun;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
// An error occurs, use the default font provider.
|
||||
return ITextFontRegistry.getRegistry().getFont(familyName, encoding, size, style, color);
|
||||
}
|
||||
}
|
||||
});
|
||||
return pdfOptions;
|
||||
}
|
||||
|
||||
public static void convertToPdf(String wordFile, String pdfFile) throws IOException {
|
||||
try (InputStream in = new FileInputStream(wordFile);
|
||||
OutputStream out = new FileOutputStream(pdfFile)) {
|
||||
PdfOptions options = getPdfOptions();
|
||||
XWPFDocument document = new XWPFDocument(in);
|
||||
PdfConverter.getInstance().convert(document, out, options);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
|
||||
String srcFile="/Users/alan/Downloads/1.docx";
|
||||
String destFile="/Users/alan/Downloads/6.pdf";
|
||||
convertToPdf(srcFile,destFile);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,175 +0,0 @@
|
||||
package com.xdadan.erp.emis.service.warehouse;
|
||||
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.data.Numberings;
|
||||
import com.deepoove.poi.data.PictureType;
|
||||
import com.deepoove.poi.data.Pictures;
|
||||
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
||||
import com.xdadan.erp.common.utils.BarcodeUtils;
|
||||
import com.xdadan.erp.emis.domain.EmisWaybill;
|
||||
import com.xdadan.erp.emis.domain.vo.Cargo;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WordTplUtils {
|
||||
|
||||
public void genWord(OutputStream out, EmisWaybill waybill) throws IOException {
|
||||
|
||||
// XWPFTemplate template = XWPFTemplate.compile(tplFile);
|
||||
// // 数据填充
|
||||
// template.render(fillMap);
|
||||
// template.write(out);
|
||||
// out.flush();
|
||||
|
||||
try {
|
||||
int width=350;
|
||||
int height=40;
|
||||
|
||||
BufferedImage barcodeImageBuffer = BarcodeUtils.getBarCodeWithWord("TAN-SHJD-24072701",width,height,70);
|
||||
|
||||
List<Cargo> cargoList= new ArrayList<>();
|
||||
|
||||
Cargo cargo=new Cargo();
|
||||
cargo.setGoodsName("测试");
|
||||
cargo.setCargoQty(1);
|
||||
cargo.setWeight(BigDecimal.valueOf(1.2D));
|
||||
cargo.setWeight(BigDecimal.valueOf(1.2D));
|
||||
cargo.setLength(BigDecimal.valueOf(1.2D));
|
||||
cargo.setWidth(BigDecimal.valueOf(1.2D));
|
||||
cargo.setHeight(BigDecimal.valueOf(1.2D));
|
||||
cargoList.add(cargo);
|
||||
|
||||
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
|
||||
Configure config = Configure.builder()
|
||||
.bind("cargoList", policy).build();
|
||||
|
||||
|
||||
InputStream fis = new ClassPathResource("tpl/ws_in_tpl.docx").getInputStream();
|
||||
XWPFTemplate template = XWPFTemplate.compile("/Users/alan/Downloads/ws_air_in_tpl.docx",config).render(
|
||||
new HashMap<String, Object>(){{
|
||||
put("wsInNo", "TAN-SHJD-24072701");
|
||||
put("country", "越南");
|
||||
put("warehouse", "柯桥");
|
||||
put("productName", "探路特快");
|
||||
put("estDate", "2024-07-22");
|
||||
put("declareType", "快递报关");
|
||||
put("eDeclareType", "快递清关");
|
||||
|
||||
put("supplier", "供应商");
|
||||
|
||||
put("sendName", "发件人");
|
||||
put("sendTel", "发件电话");
|
||||
put("sendAddress", "发件地址");
|
||||
put("sendCompany", "发件公司");
|
||||
|
||||
put("recvName", "收件人");
|
||||
put("recvTel", "收件电话");
|
||||
put("recvAddress", "收件地址");
|
||||
put("recvCompany", "收件公司");
|
||||
|
||||
put("wsContact", "易大伟");
|
||||
put("wsPhone", "123");
|
||||
put("wsAddress", "南京机场");
|
||||
put("payee", "李晓虎");
|
||||
|
||||
put("barcode", Pictures.ofBufferedImage(barcodeImageBuffer, PictureType.JPEG)
|
||||
.size(width, height).create());
|
||||
|
||||
put("cargoList", cargoList);
|
||||
}});
|
||||
|
||||
|
||||
|
||||
template.writeAndClose(new FileOutputStream("/Users/alan/Downloads/1.docx"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
int width=400;
|
||||
int height=80;
|
||||
|
||||
BufferedImage barcodeImageBuffer = BarcodeUtils.getBarCodeWithWord("TAN-SHJD-24072701",width,height,100);
|
||||
|
||||
List<Cargo> cargoList= new ArrayList<>();
|
||||
|
||||
Cargo cargo=new Cargo();
|
||||
cargo.setGoodsName("测试");
|
||||
cargo.setCargoQty(1);
|
||||
cargo.setWeight(BigDecimal.valueOf(1.2D));
|
||||
cargo.setWeight(BigDecimal.valueOf(1.2D));
|
||||
cargo.setLength(BigDecimal.valueOf(1.2D));
|
||||
cargo.setWidth(BigDecimal.valueOf(1.2D));
|
||||
cargo.setHeight(BigDecimal.valueOf(1.2D));
|
||||
cargoList.add(cargo);
|
||||
|
||||
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
|
||||
Configure config = Configure.builder()
|
||||
.bind("cargoList", policy).build();
|
||||
|
||||
|
||||
|
||||
XWPFTemplate template = XWPFTemplate.compile("/Users/alan/Downloads/ws_ls_in_tpl.docx",config).render(
|
||||
new HashMap<String, Object>(){{
|
||||
put("wsInNo", "TAN-SHJD-24072701");
|
||||
put("country", "越南");
|
||||
put("warehouse", "柯桥");
|
||||
put("productName", "探路特快");
|
||||
put("estDate", "2024-07-22");
|
||||
put("declareType", "快递报关");
|
||||
put("eDeclareType", "快递清关");
|
||||
|
||||
put("supplier", "供应商");
|
||||
|
||||
put("sendName", "发件人");
|
||||
put("sendTel", "发件电话");
|
||||
put("sendAddress", "发件地址");
|
||||
put("sendCompany", "发件公司");
|
||||
|
||||
put("recvName", "收件人");
|
||||
put("recvTel", "收件电话");
|
||||
put("recvAddress", "收件地址");
|
||||
put("recvCompany", "收件公司");
|
||||
|
||||
put("wsContact", "易大伟");
|
||||
put("wsPhone", "123");
|
||||
put("wsAddress", "南京机场");
|
||||
put("payee", "李晓虎");
|
||||
|
||||
put("barcode", Pictures.ofBufferedImage(barcodeImageBuffer, PictureType.JPEG)
|
||||
.size(width, height).create());
|
||||
|
||||
put("cargoList", cargoList);
|
||||
}});
|
||||
|
||||
|
||||
|
||||
template.writeAndClose(new FileOutputStream("/Users/alan/Downloads/1.docx"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
15
emis-biz/src/main/resources/License.xml
Normal file
15
emis-biz/src/main/resources/License.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<License>
|
||||
<Data>
|
||||
<Products>
|
||||
<Product>Aspose.Total for Java</Product>
|
||||
<Product>Aspose.Words for Java</Product>
|
||||
</Products>
|
||||
<EditionType>Enterprise</EditionType>
|
||||
<SubscriptionExpiry>20991231</SubscriptionExpiry>
|
||||
<LicenseExpiry>20991231</LicenseExpiry>
|
||||
<SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber>
|
||||
</Data>
|
||||
<Signature>
|
||||
sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=
|
||||
</Signature>
|
||||
</License>
|
||||
BIN
emis-biz/src/main/resources/font/simfang.ttf
Normal file
BIN
emis-biz/src/main/resources/font/simfang.ttf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user