bug 54015

This commit is contained in:
wangzhijiang
2022-06-17 10:58:37 +08:00
parent d9351b5746
commit dad4498342
@@ -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.SysCategoryServiceImpl;
import com.jero.modules.system.service.impl.SysDictItemServiceImpl; import com.jero.modules.system.service.impl.SysDictItemServiceImpl;
import com.jero.modules.system.util.UserUtils; import com.jero.modules.system.util.UserUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -1221,7 +1222,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
if(oSSFile!=null){ if(oSSFile!=null){
oSSFile = ossFileService.getById(oSSFile.getId()); oSSFile = ossFileService.getById(oSSFile.getId());
isText = false; isText = false;
// BASE64Encoder base64Encoder = new BASE64Encoder(); // BASE64Encoder base64Encoder = new BASE64Encoder();
// String encode = base64Encoder.encode(oSSFile.getUrl().getBytes(StandardCharsets.UTF_8)); // String encode = base64Encoder.encode(oSSFile.getUrl().getBytes(StandardCharsets.UTF_8));
String path = splitUrl + "/jero-boot/sys/split/file/getImage?fileUrl=" + oSSFile.getUrl(); String path = splitUrl + "/jero-boot/sys/split/file/getImage?fileUrl=" + oSSFile.getUrl();
@@ -3245,45 +3246,47 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
} }
private void splitContext(List<FileSplitValExportDto> valContent){ private void splitContext(List<FileSplitValExportDto> valContent){
FileSplitValExportDto fileSplitValExportDto = valContent.get(valContent.size() - 1); // 始终判断最后一个内容是否超出长度 if(CollectionUtils.isNotEmpty(valContent)){
int lastIndex = valContent.size() - 1; FileSplitValExportDto fileSplitValExportDto = valContent.get(valContent.size() - 1); // 始终判断最后一个内容是否超出长度
if ("TEXT".equals(fileSplitValExportDto.getValType())) { int lastIndex = valContent.size() - 1;
String dtoValContent = fileSplitValExportDto.getValContent(); if ("TEXT".equals(fileSplitValExportDto.getValType())) {
//判断是否超长 String dtoValContent = fileSplitValExportDto.getValContent();
if(dtoValContent.length() > 30000){ // 若超出长度 //判断是否超长
// 先移除再添加 if(dtoValContent.length() > 30000){ // 若超出长度
valContent.remove(lastIndex); // 先移除再添加
valContent.remove(lastIndex);
//拆分数据 //拆分数据
List<String> content = new ArrayList<>(); // 存放拆出来的内容 List<String> content = new ArrayList<>(); // 存放拆出来的内容
int lastLength = 0; int lastLength = 0;
while (lastLength < dtoValContent.length()) { while (lastLength < dtoValContent.length()) {
if (lastLength == 0) { if (lastLength == 0) {
String contentOld = dtoValContent.substring(0, 30000); String contentOld = dtoValContent.substring(0, 30000);
String contentNew = contentOld.substring(0,contentOld.lastIndexOf("\n")+1); String contentNew = contentOld.substring(0,contentOld.lastIndexOf("\n")+1);
content.add(contentNew); content.add(contentNew);
lastLength = 30000; lastLength = 30000;
} else if (lastLength > dtoValContent.length() - 30000) { } else if (lastLength > dtoValContent.length() - 30000) {
String contentOld = dtoValContent.substring(lastLength, dtoValContent.length()); String contentOld = dtoValContent.substring(lastLength, dtoValContent.length());
String contentNew = contentOld.substring(0,contentOld.lastIndexOf("\n")+1); String contentNew = contentOld.substring(0,contentOld.lastIndexOf("\n")+1);
content.add(contentNew); content.add(contentNew);
lastLength = dtoValContent.length(); lastLength = dtoValContent.length();
} else{ } else{
String contentOld = dtoValContent.substring(lastLength, lastLength + 30000); String contentOld = dtoValContent.substring(lastLength, lastLength + 30000);
String contentNew = contentOld.substring(0,contentOld.lastIndexOf("\n")+1); String contentNew = contentOld.substring(0,contentOld.lastIndexOf("\n")+1);
content.add(contentNew); content.add(contentNew);
lastLength = lastLength + 30000; 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);
}
} }
} }
} }