From 57bb2ca1612869274144484c62de5ea3aee942c4 Mon Sep 17 00:00:00 2001 From: sjh Date: Thu, 14 Nov 2024 19:47:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B926=E5=8F=B7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../supervision/service/ModelClueService.java | 80 ++++++++++--------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/biutag/supervision/service/ModelClueService.java b/src/main/java/com/biutag/supervision/service/ModelClueService.java index ef5979f..63582e0 100644 --- a/src/main/java/com/biutag/supervision/service/ModelClueService.java +++ b/src/main/java/com/biutag/supervision/service/ModelClueService.java @@ -294,48 +294,54 @@ public class ModelClueService extends ServiceImpl { } private static void filterDataForModel26(List> allData) { - List> filteredData = allData.stream().filter(map -> map.get("ajbh") != null).toList(); - Map>> groupedData = filteredData.stream().collect(Collectors.groupingBy(map -> (String) map.get("ajbh"))); + List> filteredData = allData.stream().filter(map -> map.get("ajbh") != null && map.get("zjhm") != null).toList(); + Map>>> groupedData = filteredData.stream() + .collect(Collectors.groupingBy( + map -> (String) map.get("ajbh"), + Collectors.groupingBy(map -> (String) map.get("zjhm")) + )); allData.clear(); - for (Map.Entry>> entry : groupedData.entrySet()) { - String ajbh = entry.getKey(); - List> records = entry.getValue(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); - String earliestJRSJ = null; - LocalDateTime earliestDateTime = LocalDateTime.MIN; - for (Map record : records) { - String jrsj = (String) record.get("jrsj"); - LocalDateTime dateTime = LocalDateTime.parse(jrsj, formatter); - if (earliestJRSJ == null || !dateTime.isAfter(earliestDateTime)) { - earliestJRSJ = jrsj; - earliestDateTime = dateTime; - } - } - String latestLKSJ = null; - LocalDateTime latestDateTime = LocalDateTime.MIN; - for (Map record : records) { - String lksj = (String) record.get("lksj"); - LocalDateTime dateTime = LocalDateTime.parse(lksj, formatter); - if (latestLKSJ == null || dateTime.isAfter(latestDateTime)) { - latestLKSJ = lksj; - latestDateTime = dateTime; + for (Map.Entry>>> entry : groupedData.entrySet()) { + for (Map.Entry>> entry2 : entry.getValue().entrySet()) { + String ajbh = entry2.getKey(); + List> records = entry2.getValue(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); + String earliestJRSJ = null; + LocalDateTime earliestDateTime = LocalDateTime.MIN; + for (Map record : records) { + String jrsj = (String) record.get("jrsj"); + LocalDateTime dateTime = LocalDateTime.parse(jrsj, formatter); + if (earliestJRSJ == null || !dateTime.isAfter(earliestDateTime)) { + earliestJRSJ = jrsj; + earliestDateTime = dateTime; + } } - } - if (earliestJRSJ != null && latestLKSJ != null) { - Duration duration = Duration.between(earliestDateTime, latestDateTime); - if (duration.toHours() >= 3) { - continue; + String latestLKSJ = null; + LocalDateTime latestDateTime = LocalDateTime.MIN; + for (Map record : records) { + String lksj = (String) record.get("lksj"); + LocalDateTime dateTime = LocalDateTime.parse(lksj, formatter); + if (latestLKSJ == null || dateTime.isAfter(latestDateTime)) { + latestLKSJ = lksj; + latestDateTime = dateTime; + } } - Map newRecord = new HashMap<>(); - newRecord.put("ajbh", ajbh); - newRecord.put("jrsj", earliestJRSJ); - newRecord.put("lksj", latestLKSJ); - for (String key : records.get(0).keySet()) { - if (!key.equals("jrsj") && !key.equals("lksj")) { - newRecord.put(key, records.get(0).get(key)); + if (earliestJRSJ != null && latestLKSJ != null) { + Duration duration = Duration.between(earliestDateTime, latestDateTime); + if (duration.toHours() >= 3) { + continue; + } + Map newRecord = new HashMap<>(); + newRecord.put("ajbh", ajbh); + newRecord.put("jrsj", earliestJRSJ); + newRecord.put("lksj", latestLKSJ); + for (String key : records.get(0).keySet()) { + if (!key.equals("jrsj") && !key.equals("lksj")) { + newRecord.put(key, records.get(0).get(key)); + } } + allData.add(newRecord); } - allData.add(newRecord); } } System.out.println("模型26筛选后的alldata数量:" + allData.size());