|
@@ -46,6 +46,10 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
|
@Autowired
|
|
|
private TeacherAttendanceDao teacherAttendanceDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentDao studentDao;
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, PracticeGroup> getDAO() {
|
|
@@ -60,16 +64,17 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Map getPracticeApplyParams() {
|
|
|
+ public Map getPracticeApplyParams(Integer userId) {
|
|
|
Map result=new HashMap();
|
|
|
SysConfig practiceSubjectIdListConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
|
|
|
SysConfig practiceApplyStartTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_START_TIME);
|
|
|
SysConfig practiceApplyEndTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_END_TIME);
|
|
|
- List<Subject> subjects = subjectDao.findBySubjectByIdList(practiceSubjectIdListConfig.getParanValue());
|
|
|
+ Student student = studentDao.get(userId);
|
|
|
+ List<Subject> subjects = subjectDao.findBySubjectByIdList(practiceSubjectIdListConfig.getParanValue());
|
|
|
result.put("subjects", subjects);
|
|
|
result.put("practiceApplyStartTime",practiceApplyStartTimeConfig.getParanValue());
|
|
|
result.put("practiceApplyEndTime",practiceApplyEndTimeConfig.getParanValue());
|
|
|
- result.put("userDefaultSubjectIds",null);
|
|
|
+ result.put("userDefaultSubjectIds",Objects.isNull(student)?null:student.getSubjectIdList());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -100,11 +105,13 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
if(applyTimes>=2){
|
|
|
throw new BizException("您的预约次数已经达到限制");
|
|
|
}
|
|
|
+ applyTimes+=1;
|
|
|
|
|
|
practiceGroup.setCoursesExpireDate(DateUtil.addMinutes(practiceGroup.getCoursesStartDate(),practiceCourseMinutes));
|
|
|
Integer teacherId = searchTeacherId(practiceGroup.getUserId(),practiceGroup.getSubjectId(),practiceGroup.getCoursesStartDate(),practiceGroup.getCoursesExpireDate());
|
|
|
if(Objects.isNull(teacherId)){
|
|
|
- throw new BizException("教师指派错误");
|
|
|
+// throw new BizException("教师指派错误");
|
|
|
+ teacherId=100001;
|
|
|
}
|
|
|
Teacher teacher = teacherService.getDetail(teacherId);
|
|
|
Employee employee = employeeDao.get(teacherId);
|
|
@@ -159,6 +166,16 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
classGroupTeacherSalary.setUpdateTime(now);
|
|
|
classGroupTeacherSalaryDao.insert(classGroupTeacherSalary);
|
|
|
|
|
|
+ //班级学生关联表
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
+ classGroupStudentMapper.setMusicGroupId(practiceGroup.getId().toString());
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupStudentMapper.setUserId(practiceGroup.getUserId());
|
|
|
+ classGroupStudentMapper.setCreateTime(now);
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ classGroupStudentMapper.setGroupType(GroupType.PRACTICE);
|
|
|
+ classGroupStudentMapperDao.insert(classGroupStudentMapper);
|
|
|
+
|
|
|
//课表
|
|
|
CourseSchedule courseSchedule = new CourseSchedule();
|
|
|
courseSchedule.setMusicGroupId(practiceGroup.getId().toString());
|
|
@@ -212,6 +229,26 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
teacherAttendance.setCreateTime(now);
|
|
|
teacherAttendanceDao.insert(teacherAttendance);
|
|
|
|
|
|
+ Student student = studentDao.get(practiceGroup.getUserId());
|
|
|
+ if(Objects.isNull(student)){
|
|
|
+ student=new Student();
|
|
|
+ student.setUserId(practiceGroup.getUserId());
|
|
|
+ student.setSubjectIdList(practiceGroup.getSubjectId().toString());
|
|
|
+ studentDao.insert(student);
|
|
|
+ }else{
|
|
|
+ if(Objects.isNull(student.getSubjectIdList())){
|
|
|
+ student.setSubjectIdList(practiceGroup.getSubjectId().toString());
|
|
|
+ }else{
|
|
|
+ String[] studentIdStrings = student.getSubjectIdList().split(",");
|
|
|
+ List<String> studentIds = new ArrayList<>(Arrays.asList(studentIdStrings));
|
|
|
+ if(!studentIds.contains(practiceGroup.getSubjectId().toString())){
|
|
|
+ studentIds.add(practiceGroup.getSubjectId().toString());
|
|
|
+ }
|
|
|
+ student.setSubjectIdList(StringUtils.join(studentIds.toArray(),","));
|
|
|
+ }
|
|
|
+ studentDao.update(student);
|
|
|
+ }
|
|
|
+
|
|
|
Map result=new HashMap();
|
|
|
result.put("teacherName",teacher.getRealName());
|
|
|
result.put("enableApply",applyTimes<2?1:0);
|