From ff30c8e2ad506d62c84f71b5256793a1e5d81040 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 17 Apr 2024 15:49:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=9A=E6=97=B6=E6=B8=85=E7=90=86=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1039529 --user=王孝刚 【项目管理】项目与权限-接口测试报告保留时间设置3小时,场景报告超过3小时的未删除 https://www.tapd.cn/55049933/s/1499849 --- .../src/main/java/io/metersphere/sdk/util/ShareUtil.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/ShareUtil.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/ShareUtil.java index d229ce6ac7..218fa2c40d 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/ShareUtil.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/ShareUtil.java @@ -3,7 +3,6 @@ package io.metersphere.sdk.util; import org.apache.commons.lang3.StringUtils; import java.time.Instant; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; @@ -50,8 +49,8 @@ public class ShareUtil { } public static long getCleanDate(String expr) { - LocalDate date = null; - LocalDate localDate = LocalDate.now(); + LocalDateTime date = null; + LocalDateTime localDate = LocalDateTime.now(); long timeMills = 0; if (StringUtils.isNotBlank(expr)) { try { @@ -63,6 +62,8 @@ public class ShareUtil { date = localDate.minusMonths(quantity); } else if (StringUtils.equals(unit, UNIT_YEAR)) { date = localDate.minusYears(quantity); + } else if (StringUtils.equals(unit, UNIT_HOUR)) { + date = localDate.minusHours(quantity); } else { LogUtils.error("clean up expr parse error. expr : " + expr); } @@ -72,7 +73,7 @@ public class ShareUtil { } } if (date != null) { - timeMills = date.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(); + timeMills = date.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); } return timeMills; }