|
@@ -391,7 +391,7 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
List<CheckJob> jobList = new ArrayList<CheckJob>();
|
|
|
List<CheckStandard> standardList = standardMapper.selectAll();
|
|
|
|
|
|
- // 查询每个标准是否有已经存在未执行的任务,如果有则不生成,否则直接生成。
|
|
|
+ // 查询每个标准是否有已经存在未执行的任务,如果有则不生成,否则直接生成。初次执行的时候,没有未执行的任务
|
|
|
Weekend<CheckJob> weekend = new Weekend<>(CheckJob.class);
|
|
|
weekend.weekendCriteria().andNotEqualTo(CheckJob::getStatus, CheckJobStatusEnum.FINISHED.getValue());
|
|
|
List<CheckJob> checkJobs = mapper.selectByExample(weekend);
|
|
@@ -662,31 +662,76 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
if(vo != null){
|
|
|
localDateTime = vo.getActualEndTime();
|
|
|
}
|
|
|
- if (CheckPlanPeriodTypeEnum.DAY.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
- startDate = DateUtils.plus(localDateTime.toLocalDate(), checkStandard.getPeriod(), ChronoUnit.DAYS);
|
|
|
- endDate = DateUtils.plus(startDate, checkStandard.getPeriod() + 2, ChronoUnit.DAYS);
|
|
|
- }
|
|
|
- if (CheckPlanPeriodTypeEnum.WEEK.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
- startDate = DateUtils.plus(localDateTime.toLocalDate(), checkStandard.getPeriod() * 7, ChronoUnit.DAYS);
|
|
|
- endDate = DateUtils.plus(startDate, checkStandard.getPeriod() * 7 + 2, ChronoUnit.DAYS);
|
|
|
- }
|
|
|
- if (CheckPlanPeriodTypeEnum.MONTH.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
- startDate = DateUtils.plus(localDateTime.toLocalDate(), checkStandard.getPeriod(), ChronoUnit.MONTHS);
|
|
|
- endDate = DateUtils.plus(startDate, 10, ChronoUnit.DAYS);
|
|
|
- }
|
|
|
- if (CheckPlanPeriodTypeEnum.SEASON.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
- startDate = DateUtils.plus(localDateTime.toLocalDate(), checkStandard.getPeriod() * 3, ChronoUnit.MONTHS);
|
|
|
- endDate = DateUtils.plus(startDate, 20, ChronoUnit.DAYS);
|
|
|
- }
|
|
|
- if (CheckPlanPeriodTypeEnum.YEAR.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
- startDate = DateUtils.plus(localDateTime.toLocalDate(), checkStandard.getPeriod(), ChronoUnit.YEARS);
|
|
|
- endDate = DateUtils.plus(startDate, 60, ChronoUnit.DAYS);
|
|
|
+
|
|
|
+ if(checkStandard.getNextDate() != null || checkStandard.getLastDate() != null){
|
|
|
+ if(checkStandard.getNextDate() != null){
|
|
|
+ startDate = checkStandard.getNextDate();
|
|
|
+ if (CheckPlanPeriodTypeEnum.DAY.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ endDate = DateUtils.plus(startDate, checkStandard.getPeriod() + 2, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ if (CheckPlanPeriodTypeEnum.WEEK.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ endDate = DateUtils.plus(startDate, checkStandard.getPeriod() * 7 + 2, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ if (CheckPlanPeriodTypeEnum.MONTH.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ endDate = DateUtils.plus(startDate, 10, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ if (CheckPlanPeriodTypeEnum.SEASON.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ endDate = DateUtils.plus(startDate, 20, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ if (CheckPlanPeriodTypeEnum.YEAR.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ endDate = DateUtils.plus(startDate, 60, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(checkStandard.getLastDate() != null){
|
|
|
+ if (CheckPlanPeriodTypeEnum.DAY.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ startDate = DateUtils.plus(checkStandard.getLastDate(), checkStandard.getPeriod(), ChronoUnit.DAYS);
|
|
|
+ endDate = DateUtils.plus(startDate, checkStandard.getPeriod() + 2, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ if (CheckPlanPeriodTypeEnum.WEEK.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ startDate = DateUtils.plus(checkStandard.getLastDate(), checkStandard.getPeriod() * 7, ChronoUnit.DAYS);
|
|
|
+ endDate = DateUtils.plus(startDate, checkStandard.getPeriod() * 7 + 2, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ if (CheckPlanPeriodTypeEnum.MONTH.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ startDate = DateUtils.plus(checkStandard.getLastDate(), checkStandard.getPeriod(), ChronoUnit.MONTHS);
|
|
|
+ endDate = DateUtils.plus(startDate, 10, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ if (CheckPlanPeriodTypeEnum.SEASON.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ startDate = DateUtils.plus(checkStandard.getLastDate(), checkStandard.getPeriod() * 3, ChronoUnit.MONTHS);
|
|
|
+ endDate = DateUtils.plus(startDate, 20, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ if (CheckPlanPeriodTypeEnum.YEAR.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ startDate = DateUtils.plus(checkStandard.getLastDate(), checkStandard.getPeriod(), ChronoUnit.YEARS);
|
|
|
+ endDate = DateUtils.plus(startDate, 60, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (CheckPlanPeriodTypeEnum.DAY.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ startDate = DateUtils.plus(localDateTime.toLocalDate(), checkStandard.getPeriod(), ChronoUnit.DAYS);
|
|
|
+ endDate = DateUtils.plus(startDate, checkStandard.getPeriod() + 2, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ if (CheckPlanPeriodTypeEnum.WEEK.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ startDate = DateUtils.plus(localDateTime.toLocalDate(), checkStandard.getPeriod() * 7, ChronoUnit.DAYS);
|
|
|
+ endDate = DateUtils.plus(startDate, checkStandard.getPeriod() * 7 + 2, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ if (CheckPlanPeriodTypeEnum.MONTH.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ startDate = DateUtils.plus(localDateTime.toLocalDate(), checkStandard.getPeriod(), ChronoUnit.MONTHS);
|
|
|
+ endDate = DateUtils.plus(startDate, 10, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ if (CheckPlanPeriodTypeEnum.SEASON.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ startDate = DateUtils.plus(localDateTime.toLocalDate(), checkStandard.getPeriod() * 3, ChronoUnit.MONTHS);
|
|
|
+ endDate = DateUtils.plus(startDate, 20, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
+ if (CheckPlanPeriodTypeEnum.YEAR.getValue().equals(checkStandard.getPeriodType())) {
|
|
|
+ startDate = DateUtils.plus(localDateTime.toLocalDate(), checkStandard.getPeriod(), ChronoUnit.YEARS);
|
|
|
+ endDate = DateUtils.plus(startDate, 60, ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
}
|
|
|
startDate = DateUtils.plus(startDate, -1, ChronoUnit.DAYS);
|
|
|
endDate = DateUtils.plus(endDate, -1, ChronoUnit.DAYS);
|
|
|
checkJob.setStartTime(startDate);
|
|
|
checkJob.setEndTime(endDate);
|
|
|
- checkStandard.setNextDate(endDate);
|
|
|
+ checkStandard.setNextDate(startDate);
|
|
|
}
|
|
|
|
|
|
public LocalDate getCheckJobEndDate(LocalDate startDate, Integer period, Integer periodType){
|