任务新增时同步新增对应记录
This commit is contained in:
parent
5f3c80eb8a
commit
0ce0f2dda3
|
@ -7,11 +7,8 @@ import org.apache.commons.lang3.time.DateFormatUtils;
|
|||
import java.lang.management.ManagementFactory;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.*;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
@ -165,4 +162,25 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zdt.toInstant());
|
||||
}
|
||||
|
||||
public static LocalDate toLocalDate(Date temporalAccessor){
|
||||
return temporalAccessor.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回两个日期之间的日期列表
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
public static Date[] getDatesBetween(Date startDate, Date endDate) {
|
||||
LocalDate start = toLocalDate(startDate);
|
||||
LocalDate end = toLocalDate(endDate);
|
||||
long numOfDays = ChronoUnit.DAYS.between(start, end) + 1;
|
||||
Date[] dates = new Date[(int) numOfDays];
|
||||
for (int i = 0; i < numOfDays; i++) {
|
||||
dates[i] = toDate(start.plusDays(i));
|
||||
}
|
||||
return dates;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.common.core.domain.TreeEntity;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.mts.domain.MesPlanDetail;
|
||||
import com.ruoyi.mts.domain.bo.MesPlanDetailBo;
|
||||
|
@ -19,6 +20,7 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -129,7 +131,18 @@ public class MesPlanDetailServiceImpl implements IMesPlanDetailService {
|
|||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
//todo
|
||||
|
||||
Date planStartDate = bo.getPlanStartDate();
|
||||
Date planEndDate = bo.getPlanEndDate();
|
||||
|
||||
Date[] datesBetween = DateUtils.getDatesBetween(planStartDate, planEndDate);
|
||||
for (Date recordDate : datesBetween) {
|
||||
MesPlanRecordBo recordBo = new MesPlanRecordBo();
|
||||
recordBo.setFlag("plan");
|
||||
recordBo.setDetailId(add.getId());
|
||||
recordBo.setRecordDate(recordDate);
|
||||
recordService.insertByBo(recordBo);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue