|
@@ -0,0 +1,70 @@
|
|
|
+package com.ym.mec.biz.service.impl;
|
|
|
+
|
|
|
+import com.ym.mec.biz.dal.dao.StudentDao;
|
|
|
+import com.ym.mec.biz.dal.dao.StudentExtracurricularExercisesSituationDao;
|
|
|
+import com.ym.mec.biz.dal.dto.StudentServeDto;
|
|
|
+import com.ym.mec.biz.dal.entity.Student;
|
|
|
+import com.ym.mec.biz.service.StudentServeService;
|
|
|
+import com.ym.mec.util.date.DateUtil;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.time.DayOfWeek;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author Joburgess
|
|
|
+ * @Date 2020.05.27
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class StudentServeServiceImpl implements StudentServeService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StudentDao studentDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void exercisesSituationStatistics(String monday) {
|
|
|
+ LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
|
|
|
+
|
|
|
+ if(nowDate.getDayOfWeek()== DayOfWeek.MONDAY){
|
|
|
+ int lastWeekTodayUpdateNum = studentExtracurricularExercisesSituationDao.findLastWeekTodayUpdateNum(nowDate.plusDays(-1).toString());
|
|
|
+ if(lastWeekTodayUpdateNum<=0){
|
|
|
+ nowDate = nowDate.plusDays(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isNotBlank(monday)){
|
|
|
+ nowDate=LocalDate.parse(monday, DateUtil.dateFormatter);
|
|
|
+ }
|
|
|
+ LocalDate monDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
|
|
|
+ LocalDate sunDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.SUNDAY.getValue());
|
|
|
+ Date nextMonday = Date.from(sunDayDate.plusDays(1).atStartOfDay(DateUtil.zoneId).toInstant());
|
|
|
+
|
|
|
+ List<StudentServeDto> serviceStudents = studentDao.getBeServiceStudents(monDayDate.toString());
|
|
|
+ if(CollectionUtils.isEmpty(serviceStudents)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //本周有课学员编号集合
|
|
|
+ Set<Integer> haveClassStudentIds=new HashSet<>();
|
|
|
+ //本周无课学员编号集合
|
|
|
+ Set<Integer> noClassStudentIds=new HashSet<>();
|
|
|
+ for (StudentServeDto serviceStudent : serviceStudents) {
|
|
|
+ if(Objects.nonNull(serviceStudent.getCourseStartTime())&&serviceStudent.getCourseStartTime().after(nextMonday)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(Objects.nonNull(serviceStudent.getCourseStartTime())){
|
|
|
+ haveClassStudentIds.add(serviceStudent.getUserId());
|
|
|
+ }else{
|
|
|
+ noClassStudentIds.add(serviceStudent.getUserId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|