Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master' into dev-1.6.0

xiewj 1 anno fa
parent
commit
1437269b06

+ 1 - 1
720yun_fd_consumer/gis_consumer/src/main/resources/application-sitAws.yml

@@ -29,7 +29,7 @@ spring:
             max-wait: 60000
             min-evictable-idle-time-millis: 30000
             min-idle: 10
-            password: 4dkk2020test%
+            password: JK20220120%JIK
             stat-view-servlet:
                 enabled: true
             test-on-borrow: false

+ 2 - 2
720yun_fd_manage/gis_application/src/main/resources/application-sitAws.yml

@@ -33,7 +33,7 @@ spring:
             max-wait: 60000
             min-evictable-idle-time-millis: 30000
             min-idle: 10
-            password: 4dkk2020test%
+            password: JK20220120%JIK
             stat-view-servlet:
                 enabled: true
             test-on-borrow: false
@@ -65,7 +65,7 @@ spring:
                 max-idle: 8
                 max-wait: -1ms
                 min-idle: 0
-        password: ''
+        password: 'redis123ROOT.'
         port: 6379
         timeout: 3000ms
     servlet:

+ 4 - 0
720yun_fd_manage/gis_common/pom.xml

@@ -168,6 +168,10 @@
             <groupId>com.dtflys.forest</groupId>
             <artifactId>forest-spring-boot-starter</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.iherus</groupId>
+            <artifactId>qrext4j</artifactId>
+        </dependency>
         <!-- redis-config 需要此包 -->
         <!--<dependency>-->
             <!--<groupId>com.fasterxml.jackson.core</groupId>-->

+ 21 - 0
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/dto/GerQrcodeDto.java

@@ -0,0 +1,21 @@
+package com.gis.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by owen on 2022/10/31 0031 18:31
+ * 四维看看后端使用
+ */
+@Data
+public class GerQrcodeDto {
+
+    @ApiModelProperty(value = "logo")
+    private String logo;
+
+    @ApiModelProperty(value = "文本内容")
+    private String text;
+
+    @ApiModelProperty(value = "图片内容")
+    private String imgData;
+}

+ 81 - 27
720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/QrCodeUtils.java

@@ -1,14 +1,31 @@
 package com.gis.oss.util;
 
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.img.ImgUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.lang.UUID;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.core.util.URLUtil;
 import cn.hutool.extra.qrcode.QrCodeUtil;
 import cn.hutool.extra.qrcode.QrConfig;
+import cn.hutool.http.HttpUtil;
+import com.amazonaws.services.dynamodbv2.xspec.S;
+import com.gis.common.constant.ConfigConstant;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
 import lombok.extern.slf4j.Slf4j;
+import org.iherus.codegen.qrcode.SimpleQrcodeGenerator;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
-
+import sun.misc.BASE64Encoder;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.Date;
 
