|
@@ -1,23 +1,29 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
-import com.ym.mec.biz.dal.dto.StudentEduTeacherDto;
|
|
|
-import com.ym.mec.biz.dal.dto.StudentExercisesSituationDto;
|
|
|
-import com.ym.mec.biz.dal.dto.StudentServiceDetailDto;
|
|
|
-import com.ym.mec.biz.dal.dto.UserGroupDto;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentExtracurricularExercisesSituation;
|
|
|
+import com.ym.mec.biz.dal.dto.*;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
+import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.TeacherRemindTypeEnum;
|
|
|
import com.ym.mec.biz.dal.page.StudentExercisesSituationQueryInfo;
|
|
|
import com.ym.mec.biz.dal.page.StudentServiceDetailQueryInfo;
|
|
|
+import com.ym.mec.biz.dal.page.TeacherServeHomeworkQueryInfo;
|
|
|
+import com.ym.mec.biz.dal.page.TeacherServeQueryInfo;
|
|
|
import com.ym.mec.biz.service.StudentExtracurricularExercisesSituationService;
|
|
|
+import com.ym.mec.biz.service.SysMessageService;
|
|
|
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.service.impl.BaseServiceImpl;
|
|
|
+import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
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.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.time.DayOfWeek;
|
|
@@ -42,6 +48,18 @@ public class StudentExtracurricularExercisesSituationServiceImpl extends BaseSer
|
|
|
private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
|
@Autowired
|
|
|
private StudentRegistrationDao studentRegistrationDao;
|
|
|
+ @Autowired
|
|
|
+ private TeacherRemindDao teacherRemindDao;
|
|
|
+ @Autowired
|
|
|
+ private SysMessageService sysMessageService;
|
|
|
+ @Autowired
|
|
|
+ private StudentDao studentDao;
|
|
|
+ @Autowired
|
|
|
+ private SubjectDao subjectDao;
|
|
|
+ @Autowired
|
|
|
+ private CourseHomeworkDao courseHomeworkDao;
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupDao classGroupDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, StudentExtracurricularExercisesSituation> getDAO() {
|
|
@@ -158,6 +176,49 @@ public class StudentExtracurricularExercisesSituationServiceImpl extends BaseSer
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public PageInfo<TeacherServeDto> queryTeacherServeInfo(TeacherServeQueryInfo queryInfo) {
|
|
|
+ if(StringUtils.isNotBlank(queryInfo.getOrganId())){
|
|
|
+ List<Integer> organIds = Arrays.stream(queryInfo.getOrganId().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());
|
|
|
+ queryInfo.setOrganIds(organIds);
|
|
|
+ }
|
|
|
+ PageInfo<TeacherServeDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+
|
|
|
+ List<TeacherServeDto> dataList = null;
|
|
|
+ int count = studentExtracurricularExercisesSituationDao.countTeacherServeInfo(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = studentExtracurricularExercisesSituationDao.queryTeacherServeInfo(params);
|
|
|
+ List<Integer> teacherIds = dataList.stream().map(TeacherServeDto::getTeacherId).collect(Collectors.toList());
|
|
|
+ List<TeacherRemind> teacherReminds = teacherRemindDao.findTeachersRemindWithType(TeacherRemindTypeEnum.SERVICE, teacherIds, queryInfo.getMonday(), queryInfo.getSunday());
|
|
|
+ Map<String, Map<Integer, List<TeacherRemind>>> mondayTeacherRemindMap = new HashMap<>();
|
|
|
+ if(!CollectionUtils.isEmpty(teacherReminds)){
|
|
|
+ mondayTeacherRemindMap = teacherReminds.stream().collect(Collectors.groupingBy(e -> DateUtil.dateToString(e.getMonday(), "yyyy-MM-dd"), Collectors.groupingBy(TeacherRemind::getTeacherId)));
|
|
|
+ }
|
|
|
+ for (TeacherServeDto teacherServeDto : dataList) {
|
|
|
+ String mondayStr = DateUtil.dateToString(teacherServeDto.getMonday(), "yyyy-MM-dd");
|
|
|
+ if(!mondayTeacherRemindMap.containsKey(mondayStr)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<Integer, List<TeacherRemind>> teacherRemindMap = mondayTeacherRemindMap.get(mondayStr);
|
|
|
+ if(!teacherRemindMap.containsKey(teacherServeDto.getTeacherId())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TeacherRemind lastTeacherRemind = teacherRemindMap.get(teacherServeDto.getTeacherId()).stream().max(Comparator.comparing(TeacherRemind::getCreateTime)).get();
|
|
|
+ teacherServeDto.setOperatorName(lastTeacherRemind.getOperatorName());
|
|
|
+ teacherServeDto.setRemindDate(lastTeacherRemind.getCreateTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (count == 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<Map<String, Object>> findServiceStudentDetail(StudentServiceDetailQueryInfo queryInfo) {
|
|
|
PageInfo<StudentServiceDetailDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
@@ -193,4 +254,191 @@ public class StudentExtracurricularExercisesSituationServiceImpl extends BaseSer
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void teacherServeRemindPush(List<TeacherServeDto> teacherServes, Integer operatorId, String operatorName) {
|
|
|
+ if(CollectionUtils.isEmpty(teacherServes)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<TeacherRemind> reminds = new ArrayList<>();
|
|
|
+ for (TeacherServeDto teacherServe : teacherServes) {
|
|
|
+ if(Objects.isNull(teacherServe.getMonday())||Objects.isNull(teacherServe.getSunday())||Objects.isNull(teacherServe.getTeacherId())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String mondayStr = DateUtil.dateToString(teacherServe.getMonday(), "yyyy-MM-dd");
|
|
|
+ List<StudentExtracurricularExercisesSituation> serves = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(mondayStr, teacherServe.getTeacherId(), null);
|
|
|
+ if(CollectionUtils.isEmpty(serves)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TeacherRemind remind = new TeacherRemind();
|
|
|
+ remind.setOperatorId(operatorId);
|
|
|
+ remind.setOperatorName(operatorName);
|
|
|
+ remind.setMonday(teacherServe.getMonday());
|
|
|
+ remind.setTeacherId(teacherServe.getTeacherId());
|
|
|
+ remind.setType(TeacherRemindTypeEnum.SERVICE);
|
|
|
+ remind.setContent("作业布置提醒");
|
|
|
+ reminds.add(remind);
|
|
|
+
|
|
|
+ Map<Integer, String> userMap = new HashMap<>();
|
|
|
+ userMap.put(teacherServe.getTeacherId(), teacherServe.getTeacherId().toString());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.HOMEWORK_REMIND,
|
|
|
+ userMap, null, 0, null, "TEACHER", null);
|
|
|
+ }
|
|
|
+ if(!CollectionUtils.isEmpty(reminds)){
|
|
|
+ teacherRemindDao.batchInsert(reminds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<TeacherServeHomeworkDto> queryTeacherServeHomeworkDetail(TeacherServeHomeworkQueryInfo queryInfo) {
|
|
|
+ if(Objects.isNull(queryInfo.getMonday())||Objects.isNull(queryInfo.getSunday())||Objects.isNull(queryInfo.getTeacherId())){
|
|
|
+ throw new BizException("请指定教师");
|
|
|
+ }
|
|
|
+ PageInfo<TeacherServeHomeworkDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ String mondayStr = DateUtil.dateToString(queryInfo.getMonday(), "yyyy-MM-dd");
|
|
|
+ List<StudentExtracurricularExercisesSituation> serves = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(mondayStr, queryInfo.getTeacherId(), null);
|
|
|
+ if(CollectionUtils.isEmpty(serves)){
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+ List<StudentExtracurricularExercisesSituation> homeworkServes = serves.stream().filter(s -> "HOMEWORK".equals(s.getServeType())).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isEmpty(homeworkServes)){
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+ List<Long> courseIdsArr = new ArrayList<>();
|
|
|
+ for (StudentExtracurricularExercisesSituation homeworkServe : homeworkServes) {
|
|
|
+ if(StringUtils.isBlank(homeworkServe.getCourseIds())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<Long> ids = Arrays.stream(homeworkServe.getCourseIds().split(",")).map(id -> Long.valueOf(id)).collect(Collectors.toList());
|
|
|
+ courseIdsArr.addAll(ids);
|
|
|
+ }
|
|
|
+ if(CollectionUtils.isEmpty(courseIdsArr)){
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Long, Long> courseNumMap = courseIdsArr.stream().collect(Collectors.groupingBy(id -> id, Collectors.counting()));
|
|
|
+ Set<Long> courseIds = new HashSet<>(courseIdsArr);
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+ params.put("courseIds", courseIds);
|
|
|
+
|
|
|
+ List<TeacherServeHomeworkDto> dataList = new ArrayList<>();
|
|
|
+ int count = courseScheduleDao.countByCourseScheduleIds(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ List<CourseSchedule> courseSchedules = courseScheduleDao.queryByCourseScheduleIds(params);
|
|
|
+ List<Integer> classGroupIds = courseSchedules.stream().map(CourseSchedule::getClassGroupId).collect(Collectors.toList());
|
|
|
+ List<ClassGroup> classGroups = classGroupDao.findByClassGroupIds(classGroupIds, null);
|
|
|
+ Map<Integer, ClassGroup> idClassGroupMap = classGroups.stream().collect(Collectors.toMap(ClassGroup::getId, c -> c, (c1, c2) -> c1));
|
|
|
+
|
|
|
+ List<CourseHomework> courseHomeworks = courseHomeworkDao.findByCourseSchedules(new ArrayList<>(courseIds));
|
|
|
+ Map<Long, Long> courseHomeworkMap = new HashMap<>();
|
|
|
+ if(!CollectionUtils.isEmpty(courseHomeworks)){
|
|
|
+ courseHomeworkMap = courseHomeworks.stream().collect(Collectors.groupingBy(CourseHomework::getCourseScheduleId, Collectors.counting()));
|
|
|
+ }
|
|
|
+ List<Integer> subjectIds = new ArrayList<>();
|
|
|
+ for (CourseSchedule courseSchedule : courseSchedules) {
|
|
|
+ if(idClassGroupMap.containsKey(courseSchedule.getClassGroupId())){
|
|
|
+ List<Integer> ids = Arrays.stream(idClassGroupMap.get(courseSchedule.getClassGroupId()).getSubjectIdList().split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList());
|
|
|
+ subjectIds.addAll(ids);
|
|
|
+ }
|
|
|
+ TeacherServeHomeworkDto tshd = new TeacherServeHomeworkDto();
|
|
|
+ BeanUtils.copyProperties(courseSchedule,tshd);
|
|
|
+ tshd.setStudentNum(courseNumMap.get(courseSchedule.getId()).intValue());
|
|
|
+ if(courseHomeworkMap.containsKey(courseSchedule.getId())){
|
|
|
+ tshd.setHomeworkExist(1);
|
|
|
+ }
|
|
|
+ dataList.add(tshd);
|
|
|
+ }
|
|
|
+ List<Subject> subjects = subjectDao.findBySubjectIds(new ArrayList<>(subjectIds));
|
|
|
+ for (TeacherServeHomeworkDto teacherServeHomeworkDto : dataList) {
|
|
|
+ if(idClassGroupMap.containsKey(teacherServeHomeworkDto.getClassGroupId())){
|
|
|
+ ClassGroup classGroup = idClassGroupMap.get(teacherServeHomeworkDto.getClassGroupId());
|
|
|
+ if(StringUtils.isNotBlank(classGroup.getSubjectIdList())){
|
|
|
+ Set<Integer> sids = Arrays.stream(classGroup.getSubjectIdList().split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toSet());
|
|
|
+ List<String> subjectNames = subjects.stream().filter(s -> sids.contains(s.getId())).map(Subject::getName).collect(Collectors.toList());
|
|
|
+ teacherServeHomeworkDto.setSubjectName(StringUtils.join(subjectNames, ","));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (count == 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<TeacherServeExtraDto> queryTeacherServeExtraDetail(TeacherServeHomeworkQueryInfo queryInfo) {
|
|
|
+ if(Objects.isNull(queryInfo.getMonday())||Objects.isNull(queryInfo.getSunday())||Objects.isNull(queryInfo.getTeacherId())){
|
|
|
+ throw new BizException("请指定教师");
|
|
|
+ }
|
|
|
+ PageInfo<TeacherServeExtraDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ String mondayStr = DateUtil.dateToString(queryInfo.getMonday(), "yyyy-MM-dd");
|
|
|
+ List<StudentExtracurricularExercisesSituation> serves = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(mondayStr, queryInfo.getTeacherId(), null);
|
|
|
+ if(CollectionUtils.isEmpty(serves)){
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+ List<StudentExtracurricularExercisesSituation> homeworkServes = serves.stream().filter(s -> "EXERCISE".equals(s.getServeType())).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isEmpty(homeworkServes)){
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Integer> studentIds = homeworkServes.stream().map(StudentExtracurricularExercisesSituation::getStudentId).collect(Collectors.toSet());
|
|
|
+ Map<Integer, List<StudentExtracurricularExercisesSituation>> studentServeMap = homeworkServes.stream().collect(Collectors.groupingBy(StudentExtracurricularExercisesSituation::getStudentId));
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+ params.put("studentIds", studentIds);
|
|
|
+
|
|
|
+ List<TeacherServeExtraDto> dataList = new ArrayList<>();
|
|
|
+ int count = studentDao.countByIds(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ List<Student> students = studentDao.queryByIds(params);
|
|
|
+ List<SimpleUserDto> usersSimpleInfo = teacherDao.getUsersSimpleInfo(new ArrayList<>(studentIds));
|
|
|
+ Map<Integer, String> idNameMap = new HashMap<>();
|
|
|
+ if(!CollectionUtils.isEmpty(usersSimpleInfo)){
|
|
|
+ idNameMap = usersSimpleInfo.stream().collect(Collectors.toMap(SimpleUserDto::getUserId, s -> s.getNickName(), (s1, s2) -> s1));
|
|
|
+ }
|
|
|
+ Set<Integer> subjectIds = new HashSet<>();
|
|
|
+ for (Student student : students) {
|
|
|
+ if(StringUtils.isNotBlank(student.getSubjectIdList())){
|
|
|
+ Set<Integer> ids = Arrays.stream(student.getSubjectIdList().split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toSet());
|
|
|
+ subjectIds.addAll(ids);
|
|
|
+ }
|
|
|
+ TeacherServeExtraDto tsed = new TeacherServeExtraDto();
|
|
|
+ BeanUtils.copyProperties(student,tsed);
|
|
|
+ if(studentServeMap.containsKey(student.getUserId())){
|
|
|
+ List<StudentExtracurricularExercisesSituation> studentServes = studentServeMap.get(student.getUserId());
|
|
|
+ int num = studentServes.stream().mapToInt(StudentExtracurricularExercisesSituation::getActualExercisesNum).reduce(0, Integer::sum);
|
|
|
+ if(num>0){
|
|
|
+ tsed.setHomeworkExist(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataList.add(tsed);
|
|
|
+ }
|
|
|
+ List<Subject> subjects = subjectDao.findBySubjectIds(new ArrayList<>(subjectIds));
|
|
|
+ for (TeacherServeExtraDto teacherServeExtraDto : dataList) {
|
|
|
+ if(idNameMap.containsKey(teacherServeExtraDto.getUserId())){
|
|
|
+ teacherServeExtraDto.setUsername(idNameMap.get(teacherServeExtraDto.getUserId()));
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(teacherServeExtraDto.getSubjectIdList())){
|
|
|
+ Set<Integer> sids = Arrays.stream(teacherServeExtraDto.getSubjectIdList().split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toSet());
|
|
|
+ List<String> subjectNames = subjects.stream().filter(s -> sids.contains(s.getId())).map(Subject::getName).collect(Collectors.toList());
|
|
|
+ teacherServeExtraDto.setSubjectNames(StringUtils.join(subjectNames, ","));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (count == 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
}
|