|
@@ -1,19 +1,15 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
-import com.ym.mec.biz.dal.dao.ExtracurricularExercisesReplyDao;
|
|
|
-import com.ym.mec.biz.dal.dao.StudentCourseHomeworkDao;
|
|
|
-import com.ym.mec.biz.dal.dao.StudentDao;
|
|
|
-import com.ym.mec.biz.dal.dao.StudentExtracurricularExercisesSituationDao;
|
|
|
+import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.StudentServeCourseHomeworkDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentServeDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentServiceHomeworkDto;
|
|
|
-import com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply;
|
|
|
-import com.ym.mec.biz.dal.entity.Student;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentExtracurricularExercisesSituation;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
import com.ym.mec.biz.dal.enums.TeachModeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
|
import com.ym.mec.biz.service.StudentServeService;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -37,6 +33,10 @@ import java.util.stream.Collectors;
|
|
|
public class StudentServeServiceImpl implements StudentServeService {
|
|
|
|
|
|
@Autowired
|
|
|
+ private CourseScheduleDao courseScheduleDao;
|
|
|
+ @Autowired
|
|
|
+ private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
|
+ @Autowired
|
|
|
private StudentDao studentDao;
|
|
|
@Autowired
|
|
|
private StudentCourseHomeworkDao studentCourseHomeworkDao;
|
|
@@ -266,4 +266,48 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
|
currentPage1=currentPage1.add(BigDecimal.ONE);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> checkeIsAssignHomework(Long courseScheduleId, String studentIdsStr) {
|
|
|
+ Map<String, Object> result=new HashMap<>();
|
|
|
+ if(Objects.isNull(courseScheduleId)&&Objects.isNull(studentIdsStr)){
|
|
|
+ result.put("isAssignHomework", 0);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ List<Integer> studentIds=new ArrayList<>();
|
|
|
+ if(StringUtils.isNotBlank(studentIdsStr)){
|
|
|
+ studentIds= Arrays.asList(studentIdsStr.split(",")).stream().map(id->Integer.valueOf(id)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ LocalDate localDate=LocalDate.now();
|
|
|
+
|
|
|
+ if(Objects.nonNull(courseScheduleId)){
|
|
|
+ CourseSchedule courseSchedule = courseScheduleDao.get(courseScheduleId);
|
|
|
+ if(Objects.isNull(courseSchedule)){
|
|
|
+ result.put("isAssignHomework", 0);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ localDate=LocalDateTime.ofInstant(courseSchedule.getClassDate().toInstant(), DateUtil.zoneId).toLocalDate();
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseSchedule(courseScheduleId);
|
|
|
+ if(CollectionUtils.isEmpty(courseScheduleStudentPayments)){
|
|
|
+ result.put("isAssignHomework", 0);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ studentIds = courseScheduleStudentPayments.stream().map(CourseScheduleStudentPayment::getUserId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ LocalDate monDayDate = localDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
|
|
|
+ LocalDate sunDayDate = localDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.SUNDAY.getValue());
|
|
|
+
|
|
|
+ Set<Integer> hss = studentCourseHomeworkDao.checkStudentHaveHomeworkInDateRange(monDayDate.toString(), sunDayDate.toString(), studentIds);
|
|
|
+ Set<Integer> ess = extracurricularExercisesReplyDao.checkStudentHaveExercisesInDateRange(monDayDate.toString(), sunDayDate.toString(), studentIds);
|
|
|
+ for (Integer studentId : studentIds) {
|
|
|
+ if(!hss.contains(studentId)&&!ess.contains(studentId)){
|
|
|
+ result.put("isAssignHomework", 1);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("isAssignHomework", 0);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|