|
@@ -34,12 +34,16 @@ import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
+import static com.timevale.tgtext.text.pdf.df.*;
|
|
|
|
+
|
|
@Service
|
|
@Service
|
|
public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup> implements ClassGroupService {
|
|
public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup> implements ClassGroupService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ClassGroupDao classGroupDao;
|
|
private ClassGroupDao classGroupDao;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private SchoolDao schoolDao;
|
|
|
|
+ @Autowired
|
|
private VipGroupDao vipGroupDao;
|
|
private VipGroupDao vipGroupDao;
|
|
@Autowired
|
|
@Autowired
|
|
private VipGroupActivityDao vipGroupActivityDao;
|
|
private VipGroupActivityDao vipGroupActivityDao;
|
|
@@ -73,6 +77,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
@Autowired
|
|
@Autowired
|
|
private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
|
|
private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private StudentRegistrationService studentRegistrationService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public BaseDAO<Integer, ClassGroup> getDAO() {
|
|
public BaseDAO<Integer, ClassGroup> getDAO() {
|
|
@@ -122,6 +128,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
String userIds = classGroup.getUserIds();
|
|
String userIds = classGroup.getUserIds();
|
|
String[] userIdArr = userIds.split(",");
|
|
String[] userIdArr = userIds.split(",");
|
|
|
|
|
|
|
|
+ classGroup.setExpectStudentNum(userIdArr.length);
|
|
classGroup.setStudentNum(userIdArr.length);
|
|
classGroup.setStudentNum(userIdArr.length);
|
|
insert(classGroup);
|
|
insert(classGroup);
|
|
|
|
|
|
@@ -129,13 +136,14 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
List<ClassGroupStudentMapper> classGroupStudentList = new ArrayList<>();
|
|
List<ClassGroupStudentMapper> classGroupStudentList = new ArrayList<>();
|
|
for (String userId : userIdArr) {
|
|
for (String userId : userIdArr) {
|
|
ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
|
+ classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
|
|
classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
classGroupStudentMapper.setUserId(Integer.parseInt(userId));
|
|
classGroupStudentMapper.setUserId(Integer.parseInt(userId));
|
|
classGroupStudentMapper.setCreateTime(date);
|
|
classGroupStudentMapper.setCreateTime(date);
|
|
classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
classGroupStudentList.add(classGroupStudentMapper);
|
|
classGroupStudentList.add(classGroupStudentMapper);
|
|
StudentRegistration studentRegistration = new StudentRegistration();
|
|
StudentRegistration studentRegistration = new StudentRegistration();
|
|
- studentRegistration.setClassGroupId(classGroup.getId().toString());
|
|
|
|
|
|
+ studentRegistration.setClassGroupId(classGroup.getId());
|
|
studentRegistration.setUserId(Integer.getInteger(userId));
|
|
studentRegistration.setUserId(Integer.getInteger(userId));
|
|
studentRegistration.setMusicGroupId(classGroup.getMusicGroupId());
|
|
studentRegistration.setMusicGroupId(classGroup.getMusicGroupId());
|
|
studentRegistrationDao.updateByUserIdAndMusicGroupId(studentRegistration);
|
|
studentRegistrationDao.updateByUserIdAndMusicGroupId(studentRegistration);
|
|
@@ -166,6 +174,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
classGroup.setSubjectIdList(subjectIds);
|
|
classGroup.setSubjectIdList(subjectIds);
|
|
classGroup.setName(name);
|
|
classGroup.setName(name);
|
|
classGroup.setType(ClassGroupTypeEnum.MIX);
|
|
classGroup.setType(ClassGroupTypeEnum.MIX);
|
|
|
|
+ classGroup.setExpectStudentNum(studentNum);
|
|
|
|
+ classGroup.setStudentNum(studentNum);
|
|
classGroup.setCreateTime(date);
|
|
classGroup.setCreateTime(date);
|
|
classGroup.setUpdateTime(date);
|
|
classGroup.setUpdateTime(date);
|
|
insert(classGroup);
|
|
insert(classGroup);
|
|
@@ -335,8 +345,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<ClassGroupTeachersDto> getClassGroupAndTeachers(String musicGroupId, String type,Integer classGroupId) {
|
|
|
|
- List<ClassGroupTeachersDto> classGroupAndTeachersList = classGroupDao.findClassGroupByMusicGroupId(musicGroupId, type,classGroupId);
|
|
|
|
|
|
+ public List<ClassGroupTeachersDto> getClassGroupAndTeachers(String musicGroupId, String type, Integer classGroupId) {
|
|
|
|
+ List<ClassGroupTeachersDto> classGroupAndTeachersList = classGroupDao.findClassGroupByMusicGroupId(musicGroupId, type, classGroupId);
|
|
|
|
|
|
List<ClassGroupTeacherMapper> classGroupTeacherMapperList = classGroupTeacherMapperService.findClassGroupTeachers(classGroupAndTeachersList);
|
|
List<ClassGroupTeacherMapper> classGroupTeacherMapperList = classGroupTeacherMapperService.findClassGroupTeachers(classGroupAndTeachersList);
|
|
|
|
|
|
@@ -353,9 +363,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<ClassGroupTeachersDto> getClassGroupAndTeacherSalary(String musicGroupId, SalarySettlementTypeEnum type,Integer classGroupId) throws Exception {
|
|
|
|
|
|
+ public List<ClassGroupTeachersDto> getClassGroupAndTeacherSalary(String musicGroupId, SalarySettlementTypeEnum type, Integer classGroupId) throws Exception {
|
|
//乐团班级及班级老师
|
|
//乐团班级及班级老师
|
|
- List<ClassGroupTeachersDto> classGroupAndTeachers = getClassGroupAndTeachers(musicGroupId, "NORMAL,MIX,HIGH",classGroupId);
|
|
|
|
|
|
+ List<ClassGroupTeachersDto> classGroupAndTeachers = getClassGroupAndTeachers(musicGroupId, "NORMAL,MIX,HIGH", classGroupId);
|
|
|
|
|
|
for (ClassGroupTeachersDto classGroupAndTeacher : classGroupAndTeachers) {
|
|
for (ClassGroupTeachersDto classGroupAndTeacher : classGroupAndTeachers) {
|
|
//班级的教师列表
|
|
//班级的教师列表
|
|
@@ -381,18 +391,30 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
Map<String, Object> params = new HashMap<>();
|
|
Map<String, Object> params = new HashMap<>();
|
|
MapUtil.populateMap(params, queryInfo);
|
|
MapUtil.populateMap(params, queryInfo);
|
|
List<CourseListDto> courseListDtos = null;
|
|
List<CourseListDto> courseListDtos = null;
|
|
- int count = classGroupDao.countCoursePage(params);
|
|
|
|
|
|
+// int count = classGroupDao.countCoursePage(params);
|
|
|
|
+ Integer vipCoursesNum = classGroupDao.countStudentVipCourses(userId);
|
|
|
|
+ Integer coursesNum = classGroupDao.countStudentMusicGroupCourses(userId);
|
|
|
|
+ int count = vipCoursesNum == null?0:vipCoursesNum + (coursesNum==null?0:coursesNum);
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
pageInfo.setTotal(count);
|
|
pageInfo.setTotal(count);
|
|
params.put("offset", pageInfo.getOffset());
|
|
params.put("offset", pageInfo.getOffset());
|
|
- courseListDtos = classGroupDao.queryCoursePage(params);
|
|
|
|
|
|
+ courseListDtos = new ArrayList<>();
|
|
|
|
+ //获取学员所购买的vip课列表详情
|
|
|
|
+ List<CourseListDto> vipCourses = classGroupDao.queryStudentVipCourses(userId);
|
|
|
|
+ //获取vip课的学生列表
|
|
|
|
+ Set<String> vipIds = vipCourses.stream().map(CourseListDto::getMusicGroupId).collect(Collectors.toSet());
|
|
|
|
+ Map<String,String> vipStuNames = MapUtil.convertMybatisMap(classGroupDao.findVipStuNames(StringUtils.join(vipIds,",")));
|
|
|
|
+ //获取学员的乐团列表详情
|
|
|
|
+ courseListDtos.addAll(classGroupDao.queryStudentMusicGroupCourses(userId));
|
|
|
|
+ courseListDtos.addAll(vipCourses);
|
|
|
|
+ //获取所有教学点名称列表
|
|
|
|
+ Set<Integer> schoolIds = courseListDtos.stream().map(CourseListDto::getTeacherSchoolId).collect(Collectors.toSet());
|
|
|
|
+ Map<Integer,String> schoolNames = MapUtil.convertMybatisMap(schoolDao.queryNameByIds(StringUtils.join(schoolIds,",")));
|
|
|
|
+// courseListDtos = classGroupDao.queryCoursePage(params);
|
|
courseListDtos.forEach(e -> {
|
|
courseListDtos.forEach(e -> {
|
|
|
|
+ e.setAddress(schoolNames.get(e.getTeacherSchoolId()));
|
|
if (ClassGroupTypeEnum.VIP == e.getType()) {
|
|
if (ClassGroupTypeEnum.VIP == e.getType()) {
|
|
- //获取vip课的学生名称列表
|
|
|
|
- List<String> vipStuNames = classGroupDao.findVipStuNames(e.getMusicGroupId());
|
|
|
|
- if (vipStuNames != null && vipStuNames.size() > 0) {
|
|
|
|
- e.setStudentNames(StringUtils.join(vipStuNames, ","));
|
|
|
|
- }
|
|
|
|
|
|
+ e.setStudentNames(vipStuNames.get(e.getMusicGroupId()));
|
|
if (e.getOffLineClassesNum() > 0 && e.getOffLineClassesNum() <= 0) {
|
|
if (e.getOffLineClassesNum() > 0 && e.getOffLineClassesNum() <= 0) {
|
|
e.setClassMode(1);
|
|
e.setClassMode(1);
|
|
} else if (e.getOffLineClassesNum() > 0 && e.getOffLineClassesNum() > 0) {
|
|
} else if (e.getOffLineClassesNum() > 0 && e.getOffLineClassesNum() > 0) {
|
|
@@ -402,12 +424,6 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
} else {
|
|
} else {
|
|
e.setClassMode(0);
|
|
e.setClassMode(0);
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- //获取学员乐团课的续费状态
|
|
|
|
- MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, e.getMusicGroupId());
|
|
|
|
- if (musicGroupStudentFee != null) {
|
|
|
|
- e.setPaymentStatus(musicGroupStudentFee.getPaymentStatus());
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -430,10 +446,13 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
//获取乐团群用户总数map
|
|
//获取乐团群用户总数map
|
|
List<Map<String, BigDecimal>> musicGroupUserNums = musicGroupDao.countMusicGroupUserNum(musicGroupIds);
|
|
List<Map<String, BigDecimal>> musicGroupUserNums = musicGroupDao.countMusicGroupUserNum(musicGroupIds);
|
|
Map<String, BigDecimal> musicGroupUserNumMap = MapUtil.convertMybatisMap(musicGroupUserNums);
|
|
Map<String, BigDecimal> musicGroupUserNumMap = MapUtil.convertMybatisMap(musicGroupUserNums);
|
|
- imGroupModels.forEach(e -> {
|
|
|
|
- MusicGroup musicGroup = musicGroups.stream().filter(mg -> mg.getId().equals(e.getId())).findFirst().get();
|
|
|
|
|
|
+ MusicGroup musicGroup;
|
|
|
|
+ Set<Integer> teachers;
|
|
|
|
+ for (ImGroupModel e:imGroupModels) {
|
|
|
|
+ teachers = e.getName() == null?new HashSet<>():new HashSet(Arrays.asList(e.getName().split(",")));
|
|
|
|
+ musicGroup = musicGroups.stream().filter(mg -> mg.getId().equals(e.getId())).findFirst().get();
|
|
//获取教学老师id列表
|
|
//获取教学老师id列表
|
|
- Set<Integer> teachers = musicGroupDao.queryTeacherIds(e.getId());
|
|
|
|
|
|
+// Set<Integer> teachers = musicGroupDao.queryTeacherIds(e.getId());
|
|
teachers.add(musicGroup.getTeamTeacherId());
|
|
teachers.add(musicGroup.getTeamTeacherId());
|
|
teachers.add(musicGroup.getEducationalTeacherId());
|
|
teachers.add(musicGroup.getEducationalTeacherId());
|
|
teachers.add(musicGroup.getOperatorUserId());
|
|
teachers.add(musicGroup.getOperatorUserId());
|
|
@@ -443,7 +462,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
BigDecimal count = musicGroupUserNumMap.get(e.getId());
|
|
BigDecimal count = musicGroupUserNumMap.get(e.getId());
|
|
e.setCount(count == null ? 0 : count.intValue() + teachers.size());
|
|
e.setCount(count == null ? 0 : count.intValue() + teachers.size());
|
|
e.setId("mg" + e.getId());
|
|
e.setId("mg" + e.getId());
|
|
- });
|
|
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
imGroupModels = new ArrayList<>();
|
|
imGroupModels = new ArrayList<>();
|
|
}
|
|
}
|
|
@@ -559,7 +578,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
throw new BizException("请登录");
|
|
throw new BizException("请登录");
|
|
}
|
|
}
|
|
|
|
|
|
- if(StringUtils.isBlank(type)){
|
|
|
|
|
|
+ if (StringUtils.isBlank(type)) {
|
|
throw new BizException("请指定课程类型");
|
|
throw new BizException("请指定课程类型");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -714,67 +733,266 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public ClassGroup classGroupAdjust(ClassGroupAdjustDto classGroupAdjustDto) throws Exception {
|
|
|
|
|
|
+ public ClassGroup classGroupAdjust(ClassGroup4MixDto classGroup4MixDto) throws Exception {
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
- MusicGroup musicGroup = musicGroupDao.get(classGroupAdjustDto.getMusicGroupId());
|
|
|
|
|
|
+ String musicGroupId = classGroup4MixDto.getMusicGroupId();
|
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
if (musicGroup != null) {
|
|
if (musicGroup != null) {
|
|
throw new Exception("乐团不存在");
|
|
throw new Exception("乐团不存在");
|
|
}
|
|
}
|
|
Integer schoolId = musicGroup.getSchoolId();
|
|
Integer schoolId = musicGroup.getSchoolId();
|
|
|
|
|
|
- List<ClassGroupStudentMapperDto> classGroupStudentMapperDtoList = classGroupAdjustDto.getClassGroupStudentMapperDtoList();
|
|
|
|
- String subjectIdList = "";
|
|
|
|
- String subjectNameList = "";
|
|
|
|
- for (ClassGroupStudentMapperDto classGroupStudentMapperDto : classGroupStudentMapperDtoList) {
|
|
|
|
- //1、永久调整,删除学生班级关联关系
|
|
|
|
- if (classGroupAdjustDto.getType().equals(YesOrNoEnum.YES)) {
|
|
|
|
- ClassGroupStudentMapper classStudentMapper = classGroupStudentMapperDao.query(classGroupStudentMapperDto.getClassGroupId(), classGroupStudentMapperDto.getUserId());
|
|
|
|
- classStudentMapper.setStatus(ClassGroupStudentStatusEnum.QUIT);
|
|
|
|
- classGroupStudentMapperDao.update(classStudentMapper);
|
|
|
|
- } else { //临时删除学生对应时间段的课程
|
|
|
|
- List<CourseSchedule> courseScheduleList = courseScheduleDao.findCourseScheduleByClassGroupIdAndDate(classGroupStudentMapperDto.getClassGroupId(), classGroupAdjustDto.getStartDate(), classGroupAdjustDto.getCourseTimes());
|
|
|
|
- courseScheduleStudentPaymentDao.deleteStudentCourseSchedule(classGroupStudentMapperDto.getUserId(), courseScheduleList);
|
|
|
|
|
|
+ List<Integer> subjectIdSet = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ List<Integer> studentIdList = classGroup4MixDto.getStudents();
|
|
|
|
+ List<StudentRegistration> studentList = studentRegistrationService.findStudentListByUserIdList(musicGroupId, studentIdList);
|
|
|
|
+ for (StudentRegistration student : studentList) {
|
|
|
|
+ subjectIdSet.add(student.getSubjectId());
|
|
|
|
+ }
|
|
|
|
+ List<Subject> subjectList = subjectService.findBySubjectByIdList(subjectIdSet);
|
|
|
|
+
|
|
|
|
+ String subjectIds = "";
|
|
|
|
+ String subjectNames = "";
|
|
|
|
+ for (Subject subject : subjectList) {
|
|
|
|
+ subjectIds += subject.getId() + ",";
|
|
|
|
+ subjectNames += subject.getName() + "/";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ subjectIds = subjectIds.substring(0, subjectIds.length() - 1);
|
|
|
|
+ subjectNames = subjectNames.substring(0, subjectNames.length() - 1);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //1、新建班级
|
|
|
|
+ ClassGroup classGroup = new ClassGroup();
|
|
|
|
+ classGroup.setMusicGroupId(classGroup4MixDto.getMusicGroupId());
|
|
|
|
+ classGroup.setSubjectIdList(subjectIds);
|
|
|
|
+ classGroup.setName(classGroup4MixDto.getClassGroupName());
|
|
|
|
+ classGroup.setExpectStudentNum(studentList.size());
|
|
|
|
+ classGroup.setStudentNum(studentList.size());
|
|
|
|
+ classGroup.setType(ClassGroupTypeEnum.NORMAL);
|
|
|
|
+ classGroup.setDelFlag(YesOrNoEnum.NO);
|
|
|
|
+ classGroup.setCreateTime(date);
|
|
|
|
+ classGroup.setUpdateTime(date);
|
|
|
|
+ classGroupDao.insert(classGroup);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //2、将学生加入新班级(学生注册表,关联表
|
|
|
|
+ List<ClassGroupStudentMapper> classGroupStudentMapperList = new ArrayList<>();
|
|
|
|
+ for (StudentRegistration studentRegistration : studentList) {
|
|
|
|
+ studentRegistration.setClassGroupId(classGroup.getId());
|
|
|
|
+ studentRegistrationService.update(studentRegistration);
|
|
|
|
+
|
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
|
|
+ classGroupStudentMapper.setUserId(studentRegistration.getUserId());
|
|
|
|
+ classGroupStudentMapper.setCreateTime(date);
|
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
|
+
|
|
|
|
+ classGroupStudentMapperList.add(classGroupStudentMapper);
|
|
|
|
+ }
|
|
|
|
+ classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMapperList);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //3、将老师加入关联关系
|
|
|
|
+ List<ClassGroupTeacherMapper> classGroupTeacherMapperList = classGroup4MixDto.getClassGroupTeacherMapperList();
|
|
|
|
+
|
|
|
|
+ //课时长度
|
|
|
|
+ long classCourseDuration = Duration.between(LocalDateTime.parse(classGroup4MixDto.getStartDate() + " " + classGroup4MixDto.getStartClassTime() + ":00"),
|
|
|
|
+ LocalDateTime.parse(classGroup4MixDto.getStartDate() + " " + classGroup4MixDto.getEndClassTime() + ":00"))
|
|
|
|
+ .toMinutes();
|
|
|
|
+
|
|
|
|
+ for (ClassGroupTeacherMapper classGroupTeacherMapper : classGroupTeacherMapperList) {
|
|
|
|
+ classGroupTeacherMapper.setClassGroupId(classGroup.getId());
|
|
|
|
+ classGroupTeacherMapper.setMusicGroupId(classGroup4MixDto.getMusicGroupId());
|
|
|
|
+
|
|
|
|
+ List<TeacherDefaultMusicGroupSalary> teacherSalaryList = teacherDefaultMusicGroupSalaryService.getTeacherSalaryByUserIdAndType(classGroupTeacherMapper.getUserId(), "SINGLE", musicGroup.getSettlementType());
|
|
|
|
+ BigDecimal salary = new BigDecimal("0");
|
|
|
|
+ for (TeacherDefaultMusicGroupSalary teacherDefaultMusicGroupSalary : teacherSalaryList) {
|
|
|
|
+ //对应基准课酬
|
|
|
|
+ BigDecimal baseSalary = classGroupTeacherMapper.getTeacherRole().equals(TeachTypeEnum.BISHOP) ? teacherDefaultMusicGroupSalary.getMainTeacherSalary() : teacherDefaultMusicGroupSalary.getAssistantTeacherSalary();
|
|
|
|
+ //基准课酬
|
|
|
|
+ if (teacherDefaultMusicGroupSalary.getSettlementType().equals(SalarySettlementTypeEnum.TEACHER_DEFAULT)) {
|
|
|
|
+ salary = new BigDecimal(classCourseDuration).divide(new BigDecimal(30)).multiply(baseSalary).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ //阶梯课酬
|
|
|
|
+ if (classCourseDuration >= teacherDefaultMusicGroupSalary.getDurationMin() && classCourseDuration <= teacherDefaultMusicGroupSalary.getDurationMin()) {
|
|
|
|
+ salary = baseSalary;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- subjectIdList += classGroupStudentMapperDto.actualSubjectId() + ",";
|
|
|
|
- subjectNameList += classGroupStudentMapperDto.getSubjectName() + "/";
|
|
|
|
|
|
+ classGroupTeacherMapper.setSalary(salary);
|
|
|
|
+ }
|
|
|
|
+ classGroupTeacherMapperDao.classGroupTeachersInsert(classGroupTeacherMapperList);
|
|
|
|
+
|
|
|
|
+ //5、插入班级排课信息
|
|
|
|
+ LocalDateTime now = LocalDate.parse(classGroup4MixDto.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
|
|
|
|
+
|
|
|
|
+ //计算每节课的课酬
|
|
|
|
+ List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaryList = new ArrayList<>();
|
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPaymentList = new ArrayList<>();
|
|
|
|
+ BigDecimal expectPrice = new BigDecimal("0");
|
|
|
|
+ int times = 0;
|
|
|
|
+ while (true) {
|
|
|
|
+ int dayOfWeek = now.getDayOfWeek().getValue();
|
|
|
|
+ if (classGroup4MixDto.getDayOfWeek().equals(dayOfWeek)) {
|
|
|
|
+ Instant instant = now.atZone(ZoneId.systemDefault()).toInstant();
|
|
|
|
+ Date classDate = Date.from(instant);
|
|
|
|
+ String startClassTime = DateUtil.getDate(classDate) + " " + classGroup4MixDto.getStartClassTime() + ":00";
|
|
|
|
+ String endClassTime = DateUtil.getDate(classDate) + " " + classGroup4MixDto.getEndClassTime() + ":00";
|
|
|
|
+
|
|
|
|
+ CourseSchedule courseSchedule = new CourseSchedule();
|
|
|
|
+ courseSchedule.setSchoolId(schoolId);
|
|
|
|
+ courseSchedule.setClassGroupId(classGroup.getId());
|
|
|
|
+ courseSchedule.setStatus(CourseStatusEnum.NOT_START);
|
|
|
|
+ courseSchedule.setClassDate(classDate);
|
|
|
|
+ courseSchedule.setStartClassTime(DateUtil.stringToDate(startClassTime));
|
|
|
|
+ courseSchedule.setEndClassTime(DateUtil.stringToDate(endClassTime));
|
|
|
|
+ courseSchedule.setCreateTime(date);
|
|
|
|
+ courseSchedule.setUpdateTime(date);
|
|
|
|
+ courseSchedule.setTeachMode(TeachModeEnum.OFFLINE);
|
|
|
|
+ courseSchedule.setType(CourseSchedule.CourseScheduleType.SINGLE);
|
|
|
|
+ courseSchedule.setName(subjectNames + "-" + CourseSchedule.CourseScheduleType.SINGLE.getMsg());
|
|
|
|
+
|
|
|
|
+ courseScheduleDao.insert(courseSchedule);
|
|
|
|
+
|
|
|
|
+ times++;
|
|
|
|
+
|
|
|
|
+ for (ClassGroupTeacherMapper classGroupTeacherMapper : classGroupTeacherMapperList) {
|
|
|
|
+ CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
|
|
|
|
+ courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
|
|
|
|
+ courseScheduleTeacherSalary.setTeacherRole(classGroupTeacherMapper.getTeacherRole());
|
|
|
|
+ courseScheduleTeacherSalary.setUserId(classGroupTeacherMapper.getUserId());
|
|
|
|
+ courseScheduleTeacherSalary.setExpectSalary(classGroupTeacherMapper.getSalary());
|
|
|
|
+ courseScheduleTeacherSalary.setClassGroupId(classGroup.getId());
|
|
|
|
+ courseScheduleTeacherSalary.setCreateTime(date);
|
|
|
|
+ courseScheduleTeacherSalary.setUpdateTime(date);
|
|
|
|
+ courseScheduleTeacherSalaryList.add(courseScheduleTeacherSalary);
|
|
|
|
+ }
|
|
|
|
+ for (StudentRegistration studentRegistration : studentList) {
|
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
|
+ courseScheduleStudentPayment.setUserId(studentRegistration.getUserId());
|
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(expectPrice);
|
|
|
|
+ courseScheduleStudentPayment.setCreateTime(date);
|
|
|
|
+ courseScheduleStudentPayment.setUpdateTime(date);
|
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
|
|
|
|
+ courseScheduleStudentPaymentList.add(courseScheduleStudentPayment);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ now = now.plusDays(1);
|
|
|
|
+ if (classGroup4MixDto.getCourseTimes().equals(times)) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //老师结算表
|
|
|
|
+ courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaryList);
|
|
|
|
+
|
|
|
|
+ //加入合奏班
|
|
|
|
+ ClassGroupRelation classGroupRelation = new ClassGroupRelation();
|
|
|
|
+ classGroupRelation.setClassGroupId(classGroup4MixDto.getMixClassGroupId());
|
|
|
|
+ classGroupRelation.setSubClassGroupId(classGroup.getId());
|
|
|
|
+ classGroupRelation.setCreateTime(date);
|
|
|
|
+ classGroupRelationService.insert(classGroupRelation);
|
|
|
|
+
|
|
|
|
+ //6、添加学生未上合奏课课程
|
|
|
|
+ List<CourseSchedule> noStartCourses = courseScheduleDao.findNoStartCoursesByClassGroupId(classGroup4MixDto.getMixClassGroupId());
|
|
|
|
+ for (CourseSchedule noStartCourse : noStartCourses) {
|
|
|
|
+ for (StudentRegistration studentRegistration : studentList) {
|
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(noStartCourse.getId());
|
|
|
|
+ courseScheduleStudentPayment.setUserId(studentRegistration.getUserId());
|
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(expectPrice);
|
|
|
|
+ courseScheduleStudentPayment.setCreateTime(date);
|
|
|
|
+ courseScheduleStudentPayment.setUpdateTime(date);
|
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(noStartCourse.getClassGroupId());
|
|
|
|
+ courseScheduleStudentPaymentList.add(courseScheduleStudentPayment);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //学生结算表
|
|
|
|
+ courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPaymentList);
|
|
|
|
+ return classGroup;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public ClassGroup classGroupUpdate(ClassGroup4MixDto classGroup4MixDto) throws Exception {
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ String musicGroupId = classGroup4MixDto.getMusicGroupId();
|
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
|
+ if (musicGroup != null) {
|
|
|
|
+ throw new Exception("乐团不存在");
|
|
|
|
+ }
|
|
|
|
+ ClassGroup classgroup = classGroupDao.get(classGroup4MixDto.getClassGroupId());
|
|
|
|
+ if (classgroup == null) {
|
|
|
|
+ throw new Exception("班级不存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Integer schoolId = musicGroup.getSchoolId();
|
|
|
|
+
|
|
|
|
+ List<Integer> subjectIdSet = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ List<Integer> studentIdList = classGroup4MixDto.getStudents();
|
|
|
|
+ List<StudentRegistration> studentList = studentRegistrationService.findStudentListByUserIdList(musicGroupId, studentIdList);
|
|
|
|
+ for (StudentRegistration student : studentList) {
|
|
|
|
+ subjectIdSet.add(student.getSubjectId());
|
|
|
|
+ }
|
|
|
|
+ List<Subject> subjectList = subjectService.findBySubjectByIdList(subjectIdSet);
|
|
|
|
+
|
|
|
|
+ String subjectIds = "";
|
|
|
|
+ String subjectNames = "";
|
|
|
|
+ for (Subject subject : subjectList) {
|
|
|
|
+ subjectIds += subject.getId() + ",";
|
|
|
|
+ subjectNames += subject.getName() + "/";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ subjectIds = subjectIds.substring(0, subjectIds.length() - 1);
|
|
|
|
+ subjectNames = subjectNames.substring(0, subjectNames.length() - 1);
|
|
|
|
|
|
- subjectIdList = subjectIdList.substring(0, subjectIdList.length() - 1);
|
|
|
|
|
|
|
|
- //2、新建班级
|
|
|
|
|
|
+ //1、新建班级
|
|
ClassGroup classGroup = new ClassGroup();
|
|
ClassGroup classGroup = new ClassGroup();
|
|
- classGroup.setMusicGroupId(classGroupAdjustDto.getMusicGroupId());
|
|
|
|
- classGroup.setSubjectIdList(subjectIdList);
|
|
|
|
- classGroup.setName(classGroupAdjustDto.getClassGroupName());
|
|
|
|
- classGroup.setExpectStudentNum(classGroupStudentMapperDtoList.size());
|
|
|
|
- classGroup.setStudentNum(classGroupStudentMapperDtoList.size());
|
|
|
|
|
|
+ classGroup.setMusicGroupId(classGroup4MixDto.getMusicGroupId());
|
|
|
|
+ classGroup.setSubjectIdList(subjectIds);
|
|
|
|
+ classGroup.setName(classGroup4MixDto.getClassGroupName());
|
|
|
|
+ classGroup.setExpectStudentNum(studentList.size());
|
|
|
|
+ classGroup.setStudentNum(studentList.size());
|
|
classGroup.setType(ClassGroupTypeEnum.NORMAL);
|
|
classGroup.setType(ClassGroupTypeEnum.NORMAL);
|
|
classGroup.setDelFlag(YesOrNoEnum.NO);
|
|
classGroup.setDelFlag(YesOrNoEnum.NO);
|
|
classGroup.setCreateTime(date);
|
|
classGroup.setCreateTime(date);
|
|
classGroup.setUpdateTime(date);
|
|
classGroup.setUpdateTime(date);
|
|
classGroupDao.insert(classGroup);
|
|
classGroupDao.insert(classGroup);
|
|
|
|
|
|
- //3、将学生加入新班级(学生注册表,关联表
|
|
|
|
|
|
+
|
|
|
|
+ //2、将学生加入新班级(学生注册表,关联表
|
|
List<ClassGroupStudentMapper> classGroupStudentMapperList = new ArrayList<>();
|
|
List<ClassGroupStudentMapper> classGroupStudentMapperList = new ArrayList<>();
|
|
- for (ClassGroupStudentMapperDto classGroupStudentMapperDto : classGroupStudentMapperDtoList) {
|
|
|
|
- classGroupStudentMapperDto.setClassGroupId(classGroup.getId());
|
|
|
|
- classGroupStudentMapperList.add(classGroupStudentMapperDto);
|
|
|
|
|
|
+ for (StudentRegistration studentRegistration : studentList) {
|
|
|
|
+ studentRegistration.setClassGroupId(classGroup.getId());
|
|
|
|
+ studentRegistrationService.update(studentRegistration);
|
|
|
|
+
|
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
|
|
+ classGroupStudentMapper.setUserId(studentRegistration.getUserId());
|
|
|
|
+ classGroupStudentMapper.setCreateTime(date);
|
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
|
+
|
|
|
|
+ classGroupStudentMapperList.add(classGroupStudentMapper);
|
|
}
|
|
}
|
|
classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMapperList);
|
|
classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMapperList);
|
|
|
|
|
|
|
|
|
|
- //4、将老师加入关联关系
|
|
|
|
- List<ClassGroupTeacherMapper> classGroupTeacherMapperList = classGroupAdjustDto.getClassGroupTeacherMapperList();
|
|
|
|
|
|
+ //3、将老师加入关联关系
|
|
|
|
+ List<ClassGroupTeacherMapper> classGroupTeacherMapperList = classGroup4MixDto.getClassGroupTeacherMapperList();
|
|
|
|
|
|
//课时长度
|
|
//课时长度
|
|
- long classCourseDuration = Duration.between(LocalDateTime.parse(classGroupAdjustDto.getStartDate() + " " + classGroupAdjustDto.getStartClassTime() + ":00"),
|
|
|
|
- LocalDateTime.parse(classGroupAdjustDto.getStartDate() + " " + classGroupAdjustDto.getEndClassTime() + ":00"))
|
|
|
|
|
|
+ long classCourseDuration = Duration.between(LocalDateTime.parse(classGroup4MixDto.getStartDate() + " " + classGroup4MixDto.getStartClassTime() + ":00"),
|
|
|
|
+ LocalDateTime.parse(classGroup4MixDto.getStartDate() + " " + classGroup4MixDto.getEndClassTime() + ":00"))
|
|
.toMinutes();
|
|
.toMinutes();
|
|
|
|
|
|
for (ClassGroupTeacherMapper classGroupTeacherMapper : classGroupTeacherMapperList) {
|
|
for (ClassGroupTeacherMapper classGroupTeacherMapper : classGroupTeacherMapperList) {
|
|
classGroupTeacherMapper.setClassGroupId(classGroup.getId());
|
|
classGroupTeacherMapper.setClassGroupId(classGroup.getId());
|
|
- classGroupTeacherMapper.setMusicGroupId(classGroupAdjustDto.getMusicGroupId());
|
|
|
|
|
|
+ classGroupTeacherMapper.setMusicGroupId(classGroup4MixDto.getMusicGroupId());
|
|
|
|
|
|
List<TeacherDefaultMusicGroupSalary> teacherSalaryList = teacherDefaultMusicGroupSalaryService.getTeacherSalaryByUserIdAndType(classGroupTeacherMapper.getUserId(), "SINGLE", musicGroup.getSettlementType());
|
|
List<TeacherDefaultMusicGroupSalary> teacherSalaryList = teacherDefaultMusicGroupSalaryService.getTeacherSalaryByUserIdAndType(classGroupTeacherMapper.getUserId(), "SINGLE", musicGroup.getSettlementType());
|
|
BigDecimal salary = new BigDecimal("0");
|
|
BigDecimal salary = new BigDecimal("0");
|
|
@@ -797,19 +1015,200 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
classGroupTeacherMapperDao.classGroupTeachersInsert(classGroupTeacherMapperList);
|
|
classGroupTeacherMapperDao.classGroupTeachersInsert(classGroupTeacherMapperList);
|
|
|
|
|
|
//5、插入班级排课信息
|
|
//5、插入班级排课信息
|
|
- LocalDateTime now = LocalDate.parse(classGroupAdjustDto.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
|
|
|
|
|
|
+ LocalDateTime now = LocalDate.parse(classGroup4MixDto.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
|
|
|
|
|
|
//计算每节课的课酬
|
|
//计算每节课的课酬
|
|
List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaryList = new ArrayList<>();
|
|
List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaryList = new ArrayList<>();
|
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPaymentList = new ArrayList<>();
|
|
|
|
+ BigDecimal expectPrice = new BigDecimal("0");
|
|
|
|
+ int times = 0;
|
|
|
|
+ while (true) {
|
|
|
|
+ int dayOfWeek = now.getDayOfWeek().getValue();
|
|
|
|
+ if (classGroup4MixDto.getDayOfWeek().equals(dayOfWeek)) {
|
|
|
|
+ Instant instant = now.atZone(ZoneId.systemDefault()).toInstant();
|
|
|
|
+ Date classDate = Date.from(instant);
|
|
|
|
+ String startClassTime = DateUtil.getDate(classDate) + " " + classGroup4MixDto.getStartClassTime() + ":00";
|
|
|
|
+ String endClassTime = DateUtil.getDate(classDate) + " " + classGroup4MixDto.getEndClassTime() + ":00";
|
|
|
|
+
|
|
|
|
+ CourseSchedule courseSchedule = new CourseSchedule();
|
|
|
|
+ courseSchedule.setSchoolId(schoolId);
|
|
|
|
+ courseSchedule.setClassGroupId(classGroup.getId());
|
|
|
|
+ courseSchedule.setStatus(CourseStatusEnum.NOT_START);
|
|
|
|
+ courseSchedule.setClassDate(classDate);
|
|
|
|
+ courseSchedule.setStartClassTime(DateUtil.stringToDate(startClassTime));
|
|
|
|
+ courseSchedule.setEndClassTime(DateUtil.stringToDate(endClassTime));
|
|
|
|
+ courseSchedule.setCreateTime(date);
|
|
|
|
+ courseSchedule.setUpdateTime(date);
|
|
|
|
+ courseSchedule.setTeachMode(TeachModeEnum.OFFLINE);
|
|
|
|
+ courseSchedule.setType(CourseSchedule.CourseScheduleType.SINGLE);
|
|
|
|
+ courseSchedule.setName(subjectNames + "-" + CourseSchedule.CourseScheduleType.SINGLE.getMsg());
|
|
|
|
+
|
|
|
|
+ courseScheduleDao.insert(courseSchedule);
|
|
|
|
+
|
|
|
|
+ times++;
|
|
|
|
+
|
|
|
|
+ for (ClassGroupTeacherMapper classGroupTeacherMapper : classGroupTeacherMapperList) {
|
|
|
|
+ CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
|
|
|
|
+ courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
|
|
|
|
+ courseScheduleTeacherSalary.setTeacherRole(classGroupTeacherMapper.getTeacherRole());
|
|
|
|
+ courseScheduleTeacherSalary.setUserId(classGroupTeacherMapper.getUserId());
|
|
|
|
+ courseScheduleTeacherSalary.setExpectSalary(classGroupTeacherMapper.getSalary());
|
|
|
|
+ courseScheduleTeacherSalary.setClassGroupId(classGroup.getId());
|
|
|
|
+ courseScheduleTeacherSalary.setCreateTime(date);
|
|
|
|
+ courseScheduleTeacherSalary.setUpdateTime(date);
|
|
|
|
+ courseScheduleTeacherSalaryList.add(courseScheduleTeacherSalary);
|
|
|
|
+ }
|
|
|
|
+ for (StudentRegistration studentRegistration : studentList) {
|
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
|
+ courseScheduleStudentPayment.setUserId(studentRegistration.getUserId());
|
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(expectPrice);
|
|
|
|
+ courseScheduleStudentPayment.setCreateTime(date);
|
|
|
|
+ courseScheduleStudentPayment.setUpdateTime(date);
|
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
|
|
|
|
+ courseScheduleStudentPaymentList.add(courseScheduleStudentPayment);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ now = now.plusDays(1);
|
|
|
|
+ if (classGroup4MixDto.getCourseTimes().equals(times)) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //老师结算表
|
|
|
|
+ courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaryList);
|
|
|
|
+
|
|
|
|
+ //加入合奏班
|
|
|
|
+ ClassGroupRelation classGroupRelation = new ClassGroupRelation();
|
|
|
|
+ classGroupRelation.setClassGroupId(classGroup4MixDto.getClassGroupId());
|
|
|
|
+ classGroupRelation.setSubClassGroupId(classGroup.getId());
|
|
|
|
+ classGroupRelation.setCreateTime(date);
|
|
|
|
+ classGroupRelationService.insert(classGroupRelation);
|
|
|
|
+
|
|
|
|
+ //6、添加学生未上合奏课课程
|
|
|
|
+ List<CourseSchedule> noStartCourses = courseScheduleDao.findNoStartCoursesByClassGroupId(classGroup4MixDto.getClassGroupId());
|
|
|
|
+ for (CourseSchedule noStartCourse : noStartCourses) {
|
|
|
|
+ for (StudentRegistration studentRegistration : studentList) {
|
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(noStartCourse.getId());
|
|
|
|
+ courseScheduleStudentPayment.setUserId(studentRegistration.getUserId());
|
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(expectPrice);
|
|
|
|
+ courseScheduleStudentPayment.setCreateTime(date);
|
|
|
|
+ courseScheduleStudentPayment.setUpdateTime(date);
|
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(noStartCourse.getClassGroupId());
|
|
|
|
+ courseScheduleStudentPaymentList.add(courseScheduleStudentPayment);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //学生结算表
|
|
|
|
+ courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPaymentList);
|
|
|
|
+ return classGroup;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public ClassGroup classGroupSnap(ClassGroup4MixDto classGroup4MixDto) throws Exception {
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ String musicGroupId = classGroup4MixDto.getMusicGroupId();
|
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
|
+ if (musicGroup != null) {
|
|
|
|
+ throw new Exception("乐团不存在");
|
|
|
|
+ }
|
|
|
|
+ Integer schoolId = musicGroup.getSchoolId();
|
|
|
|
+
|
|
|
|
+ List<Integer> subjectIdSet = new ArrayList<>();
|
|
|
|
|
|
|
|
+ List<Integer> studentIdList = classGroup4MixDto.getStudents();
|
|
|
|
+ List<StudentRegistration> studentList = studentRegistrationService.findStudentListByUserIdList(musicGroupId, studentIdList);
|
|
|
|
+ for (StudentRegistration student : studentList) {
|
|
|
|
+ subjectIdSet.add(student.getSubjectId());
|
|
|
|
+ }
|
|
|
|
+ List<Subject> subjectList = subjectService.findBySubjectByIdList(subjectIdSet);
|
|
|
|
+
|
|
|
|
+ String subjectIds = "";
|
|
|
|
+ String subjectNames = "";
|
|
|
|
+ for (Subject subject : subjectList) {
|
|
|
|
+ subjectIds += subject.getId() + ",";
|
|
|
|
+ subjectNames += subject.getName() + "/";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ subjectIds = subjectIds.substring(0, subjectIds.length() - 1);
|
|
|
|
+ subjectNames = subjectNames.substring(0, subjectNames.length() - 1);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //1、新建班级
|
|
|
|
+ ClassGroup classGroup = new ClassGroup();
|
|
|
|
+ classGroup.setMusicGroupId(classGroup4MixDto.getMusicGroupId());
|
|
|
|
+ classGroup.setSubjectIdList(subjectIds);
|
|
|
|
+ classGroup.setName(classGroup4MixDto.getClassGroupName());
|
|
|
|
+ classGroup.setExpectStudentNum(studentList.size());
|
|
|
|
+ classGroup.setStudentNum(studentList.size());
|
|
|
|
+ classGroup.setType(ClassGroupTypeEnum.SNAP);
|
|
|
|
+ classGroup.setDelFlag(YesOrNoEnum.NO);
|
|
|
|
+ classGroup.setCreateTime(date);
|
|
|
|
+ classGroup.setUpdateTime(date);
|
|
|
|
+ classGroupDao.insert(classGroup);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //2、将学生加入新班级,关联表
|
|
|
|
+ List<ClassGroupStudentMapper> classGroupStudentMapperList = new ArrayList<>();
|
|
|
|
+ for (StudentRegistration studentRegistration : studentList) {
|
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
|
|
+ classGroupStudentMapper.setUserId(studentRegistration.getUserId());
|
|
|
|
+ classGroupStudentMapper.setCreateTime(date);
|
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
|
+
|
|
|
|
+ classGroupStudentMapperList.add(classGroupStudentMapper);
|
|
|
|
+ }
|
|
|
|
+ classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMapperList);
|
|
|
|
+
|
|
|
|
+ //3、将老师加入关联关系
|
|
|
|
+ List<ClassGroupTeacherMapper> classGroupTeacherMapperList = classGroup4MixDto.getClassGroupTeacherMapperList();
|
|
|
|
+
|
|
|
|
+ //课时长度
|
|
|
|
+ long classCourseDuration = Duration.between(LocalDateTime.parse(classGroup4MixDto.getStartDate() + " " + classGroup4MixDto.getStartClassTime() + ":00"),
|
|
|
|
+ LocalDateTime.parse(classGroup4MixDto.getStartDate() + " " + classGroup4MixDto.getEndClassTime() + ":00"))
|
|
|
|
+ .toMinutes();
|
|
|
|
+
|
|
|
|
+ for (ClassGroupTeacherMapper classGroupTeacherMapper : classGroupTeacherMapperList) {
|
|
|
|
+ classGroupTeacherMapper.setClassGroupId(classGroup.getId());
|
|
|
|
+ classGroupTeacherMapper.setMusicGroupId(classGroup4MixDto.getMusicGroupId());
|
|
|
|
+
|
|
|
|
+ List<TeacherDefaultMusicGroupSalary> teacherSalaryList = teacherDefaultMusicGroupSalaryService.getTeacherSalaryByUserIdAndType(classGroupTeacherMapper.getUserId(), "SINGLE", musicGroup.getSettlementType());
|
|
|
|
+ BigDecimal salary = new BigDecimal("0");
|
|
|
|
+ for (TeacherDefaultMusicGroupSalary teacherDefaultMusicGroupSalary : teacherSalaryList) {
|
|
|
|
+ //对应基准课酬
|
|
|
|
+ BigDecimal baseSalary = classGroupTeacherMapper.getTeacherRole().equals(TeachTypeEnum.BISHOP) ? teacherDefaultMusicGroupSalary.getMainTeacherSalary() : teacherDefaultMusicGroupSalary.getAssistantTeacherSalary();
|
|
|
|
+ //基准课酬
|
|
|
|
+ if (teacherDefaultMusicGroupSalary.getSettlementType().equals(SalarySettlementTypeEnum.TEACHER_DEFAULT)) {
|
|
|
|
+ salary = new BigDecimal(classCourseDuration).divide(new BigDecimal(30)).multiply(baseSalary).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ //阶梯课酬
|
|
|
|
+ if (classCourseDuration >= teacherDefaultMusicGroupSalary.getDurationMin() && classCourseDuration <= teacherDefaultMusicGroupSalary.getDurationMin()) {
|
|
|
|
+ salary = baseSalary;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ classGroupTeacherMapper.setSalary(salary);
|
|
|
|
+ }
|
|
|
|
+ classGroupTeacherMapperDao.classGroupTeachersInsert(classGroupTeacherMapperList);
|
|
|
|
+
|
|
|
|
+ //5、插入班级排课信息
|
|
|
|
+ LocalDateTime now = LocalDate.parse(classGroup4MixDto.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
|
|
|
|
+
|
|
|
|
+ //计算每节课的课酬
|
|
|
|
+ List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaryList = new ArrayList<>();
|
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPaymentList = new ArrayList<>();
|
|
|
|
+ BigDecimal expectPrice = new BigDecimal("0");
|
|
int times = 0;
|
|
int times = 0;
|
|
while (true) {
|
|
while (true) {
|
|
int dayOfWeek = now.getDayOfWeek().getValue();
|
|
int dayOfWeek = now.getDayOfWeek().getValue();
|
|
- if (classGroupAdjustDto.getDayOfWeek().equals(dayOfWeek)) {
|
|
|
|
|
|
+ if (classGroup4MixDto.getDayOfWeek().equals(dayOfWeek)) {
|
|
Instant instant = now.atZone(ZoneId.systemDefault()).toInstant();
|
|
Instant instant = now.atZone(ZoneId.systemDefault()).toInstant();
|
|
Date classDate = Date.from(instant);
|
|
Date classDate = Date.from(instant);
|
|
- String startClassTime = DateUtil.getDate(classDate) + " " + classGroupAdjustDto.getStartClassTime() + ":00";
|
|
|
|
- String endClassTime = DateUtil.getDate(classDate) + " " + classGroupAdjustDto.getEndClassTime() + ":00";
|
|
|
|
|
|
+ String startClassTime = DateUtil.getDate(classDate) + " " + classGroup4MixDto.getStartClassTime() + ":00";
|
|
|
|
+ String endClassTime = DateUtil.getDate(classDate) + " " + classGroup4MixDto.getEndClassTime() + ":00";
|
|
|
|
|
|
CourseSchedule courseSchedule = new CourseSchedule();
|
|
CourseSchedule courseSchedule = new CourseSchedule();
|
|
courseSchedule.setSchoolId(schoolId);
|
|
courseSchedule.setSchoolId(schoolId);
|
|
@@ -822,7 +1221,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
courseSchedule.setUpdateTime(date);
|
|
courseSchedule.setUpdateTime(date);
|
|
courseSchedule.setTeachMode(TeachModeEnum.OFFLINE);
|
|
courseSchedule.setTeachMode(TeachModeEnum.OFFLINE);
|
|
courseSchedule.setType(CourseSchedule.CourseScheduleType.SINGLE);
|
|
courseSchedule.setType(CourseSchedule.CourseScheduleType.SINGLE);
|
|
- courseSchedule.setName(subjectNameList + "-" + CourseSchedule.CourseScheduleType.SINGLE.getMsg());
|
|
|
|
|
|
+ courseSchedule.setName(subjectNames + "-" + CourseSchedule.CourseScheduleType.SINGLE.getMsg());
|
|
|
|
|
|
courseScheduleDao.insert(courseSchedule);
|
|
courseScheduleDao.insert(courseSchedule);
|
|
|
|
|
|
@@ -839,14 +1238,35 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
courseScheduleTeacherSalary.setUpdateTime(date);
|
|
courseScheduleTeacherSalary.setUpdateTime(date);
|
|
courseScheduleTeacherSalaryList.add(courseScheduleTeacherSalary);
|
|
courseScheduleTeacherSalaryList.add(courseScheduleTeacherSalary);
|
|
}
|
|
}
|
|
|
|
+ for (StudentRegistration studentRegistration : studentList) {
|
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
|
+ courseScheduleStudentPayment.setUserId(studentRegistration.getUserId());
|
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(expectPrice);
|
|
|
|
+ courseScheduleStudentPayment.setCreateTime(date);
|
|
|
|
+ courseScheduleStudentPayment.setUpdateTime(date);
|
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
|
|
|
|
+ courseScheduleStudentPaymentList.add(courseScheduleStudentPayment);
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
now = now.plusDays(1);
|
|
now = now.plusDays(1);
|
|
- if (classGroupAdjustDto.getCourseTimes().equals(times)) {
|
|
|
|
|
|
+ if (classGroup4MixDto.getCourseTimes().equals(times)) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //加入合奏班
|
|
|
|
+ ClassGroupRelation classGroupRelation = new ClassGroupRelation();
|
|
|
|
+ classGroupRelation.setClassGroupId(classGroup4MixDto.getMixClassGroupId());
|
|
|
|
+ classGroupRelation.setSubClassGroupId(classGroup.getId());
|
|
|
|
+ classGroupRelation.setCreateTime(date);
|
|
|
|
+ classGroupRelationService.insert(classGroupRelation);
|
|
|
|
+
|
|
|
|
+ //老师结算表
|
|
courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaryList);
|
|
courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaryList);
|
|
|
|
+
|
|
|
|
+ //学生结算表
|
|
|
|
+ courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPaymentList);
|
|
return classGroup;
|
|
return classGroup;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -864,14 +1284,14 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
Set<Integer> classGroups = dataList.stream().map(e -> e.getClassGroupId()).collect(Collectors.toSet());
|
|
Set<Integer> classGroups = dataList.stream().map(e -> e.getClassGroupId()).collect(Collectors.toSet());
|
|
String join = StringUtils.join(classGroups, ",");
|
|
String join = StringUtils.join(classGroups, ",");
|
|
//获取主教老师
|
|
//获取主教老师
|
|
- Map<Integer,String> masterTeachers = MapUtil.convertMybatisMap(classGroupDao.countStudentNum(join, "BISHOP"));
|
|
|
|
|
|
+ Map<Integer, String> masterTeachers = MapUtil.convertMybatisMap(classGroupDao.countStudentNum(join, "BISHOP"));
|
|
//获取助教老师
|
|
//获取助教老师
|
|
- Map<Integer,String> subTeachers = MapUtil.convertMybatisMap(classGroupDao.countStudentNum(join, "TEACHING"));
|
|
|
|
|
|
+ Map<Integer, String> subTeachers = MapUtil.convertMybatisMap(classGroupDao.countStudentNum(join, "TEACHING"));
|
|
//获取在读人数
|
|
//获取在读人数
|
|
- Map<Integer,String> studyNums = MapUtil.convertMybatisMap(classGroupDao.countStudyNum(join));
|
|
|
|
|
|
+ Map<Integer, String> studyNums = MapUtil.convertMybatisMap(classGroupDao.countStudyNum(join));
|
|
//获取退班人数
|
|
//获取退班人数
|
|
- Map<Integer,String> quitNums = MapUtil.convertMybatisMap(classGroupDao.countQuitNum(join));
|
|
|
|
- dataList.forEach(e->{
|
|
|
|
|
|
+ Map<Integer, String> quitNums = MapUtil.convertMybatisMap(classGroupDao.countQuitNum(join));
|
|
|
|
+ dataList.forEach(e -> {
|
|
e.setMasterTeacher(masterTeachers.get(e.getClassGroupId()));
|
|
e.setMasterTeacher(masterTeachers.get(e.getClassGroupId()));
|
|
e.setSubTeacher(subTeachers.get(e.getClassGroupId()));
|
|
e.setSubTeacher(subTeachers.get(e.getClassGroupId()));
|
|
e.setStudyNum(studyNums.get(e.getClassGroupId()));
|
|
e.setStudyNum(studyNums.get(e.getClassGroupId()));
|
|
@@ -902,7 +1322,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
//所有课程编号的列表
|
|
//所有课程编号的列表
|
|
List<Integer> couseScheduleIds = dataList.stream().map(MusicGroupCourseScheduleDto::getCourseScheduleId).distinct().collect(Collectors.toList());
|
|
List<Integer> couseScheduleIds = dataList.stream().map(MusicGroupCourseScheduleDto::getCourseScheduleId).distinct().collect(Collectors.toList());
|
|
//获取合奏班名称
|
|
//获取合奏班名称
|
|
- Map<Integer,String> classGroupNames = MapUtil.convertMybatisMap(classGroupDao.findNameById(mixClassGroupIdsStr));
|
|
|
|
|
|
+ Map<Integer, String> classGroupNames = MapUtil.convertMybatisMap(classGroupDao.findNameById(mixClassGroupIdsStr));
|
|
|
|
|
|
//主教老师
|
|
//主教老师
|
|
List<CourseScheduleTeacherSalary> bishopTeachers = courseScheduleTeacherSalaryDao.findByCourseScheduleIdsAndTeacherRole(couseScheduleIds, "BISHOP");
|
|
List<CourseScheduleTeacherSalary> bishopTeachers = courseScheduleTeacherSalaryDao.findByCourseScheduleIdsAndTeacherRole(couseScheduleIds, "BISHOP");
|
|
@@ -910,23 +1330,23 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
|
|
|
//助教老师
|
|
//助教老师
|
|
List<CourseScheduleTeacherSalary> teachingTeachers = courseScheduleTeacherSalaryDao.findByCourseScheduleIdsAndTeacherRole(couseScheduleIds, "TEACHING");
|
|
List<CourseScheduleTeacherSalary> teachingTeachers = courseScheduleTeacherSalaryDao.findByCourseScheduleIdsAndTeacherRole(couseScheduleIds, "TEACHING");
|
|
- Map<Long, List<CourseScheduleTeacherSalary>> courseScheduleTeachingTeacherMaps=teachingTeachers.stream().collect(Collectors.groupingBy(CourseScheduleTeacherSalary::getCourseScheduleId));
|
|
|
|
|
|
+ Map<Long, List<CourseScheduleTeacherSalary>> courseScheduleTeachingTeacherMaps = teachingTeachers.stream().collect(Collectors.groupingBy(CourseScheduleTeacherSalary::getCourseScheduleId));
|
|
|
|
|
|
- dataList.forEach(e->{
|
|
|
|
|
|
+ dataList.forEach(e -> {
|
|
e.setMixClassGroupName(classGroupNames.get(e.getMixClassGroupId()));
|
|
e.setMixClassGroupName(classGroupNames.get(e.getMixClassGroupId()));
|
|
CourseScheduleTeacherSalary currentBishopTeacher = courseScheduleBishopTeacherMaps.get(e.getCourseScheduleId().longValue());
|
|
CourseScheduleTeacherSalary currentBishopTeacher = courseScheduleBishopTeacherMaps.get(e.getCourseScheduleId().longValue());
|
|
- if(!Objects.isNull(currentBishopTeacher)){
|
|
|
|
|
|
+ if (!Objects.isNull(currentBishopTeacher)) {
|
|
e.setMasterTeacherId(currentBishopTeacher.getUserId());
|
|
e.setMasterTeacherId(currentBishopTeacher.getUserId());
|
|
e.setMasterTeacherName(currentBishopTeacher.getUserName());
|
|
e.setMasterTeacherName(currentBishopTeacher.getUserName());
|
|
e.setTeacherNum(1);
|
|
e.setTeacherNum(1);
|
|
}
|
|
}
|
|
|
|
|
|
List<CourseScheduleTeacherSalary> currentCourseTeachingTeachers = courseScheduleTeachingTeacherMaps.get(e.getCourseScheduleId().longValue());
|
|
List<CourseScheduleTeacherSalary> currentCourseTeachingTeachers = courseScheduleTeachingTeacherMaps.get(e.getCourseScheduleId().longValue());
|
|
- if(CollectionUtils.isEmpty(currentCourseTeachingTeachers)){
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(currentCourseTeachingTeachers)) {
|
|
e.setTeachingTeachers(new ArrayList<>());
|
|
e.setTeachingTeachers(new ArrayList<>());
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
e.setTeachingTeachers(currentCourseTeachingTeachers);
|
|
e.setTeachingTeachers(currentCourseTeachingTeachers);
|
|
- e.setTeacherNum(e.getTeacherNum()==null?0:e.getTeacherNum() + currentCourseTeachingTeachers.size());
|
|
|
|
|
|
+ e.setTeacherNum(e.getTeacherNum() == null ? 0 : e.getTeacherNum() + currentCourseTeachingTeachers.size());
|
|
}
|
|
}
|
|
|
|
|
|
});
|
|
});
|
|
@@ -938,9 +1358,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
return pageInfo;
|
|
return pageInfo;
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public boolean batchIncreaseClassTimes(List<Integer> classGroupList) {
|
|
|
|
- classGroupDao.batchIncreaseClassTimes(classGroupList);
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public boolean batchIncreaseClassTimes(List<Integer> classGroupList) {
|
|
|
|
+ classGroupDao.batchIncreaseClassTimes(classGroupList);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|