|
@@ -28,6 +28,7 @@ import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateConvertor;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -96,6 +97,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
@Autowired
|
|
|
private ClassGroupTeacherMapperDao classGroupTeacherMapperDao;
|
|
|
@Autowired
|
|
|
+ private ClassGroupTeacherMapperService classGroupTeacherMapperService;
|
|
|
+ @Autowired
|
|
|
private CourseScheduleDao courseScheduleDao;
|
|
|
@Autowired
|
|
|
private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
@@ -194,6 +197,24 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
return pageInfo;
|
|
|
}
|
|
|
|
|
|
+ //校验主教助教是否冲突
|
|
|
+ private void checkTeachingBishop(List<ClassGroupTeacherMapper> teacherMappers){
|
|
|
+ Set<Integer> collect = teacherMappers.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
|
|
|
+ if (teacherMappers.size() != collect.size()) {
|
|
|
+ throw new BizException("主教与助教存在冲突");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private ClassGroup create(ClassGroupDto groupDto){
|
|
|
+ ClassGroup classGroup = new ClassGroup();
|
|
|
+ BeanUtils.copyProperties(groupDto,classGroup);
|
|
|
+ String userIds = classGroup.getUserIds();
|
|
|
+ Set<String> userIdStrSet = new HashSet<>(Arrays.asList(userIds.split(",")));
|
|
|
+ classGroup.setStudentNum(userIdStrSet.size());
|
|
|
+ this.insert(classGroup);
|
|
|
+ return classGroup;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Integer create(ClassGroup classGroup) {
|
|
@@ -203,11 +224,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
if (classGroup.getGroupType() == null) {
|
|
|
throw new BizException("课程组类型不能为空");
|
|
|
}
|
|
|
- List<ClassGroupTeacherMapper> teacherMappers = classGroup.getTeacherMapperList();
|
|
|
- Set<Integer> collect = teacherMappers.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
|
|
|
- if (teacherMappers.size() != collect.size()) {
|
|
|
- throw new BizException("主教与助教存在冲突");
|
|
|
- }
|
|
|
+// 校验主教助教是否冲突
|
|
|
+ this.checkTeachingBishop(classGroup.getTeacherMapperList());
|
|
|
|
|
|
//疫情原因去掉这块限制
|
|
|
//基础技能班和线上基础技能班,可分班原则为声部人数/6向上取整
|
|
@@ -304,6 +322,73 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
}
|
|
|
return classGroup.getId();
|
|
|
}
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void create1(List<ClassGroupDto> classGroups) {
|
|
|
+ //校验主教助教是否冲突
|
|
|
+ classGroups.stream().forEach(e->checkTeachingBishop(e.getClassGroupTeacherMapperList()));
|
|
|
+ Date date = new Date();
|
|
|
+ for (ClassGroupDto groupDto : classGroups) {
|
|
|
+ //创建班级
|
|
|
+ ClassGroup classGroup = this.create(groupDto);
|
|
|
+ //设置班级上的老师
|
|
|
+ List<Integer> teacherIdList = classGroupTeacherMapperService.addMapper(classGroup);
|
|
|
+ }
|
|
|
+
|
|
|
+ //2、插入班级学生关联关系
|
|
|
+ List<Integer> userIdList = new ArrayList<>();
|
|
|
+ List<ClassGroupStudentMapper> classGroupStudentList = new ArrayList<>();
|
|
|
+ for (String userId : userIdStrSet) {
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
+ classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupStudentMapper.setUserId(Integer.parseInt(userId));
|
|
|
+ classGroupStudentMapper.setCreateTime(date);
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ classGroupStudentMapper.setGroupType(MUSIC);
|
|
|
+ classGroupStudentList.add(classGroupStudentMapper);
|
|
|
+
|
|
|
+ StudentRegistration studentRegistration = new StudentRegistration();
|
|
|
+ studentRegistration.setClassGroupId(classGroup.getId());
|
|
|
+ studentRegistration.setUserId(Integer.parseInt(userId));
|
|
|
+ studentRegistration.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
+ studentRegistrationDao.updateByUserIdAndMusicGroupId(studentRegistration);
|
|
|
+
|
|
|
+ userIdList.add(Integer.parseInt(userId));
|
|
|
+ }
|
|
|
+ if (classGroupStudentList.size() > 0) {
|
|
|
+ classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentList);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 加入IM群组
|
|
|
+ if (userIdList.size() > 0) {
|
|
|
+ addImGroup(classGroup, userIdList, teacherIdList);
|
|
|
+ } else {
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(classGroup.getMusicGroupId());
|
|
|
+ Map<Integer, String> userRoleMap = new HashMap<>();
|
|
|
+ if (musicGroup.getEducationalTeacherId() != null) {
|
|
|
+ userRoleMap.put(musicGroup.getEducationalTeacherId(), "乐团主管");
|
|
|
+ }
|
|
|
+ if (musicGroup.getTeamTeacherId() != null) {
|
|
|
+ userRoleMap.put(musicGroup.getTeamTeacherId(), "运营主管");
|
|
|
+ }
|
|
|
+ if (musicGroup.getDirectorUserId() != null) {
|
|
|
+ userRoleMap.put(musicGroup.getDirectorUserId(), "乐队指导");
|
|
|
+ }
|
|
|
+ if (musicGroup.getTransactionTeacherId() != null) {
|
|
|
+ userRoleMap.put(musicGroup.getTransactionTeacherId(), "衔接老师");
|
|
|
+ }
|
|
|
+ if (teacherIdList != null && teacherIdList.size() > 0) {
|
|
|
+ for (Integer teacherId : teacherIdList) {
|
|
|
+ userRoleMap.put(teacherId, "指导老师");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ imGroupService.create(classGroup.getId().toString(), null, classGroup.getName(), musicGroup.getName(),
|
|
|
+ musicGroup.getName(), musicGroup.getName(), null, "MUSIC", ImGroup.GroupTypeEnum.valueOf(classGroup.getType().getCode()));
|
|
|
+ imGroupMemberService.join(classGroup.getId().toString(), userRoleMap);
|
|
|
+ }
|
|
|
+ return classGroup.getId();
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public List<ClassGroup> findClassGroup4Teacher(Integer teacherId) {
|
|
@@ -2369,11 +2454,12 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResponseResult classGroupUpdate(List<ClassGroup4MixDto> classGroup4MixDtos) {
|
|
|
+ public HttpResponseResult<ClassGroup> classGroupUpdate(List<ClassGroup4MixDto> classGroup4MixDtos) {
|
|
|
Date date = new Date();
|
|
|
- Integer classGroupId = classGroup4MixDtos.get(0).getClassGroupId();
|
|
|
- String musicGroupId = classGroup4MixDtos.get(0).getMusicGroupId();
|
|
|
-// Boolean checkCourseTimesFlag = classGroup4MixDtos.get(0).getCheckCourseTimesFlag();
|
|
|
+ ClassGroup4MixDto classGroup4MixDto1 = classGroup4MixDtos.get(0);
|
|
|
+ Integer classGroupId =classGroup4MixDto1.getClassGroupId();
|
|
|
+ String musicGroupId =classGroup4MixDto1.getMusicGroupId();
|
|
|
+// Boolean checkCourseTimesFlag =classGroup4MixDto1.getCheckCourseTimesFlag();
|
|
|
ClassGroup classGroup = classGroupDao.get(classGroupId);
|
|
|
if (classGroup == null) {
|
|
|
throw new BizException("班级不存在");
|
|
@@ -2381,8 +2467,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
MusicGroup musicGroup = musicGroupDao.get(classGroup.getMusicGroupId());
|
|
|
|
|
|
Boolean confirmGenerate = false;
|
|
|
- if (Objects.nonNull(classGroup4MixDtos.get(0).getConfirmGenerate())) {
|
|
|
- confirmGenerate = classGroup4MixDtos.get(0).getConfirmGenerate();
|
|
|
+ if (Objects.nonNull(classGroup4MixDto1.getConfirmGenerate())) {
|
|
|
+ confirmGenerate =classGroup4MixDto1.getConfirmGenerate();
|
|
|
}
|
|
|
|
|
|
TeachModeEnum teachMode = TeachModeEnum.OFFLINE;
|
|
@@ -2391,9 +2477,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
}
|
|
|
|
|
|
//1、更新班级关联老师信息
|
|
|
- if (Objects.nonNull(classGroup4MixDtos.get(0).getCourseAddType()) && classGroup4MixDtos.get(0).getCourseAddType().equals("onlyUpdateTeacher")) {
|
|
|
+ if (Objects.nonNull(classGroup4MixDto1.getCourseAddType()) &&classGroup4MixDto1.getCourseAddType().equals("onlyUpdateTeacher")) {
|
|
|
List<ClassGroupTeacherMapper> byClassGroup = classGroupTeacherMapperDao.findByClassGroup(classGroupId);
|
|
|
- List<ClassGroupTeacherMapper> newTeacherMapperList = classGroup4MixDtos.get(0).getClassGroupTeacherMapperList();
|
|
|
+ List<ClassGroupTeacherMapper> newTeacherMapperList =classGroup4MixDto1.getClassGroupTeacherMapperList();
|
|
|
Set<Integer> collect = newTeacherMapperList.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
|
|
|
if (newTeacherMapperList.size() != collect.size()) {
|
|
|
throw new BizException("主教与助教存在冲突");
|