课程自动复制,往下下周开始复制

This commit is contained in:
limqhz
2022-02-13 22:30:23 +08:00
parent 99a4cd94aa
commit b96514a86f
4 changed files with 130 additions and 11 deletions

View File

@@ -40,7 +40,7 @@ public class CopyLessonTask {
/**
* 每周一九点
*/
@Scheduled(cron = "0 */1 * * * ?")
// @Scheduled(cron = "0 */1 * * * ?")
public void execute(){
logger.info("开始执行拷贝课程批处理");
LocalTime time = LocalTime.now();
@@ -62,10 +62,14 @@ public class CopyLessonTask {
List<VenueLesson> allForCopy = venueLessonService.findAllForCopy(startTime, endTime);
if (allForCopy!= null && allForCopy.size()>0){
logger.info("需要操作的课程数为:" + allForCopy.size());
Integer copyTarget = venue.getCopyTarget();
if (copyTarget == null){
copyTarget = 1;
}
int count = 0;
for (VenueLesson venueLesson : allForCopy) {
count ++;
Date copyDate = DateUtilCard.addDays(venueLesson.getDate(), 7);
Date copyDate = DateUtilCard.addDays(venueLesson.getDate(), 7 * copyTarget + 7);
venueLessonService.copy(venueLesson.getId(),copyDate,copyDate);
}
logger.info("拷贝的课程数量为:" + count);
@@ -78,12 +82,12 @@ public class CopyLessonTask {
private boolean checkTime(LocalTime time, LocalTime copyTime) {
int cHour = time.getHour();
int cMinute = time.getMinute();
if (copyTime == null){
if (copyTime == null) {
copyTime = LocalTime.parse("00:00");
}
int sHour = copyTime.getHour();
int sMinute = copyTime.getMinute();
if (cHour == sHour && cMinute == sMinute){
if (cHour == sHour && cMinute == sMinute) {
return true;
}
return false;