| | |
| | | assertEquals("dev-sim:22:1:1:1", row.getSourceIdentity()); |
| | | assertEquals("cabinet:7:collector:10", row.getSourceRecordId()); |
| | | assertEquals(Date.from(Instant.parse("2026-09-02T04:00:30Z")), row.getCabinetDeviceTimeUtc()); |
| | | assertEquals(3752L, com.alibaba.fastjson2.JSON.parseObject(row.getExtensionMeasurementsJson()).getLong("relativeTimeSeconds")); |
| | | assertEquals(Date.from(Instant.parse("2026-09-02T04:00:40Z")), row.getCollectorDeviceTimeUtc()); |
| | | assertEquals(new BigDecimal("25.100"), row.getTemperature()); |
| | | assertEquals(new BigDecimal("1.620"), row.getPositivePotential()); |
| | |
| | | ArgumentCaptor<TTestRealtimeRecord> saved = ArgumentCaptor.forClass(TTestRealtimeRecord.class); |
| | | verify(fixture.mapper).insertRealtimeRecord(saved.capture()); |
| | | assertNull(saved.getValue().getCabinetSequenceId()); |
| | | assertNull(com.alibaba.fastjson2.JSON.parseObject(saved.getValue().getExtensionMeasurementsJson()).get("relativeTimeSeconds")); |
| | | assertNull(saved.getValue().getCabinetDevtype()); |
| | | assertNull(saved.getValue().getCabinetAdapterTimezoneId()); |
| | | assertNull(saved.getValue().getVoltageV()); |
| | |
| | | Instant started = Instant.parse("2026-09-02T04:00:10Z"); |
| | | Instant ended = Instant.parse("2026-09-02T04:00:50Z"); |
| | | when(fixture.simulator.stepRecords(any(ChannelIdentity.class))).thenReturn(List.of(new StepRecord( |
| | | "STEP-1", 1, 2, "恒流充电", "cc", started, ended, 3.4, 2.5, 8.4, ended.toString(), "UTC", ended, java.util.Map.of()))); |
| | | "STEP-1", 1, 2, "恒流充电", "cc", started, ended, 3.4, 2.5, 8.4, ended.toString(), "UTC", ended, |
| | | java.util.Map.of("stepDuration", new BigDecimal("40.125"), "startVoltage", new BigDecimal("3.1"), |
| | | "chargeMedianVoltage", new BigDecimal("3.25"), "dischargeMedianVoltage", BigDecimal.ZERO)))); |
| | | when(fixture.simulator.cycleRecords(any(ChannelIdentity.class))).thenReturn(List.of(new CycleRecord( |
| | | "CYCLE-1-1-1", 1, started, ended, 2.5, 2.4, 8.4, 8.0, 96, ended.toString(), "UTC", ended))); |
| | | when(fixture.mapper.insertStepRecord(any())).thenReturn(1); |
| | |
| | | verify(fixture.mapper).insertStepRecord(step.capture()); |
| | | verify(fixture.mapper).insertCycleRecord(cycle.capture()); |
| | | assertEquals("record:STEP-1", step.getValue().getDedupeKey()); |
| | | var metrics = com.alibaba.fastjson2.JSON.parseObject(step.getValue().getExtensionMeasurementsJson()); |
| | | assertEquals(new BigDecimal("40.125"), metrics.getBigDecimal("stepDuration")); |
| | | assertEquals(new BigDecimal("3.1"), metrics.getBigDecimal("startVoltage")); |
| | | assertEquals(new BigDecimal("3.25"), metrics.getBigDecimal("chargeMedianVoltage")); |
| | | assertEquals(BigDecimal.ZERO, metrics.getBigDecimal("dischargeMedianVoltage")); |
| | | assertEquals("CYCLE-1-1-1", cycle.getValue().getSourceRecordId()); |
| | | assertEquals("record:CYCLE-1-1-1", cycle.getValue().getDedupeKey()); |
| | | assertEquals(Date.from(ended), step.getValue().getServerReceivedAtUtc()); |
| | |
| | | { |
| | | Instant deviceTime = Instant.parse("2026-09-02T04:00:30Z"); |
| | | return new CabinetRealtime(7L, deviceTime, 1, 3.2, 2.5, 8.4, |
| | | 1, 2, "恒流充电", "cc", Instant.parse("2026-09-02T04:00:35Z"), "2026-09-02 12:00:30.000", "Asia/Hong_Kong"); |
| | | 1, 2, "恒流充电", "cc", Instant.parse("2026-09-02T04:00:35Z"), "2026-09-02 12:00:30.000", "Asia/Hong_Kong", 3752L); |
| | | } |
| | | |
| | | private static CollectorMeasurement collector(String channel, long sequenceId, String metric, |