Ver código fonte

提交图形查看接口

zhuoning 4 anos atrás
pai
commit
fe07b0f6a0

+ 0 - 2
huimv-video/huimv-video-manager/src/main/java/com/huimv/manager/HuimvVideoManagerApplication.java

@@ -2,9 +2,7 @@ package com.huimv.manager;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import tk.mybatis.spring.annotation.MapperScan;
 
-@MapperScan(basePackages = {"com.huimv.process.dao"})
 @SpringBootApplication
 public class HuimvVideoManagerApplication {
 

+ 22 - 2
huimv-video/huimv-video-manager/src/main/java/com/huimv/manager/controller/ImageController.java

@@ -15,17 +15,37 @@ import org.springframework.web.bind.annotation.RestController;
  * @Create : 2020-12-25
  **/
 @RestController
-@RequestMapping("/image")
-public class ImageController {
+@RequestMapping("/imageManager")
+public class ImageManagerController {
     @Autowired
     private IImageService imageService;
 
+    /**
+     * @Method      : getLastImageAiResult
+     * @Description : 读取最新的图像AI识别记录
+     * @Params      : []
+     * @Return      : java.lang.String
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/22       
+     * @Time        : 10:00
+     */
     @RequestMapping(value="/getLastImageAiResult",method = RequestMethod.GET)
     public String getLastImageAiResult(){
         //
         return imageService.getLastImage();
     }
 
+    /**
+     * @Method      : getNextImageAiResult
+     * @Description : 读取下一条图像AI识别记录
+     * @Params      : []
+     * @Return      : java.lang.String
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/22       
+     * @Time        : 10:01
+     */
     @RequestMapping(value="/getNextImageAiResult",method = RequestMethod.GET)
     public String getNextImageAiResult(){
         //

+ 1 - 1
huimv-video/huimv-video-manager/src/main/java/com/huimv/process/dao/entity/ImagePathEntity.java

@@ -1,4 +1,4 @@
-package com.huimv.process.dao.entity;
+package com.huimv.manager.dao.entity;
 
 import javax.persistence.*;
 import java.io.Serializable;

+ 35 - 0
huimv-video/huimv-video-manager/src/main/java/com/huimv/manager/dao/repo/ImagePathRepo.java

@@ -0,0 +1,35 @@
+package com.huimv.manager.dao.repo;
+
+import com.huimv.manager.dao.entity.ImagePathEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+public interface ImagePathRepo extends JpaRepository<ImagePathEntity, Integer>, JpaSpecificationExecutor<ImagePathEntity> {
+
+    /**
+     * @Method      : getLastImage
+     * @Description : 读取最新的图像记录
+     * @Params      : []
+     * @Return      : com.huimv.manager.dao.entity.ImagePathEntity
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/22       
+     * @Time        : 10:13
+     */
+    @Query(nativeQuery = true, value = "SELECT * FROM image_path ORDER BY create_date DESC LIMIT 1")
+    ImagePathEntity getLastImage();
+
+    /**
+     * @Method      : getNextImage
+     * @Description : 读取下一幅有效的图像记录
+     * @Params      : []
+     * @Return      : com.huimv.manager.dao.entity.ImagePathEntity
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/22       
+     * @Time        : 10:13
+     */
+    @Query(nativeQuery = true, value = "SELECT * FROM image_path WHERE effective=1 ORDER BY create_date ASC LIMIT 1")
+    ImagePathEntity getNextImage();
+}

+ 5 - 2
huimv-video/huimv-video-manager/src/main/java/com/huimv/manager/service/impl/ImageServiceImpl.java

@@ -1,8 +1,8 @@
 package com.huimv.manager.service.impl;
 
+import com.huimv.manager.dao.entity.ImagePathEntity;
+import com.huimv.manager.dao.repo.ImagePathRepo;
 import com.huimv.manager.service.IImageService;
-import com.huimv.process.dao.entity.ImagePathEntity;
-import com.huimv.process.dao.repo.ImagePathRepo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -50,6 +50,9 @@ public class ImageServiceImpl implements IImageService {
     public String getNextImage() {
         // 读取下一副图像
         ImagePathEntity imagePathEntity = imagePathRepo.getNextImage();
+        // 更改记录
+        imagePathEntity.setEffective(0);
+        imagePathRepo.saveAndFlush(imagePathEntity);
         return imagePathEntity.toString();
     }
 }

+ 0 - 14
huimv-video/huimv-video-manager/src/main/java/com/huimv/process/dao/repo/ImagePathRepo.java

@@ -1,14 +0,0 @@
-package com.huimv.process.dao.repo;
-
-import com.huimv.process.dao.entity.ImagePathEntity;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-import org.springframework.data.jpa.repository.Query;
-
-public interface ImagePathRepo extends JpaRepository<ImagePathEntity, Integer>, JpaSpecificationExecutor<ImagePathEntity> {
-    @Query(nativeQuery = true, value = "SELECT * FROM image_path ORDER BY create_time DESC LIMIT 1")
-    ImagePathEntity getLastImage();
-
-    @Query(nativeQuery = true, value = "SELECT * FROM image_path")
-    ImagePathEntity getNextImage();
-}

+ 36 - 0
huimv-video/huimv-video-manager/src/main/resources/application-dev.yml

@@ -0,0 +1,36 @@
+server:
+  port: 8203
+
+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: root
+    password: hm123456
+    driver-class-name: com.mysql.cj.jdbc.Driver
+  jpa:
+    hibernate:
+      ddl-auto: update  #validate
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+    show-sql: true
+  servlet:
+    multipart:
+      max-file-size: 100MB
+      max-request-size: 1000MB
+  mvc:
+    view:
+      prefix: /
+      suffix: .html
+  main:
+    allow-bean-definition-overriding: true
+#  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-manager/src/main/resources/application.properties

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

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

@@ -14,6 +14,8 @@ import org.springframework.web.client.RestTemplate;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.sql.Timestamp;
+import java.util.Date;
 
 /**
  * @Project : huimv.shiwan
@@ -33,8 +35,8 @@ public class ImageController {
     @ResponseBody
     @RequestMapping(value = "/upload", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
     public void uploadImage(@RequestBody JSONObject paramJo) throws IOException {
-//        log.info(" name>>" + paramJo.getString("name"));
-//        log.info(" image>>" + paramJo.getString("image"));
+        log.info("# 输入参数name>>" + paramJo.getString("name"));
+        log.info("# 输入参数image>>" + paramJo.getString("image"));
         String name = paramJo.getString("name");
         if (name == null) {
             log.error("出错:参数name为null");
@@ -43,7 +45,6 @@ public class ImageController {
         if (image == null) {
             log.error("出错:参数image为null");
         }
-//    }
 //        if(imageService.saveImage(imageBase64,name)){
         // 保存图片
         JSONObject saveResultJo = imageService.saveImage(image, name);
@@ -53,9 +54,7 @@ public class ImageController {
             String relativePath = saveResultJo.getString("relativePath");
             String fileName = saveResultJo.getString("fileName");
             // AI识别程序的结果
-//            String aiResult = imageService.getAiResult2(imgPath);
             JSONObject aiResultJo = imageService.getAiResult(imgPath,fileName);
-//            System.out.println("aiResultJo>>" + aiResultJo);
             String aiResult = aiResultJo.getString("result");
             if(!aiResult.trim().equalsIgnoreCase("success")){
                 log.error("AI识别结果出错: "+aiResultJo);
@@ -64,8 +63,9 @@ public class ImageController {
             }
             int aiTimeUsed = aiResultJo.getInteger("timeUsed");
             JSONArray aiPiggyJa = aiResultJo.getJSONArray("piggy");
+            Timestamp createTime = new Timestamp(new Date().getTime());
             // 图片入库
-            if(imageService.addImage(name, imgPath, relativePath, fileName,aiResult,aiTimeUsed,aiPiggyJa.toString())){
+            if(imageService.addImage(name, imgPath, relativePath, fileName,aiResult,aiTimeUsed,aiPiggyJa.toString(),createTime)){
                 log.info("图片入库成功.");
             }else{
                 log.info("图片入库出错.");

+ 2 - 1
huimv-video/huimv-video-process/src/main/java/com/huimv/process/service/IImageService.java

@@ -3,6 +3,7 @@ package com.huimv.process.service;
 import com.alibaba.fastjson.JSONObject;
 
 import java.io.IOException;
+import java.sql.Timestamp;
 
 public interface IImageService {
 
@@ -29,7 +30,7 @@ public interface IImageService {
      * @Date        : 2021/1/21       
      * @Time        : 14:23
      */
-    boolean addImage(String name, String imgPath, String relativePath, String fileName,String aiResult,int aiTimeUsed,String aiData);
+    boolean addImage(String name, String imgPath, String relativePath, String fileName, String aiResult, int aiTimeUsed, String aiData, Timestamp createTime);
 
     /**
      * @Method      : getAIResult2

+ 3 - 1
huimv-video/huimv-video-process/src/main/java/com/huimv/process/service/impl/ImageServiceImpl.java

@@ -17,6 +17,7 @@ import sun.misc.BASE64Decoder;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.sql.Timestamp;
 
 /**
  * @Project : huimv.shiwan
@@ -97,7 +98,7 @@ public class ImageServiceImpl implements IImageService {
      * @Time : 17:31
      */
     @Override
-    public boolean addImage(String name, String imgPath, String relativePath, String fileName,String aiResult,int aiTimeUsed,String aiData) {
+    public boolean addImage(String name, String imgPath, String relativePath, String fileName, String aiResult, int aiTimeUsed, String aiData, Timestamp createDate) {
         ImagePathEntity imagePathEntity = new ImagePathEntity();
         imagePathEntity.setName(name);
         imagePathEntity.setImgPath(imgPath);
@@ -107,6 +108,7 @@ public class ImageServiceImpl implements IImageService {
         imagePathEntity.setAiResult(aiResult);
         imagePathEntity.setAiTimeUsed(aiTimeUsed);
         imagePathEntity.setAiData(aiData);
+        imagePathEntity.setCreateDate(createDate);
         imagePathRepo.saveAndFlush(imagePathEntity);
         return true;
     }

+ 21 - 21
huimv-video/pom.xml

@@ -48,11 +48,11 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-jpa</artifactId>
         </dependency>
-        <dependency>
-            <groupId>tk.mybatis</groupId>
-            <artifactId>mapper</artifactId>
-            <version>4.0.0</version>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>tk.mybatis</groupId>-->
+<!--            <artifactId>mapper</artifactId>-->
+<!--            <version>4.0.0</version>-->
+<!--        </dependency>-->
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
@@ -64,22 +64,22 @@
             <version>1.2.62</version>
         </dependency>
         <!--通用mapper起步依赖-->
-        <dependency>
-            <groupId>tk.mybatis</groupId>
-            <artifactId>mapper-spring-boot-starter</artifactId>
-            <version>2.1.5</version>
-        </dependency>
-        <dependency>
-            <groupId>com.github.pagehelper</groupId>
-            <artifactId>pagehelper-spring-boot-starter</artifactId>
-            <version>1.2.3</version>
-        </dependency>
-        <dependency>
-            <groupId>javax.persistence</groupId>
-            <artifactId>persistence-api</artifactId>
-            <version>1.0</version>
-            <scope>compile</scope>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>tk.mybatis</groupId>-->
+<!--            <artifactId>mapper-spring-boot-starter</artifactId>-->
+<!--            <version>2.1.5</version>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>com.github.pagehelper</groupId>-->
+<!--            <artifactId>pagehelper-spring-boot-starter</artifactId>-->
+<!--            <version>1.2.3</version>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>javax.persistence</groupId>-->
+<!--            <artifactId>persistence-api</artifactId>-->
+<!--            <version>1.0</version>-->
+<!--            <scope>compile</scope>-->
+<!--        </dependency>-->
     </dependencies>
 
     <build>