public class Main {
public static void main(String[] args) {
List<Map<String, String>> systems = new ArrayList<>();
// 系统A
Map<String, String> systemA = new HashMap<>();
systemA.put("系统名称", "系统A");
systemA.put("文件夹路径", "系统A的文件夹路径"); // 替换为系统A的文件夹路径
systems.add(systemA);
// 系统B
Map<String, String> systemB = new HashMap<>();
systemB.put("系统名称", "系统B");
systemB.put("文件夹路径", "系统B的文件夹路径"); // 替换为系统B的文件夹路径
systems.add(systemB);
// 添加更多系统和对应的文件夹路径
for (Map<String, String> system : systems) {
String systemName = system.get("系统名称");
String folderPath = system.get("文件夹路径");
File folder = new File(folderPath);
File[] files = folder.listFiles();
if (files != null) {
Optional<File> latestFile = Arrays.stream(files)
.filter(File::isFile)
.max(Comparator.comparing(File::lastModified));
if (latestFile.isPresent()) {
File attachment = latestFile.get();
LocalDate uploadDate = LocalDate.ofEpochDay(attachment.lastModified() / (24 * 60 * 60 * 1000));
System.out.println(systemName + "最新日期的文档:" + attachment.getName());
System.out.println(systemName + "上传日期:" + uploadDate);
} else {
System.out.println(systemName + "没有找到文档");
}
} else {
System.out.println(systemName + "文件夹为空");
}
}
}
}