From b85f920f4091adf79e62a66f3eac098df4923441 Mon Sep 17 00:00:00 2001 From: "gayoun.park" Date: Tue, 19 May 2026 14:55:49 +0900 Subject: [PATCH] =?UTF-8?q?=ED=95=99=EC=8A=B5=20=EC=86=8C=EC=9A=94?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/dto/ModelTrainDetailDto.java | 37 ++++++++++++++++--- .../model/ModelDetailRepositoryImpl.java | 2 + 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/kamco/cd/training/model/dto/ModelTrainDetailDto.java b/src/main/java/com/kamco/cd/training/model/dto/ModelTrainDetailDto.java index 1c15123..53d362e 100644 --- a/src/main/java/com/kamco/cd/training/model/dto/ModelTrainDetailDto.java +++ b/src/main/java/com/kamco/cd/training/model/dto/ModelTrainDetailDto.java @@ -33,6 +33,8 @@ public class ModelTrainDetailDto { private String modelNo; private String modelVer; @JsonFormatDttm private ZonedDateTime step1StrtDttm; + @JsonFormatDttm private ZonedDateTime step1EndDttm; + @JsonFormatDttm private ZonedDateTime step2StrtDttm; @JsonFormatDttm private ZonedDateTime step2EndDttm; private String statusCd; private String trainType; @@ -61,11 +63,7 @@ public class ModelTrainDetailDto { } private String formatDuration(ZonedDateTime start, ZonedDateTime end) { - if (end == null) { - end = ZonedDateTime.now(); - } - - if (start == null) { + if (start == null || end == null) { return null; } @@ -83,7 +81,34 @@ public class ModelTrainDetailDto { } public String getStepAllDuration() { - return formatDuration(this.step1StrtDttm, this.step2EndDttm); + if (this.step2EndDttm != null) { + // step1 + step2 실제 소요시간 합산 + long step1Seconds = 0; + long step2Seconds = 0; + + if (this.step1StrtDttm != null && this.step1EndDttm != null) { + step1Seconds = + Math.abs(Duration.between(this.step1StrtDttm, this.step1EndDttm).getSeconds()); + } + if (this.step2StrtDttm != null && this.step2EndDttm != null) { + step2Seconds = + Math.abs(Duration.between(this.step2StrtDttm, this.step2EndDttm).getSeconds()); + } + + long totalSeconds = step1Seconds + step2Seconds; + long hours = totalSeconds / 3600; + long minutes = (totalSeconds % 3600) / 60; + long seconds = totalSeconds % 60; + + if (HeaderUtil.isEnglishRequest()) { + return String.format("%dh %dm %ds", hours, minutes, seconds); + } else { + return String.format("%d시간 %d분 %d초", hours, minutes, seconds); + } + } else { + // step2 없으면 step1만 + return formatDuration(this.step1StrtDttm, this.step1EndDttm); + } } } diff --git a/src/main/java/com/kamco/cd/training/postgres/repository/model/ModelDetailRepositoryImpl.java b/src/main/java/com/kamco/cd/training/postgres/repository/model/ModelDetailRepositoryImpl.java index 573148b..03688c9 100644 --- a/src/main/java/com/kamco/cd/training/postgres/repository/model/ModelDetailRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/training/postgres/repository/model/ModelDetailRepositoryImpl.java @@ -80,6 +80,8 @@ public class ModelDetailRepositoryImpl implements ModelDetailRepositoryCustom { modelMasterEntity.modelNo, modelMasterEntity.modelVer, modelMasterEntity.step1StrtDttm, + modelMasterEntity.step1EndDttm, + modelMasterEntity.step2StrtDttm, modelMasterEntity.step2EndDttm, modelMasterEntity.statusCd, modelMasterEntity.trainType,