yangdamao 1 月之前
父节点
当前提交
3f8ff44f22

+ 20 - 18
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserSubscribeServiceImpl.java

@@ -2276,18 +2276,20 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
         }
 
         //打包zip 上传oss
-        String zipPath = zhiyuan + "/zhongzheng-admin/src/main/resources/"
-                + String.format("%s预约考试%s.zip", DateUtils.timestampToDateFormat(bo.getApplySiteExamTime(), "yyyy-MM-dd"), DateUtils.getNowTime());
-        FileUtils.toZip(zipPath, destDirPath, true);
+//        String zipPath = zhiyuan + "/zhongzheng-admin/src/main/resources/"
+//                + String.format("%s预约考试%s.zip", DateUtils.timestampToDateFormat(bo.getApplySiteExamTime(), "yyyy-MM-dd"), DateUtils.getNowTime());
+        String filename = FileUtils.encodingZipFilename("学员信息数据");
+        String zipFile = FileUtils.getZipAbsoluteFile(filename);
+        FileUtils.toZip(zipFile, destDirPath, true);
         //上传oss
-        OssRequest ossRequest = new OssRequest();
-        ossRequest.setGradeId(0L);
-        ossRequest.setUserId(0L);
-        ossRequest.setImageStatus(7);
-        File file1 = new File(zipPath);
-        ossRequest.setFile(FileUtils.getMultipartFile(file1));
+//        OssRequest ossRequest = new OssRequest();
+//        ossRequest.setGradeId(0L);
+//        ossRequest.setUserId(0L);
+//        ossRequest.setImageStatus(7);
+//        File file1 = new File(zipPath);
+//        ossRequest.setFile(FileUtils.getMultipartFile(file1));
         try {
-            String upload = ossService.upload(ossRequest);
+//            String upload = ossService.upload(ossRequest);
             //删除本地资源
             Path pathStr = Paths.get(destDirPath);
             try (Stream<Path> walk = Files.walk(pathStr)) {
@@ -2297,14 +2299,14 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
                 log.error("删除本地资源失败:" + DateUtils.getNowTime());
             }
 
-            Path zipStr = Paths.get(zipPath);
-            try (Stream<Path> walk = Files.walk(zipStr)) {
-                walk.sorted(Comparator.reverseOrder())
-                        .forEach(FileUtils::deleteDirectoryStream);
-            } catch (IOException e) {
-                log.error("删除本地资源失败:" + DateUtils.getNowTime());
-            }
-            map.put("zip", AjaxResult.success(upload));
+//            Path zipStr = Paths.get(zipPath);
+//            try (Stream<Path> walk = Files.walk(zipStr)) {
+//                walk.sorted(Comparator.reverseOrder())
+//                        .forEach(FileUtils::deleteDirectoryStream);
+//            } catch (IOException e) {
+//                log.error("删除本地资源失败:" + DateUtils.getNowTime());
+//            }
+            map.put("zip", AjaxResult.success(filename));
         } catch (Exception e) {
             e.printStackTrace();
         }