zhuoning hace 4 años
padre
commit
f9a1b17987
Se han modificado 23 ficheros con 1147 adiciones y 0 borrados
  1. 39 0
      huimv-video/.gitignore
  2. 15 0
      huimv-video/huimv-video-analyse/pom.xml
  3. 13 0
      huimv-video/huimv-video-analyse/src/main/java/com/huimv/analyse/HuimvVideoAnalyseApplication.java
  4. 15 0
      huimv-video/huimv-video-manager/pom.xml
  5. 135 0
      huimv-video/huimv-video-process/pom.xml
  6. 13 0
      huimv-video/huimv-video-process/src/main/java/com/huimv/process/HuimvVideoProcessApplication.java
  7. 39 0
      huimv-video/huimv-video-process/src/main/java/com/huimv/process/controller/ImageController.java
  8. 36 0
      huimv-video/huimv-video-process/src/main/java/com/huimv/process/controller/PictureController.java
  9. 16 0
      huimv-video/huimv-video-process/src/main/java/com/huimv/process/service/IImageService.java
  10. 52 0
      huimv-video/huimv-video-process/src/main/java/com/huimv/process/service/impl/ImageServiceImpl.java
  11. 99 0
      huimv-video/huimv-video-process/src/main/java/com/huimv/process/utils/ImageBase64Converter.java
  12. 379 0
      huimv-video/huimv-video-process/src/main/java/com/huimv/process/utils/PictureUtil.java
  13. 35 0
      huimv-video/huimv-video-process/src/main/resources/application-dev.yml
  14. 4 0
      huimv-video/huimv-video-process/src/main/resources/application.properties
  15. 5 0
      huimv-video/huimv-video-process/src/main/resources/generator/config.properties
  16. 5 0
      huimv-video/huimv-video-process/src/main/resources/generator/db.properties
  17. 39 0
      huimv-video/huimv-video-process/src/main/resources/generator/generator-config.xml
  18. 38 0
      huimv-video/huimv-video-process/src/main/resources/generator/generatorConfig.xml
  19. 79 0
      huimv-video/huimv-video-process/src/test/java/com/huimv/process/service/PicUtil.java
  20. 64 0
      huimv-video/pom.xml
  21. 13 0
      huimv-video/src/main/java/com/huimv/huimvvideo/HuimvVideoApplication.java
  22. 1 0
      huimv-video/src/main/resources/application.properties
  23. 13 0
      huimv-video/src/test/java/com/huimv/huimvvideo/HuimvVideoApplicationTests.java

+ 39 - 0
huimv-video/.gitignore

@@ -0,0 +1,39 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+.mvn
+uploadImages
+huimv-video.iml
+mvnw
+mvnw.cmd

+ 15 - 0
huimv-video/huimv-video-analyse/pom.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>huimv-video</artifactId>
+        <groupId>com.huimv</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>huimv-video-analyse</artifactId>
+
+
+</project>

+ 13 - 0
huimv-video/huimv-video-analyse/src/main/java/com/huimv/analyse/HuimvVideoAnalyseApplication.java

@@ -0,0 +1,13 @@
+package com.huimv.analyse;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class HuimvVideoAnalyseApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(HuimvVideoAnalyseApplication.class, args);
+    }
+
+}

+ 15 - 0
huimv-video/huimv-video-manager/pom.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>huimv-video</artifactId>
+        <groupId>com.huimv</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>huimv-video-manager</artifactId>
+
+
+</project>

+ 135 - 0
huimv-video/huimv-video-process/pom.xml

