Browse Source

fix 修改批量下载接口

DYH2020 2 năm trước cách đây
mục cha
commit
028f2623eb

+ 12 - 12
src/main/java/com/ywt/mg/params/enterprise/marketting/BatchDownloadFilesRequest.java

@@ -10,11 +10,11 @@ public class BatchDownloadFilesRequest extends PageRequest implements Serializab
     @ApiModelProperty(value = "申请id", example = "")
     private Integer id;
 
-    @ApiModelProperty(value = "上传时间查询开始时间", example = "")
-    private String uploadTimeStart;
+    @ApiModelProperty(value = "创建时间查询开始时间", example = "")
+    private String createTimeStart;
 
-    @ApiModelProperty(value = "上传时间查询截止时间", example = "")
-    private String uploadTimeEnd;
+    @ApiModelProperty(value = "创建时间查询截止时间", example = "")
+    private String createTimeEnd;
 
     public Integer getId() {
         return id;
@@ -24,19 +24,19 @@ public class BatchDownloadFilesRequest extends PageRequest implements Serializab
         this.id = id;
     }
 
-    public String getUploadTimeStart() {
-        return uploadTimeStart;
+    public String getCreateTimeStart() {
+        return createTimeStart;
     }
 
-    public void setUploadTimeStart(String uploadTimeStart) {
-        this.uploadTimeStart = uploadTimeStart;
+    public void setCreateTimeStart(String createTimeStart) {
+        this.createTimeStart = createTimeStart;
     }
 
-    public String getUploadTimeEnd() {
-        return uploadTimeEnd;
+    public String getCreateTimeEnd() {
+        return createTimeEnd;
     }
 
-    public void setUploadTimeEnd(String uploadTimeEnd) {
-        this.uploadTimeEnd = uploadTimeEnd;
+    public void setCreateTimeEnd(String createTimeEnd) {
+        this.createTimeEnd = createTimeEnd;
     }
 }

+ 9 - 12
src/main/java/com/ywt/mg/services/enterprise/ApplyProjectService.java

@@ -66,8 +66,9 @@ public class ApplyProjectService {
      * @return
      */
     public void batchDownloadFiles(BatchDownloadFilesRequest request, HttpServletResponse response) {
-        String filePrefix = "";
-        String rootPrefix = "";
+        int number = (int) (Math.random() * 1000);
+        String filePrefix = APPLY_PROJECT_FILE_PATH + number + "/";
+        String rootPrefix = APPLY_PROJECT_ROOT_PATH + number + "/";
         try {
             // 1、先根据从前端选择的条件去数据库查找对应的记录
             Map<String, String> item = new HashMap<>();
@@ -83,9 +84,6 @@ public class ApplyProjectService {
                 MarketingImage image = marketingImageList.get(i);
                 item.put(i+"_"+image.getName(), image.getImageUrl());
             }
-            int number = (int) (Math.random() * 1000);
-            filePrefix = APPLY_PROJECT_FILE_PATH + number + "/";
-            rootPrefix = APPLY_PROJECT_ROOT_PATH + number + "/";
 
             // 2、遍历记录去下载对应的文件到服务器;
             List<String> fileUrl = new ArrayList<>();
@@ -100,11 +98,10 @@ public class ApplyProjectService {
                 downloadSingleFile(urlLink, pathName);
                 fileUrl.add(pathName);
             }
-
             // 3、将下载的文件打包
             String zipFileName = "资料";
-            if (!Checker.isNone(request.getUploadTimeStart()) && !Checker.isNone(request.getUploadTimeEnd())) {
-                zipFileName += request.getUploadTimeStart().replace("-", "") + "~" + request.getUploadTimeEnd().replace("-", "");
+            if (!Checker.isNone(request.getCreateTimeStart()) && !Checker.isNone(request.getCreateTimeEnd())) {
+                zipFileName += request.getCreateTimeStart().replace("-", "") + "~" + request.getCreateTimeEnd().replace("-", "");
             }
             zipFileName += ".zip";
             FileUtil.createFoldersIfNotExit(rootPrefix + zipFileName);
@@ -116,8 +113,8 @@ public class ApplyProjectService {
             logger.error("ApplyProjectService#batchDownloadFiles(request:{}){}", JsonSerializer.toJson(request), e.getMessage(), e);
         } finally {
             // 5、删掉之前所有的文件;
-            FileUtil.deleteFolders(filePrefix);
-            FileUtil.deleteFolders(rootPrefix);
+//            FileUtil.deleteFolders(filePrefix);
+//            FileUtil.deleteFolders(rootPrefix);
         }
     }
 
@@ -134,13 +131,13 @@ public class ApplyProjectService {
         String formatDate = "yyyy-MM-dd";
         SimpleDateFormat format = new SimpleDateFormat(formatDate);
         try {
-            String createTime = request.getUploadTimeStart();
+            String createTime = request.getCreateTimeStart();
             if (!Checker.isNull(createTime)) {
                 whereSql += " and (create_time >= ?)";
                 Date date = format.parse(createTime);
                 paramList.add(date);
             }
-            String createEndTime = request.getUploadTimeEnd();
+            String createEndTime = request.getCreateTimeEnd();
             if (!Checker.isNull(createEndTime)) {
                 whereSql += " and ( create_time < ? )";
                 Date date = format.parse(createEndTime);