Skip to content

Commit c19c826

Browse files
Merge pull request #36 from Capstone-QuarterBack/feature
Feature
2 parents be7255d + b64bed8 commit c19c826

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/java/com/example/quaterback/api/domain/txinfo/repository/SpringDataJpaTxInfoRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,7 @@ Page<TransactionInfoEntity> findByStationIdAndPeriod(
133133
@Param("end") LocalDateTime end,
134134
Pageable pageable
135135
);
136+
137+
@Query("SELECT ti.transactionId FROM TransactionInfoEntity ti ORDER BY ti.transactionId DESC")
138+
Optional<String> findLatestTransactionId();
136139
}

src/main/java/com/example/quaterback/websocket/boot/notification/handler/BootNotificationHandler.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.example.quaterback.websocket.boot.notification.handler;
22

3+
import com.example.quaterback.api.domain.txinfo.repository.SpringDataJpaTxInfoRepository;
34
import com.example.quaterback.common.annotation.Handler;
45
import com.example.quaterback.websocket.MessageUtil;
56
import com.example.quaterback.websocket.OcppMessageHandler;
@@ -16,6 +17,7 @@
1617

1718
import java.io.IOException;
1819
import java.time.LocalDateTime;
20+
import java.util.Optional;
1921

2022
@Handler
2123
@RequiredArgsConstructor
@@ -25,6 +27,7 @@ public class BootNotificationHandler implements OcppMessageHandler {
2527
private final BootNotificationService bootNotificationService;
2628
private final ObjectMapper objectMapper;
2729
private final RefreshTimeoutService refreshTimeoutService;
30+
private final SpringDataJpaTxInfoRepository springDataJpaTxInfoRepository;
2831

2932
@Override
3033
public String getAction() {
@@ -53,7 +56,11 @@ public void handle(WebSocketSession session, JsonNode jsonNode) {
5356
payloadNode.put("interval", 15);
5457
payloadNode.put("status", "Accepted");
5558

56-
response.add(payloadNode);
59+
ObjectNode customDataNode = mapper.createObjectNode();
60+
Optional<String> transactionId = springDataJpaTxInfoRepository.findLatestTransactionId();
61+
customDataNode.put("transactionId", transactionId.orElse("tx-000"));
62+
// payload에 customData 추가
63+
payloadNode.set("customData", customDataNode);
5764

5865
// 메시지 전송
5966
try {

0 commit comments

Comments
 (0)