mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-11 03:46:50 +08:00
作业导出
This commit is contained in:
@@ -31,6 +31,7 @@ import com.xboe.module.course.vo.TeacherVo;
|
|||||||
import com.xboe.module.usergroup.entity.UserGroupItem;
|
import com.xboe.module.usergroup.entity.UserGroupItem;
|
||||||
import com.xboe.school.study.entity.StudyHomeWork;
|
import com.xboe.school.study.entity.StudyHomeWork;
|
||||||
import com.xboe.school.study.service.IStudyHomeWorkService;
|
import com.xboe.school.study.service.IStudyHomeWorkService;
|
||||||
|
import com.xboe.school.study.service.IStudyService;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
@@ -102,6 +103,9 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
@Autowired
|
@Autowired
|
||||||
IStudyHomeWorkService shomeworkService;
|
IStudyHomeWorkService shomeworkService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
IStudyService studyService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
StringRedisTemplate redisTemplate;
|
StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
@@ -362,38 +366,16 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
//作业导出
|
//作业导出
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public void export(String contentId, String courseName,String studentName,HttpServletResponse response) throws IOException {
|
public void export(String courseName,String courseId,String contentId,String name,Integer status,HttpServletResponse response) throws IOException {
|
||||||
// 将courseId以逗号分割转换为list
|
|
||||||
List<String> studentNames = Arrays.asList(studentName.split(","));
|
|
||||||
Map<String, String>map=new HashMap<>();
|
Map<String, String>map=new HashMap<>();
|
||||||
try {
|
try {
|
||||||
// homeworkDao.findList(FieldFilters.in("content_id", contentIds)).stream().filter(Objects::nonNull).forEach(e -> {
|
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->{
|
||||||
// CourseContent courseContent=contentService.getById(e.getContentId());
|
//取作业后缀名
|
||||||
// if(courseContent!=null &&courseContent.getContentName()==null){
|
int dotIndex = e.getFilePath().lastIndexOf('/'); // 查找最后一个'.'的位置
|
||||||
// courseContent.setContentName("作业");
|
String extension = e.getFilePath().substring(dotIndex+1);
|
||||||
// }
|
map.put(extension,e.getFilePath());
|
||||||
// //查询目录
|
});
|
||||||
// List<CourseSection> 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());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -95,4 +95,6 @@ public interface IStudyService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
PageList<StudyCourseItem> findItemPage(int pageIndex,int pageSize,String contentId,String courseId,String name,Integer status);
|
PageList<StudyCourseItem> findItemPage(int pageIndex,int pageSize,String contentId,String courseId,String name,Integer status);
|
||||||
|
|
||||||
|
List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,6 +193,34 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<StudyCourseItem> 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
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress,String token) {
|
public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress,String token) {
|
||||||
|
|||||||
Reference in New Issue
Block a user