@@ -83,16 +83,13 @@ public void writeTransactionsCSV(TransactionQueryForm form, Writer writer) {
83
83
@ Override
84
84
public void writeTransactionsDetailsCSV (int transactionPk , Writer writer ,
85
85
boolean dataReduction , boolean firstArrivingMeterValueIfMultiple ) {
86
-
87
- // write a few information about the transaction
86
+ // write a few information about the transaction
88
87
TransactionQueryForm form = new TransactionQueryForm ();
89
88
form .setTransactionPk (transactionPk );
90
89
form .setType (TransactionQueryForm .QueryType .ALL );
91
90
form .setPeriodType (TransactionQueryForm .QueryPeriodType .ALL );
92
-
93
91
//getInternalCSV(form).fetch().formatCSV(writer);
94
-
95
- Record12 <Integer , String , Integer , String , DateTime , String , DateTime ,
92
+ Record12 <Integer , String , Integer , String , DateTime , String , DateTime ,
96
93
String , String , Integer , Integer , TransactionStopEventActor >
97
94
res = getInternal (form ).fetchOne ();
98
95
if (res == null ) {
@@ -117,32 +114,29 @@ public List<Integer> getActiveTransactionIds(String chargeBoxId) {
117
114
}
118
115
119
116
@ Override
120
- public TransactionDetails getDetails (int transactionPk ,
117
+ public TransactionDetails getDetails (int transactionPk ,
121
118
boolean dataReduction , boolean firstArrivingMeterValueIfMultiple ) {
122
-
123
119
// -------------------------------------------------------------------------
124
120
// Step 1: Collect general data about transaction
125
121
// -------------------------------------------------------------------------
126
-
122
+ //
127
123
TransactionQueryForm form = new TransactionQueryForm ();
128
124
form .setTransactionPk (transactionPk );
129
125
form .setType (TransactionQueryForm .QueryType .ALL );
130
126
form .setPeriodType (TransactionQueryForm .QueryPeriodType .ALL );
131
127
132
- Record12 <Integer , String , Integer , String , DateTime , String , DateTime ,
128
+ Record12 <Integer , String , Integer , String , DateTime , String , DateTime ,
133
129
String , String , Integer , Integer , TransactionStopEventActor >
134
130
res = getInternal (form ).fetchOne ();
135
131
136
132
if (res == null ) {
137
133
throw new SteveException ("There is no transaction with id '%s'" , transactionPk );
138
134
}
139
-
140
135
//Transaction transaction = getInternal(form).fetchOne(new TransactionMapper());
141
136
TransactionMapper mapper = new TransactionMapper ();
142
137
Transaction transaction = mapper .map (res );
143
138
TransactionStartRecord nextTx = null ;
144
-
145
- List <TransactionDetails .MeterValues > values =
139
+ List <TransactionDetails .MeterValues > values =
146
140
getDetailsQuery (transaction , nextTx , transactionPk , dataReduction , firstArrivingMeterValueIfMultiple )
147
141
.fetch ()
148
142
.map (r -> TransactionDetails .MeterValues .builder ()
@@ -159,29 +153,25 @@ public TransactionDetails getDetails(int transactionPk,
159
153
return new TransactionDetails (transaction , values , nextTx );
160
154
}
161
155
162
- private SelectQuery <Record8 <DateTime , String , String , String , String , String , String , String >>
163
- getDetailsQuery (Transaction transaction , TransactionStartRecord nextTx , int transactionPk ,
156
+ private SelectQuery <Record8 <DateTime , String , String , String , String , String , String , String >>
157
+ getDetailsQuery (Transaction transaction , TransactionStartRecord nextTx , int transactionPk ,
164
158
boolean dataReduction , boolean firstArrivingMeterValueIfMultiple ) {
165
-
166
- // // -------------------------------------------------------------------------
167
- // // Step 1a: Collect general data about transaction
168
- // // -------------------------------------------------------------------------
169
- //
159
+ // -------------------------------------------------------------------------
160
+ // Step 1a: Collect general data about transaction
161
+ // -------------------------------------------------------------------------
162
+ //
170
163
DateTime startTimestamp = transaction .getStartTimestamp ();
171
164
DateTime stopTimestamp = transaction .getStopTimestamp ();
172
165
String stopValue = transaction .getStopValue ();
173
166
String chargeBoxId = transaction .getChargeBoxId ();
174
167
int connectorId = transaction .getConnectorId ();
175
-
176
168
// -------------------------------------------------------------------------
177
169
// Step 2: Collect intermediate meter values
178
170
// -------------------------------------------------------------------------
179
-
171
+ //
180
172
Condition timestampCondition ;
181
173
//TransactionStartRecord nextTx = null;
182
-
183
174
if (stopTimestamp == null && stopValue == null ) {
184
-
185
175
// https://github.com/steve-community/steve/issues/97
186
176
//
187
177
// handle "zombie" transaction, for which we did not receive any StopTransaction. if we do not handle it,
@@ -235,19 +225,19 @@ public TransactionDetails getDetails(int transactionPk,
235
225
// UNION removes all duplicate records
236
226
//
237
227
Table <ConnectorMeterValueRecord > t1 = transactionQuery .union (timestampQuery ).asTable ("t1" );
238
- if (dataReduction == false ) {
228
+ if (! dataReduction ) {
239
229
return ctx .select (
240
- t1 .field (2 , DateTime .class ),
241
- t1 .field (3 , String .class ),
242
- t1 .field (4 , String .class ),
243
- t1 .field (5 , String .class ),
244
- t1 .field (6 , String .class ),
245
- t1 .field (7 , String .class ),
246
- t1 .field (8 , String .class ),
247
- t1 .field (9 , String .class ))
248
- .from (t1 )
249
- //.orderBy(innerTable.field(2))
250
- .getQuery ();
230
+ t1 .field (2 , DateTime .class ),
231
+ t1 .field (3 , String .class ),
232
+ t1 .field (4 , String .class ),
233
+ t1 .field (5 , String .class ),
234
+ t1 .field (6 , String .class ),
235
+ t1 .field (7 , String .class ),
236
+ t1 .field (8 , String .class ),
237
+ t1 .field (9 , String .class ))
238
+ .from (t1 )
239
+ //.orderBy(innerTable.field(2))
240
+ .getQuery ();
251
241
}
252
242
253
243
// -------------------------------------------------------------------------
@@ -259,7 +249,7 @@ public TransactionDetails getDetails(int transactionPk,
259
249
// -------------------------------------------------------------------------
260
250
261
251
//Field<DateTime> dateTimeField;
262
- Table <Record11 <Integer , Integer , DateTime , String , String , String ,
252
+ Table <Record11 <Integer , Integer , DateTime , String , String , String ,
263
253
String , String , String , String , Double >> innerTable ;
264
254
if (firstArrivingMeterValueIfMultiple ) {
265
255
//dateTimeField = DSL.min(t1.field(2, DateTime.class)).as("min");
@@ -284,7 +274,6 @@ public TransactionDetails getDetails(int transactionPk,
284
274
.where (t1 .field ("transaction_pk" , Integer .class ).eq (transactionPk ))
285
275
.and ((t1 .field ("format" , String .class ).eq ("raw" )).or (t1 .field ("format" , String .class ).isNull ()))
286
276
.asTable ();
287
-
288
277
} else {
289
278
//dateTimeField = DSL.max(t1.field(2, DateTime.class)).as("max");
290
279
innerTable =
0 commit comments