JiangChongBo 2 years ago
parent
commit
5fb87ab1cc

+ 16 - 21
src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java

@@ -348,9 +348,9 @@ public class AuthProductServiceImpl implements AuthProductService {
             // 获取对应模板
             // 获取对应模板
             TemplateVo authTemplate = authMapper.getAuthTemplate(authId, null, 2);
             TemplateVo authTemplate = authMapper.getAuthTemplate(authId, null, 2);
             certificateImage = generateAuthImage(authTemplate, newDbProduct);
             certificateImage = generateAuthImage(authTemplate, newDbProduct);
-            authImageLogo=generateAuthImageLogo(authTemplate, newDbProduct);
+//            authImageLogo=generateAuthImageLogo(authTemplate, newDbProduct);
             product.setCertificateImage(certificateImage);
             product.setCertificateImage(certificateImage);
-            product.setAuthImageLogo(authImageLogo);
+//            product.setAuthImageLogo(authImageLogo);
         }
         }
         // 添加水印
         // 添加水印
         if (StringUtils.isNotEmpty(product.getCertificateImage())) {
         if (StringUtils.isNotEmpty(product.getCertificateImage())) {
@@ -359,11 +359,10 @@ public class AuthProductServiceImpl implements AuthProductService {
             authProductMapper.updateCertificateImage(product);
             authProductMapper.updateCertificateImage(product);
         }
         }
         // logo添加水印
         // logo添加水印
-        if (StringUtils.isNotEmpty(product.getAuthImageLogo())) {
-            product.setAuthImageLogo(addWaterMark(product.getAuthImageLogo(), 1));
-//            product.setAuthImageLogo(addWaterMark(product.getAuthImageLogo(), 2));
-            authProductMapper.updateAuthImageLogo(product);
-        }
+//        if (StringUtils.isNotEmpty(product.getAuthImageLogo())) {
+//            product.setAuthImageLogo(addWaterMark(product.getAuthImageLogo(), 1));
+//            authProductMapper.updateAuthImageLogo(product);
+//        }
         // 删除商品参数
         // 删除商品参数
         authProductMapper.deleteParamsByProductId(product.getProductId());
         authProductMapper.deleteParamsByProductId(product.getProductId());
         // 保存商品参数
         // 保存商品参数
@@ -472,24 +471,20 @@ public class AuthProductServiceImpl implements AuthProductService {
         if (1 == templateId) {
         if (1 == templateId) {
             map.put("templateImage", template.getTemplateImage());
             map.put("templateImage", template.getTemplateImage());
             double rate = 0.15;
             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));
-                // 获取设备名字位置
+            if (StringUtils.isNotEmpty(product.getAuthImageLogo())) {
+                // 获取授权牌logo位置
                 try {
                 try {
                     ImageIcon imageIcon = new ImageIcon(new URL(template.getTemplateImage()));
                     ImageIcon imageIcon = new ImageIcon(new URL(template.getTemplateImage()));
                     Image srcImg = imageIcon.getImage();
                     Image srcImg = imageIcon.getImage();
                     int srcWidth = srcImg.getWidth(null);
                     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);
+                    ImageIcon authImageLogo = new ImageIcon(new URL(product.getAuthImageLogo()));
+                    Image authLogo = authImageLogo.getImage();
+                    int authLogoWidth = authLogo.getWidth(null);
+                    int x = (srcWidth - (int) Math.round(238 * rate) - authLogoWidth) / 2 + (int) Math.round(238 * rate);
+                    int y = (int) Math.round(1230 * rate);
+                    map.put("addImage1_x", x);
+                    map.put("addImage1_y", y);
+                    map.put("addImage1_image", product.getAuthImageLogo());
                 } catch (Exception e) {
                 } catch (Exception e) {
                     e.printStackTrace();
                     e.printStackTrace();
                 }
                 }