JiangChongBo 2 anos atrás
pai
commit
7b1e95710a

+ 2 - 0
src/main/java/com/caimei/mapper/cmMapper/AuthProductMapper.java

@@ -54,6 +54,8 @@ public interface AuthProductMapper {
     List<ProductFormVo> getAuthProductList(Integer authId);
 
     void updateCertificateImage(ProductPo product);
+    void updateAuthImageLogo(ProductPo product);
+
 
     AuthProductVo getAuthProductByProductId(Integer productId);
 

+ 2 - 2
src/main/java/com/caimei/mapper/cmMapper/FileMapper.java

@@ -81,10 +81,10 @@ public interface FileMapper {
 
     FileTreeVo findFileByArticleId(Integer id);
 
-    List<Integer> findDictionaryById(Integer fileId,@Param("fileName") String fileName,Integer authUserId);
+    List<FileTreeVo> findDictionaryById(Integer fileId,@Param("fileName") String fileName,Integer authUserId);
 
     List<Integer> getNewestInfoById();
 
-    List<Integer> findSecondDictionaryById(Integer fileId,@Param("fileName") String fileName,Integer authUserId);
+    List<FileTreeVo> findSecondDictionaryById(Integer fileId,@Param("fileName") String fileName,Integer authUserId);
 
 }

+ 14 - 0
src/main/java/com/caimei/model/dto/ProductSaveDto.java

@@ -5,6 +5,7 @@ import com.caimei.model.po.ProductParamPo;
 import lombok.Data;
 
 import javax.validation.constraints.NotNull;
+import java.util.Date;
 import java.util.List;
 
 
@@ -100,4 +101,17 @@ public class ProductSaveDto {
      * SN码集合(用于关联其他关联机构)
      */
     private List<String> SnList;
+    /**
+     * 授权牌Logo
+     */
+    private String authImageLogo;
+    /**
+     * 认证时间
+     */
+    private String authDate;
+
+    /**
+     * 认证时间
+     */
+    private Date authDates;
 }

+ 12 - 0
src/main/java/com/caimei/model/po/ProductPo.java

@@ -133,4 +133,16 @@ public class ProductPo {
      * 是否查看过:1是,0否
      */
     private Integer checkFlag;
+    /**
+     * 授权牌Logo
+     */
+    private String authImageLogo;
+    /**
+     * 认证时间
+     */
+    private String authDate;
+    /**
+     * 认证时间
+     */
+    private Date authDates;
 }

+ 12 - 0
src/main/java/com/caimei/model/vo/ProductFormVo.java

@@ -108,4 +108,16 @@ public class ProductFormVo {
      * 创建时间
      */
     private Date createTime;
+    /**
+     * 授权牌Logo
+     */
+    private String authImageLogo;
+    /**
+     * 认证时间
+     */
+    private String authDate;
+    /**
+     * 认证时间
+     */
+    private Date authDates;
 }

+ 106 - 0
src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java

@@ -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);
     }
 

+ 7 - 3
src/main/java/com/caimei/service/data/impl/DatabaseServiceImpl.java

