|
@@ -1,27 +1,37 @@
|
|
package com.ym.mec.biz.service.impl;
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
|
|
import com.ym.mec.biz.dal.dao.CourseScheduleDao;
|
|
import com.ym.mec.biz.dal.dao.CourseScheduleDao;
|
|
import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
|
|
import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
|
|
import com.ym.mec.biz.dal.dao.StudentAttendanceDao;
|
|
import com.ym.mec.biz.dal.dao.StudentAttendanceDao;
|
|
import com.ym.mec.biz.dal.dto.StudentPersonalAttendanceDto;
|
|
import com.ym.mec.biz.dal.dto.StudentPersonalAttendanceDto;
|
|
import com.ym.mec.biz.dal.dto.StudentStatusCountUtilEntity;
|
|
import com.ym.mec.biz.dal.dto.StudentStatusCountUtilEntity;
|
|
|
|
+import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
|
|
|
|
+import com.ym.mec.biz.dal.entity.CourseSchedule;
|
|
import com.ym.mec.biz.dal.entity.StudentAttendance;
|
|
import com.ym.mec.biz.dal.entity.StudentAttendance;
|
|
|
|
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
|
|
|
|
+import com.ym.mec.biz.dal.enums.CourseStatusEnum;
|
|
import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
|
|
import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
|
|
import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
import com.ym.mec.biz.dal.page.StudentAttendanceQueryInfo;
|
|
import com.ym.mec.biz.dal.page.StudentAttendanceQueryInfo;
|
|
import com.ym.mec.biz.service.StudentAttendanceService;
|
|
import com.ym.mec.biz.service.StudentAttendanceService;
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.page.PageInfo;
|
|
import com.ym.mec.common.page.PageInfo;
|
|
import com.ym.mec.common.page.QueryInfo;
|
|
import com.ym.mec.common.page.QueryInfo;
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import com.ym.mec.util.date.DateUtil;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentAttendance> implements StudentAttendanceService {
|
|
public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentAttendance> implements StudentAttendanceService {
|
|
@@ -32,6 +42,9 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
|
|
private MusicGroupStudentFeeDao studentFeeDao;
|
|
private MusicGroupStudentFeeDao studentFeeDao;
|
|
@Autowired
|
|
@Autowired
|
|
private CourseScheduleDao courseScheduleDao;
|
|
private CourseScheduleDao courseScheduleDao;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public BaseDAO<Long, StudentAttendance> getDAO() {
|
|
public BaseDAO<Long, StudentAttendance> getDAO() {
|
|
@@ -73,7 +86,7 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
|
|
public Map<String, Object> getCurrentCourseStudents(QueryInfo queryInfo) {
|
|
public Map<String, Object> getCurrentCourseStudents(QueryInfo queryInfo) {
|
|
Map<String,Object> result=new HashMap<>();
|
|
Map<String,Object> result=new HashMap<>();
|
|
|
|
|
|
- PageInfo pageInfo = super.queryPage(queryInfo);
|
|
|
|
|
|
+ PageInfo<StudentAttendance> pageInfo = super.queryPage(queryInfo);
|
|
|
|
|
|
result.put("pageInfo",pageInfo);
|
|
result.put("pageInfo",pageInfo);
|
|
|
|
|
|
@@ -84,6 +97,8 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
|
|
case LEAVE:
|
|
case LEAVE:
|
|
result.put("numberOfLeavePeoples",studentStatusCount.getNumberOfStudent());
|
|
result.put("numberOfLeavePeoples",studentStatusCount.getNumberOfStudent());
|
|
break;
|
|
break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -92,7 +107,7 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public PageInfo getStudentPersonalAttendances(QueryInfo queryInfo) {
|
|
|
|
|
|
+ public PageInfo<StudentPersonalAttendanceDto> getStudentPersonalAttendances(QueryInfo queryInfo) {
|
|
PageInfo<StudentPersonalAttendanceDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
PageInfo<StudentPersonalAttendanceDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
MapUtil.populateMap(params, queryInfo);
|
|
MapUtil.populateMap(params, queryInfo);
|
|
@@ -110,4 +125,43 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
|
|
pageInfo.setRows(dataList);
|
|
pageInfo.setRows(dataList);
|
|
return pageInfo;
|
|
return pageInfo;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public boolean leave(Integer userId, Long courseScheduleId, String remark) {
|
|
|
|
+
|
|
|
|
+ CourseSchedule courseSchedule = courseScheduleDao.get(courseScheduleId);
|
|
|
|
+ if(courseSchedule == null){
|
|
|
|
+ throw new BizException("课程编号异常");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(courseSchedule.getStatus() == CourseStatusEnum.OVER){
|
|
|
|
+ throw new BizException("课程已结束");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Date date = new Date();
|
|
|
|
+
|
|
|
|
+ if(DateUtil.addHours(date, 2).after(courseSchedule.getStartClassTime())){
|
|
|
|
+ throw new BizException("开课2个小时之前才可以请假");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ StudentAttendance studentAttendance = new StudentAttendance();
|
|
|
|
+ studentAttendance.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
|
+ studentAttendance.setCourseScheduleId(courseScheduleId);
|
|
|
|
+ studentAttendance.setCreateTime(date);
|
|
|
|
+ studentAttendance.setCurrentClassTimes(0);
|
|
|
|
+ studentAttendance.setRemark(remark);
|
|
|
|
+ studentAttendance.setStatus(StudentAttendanceStatusEnum.LEAVE);
|
|
|
|
+ studentAttendance.setUserId(userId);
|
|
|
|
+
|
|
|
|
+ studentAttendanceDao.insert(studentAttendance);
|
|
|
|
+
|
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = classGroupStudentMapperDao.query(courseSchedule.getClassGroupId(), userId);
|
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.LEAVE);
|
|
|
|
+ classGroupStudentMapperDao.update(classGroupStudentMapper);
|
|
|
|
+
|
|
|
|
+ //发送消息至老师
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|