Skip to content

Commit 24fbb57

Browse files
authored
Merge pull request #1515 from steve-community/1514-transaction-detail-page-should-only-show-relevant-meter-values
transaction detail page shows only energy meter values (#1514)
2 parents 8a61977 + e023def commit 24fbb57

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main/java/de/rwth/idsg/steve/repository/impl/TransactionRepositoryImpl.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
import de.rwth.idsg.steve.repository.dto.Transaction;
2424
import de.rwth.idsg.steve.repository.dto.TransactionDetails;
2525
import de.rwth.idsg.steve.utils.DateTimeUtils;
26+
import de.rwth.idsg.steve.utils.TransactionStopServiceHelper;
2627
import de.rwth.idsg.steve.web.dto.TransactionQueryForm;
2728
import jooq.steve.db.enums.TransactionStopEventActor;
2829
import jooq.steve.db.tables.records.ConnectorMeterValueRecord;
2930
import jooq.steve.db.tables.records.TransactionStartRecord;
31+
import ocpp.cs._2015._10.UnitOfMeasure;
3032
import org.joda.time.DateTime;
3133
import org.jooq.Condition;
3234
import org.jooq.DSLContext;
@@ -149,11 +151,16 @@ public TransactionDetails getDetails(int transactionPk) {
149151
timestampCondition = CONNECTOR_METER_VALUE.VALUE_TIMESTAMP.between(startTimestamp, stopTimestamp);
150152
}
151153

154+
// https://github.com/steve-community/steve/issues/1514
155+
Condition unitCondition = CONNECTOR_METER_VALUE.UNIT.isNull()
156+
.or(CONNECTOR_METER_VALUE.UNIT.in("", UnitOfMeasure.WH.value(), UnitOfMeasure.K_WH.value()));
157+
152158
// Case 1: Ideal and most accurate case. Station sends meter values with transaction id set.
153159
//
154160
SelectQuery<ConnectorMeterValueRecord> transactionQuery =
155161
ctx.selectFrom(CONNECTOR_METER_VALUE)
156162
.where(CONNECTOR_METER_VALUE.TRANSACTION_PK.eq(transactionPk))
163+
.and(unitCondition)
157164
.getQuery();
158165

159166
// Case 2: Fall back to filtering according to time windows
@@ -165,6 +172,7 @@ public TransactionDetails getDetails(int transactionPk) {
165172
.where(CONNECTOR.CHARGE_BOX_ID.eq(chargeBoxId))
166173
.and(CONNECTOR.CONNECTOR_ID.eq(connectorId))))
167174
.and(timestampCondition)
175+
.and(unitCondition)
168176
.getQuery();
169177

170178
// Actually, either case 1 applies or 2. If we retrieved values using 1, case 2 is should not be
@@ -199,7 +207,10 @@ public TransactionDetails getDetails(int transactionPk) {
199207
.location(r.value6())
200208
.unit(r.value7())
201209
.phase(r.value8())
202-
.build());
210+
.build())
211+
.stream()
212+
.filter(TransactionStopServiceHelper::isEnergyValue)
213+
.toList();
203214

204215
return new TransactionDetails(new TransactionMapper().map(transaction), values, nextTx);
205216
}

0 commit comments

Comments
 (0)