@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>huimv-video</artifactId>
+        <groupId>com.huimv</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>huimv-video-process</artifactId>
+
+<!--    <properties>-->
+<!--        <targetJavaProject>${basedir}/src/main/java</targetJavaProject>-->
+<!--        <targetResourcesProject>${basedir}/src/main/resources</targetResourcesProject>-->
+<!--        &lt;!&ndash; MyBatis Generator mapper接口的生成位置 &ndash;&gt;-->
+<!--        <targetMapperPackage>com.huimv.process.dao</targetMapperPackage>-->
+<!--        &lt;!&ndash; MyBatis Generator model类的生成位置 &ndash;&gt;-->
+<!--        <targetModelPackage>com.huimv.process.entity</targetModelPackage>-->
+<!--        &lt;!&ndash; MyBatis Generator mapper.xml生成位置 &ndash;&gt;-->
+<!--        <targetXMLPackage>com.huimv.process.mapper</targetXMLPackage>-->
+<!--        <jdk.version>1.8</jdk.version>-->
+<!--    </properties>-->
+
+    <dependencies>
+<!--        &lt;!&ndash; https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core &ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>org.mybatis.generator</groupId>-->
+<!--            <artifactId>mybatis-generator-core</artifactId>-->
+<!--            <version>1.3.6</version>-->
+<!--        </dependency>-->
+<!--        &lt;!&ndash; 通用 Mapper &ndash;&gt;-->
+<!--        &lt;!&ndash; https://mvnrepository.com/artifact/tk.mybatis/mapper &ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>tk.mybatis</groupId>-->
+<!--            <artifactId>mapper</artifactId>-->
+<!--            <version>4.0.0</version>-->
+<!--        </dependency>-->
+<!--        &lt;!&ndash; 如果你只需要用到通用 Mapper 中的插件,可以只引入 mapper-generator &ndash;&gt;-->
+<!--        &lt;!&ndash; 注意,这个包不需要和上面的 mapper 同时引入,mapper 中包含 generator &ndash;&gt;-->
+<!--        &lt;!&ndash; https://mvnrepository.com/artifact/tk.mybatis/mapper-generator &ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>tk.mybatis</groupId>-->
+<!--            <artifactId>mapper-generator</artifactId>-->
+<!--            <version>1.0.0</version>-->
+<!--        </dependency>-->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+            <version>5.1.46</version>
+        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>mysql</groupId>-->
+<!--            <artifactId>mysql-connector-java</artifactId>-->
+<!--            <version>5.1.29</version>-->
+<!--        </dependency>-->
+    </dependencies>
+
+<!--    <build>-->
+<!--        <plugins>-->
+<!--            &lt;!&ndash;Mybatis Generator&ndash;&gt;-->
+<!--            <plugin>-->
+<!--                <groupId>org.mybatis.generator</groupId>-->
+<!--                <artifactId>mybatis-generator-maven-plugin</artifactId>-->
+<!--                <version>1.3.6</version>-->
+<!--                <configuration>-->
+<!--                    <configurationFile>-->
+<!--&lt;!&ndash;                        ${basedir}/src/main/resources/generator/generator-config.xml&ndash;&gt;-->
+<!--                        src/main/resources/generator/generator-config.xml-->
+<!--                    </configurationFile>-->
+<!--                    <overwrite>false</overwrite>-->
+<!--                    <verbose>true</verbose>-->
+<!--                </configuration>-->
+<!--                <dependencies>-->
+<!--                    <dependency>-->
+<!--                        <groupId>mysql</groupId>-->
+<!--                        <artifactId>mysql-connector-java</artifactId>-->
+<!--                        <version>5.1.46</version>-->
+<!--                    </dependency>-->
+<!--                    <dependency>-->
+<!--                        <groupId>tk.mybatis</groupId>-->
+<!--                        <artifactId>mapper</artifactId>-->
+<!--                        <version>3.4.6</version>-->
+<!--                    </dependency>-->
+<!--                </dependencies>-->
+<!--            </plugin>-->
+<!--        </plugins>-->
+
+<!--        <plugins>-->
+<!--            <plugin>-->
+<!--                <artifactId>maven-compiler-plugin</artifactId>-->
+<!--                <configuration>-->
+<!--                    <source>${jdk.version}</source>-->
+<!--                    <target>${jdk.version}</target>-->
+<!--                </configuration>-->
+<!--            </plugin>-->
+<!--            <plugin>-->
+<!--                <groupId>org.mybatis.generator</groupId>-->
+<!--                <artifactId>mybatis-generator-maven-plugin</artifactId>-->
+<!--                <version>1.3.6</version>-->
+<!--                <configuration>-->
+<!--                    <configurationFile>-->
+<!--                        ${basedir}/src/main/resources/generator/generatorConfig.xml-->
+<!--                    </configurationFile>-->
+<!--                    <overwrite>true</overwrite>-->
+<!--                    <verbose>true</verbose>-->
+<!--                </configuration>-->
+<!--                <dependencies>-->
+<!--                    <dependency>-->
+<!--                        <groupId>mysql</groupId>-->
+<!--                        <artifactId>mysql-connector-java</artifactId>-->
+<!--                        <version>5.1.29</version>-->
+<!--                    </dependency>-->
+<!--                    <dependency>-->
+<!--                        <groupId>tk.mybatis</groupId>-->
+<!--                        <artifactId>mapper</artifactId>-->
+<!--                        <version>4.0.0</version>-->
+<!--                    </dependency>-->
+<!--                </dependencies>-->
+<!--            </plugin>-->
+<!--        </plugins>-->
+<!--    </build>-->
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 13 - 0
huimv-video/huimv-video-process/src/main/java/com/huimv/process/HuimvVideoProcessApplication.java

