Преглед на файлове

1、新建导出图片压缩包接口
2、新建获取前一张图片接口
3、新建获取下一张图片接口

zhuoning преди 4 години
родител
ревизия
98b7e79140

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

@@ -11,5 +11,17 @@
 
     <artifactId>huimv-video-manager</artifactId>
 
+    <dependencies>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.8.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-compress</artifactId>
+            <version>1.9</version>
+        </dependency>
+    </dependencies>
 
 </project>

+ 323 - 11
huimv-video/huimv-video-manager/src/main/java/com/huimv/manager/controller/ImageManagerController.java

@@ -4,11 +4,29 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.huimv.manager.dao.entity.ImagePathEntity;
 import com.huimv.manager.service.IImageService;
+import com.huimv.manager.utils.DateUtil;
+import com.huimv.manager.utils.ImageByteUtil;
+//import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.compress.archivers.ArchiveException;
+import org.apache.commons.compress.archivers.ArchiveOutputStream;
+import org.apache.commons.compress.archivers.ArchiveStreamFactory;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
+//import org.apache.tomcat.util.http.fileupload.FileUtils;
+import org.apache.commons.io.FileUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+//import java.sql.Timestamp;
+import java.util.Date;
+import java.util.List;
 
 /**
  * @Project : huimv.shiwan
@@ -18,12 +36,15 @@ import org.springframework.web.bind.annotation.RestController;
  * @Author : ZhuoNing
  * @Create : 2020-12-25
  **/
