|
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
//import java.sql.Timestamp;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -93,13 +94,13 @@ public class ImageManagerController {
|
|
|
public JSONObject listImage(@RequestParam(value = "startDate", required = true) String startDate, @RequestParam(value = "endDate", required = true) String endDate, @RequestParam(value = "catalog", required = false) String catalog, @RequestParam(value = "pageNo", required = true) int pageNo, @RequestParam(value = "pageSize", required = true) int pageSize) {
|
|
|
log.info("startDate>>" + startDate);
|
|
|
log.info("endDate>>" + endDate);
|
|
|
- log.info("catalog>>"+catalog);
|
|
|
+ log.info("catalog>>" + catalog);
|
|
|
log.info("pageNo>>" + pageNo);
|
|
|
log.info("pageSize>>" + pageSize);
|
|
|
// 搜索记录时,catalog是非必要字段;
|
|
|
// 导出图片时,catalog是必要字段;
|
|
|
//
|
|
|
- List<ImagePathEntity> imageList = imageService.getImageList(startDate, endDate, pageNo, pageSize,catalog);
|
|
|
+ List<ImagePathEntity> imageList = imageService.getImageList(startDate, endDate, pageNo, pageSize, catalog);
|
|
|
JSONArray imageJa = new JSONArray();
|
|
|
for (ImagePathEntity imageEntity : imageList) {
|
|
|
// JSONObject dataJo = (JSONObject) JSONObject.toJSON(imageEntity);
|
|
@@ -118,7 +119,14 @@ public class ImageManagerController {
|
|
|
imageJa.add(imageJo);
|
|
|
}
|
|
|
// 读取记录数
|
|
|
- int total = imageService.getTotal(startDate, endDate);
|
|
|
+ int total = 0;
|
|
|
+ if(catalog != null && !catalog.trim().isEmpty()){
|
|
|
+ total= imageService.getTotal(startDate, endDate,catalog);
|
|
|
+ }else{
|
|
|
+ total= imageService.getTotal(startDate, endDate);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
JSONObject outJo = new JSONObject();
|
|
|
outJo.put("data", imageJa);
|
|
|
outJo.put("total", total);
|
|
@@ -138,10 +146,10 @@ public class ImageManagerController {
|
|
|
public Result getPreviousImage(@RequestParam(value = "imageId", required = true) int imageId) {
|
|
|
//
|
|
|
ImagePathEntity imagePathEntity = imageService.getOneImage("previous", imageId);
|
|
|
- if(imagePathEntity == null){
|
|
|
- return new Result(10001,"未查询到任何记录.",false);
|
|
|
- }else{
|
|
|
- return new Result(ResultCode.SUCCESS,(JSONObject)JSONObject.toJSON(imagePathEntity));
|
|
|
+ if (imagePathEntity == null) {
|
|
|
+ return new Result(10001, "未查询到任何记录.", false);
|
|
|
+ } else {
|
|
|
+ return new Result(ResultCode.SUCCESS, (JSONObject) JSONObject.toJSON(imagePathEntity));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -158,10 +166,10 @@ public class ImageManagerController {
|
|
|
public Result getNextImage(@RequestParam(value = "imageId", required = true) int imageId) {
|
|
|
//
|
|
|
ImagePathEntity imagePathEntity = imageService.getOneImage("next", imageId);
|
|
|
- if(imagePathEntity == null){
|
|
|
- return new Result(10001,"未查询到任何记录.",false);
|
|
|
- }else{
|
|
|
- return new Result(ResultCode.SUCCESS,(JSONObject)JSONObject.toJSON(imagePathEntity));
|
|
|
+ if (imagePathEntity == null) {
|
|
|
+ return new Result(10001, "未查询到任何记录.", false);
|
|
|
+ } else {
|
|
|
+ return new Result(ResultCode.SUCCESS, (JSONObject) JSONObject.toJSON(imagePathEntity));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -306,7 +314,6 @@ public class ImageManagerController {
|
|
|
out.write(FileUtils.readFileToByteArray(zipFile));
|
|
|
out.flush();
|
|
|
out.close();
|
|
|
-
|
|
|
// 输出客户端结束后,删除压缩包
|
|
|
if (zipFile.exists()) {
|
|
|
zipFile.delete();
|
|
@@ -314,20 +321,27 @@ public class ImageManagerController {
|
|
|
}
|
|
|
|
|
|
@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 {
|
|
|
+ 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, @RequestParam(value = "catalog", required = false) String catalog) throws Exception {
|
|
|
// if(imageIds == null || imageIds.trim().isEmpty()){
|
|
|
// log.error("输入参数[imageIds]不能为空.");
|
|
|
// return ;
|
|
|
// }
|
|
|
log.info("输入参数[startDate]>>" + startDate);
|
|
|
log.info("输入参数[endDate]>>" + endDate);
|
|
|
+ log.info("输入参数[catalog]>>" + catalog);
|
|
|
log.info("输入参数[imageIds]>>" + imageIds);
|
|
|
if (startDate == null && endDate == null && imageIds == null) {
|
|
|
log.error("日期区间或指定图片导出二选一");
|
|
|
return;
|
|
|
}
|
|
|
- // 读取图片文件
|
|
|
- List<ImagePathEntity> imageList = imageService.getExportImageList(startDate, endDate, imageIds);
|
|
|
+ List<ImagePathEntity> imageList = new ArrayList<>();
|
|
|
+ if (catalog != null && !catalog.trim().isEmpty()) {
|
|
|
+ // 读取图片文件
|
|
|
+ imageList = imageService.getExportImageList(startDate, endDate, imageIds,catalog);
|
|
|
+ } else {
|
|
|
+ // 读取图片文件
|
|
|
+ imageList = imageService.getExportImageList(startDate, endDate, imageIds);
|
|
|
+ }
|
|
|
if (imageList.size() == 0) {
|
|
|
log.error("未读取到任何需要导出的图片.");
|
|
|
return;
|
|
@@ -335,8 +349,10 @@ public class ImageManagerController {
|
|
|
// System.out.println("imageList.size>>"+imageList.size());
|
|
|
int i = 0;
|
|
|
File[] fileList = new File[imageList.size()];
|
|
|
+ String camera = "";
|
|
|
for (ImagePathEntity imagePathEntity : imageList) {
|
|
|
File imageFile = new File(imagePathEntity.getImgPath());
|
|
|
+ camera = imagePathEntity.getName();
|
|
|
fileList[i++] = imageFile;
|
|
|
}
|
|
|
//定义根路径
|
|
@@ -348,11 +364,14 @@ public class ImageManagerController {
|
|
|
file.mkdir();
|
|
|
}
|
|
|
String name = "图片压缩包下载";
|
|
|
- String fileName = name + new Date().getTime();
|
|
|
+ if (catalog != null && !catalog.trim().isEmpty()) {
|
|
|
+ name = camera;
|
|
|
+ }
|
|
|
+ String fileName = name +"_"+ dateUtil.formatLongTimeForTime(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);
|
|
@@ -377,7 +396,6 @@ public class ImageManagerController {
|
|
|
out.write(FileUtils.readFileToByteArray(zipFile));
|
|
|
out.flush();
|
|
|
out.close();
|
|
|
-
|
|
|
// 输出客户端结束后,删除压缩包
|
|
|
if (zipFile.exists()) {
|
|
|
zipFile.delete();
|