Browse Source

Merge remote-tracking branch 'origin/master'

main
parent
commit
a17b41e8aa
  1. 80
      src/main/java/com/biutag/supervision/service/ModelClueService.java

80
src/main/java/com/biutag/supervision/service/ModelClueService.java

@ -294,48 +294,54 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
} }
private static void filterDataForModel26(List<Map<String, Object>> allData) { private static void filterDataForModel26(List<Map<String, Object>> allData) {
List<Map<String, Object>> filteredData = allData.stream().filter(map -> map.get("ajbh") != null).toList(); List<Map<String, Object>> filteredData = allData.stream().filter(map -> map.get("ajbh") != null && map.get("zjhm") != null).toList();
Map<String, List<Map<String, Object>>> groupedData = filteredData.stream().collect(Collectors.groupingBy(map -> (String) map.get("ajbh"))); Map<String, Map<String, List<Map<String, Object>>>> groupedData = filteredData.stream()
.collect(Collectors.groupingBy(
map -> (String) map.get("ajbh"),
Collectors.groupingBy(map -> (String) map.get("zjhm"))
));
allData.clear(); allData.clear();
for (Map.Entry<String, List<Map<String, Object>>> entry : groupedData.entrySet()) { for (Map.Entry<String, Map<String, List<Map<String, Object>>>> entry : groupedData.entrySet()) {
String ajbh = entry.getKey(); for (Map.Entry<String, List<Map<String, Object>>> entry2 : entry.getValue().entrySet()) {
List<Map<String, Object>> records = entry.getValue(); String ajbh = entry2.getKey();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); List<Map<String, Object>> records = entry2.getValue();
String earliestJRSJ = null; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
LocalDateTime earliestDateTime = LocalDateTime.MIN; String earliestJRSJ = null;
for (Map<String, Object> record : records) { LocalDateTime earliestDateTime = LocalDateTime.MIN;
String jrsj = (String) record.get("jrsj"); for (Map<String, Object> record : records) {
LocalDateTime dateTime = LocalDateTime.parse(jrsj, formatter); String jrsj = (String) record.get("jrsj");
if (earliestJRSJ == null || !dateTime.isAfter(earliestDateTime)) { LocalDateTime dateTime = LocalDateTime.parse(jrsj, formatter);
earliestJRSJ = jrsj; if (earliestJRSJ == null || !dateTime.isAfter(earliestDateTime)) {
earliestDateTime = dateTime; earliestJRSJ = jrsj;
} earliestDateTime = dateTime;
} }
String latestLKSJ = null;
LocalDateTime latestDateTime = LocalDateTime.MIN;
for (Map<String, Object> record : records) {
String lksj = (String) record.get("lksj");
LocalDateTime dateTime = LocalDateTime.parse(lksj, formatter);
if (latestLKSJ == null || dateTime.isAfter(latestDateTime)) {
latestLKSJ = lksj;
latestDateTime = dateTime;
} }
} String latestLKSJ = null;
if (earliestJRSJ != null && latestLKSJ != null) { LocalDateTime latestDateTime = LocalDateTime.MIN;
Duration duration = Duration.between(earliestDateTime, latestDateTime); for (Map<String, Object> record : records) {
if (duration.toHours() >= 3) { String lksj = (String) record.get("lksj");
continue; LocalDateTime dateTime = LocalDateTime.parse(lksj, formatter);
if (latestLKSJ == null || dateTime.isAfter(latestDateTime)) {
latestLKSJ = lksj;
latestDateTime = dateTime;
}
} }
Map<String, Object> newRecord = new HashMap<>(); if (earliestJRSJ != null && latestLKSJ != null) {
newRecord.put("ajbh", ajbh); Duration duration = Duration.between(earliestDateTime, latestDateTime);
newRecord.put("jrsj", earliestJRSJ); if (duration.toHours() >= 3) {
newRecord.put("lksj", latestLKSJ); continue;
for (String key : records.get(0).keySet()) { }
if (!key.equals("jrsj") && !key.equals("lksj")) { Map<String, Object> newRecord = new HashMap<>();
newRecord.put(key, records.get(0).get(key)); 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()); System.out.println("模型26筛选后的alldata数量:" + allData.size());

Loading…
Cancel
Save