浏览代码

场景中心 test

by su 3 年之前
父节点
当前提交
f4e67bbb29

+ 5 - 0
4dkankan-center-modeling/src/test/java/com/fdkankan/modeling/ModelingApplicationTests.java

@@ -10,4 +10,9 @@ class ModelingApplicationTests {
 	void contextLoads() {
 	}
 
+	@Test
+	public String test(){
+		return "1";
+	}
+
 }

+ 15 - 1
4dkankan-center-scene/src/main/java/com/fdkankan/scene/controller/TestController.java

@@ -1,11 +1,15 @@
 package com.fdkankan.scene.controller;
 
+import com.fdkankan.common.constant.ConstantFilePath;
+import com.fdkankan.common.util.MatrixToImageWriterUtil;
 import com.fdkankan.platform.api.feign.PlatformClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.io.File;
+
 @RestController
 @RequestMapping("/api/device")
 public class TestController {
@@ -14,11 +18,21 @@ public class TestController {
     PlatformClient platformClient;
 
     @GetMapping("/test")
-    public String test(){
+    public String test() throws Exception {
 
 //        platformClient.getCameraByChildName()
+        MatrixToImageWriterUtil.createQRCode("http://baidu.com" + "123123", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+"123123"+".png",
+                null);
         return null;
 
     }
 
+    public static void main(String[] args) throws Exception {
+        MatrixToImageWriterUtil.createQRCode("http://baidu.com" + "123123", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+"123123"+".png",
+                null);
+
+//        MatrixToImageWriterUtil.createQRCode("http://baidu.com" + "123123", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+"123123"+".png",
+//                ConstantFilePath.SCENE_PATH + "images/images" + "123123" + "/QRShareLogo.png");
+    }
+
 }

+ 8 - 0
4dkankan-center-scene/src/main/resources/bootstrap.yml

@@ -1,6 +1,11 @@
+server:
+  file:
+    location: /mnt/4Dkankan/
 spring:
   application:
     name: 4dkankan-center-scene
+  resources:
+    static-locations: classpath:/META-INF/resources/,classpath:/resources/, classpath:/static/, classpath:/web/, file:${server.file.location}
   cloud:
     nacos:
       config:
@@ -79,3 +84,6 @@ spring:
 #    musicType: [".mp3", ".wma", ".wav", ".mod", ".ra", ".cd", ".md", ".asf", ".aac", ".vqf", ".ape", ".mid", ".ogg",".m4a", ".vqf"]
 #    IPs: ["0:0:0:0:0:0:0:1","192.168.0.100"]
 
+
+
+

+ 6 - 4
4dkankan-center-scene/src/test/java/com/fdkankan/scene/SceneApplicationTests.java

@@ -1,6 +1,8 @@
 package com.fdkankan.scene;
 
+import com.fdkankan.common.constant.ConstantFilePath;
 import com.fdkankan.common.util.LogoConfig;
+import com.fdkankan.common.util.MatrixToImageWriterUtil;
 import com.fdkankan.scene.entity.Folder;
 import com.fdkankan.scene.service.IFolderService;
 import org.junit.jupiter.api.Test;
@@ -8,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
 import java.awt.image.BufferedImage;
+import java.io.File;
 import java.io.IOException;
 import java.util.List;
 
@@ -27,11 +30,10 @@ class ApplicationTests {
     }
 
     @Test
-    public String test2() throws IOException {
+    public String test2() throws Exception {
 
-        LogoConfig logoConfig = new LogoConfig();
-
-        logoConfig.LogoMatrix(new BufferedImage(1,1,1), null);
+        MatrixToImageWriterUtil.createQRCode("http://baidu.com" + "123123", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+"123123"+".png",
+                null);
 
         return "123";
 

+ 5 - 1
4dkankan-common/src/main/java/com/fdkankan/common/util/LogoConfig.java

@@ -1,5 +1,7 @@
 package com.fdkankan.common.util;
 
+import org.springframework.core.io.ClassPathResource;
+
 import javax.imageio.ImageIO;
 import java.awt.*;
 import java.awt.geom.RoundRectangle2D;
@@ -27,7 +29,9 @@ public class LogoConfig {
           * 读取Logo图片
           */
          if(logoPath == null){
-             logoPath = this.getClass().getResource("classpath:static/img/logo.png").getPath();
+//             logoPath = this.getClass().getResource("/static/img/logo.png").getPath();
+             ClassPathResource classPathResource = new ClassPathResource("static/img/logo.jpg");
+             logoPath  =classPathResource.getURL().getPath();
          }
          BufferedImage logo = ImageIO.read(new File(logoPath));