Ver código fonte

质检-影像资料
1、一份记录多个文件的处理

LHB 1 mês atrás
pai
commit
9b51509487

+ 22 - 7
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/AlbumController.java

@@ -438,6 +438,22 @@ public class AlbumController extends BladeController {
         //查询关联关系
         List<ImageClassificationFile> list = albumImagesService.selectImageUrlByAlbumId(albumDTO.getId());
         if (CollectionUtil.isNotEmpty(list)) {
+            //可能存在一条数据多张照片的情况
+            List<ImageClassificationFile> images = new ArrayList<>();
+            list.forEach(f -> {
+                //多个照片
+                if (f.getImageUrl().contains(",")) {
+                    String[] split = f.getImageUrl().split(",");
+                    for (String imageUrl : split) {
+                        ImageClassificationFile file = BeanUtil.copyProperties(f, ImageClassificationFile.class);
+                        file.setImageUrl(imageUrl);
+                        images.add(file);
+                    }
+                } else {
+                    images.add(f);
+                }
+            });
+
             //旧pdf地址
             String imagesPdf = albumDTO.getImagesPdf();
 
@@ -502,7 +518,7 @@ public class AlbumController extends BladeController {
                     Workbook workbook = null;
 
                     List<String> pdfFileList = new ArrayList<>();
-                    List<List<ImageClassificationFile>> batchSize = CommonUtil.getBatchSize(list, 2);
+                    List<List<ImageClassificationFile>> batchSize = CommonUtil.getBatchSize(images, 2);
 
 
                     for (List<ImageClassificationFile> imageClassificationFiles : batchSize) {
@@ -520,7 +536,6 @@ public class AlbumController extends BladeController {
                                         Sheet sheet = workbook.getSheetAt(0);
                                         Drawing<?> drawing = sheet.createDrawingPatriarch();
                                         ClientAnchor anchor = helper.createClientAnchor();
-                                        Long id = file.getId();
                                         //获取文件流
                                         byte[] bytes = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(file.getImageUrl()));
                                         if (bytes[0] == 82 && bytes[1] == 73 && bytes[2] == 70) {
@@ -551,9 +566,9 @@ public class AlbumController extends BladeController {
                                         sheet.getRow(baseRow + 4).getCell(1).setCellValue(a + b);
                                         i++;
 
-                                        if(endInt != null && count > endInt){
+                                        if (endInt != null && count > endInt) {
                                             middleInt = count - 1;
-                                        }else{
+                                        } else {
                                             count++;
                                         }
                                     } catch (Exception e) {
@@ -603,7 +618,7 @@ public class AlbumController extends BladeController {
                     if (bladeFile != null) {
                         album.setImagesPdf(bladeFile.getLink());
                         //删除旧pdf
-                        if(StringUtils.isNotBlank(imagesPdf)){
+                        if (StringUtils.isNotBlank(imagesPdf)) {
                             String pdfName = imagesPdf.split("upload")[1];
                             this.newIOSSClient.removeFile("upload" + pdfName);
                         }
@@ -616,9 +631,9 @@ public class AlbumController extends BladeController {
                     throw new RuntimeException(e);
                 }
             }
-            if(middleInt != null){
+            if (middleInt != null) {
                 album.setCodes(startInt + "~" + middleInt);
-            }else{
+            } else {
                 album.setCodes(startInt + "~" + (count - 1));
             }
             return R.status(albumService.updateById(album));