mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-21 00:36:51 +08:00
作业导出,bug修复
This commit is contained in:
@@ -14,10 +14,13 @@ import com.xboe.school.study.entity.StudyCourse;
|
|||||||
import com.xboe.system.user.dao.UserDao;
|
import com.xboe.system.user.dao.UserDao;
|
||||||
import com.xboe.system.user.entity.User;
|
import com.xboe.system.user.entity.User;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -66,6 +69,10 @@ public class ThirdApi {
|
|||||||
|
|
||||||
@Value("${manageApi.editExam}")
|
@Value("${manageApi.editExam}")
|
||||||
private String editExam;
|
private String editExam;
|
||||||
|
|
||||||
|
@Value("${userBasic.getUserBasicInfo}")
|
||||||
|
private String getUserBasicInfo;
|
||||||
|
|
||||||
//获取例外人员的id
|
//获取例外人员的id
|
||||||
public List<String> getUserId(){
|
public List<String> getUserId(){
|
||||||
String responseBody = Optional.ofNullable(HttpRequest.get(infarasApiUrl+"?pid=316&type=1").execute() //prod 316
|
String responseBody = Optional.ofNullable(HttpRequest.get(infarasApiUrl+"?pid=316&type=1").execute() //prod 316
|
||||||
@@ -234,5 +241,29 @@ public class ThirdApi {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 虽然当前已存在接口查询用户基本信息,目前仅仅包括用户名、工号、用户ID
|
||||||
|
*/
|
||||||
|
public List<UserBasicInfo> getUserBasicInfoByUserId(List<String> userIds, HttpServletRequest request) {
|
||||||
|
String token = request.getHeader("Xboe-Access-Token");
|
||||||
|
if (StringUtils.isEmpty(token)) {
|
||||||
|
token = request.getHeader("token");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将userIds列表转换为逗号分隔的字符串
|
||||||
|
String userIdsStr = userIds.stream()
|
||||||
|
.collect(Collectors.joining(","));
|
||||||
|
String url = getUserBasicInfo +"?userIds=" + userIdsStr;
|
||||||
|
|
||||||
|
String respStr = Optional.ofNullable(HttpRequest
|
||||||
|
.get(url)
|
||||||
|
.header("token", token)
|
||||||
|
.execute().body()).orElseThrow(() -> new RuntimeException("用户中心用户数据获取失败"));
|
||||||
|
|
||||||
|
UserBasicInfoResult userBasicInfoResult = JSONUtil.parseObj(respStr).toBean(UserBasicInfoResult.class);
|
||||||
|
List<UserBasicInfo> basicInfos = userBasicInfoResult.getResult();
|
||||||
|
return basicInfos;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.xboe.api.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserBasicInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名。
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工号。
|
||||||
|
*/
|
||||||
|
private String workNum;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.xboe.api.vo;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Slf4j
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class UserBasicInfoResult {
|
||||||
|
|
||||||
|
private String error;
|
||||||
|
private String message;
|
||||||
|
private String permissions;
|
||||||
|
private List<UserBasicInfo> result;
|
||||||
|
private int status;
|
||||||
|
private Date timestamp;
|
||||||
|
|
||||||
|
public UserBasicInfoResult success() {
|
||||||
|
if (this.status != 200) {
|
||||||
|
log.error("获取用户基本信息失败----{}", JSONUtil.toJsonPrettyStr(this));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.xboe.api.ThirdApi;
|
import com.xboe.api.ThirdApi;
|
||||||
|
import com.xboe.api.vo.UserBasicInfo;
|
||||||
import com.xboe.core.orm.FieldFilters;
|
import com.xboe.core.orm.FieldFilters;
|
||||||
import com.xboe.module.course.entity.*;
|
import com.xboe.module.course.entity.*;
|
||||||
import com.xboe.module.course.vo.TeacherVo;
|
import com.xboe.module.course.vo.TeacherVo;
|
||||||
@@ -365,13 +366,15 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
//作业导出
|
//作业导出
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public JsonResponse<String> export(String courseId,String courseName,String contentId,String name,Integer status) throws IOException {
|
public JsonResponse<String> export(String courseId,String courseName,String contentId,String name,Integer status,HttpServletRequest request) throws IOException {
|
||||||
Map<String, String>map=new HashMap<>();
|
Map<String, String>map=new HashMap<>();
|
||||||
List<String> userIds = studyCourseDao.findList(FieldFilters.eq("courseId", courseId)).stream().filter(Objects::nonNull).map(StudyCourse::getAid).collect(Collectors.toList());
|
List<String> userIds = studyCourseDao.findList(FieldFilters.eq("courseId", courseId)).stream().filter(Objects::nonNull).map(StudyCourse::getAid).collect(Collectors.toList());
|
||||||
if (userIds.isEmpty()){
|
if (userIds.isEmpty()){
|
||||||
return error("查询不到用户");
|
return error("查询不到用户");
|
||||||
}
|
}
|
||||||
List<User>user=studyService.getUserNo(userIds);
|
|
||||||
|
List <UserBasicInfo> userBasicInfoList =thirdApi.getUserBasicInfoByUserId(userIds,request);
|
||||||
|
|
||||||
try {//筛选出的人员
|
try {//筛选出的人员
|
||||||
List<StudyCourseItem> list = studyService.getList(courseId, contentId, name, status);
|
List<StudyCourseItem> list = studyService.getList(courseId, contentId, name, status);
|
||||||
if(list.isEmpty()){
|
if(list.isEmpty()){
|
||||||
@@ -383,12 +386,12 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
return success("暂无数据");
|
return success("暂无数据");
|
||||||
}
|
}
|
||||||
studyHomeWorks.forEach(e->{
|
studyHomeWorks.forEach(e->{
|
||||||
user.forEach(u->{
|
userBasicInfoList.forEach(u->{
|
||||||
if(u.getId().equals(s.getAid())){
|
if(u.getUserId().equals(s.getAid())){
|
||||||
//取后缀
|
//取后缀
|
||||||
int dotIndex = e.getFilePath().lastIndexOf('.'); // 查找最后一个'.'的位置
|
int dotIndex = e.getFilePath().lastIndexOf('.'); // 查找最后一个'.'的位置
|
||||||
String extension = e.getFilePath().substring(dotIndex);
|
String extension = e.getFilePath().substring(dotIndex);
|
||||||
map.put(u.getName()+"-"+u.getUserNo()+extension,"/home/www/elearning/upload"+e.getFilePath());
|
map.put(u.getUserName()+"-"+u.getWorkNum()+extension,"/home/www/elearning/upload"+e.getFilePath());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -99,5 +99,4 @@ public interface IStudyService {
|
|||||||
|
|
||||||
List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status);
|
List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status);
|
||||||
|
|
||||||
List<User> getUserNo(List<String> userIds);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,11 +219,6 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
return scItemDao.findList(query.builder());
|
return scItemDao.findList(query.builder());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<User> getUserNo(List<String> userIds) {
|
|
||||||
return userDao.findList(FieldFilters.in("id", userIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
@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) {
|
||||||
|
|||||||
@@ -75,3 +75,4 @@ manageApi.editExam=${boe.domain}/manageApi/admin/project/editExam
|
|||||||
#获取离职教师id
|
#获取离职教师id
|
||||||
userBasic.getTeacherIds=${boe.domain}/userbasic/user/getTeacherInfo
|
userBasic.getTeacherIds=${boe.domain}/userbasic/user/getTeacherInfo
|
||||||
coursesuilt.getStudyStatus=${boe.domain}/manageApi/stu/project/completeStatus
|
coursesuilt.getStudyStatus=${boe.domain}/manageApi/stu/project/completeStatus
|
||||||
|
userBasic.getUserBasicInfo=${boe.domain}/userbasic/user/getUserBasicInfo
|
||||||
|
|||||||
Reference in New Issue
Block a user