Commit 60ceaa58 by akexiu

Revert "经纪人名片4.经纪人电子名片有后端返回"

This reverts commit 57478241.
parent b6cd133c
......@@ -3,8 +3,6 @@ package com.yd.api.practitioner.service.impl;
import static java.util.stream.Collectors.toList;
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
......@@ -15,7 +13,6 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLEncoder;
......@@ -44,9 +41,6 @@ import javax.script.ScriptException;
import org.apache.commons.beanutils.BeanPropertyValueEqualsPredicate;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPageTree;
import org.apache.pdfbox.rendering.PDFRenderer;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -5184,134 +5178,10 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
}else{
resp.setCommonResult(new CommonResult(false, "没有查到该经纪人"));
}
businessCardE(resp);
return resp;
}
/**
* 经纪人电子名片
* @param PractitionerBusinessCardResponseVO
* @return void
* @author Yan Wenyang
*/
public void businessCardE(PractitionerBusinessCardResponseVO resp){
Long practitionerId = resp.getPractitionerId();
String templatePDF = PDFConfiguration.getProperty("businessCardE.pdf.template");
//模板文件生成临时文件目录
String tmpPathPDF = PDFConfiguration.getProperty("businessCardE.pdf.temp.path");
//PDF模板输出结果文件
String templateResultPDF = tmpPathPDF + practitionerId + "-businessCardE.pdf";
//JPG模板输出结果文件
String templateResultJPG = tmpPathPDF + practitionerId + "-businessCardE.jpg";
//填充数据
Map<String, String> initDatas = new HashMap<>();
Map<String, String> initImages = new HashMap<>();
//下载图片
Map<String, Object> input = HttpUtil.getInput(resp.getWxQRImgUrl());
if ((boolean) input.get("success")) {
InputStream inputStream = (InputStream) input.get("is");
String wxQRImgUrl = this.getImgStrFilePath(tmpPathPDF, "sign.png", inputStream);
initImages.put("wxQRImgUrl", wxQRImgUrl);
}
if(resp.getCertificateList() != null && resp.getCertificateList().size() > 0){
for (int j = 0; j < resp.getCertificateList().size(); j++) {
Certificate certificate = resp.getCertificateList().get(j);
if(certificate != null){
int jj = j + 1;
initDatas.put("certName"+jj, certificate.getCertName() + " " + certificate.getCertNameEn());
}
}
}
if(!Strings.isNullOrEmpty(resp.getPractitionerName())){
initDatas.put("practitionerName", resp.getPractitionerName());
}
if(!Strings.isNullOrEmpty(resp.getPractitionerNameEn())){
initDatas.put("practitionerNameEn", resp.getPractitionerNameEn());
}
if(!Strings.isNullOrEmpty(resp.getLevelName())){
initDatas.put("levelName", resp.getLevelName());
}
if(!Strings.isNullOrEmpty(resp.getLevelNameEn())){
initDatas.put("levelNameEn", resp.getLevelNameEn());
}
if(!Strings.isNullOrEmpty(resp.getInsurerName())){
initDatas.put("insurerName", resp.getInsurerName());
}
if(!Strings.isNullOrEmpty(resp.getInsurerAbbre())){
initDatas.put("insurerAbbre", resp.getInsurerAbbre());
}
if(!Strings.isNullOrEmpty(resp.getInsurerUrl())){
initDatas.put("insurerUrl", resp.getInsurerUrl());
}
if(!Strings.isNullOrEmpty(resp.getInsurerAddress())){
initDatas.put("insurerAddress", resp.getInsurerAddress());
}
if(!Strings.isNullOrEmpty(resp.getInsurerUser())){
initDatas.put("insurerUser", resp.getInsurerUser());
}
if(!Strings.isNullOrEmpty(resp.getMobileNo())){
initDatas.put("mobileNo", "T: " + resp.getMobileNo());
}
if(!Strings.isNullOrEmpty(resp.getEmail())){
initDatas.put("email", "E: " + resp.getEmail());
}
//按模板填充数据生成结果PDF
PDFTemplate.generatePDF(templatePDF, templateResultPDF, initDatas, initImages);
try {
PDDocument doc = null;
ByteArrayOutputStream os = null;
InputStream stream = null;
OutputStream out = null;
try {
// pdf路径
stream = new FileInputStream(templateResultPDF);
// 加载解析PDF文件
doc = PDDocument.load(stream);
PDFRenderer pdfRenderer = new PDFRenderer(doc);
PDPageTree pages = doc.getPages();
int pageCount = pages.getCount();
for (int i = 0; i < pageCount; i++) {
BufferedImage bim = pdfRenderer.renderImageWithDPI(i, 92);
os = new ByteArrayOutputStream();
Image image = bim.getScaledInstance(92,58,Image.SCALE_SMOOTH); //设置图像的缩放大小
AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(1,1),null); //设置图像的缩放比例
image = op.filter(bim,null);
ImageIO.write((BufferedImage)image, "jpg", os);
byte[] dataList = os.toByteArray();
// jpg文件转出路径
File file = new File(templateResultJPG);
if (!file.getParentFile().exists()) {
// 不存在则创建父目录及子文件
file.getParentFile().mkdirs();
file.createNewFile();
}
out = new FileOutputStream(file);
out.write(dataList);
if(i == 0){
resp.setBusinessCardProsUrl(putContractFileToOSS("businessCardEPros", templateResultJPG, practitionerId));
}else if(i == 1){
resp.setBusinessCardConsUrl(putContractFileToOSS("businessCardECons", templateResultJPG, practitionerId));
}
}
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
if (doc != null) doc.close();
if (os != null) os.close();
if (stream != null) stream.close();
if (out != null) out.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 经纪人申请开通邮箱
* @param PractitionerApplyEmailRequestVO
* @return CommonResultResponseVO
......
......@@ -26,8 +26,6 @@ public class PractitionerBusinessCardResponseVO {
private String mobileNo;//手机号
private String email;//电子邮件
private Integer emailIsActive;//经纪人邮箱是否开通(0=No, 1=Yes)
private String businessCardProsUrl;//电子名片正面Url
private String businessCardConsUrl;//电子名片反面Url
private CommonResult commonResult;
}
......@@ -27,6 +27,3 @@ commitment.pdf.temp.path=/opt/tomcat8/conf/ydpdf/commitment
unionSales.pdf.template=/opt/tomcat8/conf/ydpdf/unionSales/ydLogo.jpg
unionSales.pdf.temp.path=/opt/tomcat8/conf/ydpdf/unionSales/
businessCardE.pdf.template=/opt/tomcat8/conf/ydpdf/businessCardE/templateBusinessCardE.pdf
businessCardE.pdf.temp.path=/opt/tomcat8/conf/ydpdf/businessCardE
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