fix(接口测试): 修复定时清理不生效的缺陷
--bug=1039529 --user=王孝刚 【项目管理】项目与权限-接口测试报告保留时间设置3小时,场景报告超过3小时的未删除 https://www.tapd.cn/55049933/s/1499849
This commit is contained in:
parent
5714a1275a
commit
ff30c8e2ad
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue