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.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<FileSplitItemsEOMap
if(oSSFile!=null){
oSSFile = ossFileService.getById(oSSFile.getId());
isText = false;
// BASE64Encoder base64Encoder = new BASE64Encoder();
// String encode = base64Encoder.encode(oSSFile.getUrl().getBytes(StandardCharsets.UTF_8));
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){
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);
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<String> 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<String> 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);
}
}
}
}