|
@@ -275,7 +275,7 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
|
currentPage=currentPage.add(BigDecimal.ONE);
|
|
|
}
|
|
|
|
|
|
- studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString());
|
|
|
+ studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(), null);
|
|
|
|
|
|
BigDecimal currentPage1=BigDecimal.ONE,
|
|
|
pageSize1=new BigDecimal(10000),
|
|
@@ -427,59 +427,174 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
|
}
|
|
|
|
|
|
if(!CollectionUtils.isEmpty(results)){
|
|
|
-// studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString());
|
|
|
- BigDecimal currentPage1=BigDecimal.ONE,
|
|
|
- pageSize1=new BigDecimal(10000),
|
|
|
- total1=new BigDecimal(results.size()),
|
|
|
- totalPage1=total1.divide(pageSize1, BigDecimal.ROUND_UP);
|
|
|
|
|
|
- while (currentPage1.compareTo(totalPage1)<=0){
|
|
|
- List<StudentExtracurricularExercisesSituation> rows=results.stream().skip(pageSize1.multiply(currentPage1.subtract(BigDecimal.ONE)).longValue()).limit(pageSize1.longValue()).collect(Collectors.toList());
|
|
|
- List<Integer> updateStudentIds = rows.stream().map(StudentExtracurricularExercisesSituation::getStudentId).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isEmpty(studentIds)){
|
|
|
+ studentIds = results.stream().map(StudentExtracurricularExercisesSituation::getStudentId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
|
|
|
- List<StudentExtracurricularExercisesSituation> weekServiceWithStudents = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(monDayDate.toString(), null, updateStudentIds);
|
|
|
- Map<String, StudentExtracurricularExercisesSituation> codeServeMap = weekServiceWithStudents.stream().collect(Collectors.toMap(StudentExtracurricularExercisesSituation::getStuAndTeaCode, s -> s, (s1, s2) -> s1));
|
|
|
+ Map<Integer, List<StudentServeCourseHomeworkDto>> studentHomeworkMap=new HashMap<>();
|
|
|
+ Map<Integer, List<ExtracurricularExercisesReply>> studentExercisesMap=new HashMap<>();
|
|
|
|
|
|
- Set<String> newCodes = rows.stream().map(StudentExtracurricularExercisesSituation::getStuAndTeaCode).collect(Collectors.toSet());
|
|
|
- for (StudentExtracurricularExercisesSituation weekServiceWithStudent : weekServiceWithStudents) {
|
|
|
- if(weekServiceWithStudent.getActualExercisesNum()>0||newCodes.contains(weekServiceWithStudent.getStuAndTeaCode())){
|
|
|
- continue;
|
|
|
+ List<StudentServeCourseHomeworkDto> allStudentHomeworks = studentCourseHomeworkDao.findStudentHomeworkWithCourseDateRange(monDayDate.toString(), sunDayDate.toString(), new ArrayList<>(studentIds));
|
|
|
+ List<StudentServeCourseHomeworkDto> studentHomeworksTmp =new ArrayList<>();
|
|
|
+ for (StudentServeCourseHomeworkDto studentHomework : allStudentHomeworks) {
|
|
|
+ LocalDate courseStartLocalDate = LocalDateTime.ofInstant(studentHomework.getCourseStartTime().toInstant(), DateUtil.zoneId).toLocalDate();
|
|
|
+ switch (courseStartLocalDate.getDayOfWeek()){
|
|
|
+ case SATURDAY:
|
|
|
+ if(DateUtil.daysBetween(studentHomework.getCourseStartTime(), studentHomework.getHomeworkCreateTime())<4){
|
|
|
+ studentHomeworksTmp.add(studentHomework);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case SUNDAY:
|
|
|
+ if(DateUtil.daysBetween(studentHomework.getCourseStartTime(), studentHomework.getHomeworkCreateTime())<3){
|
|
|
+ studentHomeworksTmp.add(studentHomework);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ LocalDate homeworkCreateTime = LocalDateTime.ofInstant(studentHomework.getHomeworkCreateTime().toInstant(), DateUtil.zoneId).toLocalDate();
|
|
|
+ if(courseStartLocalDate.get(DateUtil.weekFields.weekOfYear())==homeworkCreateTime.get(DateUtil.weekFields.weekOfYear())){
|
|
|
+ studentHomeworksTmp.add(studentHomework);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!CollectionUtils.isEmpty(studentHomeworksTmp)){
|
|
|
+ studentHomeworkMap = studentHomeworksTmp.stream()
|
|
|
+ .collect(Collectors.groupingBy(StudentServeCourseHomeworkDto::getUserId));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<ExtracurricularExercisesReply> allStudentExercises = extracurricularExercisesReplyDao.getStudentExercisesWithTimeZone(monDayDate.toString(), sunDayDate.toString(), new ArrayList<>(studentIds));
|
|
|
+ if(!CollectionUtils.isEmpty(allStudentExercises)){
|
|
|
+ studentExercisesMap = allStudentExercises.stream().collect(Collectors.groupingBy(ExtracurricularExercisesReply::getUserId));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (StudentExtracurricularExercisesSituation weekServiceWithStudent : results) {
|
|
|
+ List<StudentServeCourseHomeworkDto> studentAllHomeworks = studentHomeworkMap.get(weekServiceWithStudent.getStudentId());
|
|
|
+ weekServiceWithStudent.setActualExercisesNum(0);
|
|
|
+ if(!CollectionUtils.isEmpty(studentAllHomeworks)&&weekServiceWithStudent.getServeType().equals("HOMEWORK")){
|
|
|
+ Set<String> courseIds = Arrays.stream(weekServiceWithStudent.getCourseIds().split(",")).collect(Collectors.toSet());
|
|
|
+ List<StudentServeCourseHomeworkDto> studentHomeworks = studentAllHomeworks.stream().filter(s -> courseIds.contains(s.getCourseScheduleId())).collect(Collectors.toList());
|
|
|
+ weekServiceWithStudent.setActualExercisesNum(1);
|
|
|
+ long replyNum = studentHomeworks.stream().filter(e -> YesOrNoEnum.YES.equals(e.getStatus())).count();
|
|
|
+ weekServiceWithStudent.setExercisesReplyNum(replyNum>0?1:0);
|
|
|
+ long haveSubmitTimes = studentHomeworks.stream().filter(e -> Objects.nonNull(e.getSubmitTime())).count();
|
|
|
+ if(replyNum>0&&haveSubmitTimes>0){
|
|
|
+ Date lastSubmitTime = studentHomeworks.stream().filter(e->Objects.nonNull(e.getSubmitTime())).max(Comparator.comparing(StudentServeCourseHomeworkDto::getSubmitTime)).get().getSubmitTime();
|
|
|
+ weekServiceWithStudent.setLastSubmitTime(lastSubmitTime);
|
|
|
}
|
|
|
- studentExtracurricularExercisesSituationDao.delete(weekServiceWithStudent.getId());
|
|
|
+ int exercisesMessageNum=0;
|
|
|
+ int exercisesMessageTimelyNum=0;
|
|
|
+ for (StudentServeCourseHomeworkDto studentHomework : studentHomeworks) {
|
|
|
+ if(!YesOrNoEnum.YES.equals(studentHomework.getStatus())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(!YesOrNoEnum.YES.equals(studentHomework.getIsReplied())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ exercisesMessageNum+=1;
|
|
|
+ if(new Integer(1).equals(studentHomework.getIsRepliedTimely())){
|
|
|
+ exercisesMessageTimelyNum+=1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ weekServiceWithStudent.setExercisesMessageNum(exercisesMessageNum>0?1:0);
|
|
|
+ weekServiceWithStudent.setExercisesMessageTimelyNum(exercisesMessageTimelyNum>0?1:0);
|
|
|
}
|
|
|
|
|
|
- List<StudentExtracurricularExercisesSituation> newService = new ArrayList<>();
|
|
|
- List<StudentExtracurricularExercisesSituation> updateService = new ArrayList<>();
|
|
|
- for (StudentExtracurricularExercisesSituation result : rows) {
|
|
|
- if(codeServeMap.containsKey(result.getStuAndTeaCode())){
|
|
|
- StudentExtracurricularExercisesSituation s = codeServeMap.get(result.getStuAndTeaCode());
|
|
|
- Set<Long> courseIds = new HashSet<>();
|
|
|
-// if(StringUtils.isNotBlank(s.getCourseIds())&&s.getActualExercisesNum()>0){
|
|
|
-// courseIds = Arrays.stream(s.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet());
|
|
|
-// }
|
|
|
- if(StringUtils.isNotBlank(result.getCourseIds())){
|
|
|
- courseIds.addAll(Arrays.stream(result.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet()));
|
|
|
+ List<ExtracurricularExercisesReply> studentAllExercises = studentExercisesMap.get(weekServiceWithStudent.getStudentId());
|
|
|
+ if(!CollectionUtils.isEmpty(studentAllExercises)&&weekServiceWithStudent.getServeType().equals("EXERCISE")){
|
|
|
+ List<ExtracurricularExercisesReply> studentExercises = studentAllExercises.stream().filter(s -> weekServiceWithStudent.getTeacherId().equals(s.getExtracurricularExercises().getTeacherId())).collect(Collectors.toList());
|
|
|
+ weekServiceWithStudent.setActualExercisesNum(1);
|
|
|
+ long replyNum = studentExercises.stream().filter(e -> e.getStatus()==1).count();
|
|
|
+ if(weekServiceWithStudent.getExercisesReplyNum()<=0){
|
|
|
+ weekServiceWithStudent.setExercisesReplyNum(replyNum>0?1:0);
|
|
|
+ }
|
|
|
+ long haveSubmitTimes = studentExercises.stream().filter(e->Objects.nonNull(e.getSubmitTime())).count();
|
|
|
+ if(replyNum>0&&haveSubmitTimes>0){
|
|
|
+ Date lastSubmitTime = studentExercises.stream().filter(e->Objects.nonNull(e.getSubmitTime())).max(Comparator.comparing(ExtracurricularExercisesReply::getSubmitTime)).get().getSubmitTime();
|
|
|
+ if(Objects.isNull(weekServiceWithStudent.getLastSubmitTime())||lastSubmitTime.after(weekServiceWithStudent.getLastSubmitTime())){
|
|
|
+ weekServiceWithStudent.setLastSubmitTime(lastSubmitTime);
|
|
|
}
|
|
|
- s.setServeType(result.getServeType());
|
|
|
- if(s.getServeType().equals("HOMEWORK")){
|
|
|
- s.setCourseIds(StringUtils.join(courseIds, ","));
|
|
|
- }else{
|
|
|
- s.setCourseIds("");
|
|
|
+ }
|
|
|
+ int exercisesMessageNum=0;
|
|
|
+ int exercisesMessageTimelyNum=0;
|
|
|
+ for (ExtracurricularExercisesReply studentHomework : studentExercises) {
|
|
|
+ if(!new Integer(1).equals(studentHomework.getStatus())){
|
|
|
+ continue;
|
|
|
}
|
|
|
- if(StringUtils.isBlank(s.getCourseIds())){
|
|
|
- s.setExpectExercisesNum(1);
|
|
|
- }else{
|
|
|
- s.setExpectExercisesNum(courseIds.size());
|
|
|
+ if(!new Integer(1).equals(studentHomework.getIsReplied())){
|
|
|
+ continue;
|
|
|
}
|
|
|
- updateService.add(s);
|
|
|
- }else{
|
|
|
- newService.add(result);
|
|
|
+ exercisesMessageNum+=1;
|
|
|
+ if(new Integer(1).equals(studentHomework.getIsRepliedTimely())){
|
|
|
+ exercisesMessageTimelyNum+=1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(weekServiceWithStudent.getExercisesMessageNum()<=0){
|
|
|
+ weekServiceWithStudent.setExercisesMessageNum(exercisesMessageNum>0?1:0);
|
|
|
+ }
|
|
|
+ if(weekServiceWithStudent.getExercisesMessageTimelyNum()<=0){
|
|
|
+ weekServiceWithStudent.setExercisesMessageTimelyNum(exercisesMessageTimelyNum>0?1:0);
|
|
|
}
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(updateService))
|
|
|
- studentExtracurricularExercisesSituationDao.batchUpdate(updateService);
|
|
|
- if(!CollectionUtils.isEmpty(newService))
|
|
|
- studentExtracurricularExercisesSituationDao.batchInsert(newService);
|
|
|
+ }
|
|
|
+
|
|
|
+ studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(), studentIds);
|
|
|
+
|
|
|
+ BigDecimal currentPage1=BigDecimal.ONE,
|
|
|
+ pageSize1=new BigDecimal(10000),
|
|
|
+ total1=new BigDecimal(results.size()),
|
|
|
+ totalPage1=total1.divide(pageSize1, BigDecimal.ROUND_UP);
|
|
|
+
|
|
|
+ while (currentPage1.compareTo(totalPage1)<=0){
|
|
|
+ List<StudentExtracurricularExercisesSituation> rows=results.stream().skip(pageSize1.multiply(currentPage1.subtract(BigDecimal.ONE)).longValue()).limit(pageSize1.longValue()).collect(Collectors.toList());
|
|
|
+// List<Integer> updateStudentIds = rows.stream().map(StudentExtracurricularExercisesSituation::getStudentId).collect(Collectors.toList());
|
|
|
+//
|
|
|
+// List<StudentExtracurricularExercisesSituation> weekServiceWithStudents = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(monDayDate.toString(), null, updateStudentIds);
|
|
|
+// Map<String, StudentExtracurricularExercisesSituation> codeServeMap = weekServiceWithStudents.stream().collect(Collectors.toMap(StudentExtracurricularExercisesSituation::getStuAndTeaCode, s -> s, (s1, s2) -> s1));
|
|
|
+//
|
|
|
+// Set<String> newCodes = rows.stream().map(StudentExtracurricularExercisesSituation::getStuAndTeaCode).collect(Collectors.toSet());
|
|
|
+// for (StudentExtracurricularExercisesSituation weekServiceWithStudent : weekServiceWithStudents) {
|
|
|
+// if(weekServiceWithStudent.getActualExercisesNum()>0||newCodes.contains(weekServiceWithStudent.getStuAndTeaCode())){
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// studentExtracurricularExercisesSituationDao.delete(weekServiceWithStudent.getId());
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<StudentExtracurricularExercisesSituation> newService = new ArrayList<>();
|
|
|
+// List<StudentExtracurricularExercisesSituation> updateService = new ArrayList<>();
|
|
|
+// for (StudentExtracurricularExercisesSituation result : rows) {
|
|
|
+// if(codeServeMap.containsKey(result.getStuAndTeaCode())){
|
|
|
+// StudentExtracurricularExercisesSituation s = codeServeMap.get(result.getStuAndTeaCode());
|
|
|
+// Set<Long> courseIds = new HashSet<>();
|
|
|
+// if(StringUtils.isNotBlank(s.getCourseIds())&&s.getActualExercisesNum()>0){
|
|
|
+// courseIds = Arrays.stream(s.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet());
|
|
|
+// }
|
|
|
+// if(StringUtils.isNotBlank(result.getCourseIds())){
|
|
|
+// courseIds.addAll(Arrays.stream(result.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet()));
|
|
|
+// }
|
|
|
+// s.setServeType(result.getServeType());
|
|
|
+// if(s.getServeType().equals("HOMEWORK")){
|
|
|
+// s.setCourseIds(StringUtils.join(courseIds, ","));
|
|
|
+// }else{
|
|
|
+// s.setCourseIds("");
|
|
|
+// }
|
|
|
+// if(StringUtils.isBlank(s.getCourseIds())){
|
|
|
+// s.setExpectExercisesNum(1);
|
|
|
+// }else{
|
|
|
+// s.setExpectExercisesNum(courseIds.size());
|
|
|
+// }
|
|
|
+// updateService.add(s);
|
|
|
+// }else{
|
|
|
+// newService.add(result);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(!CollectionUtils.isEmpty(updateService))
|
|
|
+// studentExtracurricularExercisesSituationDao.batchUpdate(updateService);
|
|
|
+// if(!CollectionUtils.isEmpty(newService))
|
|
|
+// studentExtracurricularExercisesSituationDao.batchInsert(newService);
|
|
|
+
|
|
|
+ studentExtracurricularExercisesSituationDao.batchInsert(rows);
|
|
|
|
|
|
currentPage1=currentPage1.add(BigDecimal.ONE);
|
|
|
}
|
|
@@ -489,6 +604,9 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
|
|
|
|
@Override
|
|
|
public void updateExercisesSituation(Date date,List<Integer> studentIds, Integer teacherId) {
|
|
|
+ if(true){
|
|
|
+ return;
|
|
|
+ }
|
|
|
LocalDate nowDate = LocalDateTime.ofInstant(date.toInstant(), DateUtil.zoneId).toLocalDate();
|
|
|
if(Objects.isNull(date)){
|
|
|
nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
|
|
@@ -540,9 +658,11 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
|
}
|
|
|
|
|
|
for (StudentExtracurricularExercisesSituation weekServiceWithStudent : weekServiceWithStudents) {
|
|
|
- List<StudentServeCourseHomeworkDto> studentHomeworks = studentHomeworkMap.get(weekServiceWithStudent.getStudentId());
|
|
|
+ List<StudentServeCourseHomeworkDto> studentAllHomeworks = studentHomeworkMap.get(weekServiceWithStudent.getStudentId());
|
|
|
weekServiceWithStudent.setActualExercisesNum(0);
|
|
|
- if(!CollectionUtils.isEmpty(studentHomeworks)&&weekServiceWithStudent.getServeType().equals("HOMEWORK")){
|
|
|
+ if(!CollectionUtils.isEmpty(studentAllHomeworks)&&weekServiceWithStudent.getServeType().equals("HOMEWORK")){
|
|
|
+ Set<String> courseIds = Arrays.stream(weekServiceWithStudent.getCourseIds().split(",")).collect(Collectors.toSet());
|
|
|
+ List<StudentServeCourseHomeworkDto> studentHomeworks = studentAllHomeworks.stream().filter(s -> courseIds.contains(s.getCourseScheduleId())).collect(Collectors.toList());
|
|
|
weekServiceWithStudent.setActualExercisesNum(1);
|
|
|
long replyNum = studentHomeworks.stream().filter(e -> YesOrNoEnum.YES.equals(e.getStatus())).count();
|
|
|
weekServiceWithStudent.setExercisesReplyNum(replyNum>0?1:0);
|
|
@@ -569,8 +689,9 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
|
weekServiceWithStudent.setExercisesMessageTimelyNum(exercisesMessageTimelyNum>0?1:0);
|
|
|
}
|
|
|
|
|
|
- List<ExtracurricularExercisesReply> studentExercises = studentExercisesMap.get(weekServiceWithStudent.getStudentId());
|
|
|
- if(!CollectionUtils.isEmpty(studentExercises)&&weekServiceWithStudent.getServeType().equals("EXERCISE")){
|
|
|
+ List<ExtracurricularExercisesReply> studentAllExercises = studentExercisesMap.get(weekServiceWithStudent.getStudentId());
|
|
|
+ if(!CollectionUtils.isEmpty(studentAllExercises)&&weekServiceWithStudent.getServeType().equals("EXERCISE")){
|
|
|
+ List<ExtracurricularExercisesReply> studentExercises = studentAllExercises.stream().filter(s -> weekServiceWithStudent.getTeacherId().equals(s.getExtracurricularExercises().getTeacherId())).collect(Collectors.toList());
|
|
|
weekServiceWithStudent.setActualExercisesNum(1);
|
|
|
long replyNum = studentExercises.stream().filter(e -> e.getStatus()==1).count();
|
|
|
if(weekServiceWithStudent.getExercisesReplyNum()<=0){
|