From 43c8a44f5651c52edb1cc823bbb120881f732e36 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期一, 31 八月 2026 23:36:02 +0800
Subject: [PATCH] 实现测试工步设置与工步汇总
---
ruoyi-device/src/main/java/com/ruoyi/device/bts/BtsDevelopmentSimulator.java | 32 ++++++++++++++++++++++----------
1 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/ruoyi-device/src/main/java/com/ruoyi/device/bts/BtsDevelopmentSimulator.java b/ruoyi-device/src/main/java/com/ruoyi/device/bts/BtsDevelopmentSimulator.java
index 2c583fa..7e44d6f 100644
--- a/ruoyi-device/src/main/java/com/ruoyi/device/bts/BtsDevelopmentSimulator.java
+++ b/ruoyi-device/src/main/java/com/ruoyi/device/bts/BtsDevelopmentSimulator.java
@@ -417,10 +417,14 @@
return grouped.entrySet().stream().map(entry -> {
BtsCycleRecord calculated = entry.getValue().finish();
BtsExcelFixture.CycleSummary expected = BtsExcelFixture.cycle(entry.getKey());
- if (expected == null || entry.getValue().count < expected.recordCount()) return calculated;
- return new BtsCycleRecord(calculated.cycleNo(), expected.recordCount(), calculated.startedAt(),
+ String recordNo = "CYCLE-" + deviceId + "-" + channelId + "-" + entry.getKey();
+ if (expected == null || entry.getValue().count < expected.recordCount())
+ return new BtsCycleRecord(recordNo, calculated.cycleNo(), calculated.recordCount(), calculated.startedAt(), calculated.endedAt(),
+ calculated.chargeCapacityAh(), calculated.dischargeCapacityAh(), calculated.chargeEnergyWh(), calculated.dischargeEnergyWh(), calculated.efficiency());
+ return new BtsCycleRecord(recordNo, calculated.cycleNo(), expected.recordCount(), calculated.startedAt(),
calculated.endedAt(), expected.chargeCapacityAh(), expected.dischargeCapacityAh(),
- expected.chargeEnergyWh(), expected.dischargeEnergyWh());
+ expected.chargeEnergyWh(), expected.dischargeEnergyWh(),
+ efficiency(expected.chargeCapacityAh(), expected.dischargeCapacityAh()));
}).toList();
}
@@ -845,10 +849,17 @@
}
public record BtsStepRecord(int cycleNo, int stepNo, String stepName, String stepType, long recordCount,
- Instant startedAt, Instant endedAt, double capacityAh, double energyWh) { }
+ Instant startedAt, Instant endedAt, double durationSeconds, double capacityAh, double energyWh,
+ double startVoltageV, double endVoltageV, double chargePeakVoltageV, double dischargeValleyVoltageV) { }
- public record BtsCycleRecord(int cycleNo, long recordCount, Instant startedAt, Instant endedAt,
- double chargeCapacityAh, double dischargeCapacityAh, double chargeEnergyWh, double dischargeEnergyWh) { }
+ public record BtsCycleRecord(String recordNo, int cycleNo, long recordCount, Instant startedAt, Instant endedAt,
+ double chargeCapacityAh, double dischargeCapacityAh, double chargeEnergyWh, double dischargeEnergyWh,
+ double efficiency) { }
+
+ private static double efficiency(double chargeCapacityAh, double dischargeCapacityAh)
+ {
+ return chargeCapacityAh > 0d ? dischargeCapacityAh / chargeCapacityAh * 100d : 0d;
+ }
public record PlaybackSnapshot(int deviceId, int channelId, BtsPlaybackState playback,
List<BtsHistoryRecord> records, List<BtsStepRecord> steps, List<BtsCycleRecord> cycles) { }
@@ -856,10 +867,11 @@
private static final class BtsStepAccumulator
{
private final int cycle; private final int step; private final String name; private final String type;
- private long count; private Instant first; private Instant last; private double capacity; private double energy;
+ private long count; private Instant first; private Instant last; private double duration; private double capacity; private double energy;
+ private double startVoltage; private double endVoltage; private double chargePeak = Double.NEGATIVE_INFINITY; private double dischargeValley = Double.POSITIVE_INFINITY;
BtsStepAccumulator(BtsHistoryRecord first) { cycle = first.cycleNo(); step = first.stepNo(); name = first.stepName(); type = first.stepType(); }
- void add(BtsHistoryRecord item) { count++; if (first == null) first = item.deviceTime(); last = item.deviceTime(); capacity = item.capacityAh(); energy = item.energyWh(); }
- BtsStepRecord finish() { return new BtsStepRecord(cycle, step, name, type, count, first, last, capacity, energy); }
+ void add(BtsHistoryRecord item) { count++; if (first == null) { first = item.deviceTime(); startVoltage = item.voltageV(); } last = item.deviceTime(); endVoltage = item.voltageV(); duration = first == null ? 0 : Math.max(0, java.time.Duration.between(first, last).toMillis() / 1000d); capacity = item.capacityAh(); energy = item.energyWh(); if (item.currentA() >= 0) chargePeak = Math.max(chargePeak, item.voltageV()); else dischargeValley = Math.min(dischargeValley, item.voltageV()); }
+ BtsStepRecord finish() { return new BtsStepRecord(cycle, step, name, type, count, first, last, duration, capacity, energy, startVoltage, endVoltage, chargePeak == Double.NEGATIVE_INFINITY ? 0 : chargePeak, dischargeValley == Double.POSITIVE_INFINITY ? 0 : dischargeValley); }
}
private static final class BtsCycleAccumulator
@@ -869,7 +881,7 @@
private double chargeEnergy; private double dischargeEnergy;
BtsCycleAccumulator(BtsHistoryRecord first) { cycle = first.cycleNo(); }
void add(BtsHistoryRecord item) { count++; if (first == null) first = item.deviceTime(); last = item.deviceTime(); maximumCapacity = Math.max(maximumCapacity, item.capacityAh()); minimumCapacity = Math.min(minimumCapacity, item.capacityAh()); if (item.currentA() >= 0) chargeEnergy = Math.max(chargeEnergy, item.energyWh()); else dischargeEnergy = Math.max(dischargeEnergy, Math.abs(item.energyWh())); }
- BtsCycleRecord finish() { return new BtsCycleRecord(cycle, count, first, last, Math.max(0d, maximumCapacity), Math.max(0d, maximumCapacity - minimumCapacity), chargeEnergy, dischargeEnergy); }
+ BtsCycleRecord finish() { double charge = Math.max(0d, maximumCapacity); double discharge = Math.max(0d, maximumCapacity - minimumCapacity); return new BtsCycleRecord(cycle, count, first, last, charge, discharge, chargeEnergy, dischargeEnergy, efficiency(charge, discharge)); }
}
private java.util.Set<String> requestedChannels(String request)
--
Gitblit v1.7.1