From c23c93b7538a98a01de342363f5e2d57b0b2ffba Mon Sep 17 00:00:00 2001 From: dengqichen Date: Sun, 2 Nov 2025 22:59:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=83=A8=E7=BD=B2=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/IDeployRecordRepository.java | 30 +++++++++++++------ .../service/impl/DeployServiceImpl.java | 11 ++++++- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/com/qqchen/deploy/backend/deploy/repository/IDeployRecordRepository.java b/backend/src/main/java/com/qqchen/deploy/backend/deploy/repository/IDeployRecordRepository.java index c5d10b30..70472467 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/deploy/repository/IDeployRecordRepository.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/deploy/repository/IDeployRecordRepository.java @@ -50,16 +50,28 @@ public interface IDeployRecordRepository extends IBaseRepository 30) " + + " THEN 1 ELSE 0 END) as failedCount, " + + " SUM(CASE WHEN dr.status = 'RUNNING' " + + " OR (dr.status = 'CREATED' AND TIMESTAMPDIFF(MINUTE, dr.create_time, NOW()) <= 30) " + + " THEN 1 ELSE 0 END) as runningCount, " + + " MAX(dr.start_time) as lastDeployTime " + + "FROM deploy_record dr " + + "WHERE dr.team_application_id IN (:teamApplicationIds) AND dr.deleted = false " + + "GROUP BY dr.team_application_id", + nativeQuery = true) List findDeployStatisticsByTeamApplicationIds( @Param("teamApplicationIds") List teamApplicationIds); diff --git a/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/DeployServiceImpl.java b/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/DeployServiceImpl.java index 0493eb24..dab7c040 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/DeployServiceImpl.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/DeployServiceImpl.java @@ -25,6 +25,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -209,7 +210,15 @@ public class DeployServiceImpl implements IDeployService { Long successCount = ((Number) row[2]).longValue(); Long failedCount = ((Number) row[3]).longValue(); Long runningCount = ((Number) row[4]).longValue(); - LocalDateTime lastDeployTime = (LocalDateTime) row[5]; + // 处理原生SQL返回的Timestamp类型 + LocalDateTime lastDeployTime = null; + if (row[5] != null) { + if (row[5] instanceof Timestamp) { + lastDeployTime = ((Timestamp) row[5]).toLocalDateTime(); + } else if (row[5] instanceof LocalDateTime) { + lastDeployTime = (LocalDateTime) row[5]; + } + } DeployStatisticsDTO stats = new DeployStatisticsDTO(); stats.setTotalCount(totalCount);