fix(项目设置): 分享报告时间检验

--user=郭雨琦 分享报告时间检验
This commit is contained in:
guoyuqi 2022-02-16 14:09:03 +08:00 committed by 刘瑞斌
parent c4d7514bd0
commit 723178b2f0
2 changed files with 10 additions and 10 deletions

View File

@ -527,22 +527,22 @@ public class ShareInfoService {
type = "TRACK"; type = "TRACK";
} }
if(StringUtils.isBlank(type)){ if(StringUtils.isBlank(type)){
millisCheck(shareInfo,1000 * 60 * 60 * 24); millisCheck(System.currentTimeMillis() - shareInfo.getUpdateTime() ,1000 * 60 * 60 * 24,shareInfo.getId());
}else{ }else{
ProjectApplication projectApplication = projectApplicationService.getProjectApplication(SessionUtils.getCurrentProjectId(),type); ProjectApplication projectApplication = projectApplicationService.getProjectApplication(SessionUtils.getCurrentProjectId(),type);
if(projectApplication.getProjectId()==null){ if(projectApplication.getProjectId()==null){
millisCheck(shareInfo,1000 * 60 * 60 * 24); millisCheck(System.currentTimeMillis() - shareInfo.getUpdateTime() ,1000 * 60 * 60 * 24,shareInfo.getId());
}else { }else {
String expr= projectApplication.getShareReportExpr(); String expr= projectApplication.getShareReportExpr();
long timeMills = getTimeMills(shareInfo.getUpdateTime(),expr); long timeMills = getTimeMills(shareInfo.getUpdateTime(),expr);
millisCheck(shareInfo,timeMills); millisCheck(System.currentTimeMillis(),timeMills,shareInfo.getId());
} }
} }
} }
private void millisCheck(ShareInfo shareInfo, long millis) { private void millisCheck(long compareMillis, long millis,String shareInfoId) {
if (shareInfo.getUpdateTime()<millis) { if (compareMillis>millis) {
shareInfoMapper.deleteByPrimaryKey(shareInfo.getId()); shareInfoMapper.deleteByPrimaryKey(shareInfoId);
MSException.throwException("连接已失效,请重新获取!"); MSException.throwException("连接已失效,请重新获取!");
} }
} }

View File

@ -28,13 +28,13 @@ public class ShareUtill {
String unit = expr.substring(expr.length() - 1); String unit = expr.substring(expr.length() - 1);
int quantity = Integer.parseInt(expr.substring(0, expr.length() - 1)); int quantity = Integer.parseInt(expr.substring(0, expr.length() - 1));
if(StringUtils.equals(unit,UNIT_HOUR)){ if(StringUtils.equals(unit,UNIT_HOUR)){
date = localDateTime.minusHours(quantity); date = localDateTime.plusHours(quantity);
} else if (StringUtils.equals(unit, UNIT_DAY)) { } else if (StringUtils.equals(unit, UNIT_DAY)) {
date = localDateTime.minusDays(quantity); date = localDateTime.plusDays(quantity);
} else if (StringUtils.equals(unit, UNIT_MONTH)) { } else if (StringUtils.equals(unit, UNIT_MONTH)) {
date = localDateTime.minusMonths(quantity); date = localDateTime.plusMonths(quantity);
} else if (StringUtils.equals(unit, UNIT_YEAR)) { } else if (StringUtils.equals(unit, UNIT_YEAR)) {
date = localDateTime.minusYears(quantity); date = localDateTime.plusYears(quantity);
} }
return date; return date;
} }