+@Slf4j
 @CrossOrigin
 @RestController
 @RequestMapping("/imageManager")
 public class ImageManagerController {
     @Autowired
     private IImageService imageService;
+    @Autowired
+    private DateUtil dateUtil;
 
     /**
      * @Method      : getLastImageAiResult
@@ -37,9 +58,7 @@ public class ImageManagerController {
      */
     @RequestMapping(value="/getLastImageAiResult",method = RequestMethod.GET)
     public String getLastImageAiResult(){
-        //
-        ImagePathEntity imagePathEntity = imageService.getLastImage();
-        return JSONObject.toJSON(imagePathEntity).toString();
+        return JSONObject.toJSON(imageService.getLastImage()).toString();
     }
 
     /**
@@ -55,11 +74,304 @@ public class ImageManagerController {
     @RequestMapping(value="/getNextImageAiResult",method = RequestMethod.GET)
     public String getNextImageAiResult(){
         //
-        return imageService.getNextImage();
+        return JSONObject.toJSON(imageService.getNextImage()).toString();
+    }
+
+    /**
+     * @Method      : listImage
+     * @Description : 
+     * @Params      : [startDate, endDate, pageNo, pageSize]
+     * @Return      : com.alibaba.fastjson.JSONArray
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/22       
+     * @Time        : 16:28
+     */
+    @Deprecated
+    @RequestMapping(value="/listImage",method = RequestMethod.GET)
+    public JSONObject listImage(@RequestParam(value = "startDate",required = true) String startDate,@RequestParam(value = "endDate",required = true) String endDate,@RequestParam(value = "pageNo",required = true) int pageNo,@RequestParam(value = "pageSize",required = true) int pageSize){
+        log.info("startDate>>"+startDate);
+        log.info("endDate>>"+endDate);
+        log.info("pageNo>>"+pageNo);
+        log.info("pageSize>>"+pageSize);
+        //
+        List<ImagePathEntity> imageList = imageService.getImageList(startDate,endDate,pageNo,pageSize);
+        JSONArray imageJa = new JSONArray();
+        for(ImagePathEntity imageEntity:imageList){
+//            JSONObject dataJo = (JSONObject) JSONObject.toJSON(imageEntity);
+            JSONObject imageJo = new JSONObject();
+            imageJo.put("aiData",imageEntity.getAiData());
+            imageJo.put("aiResult",imageEntity.getAiResult());
+            imageJo.put("aiTimeUsed",imageEntity.getAiTimeUsed());
+            imageJo.put("createDate",dateUtil.formatTimestamp(imageEntity.getCreateDate()));
+            imageJo.put("effective",imageEntity.getEffective());
+            imageJo.put("fileName",imageEntity.getFileName());
+            imageJo.put("id",imageEntity.getId());
+            imageJo.put("imgPath",imageEntity.getImgPath());
+            imageJo.put("name",imageEntity.getName());
+            imageJo.put("relativePath",imageEntity.getRelativePath());
+            imageJa.add(imageJo);
+        }
+        // 读取记录数
+        int total = imageService.getTotal(startDate,endDate);
+        JSONObject outJo = new JSONObject();
+        outJo.put("data",imageJa);
+        outJo.put("total",total);
+        return outJo;
     }
 
-//    public JSONArray listImage(String startDate, String endDate){
-//        imageService
-//    }
+    /**
+     * @Method      : previousImage
+     * @Description : 读取前一张
+     * @Params      : [id]
+     * @Return      : com.alibaba.fastjson.JSONObject
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/23       
+     * @Time        : 19:09
+     */
+    @RequestMapping(value = "/getPreviousImage",method = RequestMethod.GET)
+    public JSONObject getPreviousImage(@RequestParam(value = "imageId",required = true) int imageId){
+        return imageService.getOneImage("previous",imageId);
+    }
 
+    /**
+     * @Method      : nextImage
+     * @Description : 读取下一张图片
+     * @Params      : [id]
+     * @Return      : com.alibaba.fastjson.JSONObject
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/23       
+     * @Time        : 19:09
+     */
+    @RequestMapping(value = "/getNextImage",method = RequestMethod.GET)
+    public JSONObject getNextImage(@RequestParam(value = "imageId",required = true) int imageId){
+        //
+        return imageService.getOneImage("next",imageId);
+    }
+
+    @Deprecated
+    @RequestMapping("/exportPicture")
+    public void exportPicture(HttpServletRequest request, HttpServletResponse response) throws Exception {
+        //定义根路径
+        String rootPath = request.getRealPath("/");
+        //创建文件
+        File file = new File(rootPath+"temp_download");
+        //判断文件是否存在,如果不存在,则创建此文件夹
+        if(!file.exists()){
+            file.mkdir();
+        }
+        String name = "图片压缩包下载";
+        String fileName = name+new Date().getTime();
+        String zipFileName = fileName + ".zip";
+        File zipFile = null;
+        String path = rootPath + "temp_download";
+
+        //调用工具类获取图片
+        byte[] data = ImageByteUtil.image2byte("F:\\blank.jpg");
+        //new一个文件对象用来保存图片,默认保存当前工程根目录
+        if(data != null){
+            File imageFile = new File(path+File.separator+fileName+".jpg");
+            //创建输出流
+            FileOutputStream outStream = new FileOutputStream(imageFile);
+            //写入数据
+            outStream.write(data);
+            //关闭输出流
+            outStream.close();
+        }
+
+        try {
+            /*
+             * 用JDK自带的zipentry压缩后,压缩包中的文件名中文乱码,故放弃此种方法,使用commons-compress-1.6.jar包
+             * ZipEntry zipEntry = new ZipEntry(new
+             * String(txtFile.getName().getBytes("GB2312"),"ISO-8859-1"));
+             * zos.putNextEntry(zipEntry); ZipOutputStream zos = new
+             * ZipOutputStream(zipFos); ZipEntry zipEntry = new ZipEntry(new
+             * String(txtFile.getName().getBytes("GB2312"),"ISO-8859-1")); zos.
+             * putNextEntry(zipEntry);
+             * zos.write(FileUtils.readFileToByteArray(txtFile)); zos.flush();
+             * zos.close();
+             */
+            //获取创建好的图片文件
+            File imageFile = new File(path+"/"+fileName+".jpg");
+            // 打成压缩包
+            zipFile = new File(path + "/" + zipFileName);
+            FileOutputStream zipFos = new FileOutputStream(zipFile);
+            ArchiveOutputStream archOut = new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, zipFos);
+            if (archOut instanceof ZipArchiveOutputStream) {
+                ZipArchiveOutputStream zos = (ZipArchiveOutputStream) archOut;
+                ZipArchiveEntry zipEntry = new ZipArchiveEntry(imageFile, imageFile.getName());
+                zos.putArchiveEntry(zipEntry);
+                zos.write(FileUtils.readFileToByteArray(imageFile));
+                zos.closeArchiveEntry();
+                zos.flush();
+                zos.close();
+            }
+
+            // 压缩完删除txt文件
+            if (imageFile.exists()) {
+                imageFile.delete();
+            }
+
+            // 输出到客户端
+            OutputStream out = null;
+            out = response.getOutputStream();
+            response.reset();
+            response.setHeader("Content-Disposition", "attachment;filename=" + new String(zipFileName.getBytes("GB2312"), "ISO-8859-1"));
+            response.setContentType("application/octet-stream; charset=utf-8");
+            response.setCharacterEncoding("UTF-8");
+            out.write(FileUtils.readFileToByteArray(zipFile));
+            out.flush();
+            out.close();
+
+            // 输出客户端结束后,删除压缩包
+            if (zipFile.exists()) {
+                zipFile.delete();
+            }
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ArchiveException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 压缩多个文件到一个zip压缩包中
+     * @description :
+     * @date 2016-11-4
+     * @author liucong
+     * @param request
+     * @param response
+     * @throws Exception
+     *
+     *
+     */
+    @RequestMapping("/zipMoreFiles")
+    public void zipMoreFiles(HttpServletRequest request,HttpServletResponse response) throws Exception{
+        //定义根路径
+        String rootPath = request.getRealPath("/");
+        //创建文件
+        File file = new File(rootPath+"temp_download");
+        //判断文件是否存在,如果不存在,则创建此文件夹
+        if(!file.exists()){
+            file.mkdir();
+        }
+        String name = "图片压缩包下载";
+        String fileName = name+new Date().getTime();
+        String zipFileName = fileName + ".zip";
+        File zipFile = null;
+        String path = rootPath + "temp_download";
+        //获取本地文件夹中图片集合,事先准备好图片
+        File files = new File("F:\\images\\");
+        //获取该文件夹中的图片文件数组
+        File[] filelist = files.listFiles();
+        // 打成压缩包
+        zipFile = new File(path + "/" + zipFileName);
+        FileOutputStream zipFos = new FileOutputStream(zipFile);
+        ArchiveOutputStream archOut = new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, zipFos);
+        if (archOut instanceof ZipArchiveOutputStream) {
+            ZipArchiveOutputStream zos = (ZipArchiveOutputStream) archOut;
+            for(File imageFile : filelist){
+                ZipArchiveEntry zipEntry = new ZipArchiveEntry(imageFile, imageFile.getName());
+                zos.putArchiveEntry(zipEntry);
+                zos.write(FileUtils.readFileToByteArray(imageFile));
+                zos.closeArchiveEntry();
+                zos.flush();
+            }
+            zos.close();
+        }
+        // 输出到客户端
+        OutputStream out = null;
+        out = response.getOutputStream();
+        response.reset();
+        response.setHeader("Content-Disposition", "attachment;filename=" + new String(zipFileName.getBytes("GB2312"), "ISO-8859-1"));
+        response.setContentType("application/octet-stream; charset=utf-8");
+        response.setCharacterEncoding("UTF-8");
+        out.write(FileUtils.readFileToByteArray(zipFile));
+        out.flush();
+        out.close();
+
+        // 输出客户端结束后,删除压缩包
+        if (zipFile.exists()) {
+            zipFile.delete();
+        }
+    }
+    @RequestMapping("/exportImage")
+    public void exportImage(HttpServletRequest request,HttpServletResponse response,@RequestParam(value="startDate",required = false) String startDate,@RequestParam(value="endDate",required = false) String endDate,@RequestParam(value="imageIds",required = false) String imageIds) throws Exception{
+//        if(imageIds == null || imageIds.trim().isEmpty()){
+//            log.error("输入参数[imageIds]不能为空.");
+//            return ;
+//        }
+        log.info("输入参数[startDate]>>"+startDate);
+        log.info("输入参数[endDate]>>"+endDate);
+        log.info("输入参数[imageIds]>>"+imageIds);
+        if(startDate == null && endDate == null && imageIds ==null ){
+            log.error("日期区间或指定图片导出二选一");
+            return ;
+        }
+        // 读取图片文件
+        List<ImagePathEntity> imageList = imageService.getExportImageList(startDate,endDate,imageIds);
+        if(imageList.size()==0){
+            log.error("未读取到任何需要导出的图片.");
+            return;
+        }
+//        System.out.println("imageList.size>>"+imageList.size());
+        int i = 0;
+        File[] fileList = new File[imageList.size()];
+        for(ImagePathEntity imagePathEntity:imageList){
+            File imageFile = new File(imagePathEntity.getImgPath());
+            fileList[i++]=imageFile;
+        }
+        //定义根路径
+        String rootPath = request.getRealPath("/");
+        //创建文件
+        File file = new File(rootPath+"temp_download");
+        //判断文件是否存在,如果不存在,则创建此文件夹
+        if(!file.exists()){
+            file.mkdir();
+        }
+        String name = "图片压缩包下载";
+        String fileName = name+new Date().getTime();
+        String zipFileName = fileName + ".zip";
+        File zipFile = null;
+        String path = rootPath + "temp_download";
+// 打成压缩包
+        zipFile = new File(path + "/" + zipFileName);
+        FileOutputStream zipFos = new FileOutputStream(zipFile);
+        ArchiveOutputStream archOut = new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, zipFos);
+        if (archOut instanceof ZipArchiveOutputStream) {
+            ZipArchiveOutputStream zos = (ZipArchiveOutputStream) archOut;
+            for(File imageFile : fileList){
+                ZipArchiveEntry zipEntry = new ZipArchiveEntry(imageFile, imageFile.getName());
+                zos.putArchiveEntry(zipEntry);
+                zos.write(FileUtils.readFileToByteArray(imageFile));
+                zos.closeArchiveEntry();
+                zos.flush();
+            }
+            zos.close();
+        }
+        // 输出到客户端
+        OutputStream out = null;
+        out = response.getOutputStream();
+        response.reset();
+        response.setHeader("Content-Disposition", "attachment;filename=" + new String(zipFileName.getBytes("GB2312"), "ISO-8859-1"));
+        response.setContentType("application/octet-stream; charset=utf-8");
+        response.setCharacterEncoding("UTF-8");
+        out.write(FileUtils.readFileToByteArray(zipFile));
+        out.flush();
+        out.close();
+
+        // 输出客户端结束后,删除压缩包
+        if (zipFile.exists()) {
+            zipFile.delete();
+        }
+    }
+
+    @RequestMapping(value = "/exportOneImage",method = RequestMethod.GET)
+    public void exportOneImage(@RequestParam(value = "type",required = true) String type){
+
+    }
 }

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

@@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Query;
 
+import java.util.List;
+
 public interface ImagePathRepo extends JpaRepository<ImagePathEntity, Integer>, JpaSpecificationExecutor<ImagePathEntity> {
 
     /**
@@ -32,4 +34,65 @@ public interface ImagePathRepo extends JpaRepository<ImagePathEntity, Integer>,
      */
     @Query(nativeQuery = true, value = "SELECT * FROM image_path WHERE effective=1 ORDER BY create_date ASC LIMIT 1")
     ImagePathEntity getNextImage();
+
+    @Query(nativeQuery = true, value = "SELECT id,name,img_path,relative_path,file_name,effective,ai_result,ai_time_used,ai_data,create_date FROM image_path WHERE DATE_FORMAT(create_date,'%Y-%m-%d')>=DATE_FORMAT(:startDate,'%Y-%m-%d') AND DATE_FORMAT(create_date,'%Y-%m-%d')<=DATE_FORMAT(:endDate,'%Y-%m-%d') ORDER BY create_date DESC LIMIT :pageNo,:pageSize")
+    List<ImagePathEntity> listImage(String startDate, String endDate,int pageNo,int pageSize);
+
+    @Query(nativeQuery = true, value = "SELECT id,name,img_path,relative_path,file_name,effective,ai_result,ai_time_used,ai_data,create_date FROM image_path WHERE DATE_FORMAT(create_date,'%Y-%m-%d')>=DATE_FORMAT(:startDate,'%Y-%m-%d') AND DATE_FORMAT(create_date,'%Y-%m-%d')<=DATE_FORMAT(:endDate,'%Y-%m-%d') ORDER BY create_date DESC LIMIT :pageNo,:pageSize")
+    List<ImagePathEntity> listImage2(String startDate, String endDate,int pageNo,int pageSize);
+
+    @Query(nativeQuery = true, value = "SELECT count(id) FROM image_path WHERE DATE_FORMAT(create_date,'%Y-%m-%d')>=DATE_FORMAT(:startDate,'%Y-%m-%d') AND DATE_FORMAT(create_date,'%Y-%m-%d')<=DATE_FORMAT(:endDate,'%Y-%m-%d')")
+    int getTotal(String startDate, String endDate);
+
+    /**
+     * @Method      : getExportImageList
+     * @Description : 读取导出的图片
+     * @Params      : [startDate, endDate]
+     * @Return      : java.util.List
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/23       
+     * @Time        : 17:06
+     */
+    @Query(nativeQuery = true, value = "SELECT * FROM image_path WHERE DATE_FORMAT(create_date,'%Y-%m-%d')>=DATE_FORMAT(:startDate,'%Y-%m-%d') AND DATE_FORMAT(create_date,'%Y-%m-%d')<=DATE_FORMAT(:endDate,'%Y-%m-%d')")
+    List<ImagePathEntity> getExportImageListByStartAndEndDate(String startDate, String endDate);
+
+    /**
+     * @Method      : getExportImageListById
+     * @Description : 
+     * @Params      : [imageIdList]
+     * @Return      : java.util.List
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/23       
+     * @Time        : 17:07
+     */
+    @Query(nativeQuery = true, value = "SELECT * FROM image_path WHERE id IN(:imageIdList)")
+    List<ImagePathEntity> getExportImageListById(List imageIdList);
+
+    /**
+     * @Method      : getNextImageById
+     * @Description : 读取下一张图片
+     * @Params      : [imageId]
+     * @Return      : void
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/23       
+     * @Time        : 19:23
+     */
+    @Query(nativeQuery = true, value = "SELECT * FROM image_path WHERE id>:imageId ORDER BY id ASC LIMIT 1")
+    ImagePathEntity getNextImageById(int imageId);
+
+    /**
+     * @Method      : getPreviousImageById
+     * @Description : 读取前一张图片
+     * @Params      : [imageId]
+     * @Return      : void
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/23       
+     * @Time        : 19:24
+     */
+    @Query(nativeQuery = true, value = "SELECT * FROM image_path WHERE id<:imageId ORDER BY id DESC LIMIT 1")
+    ImagePathEntity getPreviousImageById(int imageId);
 }

