|
@@ -3,10 +3,7 @@ package com.ym.mec.biz.service.impl;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
-import com.ym.mec.biz.dal.dto.CourseHomeworkStudentDetailDto;
|
|
|
-import com.ym.mec.biz.dal.dto.SimpleUserDto;
|
|
|
-import com.ym.mec.biz.dal.dto.StudentCourseHomeworkDto;
|
|
|
-import com.ym.mec.biz.dal.dto.StudentHomeworkRecordDto;
|
|
|
+import com.ym.mec.biz.dal.dto.*;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
@@ -24,6 +21,7 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -60,6 +58,10 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
|
|
|
private TeacherDao teacherDao;
|
|
|
@Autowired
|
|
|
private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentDao studentDao;
|
|
|
+ @Autowired
|
|
|
+ private SubjectDao subjectDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, StudentCourseHomework> getDAO() {
|
|
@@ -352,4 +354,78 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getCourseHomeworkDetail(CourseHomeworkQueryInfo queryInfo) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ CourseHomework courseHomework = courseHomeworkDao.findByCourseSchedule(queryInfo.getCourseScheduleId());
|
|
|
+
|
|
|
+ if(Objects.isNull(courseHomework)){
|
|
|
+ result.put("countInfo", null);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ PageInfo<StudentCourseHomeworkDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+
|
|
|
+ List<StudentCourseHomework> dataList = new ArrayList<>();
|
|
|
+ List<StudentCourseHomeworkDto> studentCourseHomeworkDtos = new ArrayList<>();
|
|
|
+ int count = studentCourseHomeworkDao.countAll(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = studentCourseHomeworkDao.queryAll(params);
|
|
|
+ Set<Integer> studentIds = dataList.stream().map(StudentCourseHomework::getUserId).collect(Collectors.toSet());
|
|
|
+ List<SimpleUserDto> usersSimpleInfo = teacherDao.getUsersSimpleInfo(new ArrayList<>(studentIds));
|
|
|
+ List<Student> students = studentDao.findByStudentIds(new ArrayList<>(studentIds));
|
|
|
+ Set<Integer> subjectIds = new HashSet<>();
|
|
|
+ for (Student student : students) {
|
|
|
+ if(StringUtils.isBlank(student.getSubjectIdList())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Set<Integer> studentSubjectIds = Arrays.stream(student.getSubjectIdList().split(",")).mapToInt(Integer::valueOf).boxed().collect(Collectors.toSet());
|
|
|
+ subjectIds.addAll(studentSubjectIds);
|
|
|
+ }
|
|
|
+ List<Subject> subjects = new ArrayList<>();
|
|
|
+ if(!CollectionUtils.isEmpty(subjectIds)){
|
|
|
+ subjects = subjectDao.findBySubjectIds(new ArrayList<>(subjectIds));
|
|
|
+ }
|
|
|
+ Map<Integer, SimpleUserDto> studentInfoMap = usersSimpleInfo.stream().collect(Collectors.toMap(SimpleUserDto::getUserId, s -> s, (s1, s2) -> s1));
|
|
|
+ Map<Integer, Student> studentMap = students.stream().collect(Collectors.toMap(Student::getUserId, s -> s, (s1, s2) -> s1));
|
|
|
+ for (StudentCourseHomework studentCourseHomework : dataList) {
|
|
|
+ StudentCourseHomeworkDto s = new StudentCourseHomeworkDto();
|
|
|
+ s.setStudentId(studentCourseHomework.getUserId());
|
|
|
+ s.setStudentName(studentInfoMap.containsKey(s.getStudentId())?studentInfoMap.get(s.getStudentId()).getNickName():"");
|
|
|
+ s.setPhone(studentInfoMap.containsKey(s.getStudentId())?studentInfoMap.get(s.getStudentId()).getPhone():"");
|
|
|
+ s.setSubjectIds(studentMap.containsKey(s.getStudentId())?studentMap.get(s.getStudentId()).getSubjectIdList():"");
|
|
|
+ if(StringUtils.isNotBlank(s.getSubjectIds())){
|
|
|
+ Set<Integer> studentSubjectIds = Arrays.stream(s.getSubjectIds().split(",")).mapToInt(Integer::valueOf).boxed().collect(Collectors.toSet());
|
|
|
+ List<String> subjectNames = subjects.stream().filter(sj -> studentSubjectIds.contains(sj.getId())).map(Subject::getName).collect(Collectors.toList());
|
|
|
+ s.setSubjectNames(StringUtils.join(subjectNames, ","));
|
|
|
+ }
|
|
|
+ s.setSubmitTime(studentCourseHomework.getSubmitTime());
|
|
|
+ s.setIsView(studentCourseHomework.getIsView().getCode());
|
|
|
+ s.setIsReplied(studentCourseHomework.getIsReplied().getCode());
|
|
|
+ s.setAttachments(studentCourseHomework.getAttachments());
|
|
|
+ studentCourseHomeworkDtos.add(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pageInfo.setRows(studentCourseHomeworkDtos);
|
|
|
+
|
|
|
+ if(queryInfo.getPage()==1){
|
|
|
+ params.put("isReplied", 1);
|
|
|
+ int repliedNum = studentCourseHomeworkDao.countAll(params);
|
|
|
+ CourseHomeworkDto courseHomeworkDto = new CourseHomeworkDto();
|
|
|
+ courseHomeworkDto.setExpectNum(courseHomework.getExpectNum());
|
|
|
+ courseHomeworkDto.setCompletedNum(courseHomework.getCompletedNum());
|
|
|
+ courseHomeworkDto.setRepliedNum(repliedNum);
|
|
|
+ courseHomeworkDto.setRepliedNum(repliedNum);
|
|
|
+ result.put("countInfo", courseHomeworkDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ result.put("pageInfo", pageInfo);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|