From 9b8487b0caaf915afc6da0160738554edbe4f4d2 Mon Sep 17 00:00:00 2001 From: lu Date: Tue, 30 Jul 2024 15:26:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/course/api/CoursePortalApi.java | 42 ++++++------------- .../school/study/service/IStudyService.java | 2 + .../study/service/impl/StudyServiceImpl.java | 28 +++++++++++++ 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CoursePortalApi.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CoursePortalApi.java index 2c09241d..d1566b73 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CoursePortalApi.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CoursePortalApi.java @@ -31,6 +31,7 @@ import com.xboe.module.course.vo.TeacherVo; import com.xboe.module.usergroup.entity.UserGroupItem; import com.xboe.school.study.entity.StudyHomeWork; import com.xboe.school.study.service.IStudyHomeWorkService; +import com.xboe.school.study.service.IStudyService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; @@ -102,6 +103,9 @@ public class CoursePortalApi extends ApiBaseController{ @Autowired IStudyHomeWorkService shomeworkService; + @Autowired + IStudyService studyService; + @Autowired StringRedisTemplate redisTemplate; @@ -362,38 +366,16 @@ public class CoursePortalApi extends ApiBaseController{ } //作业导出 @GetMapping("/export") - public void export(String contentId, String courseName,String studentName,HttpServletResponse response) throws IOException { -// 将courseId以逗号分割转换为list - List studentNames = Arrays.asList(studentName.split(",")); + public void export(String courseName,String courseId,String contentId,String name,Integer status,HttpServletResponse response) throws IOException { Mapmap=new HashMap<>(); try { -// homeworkDao.findList(FieldFilters.in("content_id", contentIds)).stream().filter(Objects::nonNull).forEach(e -> { -// //查询内容名称 -// CourseContent courseContent=contentService.getById(e.getContentId()); -// if(courseContent!=null &&courseContent.getContentName()==null){ -// courseContent.setContentName("作业"); -// } -// //查询目录 -// List courseSections = sectionService.getByCourseId(e.getCourseId()); -// //取作业后缀名 -// int dotIndex = e.getFile().lastIndexOf('.'); // 查找最后一个'.'的位置 -// String extension = e.getFile().substring(dotIndex); -// //判断是否有目录 -// if(!courseSections.isEmpty()){ -// map.put(courseSections.get(0).getName()+"--"+courseContent.getContentName()+extension, "/home/www/elearning/upload"+e.getFile()); -// }else { -// Course course=courseDao.get(e.getCourseId()); -// if(course==null || course.getDeleted()){ -// throw new RuntimeException("课程不存在或已被删除"); -// } -// map.put(course.getName()+"--"+courseContent.getContentName()+extension, "/home/www/elearning/upload"+e.getFile()); -// } -// }); - shomeworkService.getByStudnetNameAndContentId(studentNames,contentId).stream().filter(Objects::nonNull).filter(e->e.getFilePath()!=null).forEach(e->{ - //取作业后缀名 - int dotIndex = e.getFilePath().lastIndexOf('/'); // 查找最后一个'.'的位置 - String extension = e.getFilePath().substring(dotIndex+1); - map.put(extension,e.getFilePath()); + studyService.getList(courseId, contentId, name, status).stream().filter(Objects::nonNull).forEach(s->{ + shomeworkService.getByStudyIdAndContentId(s.getStudyId(),contentId).stream().filter(Objects::nonNull).filter(e->e.getFilePath()!=null).forEach(e->{ + //取作业后缀名 + int dotIndex = e.getFilePath().lastIndexOf('/'); // 查找最后一个'.'的位置 + String extension = e.getFilePath().substring(dotIndex+1); + map.put(extension,e.getFilePath()); + }); }); } catch (Exception e) { diff --git a/servers/boe-server-all/src/main/java/com/xboe/school/study/service/IStudyService.java b/servers/boe-server-all/src/main/java/com/xboe/school/study/service/IStudyService.java index 9b25520f..c0f1ed64 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/school/study/service/IStudyService.java +++ b/servers/boe-server-all/src/main/java/com/xboe/school/study/service/IStudyService.java @@ -95,4 +95,6 @@ public interface IStudyService { * @return */ PageList findItemPage(int pageIndex,int pageSize,String contentId,String courseId,String name,Integer status); + + List getList(String courseId, String contentId, String name, Integer status); } diff --git a/servers/boe-server-all/src/main/java/com/xboe/school/study/service/impl/StudyServiceImpl.java b/servers/boe-server-all/src/main/java/com/xboe/school/study/service/impl/StudyServiceImpl.java index d6cc2110..fca9bd70 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/school/study/service/impl/StudyServiceImpl.java +++ b/servers/boe-server-all/src/main/java/com/xboe/school/study/service/impl/StudyServiceImpl.java @@ -193,6 +193,34 @@ public class StudyServiceImpl implements IStudyService{ } + @Override + public List getList(String courseId, String contentId, String name, Integer status) { + + QueryBuilder query=QueryBuilder.from(StudyCourseItem.class); + + OrderCondition oc=OrderCondition.desc("id"); + query.addOrder(oc); + if(StringUtils.isNotBlank(contentId)) { + query.addFilter(FieldFilters.eq("contentId",contentId)); + } + if(StringUtils.isNotBlank(courseId)) { + query.addFilter(FieldFilters.eq("courseId",courseId)); + } + + if(status!=null) { + if(status==1) { + query.addFilter(FieldFilters.eq("progress", 0)); + }else { + query.addFilter(FieldFilters.eq("progress",100)); + } + + } + if(StringUtils.isNotBlank(name)) { + query.addFilter(FieldFilters.eq("aname", name)); + } + return scItemDao.findList(query.builder()); + } + @Override @Transactional public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress,String token) {