+ 52 - 1
huimv-video/huimv-video-manager/src/main/java/com/huimv/manager/service/IImageService.java

@@ -1,7 +1,10 @@
 package com.huimv.manager.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.huimv.manager.dao.entity.ImagePathEntity;
 
+import java.util.List;
+
 public interface IImageService {
     /**
      * @Method      : getLastImage
@@ -25,5 +28,53 @@ public interface IImageService {
      * @Date        : 2021/1/21       
      * @Time        : 20:56
      */
-    String getNextImage();
+    ImagePathEntity getNextImage();
+
+    /**
+     * @Method      : getImageList
+     * @Description : 
+     * @Params      : [startDate, endDate]
+     * @Return      : java.util.List<com.huimv.manager.dao.entity.ImagePathEntity>
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/22       
+     * @Time        : 16:04
+     */
+    List<ImagePathEntity> getImageList(String startDate, String endDate,int pageNo,int pageSize);
+
+    /**
+     * @Method      : getTotal
+     * @Description : 
+     * @Params      : [startDate, endDate]
+     * @Return      : int
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/22       
+     * @Time        : 16:48
+     */
+    int getTotal(String startDate, String endDate);
+
+    /**
+     * @Method      : getExportImageList
+     * @Description : 
+     * @Params      : [startDate, endDate, imageIds]
+     * @Return      : java.util.List
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/23       
+     * @Time        : 16:50
+     */
+    List getExportImageList(String startDate, String endDate, String imageIds);
+
+    /**
+     * @Method      : getOneImage
+     * @Description : 
+     * @Params      : [type, imageId]
+     * @Return      : com.alibaba.fastjson.JSONObject
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/23       
+     * @Time        : 19:25
+     */
+    JSONObject getOneImage(String type, int imageId);
 }