@@ -23,11 +40,16 @@ public class QrCodeUtils {
 
     @Autowired
     FileAndOssUtil fileAndOssUtil;
-
+    @Autowired
+    ConfigConstant configConstant;
 
     @Test
     public void test(){
-        QrCodeUtil.generate("http://ossxiaoan.4dage.com/cms_zhen/image/20201218_142627638.png?123", 300,300, FileUtil.file("F:\\test\\ngin\\cms_wuhu_gov_data\\qrCode\\3.jpg"));
+        try {
+            new SimpleQrcodeGenerator().generate("http://ossxiaoan.4dage.com/cms_zhen/image/20201218_142627638.png?123").toFile("F:\\test\\ngin\\cms_wuhu_gov_data\\qrCode\\3.jpg");
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
     }
 
     /**
@@ -49,7 +71,11 @@ public class QrCodeUtils {
         savePath = savePath + time;
         log.info("savePath: {}", savePath);
         // 创建二维码tpt
-        QrCodeUtil.generate(url, 300,300, FileUtil.file(savePath));
+        try {
+            new SimpleQrcodeGenerator().generate(url).toFile(savePath);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
     }
 
 
@@ -75,8 +101,11 @@ public class QrCodeUtils {
         savePath = savePath + "/qrCode.jpg";
 //        log.info("savePath: {}", savePath);
         // 创建二维码tpt
-        QrCodeUtil.generate(url, QrConfig.create().setImg(logoPath).setWidth(300), FileUtil.file(savePath));
-
+        try {
+            new SimpleQrcodeGenerator().setLogo(logoPath).generate(url).toFile(savePath);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
         // 二维码上传oss
         String ossPath = ossBasePath + id + "/qrCode_"+lang+".jpg";
         fileAndOssUtil.upload(savePath, ossPath);
@@ -89,7 +118,6 @@ public class QrCodeUtils {
     }
 
 
-
     /**
      * 自定义logo小图标二维码
      * @param url 二维码内容url
@@ -111,8 +139,11 @@ public class QrCodeUtils {
         savePath = savePath + "/qrCode.jpg";
 //        log.info("savePath: {}", savePath);
         // 创建二维码tpt
-        QrCodeUtil.generate(url, QrConfig.create().setImg(logoPath).setWidth(300), FileUtil.file(savePath));
-
+        try {
+            new SimpleQrcodeGenerator().setLogo(logoPath).generate(url).toFile(savePath);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
         // 二维码上传oss
         String ossPath = ossBasePath + id + "/qrCode.jpg";
         fileAndOssUtil.upload(savePath, ossPath);
@@ -121,32 +152,55 @@ public class QrCodeUtils {
 
         return ossUrl;
     }
-
-
     /**
      * 附带logo小图标二维码
      */
-    @Test
-    public  void testGenerateLogoQrCode(){
-        String url = "https://www.baidu.com";
-        String savePath = "E:\\cache\\";
-        // 保存地址
-        String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS") + ".jpg";
-        String dirType = "qrCode/";
-        savePath = savePath + dirType;
-
-        String logoPath = FileUtils.getResource() + "img/kankan_icon.png";
-        log.info("logoPath: {}", logoPath);
+    public String generateLogoQrCodeBase64(String logo,String text){
+        String serverBasePath=configConstant.serverBasePath;
 
+        String savePath =  serverBasePath +File.separator+"gerQrcode"+File.separator+ IdUtil.getSnowflakeNextId()+File.separator;
         // 创建目录
         if (!FileUtil.isDirectory(savePath)) {
             FileUtil.mkdir(savePath);
         }
-        savePath = savePath + time;
-        log.info("savePath: {}", savePath);
-        // 创建二维码tpt
-        QrCodeUtil.generate(url, QrConfig.create().setImg(logoPath).setWidth(300), FileUtil.file(savePath));
+        String logoPath = serverBasePath + "img/kankan_icon.png";
+        if (StrUtil.isNotEmpty(logo)){
+            File file = HttpUtil.downloadFileFromUrl(logo, savePath);
+                 logoPath=file.getPath();
+                log.info("diy_logoPath{}",logoPath);
+
+        }else {
+             if (!FileUtil.isFile(logoPath)) {
+                InputStream resource = FileUtils.getResource("img/kankan_icon.png");
+                FileUtil.writeFromStream(resource, logoPath);
+                log.info("logo写入完成");
+            }
+        }
+        log.info("logoPath: {}", logoPath);
+        BufferedImage test = new SimpleQrcodeGenerator().setLogo(logoPath).generate(text).getImage();
+        System.out.println(test);
+        String png = ImgUtil.toBase64(test, "jpg");
+        png = "data:image/jpg;base64," + png;
+        if (StrUtil.isNotEmpty(logo)&&!logoPath.contains("kankan_icon.png")){
+            boolean del = FileUtil.del(savePath);
+            log.info("删除logo:{}",del);
+        }
+        return png;
+    }
+    /**
+     * 附带logo小图标二维码
+     */
+    public static void main(String[] args) {
+        String logoPath = "C:\\Users\\4DAGE\\Downloads\\img"+File.separator+ IdUtil.getSnowflakeNextId()+File.separator;
+        String logo="https://ossxiaoan.4dage.com/720yun_fd_manage/fd720_gxqoc32gt/vtour/panos/fd720_gxqoc32gt.tiles/thumb.jpg";
+        if (StrUtil.isNotEmpty(logo)) {
+            if (!FileUtil.isDirectory(logoPath)) {
+                FileUtil.mkdir(logoPath);
+            }
+            File file = HttpUtil.downloadFileFromUrl(logo, logoPath);
+            System.out.println(file.getPath());
+        }
     }
 
 
-}
+ }

+ 53 - 0
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/LogoController.java

@@ -0,0 +1,53 @@
+package com.gis.web.controller;
+
+import com.gis.common.util.Result;
+import com.gis.domain.dto.AgePageDto;
+import com.gis.domain.dto.GerQrcodeDto;
+import com.gis.domain.dto.ReportDto;
+import com.gis.domain.dto.UserTrentDto;
+import com.gis.domain.entity.WorkEntity;
+import com.gis.domain.po.ReportPo;
+import com.gis.oss.util.QrCodeUtils;
+import com.gis.service.ReportService;
+import com.gis.service.WorkService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.iherus.codegen.qrcode.SimpleQrcodeGenerator;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by owen on 2022/6/28 0028 16:56
+ *
+ */
+@Slf4j
+@Api(tags = "生成二维码")
+@RestController
+@RequestMapping("/manage/logo")
+public class LogoController {
+
+    @Autowired
+    QrCodeUtils qrCodeUtils;
+
+    /*
+     * 获取所有场景
+     * 使用超级管理员权限的
+     * @param param
+     * @return
+     */
+    @ApiOperation(value = "生成二维码")
+    @PostMapping("/gerQrCode")
+    public Result<WorkEntity> gerQrCode(@RequestBody GerQrcodeDto param)
+    {
+        String data = qrCodeUtils.generateLogoQrCodeBase64(param.getLogo(), param.getText());
+        Map<String,Object> res=new HashMap<>();
+        res.put("img",data);
+        return Result.success(res);
+    }
+}

+ 7 - 1
720yun_fd_manage/pom.xml

@@ -36,7 +36,7 @@
         <gis.version>1.0.0</gis.version>
         <fastjson.version>1.2.83</fastjson.version>
         <druid.version>1.1.14</druid.version>
-        <hutool.version>5.3.3</hutool.version>
+        <hutool.version>5.8.22</hutool.version>
         <lombok.version>1.18.2</lombok.version>
         <lang3.version>3.7</lang3.version>
         <mysql.version>8.0.15</mysql.version>
@@ -59,6 +59,7 @@
         <!-- 打包跳过测试用例 -->
         <skipTests>true</skipTests>
 
+        <qrext4j.version>1.3.1</qrext4j.version>
     </properties>
 
 
@@ -297,6 +298,11 @@
                 <artifactId>forest-spring-boot-starter</artifactId>
                 <version>${forest-spring-boot-starter.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.iherus</groupId>
+                <artifactId>qrext4j</artifactId>
+                <version>${qrext4j.version}</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>