|
@@ -2,6 +2,8 @@ package org.dromara.system.service.impl;
|
|
|
|
|
|
import lombok.SneakyThrows;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
+import org.dromara.common.core.domain.dto.RoleDTO;
|
|
|
+import org.dromara.common.core.domain.model.LoginUser;
|
|
|
import org.dromara.common.core.utils.DateUtils;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
@@ -12,10 +14,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.dromara.common.redis.utils.RedisUtils;
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
+import org.dromara.system.domain.bo.FormalTeacherClassBo;
|
|
|
import org.dromara.system.domain.vo.CourseChangeVo;
|
|
|
import org.dromara.system.domain.vo.CourseTableTimeVo;
|
|
|
+import org.dromara.system.domain.vo.FormalTeacherClassVo;
|
|
|
import org.dromara.system.mapper.CourseChangeMapper;
|
|
|
import org.dromara.system.mapper.CourseTableTimeMapper;
|
|
|
+import org.dromara.system.service.IFormalTeacherClassService;
|
|
|
import org.springframework.data.redis.cache.RedisCache;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.dromara.system.domain.bo.CourseTableBo;
|
|
@@ -25,6 +31,7 @@ import org.dromara.system.mapper.CourseTableMapper;
|
|
|
import org.dromara.system.service.ICourseTableService;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 课程Service业务层处理
|
|
@@ -42,6 +49,8 @@ public class CourseTableServiceImpl implements ICourseTableService {
|
|
|
|
|
|
private final CourseTableTimeMapper courseTableTimeMapper;
|
|
|
|
|
|
+ private final IFormalTeacherClassService formalTeacherClassService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询课程
|
|
|
*/
|
|
@@ -50,7 +59,6 @@ public class CourseTableServiceImpl implements ICourseTableService {
|
|
|
return baseMapper.selectVoById(id);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 查询课程列表
|
|
|
*/
|
|
@@ -62,23 +70,119 @@ public class CourseTableServiceImpl implements ICourseTableService {
|
|
|
}
|
|
|
LambdaQueryWrapper<CourseTable> lqw = buildQueryWrapper(bo);
|
|
|
Page<CourseTableVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
-
|
|
|
List<CourseTableVo> courseTableList = result.getRecords();
|
|
|
+
|
|
|
+
|
|
|
//获取本周一和本周五的时间
|
|
|
String fist = DateUtils.getTimeIntervalOne(new Date());
|
|
|
String five = DateUtils.getTimeIntervalFive(fist);
|
|
|
List<CourseChangeVo> courseChangeList = courseChangeMapper.selectCourseChangeListByEdit(bo.getClassId(), fist, five);
|
|
|
- if (courseChangeList == null || courseChangeList.size() <=0){
|
|
|
- return TableDataInfo.build(result);
|
|
|
+ if (courseChangeList != null && courseChangeList.size() >0){
|
|
|
+ for (CourseTableVo table : courseTableList) {
|
|
|
+ //将修改后的课程放入当前周课表
|
|
|
+ changeCourseTable(table,courseChangeList,fist,five);
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果当前角色是老师,获取老师的课程
|
|
|
+ LoginUser user = LoginHelper.getLoginUser();
|
|
|
+ Map<String, Object> params = bo.getParams();
|
|
|
+ String ro = "";
|
|
|
+ if (params != null && params.size() > 0) {
|
|
|
+ ro = (String) params.get("role");
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(ro) && "teacher".equals(ro)){
|
|
|
+ //查询老师当前班级所带的课
|
|
|
+ FormalTeacherClassBo ftbo = new FormalTeacherClassBo();
|
|
|
+ ftbo.setClassId(Long.valueOf(bo.getClassId()));
|
|
|
+ ftbo.setTeacherId(user.getUserId());
|
|
|
+ List<FormalTeacherClassVo> flVoList = formalTeacherClassService.queryList(ftbo);
|
|
|
+ List<String> disciplineName = flVoList.stream().map(FormalTeacherClassVo::getDiscipline).collect(Collectors.toList());
|
|
|
+ maekers(courseTableList, disciplineName);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- for (CourseTableVo table : courseTableList) {
|
|
|
- changeCourseTable(table,courseChangeList,fist,five);
|
|
|
+ return TableDataInfo.build(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<CourseTableVo> queryPagePcList(CourseTableBo bo, PageQuery pageQuery) {
|
|
|
+ if(StringUtils.isEmpty(bo.getClassId()) || StringUtils.isEmpty(bo.getSchoolId())){
|
|
|
+ return TableDataInfo.build(new ArrayList<>());
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<CourseTable> lqw = buildQueryWrapper(bo);
|
|
|
+ Page<CourseTableVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+ List<CourseTableVo> courseTableList = result.getRecords();
|
|
|
+
|
|
|
+ //获取本周一和本周五的时间
|
|
|
+ String fist = DateUtils.getTimeIntervalOne(new Date());
|
|
|
+ String five = DateUtils.getTimeIntervalFive(fist);
|
|
|
+ List<CourseChangeVo> courseChangeList = courseChangeMapper.selectCourseChangeListByEdit(bo.getClassId(), fist, five);
|
|
|
+ if (courseChangeList != null && courseChangeList.size() >0){
|
|
|
+ for (CourseTableVo table : courseTableList) {
|
|
|
+ //将修改后的课程放入当前周课表
|
|
|
+ changeCourseTable(table,courseChangeList,fist,five);
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果当前角色是老师,获取老师的课程
|
|
|
+ LoginUser user = LoginHelper.getLoginUser();
|
|
|
+ List<RoleDTO> roles = user.getRoles();
|
|
|
+ boolean bl = false;
|
|
|
+ for (RoleDTO role : roles) {
|
|
|
+ if ("teacher".equals(role.getRoleKey())) {
|
|
|
+ bl = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (bl) {
|
|
|
+ //查询老师当前班级所带的课
|
|
|
+ FormalTeacherClassBo ftbo = new FormalTeacherClassBo();
|
|
|
+ ftbo.setClassId(Long.valueOf(bo.getClassId()));
|
|
|
+ ftbo.setTeacherId(user.getUserId());
|
|
|
+ List<FormalTeacherClassVo> flVoList = formalTeacherClassService.queryList(ftbo);
|
|
|
+ List<String> disciplineName = flVoList.stream().map(FormalTeacherClassVo::getDiscipline).collect(Collectors.toList());
|
|
|
+
|
|
|
+ maekers(courseTableList, disciplineName);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return TableDataInfo.build(result);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private void maekers(List<CourseTableVo> courseTableList, List<String> disciplineName) {
|
|
|
+ //判断老师所带的课程
|
|
|
+ for (CourseTableVo table : courseTableList) {
|
|
|
+ table.setTeacherClassName(disciplineName);
|
|
|
+ Set<Long> teacherClassNum = new HashSet<>();
|
|
|
+ if(disciplineName.contains(table.getOneClass())){
|
|
|
+ teacherClassNum.add(1L);
|
|
|
+ }
|
|
|
+ if(disciplineName.contains(table.getTwoClass())){
|
|
|
+ teacherClassNum.add(2L);
|
|
|
+ }
|
|
|
+ if(disciplineName.contains(table.getThreeClass())){
|
|
|
+ teacherClassNum.add(3L);
|
|
|
+ }
|
|
|
+ if(disciplineName.contains(table.getFourClass())){
|
|
|
+ teacherClassNum.add(4L);
|
|
|
+ }
|
|
|
+ if(disciplineName.contains(table.getFiveClass())){
|
|
|
+ teacherClassNum.add(5L);
|
|
|
+ }
|
|
|
+ if(disciplineName.contains(table.getSixClass())){
|
|
|
+ teacherClassNum.add(6L);
|
|
|
+ }
|
|
|
+ if(disciplineName.contains(table.getSevenClass())){
|
|
|
+ teacherClassNum.add(7L);
|
|
|
+ }
|
|
|
+ if(disciplineName.contains(table.getEightClass())){
|
|
|
+ teacherClassNum.add(8L);
|
|
|
+ }
|
|
|
+ table.setTeacherClassNum(teacherClassNum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@SneakyThrows
|
|
|
private void changeCourseTable(CourseTableVo table, List<CourseChangeVo> courseChangeList, String fist, String five) {
|
|
|
String format = "yyyy-MM-dd";
|
|
@@ -319,6 +423,7 @@ public class CourseTableServiceImpl implements ICourseTableService {
|
|
|
return R.ok(map);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@SneakyThrows
|
|
|
private int isClass(CourseTableTimeVo courseTableTime) {
|
|
|
//获取当前时间
|