|
|
@@ -12,6 +12,8 @@ import com.google.gson.JsonParser;
|
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
|
import com.xjrsoft.common.enums.EnabledMark;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
+import com.xjrsoft.module.base.entity.BaseSemester;
|
|
|
+import com.xjrsoft.module.base.service.IBaseSemesterService;
|
|
|
import com.xjrsoft.module.courseTable.entity.CourseTable;
|
|
|
import com.xjrsoft.module.courseTable.service.ICourseTableService;
|
|
|
import com.xjrsoft.module.schedule.dto.CourseTableAdjustDto;
|
|
|
@@ -43,7 +45,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.time.DayOfWeek;
|
|
|
+import java.time.Duration;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
@@ -67,6 +71,7 @@ public class ScheduleController {
|
|
|
private final IBaseStudentSchoolRollService baseStudentSchoolRollService;
|
|
|
private final IBaseTeacherService baseTeacherService;
|
|
|
private final ITeacherbaseManagerService teacherService;
|
|
|
+ private final IBaseSemesterService semesterService;
|
|
|
|
|
|
@GetMapping(value = "/receive-msg")
|
|
|
@ApiOperation(value="接收消息")
|
|
|
@@ -130,6 +135,32 @@ public class ScheduleController {
|
|
|
return RT.ok(list);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping(value = "/current-week")
|
|
|
+ @ApiOperation(value="获取当前周次")
|
|
|
+ @SaCheckPermission("room:detail")
|
|
|
+ public RT<Integer> currentWeek(CourseTableDto dto){
|
|
|
+ List<BaseSemester> semesterList = semesterService.list(new QueryWrapper<BaseSemester>().lambda().orderByDesc(BaseSemester::getStartDate));
|
|
|
+ BaseSemester baseSemester = semesterList.get(0);
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ //计算本周是第几周
|
|
|
+ LocalDateTime startDateTime = LocalDateTime.ofInstant(baseSemester.getStartDate().toInstant(), ZoneId.systemDefault());
|
|
|
+ LocalDateTime endDateTime = LocalDateTime.ofInstant(baseSemester.getEndDate().toInstant(), ZoneId.systemDefault());
|
|
|
+ Duration between = Duration.between(startDateTime, endDateTime);
|
|
|
+ long days = between.toDays();
|
|
|
+ int weeks = (int) Math.ceil((double) days / 7);
|
|
|
+ if (dto.getWeek() == null) {
|
|
|
+ for (int i = 0; i < weeks; i++) {
|
|
|
+ LocalDateTime startDate = startDateTime.plusDays(i * 6).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
+ LocalDateTime endDate = startDateTime.plusDays((i + 1) * 6).withHour(23).withMinute(59).withSecond(59).withNano(9999);
|
|
|
+ if (now.isAfter(startDate) && now.isBefore(endDate)) {
|
|
|
+ return RT.ok(i + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return RT.error("未能查询到当前周次");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@GetMapping(value = "/adjust-list")
|
|
|
@ApiOperation(value = "可以调课的课程")
|