|
@@ -21,15 +21,19 @@ import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.format.datetime.DateFormatter;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DateFormat;
|
|
|
import java.time.Instant;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -68,6 +72,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
private SubjectService subjectService;
|
|
|
@Autowired
|
|
|
private ClassGroupTeacherMapperDao classGroupTeacherMapperDao;
|
|
|
+ @Autowired
|
|
|
+ private CourseScheduleDao courseScheduleDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, ClassGroup> getDAO() {
|
|
@@ -205,6 +211,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
highClassGroup.setCreateTime(date);
|
|
|
highClassGroup.setUpdateTime(date);
|
|
|
highClassGroup.setType(ClassGroupTypeEnum.HIGH);
|
|
|
+ highClassGroup.setTotalClassTimes(highClassGroup.getCourseTimes());
|
|
|
+ highClassGroup.setCurrentClassTimes(0);
|
|
|
insert(highClassGroup);
|
|
|
|
|
|
//2、插入班级关联老师
|
|
@@ -219,21 +227,21 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
|
|
|
//3、插入班级排课信息
|
|
|
List<CourseSchedule> courseScheduleList = new ArrayList<>();
|
|
|
- int i = 0;
|
|
|
- LocalDateTime now = LocalDateTime.ofInstant(highClassGroup.getStartDate().toInstant(), ZoneId.systemDefault());
|
|
|
+ int times = 0;
|
|
|
+ //LocalDateTime now = LocalDateTime.ofInstant(highClassGroup.getStartDate().toInstant(), ZoneId.systemDefault());
|
|
|
+ LocalDateTime now = LocalDate.parse(highClassGroup.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
|
|
|
+
|
|
|
while (true) {
|
|
|
- now = now.plusDays(i);
|
|
|
int dayOfWeek = now.getDayOfWeek().getValue();
|
|
|
-
|
|
|
if (highClassGroup.getDayOfWeek().equals(dayOfWeek)) {
|
|
|
CourseSchedule courseSchedule = new CourseSchedule();
|
|
|
Instant instant = now.atZone(ZoneId.systemDefault()).toInstant();
|
|
|
Date classDate = Date.from(instant);
|
|
|
- String startClassTime = DateUtil.getDate(classDate) + " " + highClassGroup.getStartClassTime();
|
|
|
- String endClassTime = DateUtil.getDate(classDate) + " " + highClassGroup.getEndClassTime();
|
|
|
+ String startClassTime = DateUtil.getDate(classDate) + " " + highClassGroup.getStartClassTime()+":00";
|
|
|
+ String endClassTime = DateUtil.getDate(classDate) + " " + highClassGroup.getEndClassTime()+":00";
|
|
|
|
|
|
courseSchedule.setSchoolId(schoolId);
|
|
|
- courseSchedule.setClassGroupId(highClassGroup.getUserId());
|
|
|
+ courseSchedule.setClassGroupId(highClassGroup.getId());
|
|
|
courseSchedule.setStatus(CourseStatusEnum.NOT_START);
|
|
|
courseSchedule.setClassDate(classDate);
|
|
|
courseSchedule.setStartClassTime(DateUtil.stringToDate(startClassTime));
|
|
@@ -243,14 +251,19 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
courseSchedule.setCreateTime(date);
|
|
|
courseSchedule.setUpdateTime(date);
|
|
|
courseSchedule.setTeachMode(TeachModeEnum.OFFLINE);
|
|
|
+ courseSchedule.setType(CourseSchedule.CourseScheduleType.HIGH);
|
|
|
+ Subject subject = subjectService.get(Integer.parseInt(highClassGroup.getSubjectIdList()));
|
|
|
+ courseSchedule.setName(subject.getName()+"-"+CourseSchedule.CourseScheduleType.HIGH.getMsg());
|
|
|
+
|
|
|
courseScheduleList.add(courseSchedule);
|
|
|
- i++;
|
|
|
+ times++;
|
|
|
}
|
|
|
- if (highClassGroup.getCourseTimes().equals(i)) {
|
|
|
+ now = now.plusDays(1);
|
|
|
+ if (highClassGroup.getCourseTimes().equals(times)) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- courseScheduleService.batchAddCourseSchedule(courseScheduleList);
|
|
|
+ courseScheduleDao.batchAddCourseSchedules(courseScheduleList);
|
|
|
}
|
|
|
return highClassGroupList;
|
|
|
}
|