Alte Klassen entfernt

This commit is contained in:
Tobias Peper 2025-03-14 22:38:22 +01:00
parent a8feeef1c1
commit b7017f5087
9 changed files with 109 additions and 425 deletions

View File

@ -1,9 +0,0 @@
package info.peper.vz.rest;
import org.springframework.data.jpa.repository.JpaRepository;
import info.peper.vz.rest.bo.db.Aggregate;
interface AggregateRepository extends JpaRepository<Aggregate, Aggregate.CompositeKey> {
}

View File

@ -13,7 +13,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import info.peper.vz.rest.bo.db.Aggregate2;
import info.peper.vz.rest.bo.db.Aggregate;
import info.peper.vz.rest.bo.db.Data;
public final class Calculator {
@ -170,14 +170,14 @@ public final class Calculator {
}
public static List<Aggregate2> processHouseMulti(final int houseId,
public static List<Aggregate> processHouseMulti(final int houseId,
final long startTimestamp,
final long endTimestamp,
final long interval,
final int[] channelIdsSolar,
final int[] channelIdsMeter,
final Connection con) throws SQLException {
final List<Aggregate2> result = new LinkedList<Aggregate2>();
final List<Aggregate> result = new LinkedList<Aggregate>();
final PreparedStatement[] stmtSolar = new PreparedStatement[channelIdsSolar.length];
final PreparedStatement[] stmtMeter = new PreparedStatement[channelIdsMeter.length];
@ -274,7 +274,7 @@ public final class Calculator {
System.out.println(" " + intervalProduced + " / " + intervalObtained + " / " + intervalInjected);
result.add(new Aggregate2(houseId, intervalStartTimestamp, intervalEndTimestamp, intervalProduced, intervalObtained, intervalInjected));
result.add(new Aggregate(houseId, intervalStartTimestamp, intervalEndTimestamp, intervalProduced, intervalObtained, intervalInjected));
intervalStartTimestamp += interval;
intervalEndTimestamp += interval;

View File

@ -0,0 +1,19 @@
package info.peper.vz.rest;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoField;
import java.time.temporal.Temporal;
public class DurationTestMain {
public static void main(String[] args) {
final Duration duration = Duration.parse("P3D");
final Instant now = Instant.now();
final Temporal temporal = duration.subtractFrom(now);
System.out.println(temporal.getLong(ChronoField.INSTANT_SECONDS));
}
}

View File

@ -16,7 +16,7 @@ import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAccessor;
import java.util.List;
import info.peper.vz.rest.bo.db.Aggregate2;
import info.peper.vz.rest.bo.db.Aggregate;
public class FillAggregateTableMain {
@ -36,7 +36,7 @@ public class FillAggregateTableMain {
final long startTimeStamp = getTimestamp("2022-05-20T09:00:00");
final long finalEndTimeStamp = getTimestamp("2025-03-09T15:00:00");
final List<Aggregate2> aggregates = Calculator.processHouseMulti(
final List<Aggregate> aggregates = Calculator.processHouseMulti(
1,
startTimeStamp,
finalEndTimeStamp,
@ -51,7 +51,7 @@ public class FillAggregateTableMain {
final long startTimeStamp = getTimestamp("2024-06-23T17:00:00");
final long finalEndTimeStamp = getTimestamp("2025-03-09T15:00:00");
final List<Aggregate2> aggregates = Calculator.processHouseMulti(
final List<Aggregate> aggregates = Calculator.processHouseMulti(
2,
startTimeStamp,
finalEndTimeStamp,
@ -62,11 +62,11 @@ public class FillAggregateTableMain {
saveValues(con, aggregates, 2);
}
private static void saveValues(final Connection con, final List<Aggregate2> aggregates, final int houseId) throws SQLException {
private static void saveValues(final Connection con, final List<Aggregate> aggregates, final int houseId) throws SQLException {
System.out.println("Saving entries... : " + aggregates.size());
try (final PreparedStatement stmt = con.prepareStatement("INSERT INTO tobias_aggregate2 (house_id, timestamp_start, timestamp_end, produced_energy, obtained_energy, injected_energy) VALUES (?, ?, ?, ?, ?, ?)")) {
int i = 0;
for (Aggregate2 ats : aggregates) {
for (Aggregate ats : aggregates) {
stmt.setInt(1, houseId);
stmt.setLong(2, ats.getTimestampStart());
stmt.setLong(3, ats.getTimestampEnd());

View File

@ -3,7 +3,9 @@ package info.peper.vz.rest;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.LinkedList;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoField;
import java.util.List;
import java.util.Locale;
@ -16,10 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import info.peper.vz.rest.bo.Sums;
import info.peper.vz.rest.bo.Sums2;
import info.peper.vz.rest.bo.db.Aggregate;
import info.peper.vz.rest.bo.db.Aggregate2;
import info.peper.vz.rest.bo.db.Data;
import info.peper.vz.rest.bo.db.EnergyPrice;
@RestController
@ -27,70 +26,25 @@ class VzRestController {
private static final Logger log = LoggerFactory.getLogger(VzRestController.class);
private final AggregateRepository aggregateRep;
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private JdbcTemplate jdbcTemplateWithLimitedRows;
public VzRestController(final AggregateRepository aggregateRep) {
this.aggregateRep = aggregateRep;
public VzRestController() {
}
@GetMapping("/data/sums")
Sums getData(@RequestParam("timestampStart")final long timestampStart,
@RequestParam("timestampEnd")final long timestampEnd,
@RequestParam("channelId")final int channelId) {
final List<Aggregate> aggregates = jdbcTemplate.query(
"SELECT MIN(timestamp_start) AS min_timestamp_start, MAX(timestamp_end) AS max_timestamp_end, SUM(sum_positive) AS sum_positive, SUM(sum_negative) AS sum_negative FROM volkszaehler.tobias_aggregate WHERE channel_id=? AND timestamp_start>=? AND timestamp_end<=?;",
(rs, rowNum) -> new Aggregate(channelId, rs.getLong("min_timestamp_start"), rs.getLong("max_timestamp_end"),
rs.getLong("sum_positive"), rs.getLong("sum_negative")),
channelId ,timestampStart, timestampEnd);
if (aggregates.size() != 1) {
throw new RuntimeException("Interal error in SQL query.");
}
final Aggregate aggregate = aggregates.iterator().next();
double sumPos = aggregate.getSumPositive();
double sumNeg = aggregate.getSumNegative();
log.debug("sumPos: " + sumPos + " / sumNeg: " + sumNeg);
log.debug("timestampStart: " + timestampStart);
log.debug("timestampEnd: " + timestampEnd);
log.debug("firstTimestamp: " + aggregate.getTimestampStart());
log.debug("lastTimestamp: " + aggregate.getTimestampEnd());
if (timestampStart < aggregate.getTimestampStart() ) {
final Sums startSums = getSums(timestampStart, aggregate.getTimestampStart(), channelId);
sumPos += startSums.getSumPositive();
sumNeg += startSums.getSumNegative();
log.debug("Start: " + startSums.toString());
}
if (timestampEnd > aggregate.getTimestampEnd()) {
final Sums endSums = getSums(aggregate.getTimestampEnd(), timestampEnd, channelId);
sumPos += endSums.getSumPositive();
sumNeg += endSums.getSumNegative();
log.debug("End: " + endSums.toString());
}
sumPos /= 3600;
sumNeg /= 3600;
return new Sums(Math.round(sumPos), Math.round(sumNeg));
}
@GetMapping("/data/sums2")
Sums2 getData2(@RequestParam("timestampStart")final long timestampStart,
Sums getData2(@RequestParam("timestampStart")final long timestampStart,
@RequestParam("timestampEnd")final long timestampEnd,
@RequestParam("houseId")final int houseId) {
final List<Aggregate2> aggregates = jdbcTemplate.query(
final List<Aggregate> aggregates = jdbcTemplate.query(
"SELECT MIN(timestamp_start) AS min_ts_start, MAX(timestamp_end) AS max_ts_end, SUM(produced_energy)/3600 AS sum_produced, SUM(obtained_energy)/3600 AS sum_obtained, SUM(injected_energy)/3600 AS sum_injected FROM volkszaehler.tobias_aggregate2 WHERE house_id=? AND timestamp_start>=? AND timestamp_end<=?;",
(rs, rowNum) -> new Aggregate2(houseId, rs.getLong("min_ts_start"), rs.getLong("max_ts_end"),
(rs, rowNum) -> new Aggregate(houseId, rs.getLong("min_ts_start"), rs.getLong("max_ts_end"),
rs.getLong("sum_produced"), rs.getLong("sum_obtained"), rs.getLong("sum_injected")),
houseId ,timestampStart, timestampEnd);
if (aggregates.size() != 1) {
throw new RuntimeException("Interal error in SQL query.");
}
final Aggregate2 aggregate = aggregates.iterator().next();
final Aggregate aggregate = aggregates.iterator().next();
log.debug("energyProduced: " + aggregate.getProducedEnergy() + " / energyObtained: " + aggregate.getObtainedEnergy() + " / injectedEnergy: " + aggregate.getInjectedEnergy());
log.debug("timestampStart: " + timestampStart);
@ -98,70 +52,12 @@ class VzRestController {
log.debug("firstTimestamp: " + aggregate.getTimestampStart());
log.debug("lastTimestamp: " + aggregate.getTimestampEnd());
return new Sums2(
return new Sums(
Math.round(aggregate.getInjectedEnergy()),
Math.round(aggregate.getObtainedEnergy()),
Math.round(aggregate.getProducedEnergy()));
}
@GetMapping("/data/sumsWithFactor")
Sums getDataWithFactor(@RequestParam("timestampStart")final long timestampStart,
@RequestParam("timestampEnd")final long timestampEnd,
@RequestParam("channelId")final int channelId) {
// this.jdbcTemplateWithLimitedRows.setMaxRows(1000);
final List<Aggregate> aggregates = jdbcTemplate.query(
"SELECT * FROM volkszaehler.tobias_aggregate WHERE channel_id=? AND timestamp_start>=? AND timestamp_end<=? ORDER BY timestamp_start;",
(rs, rowNum) -> new Aggregate(rs.getInt("channel_id"), rs.getLong("timestamp_start"), rs.getLong("timestamp_end"),
rs.getLong("sum_positive"), rs.getLong("sum_negative")),
channelId ,timestampStart, timestampEnd);
long firstTimestamp = Long.MAX_VALUE;
long lastTimestamp = Long.MIN_VALUE;
double sumPos = 0;
double sumNeg = 0;
log.debug("Number of aggregates: " + aggregates.size());
for (Aggregate ag : aggregates) {
if (ag.getTimestampStart() < firstTimestamp) {
firstTimestamp = ag.getTimestampStart();
}
if (ag.getTimestampEnd() > lastTimestamp) {
lastTimestamp = ag.getTimestampEnd();
}
sumPos += ag.getSumPositive();
sumNeg += ag.getSumNegative();
}
log.debug("sumPos: " + sumPos + " / sumNeg: " + sumNeg);
log.debug("timestampStart: " + timestampStart);
log.debug("timestampEnd: " + timestampEnd);
log.debug("firstTimestamp: " + firstTimestamp);
log.debug("lastTimestamp: " + lastTimestamp);
if (timestampStart < firstTimestamp ) {
final Sums startSums = getSums(timestampStart, firstTimestamp, channelId);
sumPos += startSums.getSumPositive();
sumNeg += startSums.getSumNegative();
log.debug("Start: " + startSums.toString());
}
if (timestampEnd > lastTimestamp) {
final Sums endSums = getSums(lastTimestamp, timestampEnd, channelId);
sumPos += endSums.getSumPositive();
sumNeg += endSums.getSumNegative();
log.debug("End: " + endSums.toString());
}
sumPos /= 3600;
sumNeg /= 3600;
return new Sums(Math.round(sumPos), Math.round(sumNeg));
}
@GetMapping("/data/sumsWithoutAggregate")
Sums getDataWithoutAggregate(@RequestParam("timestampStart")final long timestampStart,
@RequestParam("timestampEnd")final long timestampEnd,
@RequestParam("channelId")final int channelId) {
final Sums startSums = getSums(timestampStart, timestampEnd, channelId);
final Sums returnSums = new Sums(Math.round((double)startSums.getSumPositive()/3600), Math.round((double)startSums.getSumNegative()/3600));
return returnSums;
}
@GetMapping("/data/prices")
List<EnergyPrice> getPrices(@RequestParam("timestampStart")final long timestampStart,
@RequestParam("timestampEnd")final long timestampEnd,
@ -175,55 +71,23 @@ class VzRestController {
}
@GetMapping("/data/summary")
String getSummary(@RequestParam("timestampStart")final long timestampStart,
@RequestParam("timestampEnd")final long timestampEnd,
@RequestParam("houseId")final int houseId,
@RequestParam("channelIdMeter")final int channelIdMeter,
@RequestParam("channelIdSolar")final int channelIdSolar) {
final NumberFormat formatCurrency = new DecimalFormat("#,##0.00", new DecimalFormatSymbols(Locale.GERMAN));
final NumberFormat formatPercent = new DecimalFormat("#,##0.00", new DecimalFormatSymbols(Locale.GERMAN));
final NumberFormat formatEnergy = new DecimalFormat("#,##0", new DecimalFormatSymbols(Locale.GERMAN));
final List<EnergyPrice> prices = this.getPrices(timestampStart, timestampEnd, houseId);
final List<Sums> partsMeter = new LinkedList<Sums>();
final List<Sums> partsSolar = new LinkedList<Sums>();
float savedMoney = 0;
long totalSolar = 0;
long totalObtained = 0;
long totalInjected = 0;
for (EnergyPrice price : prices) {
final long tsStart = Math.max(price.getTimestampStart(), timestampStart);
final long tsEnd = Math.min(price.getTimestampEnd(), timestampEnd);
final Sums sumsMeter = getData(tsStart, tsEnd, channelIdMeter);
final Sums sumsSolar = getData(tsStart, tsEnd, channelIdSolar);
savedMoney += (float)(sumsSolar.getSumPositive() - sumsMeter.getSumNegative())/1000000 * price.getPrice();
totalSolar += sumsSolar.getSumPositive();
totalObtained += sumsMeter.getSumPositive();
totalInjected += sumsMeter.getSumNegative();
partsMeter.add(sumsMeter);
partsSolar.add(sumsSolar);
}
final StringBuilder sb = new StringBuilder();
sb.append("Erzeugter Strom von der Photovoltaik: " + formatEnergy.format(totalSolar/1000000) + " kWh\n");
sb.append("Eingespeister Strom von der Photovoltaik: " + formatEnergy.format(totalInjected/1000000) + " kWh\n");
sb.append("Genutzter Strom von der Photovoltaik: " + formatEnergy.format((totalSolar-totalInjected)/1000000) + " kWh (=");
sb.append(formatPercent.format((float)(totalSolar-totalInjected)/(float)totalSolar*100) + " %)\n");
sb.append("Bezogener Strom: " + formatEnergy.format(totalObtained/1000000) + " kWh\n");
sb.append("Autakie: " + formatPercent.format((float)(totalSolar-totalInjected)/(float)(totalObtained+totalSolar-totalInjected)*100) + " %\n");
sb.append("Eingespartes Geld: " + formatCurrency.format(savedMoney) + "\n");
return sb.toString();
}
@GetMapping("/data/summary2")
String getSummary2(@RequestParam(name = "timestampStart", defaultValue = "-1")long timestampStart,
@RequestParam(name = "timestampEnd", defaultValue = "-1")long timestampEnd,
@RequestParam(name = "duration", defaultValue = "")final String duration,
@RequestParam("houseId")final int houseId) {
if (!"".equals(duration)) {
final Duration dur = Duration.parse(duration);
timestampEnd = (Instant.now().toEpochMilli()/Calculator.INTERVAL)*Calculator.INTERVAL;
timestampStart = ((dur.subtractFrom(Instant.now()).getLong(ChronoField.INSTANT_SECONDS)*1000)/Calculator.INTERVAL)*Calculator.INTERVAL;
} else {
if (timestampStart == -1) {
timestampStart = jdbcTemplate.queryForObject("SELECT MIN(timestamp_start) AS ts FROM tobias_aggregate2 WHERE house_id=?;", Long.class, houseId);
}
if (timestampEnd == -1) {
timestampEnd = jdbcTemplate.queryForObject("SELECT MAX(timestamp_end) AS ts FROM tobias_aggregate2 WHERE house_id=?;", Long.class, houseId);
}
}
final NumberFormat formatCurrency = new DecimalFormat("#,##0.00", new DecimalFormatSymbols(Locale.GERMAN));
final NumberFormat formatPercent = new DecimalFormat("#,##0.00", new DecimalFormatSymbols(Locale.GERMAN));
@ -237,7 +101,7 @@ class VzRestController {
for (EnergyPrice price : prices) {
final long tsStart = Math.max(price.getTimestampStart(), timestampStart);
final long tsEnd = Math.min(price.getTimestampEnd(), timestampEnd);
final Sums2 sums = getData2(tsStart, tsEnd, houseId);
final Sums sums = getData2(tsStart, tsEnd, houseId);
savedMoney += (float)(sums.getProduced() - sums.getInjected())/1000000 * price.getPrice();
totalProduced += sums.getProduced();
totalObtained += sums.getObtained();
@ -254,33 +118,4 @@ class VzRestController {
return sb.toString();
}
private Sums getSums(final long startTimestamp,
final long endTimestamp,
final int channelId) {
long currentTimestamp = startTimestamp;
double wattMillisecondsPos = 0;
double wattMillisecondsNeg = 0;
while (currentTimestamp < endTimestamp) {
final List<Data> datas = jdbcTemplateWithLimitedRows.query("SELECT * FROM volkszaehler.data WHERE channel_id=? AND timestamp>? ORDER BY timestamp;",
(rs, rowNum) -> new Data(rs.getInt("channel_id"), rs.getLong("timestamp"), rs.getDouble("value")),
channelId, currentTimestamp);
for (Data data : datas) {
if (currentTimestamp <= endTimestamp)
{
final long tsDiff = Math.min(data.getTimestamp() - currentTimestamp, endTimestamp - currentTimestamp);
currentTimestamp = data.getTimestamp();
if (data.getValue() > 1.0) {
wattMillisecondsPos += (data.getValue() * tsDiff);
}
if (data.getValue() < 0.0) {
wattMillisecondsNeg += (-data.getValue() * tsDiff);
}
}
}
}
return new Sums(Math.round(wattMillisecondsPos), Math.round(wattMillisecondsNeg));
}
}

View File

@ -1,33 +1,34 @@
package info.peper.vz.rest.bo;
import java.io.Serializable;
import java.util.Objects;
public class Sums implements Serializable {
private static final long serialVersionUID = -1816023197422851264L;
private final long sumPositive;
private final long sumNegative;
public Sums(long sumPositive, long sumNegative) {
private final long injected;
private final long obtained;
private final long produced;
public Sums(long injected, long obtained, long produced) {
super();
this.sumPositive = sumPositive;
this.sumNegative = sumNegative;
this.injected = injected;
this.obtained = obtained;
this.produced = produced;
}
public long getSumPositive() {
return sumPositive;
public long getInjected() {
return injected;
}
public long getSumNegative() {
return sumNegative;
public long getObtained() {
return obtained;
}
@Override
public String toString() {
return "Sums [sumPositive=" + sumPositive + ", sumNegative=" + sumNegative + "]";
public long getProduced() {
return produced;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (sumNegative ^ (sumNegative >>> 32));
result = prime * result + (int) (sumPositive ^ (sumPositive >>> 32));
result = prime * result + (int) (injected ^ (injected >>> 32));
result = prime * result + (int) (obtained ^ (obtained >>> 32));
result = prime * result + (int) (produced ^ (produced >>> 32));
return result;
}
@Override
@ -39,12 +40,12 @@ public class Sums implements Serializable {
if (getClass() != obj.getClass())
return false;
Sums other = (Sums) obj;
if (sumNegative != other.sumNegative)
if (injected != other.injected)
return false;
if (sumPositive != other.sumPositive)
if (obtained != other.obtained)
return false;
if (produced != other.produced)
return false;
return true;
}
}

View File

@ -1,51 +0,0 @@
package info.peper.vz.rest.bo;
import java.io.Serializable;
public class Sums2 implements Serializable {
private static final long serialVersionUID = -1816023197422851264L;
private final long injected;
private final long obtained;
private final long produced;
public Sums2(long injected, long obtained, long produced) {
super();
this.injected = injected;
this.obtained = obtained;
this.produced = produced;
}
public long getInjected() {
return injected;
}
public long getObtained() {
return obtained;
}
public long getProduced() {
return produced;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (injected ^ (injected >>> 32));
result = prime * result + (int) (obtained ^ (obtained >>> 32));
result = prime * result + (int) (produced ^ (produced >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Sums2 other = (Sums2) obj;
if (injected != other.injected)
return false;
if (obtained != other.obtained)
return false;
if (produced != other.produced)
return false;
return true;
}
}

View File

@ -7,12 +7,12 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
@Entity(name = "tobias_aggregate")
@Entity(name = "tobias_aggregate2")
@IdClass(Aggregate.CompositeKey.class)
public class Aggregate {
public static class CompositeKey implements Serializable {
private static final long serialVersionUID = 3097284483123288289L;
private int channelId;
private int houseId;
private long timestampStart;
private long timestampEnd;
@ -20,7 +20,7 @@ public class Aggregate {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + channelId;
result = prime * result + houseId;
result = prime * result + (int) (timestampEnd ^ (timestampEnd >>> 32));
result = prime * result + (int) (timestampStart ^ (timestampStart >>> 32));
return result;
@ -34,7 +34,7 @@ public class Aggregate {
if (getClass() != obj.getClass())
return false;
CompositeKey other = (CompositeKey) obj;
if (channelId != other.channelId)
if (houseId != other.houseId)
return false;
if (timestampEnd != other.timestampEnd)
return false;
@ -48,33 +48,37 @@ public class Aggregate {
super();
}
public Aggregate(int channelId, long timestampStart, long timestampEnd, long sumPositive, long sumNegative) {
public Aggregate(int houseId, long timestampStart, long timestampEnd, long producedEnergy, long obtainedEnergy, long injectedEnergy) {
super();
this.channelId = channelId;
this.houseId = houseId;
this.timestampStart = timestampStart;
this.timestampEnd = timestampEnd;
this.sumPositive = sumPositive;
this.sumNegative = sumNegative;
this.producedEnergy = producedEnergy;
this.obtainedEnergy = obtainedEnergy;
this.injectedEnergy = injectedEnergy;
}
@Id
@Column(name="channel_id")
private int channelId;
@Column(name="house_id")
private int houseId;
@Id
@Column(name="timestamp_start")
private long timestampStart;
@Id
@Column(name="timestamp_end")
private long timestampEnd;
@Column(name="sum_positive")
private long sumPositive;
@Column(name="sum_negative")
private long sumNegative;
public int getChannelId() {
return channelId;
@Column(name="produced_energy")
private long producedEnergy;
@Column(name="obtained_energy")
private long obtainedEnergy;
@Column(name="injected_energy")
private long injectedEnergy;
public int getHouseId() {
return houseId;
}
public void setChannelId(int channelId) {
this.channelId = channelId;
public void setHouseId(int houseId) {
this.houseId = houseId;
}
public long getTimestampStart() {
@ -93,19 +97,28 @@ public class Aggregate {
this.timestampEnd = timestampEnd;
}
public long getSumPositive() {
return sumPositive;
public long getProducedEnergy() {
return producedEnergy;
}
public void setSumPositive(long sumPositive) {
this.sumPositive = sumPositive;
public void setProducedEnergy(long producedEnergy) {
this.producedEnergy = producedEnergy;
}
public long getSumNegative() {
return sumNegative;
public long getObtainedEnergy() {
return obtainedEnergy;
}
public void setSumNegative(long sumNegative) {
this.sumNegative = sumNegative;
public void setObtainedEnergy(long obtainedEnergy) {
this.obtainedEnergy = obtainedEnergy;
}
public long getInjectedEnergy() {
return injectedEnergy;
}
public void setInjectedEnergy(long injectedEnergy) {
this.injectedEnergy = injectedEnergy;
}
}

View File

@ -1,124 +0,0 @@
package info.peper.vz.rest.bo.db;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
@Entity(name = "tobias_aggregate2")
@IdClass(Aggregate2.CompositeKey.class)
public class Aggregate2 {
public static class CompositeKey implements Serializable {
private static final long serialVersionUID = 3097284483123288289L;
private int houseId;
private long timestampStart;
private long timestampEnd;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + houseId;
result = prime * result + (int) (timestampEnd ^ (timestampEnd >>> 32));
result = prime * result + (int) (timestampStart ^ (timestampStart >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CompositeKey other = (CompositeKey) obj;
if (houseId != other.houseId)
return false;
if (timestampEnd != other.timestampEnd)
return false;
if (timestampStart != other.timestampStart)
return false;
return true;
}
}
Aggregate2() {
super();
}
public Aggregate2(int houseId, long timestampStart, long timestampEnd, long producedEnergy, long obtainedEnergy, long injectedEnergy) {
super();
this.houseId = houseId;
this.timestampStart = timestampStart;
this.timestampEnd = timestampEnd;
this.producedEnergy = producedEnergy;
this.obtainedEnergy = obtainedEnergy;
this.injectedEnergy = injectedEnergy;
}
@Id
@Column(name="house_id")
private int houseId;
@Id
@Column(name="timestamp_start")
private long timestampStart;
@Id
@Column(name="timestamp_end")
private long timestampEnd;
@Column(name="produced_energy")
private long producedEnergy;
@Column(name="obtained_energy")
private long obtainedEnergy;
@Column(name="injected_energy")
private long injectedEnergy;
public int getHouseId() {
return houseId;
}
public void setHouseId(int houseId) {
this.houseId = houseId;
}
public long getTimestampStart() {
return timestampStart;
}
public void setTimestampStart(long timestampStart) {
this.timestampStart = timestampStart;
}
public long getTimestampEnd() {
return timestampEnd;
}
public void setTimestampEnd(long timestampEnd) {
this.timestampEnd = timestampEnd;
}
public long getProducedEnergy() {
return producedEnergy;
}
public void setProducedEnergy(long producedEnergy) {
this.producedEnergy = producedEnergy;
}
public long getObtainedEnergy() {
return obtainedEnergy;
}
public void setObtainedEnergy(long obtainedEnergy) {
this.obtainedEnergy = obtainedEnergy;
}
public long getInjectedEnergy() {
return injectedEnergy;
}
public void setInjectedEnergy(long injectedEnergy) {
this.injectedEnergy = injectedEnergy;
}
}