You've already forked FrameTour-BE
refactor(device): 优化文件列表获取逻辑
- 移除了不必要的循环遍历,简化了代码结构 - 仅根据起始日期获取一次文件列表,提高了效率- 清除了无用的日历操作,减少了代码复杂性
This commit is contained in:
@@ -69,22 +69,14 @@ public class AliOssStorageOperator extends ADeviceStorageOperator {
|
|||||||
if (startDate == null || endDate == null) {
|
if (startDate == null || endDate == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<FileObject> fileList = new ArrayList<>();
|
|
||||||
if (startDate.after(endDate)) {
|
|
||||||
return fileList;
|
|
||||||
}
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(startDate);
|
calendar.setTime(startDate);
|
||||||
calendar.set(Calendar.SECOND, 0);
|
calendar.set(Calendar.SECOND, 0);
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||||
while (calendar.getTime().before(endDate)) {
|
String prefix = dateFormat.format(calendar.getTime());
|
||||||
String prefix = dateFormat.format(calendar.getTime());
|
List<FileObject> fileList = getOssFileListByPrefix(prefix);
|
||||||
List<FileObject> fileListByPrefix = getOssFileListByPrefix(prefix);
|
if (fileList == null) {
|
||||||
if (fileListByPrefix == null) {
|
return null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
fileList.addAll(fileListByPrefix);
|
|
||||||
calendar.add(Calendar.DATE, 1);
|
|
||||||
}
|
}
|
||||||
calendar.clear();
|
calendar.clear();
|
||||||
return fileList.stream()
|
return fileList.stream()
|
||||||
|
Reference in New Issue
Block a user