@@ -0,0 +1,13 @@
+package com.huimv.process;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class HuimvVideoProcessApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(HuimvVideoProcessApplication.class, args);
+    }
+
+}

+ 39 - 0
huimv-video/huimv-video-process/src/main/java/com/huimv/process/controller/ImageController.java

@@ -0,0 +1,39 @@
+package com.huimv.process.controller;
+
+import com.huimv.process.service.IImageService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.io.IOException;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@RestController
+@RequestMapping("/image")
+@Slf4j
+public class ImageController {
+    @Autowired
+    private IImageService iImageService;
+
+    @RequestMapping(value = "/upload", method = RequestMethod.POST)
+    public void uploadPicture(@RequestParam("name") String name, @RequestParam("image") String imageBase64) throws IOException {
+        log.info(" name>>" + name);
+        log.info(" image_base64.length>>" + imageBase64.length());
+        //
+        if(iImageService.saveImage(imageBase64,name)){
+            log.info("保存图片成功");
+        }else{
+            log.error("保存图片出错");
+        }
+    }
+}

+ 36 - 0
huimv-video/huimv-video-process/src/main/java/com/huimv/process/controller/PictureController.java

@@ -0,0 +1,36 @@
+package com.huimv.process.controller;
+
+import com.huimv.process.service.IImageService;
+import com.huimv.process.utils.PictureUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import sun.misc.BASE64Decoder;
+
+import java.io.*;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@RestController
+@RequestMapping("/picture")
+public class PictureController {
+
+    @Autowired
+    private IImageService iImageService;
+
+    @RequestMapping(value = "/upload", method = RequestMethod.POST)
+    public void uploadPicture(@RequestParam("name") String name, @RequestParam("image") String imageBase64) throws IOException {
+        System.out.println("name>>" + name);
+        System.out.println("image_base64>>" + imageBase64);
+        //
+        iImageService.saveImage(imageBase64,name);
+    }
+
+
+
+}

+ 16 - 0
huimv-video/huimv-video-process/src/main/java/com/huimv/process/service/IImageService.java

@@ -0,0 +1,16 @@
+package com.huimv.process.service;
+
+public interface IImageService {
+
+    /**
+     * @Method      : saveImage
+     * @Description : 
+     * @Params      : [imageBase64, imgPath]
+     * @Return      : void
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/20       
+     * @Time        : 15:51
+     */
+    public boolean saveImage(String imageBase64, String name);
+}

+ 52 - 0
huimv-video/huimv-video-process/src/main/java/com/huimv/process/service/impl/ImageServiceImpl.java

@@ -0,0 +1,52 @@
+package com.huimv.process.service.impl;
+
+import com.huimv.process.service.IImageService;
+import com.huimv.process.utils.PictureUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Service
+@Slf4j
+public class ImageServiceImpl implements IImageService {
+
+    @Autowired
+    private PictureUtil pictureUtil;
+
+    @Override
+    public boolean saveImage(String imageBase64, String name) {
+        String uploadPath = "";
+        //
+        String os = System.getProperty("os.name");
+        String userDir = System.getProperty("user.dir");
+        if (os.toLowerCase().indexOf("windows") != -1) {
+            // Windows
+            uploadPath = userDir + "\\uploadImages\\";
+        } else {
+            // Linux
+            uploadPath = userDir+ "/uploadImages/";
+        }
+        // 时间戳
+        long timeMillis = System.currentTimeMillis();
+        //判断文件目录是否存在
+        File dir = new File(uploadPath);
+        if (!dir.exists()) { // && dir.isDirectory()
+            dir.mkdirs();
+        }
+//        String imgPath = uploadPath + name + "_"+ timeMillis + ".jpg";
+        StringBuilder imgBuild = new StringBuilder();
+        String imgPath = imgBuild.append(uploadPath).append(name).append("_").append(timeMillis).append(".jpg").toString();
+        // 保存
+         return pictureUtil.base64ToImage(imageBase64, imgPath);
+    }
+}

+ 99 - 0
huimv-video/huimv-video-process/src/main/java/com/huimv/process/utils/ImageBase64Converter.java

