|
|
|
|
@ -189,6 +189,46 @@ public class DmsPlanInspectServiceImpl implements IDmsPlanInspectService
|
|
|
|
|
@Override
|
|
|
|
|
public int updateDmsPlanInspect(DmsPlanInspect dmsPlanInspect)
|
|
|
|
|
{
|
|
|
|
|
// 根据巡检级别和周期字段重新构建cron表达式
|
|
|
|
|
String day = "*";
|
|
|
|
|
String month = "*";
|
|
|
|
|
String week = "*";
|
|
|
|
|
String year = "*";
|
|
|
|
|
String cron = "";
|
|
|
|
|
if (dmsPlanInspect.getDay()!=null){
|
|
|
|
|
day = dmsPlanInspect.getDay().toString();
|
|
|
|
|
}
|
|
|
|
|
if (dmsPlanInspect.getMonth()!=null){
|
|
|
|
|
month = dmsPlanInspect.getMonth().toString();
|
|
|
|
|
}
|
|
|
|
|
if (dmsPlanInspect.getWeek()!=null){
|
|
|
|
|
Long weekDay = dmsPlanInspect.getWeek() + 1;
|
|
|
|
|
week = weekDay.toString();
|
|
|
|
|
}
|
|
|
|
|
if (dmsPlanInspect.getYear()!=null){
|
|
|
|
|
year = dmsPlanInspect.getYear().toString();
|
|
|
|
|
}
|
|
|
|
|
if (dmsPlanInspect.getInspectLevel().equals(1l)){
|
|
|
|
|
cron = "0 0 "+dmsPlanInspect.getHour()+" "+day+" "+month+" ?";
|
|
|
|
|
}
|
|
|
|
|
if (dmsPlanInspect.getInspectLevel().equals(2l)){
|
|
|
|
|
cron = "0 0 "+dmsPlanInspect.getHour()+" ?"+" "+month+" "+week;
|
|
|
|
|
}
|
|
|
|
|
if (dmsPlanInspect.getInspectLevel().equals(3l)){
|
|
|
|
|
cron = "0 0 "+dmsPlanInspect.getHour()+" "+day+" "+ month+" ? "+year;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String time = cron;
|
|
|
|
|
//通过cron表达式获取下一次执行时间
|
|
|
|
|
Date nextExecution = CronUtils.getNextExecution(time);
|
|
|
|
|
dmsPlanInspect.setPlanTime(nextExecution);
|
|
|
|
|
dmsPlanInspect.setCronExpression(cron);
|
|
|
|
|
|
|
|
|
|
Long timeLimitDays = dmsPlanInspect.getTimeLimitDays()==null?0L:dmsPlanInspect.getTimeLimitDays();
|
|
|
|
|
Long timeLimitHours = dmsPlanInspect.getTimeLimitHours() == null?0L:dmsPlanInspect.getTimeLimitHours();
|
|
|
|
|
dmsPlanInspect.setTimeLimit((timeLimitDays * 24 * 60 * 60)
|
|
|
|
|
+ (timeLimitHours * 60 * 60));
|
|
|
|
|
|
|
|
|
|
LoginUser user = SecurityUtils.getLoginUser();
|
|
|
|
|
dmsPlanInspect.setUpdateBy(user.getUserId());
|
|
|
|
|
dmsPlanInspect.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|