935090232@qq.com
2022-04-20 281dc31c4a4d4e2cf266dd65a470c7d29e4e7332
zq-erp/src/main/java/com/matrix/component/tools/CodeUtil.java
@@ -5,10 +5,11 @@
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.matrix.core.tools.PropertiesUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.tools.UUIDUtil;
import com.matrix.system.common.constance.AppConstance;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.imageio.ImageIO;
import java.awt.*;
@@ -20,9 +21,16 @@
import java.util.Date;
import java.util.Hashtable;
@Component
public class CodeUtil {
    @Value("${file_storage_path}")
    private String fileStoragePath;
    @Value("${static_resource_url}")
    private String staticResourceUrl;
   private static final String CHARSET = "utf-8";  
    private static final String FORMAT_NAME = "JPG";  
    // 二维码尺寸  
@@ -151,7 +159,7 @@
     *            是否压缩LOGO 
     * @throws Exception 
     */  
    public static void encode(String content, String imgPath, String destPath,
    public static void encode(String content, String imgPath, String destPath,
            boolean needCompress) throws Exception {  
        BufferedImage image = CodeUtil.createImage(content, imgPath,  
                needCompress,null);  
@@ -161,14 +169,14 @@
        ImageIO.write(image, FORMAT_NAME, new File(destPath+"/"+file));  
    }  
    
    public static String encode(String content, String imgPath, boolean needCompress,
    public  String encode(String content, String imgPath, boolean needCompress,
          String title) throws Exception {  
        BufferedImage image = CodeUtil.createImage(content, imgPath,  
                needCompress,title);  
     // 图片保存目录路径
      String savePath = PropertiesUtil.getString(AppConstance.FILES_TORAGE_PATH);
      String savePath = fileStoragePath;
      // 图片保存目录URL
      String saveUrl = PropertiesUtil.getString(AppConstance.NGINX_URL);
      String saveUrl = staticResourceUrl;
      // 以账号ID命名创建文件夹
      savePath+="qrCode" + File.separatorChar;
        saveUrl+="qrCode" +  File.separatorChar;