Commit a6791f4f by wenyang Committed by akexiu

经纪人名片4.经纪人电子名片由后端返回,支持PDF/png

parent 353d21dd
...@@ -5195,7 +5195,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -5195,7 +5195,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
//PDF模板输出结果文件 //PDF模板输出结果文件
String templateResultPDF = tmpPathPDF + practitionerId + "-businessCardE.pdf"; String templateResultPDF = tmpPathPDF + practitionerId + "-businessCardE.pdf";
//JPG模板输出结果文件 //JPG模板输出结果文件
String templateResultJPG = tmpPathPDF + practitionerId + "-businessCardE.jpg"; String templateResultPNG = tmpPathPDF + practitionerId + "-businessCardE.png";
//填充数据 //填充数据
Map<String, String> initDatas = new HashMap<>(); Map<String, String> initDatas = new HashMap<>();
Map<String, String> initImages = new HashMap<>(); Map<String, String> initImages = new HashMap<>();
...@@ -5251,6 +5251,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -5251,6 +5251,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
//按模板填充数据生成结果PDF //按模板填充数据生成结果PDF
PDFTemplate.generatePDF(templatePDF, templateResultPDF, initDatas, initImages); PDFTemplate.generatePDF(templatePDF, templateResultPDF, initDatas, initImages);
try { try {
resp.setBusinessCardPdfUrl(putContractFileToOSS("businessCardEPDF", templateResultPDF, practitionerId));
PDDocument doc = null; PDDocument doc = null;
ByteArrayOutputStream os = null; ByteArrayOutputStream os = null;
InputStream stream = null; InputStream stream = null;
...@@ -5264,29 +5265,27 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -5264,29 +5265,27 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
PDPageTree pages = doc.getPages(); PDPageTree pages = doc.getPages();
int pageCount = pages.getCount(); int pageCount = pages.getCount();
for (int i = 0; i < pageCount; i++) { for (int i = 0; i < pageCount; i++) {
BufferedImage bim = pdfRenderer.renderImageWithDPI(i, 92); BufferedImage bim = pdfRenderer.renderImageWithDPI(i, 70);
os = new ByteArrayOutputStream(); ImageIO.write(bim, "png", new File(templateResultPNG));
// os = new ByteArrayOutputStream();
Image image = bim.getScaledInstance(92,58,Image.SCALE_SMOOTH); //设置图像的缩放大小 // Image image = bim.getScaledInstance(70,45,Image.SCALE_SMOOTH); //设置图像的缩放大小
AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(1,1),null); //设置图像的缩放比例 // AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(1,1),null); //设置图像的缩放比例
image = op.filter(bim,null); // image = op.filter(bim,null);
// ImageIO.write((BufferedImage)image, "png", os);
ImageIO.write((BufferedImage)image, "jpg", os); // byte[] dataList = os.toByteArray();
byte[] dataList = os.toByteArray(); // // png文件转出路径
// jpg文件转出路径 // File file = new File(templateResultPNG);
File file = new File(templateResultJPG); // if (!file.getParentFile().exists()) {
if (!file.getParentFile().exists()) { // // 不存在则创建父目录及子文件
// 不存在则创建父目录及子文件 // file.getParentFile().mkdirs();
file.getParentFile().mkdirs(); // file.createNewFile();
file.createNewFile(); // }
} // out = new FileOutputStream(file);
out = new FileOutputStream(file); // out.write(dataList);
out.write(dataList);
if(i == 0){ if(i == 0){
resp.setBusinessCardProsUrl(putContractFileToOSS("businessCardEPros", templateResultJPG, practitionerId)); resp.setBusinessCardProsImg(putContractFileToOSS("businessCardEPros", templateResultPNG, practitionerId));
}else if(i == 1){ }else if(i == 1){
resp.setBusinessCardConsUrl(putContractFileToOSS("businessCardECons", templateResultJPG, practitionerId)); resp.setBusinessCardConsImg(putContractFileToOSS("businessCardECons", templateResultPNG, practitionerId));
} }
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -26,8 +26,9 @@ public class PractitionerBusinessCardResponseVO { ...@@ -26,8 +26,9 @@ public class PractitionerBusinessCardResponseVO {
private String mobileNo;//手机号 private String mobileNo;//手机号
private String email;//电子邮件 private String email;//电子邮件
private Integer emailIsActive;//经纪人邮箱是否开通(0=No, 1=Yes) private Integer emailIsActive;//经纪人邮箱是否开通(0=No, 1=Yes)
private String businessCardProsUrl;//电子名片正面Url private String businessCardPdfUrl;//电子名片PDF
private String businessCardConsUrl;//电子名片反面Url private String businessCardProsImg;//电子名片正面Url
private String businessCardConsImg;//电子名片反面Url
private CommonResult commonResult; private CommonResult commonResult;
} }
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