+ 72 - 3
huimv-video/huimv-video-manager/src/main/java/com/huimv/manager/service/impl/ImageServiceImpl.java

@@ -1,11 +1,15 @@
 package com.huimv.manager.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.huimv.manager.dao.entity.ImagePathEntity;
 import com.huimv.manager.dao.repo.ImagePathRepo;
 import com.huimv.manager.service.IImageService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * @Project : huimv.shiwan
  * @Package : com.huimv.biosafety.uface.controller
@@ -47,16 +51,81 @@ public class ImageServiceImpl implements IImageService {
      * @Time        : 20:49
      */
     @Override
-    public String getNextImage() {
+    public ImagePathEntity getNextImage() {
         // 读取下一副图像
         ImagePathEntity imagePathEntity = imagePathRepo.getNextImage();
         if(imagePathEntity!=null){
             // 更改记录
             imagePathEntity.setEffective(0);
             imagePathRepo.saveAndFlush(imagePathEntity);
-            return imagePathEntity.toString();
+            return imagePathEntity;
+        }else{
+            return imagePathRepo.getLastImage();
+        }
+    }
+
+    /**
+     * @Method      : getImageList
+     * @Description : 
+     * @Params      : [startDate, endDate, pageNo, pageSize]
+     * @Return      : java.util.List<com.huimv.manager.dao.entity.ImagePathEntity>
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/22       
+     * @Time        : 16:50
+     */
+    @Override
+    public List<ImagePathEntity> getImageList(String startDate, String endDate,int pageNo,int pageSize) {
+        System.out.println("pageNo>>"+pageNo);
+        System.out.println("pageSize>>"+pageSize);
+        int start = (pageNo-1)*pageSize;
+        System.out.println("start>>"+start);
+        // 按照日期区间,读取图片列表
+        return imagePathRepo.listImage(startDate,endDate,start,pageSize);
+    }
+
+    /**
+     * @Method      : getTotal
+     * @Description : 
+     * @Params      : [startDate, endDate]
+     * @Return      : int
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/1/22       
+     * @Time        : 16:50
+     */
+    @Override
+    public int getTotal(String startDate, String endDate) {
+        // 根据条件读取总记录数
+        return imagePathRepo.getTotal(startDate,endDate);
+    }
+
+    @Override
+    public List<ImagePathEntity> getExportImageList(String startDate, String endDate, String imageIds) {
+        // 以指定图片导出优先条件
+        if(imageIds == null || imageIds.trim().isEmpty()){
+            // 用startDate,endDate读取需要导出的图片
+            return imagePathRepo.getExportImageListByStartAndEndDate(startDate,endDate);
+        }else{
+            // 指定需要导出的图片
+            String[] idArray = imageIds.split(",");
+            List imageIdList = new ArrayList();
+            for(String id:idArray){
+                imageIdList.add(id);
+            }
+            // 读取导出图片
+            return imagePathRepo.getExportImageListById(imageIdList);
+        }
+    }
+
+    @Override
+    public JSONObject getOneImage(String type, int imageId) {
+        if(type.trim().equalsIgnoreCase("next")){
+            // 读取下一张照片
+            return  (JSONObject)JSONObject.toJSON(imagePathRepo.getNextImageById(imageId));
         }else{
-            return imagePathRepo.getLastImage().toString();
+            // 读取上一张照片
+            return  (JSONObject)JSONObject.toJSON(imagePathRepo.getPreviousImageById(imageId));
         }
     }
 }

+ 34 - 0
huimv-video/huimv-video-manager/src/main/java/com/huimv/manager/utils/DateUtil.java

@@ -0,0 +1,34 @@
+package com.huimv.manager.utils;
+
+import org.springframework.stereotype.Component;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+public class DateUtil {
+//1429339937748l
+    public String formatLongTime(Long dateLong){
+        Date date =new Date(dateLong);//以1429339937748为bai毫秒数du实例化zhi一个Date对象dao
+        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");//设置转化格式
+        String time=sdf.format(date);//将Date对象转化为yyyy-MM-dd形式的字符串zhuan
+        System.out.println(time);//输出字符串
+        return time;
+    }
+
+    public String formatTimestamp(Timestamp timestamp) {
+        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        //方法一
+        return sdf.format(timestamp);
+    }
+}

+ 91 - 0
huimv-video/huimv-video-manager/src/main/java/com/huimv/manager/utils/ImageByteUtil.java

@@ -0,0 +1,91 @@
+package com.huimv.manager.utils;
+
+import javax.imageio.stream.FileImageInputStream;
+import javax.imageio.stream.FileImageOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+public class ImageByteUtil {
+    /**
+     * 实现图片与byte数组之间的互相转换
+     * @param args
+     */
+    public static void main(String[] args) {
+        //定义路径
+        String path = "F:\\blank.jpg";
+        byte[] data = image2byte(path);
+        System.out.println(data.length);
+    }
+
+    /**
+     * 将图片转换为byte数组
+     * @param path 图片路径
+     * @return
+     */
+    public static byte[] image2byte(String path){
+        //定义byte数组
+        byte[] data = null;
+        //输入流
+        FileImageInputStream input = null;
+        try {
+            input = new FileImageInputStream(new File(path));
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
+            byte[] buf = new byte[1024];
+            int numBytesRead = 0;
+            while ((numBytesRead = input.read(buf)) != -1) {
+                output.write(buf, 0, numBytesRead);
+            }
+            data = output.toByteArray();
+            output.close();
+            input.close();
+        }
+        catch (FileNotFoundException ex1) {
+            ex1.printStackTrace();
+        }
+        catch (IOException ex1) {
+            ex1.printStackTrace();
+        }
+        return data;
+    }
+
+    //byte数组到图片
+    public void byte2image(byte[] data,String path){
+        if(data.length<3||path.equals("")){ return; }
+        try{
+            FileImageOutputStream imageOutput = new FileImageOutputStream(new File(path));
+            imageOutput.write(data, 0, data.length);
+            imageOutput.close();
+            System.out.println("Make Picture success,Please find image in " + path);
+        } catch(Exception ex) {
+            System.out.println("Exception: " + ex);
+            ex.printStackTrace();
+        }
+    }
+    //byte数组到16进制字符串
+    public String byte2string(byte[] data){
+        if(data==null||data.length<=1){ return "0x"; }
+        if(data.length>200000){ return "0x"; }
+        StringBuffer sb = new StringBuffer();
+        int buf[] = new int[data.length];
+        //byte数组转化成十进制
+        for(int k=0;k<data.length;k++){
+            buf[k] = data[k]<0?(data[k]+256):(data[k]);
+        }
+        //十进制转化成十六进制
+        for(int k=0;k<buf.length;k++){
+            if(buf[k]<16){ sb.append("0"+Integer.toHexString(buf[k])); }
+            else{ sb.append(Integer.toHexString(buf[k])); }
+        }
+        return "0x"+sb.toString().toUpperCase();
+    }
+}

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

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

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

@@ -1,13 +0,0 @@
-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);
-    }
-
-}

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

@@ -1 +0,0 @@
-

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

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