Browse Source

白名单过期后,未能正常

dzx 2 months ago
parent
commit
6a52e2000f

+ 0 - 4
src/main/java/com/xjrsoft/module/material/controller/MaterialTaskController.java

@@ -277,10 +277,6 @@ public class MaterialTaskController {
     @PostMapping("/download-file-export-query")
     @PostMapping("/download-file-export-query")
     @ApiOperation(value = "下载附件(zip压缩包)")
     @ApiOperation(value = "下载附件(zip压缩包)")
     public ResponseEntity<byte[]> downloadFile(@Valid @RequestBody MaterialTaskAssignListDto dto) {
     public ResponseEntity<byte[]> downloadFile(@Valid @RequestBody MaterialTaskAssignListDto dto) {
-        MaterialTask materialTask = materialTaskService.getById(dto.getMaterialTaskId());
-
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
-
         byte[] bytes = materialTaskService.downloadFile(dto);
         byte[] bytes = materialTaskService.downloadFile(dto);
         return RT.fileStream(bytes, "download-file-export.zip");
         return RT.fileStream(bytes, "download-file-export.zip");
     }
     }

+ 24 - 6
src/main/java/com/xjrsoft/module/material/service/impl/MaterialTaskServiceImpl.java

@@ -526,10 +526,22 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
 
 
     @Override
     @Override
     public byte[] downloadFile(MaterialTaskAssignListDto dto) {
     public byte[] downloadFile(MaterialTaskAssignListDto dto) {
-        List<MaterialTaskAppendix> appendices = appendixMapper.selectList(
-                new QueryWrapper<MaterialTaskAppendix>().lambda()
-                        .eq(MaterialTaskAppendix::getMaterialTaskId, dto.getMaterialTaskId())
-        );
+
+        MPJLambdaWrapper<MaterialTaskAppendix> queryWrapper = new MPJLambdaWrapper<>();
+        queryWrapper
+                .disableSubLogicDel()
+                .distinct()
+                .select(MaterialTaskAppendix::getId)
+                .select(MaterialTaskAppendix.class, x -> VoToColumnUtil.fieldsToColumns(MaterialTaskAppendix.class).contains(x.getProperty()))
+                .innerJoin(MaterialTaskAssign.class, MaterialTaskAssign::getId, MaterialTaskAppendix::getMaterialTaskId)
+                .eq(MaterialTaskAssign::getMaterialTaskId, dto.getMaterialTaskId())
+                .eq(MaterialTaskAssign::getStatus, dto.getState())
+        ;
+
+        List<MaterialTaskAppendix> appendices = appendixMapper.selectJoinList(MaterialTaskAppendix.class, queryWrapper);
+        if(appendices.isEmpty()){
+            throw new MyException("未能查询到附件");
+        }
         List<Long> userIds = appendices.stream().map(MaterialTaskAppendix::getCreateUserId).collect(Collectors.toList());
         List<Long> userIds = appendices.stream().map(MaterialTaskAppendix::getCreateUserId).collect(Collectors.toList());
         List<User> userList = userService.listByIds(userIds);
         List<User> userList = userService.listByIds(userIds);
         Map<Long, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, x -> x));
         Map<Long, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, x -> x));
@@ -538,8 +550,9 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
         MaterialTask task = this.getById(dto.getMaterialTaskId());
         MaterialTask task = this.getById(dto.getMaterialTaskId());
 
 
         for (MaterialTaskAppendix appendix : appendices) {
         for (MaterialTaskAppendix appendix : appendices) {
-            List<File> fileList = fileService.list(Wrappers.<File>query().lambda().eq(File::getFolderId, appendix.getFileId()));
+            List<File> fileList = fileService.list(Wrappers.<File>query().lambda().eq(File::getId, appendix.getFileId()));
             User user = userMap.get(appendix.getCreateUserId());
             User user = userMap.get(appendix.getCreateUserId());
+
             for (int i = 0; i < fileList.size(); i++) {
             for (int i = 0; i < fileList.size(); i++) {
                 try {
                 try {
                     URL url = new URL(fileList.get(i).getFileUrl());
                     URL url = new URL(fileList.get(i).getFileUrl());
@@ -552,7 +565,12 @@ public class MaterialTaskServiceImpl extends MPJBaseServiceImpl<MaterialTaskMapp
                         outputStream.write(buffer, 0, bytesRead);
                         outputStream.write(buffer, 0, bytesRead);
                     }
                     }
                     byte[] byteArray = outputStream.toByteArray();
                     byte[] byteArray = outputStream.toByteArray();
-                    byteAryMap.put(user.getName() + "-" + user.getUserName() + "-" + task.getName() + fileList.get(i).getFileType(), byteArray);
+                    String fileName = user.getName() + "-" + user.getUserName() + "-" + task.getName();
+                    if(fileList.size() > 1){
+                        fileName += "-" + (i + 1);
+                    }
+                    fileName += fileList.get(i).getFileType();
+                    byteAryMap.put(fileName, byteArray);
                     in.close();
                     in.close();
                     outputStream.close();
                     outputStream.close();
                 } catch (IOException e) {
                 } catch (IOException e) {