@@ -0,0 +1,99 @@
+package com.huimv.process.utils;
+
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+
+import java.io.*;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+public class ImageBase64Converter {
+    /**
+     * 本地文件(图片、excel等)转换成Base64字符串
+     *
+     * @param imgPath
+     */
+    public static String convertFileToBase64(String imgPath) {
+        byte[] data = null;
+        // 读取图片字节数组
+        try {
+            InputStream in = new FileInputStream(imgPath);
+            System.out.println("文件大小(字节)="+in.available());
+            data = new byte[in.available()];
+            in.read(data);
+            in.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        // 对字节数组进行Base64编码,得到Base64编码的字符串
+        BASE64Encoder encoder = new BASE64Encoder();
+        String base64Str = encoder.encode(data);
+        return base64Str;
+    }
+
+    /**
+     * 将base64字符串,生成文件
+     */
+    public static File convertBase64ToFile(String fileBase64String, String filePath, String fileName) {
+
+        BufferedOutputStream bos = null;
+        FileOutputStream fos = null;
+        File file = null;
+        try {
+            File dir = new File(filePath);
+            if (!dir.exists() && dir.isDirectory()) {//判断文件目录是否存在
+                dir.mkdirs();
+            }
+
+            BASE64Decoder decoder = new BASE64Decoder();
+            byte[] bfile = decoder.decodeBuffer(fileBase64String);
+
+            file = new File(filePath + File.separator + fileName);
+            fos = new FileOutputStream(file);
+            bos = new BufferedOutputStream(fos);
+            bos.write(bfile);
+            return file;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        } finally {
+            if (bos != null) {
+                try {
+                    bos.close();
+                } catch (IOException e1) {
+                    e1.printStackTrace();
+                }
+            }
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (IOException e1) {
+                    e1.printStackTrace();
+                }
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        long start = System.currentTimeMillis();
+        String imgBase64Str= ImageBase64Converter.convertFileToBase64("D:\\pic\\dream.jpg");
+        System.out.println("本地图片转换Base64:" + imgBase64Str);
+        System.out.println("Base64字符串length="+imgBase64Str.length());
+        ImageBase64Converter.convertBase64ToFile(imgBase64Str,"D:\\pic\\out","test.jpg");
+        System.out.println("duration:"+(System.currentTimeMillis()-start));
+
+//        start=System.currentTimeMillis();
+//        String fileBase64Str= ImageBase64Converter.convertFileToBase64("D:\\Pictures\\科技\\PayOrderList200109075516581.xlsx");
+////        System.out.println("本地excel转换Base64:" + fileBase64Str);
+//        System.out.println("Base64字符串length="+fileBase64Str.length());
+//        ImageBase64Converter.convertBase64ToFile(fileBase64Str,"D:\\Pictures\\科技","test.xlsx");
+//        System.out.println("duration:"+(System.currentTimeMillis()-start));
+
+    }
+}

+ 379 - 0
huimv-video/huimv-video-process/src/main/java/com/huimv/process/utils/PictureUtil.java

@@ -0,0 +1,379 @@
+package com.huimv.process.utils;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+
+import java.io.*;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+@Slf4j
+public class PictureUtil {
+
+    /**
+     * @Method : Base64ToImage
+     * @Description :
+     * @Params : [imgStr, imgFilePath]
+     * @Return : boolean
+     * @Author : ZhuoNing
+     * @Date : 2021/1/20
+     * @Time : 13:51
+     */
+    public boolean base64ToImage(String imageBase64, String imgFilePath) { // 对字节数组字符串进行Base64解码并生成图片
+        if (imageBase64 == null) {
+            // 图像数据为空
+            log.error("当前图像数据为空");
+            return false;
+        }
+        imageBase64 = imageBase64.replace("data:image/jpg;base64,","");
+        BASE64Decoder decoder = new BASE64Decoder();
+        try {
+            // Base64解码
+            byte[] b = decoder.decodeBuffer(imageBase64);
+            for (int i = 0; i < b.length; ++i) {
+                if (b[i] < 0) {// 调整异常数据
+                    b[i] += 256;
+                }
+            }
+            OutputStream out = new FileOutputStream(imgFilePath);
+            out.write(b);
+            out.flush();
+            out.close();
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    /**
+     * @param imgStr base64编码字符串
+     * @param path   图片路径-具体到文件
+     * @return
+     * @Description: 将base64编码字符串转换为图片
+     * @Author:
+     * @CreateTime:
+     */
+    public boolean generateImage(String imgStr, String path) {
+        if (imgStr == null) {
+            return false;
+        }
+        imgStr = imgStr.replace("image/jpg;base64,", "");
+
+        System.out.println(">>" + imgStr);
+        BASE64Decoder decoder = new BASE64Decoder();
+        try {
+// 解密
+            byte[] b = decoder.decodeBuffer(imgStr);
+// 处理数据
+            for (int i = 0; i < b.length; ++i) {
+                if (b[i] < 0) {
+                    b[i] += 256;
+                }
+            }
+            OutputStream out = new FileOutputStream(path);
+            out.write(b);
+            out.flush();
+            out.close();
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    /**
+     * @return
+     * @Description: 根据图片地址转换为base64编码字符串
+     * @Author:
+     * @CreateTime:
+     */
+//    public String getImageStr(String imgFile) {
+//        InputStream inputStream = null;
+//        byte[] data = null;
+//        try {
+//            inputStream = new FileInputStream(imgFile);
+//            data = new byte[inputStream.available()];
+//            inputStream.read(data);
+//            inputStream.close();
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }
+//        // 加密
+//        BASE64Encoder encoder = new BASE64Encoder();
+//        return encoder.encode(data);
+//    }
+
+    /**
+     * 本地文件(图片、excel等)转换成Base64字符串
+     *
+     * @param imgPath
+     */
+    public String convertFileToBase64(String imgPath) {
+        byte[] data = null;
+        // 读取图片字节数组
+        try {
+            InputStream in = new FileInputStream(imgPath);
+            System.out.println("文件大小(字节)=" + in.available());
+            data = new byte[in.available()];
+            in.read(data);
+            in.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        // 对字节数组进行Base64编码,得到Base64编码的字符串
+        BASE64Encoder encoder = new BASE64Encoder();
+        String base64Str = encoder.encode(data);
+        return base64Str;
+    }
+
+    /**
+     * 将base64字符串,生成文件
+     */
+    public File convertBase64ToFile(String fileBase64String, String filePath, String fileName) {
+        BufferedOutputStream bos = null;
+        FileOutputStream fos = null;
+        File file = null;
+        try {
+            File dir = new File(filePath);
+            if (!dir.exists() && dir.isDirectory()) {//判断文件目录是否存在
+                dir.mkdirs();
+            }
+
+            BASE64Decoder decoder = new BASE64Decoder();
+            byte[] bfile = decoder.decodeBuffer(fileBase64String);
+
+            file = new File(filePath + File.separator + fileName);
+            fos = new FileOutputStream(file);
+            bos = new BufferedOutputStream(fos);
+            bos.write(bfile);
+            return file;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        } finally {
+            if (bos != null) {
+                try {
+                    bos.close();
+                } catch (IOException e1) {
+                    e1.printStackTrace();
+                }
+            }
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (IOException e1) {
+                    e1.printStackTrace();
+                }
+            }
+        }
+    }
+    /**
+     * @Method : savePicture1
+     * @Description :
+     * @Params : [name, image_base64]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2021/1/20
+     * @Time : 12:13
+     */
+//    public void savePicture1(String name, String image_base64) {
+//        try {
+////            System.out.println("===imgStr.length()====>" + image.length()
+////                    + "=====imgStr=====>" + image);
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        int stateInt = 1;
+//        if (image_base64 != null && image_base64.length() > 0) {
+//            try {
+//
+//                // 将字符串转换成二进制,用于显示图片
+//                // 将上面生成的图片格式字符串 imgStr,还原成图片显示
+//                byte[] imgByte = hex2byte(image_base64);
+//                System.out.println("imgByte 输出>>" + imgByte);
+//                InputStream in = new ByteArrayInputStream(imgByte);
+//                System.out.println();
+//                String imgPath = "D:\\pic\\";
+//                File file = new File(imgPath, image_base64); //可以是任何图片格式.jpg,.png等
+//                FileOutputStream fos = new FileOutputStream(file);
+//
+//                byte[] b = new byte[1024];
+//                int nRead = 0;
+//                while ((nRead = in.read(b)) != -1) {
+//                    fos.write(b, 0, nRead);
+//                }
+//                fos.flush();
+//                fos.close();
+//                in.close();
+//
+//            } catch (Exception e) {
+//                stateInt = 0;
+//                e.printStackTrace();
+//            } finally {
+//            }
+//        }
+//    }
+
+    /**
+     * 将二进制转换成图片保存
+     //     * @param imgStr 二进制流转换的字符串
+     * @param imgPath 图片的保存路径
+     * @param imgName 图片的名称
+     * @return
+     *      1:保存正常
+     *      0:保存失败
+     */
+//    public static int saveToImgByBytes(File imgFile,String imgPath,String imgName){
+//
+//        int stateInt = 1;
+//        if(imgFile.length() > 0){
+//            try {
+//                File file=new File(imgPath,imgName);//可以是任何图片格式.jpg,.png等
+//                FileOutputStream fos=new FileOutputStream(file);
+//
+//                FileInputStream fis = new FileInputStream(imgFile);
+//
+//                byte[] b = new byte[1024];
+//                int nRead = 0;
+//                while ((nRead = fis.read(b)) != -1) {
+//                    fos.write(b, 0, nRead);
+//                }
+//                fos.flush();
+//                fos.close();
+//                fis.close();
+//
+//            } catch (Exception e) {
+//                stateInt = 0;
+//                e.printStackTrace();
+//            } finally {
+//            }
+//        }
+//        return stateInt;
+//    }
+
+    /**
+     * 二进制转字符串
+     * @param b
+     * @return
+     */
+//    public static String byte2hex(byte[] b) // 二进制转字符串
+//    {
+//        StringBuffer sb = new StringBuffer();
+//        String stmp = "";
+//        for (int n = 0; n < b.length; n++) {
+//            stmp = Integer.toHexString(b[n] & 0XFF);
+//            if (stmp.length() == 1) {
+//                sb.append("0" + stmp);
+//            } else {
+//                sb.append(stmp);
+//            }
+//
+//        }
+//        return sb.toString();
+//    }
+
+    /**
+     * 字符串转二进制
+     *
+     * @param str 要转换的字符串
+     * @return 转换后的二进制数组
+     */
+//    public static byte[] hex2byte(String str) { // 字符串转二进制
+//        if (str == null) {
+//            return null;
+//        }
+//        str = str.trim();
+//        int len = str.length();
+//        if (len == 0 || len % 2 == 1) {
+//            return null;
+//        }
+//        byte[] b = new byte[len / 2];
+//        try {
+//            for (int i = 0; i < str.length(); i += 2) {
+//                b[i / 2] = (byte) Integer
+//                        .decode("0X" + str.substring(i, i + 2)).intValue();
+//            }
+//            return b;
+//        } catch (Exception e) {
+//            return null;
+//        }
+//    }
+    ////////////////////////////////////////
+//    public boolean savePicture2(String imgData, String imgFilePath) throws IOException { // 对字节数组字符串进行Base64解码并生成图片
+//        if (imgData == null) { // 图像数据为空
+//            return false;
+//        }
+//        BASE64Decoder decoder = new BASE64Decoder();
+//        OutputStream out = null;
+//        try {
+//            out = new FileOutputStream(imgFilePath);
+//            // Base64解码
+//            byte[] b = decoder.decodeBuffer(imgData);
+//            for (int i = 0; i < b.length; ++i) {
+//                if (b[i] < 0) {// 调整异常数据
+//                    b[i] += 256;
+//                }
+//            }
+//            out.write(b);
+//        } catch (FileNotFoundException e) {
+//            // TODO Auto-generated catch block
+//            e.printStackTrace();
+//        } catch (IOException e) {
+//            // TODO Auto-generated catch block
+//            e.printStackTrace();
+//        } finally {
+//            out.flush();
+//            out.close();
+//            return true;
+//        }
+//    }
+    ////////////////////////////////////////////////////////////////////////
+//    public static boolean GenerateImage(String imgStr, String path) {
+//        if (imgStr == null) {
+//            return false;
+//        }
+//        BASE64Decoder decoder = new BASE64Decoder();
+//        try {
+//// 解密
+//            byte[] b = decoder.decodeBuffer(imgStr);
+//// 处理数据
+//            for (int i = 0; i < b.length; ++i) {
+//                if (b[i] < 0) {
+//                    b[i] += 256;
+//                }
+//            }
+//            OutputStream out = new FileOutputStream(path);
+//            out.write(b);
+//            out.flush();
+//            out.close();
+//            return true;
+//        } catch (Exception e) {
+//            return false;
+//        }
+//    }
+
+    /**
+     * 示例
+     */
+    public static void main(String[] args) {
+        PictureUtil pictureUtil = new PictureUtil();
+//        String strImg = pictureUtil.getImageStr("D:/pic/86619-106.jpg");
+//        System.out.println(strImg);
+//        pictureUtil.generateImage(strImg, "D:/pic/86619-107.jpg");
+
+        long start = System.currentTimeMillis();
+        String imgBase64Str = pictureUtil.convertFileToBase64("D:\\pic\\dream.jpg");
+        System.out.println("本地图片转换Base64:" + imgBase64Str);
+        System.out.println("Base64字符串length=" + imgBase64Str.length());
+        pictureUtil.convertBase64ToFile(imgBase64Str, "D:\\pic\\out", "test.jpg");
+        System.out.println("duration:" + (System.currentTimeMillis() - start));
+    }
+}

+ 35 - 0
huimv-video/huimv-video-process/src/main/resources/application-dev.yml

@@ -0,0 +1,35 @@
+server:
+  port: 8201
+
+spring:
+  datasource:
+    url: jdbc:mysql://192.168.1.7:3306/huimv-video_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    username: huimv
+    password: hm123456
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  jpa:
+    hibernate:
+      ddl-auto: update
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+    show-sql: true
+  servlet:
+    multipart:
+      max-file-size: 100MB
+      max-request-size: 1000MB
+  mvc:
+    view:
+      prefix: /
+      suffix: .html
+
+#  redis:
+#    database: 0
+#    host: 124.71.192.190
+#    port: 6379
+#    password: hm123456
+#    jedis:
+#      pool:
+#        max-active: 20
+#        max-wait: -1
+#        max-idle: 10
+#        min-idle: 0
+#    timeout: 5000

+ 4 - 0
huimv-video/huimv-video-process/src/main/resources/application.properties

@@ -0,0 +1,4 @@
+spring.profiles.active=dev
+#spring.profiles.active=prod
+
+

+ 5 - 0
huimv-video/huimv-video-process/src/main/resources/generator/config.properties

@@ -0,0 +1,5 @@
+jdbc.driverClass=com.mysql.cj.jdbc.Driver
+#jdbc.url=jdbc:mysql://192.168.1.7:3306/huimv-video_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+jdbc.url=jdbc:mysql://192.168.1.7:3306/huimv-video_db?useSSL=false
+jdbc.user=root
+jdbc.password=jdbc.password

+ 5 - 0
huimv-video/huimv-video-process/src/main/resources/generator/db.properties

@@ -0,0 +1,5 @@
+jdbc.driver=com.mysql.cj.jdbc.Driver
+#jdbc.url=jdbc:mysql://192.168.1.7:3306/huimv-video_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+jdbc.url=jdbc:mysql://192.168.1.7:3306/huimv-video_db?useSSL=false
+jdbc.username=root
+jdbc.password=hm123456

+ 39 - 0
huimv-video/huimv-video-process/src/main/resources/generator/generator-config.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE generatorConfiguration
+        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
+        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
+
+<generatorConfiguration>
+
+    <properties resource="generator/db.properties" />
+    <classPathEntry location="D:\DevTools\apache-maven-3.6.3\repo\mysql\mysql-connector-java\5.1.46\mysql-connector-java-5.1.46.jar"/>
+    <context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
+        <property name="beginningDelimiter" value="`" />
+        <property name="endingDelimiter" value="`" />
+        <plugin type="tk.mybatis.mapper.generator.MapperPlugin">
+            <!--自定义通用Mapper接口,将来所有生成的mapper接口都会继承这个接口-->
+            <property name="mappers"
+                      value="com.spldeolin.demoapp.component.Mapper" />
+        </plugin>
+<!--        <jdbcConnection driverClass="${jdbc.driver}"-->
+<!--                        connectionURL="${jdbc.url}"-->
+<!--                        userId="${jdbc.username}"-->
+<!--                        password="${jdbc.password}">-->
+<!--        </jdbcConnection>-->
+        <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
+                        connectionURL="jdbc:mysql://192.168.1.7:3306/huimv-video_db?serverTimezone=UTC&amp;useUnicode=true&amp;characterEncoding=utf-8"
+                        userId="root"
+                        password="hm123456">
+        </jdbcConnection>
+        <javaModelGenerator targetPackage="${targetModelPackage}"
+                            targetProject="${targetJavaProject}" />
+        <sqlMapGenerator targetPackage="${targetXMLPackage}"
+                         targetProject="${targetResourcesProject}" />
+        <javaClientGenerator targetPackage="${targetMapperPackage}"
+                             targetProject="${targetJavaProject}" type="XMLMAPPER" />
+        <table tableName="%">
+            <generatedKey column="id" sqlStatement="Mysql" identity="true" />
+        </table>
+    </context>
+
+</generatorConfiguration>

+ 38 - 0
huimv-video/huimv-video-process/src/main/resources/generator/generatorConfig.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE generatorConfiguration
+        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
+        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
+
+<generatorConfiguration>
+    <properties resource="generator/config.properties"/>
+
+    <context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
+        <property name="beginningDelimiter" value="`"/>
+        <property name="endingDelimiter" value="`"/>
+
+        <plugin type="tk.mybatis.mapper.generator.MapperPlugin">
+            <property name="mappers" value="tk.mybatis.mapper.common.Mapper"/>
+            <property name="caseSensitive" value="true"/>
+        </plugin>
+
+        <jdbcConnection driverClass="${jdbc.driverClass}"
+                        connectionURL="${jdbc.url}"
+                        userId="${jdbc.user}"
+                        password="${jdbc.password}">
+        </jdbcConnection>
+
+        <javaModelGenerator targetPackage="com.isea533.mybatis.model"
+                            targetProject="src/main/java"/>
+
+        <sqlMapGenerator targetPackage="mapper"
+                         targetProject="src/main/resources"/>
+
+        <javaClientGenerator targetPackage="com.isea533.mybatis.mapper"
+                             targetProject="src/main/java"
+                             type="XMLMAPPER"/>
+
+        <table tableName="pasture_area">
+            <generatedKey column="id" sqlStatement="JDBC"/>
+        </table>
+    </context>
+</generatorConfiguration>

+ 79 - 0
huimv-video/huimv-video-process/src/test/java/com/huimv/process/service/PicUtil.java

@@ -0,0 +1,79 @@
+package com.huimv.process.service;
+
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+
+import java.io.*;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+public class PicUtil {
+    /**
+     * @param imgStr base64编码字符串
+     * @param path   图片路径-具体到文件
+     * @return
+     * @Description: 将base64编码字符串转换为图片
+     * @Author:
+     * @CreateTime:
+     */
+    public static boolean generateImage(String imgStr, String path) {
+        if (imgStr == null) {
+            return false;
+        }
+        BASE64Decoder decoder = new BASE64Decoder();
+        try {
+// 解密
+            byte[] b = decoder.decodeBuffer(imgStr);
+// 处理数据
+            for (int i = 0; i < b.length; ++i) {
+                if (b[i] < 0) {
+                    b[i] += 256;
+                }
+            }
+            OutputStream out = new FileOutputStream(path);
+            out.write(b);
+            out.flush();
+            out.close();
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    /**
+     * @return
+     * @Description: 根据图片地址转换为base64编码字符串
+     * @Author:
+     * @CreateTime:
+     */
+    public static String getImageStr(String imgFile) {
+        InputStream inputStream = null;
+        byte[] data = null;
+        try {
+            inputStream = new FileInputStream(imgFile);
+            data = new byte[inputStream.available()];
+            inputStream.read(data);
+            inputStream.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        // 加密
+        BASE64Encoder encoder = new BASE64Encoder();
+        return encoder.encode(data);
+    }
+
+    /**
+     * 示例
+     */
+    public static void main(String[] args) {
+        String strImg = getImageStr("D:/pic/dream.jpg");
+        System.out.println(strImg);
+        generateImage(strImg, "D:/pic/dream2.jpg");
+    }
+}

+ 64 - 0
huimv-video/pom.xml

@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <packaging>pom</packaging>
+    <modules>
+        <module>huimv-video-process</module>
+        <module>huimv-video-manager</module>
+        <module>huimv-video-analyse</module>
+    </modules>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.4.2</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.huimv</groupId>
+    <artifactId>huimv-video</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>huimv-video</name>
+    <description>Demo project for Spring Boot</description>
+
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>5.1.46</version>
+        </dependency>
+        <dependency>
+            <groupId>tk.mybatis</groupId>
+            <artifactId>mapper</artifactId>
+            <version>4.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 13 - 0
huimv-video/src/main/java/com/huimv/huimvvideo/HuimvVideoApplication.java

@@ -0,0 +1,13 @@
+package com.huimv.huimvvideo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class HuimvVideoApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(HuimvVideoApplication.class, args);
+    }
+
+}

+ 1 - 0
huimv-video/src/main/resources/application.properties

@@ -0,0 +1 @@
+

+ 13 - 0
huimv-video/src/test/java/com/huimv/huimvvideo/HuimvVideoApplicationTests.java

@@ -0,0 +1,13 @@
+package com.huimv.huimvvideo;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class HuimvVideoApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}