|
@@ -146,6 +146,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
String productImage = productSaveDto.getProductImage();
|
|
|
String snCode = productSaveDto.getSnCode();
|
|
|
String certificateImage = productSaveDto.getCertificateImage();
|
|
|
+ String authImageLogo=productSaveDto.getAuthImageLogo();
|
|
|
Integer certificateImageType = productSaveDto.getCertificateImageType();
|
|
|
Integer createBy = productSaveDto.getCreateBy();
|
|
|
String purchaseWay = productSaveDto.getPurchaseWay();
|
|
@@ -271,6 +272,8 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
// 授权牌照
|
|
|
product.setCertificateImage(certificateImage);
|
|
|
product.setCertificateImageType(certificateImageType);
|
|
|
+ product.setAuthImageLogo(authImageLogo);
|
|
|
+ product.setAuthDate(productSaveDto.getAuthDate());
|
|
|
// 购买渠道
|
|
|
product.setPurchaseWay(purchaseWay);
|
|
|
// 发票图片
|
|
@@ -345,7 +348,9 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
// 获取对应模板
|
|
|
TemplateVo authTemplate = authMapper.getAuthTemplate(authId, null, 2);
|
|
|
certificateImage = generateAuthImage(authTemplate, newDbProduct);
|
|
|
+ authImageLogo=generateAuthImageLogo(authTemplate, newDbProduct);
|
|
|
product.setCertificateImage(certificateImage);
|
|
|
+ product.setAuthImageLogo(authImageLogo);
|
|
|
}
|
|
|
// 添加水印
|
|
|
if (StringUtils.isNotEmpty(product.getCertificateImage())) {
|
|
@@ -353,6 +358,12 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
product.setAppletsCertificateImage(addWaterMark(product.getCertificateImage(), 2));
|
|
|
authProductMapper.updateCertificateImage(product);
|
|
|
}
|
|
|
+ // logo添加水印
|
|
|
+ if (StringUtils.isNotEmpty(product.getAuthImageLogo())) {
|
|
|
+ product.setAuthImageLogo(addWaterMark(product.getAuthImageLogo(), 1));
|
|
|
+// product.setAuthImageLogo(addWaterMark(product.getAuthImageLogo(), 2));
|
|
|
+ authProductMapper.updateAuthImageLogo(product);
|
|
|
+ }
|
|
|
// 删除商品参数
|
|
|
authProductMapper.deleteParamsByProductId(product.getProductId());
|
|
|
// 保存商品参数
|
|
@@ -428,6 +439,32 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+ public String generateAuthImageLogo(TemplateVo authTemplate, ProductFormVo product) {
|
|
|
+ if (null != authTemplate) {
|
|
|
+ // 根据模板id设置相关数据
|
|
|
+ Map<String, Object> templateInfo = getTemplateInfo(authTemplate, product);
|
|
|
+ Object templateImage = templateInfo.get("templateImage");
|
|
|
+ if (null != templateImage) {
|
|
|
+ String authImage = ImageUtils.generateAuthImage(templateInfo);
|
|
|
+ log.info("【图片上传】>>>>>>>>>>>>>>>>图片临时路径:" + authImage);
|
|
|
+ // 临时图片
|
|
|
+ File tempFile = new File(authImage);
|
|
|
+ String imageUrl = null;
|
|
|
+ try {
|
|
|
+ imageUrl = imageDomain + "/" + client.uploadFile(authImage);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ // 删除临时图片
|
|
|
+ boolean delete = tempFile.delete();
|
|
|
+ log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时图片:" + delete);
|
|
|
+ return imageUrl;
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
private Map<String,Object> getTemplateInfo(TemplateVo template, ProductFormVo product) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
@@ -493,6 +530,70 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ private Map<String,Object> getTemplateLogoInfo(TemplateVo template, ProductFormVo product) {
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ Integer templateId = template.getTemplateId();
|
|
|
+ if (1 == templateId) {
|
|
|
+ map.put("templateImage", template.getTemplateImage());
|
|
|
+ double rate = 0.15;
|
|
|
+ String productName = product.getProductName();
|
|
|
+ if (StringUtils.isNotEmpty(productName)) {
|
|
|
+ map.put("addWord1_content", productName);
|
|
|
+ map.put("addWord1_color", "0,0,0");
|
|
|
+ map.put("addWord1_type", "思源宋体");
|
|
|
+ map.put("addWord1_style", Font.BOLD);
|
|
|
+ map.put("addWord1_size", (int) Math.round(233 * rate));
|
|
|
+ // 获取设备名字位置
|
|
|
+ try {
|
|
|
+ ImageIcon imageIcon = new ImageIcon(new URL(template.getTemplateImage()));
|
|
|
+ Image srcImg = imageIcon.getImage();
|
|
|
+ int srcWidth = srcImg.getWidth(null);
|
|
|
+ int wordWidth = ImageUtils.getWordWidth(new Font("思源宋体", Font.BOLD, (int) Math.round(233 * rate)), productName);
|
|
|
+ int x = (srcWidth - (int) Math.round(238 * rate) - wordWidth) / 2 + (int) Math.round(238 * rate);
|
|
|
+ int y = (int) Math.round(1630 * rate);
|
|
|
+ // 居中
|
|
|
+ map.put("addWord1_x", x);
|
|
|
+ map.put("addWord1_y", y);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 添加认证编号信息
|
|
|
+ if (StringUtils.isNotEmpty(product.getSnCode())) {
|
|
|
+ map.put("addWord2_content", product.getSnCode());
|
|
|
+ map.put("addWord2_color", "218,185,107");
|
|
|
+ map.put("addWord2_type", "思源宋体");
|
|
|
+ map.put("addWord2_style", Font.BOLD);
|
|
|
+ map.put("addWord2_size", (int) Math.round(90 * rate));
|
|
|
+ map.put("addWord2_x", (int) Math.round(2168 * rate));
|
|
|
+ map.put("addWord2_y", (int) Math.round(3160 * rate));
|
|
|
+ }
|
|
|
+ // 添加认证日期信息
|
|
|
+ if (null != product.getAuthDate()) {
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
|
|
|
+ map.put("addWord3_content", format.format(product.getAuthDate()));
|
|
|
+ map.put("addWord3_color", "218,185,107");
|
|
|
+ map.put("addWord3_type", "思源宋体");
|
|
|
+ map.put("addWord3_style", Font.PLAIN);
|
|
|
+ map.put("addWord3_size", (int) Math.round(90 * rate));
|
|
|
+ map.put("addWord3_x", (int) Math.round(2085 * rate));
|
|
|
+ map.put("addWord3_y", (int) Math.round(3292 * rate));
|
|
|
+ }
|
|
|
+ // 添加二维码信息
|
|
|
+ if (StringUtils.isNotEmpty(template.getQrPosition())) {
|
|
|
+ String qrCodeLink = wwwServer + "/product/auth/product-" + product.getProductId() + ".html";
|
|
|
+ map.put("addQr1_link", qrCodeLink);
|
|
|
+ map.put("addQr1_size", template.getQrSize());
|
|
|
+ String[] split = template.getQrPosition().split(",");
|
|
|
+ if (split.length == 2) {
|
|
|
+ map.put("addQr1_x", Integer.parseInt(split[0]));
|
|
|
+ map.put("addQr1_y", Integer.parseInt(split[1]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
private String addWaterMark(String image,Integer type) throws IOException {
|
|
|
//type:1pc,2applets
|
|
|
ClassPathResource classPathResource = new ClassPathResource("/images/newPcWaterMark.png");
|
|
@@ -542,6 +643,11 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
paramList = authProductMapper.getParamsByProductId(productForm.getProductId());
|
|
|
}
|
|
|
productForm.setParamList(paramList);
|
|
|
+ if(null!=productForm){
|
|
|
+ SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String authDate = simpleDateFormat.format(productForm.getAuthDate());
|
|
|
+ productForm.setAuthDate(authDate);
|
|
|
+ }
|
|
|
return ResponseJson.success(productForm);
|
|
|
}
|
|
|
|