获取时记得排序,默认是倒叙的

This commit is contained in:
Jerry Yan 2025-01-13 10:26:10 +08:00
parent 0d2c92e8e1
commit 9c1d979bd8

View File

@ -14,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
import java.net.URI; import java.net.URI;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -78,7 +79,8 @@ public class WvpActiveStorageOperator extends ADeviceStorageOperator {
if (result.getInteger("code") == 0) { if (result.getInteger("code") == 0) {
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
List<JSONObject> recordList = data.getJSONArray("list").toJavaList(JSONObject.class); List<JSONObject> recordList = data.getJSONArray("list").toJavaList(JSONObject.class);
return recordList.stream().map(record -> { return recordList.stream()
.map(record -> {
FileObject object = new FileObject(); FileObject object = new FileObject();
object.setName(record.getString("id")); object.setName(record.getString("id"));
object.setPath(record.getString("folder")); object.setPath(record.getString("folder"));
@ -87,7 +89,9 @@ public class WvpActiveStorageOperator extends ADeviceStorageOperator {
object.setCreateTime(new Date(record.getLongValue("startTime"))); object.setCreateTime(new Date(record.getLongValue("startTime")));
object.setEndTime(new Date(record.getLongValue("endTime"))); object.setEndTime(new Date(record.getLongValue("endTime")));
return object; return object;
}).collect(Collectors.toList()); })
.sorted(Comparator.comparing(FileObject::getCreateTime))
.collect(Collectors.toList());
} }
return Collections.emptyList(); return Collections.emptyList();
} }