From dad449834228cbf49434b0f062f3f779396a40e6 Mon Sep 17 00:00:00 2001 From: wangzhijiang <12345678> Date: Fri, 17 Jun 2022 10:58:37 +0800 Subject: [PATCH] bug 54015 --- .../impl/FileSplitItemsEOServiceImpl.java | 77 ++++++++++--------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java index bb5bd606d..3a21d9da6 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java @@ -55,6 +55,7 @@ import com.jero.modules.system.service.ISysUserService; import com.jero.modules.system.service.impl.SysCategoryServiceImpl; import com.jero.modules.system.service.impl.SysDictItemServiceImpl; import com.jero.modules.system.util.UserUtils; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -1221,7 +1222,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl 30000){ // 若超出长度 - // 先移除再添加 - valContent.remove(lastIndex); + if(CollectionUtils.isNotEmpty(valContent)){ + FileSplitValExportDto fileSplitValExportDto = valContent.get(valContent.size() - 1); // 始终判断最后一个内容是否超出长度 + int lastIndex = valContent.size() - 1; + if ("TEXT".equals(fileSplitValExportDto.getValType())) { + String dtoValContent = fileSplitValExportDto.getValContent(); + //判断是否超长 + if(dtoValContent.length() > 30000){ // 若超出长度 + // 先移除再添加 + valContent.remove(lastIndex); - //拆分数据 - List content = new ArrayList<>(); // 存放拆出来的内容 - int lastLength = 0; - while (lastLength < dtoValContent.length()) { - if (lastLength == 0) { - String contentOld = dtoValContent.substring(0, 30000); - String contentNew = contentOld.substring(0,contentOld.lastIndexOf("\n")+1); - content.add(contentNew); - lastLength = 30000; - } else if (lastLength > dtoValContent.length() - 30000) { - String contentOld = dtoValContent.substring(lastLength, dtoValContent.length()); - String contentNew = contentOld.substring(0,contentOld.lastIndexOf("\n")+1); - content.add(contentNew); - lastLength = dtoValContent.length(); - } else{ - String contentOld = dtoValContent.substring(lastLength, lastLength + 30000); - String contentNew = contentOld.substring(0,contentOld.lastIndexOf("\n")+1); - content.add(contentNew); - lastLength = lastLength + 30000; + //拆分数据 + List content = new ArrayList<>(); // 存放拆出来的内容 + int lastLength = 0; + while (lastLength < dtoValContent.length()) { + if (lastLength == 0) { + String contentOld = dtoValContent.substring(0, 30000); + String contentNew = contentOld.substring(0,contentOld.lastIndexOf("\n")+1); + content.add(contentNew); + lastLength = 30000; + } else if (lastLength > dtoValContent.length() - 30000) { + String contentOld = dtoValContent.substring(lastLength, dtoValContent.length()); + String contentNew = contentOld.substring(0,contentOld.lastIndexOf("\n")+1); + content.add(contentNew); + lastLength = dtoValContent.length(); + } else{ + String contentOld = dtoValContent.substring(lastLength, lastLength + 30000); + String contentNew = contentOld.substring(0,contentOld.lastIndexOf("\n")+1); + content.add(contentNew); + lastLength = lastLength + 30000; + } } + + // 添加 + for (String c : content) { + FileSplitValExportDto dto = new FileSplitValExportDto(); + dto.setValType(fileSplitValExportDto.getValType()); + dto.setValContent(c); + valContent.add(dto); + } + } - - // 添加 - for (String c : content) { - FileSplitValExportDto dto = new FileSplitValExportDto(); - dto.setValType(fileSplitValExportDto.getValType()); - dto.setValContent(c); - valContent.add(dto); - } - } } }