This commit is contained in:
linfso 2024-08-21 17:56:35 +08:00
parent 4ecb1a8456
commit 516c4a5927
10 changed files with 438 additions and 30 deletions

View File

@ -36,6 +36,7 @@ import com.xdadan.erp.emis.domain.vo.Sender;
import com.xdadan.erp.emis.domain.vo.WaybillOrder;
import com.xdadan.erp.emis.service.*;
import com.xdadan.erp.emis.service.print.IXddTplPrint;
import com.xdadan.erp.emis.service.print.tanex.TanexGMPrintTplImpl;
import com.xdadan.erp.emis.service.print.tanex.TanexSubBillPrintImpl;
import com.xdadan.erp.emis.service.print.tanex.TanexTplPrintImpl;
import com.xdadan.erp.emis.utils.WaybillHelper;
@ -421,8 +422,9 @@ public class EmisCommonController extends EmisBaseController
Map<String, Object> order = emisBaseService.getWaybillPrintOrder(billCode, "1,1",tplCode, "zh", tplCode,printManCode);
if(order!=null) {
IXddTplPrint tplPrint = new TanexSubBillPrintImpl();
tplPrint.genPNG(order, os);
IXddTplPrint tplPrint = new TanexGMPrintTplImpl();
// IXddTplPrint tplPrint = new TanexSubBillPrintImpl();
tplPrint.genPNG(order,tplCode, os);
}else{
log.debug("获取运单信息失败");

View File

@ -275,6 +275,9 @@ public class WaybillOrder implements Serializable {
/* 是否特殊报价 */
private String blSpecialQuote;
/* 是否敏感物 */
private String blSpecialGoods;
/* ext_info */
private String extInfo;
@ -537,6 +540,7 @@ public class WaybillOrder implements Serializable {
voItem.setFeeRemark(dbWaybill.getFeeRemark());
voItem.setBlSpecialQuote(dbWaybill.getBlSpecialQuote());
voItem.setBlSpecialGoods(dbWaybill.getBlSpecialGoods());
// voItem.setThirdCode(dbWaybill.getThirdCode());
@ -757,7 +761,9 @@ public class WaybillOrder implements Serializable {
// dbWaybill.setBlBill(this.getBlBill());
// dbWaybill.setBlBillText(this.getBlBillText());
dbWaybill.setBlSpecialGoods(this.getBlSpecialQuote());
dbWaybill.setBlSpecialQuote(this.getBlSpecialQuote());
dbWaybill.setBlSpecialGoods(this.getBlSpecialGoods());
dbWaybill.setBlOverWeight(this.getBlOverWeight());
dbWaybill.setOverWeightNumber(this.getOverWeightNumber());

View File

@ -7,13 +7,13 @@ import java.util.Map;
public interface IXddTplPrint {
public AjaxResult genPDF(Map<String, Object> order, OutputStream os) throws Exception;
public AjaxResult genPDF(Map<String, Object> order,String tplStrBase64, OutputStream os) throws Exception;
public AjaxResult genPNG(Map<String, Object> order, OutputStream os) throws Exception;
public AjaxResult genPNG(Map<String, Object> order,String tplStrBase64, OutputStream os) throws Exception;
public String genPNGBase64(Map<String, Object> order) throws Exception;
public String genPNGBase64(Map<String, Object> order,String tplStrBase64) throws Exception;
public String genPDFBase64(Map<String, Object> order) throws Exception;
public String genPDFBase64(Map<String, Object> order,String tplStrBase64) throws Exception;
}

View File

@ -0,0 +1,107 @@
package com.xdadan.erp.emis.service.print;
import org.apache.commons.codec.binary.Base64;
import java.io.*;
public class TestUtil {
/**
*
* @param path 文件全路径(加文件名)
* @return String
* @description 将文件转base64字符串
* @date 2019年11月24日
* @author rmk
*/
public static String fileToBase64(String path) {
String base64 = null;
InputStream in = null;
try {
File file = new File(path);
in = new FileInputStream(file);
byte[] bytes = new byte[(int) file.length()];
in.read(bytes);
base64 = new String(Base64.encodeBase64(bytes),"UTF-8");
System.out.println("将文件["+path+"]转base64字符串:"+base64);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return base64;
}
/**
* @param outFilePath 输出文件路径, base64 base64文件编码字符串, outFileName 输出文件名
* @return String
* @description BASE64解码成File文件
* @date 2019年11月24日
* @author rmk
*/
public static void base64ToFile(String outFilePath,String base64, String outFileName) {
System.out.println("BASE64:["+base64+"]解码成File文件["+outFilePath+"\\"+outFileName+"]");
File file = null;
//创建文件目录
String filePath=outFilePath;
File dir=new File(filePath);
if (!dir.exists() && !dir.isDirectory()) {
dir.mkdirs();
}
BufferedOutputStream bos = null;
java.io.FileOutputStream fos = null;
try {
byte[] bytes = Base64.decodeBase64(base64);
file=new File(filePath+"/"+outFileName);
fos = new java.io.FileOutputStream(file);
bos = new BufferedOutputStream(fos);
bos.write(bytes);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bos != null) {
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 单元测试
*/
public static void main(String[] args) {
// private static String tplName="/Users/alan/work/git/tanex56/emis-service/emis-biz/src/main/resources/tpl/tanex_zd_tpl.pdf";
//定义文件路径
String filePath = "/Users/alan/work/git/tanex56/emis-service/emis-biz/src/main/resources/tpl/tanex_zd_tpl.pdf";
//将文件转base64字符串
String base64 = fileToBase64(filePath);
System.out.println(base64);
//定义输出文件的路径outFilePath和输出文件名outoutFileName
// String outFilePath = "E:\\FileTest\\logs";
// String outFileName = "test.log";
// //将BASE64解码成File文件
// base64ToFile(outFilePath, base64, outFileName);
}
}

File diff suppressed because one or more lines are too long

View File

@ -123,7 +123,7 @@ public class TanexSubBillPrintImpl extends XddBasePrint {
* @throws Exception
*/
@Override
public AjaxResult genPDF(Map<String, Object> orderMap, OutputStream os) throws Exception {
public AjaxResult genPDF(Map<String, Object> orderMap,String tplStrBase64, OutputStream os) throws Exception {
AjaxResult ar = new AjaxResult();
ClassPathResource classPathResource = new ClassPathResource(tplName);
@ -138,11 +138,11 @@ public class TanexSubBillPrintImpl extends XddBasePrint {
@Override
public AjaxResult genPNG(Map<String, Object> order, OutputStream os) throws Exception {
public AjaxResult genPNG(Map<String, Object> order,String tplStrBase64, OutputStream os) throws Exception {
AjaxResult ar = new AjaxResult();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
genPDF(order, bos);
genPDF(order,tplStrBase64, bos);
PDDocument document = PDDocument.load(bos.toByteArray());
PDFRenderer renderer = new PDFRenderer(document);
BufferedImage bufferedImage = renderer.renderImageWithDPI(0, 200, ImageType.RGB);
@ -151,12 +151,12 @@ public class TanexSubBillPrintImpl extends XddBasePrint {
}
@Override
public String genPNGBase64(Map<String, Object> order) throws Exception {
public String genPNGBase64(Map<String, Object> order,String tplStrBase64) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
// 生成pdf
genPDF(order,bos);
genPDF(order,tplStrBase64,bos);
PDDocument document = PDDocument.load(bos.toByteArray());
// bos.close();
PDFRenderer renderer = new PDFRenderer(document);
@ -174,11 +174,11 @@ public class TanexSubBillPrintImpl extends XddBasePrint {
}
@Override
public String genPDFBase64(Map<String, Object> order) throws Exception {
public String genPDFBase64(Map<String, Object> order,String tplStrBase64) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
// 生成pdfbase64
genPDF(order,bos);
genPDF(order,tplStrBase64,bos);
byte[] pdfBytes = bos.toByteArray();
String pdfBase64Str = Base64.getEncoder().encodeToString(pdfBytes);
return pdfBase64Str;
@ -236,7 +236,8 @@ public class TanexSubBillPrintImpl extends XddBasePrint {
// 生成pdf base64
// byte[] pdfBytes = os.toByteArray();
// String pdfBase64Str = Base64.getEncoder().encodeToString(pdfBytes);
String pdfBase64Str =xtp.genPDFBase64(order);
String tplStrBase64="";
String pdfBase64Str =xtp.genPDFBase64(order,tplStrBase64);
System.out.println(pdfBase64Str);
// xtp.genPNGBase64(order);
@ -250,11 +251,10 @@ public class TanexSubBillPrintImpl extends XddBasePrint {
testPrint(i);
}
// xtp.testPdfPrint("/Users/alan/work/git/doitinfo/ai/logistic/src/main/resources/print_tpl/ynmb_blank.pdf","/Users/alan/Downloads/ynmb_blank_t21.pdf");
// testPdfPrint("/Users/alan/work/git/doitinfo/ai/logistic/src/main/resources/print_tpl/ynmb_blank.pdf","/Users/alan/Downloads/ynmb_blank_t21.pdf");
// testPdfPrint2Png("/Users/alan/work/git/doitinfo/ai/logistic/src/main/resources/print_tpl/lt_blank_bd.pdf","/Users/alan/Downloads/ynmb_blank_t10.png");
// testPdfPrint2Png("/Users/alan/Downloads/ynmb_blank_t21.pdf","/Users/alan/Downloads/ynmb_blank_x1.png");
// testPdfPrint2Png("/Users/alan/Downloads/ynmb_blank_t21.pdf","/Users/alan/Downloads/ynmb_blank_x1.png");
} catch (Exception e) {

View File

@ -28,6 +28,8 @@ public class TanexTplPrintImpl extends XddBasePrint {
* 模版文件
*/
// private static String tplName="tpl/tanex_sd_2.pdf";
private static String tplPath="/Users/alan/work/git/tanex56/emis-service/emis-biz/src/main/resources/tpl/";
private static String tplName="/Users/alan/work/git/tanex56/emis-service/emis-biz/src/main/resources/tpl/tanex_zd_tpl.pdf";
// private static String tplName="/Users/alan/work/git/doitinfo/ai/logistic/src/main/resources/print_tpl/tanex/tanex_sd_2.pdf";
@ -120,7 +122,7 @@ public class TanexTplPrintImpl extends XddBasePrint {
* @throws Exception
*/
@Override
public AjaxResult genPDF(Map<String, Object> orderMap, OutputStream os) throws Exception {
public AjaxResult genPDF(Map<String, Object> orderMap,String tplStrBase64, OutputStream os) throws Exception {
AjaxResult ar = new AjaxResult();
ClassPathResource classPathResource = new ClassPathResource(tplName);
@ -135,11 +137,11 @@ public class TanexTplPrintImpl extends XddBasePrint {
@Override
public AjaxResult genPNG(Map<String, Object> order, OutputStream os) throws Exception {
public AjaxResult genPNG(Map<String, Object> order,String tplStrBase64, OutputStream os) throws Exception {
AjaxResult ar = new AjaxResult();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
genPDF(order, bos);
genPDF(order,tplStrBase64, bos);
PDDocument document = PDDocument.load(bos.toByteArray());
PDFRenderer renderer = new PDFRenderer(document);
BufferedImage bufferedImage = renderer.renderImageWithDPI(0, 280, ImageType.RGB);
@ -148,23 +150,23 @@ public class TanexTplPrintImpl extends XddBasePrint {
}
@Override
public String genPDFBase64(Map<String, Object> order) throws Exception {
public String genPDFBase64(Map<String, Object> order,String tplStrBase64) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
// 生成pdfbase64
genPDF(order,bos);
genPDF(order,tplStrBase64,bos);
byte[] pdfBytes = bos.toByteArray();
String pdfBase64Str = Base64.getEncoder().encodeToString(pdfBytes);
return pdfBase64Str;
}
@Override
public String genPNGBase64(Map<String, Object> order) throws Exception {
public String genPNGBase64(Map<String, Object> order,String tplStrBase64) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
// 生成pdf
genPDF(order,bos);
genPDF(order,tplStrBase64,bos);
PDDocument document = PDDocument.load(bos.toByteArray());
// bos.close();
PDFRenderer renderer = new PDFRenderer(document);
@ -214,9 +216,10 @@ public class TanexTplPrintImpl extends XddBasePrint {
ByteArrayOutputStream os = new ByteArrayOutputStream();
String tplStrBase64="";
IXddTplPrint xtp = new TanexTplPrintImpl();
xtp.genPDF(order,os);
xtp.genPNG(order,out);
xtp.genPDF(order,tplStrBase64,os);
xtp.genPNG(order,tplStrBase64,out);
// 生成pdf base64
byte[] pdfBytes = os.toByteArray();
@ -230,15 +233,15 @@ public class TanexTplPrintImpl extends XddBasePrint {
public static void main(String[] args) {
try {
for(int i=0;i<1;i++){
testPrint(i);
}
// for(int i=0;i<1;i++){
// testPrint(i);
// }
// xtp.testPdfPrint("/Users/alan/work/git/doitinfo/ai/logistic/src/main/resources/print_tpl/ynmb_blank.pdf","/Users/alan/Downloads/ynmb_blank_t21.pdf");
// testPdfPrint("/Users/alan/work/git/doitinfo/ai/logistic/src/main/resources/print_tpl/ynmb_blank.pdf","/Users/alan/Downloads/ynmb_blank_t21.pdf");
// testPdfPrint2Png("/Users/alan/work/git/doitinfo/ai/logistic/src/main/resources/print_tpl/lt_blank_bd.pdf","/Users/alan/Downloads/ynmb_blank_t10.png");
// testPdfPrint2Png("/Users/alan/Downloads/ynmb_blank_t21.pdf","/Users/alan/Downloads/ynmb_blank_x1.png");
// testPdfPrint2Png("ynmb_blank_t21.pdf","/Users/alan/Downloads/ynmb_blank_x1.png");
} catch (Exception e) {

Binary file not shown.

Binary file not shown.

Binary file not shown.