@@ -441,14 +441,18 @@ public class DatabaseServiceImpl implements DatabaseService {
                         System.out.println("文件---------" + filePathArr[i]);
                     } else {
                         //判断是否根目录
-                        List<Integer> dictionaryById=new ArrayList<>();
+                        List<FileTreeVo> dictionaryById=new ArrayList<>();
                         if(null!=fileTreeVo.getParentId()&&0==fileTreeVo.getParentId()){
                             dictionaryById=fileMapper.findDictionaryById(null,filePathArr[i],authUserId);
+                            if(null!=dictionaryById&&dictionaryById.size()>0&&dictionaryById.get(0).getParentId()==0){
+                            }else{
+                                dictionaryById=null;
+                            }
                         }else{
                              dictionaryById = fileMapper.findDictionaryById(fileTreeVo.getParentId(),filePathArr[i],authUserId);
                              if(null==dictionaryById||dictionaryById.size()<=0){
                                  //判断次级目录是否存在
-                                 List<Integer> secondDictionaryById = fileMapper.findSecondDictionaryById(fileTreeVo.getParentId(), filePathArr[i],authUserId);
+                                 List<FileTreeVo> secondDictionaryById = fileMapper.findSecondDictionaryById(fileTreeVo.getParentId(), filePathArr[i],authUserId);
                                  if(null!=secondDictionaryById&&secondDictionaryById.size()>0){
                                      dictionaryById.add(secondDictionaryById.get(0));
                                  }
@@ -457,7 +461,7 @@ public class DatabaseServiceImpl implements DatabaseService {
                         //创建文件夹
                         //判断文件夹是否存在(不存在则新建,存在则跳过)
                         if (null != dictionaryById && dictionaryById.size() > 0) {
-                            fileTreeVo.setParentId(dictionaryById.get(0));
+                            fileTreeVo.setParentId(dictionaryById.get(0).getId());
                             continue;
                         } else {
                             //不存在创建文件夹

+ 14 - 4
src/main/resources/mapper/AuthProductMapper.xml

@@ -7,12 +7,12 @@
                                           `appletsCertificateImage`,
                                           purchaseWay, invoiceImage, `status`, auditBy, auditTime,
                                           `auditStatus`, shopAuditStatus, checkFlag, `createTime`, `createBy`,
-                                          createSource)
+                                          createSource,authImageLogo,authDates)
         values (#{infoId}, #{productTypeId}, #{snCode}, #{name}, #{image}, #{certificateImageType},
                 #{certificateImage}, #{pcCertificateImage},
                 #{appletsCertificateImage},
                 #{purchaseWay}, #{invoiceImage}, #{status}, #{auditBy}, #{auditTime},
-                #{auditStatus}, #{shopAuditStatus}, #{checkFlag}, #{createTime}, #{createBy}, #{createSource})
+                #{auditStatus}, #{shopAuditStatus}, #{checkFlag}, #{createTime}, #{createBy}, #{createSource},#{authImageLogo},#{authDate})
     </insert>
     <insert id="insertProductParam">
         insert into cm_brand_product_param (`productId`, `name`, `content`)
@@ -49,6 +49,8 @@
         `snCode`           = #{snCode},
         `certificateImageType` = #{certificateImageType},
         `certificateImage` = #{certificateImage},
+        authImageLogo=#{authImageLogo},
+        authDates=#{authDate},
         <if test="pcCertificateImage != null and pcCertificateImage != ''">
             `pcCertificateImage`      = #{pcCertificateImage},
         </if>
@@ -98,7 +100,13 @@
         update cm_brand_auth_product
         set certificateImage = #{certificateImage},
             pcCertificateImage = #{pcCertificateImage},
-            appletsCertificateImage = #{appletsCertificateImage}
+            appletsCertificateImage = #{appletsCertificateImage},
+        where id = #{productId}
+    </update>
+    <update id="updateAuthImageLogo">
+        update cm_brand_auth_product
+        set
+            authImageLogo=#{authImageLogo}
         where id = #{productId}
     </update>
     <update id="updateProductType">
@@ -244,7 +252,9 @@
                p.createTime,
                if(shopAuditStatus = 0, shopInvalidReason, p.invalidReason) as invalidReason,
                r.id                                                        as relationId,
-               r.authType
+               r.authType,
+               p.authImageLogo,
+               p.authDates
         from cm_brand_auth_product p
                  left join cm_brand_product_relation r on p.id = r.productId
                  left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0

+ 3 - 3
src/main/resources/mapper/FileMapper.xml

@@ -324,8 +324,8 @@
         from cm_tree_file
         where articleId = #{id}
     </select>
-    <select id="findDictionaryById" resultType="java.lang.Integer">
-        select id
+    <select id="findDictionaryById" resultType="com.caimei.model.vo.FileTreeVo">
+        select id,parentId
         from cm_tree_file
         where authUserId=#{authUserId}
         <if test="null != fileId">
@@ -341,7 +341,7 @@
         order by id desc
     </select>
 
-    <select id="findSecondDictionaryById" resultType="java.lang.Integer">
+    <select id="findSecondDictionaryById" resultType="com.caimei.model.vo.FileTreeVo">
         select id
         from cm_tree_file
         where authUserId=#{authUserId}