9
9
import java .util .ArrayList ;
10
10
import java .util .Date ;
11
11
import java .util .HashMap ;
12
+ import java .util .HashSet ;
12
13
import java .util .List ;
13
14
import java .util .Map ;
14
15
import java .util .Map .Entry ;
16
+ import java .util .function .BiConsumer ;
17
+ import java .util .function .Consumer ;
15
18
import java .util .function .Function ;
16
19
17
20
import org .slf4j .Logger ;
@@ -174,6 +177,10 @@ public static void pushRecords(EntityManager em, String stationType, DataMapDto<
174
177
throw new JPAException (String .format ("Provenance with UUID %s not found" , dataMap .getProvenance ()));
175
178
}
176
179
log .setProvenance (provenance );
180
+
181
+ var skippedDataTypes = new HashSet <String >();
182
+ int skippedCount = 0 ;
183
+
177
184
for (Entry <String , DataMapDto <RecordDtoImpl >> stationEntry : dataMap .getBranch ().entrySet ()) {
178
185
Station station = Station .findStation (em , stationType , stationEntry .getKey ());
179
186
if (station == null ) {
@@ -245,7 +252,6 @@ public static void pushRecords(EntityManager em, String stationType, DataMapDto<
245
252
}
246
253
}
247
254
248
- int skippedRecs = 0 ;
249
255
for (Period period : periods .values ()) {
250
256
period .number .updateLatest (em , (newest ) -> {
251
257
return new Measurement (station , type , ((Number ) newest .getValue ()).doubleValue (),
@@ -262,13 +268,8 @@ public static void pushRecords(EntityManager em, String stationType, DataMapDto<
262
268
period .period );
263
269
});
264
270
265
- skippedRecs = skippedRecs + period .skippedRecs ;
266
- }
267
-
268
- if (skippedRecs > 0 ) {
269
- log .warn (String .format ("Skipped %d records due to timestamp for type: [%s, %s, %s]" ,
270
- skippedRecs ,
271
- station .stationtype , station .stationcode , type .getCname ()));
271
+ skippedDataTypes .add (type .getCname ());
272
+ skippedCount += period .skippedCount ;
272
273
}
273
274
274
275
em .getTransaction ().commit ();
@@ -283,6 +284,12 @@ public static void pushRecords(EntityManager em, String stationType, DataMapDto<
283
284
}
284
285
}
285
286
}
287
+
288
+ if (skippedCount > 0 ) {
289
+ log .warn (String .format ("Skipped %d records due to timestamp for type: [%s, (%s)]" ,
290
+ skippedCount ,
291
+ stationType , String .join (", " , skippedDataTypes )));
292
+ }
286
293
} catch (Exception e ) {
287
294
if (em .getTransaction ().isActive ())
288
295
em .getTransaction ().rollback ();
@@ -303,7 +310,7 @@ private static class Period {
303
310
private DataType type ;
304
311
private Integer period ;
305
312
private Provenance provenance ;
306
- public int skippedRecs = 0 ;
313
+ public int skippedCount = 0 ;
307
314
308
315
private class TimeSeries {
309
316
private MeasurementAbstract latest ;
@@ -332,7 +339,7 @@ public void addHistory(EntityManager em, Log log, SimpleRecordDto dto, Measureme
332
339
} else {
333
340
LOG .debug (String .format ("Skipping record due to timestamp: [%s, %s, %s, %d, %d]" ,
334
341
station .stationtype , station .stationcode , type .getCname (), period , dto .getTimestamp ()));
335
- skippedRecs ++;
342
+ skippedCount ++;
336
343
}
337
344
}
338
345
0 commit comments