mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 03:16:48 +08:00
Compare commits
29 Commits
c8c093ffd9
...
251114-fea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eba13bb602 | ||
|
|
240d4725e6 | ||
|
|
0b5716ed7d | ||
|
|
a1121e8700 | ||
|
|
5f42139407 | ||
|
|
3d35519615 | ||
|
|
e76833a3c2 | ||
|
|
c3027517c5 | ||
|
|
ce2524fdcb | ||
|
|
4f53a268ba | ||
|
|
8e1a68d416 | ||
|
|
4e6d1a6b04 | ||
|
|
f506fe49f2 | ||
|
|
3c582e9ade | ||
|
|
716ba91c2e | ||
|
|
f39562ffc9 | ||
|
|
2b7d0ef35a | ||
|
|
7e21784a74 | ||
|
|
4b064171e6 | ||
|
|
9f26b991a0 | ||
|
|
a701f54a52 | ||
|
|
d54937c416 | ||
|
|
4ec928c451 | ||
|
|
4fd415e7db | ||
|
|
8b9fb576c8 | ||
|
|
d9cbc9a24d | ||
|
|
25ed807efd | ||
|
|
dca4b96b62 | ||
|
|
beae204174 |
@@ -131,6 +131,16 @@ public class CourseManageApi extends ApiBaseController{
|
|||||||
return success(coursePageService.pageQuery(null, coursePageQueryDTO));
|
return success(coursePageService.pageQuery(null, coursePageQueryDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新-教师端 我开发的课程
|
||||||
|
* @param coursePageQueryDTO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/develop_page")
|
||||||
|
public JsonResponse<PageList<CoursePageVo>> teacherPage(@RequestBody CoursePageQueryDTO coursePageQueryDTO) {
|
||||||
|
return success(coursePageService.pageQuery(getCurrent(), coursePageQueryDTO));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前用户是否在管理端显示置顶相关功能
|
* 当前用户是否在管理端显示置顶相关功能
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.time.LocalDate;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.xboe.module.course.dto.CoursePageQueryDTO;
|
import com.xboe.module.course.dto.CoursePageQueryDTO;
|
||||||
@@ -101,6 +102,7 @@ public class CourseDao extends BaseDao<Course> {
|
|||||||
StringBuilder builder = new StringBuilder("select ");
|
StringBuilder builder = new StringBuilder("select ");
|
||||||
builder.append("c.id,");
|
builder.append("c.id,");
|
||||||
builder.append("c.name,");
|
builder.append("c.name,");
|
||||||
|
builder.append("c.type,");
|
||||||
builder.append("c.cover_img AS coverImg,");
|
builder.append("c.cover_img AS coverImg,");
|
||||||
builder.append("c.sys_type1 AS sysType1,");
|
builder.append("c.sys_type1 AS sysType1,");
|
||||||
builder.append("c.sys_type2 AS sysType2,");
|
builder.append("c.sys_type2 AS sysType2,");
|
||||||
@@ -122,7 +124,8 @@ public class CourseDao extends BaseDao<Course> {
|
|||||||
builder.append("c.open_course AS openCourse,");
|
builder.append("c.open_course AS openCourse,");
|
||||||
builder.append("c.is_top AS isTop,");
|
builder.append("c.is_top AS isTop,");
|
||||||
builder.append("COALESCE(tch.teacher_names, '') AS teacherName,");
|
builder.append("COALESCE(tch.teacher_names, '') AS teacherName,");
|
||||||
builder.append("c.sort_weight AS sortWeight");
|
builder.append("c.sort_weight AS sortWeight,");
|
||||||
|
builder.append("c.sys_update_time AS sysUpdateTime");
|
||||||
// 拼接FROM及查询条件语句
|
// 拼接FROM及查询条件语句
|
||||||
appendFrom(builder, queryDTO, isSystemAdmin, orgIds, currentAccountId, userCenterSchema);
|
appendFrom(builder, queryDTO, isSystemAdmin, orgIds, currentAccountId, userCenterSchema);
|
||||||
// 排序语句
|
// 排序语句
|
||||||
@@ -142,59 +145,65 @@ public class CourseDao extends BaseDao<Course> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vo.setName((String) row[1]);
|
vo.setName((String) row[1]);
|
||||||
vo.setCoverImg((String) row[2]);
|
vo.setType((Integer) row[2]);
|
||||||
vo.setSysType1((String) row[3]);
|
vo.setCoverImg((String) row[3]);
|
||||||
vo.setSysType2((String) row[4]);
|
vo.setSysType1((String) row[4]);
|
||||||
vo.setSysType3((String) row[5]);
|
vo.setSysType2((String) row[5]);
|
||||||
vo.setOrgId((String) row[6]);
|
vo.setSysType3((String) row[6]);
|
||||||
vo.setOrgName((String) row[7]);
|
vo.setOrgId((String) row[7]);
|
||||||
vo.setOrgFullName((String) row[8]);
|
vo.setOrgName((String) row[8]);
|
||||||
vo.setSysCreateBy((String) row[9]);
|
vo.setOrgFullName((String) row[9]);
|
||||||
vo.setCreateFrom((String) row[10]);
|
vo.setSysCreateBy((String) row[10]);
|
||||||
|
vo.setCreateFrom((String) row[11]);
|
||||||
|
|
||||||
// 增加对Timestamp和LocalDateTime的兼容性,防止Timestamp为null的情况
|
// 增加对Timestamp和LocalDateTime的兼容性,防止Timestamp为null的情况
|
||||||
Timestamp sysCreateTimestamp = (Timestamp) row[11];
|
Timestamp sysCreateTimestamp = (Timestamp) row[12];
|
||||||
if (sysCreateTimestamp != null) {
|
if (sysCreateTimestamp != null) {
|
||||||
vo.setSysCreateTime(sysCreateTimestamp.toLocalDateTime());
|
vo.setSysCreateTime(sysCreateTimestamp.toLocalDateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
vo.setForUsers((String) row[12]);
|
vo.setForUsers((String) row[13]);
|
||||||
vo.setStatus((Integer) row[13]);
|
vo.setStatus((Integer) row[14]);
|
||||||
vo.setPublished((Boolean) row[14]);
|
vo.setPublished((Boolean) row[15]);
|
||||||
|
|
||||||
// 增加对Timestamp和LocalDateTime的兼容性,防止Timestamp为null的情况
|
// 增加对Timestamp和LocalDateTime的兼容性,防止Timestamp为null的情况
|
||||||
Timestamp publishTimestamp = (Timestamp) row[15];
|
Timestamp publishTimestamp = (Timestamp) row[16];
|
||||||
if (publishTimestamp != null) {
|
if (publishTimestamp != null) {
|
||||||
vo.setPublishTime(publishTimestamp.toLocalDateTime());
|
vo.setPublishTime(publishTimestamp.toLocalDateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 防止Number为null的情况
|
// 防止Number为null的情况
|
||||||
Number studysNum = (Number) row[16];
|
Number studysNum = (Number) row[17];
|
||||||
if (studysNum != null) {
|
if (studysNum != null) {
|
||||||
vo.setStudys(studysNum.intValue());
|
vo.setStudys(studysNum.intValue());
|
||||||
} else {
|
} else {
|
||||||
vo.setStudys(0);
|
vo.setStudys(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Number scoreNum = (Number) row[17];
|
Number scoreNum = (Number) row[18];
|
||||||
if (scoreNum != null) {
|
if (scoreNum != null) {
|
||||||
vo.setScore(scoreNum.floatValue());
|
vo.setScore(scoreNum.floatValue());
|
||||||
} else {
|
} else {
|
||||||
vo.setScore(0.0f);
|
vo.setScore(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Number durationNum = (Number) row[18];
|
Number durationNum = (Number) row[19];
|
||||||
if (durationNum != null) {
|
if (durationNum != null) {
|
||||||
vo.setCourseDuration(durationNum.longValue());
|
vo.setCourseDuration(durationNum.longValue());
|
||||||
} else {
|
} else {
|
||||||
vo.setCourseDuration(0L);
|
vo.setCourseDuration(0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
vo.setEnabled((Boolean) row[19]);
|
vo.setEnabled((Boolean) row[20]);
|
||||||
vo.setOpenCourse((Integer) row[20]);
|
vo.setOpenCourse((Integer) row[21]);
|
||||||
vo.setIsTop((Boolean) row[21]);
|
vo.setIsTop((Boolean) row[22]);
|
||||||
vo.setTeacherName((String) row[22]);
|
vo.setTeacherName((String) row[23]);
|
||||||
vo.setSortWeight((Integer) row[23]);
|
vo.setSortWeight((Integer) row[24]);
|
||||||
|
// 增加对Timestamp和LocalDateTime的兼容性,防止Timestamp为null的情况
|
||||||
|
Timestamp sysUpdateTimestamp = (Timestamp) row[25];
|
||||||
|
if (sysUpdateTimestamp != null) {
|
||||||
|
vo.setSysUpdateTime(sysUpdateTimestamp.toLocalDateTime());
|
||||||
|
}
|
||||||
coursePageVos.add(vo);
|
coursePageVos.add(vo);
|
||||||
}
|
}
|
||||||
return coursePageVos;
|
return coursePageVos;
|
||||||
@@ -229,7 +238,7 @@ public class CourseDao extends BaseDao<Course> {
|
|||||||
// 开头判断:课程培训时间的两个参数是否不为null
|
// 开头判断:课程培训时间的两个参数是否不为null
|
||||||
boolean filterLearningTime = queryDTO.getLearningTimeStart() != null && queryDTO.getLearningTimeEnd() != null;
|
boolean filterLearningTime = queryDTO.getLearningTimeStart() != null && queryDTO.getLearningTimeEnd() != null;
|
||||||
builder.append(" FROM boe_course c");
|
builder.append(" FROM boe_course c");
|
||||||
// 聚合教师姓名(仅未删除的教师)
|
// 聚合教师姓名
|
||||||
builder.append(System.lineSeparator());
|
builder.append(System.lineSeparator());
|
||||||
builder.append("LEFT JOIN (SELECT course_id, GROUP_CONCAT(teacher_name ORDER BY id SEPARATOR ',') AS teacher_names FROM boe_course_teacher GROUP BY course_id) tch ON c.id = tch.course_id");
|
builder.append("LEFT JOIN (SELECT course_id, GROUP_CONCAT(teacher_name ORDER BY id SEPARATOR ',') AS teacher_names FROM boe_course_teacher GROUP BY course_id) tch ON c.id = tch.course_id");
|
||||||
// 学习人数聚合(满足时间条件的学习记录,且学习记录有效)
|
// 学习人数聚合(满足时间条件的学习记录,且学习记录有效)
|
||||||
@@ -253,6 +262,9 @@ public class CourseDao extends BaseDao<Course> {
|
|||||||
builder.append(System.lineSeparator());
|
builder.append(System.lineSeparator());
|
||||||
builder.append("LEFT JOIN ").append(userCenterSchema)
|
builder.append("LEFT JOIN ").append(userCenterSchema)
|
||||||
.append(".organization org ON c.org_id = org.organization_id AND org.deleted = 0");
|
.append(".organization org ON c.org_id = org.organization_id AND org.deleted = 0");
|
||||||
|
// 教师联查
|
||||||
|
builder.append(System.lineSeparator());
|
||||||
|
builder.append("LEFT JOIN boe_course_teacher ct ON c.id = ct.course_id");
|
||||||
|
|
||||||
// where条件
|
// where条件
|
||||||
// 第一个条件:deleted = 0
|
// 第一个条件:deleted = 0
|
||||||
@@ -302,9 +314,14 @@ public class CourseDao extends BaseDao<Course> {
|
|||||||
builder.append("AND (:learningTimeStart IS NULL OR :learningTimeEnd IS NULL OR EXISTS (SELECT 1 FROM boe_study_course sc WHERE sc.course_id = c.id AND sc.finish_time IS NOT NULL AND sc.add_time >= :learningTimeStart AND sc.finish_time <= :learningTimeEnd))");
|
builder.append("AND (:learningTimeStart IS NULL OR :learningTimeEnd IS NULL OR EXISTS (SELECT 1 FROM boe_study_course sc WHERE sc.course_id = c.id AND sc.finish_time IS NOT NULL AND sc.add_time >= :learningTimeStart AND sc.finish_time <= :learningTimeEnd))");
|
||||||
}
|
}
|
||||||
// 授课教师
|
// 授课教师
|
||||||
if (StringUtils.isNotBlank(queryDTO.getTeacherName())) {
|
if (StringUtils.isNotBlank(queryDTO.getTeacherId())) {
|
||||||
builder.append(System.lineSeparator());
|
builder.append(System.lineSeparator());
|
||||||
builder.append("AND tch.teacher_names LIKE CONCAT('%', :teacherName, '%')");
|
// 判断teacherId是一个还是多个
|
||||||
|
if (queryDTO.getTeacherId().contains(",")) {
|
||||||
|
builder.append("AND ct.teacher_id IN (:teacherIdList)");
|
||||||
|
} else {
|
||||||
|
builder.append("AND ct.teacher_id = :teacherId");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 展开后条件
|
// 展开后条件
|
||||||
if (queryDTO.getEnabled() != null) {
|
if (queryDTO.getEnabled() != null) {
|
||||||
@@ -319,9 +336,13 @@ public class CourseDao extends BaseDao<Course> {
|
|||||||
builder.append(System.lineSeparator());
|
builder.append(System.lineSeparator());
|
||||||
builder.append("AND c.org_id = :orgId");
|
builder.append("AND c.org_id = :orgId");
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(queryDTO.getCreateUser())) {
|
if (StringUtils.isNotBlank(queryDTO.getCreateUserId())) {
|
||||||
builder.append(System.lineSeparator());
|
builder.append(System.lineSeparator());
|
||||||
builder.append("AND c.sys_create_by LIKE CONCAT('%', :createUser, '%')");
|
if (queryDTO.getCreateUserId().contains(",")) {
|
||||||
|
builder.append("AND c.sys_create_aid IN (:createUserIdList)");
|
||||||
|
} else {
|
||||||
|
builder.append("AND c.sys_create_aid = :createUserId");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(queryDTO.getCreateFrom())) {
|
if (StringUtils.isNotBlank(queryDTO.getCreateFrom())) {
|
||||||
builder.append(System.lineSeparator());
|
builder.append(System.lineSeparator());
|
||||||
@@ -402,8 +423,14 @@ public class CourseDao extends BaseDao<Course> {
|
|||||||
query.setParameter("learningTimeStart", queryDTO.getLearningTimeStart());
|
query.setParameter("learningTimeStart", queryDTO.getLearningTimeStart());
|
||||||
query.setParameter("learningTimeEnd", queryDTO.getLearningTimeEnd());
|
query.setParameter("learningTimeEnd", queryDTO.getLearningTimeEnd());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(queryDTO.getTeacherName())) {
|
if (StringUtils.isNotBlank(queryDTO.getTeacherId())) {
|
||||||
query.setParameter("teacherName", queryDTO.getTeacherName());
|
String teacherIdStr = queryDTO.getTeacherId();
|
||||||
|
if (teacherIdStr.contains(",")) {
|
||||||
|
List<String> teacherIdList = Arrays.asList(teacherIdStr.split(","));
|
||||||
|
query.setParameter("teacherIdList", teacherIdList);
|
||||||
|
} else {
|
||||||
|
query.setParameter("teacherId", queryDTO.getTeacherId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (queryDTO.getEnabled() != null) {
|
if (queryDTO.getEnabled() != null) {
|
||||||
query.setParameter("enabled", queryDTO.getEnabled());
|
query.setParameter("enabled", queryDTO.getEnabled());
|
||||||
@@ -414,8 +441,14 @@ public class CourseDao extends BaseDao<Course> {
|
|||||||
if (StringUtils.isNotBlank(queryDTO.getResOwner1())) {
|
if (StringUtils.isNotBlank(queryDTO.getResOwner1())) {
|
||||||
query.setParameter("orgId", queryDTO.getResOwner1());
|
query.setParameter("orgId", queryDTO.getResOwner1());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(queryDTO.getCreateUser())) {
|
if (StringUtils.isNotBlank(queryDTO.getCreateUserId())) {
|
||||||
query.setParameter("createUser", queryDTO.getCreateUser());
|
String createUserIdStr = queryDTO.getCreateUserId();
|
||||||
|
if (createUserIdStr.contains(",")) {
|
||||||
|
List<String> createUserIdList = Arrays.asList(createUserIdStr.split(","));
|
||||||
|
query.setParameter("createUserIdList", createUserIdList);
|
||||||
|
} else {
|
||||||
|
query.setParameter("createUserId", queryDTO.getCreateUserId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(queryDTO.getCreateFrom())) {
|
if (StringUtils.isNotBlank(queryDTO.getCreateFrom())) {
|
||||||
query.setParameter("createFrom", queryDTO.getCreateFrom());
|
query.setParameter("createFrom", queryDTO.getCreateFrom());
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ public class CoursePageQueryDTO {
|
|||||||
/**创建人*/
|
/**创建人*/
|
||||||
private String createUser;
|
private String createUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人id
|
||||||
|
*/
|
||||||
|
private String createUserId;
|
||||||
|
|
||||||
/**课程分类的一级*/
|
/**课程分类的一级*/
|
||||||
private String sysType1;
|
private String sysType1;
|
||||||
|
|
||||||
@@ -43,6 +48,11 @@ public class CoursePageQueryDTO {
|
|||||||
/**授课教师*/
|
/**授课教师*/
|
||||||
private String teacherName;
|
private String teacherName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授课教师id
|
||||||
|
*/
|
||||||
|
private String teacherId;
|
||||||
|
|
||||||
/**培训时间筛选类型*/
|
/**培训时间筛选类型*/
|
||||||
private String learningTimeType;
|
private String learningTimeType;
|
||||||
|
|
||||||
@@ -77,4 +87,11 @@ public class CoursePageQueryDTO {
|
|||||||
|
|
||||||
/**排序顺序*/
|
/**排序顺序*/
|
||||||
private Boolean orderAsc;
|
private Boolean orderAsc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是新建在线课程页面
|
||||||
|
* false时,代表是在管理端的“在线管理”、“我开发的课程”
|
||||||
|
* true时,代表是在学习路径图/项目管理 中,创建在线课程的选择页面
|
||||||
|
*/
|
||||||
|
private Boolean isCreateCourse;
|
||||||
}
|
}
|
||||||
@@ -82,65 +82,9 @@ public class CoursePageServiceImpl implements ICoursePageService {
|
|||||||
|
|
||||||
String currentAccountId = currentUser == null ? null : currentUser.getAccountId();
|
String currentAccountId = currentUser == null ? null : currentUser.getAccountId();
|
||||||
|
|
||||||
// 第一版废弃
|
List<String> readIds = userOrgIds.getReadIds();
|
||||||
// // 构建查询条件
|
orgIds.addAll(readIds);
|
||||||
// List<IFieldFilter> filters = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// // 自动添加过滤已删除
|
|
||||||
// filters.add(FieldFilters.eq("c.deleted", false));
|
|
||||||
//
|
|
||||||
// // 添加权限过滤条件
|
|
||||||
// if (!isSystemAdmin) {
|
|
||||||
// // 非系统管理员需要进行权限过滤
|
|
||||||
// List<IFieldFilter> permissionFilters = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// // 添加组织权限过滤
|
|
||||||
// if (orgIds != null && !orgIds.isEmpty()) {
|
|
||||||
// permissionFilters.add(FieldFilters.in("c.orgId", orgIds));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 添加创建人过滤(可以看到自己创建的课程)
|
|
||||||
// if (StringUtils.isNotBlank(currentAccountId)) {
|
|
||||||
// permissionFilters.add(FieldFilters.eq("c.sysCreateAid", currentAccountId));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 如果有权限条件,则添加OR条件
|
|
||||||
// if (!permissionFilters.isEmpty()) {
|
|
||||||
// filters.add(FieldFilters.or(permissionFilters));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// filters.addAll(createFilters(coursePageQueryDTO));
|
|
||||||
//
|
|
||||||
// QueryBuilder query = QueryBuilder.from(Course.class.getSimpleName() + " c").addFilters(filters);
|
|
||||||
// // 处理排序
|
|
||||||
// handleOrder(query, coursePageQueryDTO.getOrderField(), coursePageQueryDTO.getOrderAsc());
|
|
||||||
//
|
|
||||||
// // 设置分页参数
|
|
||||||
// int pageIndex = coursePageQueryDTO.getPageIndex() != null ? coursePageQueryDTO.getPageIndex() : 0;
|
|
||||||
// int pageSize = coursePageQueryDTO.getPageSize() != null ? coursePageQueryDTO.getPageSize() : 10;
|
|
||||||
// query.setPageIndex(pageIndex);
|
|
||||||
// query.setPageSize(pageSize);
|
|
||||||
//
|
|
||||||
// // 执行查询
|
|
||||||
// PageList<Course> coursePageList = courseDao.findPage(query.builder());
|
|
||||||
//
|
|
||||||
// // 转换为CoursePageVo
|
|
||||||
// PageList<CoursePageVo> result = new PageList<>();
|
|
||||||
// result.setCount(coursePageList.getCount());
|
|
||||||
// result.setPageSize(coursePageList.getPageSize());
|
|
||||||
//
|
|
||||||
// // 子查询:根据课程id查询课程下的教师
|
|
||||||
// List<String> courseIds = coursePageList.getList().stream()
|
|
||||||
// .map(Course::getId)
|
|
||||||
// .collect(Collectors.toList());
|
|
||||||
// List<CourseTeacher> courseTeacherList = getCourseTeacherList(courseIds);
|
|
||||||
// List<CoursePageVo> voList = coursePageList.getList().stream()
|
|
||||||
// .map(c -> convertToVo(c, courseTeacherList))
|
|
||||||
// .collect(Collectors.toList());
|
|
||||||
// result.setList(voList);
|
|
||||||
//
|
|
||||||
// return result;
|
|
||||||
// 第二版
|
|
||||||
long total = courseDao.countCourse(coursePageQueryDTO, isSystemAdmin, orgIds, currentAccountId, mySqlSchemaProperties.getUserCenterSchema());
|
long total = courseDao.countCourse(coursePageQueryDTO, isSystemAdmin, orgIds, currentAccountId, mySqlSchemaProperties.getUserCenterSchema());
|
||||||
List<CoursePageVo> voList = courseDao.queryCourse(coursePageQueryDTO, isSystemAdmin, orgIds, currentAccountId, true, mySqlSchemaProperties.getUserCenterSchema());
|
List<CoursePageVo> voList = courseDao.queryCourse(coursePageQueryDTO, isSystemAdmin, orgIds, currentAccountId, true, mySqlSchemaProperties.getUserCenterSchema());
|
||||||
PageList<CoursePageVo> result = new PageList<>();
|
PageList<CoursePageVo> result = new PageList<>();
|
||||||
@@ -306,7 +250,7 @@ public class CoursePageServiceImpl implements ICoursePageService {
|
|||||||
map.put("published", coursePageVo.getPublished() == null || !coursePageVo.getPublished() ? "未发布" : "已发布");
|
map.put("published", coursePageVo.getPublished() == null || !coursePageVo.getPublished() ? "未发布" : "已发布");
|
||||||
map.put("enabled", coursePageVo.getEnabled() == null || coursePageVo.getEnabled() ? "停用" : "启用");
|
map.put("enabled", coursePageVo.getEnabled() == null || coursePageVo.getEnabled() ? "停用" : "启用");
|
||||||
map.put("openCourse", coursePageVo.getOpenCourse() == null || coursePageVo.getOpenCourse() == 0 ? "否" : "是");
|
map.put("openCourse", coursePageVo.getOpenCourse() == null || coursePageVo.getOpenCourse() == 0 ? "否" : "是");
|
||||||
map.put("orgName", coursePageVo.getOrgName());
|
map.put("orgName", coursePageVo.getOrgFullName()); // 修改为组织全名
|
||||||
map.put("sysCreateBy", coursePageVo.getSysCreateBy());
|
map.put("sysCreateBy", coursePageVo.getSysCreateBy());
|
||||||
map.put("createFrom", CourseCreateFromEnum.getByCode(coursePageVo.getCreateFrom()).getLabel());
|
map.put("createFrom", CourseCreateFromEnum.getByCode(coursePageVo.getCreateFrom()).getLabel());
|
||||||
map.put("sysCreateTime", formatter.format(coursePageVo.getSysCreateTime()));
|
map.put("sysCreateTime", formatter.format(coursePageVo.getSysCreateTime()));
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ public class CoursePageVo {
|
|||||||
* 课程名称
|
* 课程名称
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 课程类型
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课程封面图片地址
|
* 课程封面图片地址
|
||||||
@@ -87,6 +92,13 @@ public class CoursePageVo {
|
|||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private LocalDateTime sysCreateTime;
|
private LocalDateTime sysCreateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后修改时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private LocalDateTime sysUpdateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目标人群
|
* 目标人群
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.xboe.constants.CacheName;
|
|||||||
import com.xboe.core.CurrentUser;
|
import com.xboe.core.CurrentUser;
|
||||||
import com.xboe.core.JsonResponse;
|
import com.xboe.core.JsonResponse;
|
||||||
import com.xboe.core.api.ApiBaseController;
|
import com.xboe.core.api.ApiBaseController;
|
||||||
|
import com.xboe.core.upload.XFileUploader;
|
||||||
import com.xboe.data.outside.IOutSideDataService;
|
import com.xboe.data.outside.IOutSideDataService;
|
||||||
import com.xboe.module.course.entity.*;
|
import com.xboe.module.course.entity.*;
|
||||||
import com.xboe.module.course.service.ICourseContentService;
|
import com.xboe.module.course.service.ICourseContentService;
|
||||||
@@ -27,6 +28,7 @@ import com.xboe.school.study.dto.*;
|
|||||||
import com.xboe.school.study.entity.*;
|
import com.xboe.school.study.entity.*;
|
||||||
import com.xboe.school.study.service.*;
|
import com.xboe.school.study.service.*;
|
||||||
import com.xboe.school.vo.StudyTimeVo;
|
import com.xboe.school.vo.StudyTimeVo;
|
||||||
|
import com.xboe.system.organization.entity.Organization;
|
||||||
import com.xboe.system.organization.service.IOrganizationService;
|
import com.xboe.system.organization.service.IOrganizationService;
|
||||||
import com.xboe.system.user.entity.User;
|
import com.xboe.system.user.entity.User;
|
||||||
import com.xboe.system.user.service.IUserService;
|
import com.xboe.system.user.service.IUserService;
|
||||||
@@ -42,7 +44,7 @@ import javax.annotation.Resource;
|
|||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.OutputStream;
|
import java.io.*;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
@@ -51,6 +53,8 @@ import java.util.*;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课程学习的内容
|
* 课程学习的内容
|
||||||
@@ -75,6 +79,9 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
@Autowired
|
@Autowired
|
||||||
IStudyHomeWorkService studyHomeWorkService;
|
IStudyHomeWorkService studyHomeWorkService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
IStudyAssessService assessService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ThirdApi thirdApi;
|
private ThirdApi thirdApi;
|
||||||
|
|
||||||
@@ -110,6 +117,9 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
@Resource
|
@Resource
|
||||||
private IOrganizationService organizationService;
|
private IOrganizationService organizationService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private XFileUploader fileUploader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于避免JPA查询后修改entity实体字段,自动更新到数据库
|
* 用于避免JPA查询后修改entity实体字段,自动更新到数据库
|
||||||
*/
|
*/
|
||||||
@@ -123,15 +133,15 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
*
|
*
|
||||||
* @param pager 分页参数
|
* @param pager 分页参数
|
||||||
* @param courseId 25.11.25新增
|
* @param courseId 25.11.25新增
|
||||||
*
|
* @param contentName 资源名称
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/pagelist-resource", method = {RequestMethod.GET, RequestMethod.POST})
|
@RequestMapping(value = "/pagelist-resource", method = {RequestMethod.GET, RequestMethod.POST})
|
||||||
public JsonResponse<PageList<CourseFinishCountDto>> findPageResource(Pagination pager, String courseId) {
|
public JsonResponse<PageList<CourseFinishCountDto>> findPageResource(Pagination pager, String courseId, String contentName) {
|
||||||
if (StringUtil.isBlank(courseId)) {
|
if (StringUtil.isBlank(courseId)) {
|
||||||
return error("课程id不能为空");
|
return error("课程id不能为空");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PageList<CourseFinishCountDto> courseFinishCountDTOs = service.findPageResource(pager.getPageIndex(), pager.getPageSize(), courseId);
|
PageList<CourseFinishCountDto> courseFinishCountDTOs = service.findPageResource(pager.getPageIndex(), pager.getPageSize(), courseId, contentName);
|
||||||
return success(courseFinishCountDTOs);
|
return success(courseFinishCountDTOs);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("查询课程学习记录错误:{}", e.getMessage());
|
log.error("查询课程学习记录错误:{}", e.getMessage());
|
||||||
@@ -160,7 +170,7 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
excelHeadMap.put("姓名", "name");
|
excelHeadMap.put("姓名", "name");
|
||||||
excelHeadMap.put("工号", "userNo");
|
excelHeadMap.put("工号", "userNo");
|
||||||
excelHeadMap.put("部门", "departName");
|
excelHeadMap.put("部门", "departName");
|
||||||
excelHeadMap.put("报名方式", "signType");
|
excelHeadMap.put("报名方式", "signTypeName");
|
||||||
excelHeadMap.put("报名时间", "signTime");
|
excelHeadMap.put("报名时间", "signTime");
|
||||||
// 3. 调用Service:根据筛选条件查询报名记录
|
// 3. 调用Service:根据筛选条件查询报名记录
|
||||||
List<StudySignup> signRecordList = courseSignService.querySignRecords(queryDto);
|
List<StudySignup> signRecordList = courseSignService.querySignRecords(queryDto);
|
||||||
@@ -194,7 +204,9 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
? userInfo.getUserNo()
|
? userInfo.getUserNo()
|
||||||
: "");
|
: "");
|
||||||
// 3. 填部门:通过departId查部门名称
|
// 3. 填部门:通过departId查部门名称
|
||||||
String departName = organizationService.getName(userInfo.getDepartId());
|
// 获取部门信息(参考现有机构表,获取namePath字段)
|
||||||
|
Organization organization = organizationService.get(userInfo.getDepartId());
|
||||||
|
String departName = organization != null ? organization.getNamePath() : "";
|
||||||
resultVo.setOrgInfo(StringUtils.isNotBlank(departName)
|
resultVo.setOrgInfo(StringUtils.isNotBlank(departName)
|
||||||
? departName
|
? departName
|
||||||
: "");
|
: "");
|
||||||
@@ -230,11 +242,11 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
// 4.2 格式化:报名状态(枚举值→中文描述)
|
// 4.2 格式化:报名状态(枚举值→中文描述)
|
||||||
Integer signStatus = studySignup.getSignType();
|
Integer signStatus = studySignup.getSignType();
|
||||||
if (Objects.equals(signStatus, 1)) {
|
if (Objects.equals(signStatus, 1)) {
|
||||||
exportDto.setSignType("自主报名");
|
exportDto.setSignTypeName("自主报名");
|
||||||
} else if (Objects.equals(signStatus, 2)) {
|
} else if (Objects.equals(signStatus, 2)) {
|
||||||
exportDto.setSignType("手动加入");
|
exportDto.setSignTypeName("手动加入");
|
||||||
} else {
|
} else {
|
||||||
exportDto.setSignType("");
|
exportDto.setSignTypeName("");
|
||||||
}
|
}
|
||||||
// 4.3 从 UserSimpleVo 中获取工号、部门
|
// 4.3 从 UserSimpleVo 中获取工号、部门
|
||||||
UserSimpleVo user = userInfoMap.get(studySignup.getAid());
|
UserSimpleVo user = userInfoMap.get(studySignup.getAid());
|
||||||
@@ -336,7 +348,7 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
exportMap.put("学习进度", "学习进度");
|
exportMap.put("学习进度", "学习进度");
|
||||||
// 2.查询课程的所有考试答卷信息,拼接动态表头(XXX考试成绩)
|
// 2.查询课程的所有考试答卷信息,拼接动态表头(XXX考试成绩)
|
||||||
// 注意:这里的考试信息每个学生每门课程只有一条,实际数据可能多次考试,因此根据考试配置中的(最高分/最新数据)获取对应列表数据即可(本次新增接口)
|
// 注意:这里的考试信息每个学生每门课程只有一条,实际数据可能多次考试,因此根据考试配置中的(最高分/最新数据)获取对应列表数据即可(本次新增接口)
|
||||||
List<StudyExam> studyExams = studyExamService.getByCourseId(courseId);
|
List<StudyExam> studyExams = studyExamService.getByCourseIdAndContentId(courseId, null);
|
||||||
// courseExam和studyExam表都有testName字段,查看现有逻辑后,选择studyExam表的testName字段作为考试名称
|
// courseExam和studyExam表都有testName字段,查看现有逻辑后,选择studyExam表的testName字段作为考试名称
|
||||||
// 因为需求没提,因此查询按默认id排序
|
// 因为需求没提,因此查询按默认id排序
|
||||||
// 查询学习记录接口,学习记录默认存储获取最高/最新的分数,备用
|
// 查询学习记录接口,学习记录默认存储获取最高/最新的分数,备用
|
||||||
@@ -412,7 +424,10 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
if (Objects.equals(userId, studyCourse1.getAid())) {
|
if (Objects.equals(userId, studyCourse1.getAid())) {
|
||||||
log.info("【导出课程学习记录】查询boe人员表,机构id:{}", userInfo.getDepartId());
|
log.info("【导出课程学习记录】查询boe人员表,机构id:{}", userInfo.getDepartId());
|
||||||
// 和技术沟通后,确认这里机构名称是redis获取的,获取不到返回null,因此正常遍历没有效率和空值问题
|
// 和技术沟通后,确认这里机构名称是redis获取的,获取不到返回null,因此正常遍历没有效率和空值问题
|
||||||
studyCourse1.setOrgInfo(organizationService.getName(userInfo.getDepartId()));
|
// 获取部门信息(参考现有机构表,获取namePath字段)
|
||||||
|
Organization organization = organizationService.get(userInfo.getDepartId());
|
||||||
|
String departName = organization != null ? organization.getNamePath() : "";
|
||||||
|
studyCourse1.setOrgInfo(departName);
|
||||||
// 取userNo为工号
|
// 取userNo为工号
|
||||||
studyCourse1.setUserNo(userInfo.getUserNo());
|
studyCourse1.setUserNo(userInfo.getUserNo());
|
||||||
}
|
}
|
||||||
@@ -436,8 +451,8 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
map.put("学习开始时间", studyCourse1.getStartTime());
|
map.put("学习开始时间", studyCourse1.getStartTime());
|
||||||
// 结束时间为空的,说明还没学习结束(有值)
|
// 结束时间为空的,说明还没学习结束(有值)
|
||||||
map.put("学习结束时间", studyCourse1.getFinishTime());
|
map.put("学习结束时间", studyCourse1.getFinishTime());
|
||||||
// 学习时长:学习总时间是秒,现在要求的学习时间是分钟,向上取整,1秒算1分钟,60秒算1分钟,61秒算2分钟
|
// 学习时长(保留两位小数):
|
||||||
map.put("学习时长(分)", studyCourse1.getTotalDuration() == null ? null : (int) Math.ceil(studyCourse1.getTotalDuration() / 60.0));
|
map.put("学习时长(分)", studyCourse1.getTotalDuration() == null ? null : String.format("%.2f", studyCourse1.getTotalDuration() / 60.0));
|
||||||
// 学习状态需要转换
|
// 学习状态需要转换
|
||||||
String statusText = "";
|
String statusText = "";
|
||||||
if (studyCourse1.getStatus() != null) {
|
if (studyCourse1.getStatus() != null) {
|
||||||
@@ -1233,14 +1248,14 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// 查询当前课程的考试信息
|
// 查询当前课程的考试信息
|
||||||
List<StudyExam> studyExams = studyExamService.getByCourseId(courseId);
|
List<StudyExam> studyExams = studyExamService.getByCourseIdAndContentId(courseId, contentId);
|
||||||
// 空值校验
|
// 空值校验
|
||||||
if (studyExams == null || studyExams.isEmpty()) {
|
if (studyExams == null || studyExams.isEmpty()) {
|
||||||
return success(new PageList<>());
|
return success(new PageList<>());
|
||||||
}
|
}
|
||||||
List<String> studyCourseItemIds = studyExams.stream().map(StudyExam::getStudyItemId).collect(Collectors.toList());
|
List<String> studyCourseItemIds = studyExams.stream().map(StudyExam::getStudyItemId).collect(Collectors.toList());
|
||||||
// 分页查询资源学习信息
|
// 分页查询资源学习信息(只查询有考试信息的部分)
|
||||||
PageList<StudyCourseItem> rs = studyService.findItemPage(pager.getPageIndex(), pager.getPageSize(), studyCourseItemIds, contentId, courseId, name, status);
|
PageList<StudyCourseItem> rs = studyService.findItemPage(pager.getPageIndex(), pager.getPageSize(), null, contentId, courseId, name, status);
|
||||||
// 拼接考试信息
|
// 拼接考试信息
|
||||||
List<StudyCourseItem> studyCourseItems = rs.getList();
|
List<StudyCourseItem> studyCourseItems = rs.getList();
|
||||||
if (studyCourseItems != null && !studyCourseItems.isEmpty() && !studyExams.isEmpty()) {
|
if (studyCourseItems != null && !studyCourseItems.isEmpty() && !studyExams.isEmpty()) {
|
||||||
@@ -1256,6 +1271,390 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源学习情况分页查询-评估信息
|
||||||
|
* 此接口只查询评估信息
|
||||||
|
*
|
||||||
|
* @param pager 分页参数
|
||||||
|
* @param courseId 课程id
|
||||||
|
* @param contentId 内容id
|
||||||
|
* @param name 用户名称
|
||||||
|
* @param status 用户学习状态(1-未开始,2-已完成,3-进行中)
|
||||||
|
* @return 资源学习情况分页集合
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/contents-assess", method = {RequestMethod.GET, RequestMethod.POST})
|
||||||
|
public JsonResponse<PageList<StudyCourseItem>> findPageAssess(Pagination pager, String courseId, String contentId, String name, Integer status) {
|
||||||
|
if (StringUtils.isBlank(courseId)) {
|
||||||
|
return error("无课程信息");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(contentId)) {
|
||||||
|
return error("无资源信息");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// 查询当前课程的评估信息
|
||||||
|
List<StudyAssess> studyAssesses = assessService.getByCourseIdAndContentId(courseId, contentId);
|
||||||
|
// 空值校验
|
||||||
|
if (studyAssesses == null || studyAssesses.isEmpty()) {
|
||||||
|
return success(new PageList<>());
|
||||||
|
}
|
||||||
|
// 分页查询资源学习信息(只查询有评估信息的部分)
|
||||||
|
PageList<StudyCourseItem> rs = studyService.findItemPage(pager.getPageIndex(), pager.getPageSize(), null, contentId, courseId, name, status);
|
||||||
|
// 拼接评估信息
|
||||||
|
List<StudyCourseItem> studyCourseItems = rs.getList();
|
||||||
|
if (studyCourseItems != null && !studyCourseItems.isEmpty() && !studyAssesses.isEmpty()) {
|
||||||
|
for (StudyCourseItem studyCourseItem : studyCourseItems) {
|
||||||
|
// 获取当前课程的评估信息
|
||||||
|
studyCourseItem.setStudyAssesses(studyAssesses.stream().filter(studyAssess -> studyAssess.getStudyItemId().equals(studyCourseItem.getId())).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success(rs);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【资源学习情况分页查询-评估信息】错误:{}", e.getMessage());
|
||||||
|
return error("查询失败", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源学习情况导出-考试信息
|
||||||
|
* 导出单个考试信息
|
||||||
|
*
|
||||||
|
* @param courseId 课程id
|
||||||
|
* @param contentId 内容id
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/contents-exam-export", method = {RequestMethod.GET, RequestMethod.POST})
|
||||||
|
public void findPageExam(String courseId, String contentId, HttpServletResponse response) {
|
||||||
|
if (StringUtils.isBlank(courseId)) {
|
||||||
|
log.error("【资源学习情况导出-考试信息】课程id不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(contentId)) {
|
||||||
|
log.error("【资源学习情况导出-考试信息】内容id不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OutputStream outputStream = null;
|
||||||
|
try {
|
||||||
|
outputStream = response.getOutputStream();
|
||||||
|
LinkedHashMap<String, String> exportMap = new LinkedHashMap<>();
|
||||||
|
// 1.拼接固定表头(课程名称、资源名称、姓名、工号、部门、考试状态、考试成绩、完成时间)
|
||||||
|
// 获取逻辑:课程名称从studyCourse表获取,资源名称从courseContent表获取,姓名、工号、部门从用户接口获取,考试状态、考试成绩、完成时间从studyExam表获取
|
||||||
|
exportMap.put("课程名称", "课程名称");
|
||||||
|
exportMap.put("资源名称", "资源名称");
|
||||||
|
exportMap.put("姓名", "姓名");
|
||||||
|
exportMap.put("工号", "工号");
|
||||||
|
exportMap.put("部门", "部门");
|
||||||
|
exportMap.put("考试状态", "考试状态");
|
||||||
|
exportMap.put("考试成绩", "考试成绩");
|
||||||
|
exportMap.put("完成时间", "完成时间");
|
||||||
|
// 查询课程名称
|
||||||
|
StudyCourse studyCourse = new StudyCourse();
|
||||||
|
studyCourse.setCourseId(courseId);
|
||||||
|
List<StudyCourse> studyCourses = service.findList(studyCourse, null, null);
|
||||||
|
String courseName;
|
||||||
|
if (studyCourses != null && !studyCourses.isEmpty()) {
|
||||||
|
courseName = studyCourses.get(0).getCourseName();
|
||||||
|
// 查询资源名称
|
||||||
|
List<CourseContent> courseContents = contentService.getByCourseId(courseId);
|
||||||
|
String contentName = "";
|
||||||
|
if (courseContents != null && !courseContents.isEmpty()) {
|
||||||
|
for (CourseContent cc : courseContents) {
|
||||||
|
if (contentId.equals(cc.getId())) {
|
||||||
|
contentName = cc.getContentName();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 查询特定考试信息(这里同一个学员,同一次考试可以导出多次考试信息)
|
||||||
|
List<StudyExam> studyExams = studyExamService.getByCourseIdAndContentId(courseId, contentId);
|
||||||
|
// 通过studyExams中的人员id集合(去重),调用用户中心接口获取人员信息,填充部门字段
|
||||||
|
Set<String> userIds = studyExams.stream().map(StudyExam::getStudentId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
List<UserSimpleVo> userList = new ArrayList<>();
|
||||||
|
if (!userIds.isEmpty()) {
|
||||||
|
// 调用用户中心接口
|
||||||
|
List<UserSimpleVo> userSimpleVos = outsideService.findByIds(new ArrayList<>(userIds));
|
||||||
|
if (userSimpleVos != null && !userSimpleVos.isEmpty()) {
|
||||||
|
userList.addAll(userSimpleVos);
|
||||||
|
} else {
|
||||||
|
log.error("【资源学习情况导出-考试信息】用户信息查询失败,查询boe人员表作为兜底方案");
|
||||||
|
// 查询boe的人员表作为兜底方案
|
||||||
|
for (String userId : userIds) {
|
||||||
|
// 用户信息也是redis获取的
|
||||||
|
User userInfo = userService.get(userId);
|
||||||
|
if (userInfo != null) {
|
||||||
|
UserSimpleVo userSimpleVo = new UserSimpleVo();
|
||||||
|
userSimpleVo.setAid(userInfo.getId());
|
||||||
|
userSimpleVo.setCode(userInfo.getUserNo());
|
||||||
|
// 获取部门信息(参考现有机构表,获取namePath字段)
|
||||||
|
Organization organization = organizationService.get(userInfo.getDepartId());
|
||||||
|
String departName = organization != null ? organization.getNamePath() : "";
|
||||||
|
userSimpleVo.setOrgInfo(StringUtils.isNotBlank(departName) ? departName : "");
|
||||||
|
userList.add(userSimpleVo);
|
||||||
|
log.info("【资源学习情况导出-考试信息】查询boe人员表,用户id:{}", userId);
|
||||||
|
} else {
|
||||||
|
log.error("【资源学习情况导出-考试信息】用户信息查询boe人员表失败,用户id:{}", userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 将考试信息与用户信息拼接为map
|
||||||
|
String finalContentName = contentName;
|
||||||
|
List<Map<String, Object>> dataList = studyExams.stream().map(exam -> {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
// 拼接基本信息
|
||||||
|
map.put("课程名称", courseName);
|
||||||
|
map.put("资源名称", finalContentName);
|
||||||
|
map.put("姓名", exam.getStudentName());
|
||||||
|
// 工号和部门信息需要从用户信息中获取
|
||||||
|
String userNo = "";
|
||||||
|
String orgInfo = "";
|
||||||
|
for (UserSimpleVo user : userList) {
|
||||||
|
if (exam.getStudentId().equals(user.getAid())) {
|
||||||
|
userNo = user.getCode();
|
||||||
|
orgInfo = user.getOrgInfo();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("工号", userNo);
|
||||||
|
map.put("部门", orgInfo);
|
||||||
|
// 考试状态需要转换(根据成绩和及格线判断)
|
||||||
|
String examStatus = "";
|
||||||
|
if (exam.getScore() != null && exam.getPassLine() != null) {
|
||||||
|
examStatus = exam.getScore() >= exam.getPassLine() ? "通过" : "未通过";
|
||||||
|
}
|
||||||
|
map.put("考试状态", examStatus);
|
||||||
|
// 考试成绩
|
||||||
|
map.put("考试成绩", exam.getScore());
|
||||||
|
// 完成时间
|
||||||
|
map.put("完成时间", exam.getEndTime());
|
||||||
|
return map;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
// 4.拼接消息类型和响应头信息
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename=ExamRecord.xlsx");
|
||||||
|
// 5.调用动态列excel导出接口
|
||||||
|
ExportsExcelSenderUtil.exportDynamic(exportMap, dataList, outputStream, "yyyy-MM-dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【资源学习情况导出-考试信息】导出资源学习情况错误:{}", e.getMessage());
|
||||||
|
} finally {
|
||||||
|
if (outputStream != null) {
|
||||||
|
try {
|
||||||
|
outputStream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("【资源学习情况导出-考试信息】关闭输出流失败:{}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源学习情况导出-作业信息
|
||||||
|
* 导出单个作业信息
|
||||||
|
*
|
||||||
|
* @param courseId 课程id
|
||||||
|
* @param contentId 内容id
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/contents-homework-export", method = {RequestMethod.GET, RequestMethod.POST})
|
||||||
|
public void findPageHomework(String courseId, String contentId, HttpServletResponse response) {
|
||||||
|
if (StringUtils.isBlank(courseId)) {
|
||||||
|
log.error("【资源学习情况导出-作业信息】课程id不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(contentId)) {
|
||||||
|
log.error("【资源学习情况导出-作业信息】内容id不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OutputStream outputStream = null;
|
||||||
|
try {
|
||||||
|
// 创建临时文件用于存储Excel
|
||||||
|
File tempExcelFile = File.createTempFile("HomeWorkRecord", ".xlsx");
|
||||||
|
String tempExcelPath = tempExcelFile.getAbsolutePath();
|
||||||
|
|
||||||
|
LinkedHashMap<String, String> exportMap = new LinkedHashMap<>();
|
||||||
|
// 1.拼接固定表头(课程名称、资源名称、姓名、工号、部门、作业状态、作业成绩、完成时间)
|
||||||
|
exportMap.put("课程名称", "课程名称");
|
||||||
|
exportMap.put("资源名称", "资源名称");
|
||||||
|
exportMap.put("姓名", "姓名");
|
||||||
|
exportMap.put("工号", "工号");
|
||||||
|
exportMap.put("部门", "部门");
|
||||||
|
exportMap.put("作业状态", "作业状态");
|
||||||
|
exportMap.put("作业成绩", "作业成绩");
|
||||||
|
exportMap.put("完成时间", "完成时间");
|
||||||
|
// 2.整理导出数据
|
||||||
|
// 查询课程名称
|
||||||
|
StudyCourse studyCourse = new StudyCourse();
|
||||||
|
studyCourse.setCourseId(courseId);
|
||||||
|
List<StudyCourse> studyCourses = service.findList(studyCourse, null, null);
|
||||||
|
String courseName;
|
||||||
|
if (studyCourses != null && !studyCourses.isEmpty()) {
|
||||||
|
courseName = studyCourses.get(0).getCourseName();
|
||||||
|
} else {
|
||||||
|
courseName = "";
|
||||||
|
}
|
||||||
|
// 查询资源名称
|
||||||
|
List<CourseContent> courseContents = contentService.getByCourseId(courseId);
|
||||||
|
String contentName = "";
|
||||||
|
if (courseContents != null && !courseContents.isEmpty()) {
|
||||||
|
for (CourseContent cc : courseContents) {
|
||||||
|
if (contentId.equals(cc.getId())) {
|
||||||
|
contentName = cc.getContentName();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 查询特定作业信息
|
||||||
|
List<StudyHomeWork> studyHomeWorks = studyHomeWorkService.getByCourseIdAndContentId(courseId, contentId);
|
||||||
|
// 通过studyHomeWorks中的人员id集合(去重),调用用户中心接口获取人员信息,填充部门字段
|
||||||
|
Set<String> userIds = studyHomeWorks.stream().map(StudyHomeWork::getStudentId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||||
|
List<UserSimpleVo> userList = new ArrayList<>();
|
||||||
|
if (!userIds.isEmpty()) {
|
||||||
|
// 调用用户中心接口
|
||||||
|
List<UserSimpleVo> userSimpleVos = outsideService.findByIds(new ArrayList<>(userIds));
|
||||||
|
if (userSimpleVos != null && !userSimpleVos.isEmpty()) {
|
||||||
|
userList.addAll(userSimpleVos);
|
||||||
|
} else {
|
||||||
|
log.error("【资源学习情况导出-作业信息】用户信息查询失败,查询boe人员表作为兜底方案");
|
||||||
|
// 查询boe的人员表作为兜底方案
|
||||||
|
for (String userId : userIds) {
|
||||||
|
// 用户信息也是redis获取的
|
||||||
|
User userInfo = userService.get(userId);
|
||||||
|
if (userInfo != null) {
|
||||||
|
UserSimpleVo userSimpleVo = new UserSimpleVo();
|
||||||
|
userSimpleVo.setAid(userInfo.getId());
|
||||||
|
userSimpleVo.setCode(userInfo.getUserNo());
|
||||||
|
// 获取部门信息(参考现有机构表,获取namePath字段)
|
||||||
|
Organization organization = organizationService.get(userInfo.getDepartId());
|
||||||
|
String departName = organization != null ? organization.getNamePath() : "";
|
||||||
|
userSimpleVo.setOrgInfo(StringUtils.isNotBlank(departName) ? departName : "");
|
||||||
|
userList.add(userSimpleVo);
|
||||||
|
log.info("【资源学习情况导出-作业信息】查询boe人员表,用户id:{}", userId);
|
||||||
|
} else {
|
||||||
|
log.error("【资源学习情况导出-作业信息】用户信息查询boe人员表失败,用户id:{}", userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 3.将作业信息与用户信息拼接为map
|
||||||
|
String finalContentName = contentName;
|
||||||
|
List<Map<String, Object>> dataList = studyHomeWorks.stream().map(hw -> {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
// 拼接基本信息
|
||||||
|
map.put("课程名称", courseName);
|
||||||
|
map.put("资源名称", finalContentName);
|
||||||
|
map.put("姓名", hw.getStudentName());
|
||||||
|
// 工号和部门信息需要从用户信息中获取
|
||||||
|
String userNo = "";
|
||||||
|
String orgInfo = "";
|
||||||
|
for (UserSimpleVo user : userList) {
|
||||||
|
if (hw.getStudentId().equals(user.getAid())) {
|
||||||
|
userNo = user.getCode();
|
||||||
|
orgInfo = user.getOrgInfo();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("工号", userNo);
|
||||||
|
map.put("部门", orgInfo);
|
||||||
|
// 作业状态(如果有成绩则为已完成,否则为未完成)
|
||||||
|
String hwStatus = (hw.getScore() != null) ? "已完成" : "未完成";
|
||||||
|
map.put("作业状态", hwStatus);
|
||||||
|
// 作业成绩
|
||||||
|
map.put("作业成绩", hw.getScore());
|
||||||
|
// 完成时间
|
||||||
|
map.put("完成时间", hw.getEndTime());
|
||||||
|
return map;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
// 先将Excel数据写入临时文件
|
||||||
|
try (FileOutputStream excelOutputStream = new FileOutputStream(tempExcelFile)) {
|
||||||
|
ExportsExcelSenderUtil.exportDynamic(exportMap, dataList, excelOutputStream, "yyyy-MM-dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
// 4.整理作业的附件信息备用
|
||||||
|
// 获取附件信息集合
|
||||||
|
Map<String, String> homeworkFiles = new HashMap<>();
|
||||||
|
String savePath = fileUploader.getSavePath();
|
||||||
|
for (StudyHomeWork studyHomeWork : studyHomeWorks) {
|
||||||
|
String filePath = studyHomeWork.getFilePath();
|
||||||
|
if (StringUtils.isNotBlank(filePath)) {
|
||||||
|
String fullPath = savePath + filePath;
|
||||||
|
log.info("【资源学习情况导出-作业信息】下载附件路径:{}", fullPath);
|
||||||
|
File file = new File(fullPath);
|
||||||
|
if (file.exists()) {
|
||||||
|
// 使用文件名作为zip中的条目名
|
||||||
|
String fileName = file.getName();
|
||||||
|
// 避免文件名冲突,如果已存在则添加序号
|
||||||
|
String zipEntryName = fileName;
|
||||||
|
int counter = 1;
|
||||||
|
while (homeworkFiles.containsKey(zipEntryName)) {
|
||||||
|
int dotIndex = fileName.lastIndexOf('.');
|
||||||
|
if (dotIndex > 0) {
|
||||||
|
zipEntryName = fileName.substring(0, dotIndex) + "_" + counter + fileName.substring(dotIndex);
|
||||||
|
} else {
|
||||||
|
zipEntryName = fileName + "_" + counter;
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
homeworkFiles.put(zipEntryName, fullPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 5.设置响应头信息为zip文件
|
||||||
|
response.setContentType("application/zip");
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename=HomeWorkRecord.zip");
|
||||||
|
outputStream = response.getOutputStream();
|
||||||
|
// 6.把输出的附件和导出的excel文件拼接为一个zip导出
|
||||||
|
try (ZipOutputStream zos = new ZipOutputStream(outputStream)) {
|
||||||
|
// 添加Excel文件到zip
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
// 添加Excel文件
|
||||||
|
File excelFile = new File(tempExcelPath);
|
||||||
|
if (excelFile.exists()) {
|
||||||
|
FileInputStream fis = new FileInputStream(excelFile);
|
||||||
|
ZipEntry zipEntry = new ZipEntry("HomeWorkRecord.xlsx");
|
||||||
|
zos.putNextEntry(zipEntry);
|
||||||
|
int length;
|
||||||
|
while ((length = fis.read(buffer)) > 0) {
|
||||||
|
zos.write(buffer, 0, length);
|
||||||
|
}
|
||||||
|
zos.closeEntry();
|
||||||
|
fis.close();
|
||||||
|
}
|
||||||
|
// 添加作业附件文件
|
||||||
|
// 25.11.27标记:和技术沟通后,按业务此处调用频率不会过高,因此暂不采用多线程下载方案
|
||||||
|
// 为了防止命名冲突,附件放在zip的/附件目录下
|
||||||
|
// zip规范要求使用 正斜杠/作为路径分隔符,不要用File.separator(在windows上是\,会导致zip解压异常)
|
||||||
|
String zipFilePath = "附件/";
|
||||||
|
for (Map.Entry<String, String> entry : homeworkFiles.entrySet()) {
|
||||||
|
String zipEntryName = zipFilePath + entry.getKey();
|
||||||
|
String filePath = entry.getValue();
|
||||||
|
File file = new File(filePath);
|
||||||
|
if (file.exists()) {
|
||||||
|
FileInputStream fis = new FileInputStream(file);
|
||||||
|
ZipEntry zipEntry = new ZipEntry(zipEntryName);
|
||||||
|
zos.putNextEntry(zipEntry);
|
||||||
|
int len;
|
||||||
|
while ((len = fis.read(buffer)) > 0) {
|
||||||
|
zos.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
zos.closeEntry();
|
||||||
|
fis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 删除临时Excel文件
|
||||||
|
if (tempExcelFile.exists()) {
|
||||||
|
tempExcelFile.delete();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【资源学习情况导出-作业信息】导出资源学习情况错误:{}", e.getMessage());
|
||||||
|
} finally {
|
||||||
|
if (outputStream != null) {
|
||||||
|
try {
|
||||||
|
outputStream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("关闭输出流失败:{}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value="/study-course-content",method = {RequestMethod.GET,RequestMethod.POST})
|
@RequestMapping(value="/study-course-content",method = {RequestMethod.GET,RequestMethod.POST})
|
||||||
public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId){
|
public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId){
|
||||||
if(StringUtils.isBlank(studyId)){
|
if(StringUtils.isBlank(studyId)){
|
||||||
|
|||||||
@@ -1,20 +1,5 @@
|
|||||||
package com.xboe.school.study.api;
|
package com.xboe.school.study.api;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import com.xboe.common.OrderCondition;
|
import com.xboe.common.OrderCondition;
|
||||||
import com.xboe.common.PageList;
|
import com.xboe.common.PageList;
|
||||||
import com.xboe.common.Pagination;
|
import com.xboe.common.Pagination;
|
||||||
@@ -26,8 +11,16 @@ import com.xboe.core.api.ApiBaseController;
|
|||||||
import com.xboe.school.study.dto.BatchSignup;
|
import com.xboe.school.study.dto.BatchSignup;
|
||||||
import com.xboe.school.study.entity.StudySignup;
|
import com.xboe.school.study.entity.StudySignup;
|
||||||
import com.xboe.school.study.service.IStudySignupService;
|
import com.xboe.school.study.service.IStudySignupService;
|
||||||
|
|
||||||
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.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课程报名, 本控制器只有一个报名处理,没有其它的处理
|
* 课程报名, 本控制器只有一个报名处理,没有其它的处理
|
||||||
@@ -63,17 +56,24 @@ public class StudySignupApi extends ApiBaseController{
|
|||||||
return error("报名失败,请与管理员联系",e.getMessage());
|
return error("报名失败,请与管理员联系",e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 分页查询报名人员
|
||||||
|
* @param pager 分页
|
||||||
|
* @param courseId 课程id
|
||||||
|
* @param name 姓名
|
||||||
|
* @param signType 报名方式
|
||||||
|
* @return 返回课程报名表的集合
|
||||||
|
*/
|
||||||
@PostMapping("/pagelist")
|
@PostMapping("/pagelist")
|
||||||
public JsonResponse<PageList<StudySignup>> findPage(Pagination pager,String courseId,String name,Integer status){
|
public JsonResponse<PageList<StudySignup>> findPage(Pagination pager, String courseId, String name, Integer signType) {
|
||||||
// if(StringUtils.isBlank(courseId)){
|
// if(StringUtils.isBlank(courseId)){
|
||||||
// return error("无课程信息");
|
// return error("无课程信息");
|
||||||
// }
|
// }
|
||||||
StudySignup ss=new StudySignup();
|
StudySignup ss=new StudySignup();
|
||||||
ss.setCourseId(courseId);
|
ss.setCourseId(courseId);
|
||||||
ss.setName(name);
|
ss.setName(name);
|
||||||
ss.setStatus(status);
|
//2025.11.28 新增signType筛选
|
||||||
|
ss.setSignType(signType);
|
||||||
//CurrentUser cuser=getCurrent();
|
//CurrentUser cuser=getCurrent();
|
||||||
try {
|
try {
|
||||||
PageList<StudySignup> list =signupService.findPage(pager.getPageIndex(),pager.getPageSize(), ss, OrderCondition.desc("id"));
|
PageList<StudySignup> list =signupService.findPage(pager.getPageIndex(),pager.getPageSize(), ss, OrderCondition.desc("id"));
|
||||||
|
|||||||
@@ -6,34 +6,56 @@ import com.xboe.school.study.dto.CourseFinishCountDto;
|
|||||||
import com.xboe.school.study.entity.StudyCourse;
|
import com.xboe.school.study.entity.StudyCourse;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class CourseStatDao extends BaseDao<StudyCourse> {
|
public class CourseStatDao extends BaseDao<StudyCourse> {
|
||||||
// 查当前页DTO列表(参数:偏移量、每页条数、courseId)
|
|
||||||
public List<CourseFinishCountDto> findFinishCountPage(int startIndex, int pageSize, String courseId) {
|
/**
|
||||||
|
* 查询课程完成人数
|
||||||
|
*
|
||||||
|
* @param startIndex 分页开始索引
|
||||||
|
* @param pageSize 分页大小
|
||||||
|
* @param courseId 课程ID
|
||||||
|
* @param contentName 资源名称
|
||||||
|
* @return 课程完成人数统计DTO集合
|
||||||
|
*/
|
||||||
|
public List<CourseFinishCountDto> findFinishCountPage(int startIndex, int pageSize, String courseId, String contentName) {
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("SELECT ")
|
sql.append("SELECT ")
|
||||||
// 课程名(和DTO字段对应)
|
// 资源名
|
||||||
.append("c.content_name AS contentName, ")
|
.append("cc.content_name AS contentName, ")
|
||||||
|
// 资源ID
|
||||||
|
.append("cc.id AS contentId, ")
|
||||||
// 完成人数(去重统计)
|
// 完成人数(去重统计)
|
||||||
.append("COUNT(DISTINCT c.aid) AS finishCount ")
|
.append("COUNT(DISTINCT c.aid) AS finishCount, ")
|
||||||
// 你的课程表名(必改!)
|
//2025.11.27新增:资源类型
|
||||||
.append("FROM boe_study_course_item c ")
|
.append("cc.content_type AS contentType ")
|
||||||
.append("WHERE 1=1 ")
|
// 你的课程表名
|
||||||
// 条件:已完成
|
.append("FROM boe_course_content cc ")
|
||||||
.append("AND c.status = 9 ");
|
// 2025.11.27新增:连表 boe_course_content
|
||||||
|
.append("LEFT JOIN boe_study_course_item c ON cc.id = c.content_id AND c.status = 9 ")
|
||||||
|
.append("WHERE 1=1 ");
|
||||||
List<Object> params = new ArrayList<>();
|
List<Object> params = new ArrayList<>();
|
||||||
// courseId非空则过滤(参数化防注入)
|
// courseId非空则过滤(参数化防注入)
|
||||||
if (StringUtils.isNotBlank(courseId)) {
|
if (StringUtils.isNotBlank(courseId)) {
|
||||||
sql.append("AND c.course_id = ? ");
|
sql.append("AND cc.course_id = ? ");
|
||||||
params.add(courseId);
|
params.add(courseId);
|
||||||
}
|
}
|
||||||
|
// 25.12.1修改 新增:contentName模糊查询(粗略匹配)
|
||||||
|
if (StringUtils.isNotBlank(contentName)) {
|
||||||
|
// 实现“包含contentName”的模糊查询
|
||||||
|
sql.append("AND cc.content_name LIKE ? ");
|
||||||
|
// 通配符%拼接在参数上防注入,表示“前后任意字符包含contentName”
|
||||||
|
params.add("%" + contentName + "%");
|
||||||
|
}
|
||||||
// 分组+排序+分页(聚合函数必须分组,排序参考第一个代码的desc id)
|
// 分组+排序+分页(聚合函数必须分组,排序参考第一个代码的desc id)
|
||||||
sql.append("GROUP BY c.content_id, c.content_name ")
|
sql.append("GROUP BY cc.id, cc.content_name, cc.content_type ")
|
||||||
.append("ORDER BY c.content_id DESC ")
|
.append("ORDER BY cc.id DESC ")
|
||||||
.append("LIMIT ?, ?"); // MySQL分页:偏移量,每页条数
|
// MySQL分页:偏移量,每页条数
|
||||||
|
.append("LIMIT ?, ?");
|
||||||
// 补充分页参数(顺序:startIndex → pageSize)
|
// 补充分页参数(顺序:startIndex → pageSize)
|
||||||
params.add(startIndex);
|
params.add(startIndex);
|
||||||
params.add(pageSize);
|
params.add(pageSize);
|
||||||
@@ -44,28 +66,41 @@ public class CourseStatDao extends BaseDao<StudyCourse> {
|
|||||||
for (Object[] objs : resultList) {
|
for (Object[] objs : resultList) {
|
||||||
CourseFinishCountDto dto = new CourseFinishCountDto();
|
CourseFinishCountDto dto = new CourseFinishCountDto();
|
||||||
dto.setContentName(objs[0] != null ? (String) objs[0] : "");
|
dto.setContentName(objs[0] != null ? (String) objs[0] : "");
|
||||||
dto.setFinishCount(objs[1] != null ? ((Number) objs[1]).intValue() : 0);
|
dto.setContentId(((BigInteger) objs[1]).toString());
|
||||||
|
dto.setFinishCount(objs[2] != null ? ((Number) objs[2]).intValue() : 0);
|
||||||
|
dto.setContentType((Integer) objs[3]);
|
||||||
dtoList.add(dto);
|
dtoList.add(dto);
|
||||||
}
|
}
|
||||||
return dtoList;
|
return dtoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查总条数(返回int类型,匹配PageList的count字段)
|
/**
|
||||||
public int findFinishCountTotal(String courseId) {
|
* 查询课程完成人数
|
||||||
|
*
|
||||||
|
* @param courseId 课程ID
|
||||||
|
* @param contentName 资源名称
|
||||||
|
* @return 课程完成人数
|
||||||
|
*/
|
||||||
|
public int findFinishCountTotal(String courseId, String contentName) {
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("SELECT ")
|
sql.append("SELECT ")
|
||||||
// 总条数=去重后的人数(和GROUP BY对应)
|
// 总条数=去重后的人数
|
||||||
.append("COUNT(DISTINCT c.content_id) ")
|
.append("COUNT(DISTINCT c.id) ")
|
||||||
.append("FROM boe_study_course_item c ")
|
.append("FROM boe_course_content c ")
|
||||||
.append("WHERE 1=1 ")
|
.append("WHERE 1=1 ");
|
||||||
// 条件:已完成
|
|
||||||
.append("AND c.status = 9 ");
|
|
||||||
List<Object> params = new ArrayList<>();
|
List<Object> params = new ArrayList<>();
|
||||||
// courseId非空则过滤(参数化防注入)
|
// courseId非空则过滤(参数化防注入)
|
||||||
if (StringUtils.isNotBlank(courseId)) {
|
if (StringUtils.isNotBlank(courseId)) {
|
||||||
sql.append("AND c.course_id = ? ");
|
sql.append("AND c.course_id = ? ");
|
||||||
params.add(courseId);
|
params.add(courseId);
|
||||||
}
|
}
|
||||||
|
// 25.12.1修改 新增:contentName模糊查询(粗略匹配)
|
||||||
|
if (StringUtils.isNotBlank(contentName)) {
|
||||||
|
// 实现“包含contentName”的模糊查询
|
||||||
|
sql.append("AND c.content_name LIKE ? ");
|
||||||
|
// 通配符%拼接在参数上防注入,表示“前后任意字符包含contentName”
|
||||||
|
params.add("%" + contentName + "%");
|
||||||
|
}
|
||||||
// 用sqlCount替代sqlFindObject,直接返回int类型结果
|
// 用sqlCount替代sqlFindObject,直接返回int类型结果
|
||||||
// sqlCount会执行SQL并返回COUNT的结果,无需手动转换Object
|
// sqlCount会执行SQL并返回COUNT的结果,无需手动转换Object
|
||||||
return this.sqlCount(sql.toString(), params.toArray());
|
return this.sqlCount(sql.toString(), params.toArray());
|
||||||
|
|||||||
@@ -2,6 +2,11 @@ package com.xboe.school.study.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 课程完成人数统计DTO
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CourseFinishCountDto {
|
public class CourseFinishCountDto {
|
||||||
|
|
||||||
@@ -10,9 +15,21 @@ public class CourseFinishCountDto {
|
|||||||
*/
|
*/
|
||||||
private String contentName;
|
private String contentName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容ID
|
||||||
|
*/
|
||||||
|
private String contentId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 完成人数(数据库 count 统计得出)
|
* 完成人数(数据库 count 统计得出)
|
||||||
*/
|
*/
|
||||||
private Integer finishCount;
|
private Integer finishCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容类型
|
||||||
|
* 枚举值参考BoedxContentType
|
||||||
|
*/
|
||||||
|
private Integer contentType;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,12 @@ public class CourseSignDto {
|
|||||||
/**
|
/**
|
||||||
* 报名状态(1.自主报名 2.手动加入)
|
* 报名状态(1.自主报名 2.手动加入)
|
||||||
*/
|
*/
|
||||||
private String signType;
|
private Integer signType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报名状态显示(1.自主报名 2.手动加入)
|
||||||
|
*/
|
||||||
|
private String signTypeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课程名称
|
* 课程名称
|
||||||
|
|||||||
@@ -144,4 +144,12 @@ public class StudyCourseItem extends IdEntity {
|
|||||||
*/
|
*/
|
||||||
@Transient
|
@Transient
|
||||||
private List<StudyExam> studyExams;
|
private List<StudyExam> studyExams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评估记录集合
|
||||||
|
* 仅在资源学习情况分页查询-评估信息接口使用
|
||||||
|
* 25.11.28新增
|
||||||
|
*/
|
||||||
|
@Transient
|
||||||
|
private List<StudyAssess> studyAssesses;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,4 +28,13 @@ public interface IStudyAssessService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<StudyAssess> getByStudyIdAndContentId(String studyId,String contentId);
|
List<StudyAssess> getByStudyIdAndContentId(String studyId,String contentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据课程id和内容id得到评估的内容
|
||||||
|
* @param courseId 课程id
|
||||||
|
* @param contentId 内容
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<StudyAssess> getByCourseIdAndContentId(String courseId,String contentId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,8 +69,9 @@ public interface IStudyCourseService {
|
|||||||
* @param pageIndex 页码
|
* @param pageIndex 页码
|
||||||
* @param pageSize 每页数据条数
|
* @param pageSize 每页数据条数
|
||||||
* @param courseId 课程id
|
* @param courseId 课程id
|
||||||
|
* @param contentName 资源名称
|
||||||
*/
|
*/
|
||||||
PageList<CourseFinishCountDto> findPageResource(int pageIndex, int pageSize, String courseId);
|
PageList<CourseFinishCountDto> findPageResource(int pageIndex, int pageSize, String courseId, String contentName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 热度榜
|
* 热度榜
|
||||||
|
|||||||
@@ -31,13 +31,15 @@ public interface IStudyExamService {
|
|||||||
List<StudyExam> getByStudyIdAndContentId(String studyId,String contentId);
|
List<StudyExam> getByStudyIdAndContentId(String studyId,String contentId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据课程id得到对应的考试记录
|
* 根据课程id或者内容id得到对应的考试记录
|
||||||
|
* 课程id必填,内容id选填
|
||||||
* 25.11.20新增
|
* 25.11.20新增
|
||||||
*
|
*
|
||||||
* @param courseId 课程id
|
* @param courseId 课程id
|
||||||
|
* @param contentId 内容id
|
||||||
* @return 考试记录集合
|
* @return 考试记录集合
|
||||||
*/
|
*/
|
||||||
List<StudyExam> getByCourseId(String courseId);
|
List<StudyExam> getByCourseIdAndContentId(String courseId, String contentId);
|
||||||
|
|
||||||
void correctStstus(String courseId);
|
void correctStstus(String courseId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package com.xboe.school.study.service;
|
package com.xboe.school.study.service;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.xboe.school.study.entity.StudyHomeWork;
|
import com.xboe.school.study.entity.StudyHomeWork;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface IStudyHomeWorkService {
|
public interface IStudyHomeWorkService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,17 +11,17 @@ public interface IStudyHomeWorkService {
|
|||||||
* @param exam
|
* @param exam
|
||||||
*/
|
*/
|
||||||
void save(StudyHomeWork homework,String token);
|
void save(StudyHomeWork homework,String token);
|
||||||
|
|
||||||
|
|
||||||
StudyHomeWork get(String id);
|
StudyHomeWork get(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据学习内容id得到答卷信息
|
* 根据学习内容id得到答卷信息
|
||||||
* @param studyItemId
|
* @param studyItemId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<StudyHomeWork> getByStudyItem(String studyItemId);
|
List<StudyHomeWork> getByStudyItem(String studyItemId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据学习id和内容id查出作业列表
|
* 根据学习id和内容id查出作业列表
|
||||||
* @param studyId
|
* @param studyId
|
||||||
@@ -32,4 +31,15 @@ public interface IStudyHomeWorkService {
|
|||||||
List<StudyHomeWork> getByStudyIdAndContentId(String studyId,String contentId);
|
List<StudyHomeWork> getByStudyIdAndContentId(String studyId,String contentId);
|
||||||
|
|
||||||
List<StudyHomeWork>getByStudnetNameAndContentId(List<String> studentName, String contentId);
|
List<StudyHomeWork>getByStudnetNameAndContentId(List<String> studentName, String contentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据课程id得到对应的作业记录
|
||||||
|
* 25.11.20新增
|
||||||
|
*
|
||||||
|
* @param courseId 课程id
|
||||||
|
* @param contentId 内容id
|
||||||
|
* @return 作业记录集合
|
||||||
|
*/
|
||||||
|
List<StudyHomeWork> getByCourseIdAndContentId(String courseId, String contentId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ public class CourseSignServiceImpl implements ICourseSignService {
|
|||||||
if (StringUtils.isNotBlank(queryDto.getCourseId())) {
|
if (StringUtils.isNotBlank(queryDto.getCourseId())) {
|
||||||
query.addFilter(FieldFilters.eq("courseId", queryDto.getCourseId()));
|
query.addFilter(FieldFilters.eq("courseId", queryDto.getCourseId()));
|
||||||
}
|
}
|
||||||
// 3. 课程类型精确查询
|
//3. 课程类型精确查询
|
||||||
if (queryDto.getSignType() != null) {
|
if (queryDto.getSignType() != null) {
|
||||||
query.addFilter(FieldFilters.eq("courseType", queryDto.getSignType()));
|
query.addFilter(FieldFilters.eq("signType", queryDto.getSignType()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return coursesignDao.findList(query.builder());
|
return coursesignDao.findList(query.builder());
|
||||||
|
|||||||
@@ -86,4 +86,15 @@ public class StudyAssessServiceImpl implements IStudyAssessService{
|
|||||||
return dao.findList(FieldFilters.eq("studyId", studyId),FieldFilters.eq("contentId", contentId));
|
return dao.findList(FieldFilters.eq("studyId", studyId),FieldFilters.eq("contentId", contentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据课程id和内容id得到评估的内容
|
||||||
|
* @param courseId 课程id
|
||||||
|
* @param contentId 内容
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<StudyAssess> getByCourseIdAndContentId(String courseId,String contentId){
|
||||||
|
return dao.findList(FieldFilters.eq("courseId", courseId),FieldFilters.eq("contentId", contentId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ package com.xboe.school.study.service.impl;
|
|||||||
|
|
||||||
import com.xboe.common.OrderCondition;
|
import com.xboe.common.OrderCondition;
|
||||||
import com.xboe.common.PageList;
|
import com.xboe.common.PageList;
|
||||||
import com.xboe.core.orm.*;
|
import com.xboe.core.orm.FieldFilters;
|
||||||
|
import com.xboe.core.orm.FieldUpdateType;
|
||||||
|
import com.xboe.core.orm.QueryBuilder;
|
||||||
|
import com.xboe.core.orm.UpdateBuilder;
|
||||||
import com.xboe.core.utils.ConvertUtil;
|
import com.xboe.core.utils.ConvertUtil;
|
||||||
import com.xboe.data.outside.IOutSideDataService;
|
import com.xboe.data.outside.IOutSideDataService;
|
||||||
import com.xboe.module.course.dao.CourseContentDao;
|
import com.xboe.module.course.dao.CourseContentDao;
|
||||||
@@ -16,6 +19,7 @@ import com.xboe.school.study.entity.StudyCourseItem;
|
|||||||
import com.xboe.school.study.entity.StudySignup;
|
import com.xboe.school.study.entity.StudySignup;
|
||||||
import com.xboe.school.study.service.IStudyCourseService;
|
import com.xboe.school.study.service.IStudyCourseService;
|
||||||
import com.xboe.school.study.service.IStudySignupService;
|
import com.xboe.school.study.service.IStudySignupService;
|
||||||
|
import com.xboe.system.organization.entity.Organization;
|
||||||
import com.xboe.system.organization.service.IOrganizationService;
|
import com.xboe.system.organization.service.IOrganizationService;
|
||||||
import com.xboe.system.user.entity.User;
|
import com.xboe.system.user.entity.User;
|
||||||
import com.xboe.system.user.service.IUserService;
|
import com.xboe.system.user.service.IUserService;
|
||||||
@@ -23,15 +27,17 @@ import com.xboe.system.user.vo.UserSimpleVo;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
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.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -55,6 +61,10 @@ public class StudyCourseServiceImpl implements IStudyCourseService{
|
|||||||
@Autowired
|
@Autowired
|
||||||
IOrganizationService organizationService;
|
IOrganizationService organizationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Lazy
|
||||||
|
IStudyCourseService studyCourseService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
StudyCourseDao studyCourseDao;
|
StudyCourseDao studyCourseDao;
|
||||||
|
|
||||||
@@ -91,6 +101,13 @@ public class StudyCourseServiceImpl implements IStudyCourseService{
|
|||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
ICourseStudySearch esSearch;//对ES的处理
|
ICourseStudySearch esSearch;//对ES的处理
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于避免JPA查询后修改entity实体字段,自动更新到数据库
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StudyCourse findByCourseIdAndAid(String courseId, String aid) {
|
public StudyCourse findByCourseIdAndAid(String courseId, String aid) {
|
||||||
//加上排序,如果是多条学习记录,只会取最新的一条
|
//加上排序,如果是多条学习记录,只会取最新的一条
|
||||||
@@ -145,36 +162,6 @@ public class StudyCourseServiceImpl implements IStudyCourseService{
|
|||||||
if(StringUtils.isNotBlank(sc.getAid())) {
|
if(StringUtils.isNotBlank(sc.getAid())) {
|
||||||
query.addFilter(FieldFilters.eq("aid", sc.getAid()));
|
query.addFilter(FieldFilters.eq("aid", sc.getAid()));
|
||||||
}
|
}
|
||||||
// 25.11.25新增:添加基于时间的查询条件
|
|
||||||
if (sc.getQueryStartTime() != null && sc.getQueryFinishTime() != null) {
|
|
||||||
// 开始结束时间均传入的情况,实现筛选逻辑
|
|
||||||
// (startTime >= 查询开始时间 AND startTime <= 查询结束时间) OR (finishTime >= 查询开始时间 AND finishTime <= 查询结束时间)
|
|
||||||
// 这样兼容查询结束时间为空值的情况,因为学员课程未结束时没有结束时间
|
|
||||||
LocalDate startDate = LocalDate.parse(sc.getQueryStartTime());
|
|
||||||
LocalDateTime startDateTime = startDate.atStartOfDay();
|
|
||||||
LocalDate finishDate = LocalDate.parse(sc.getQueryFinishTime());
|
|
||||||
LocalDateTime finishDateTime = finishDate.atTime(LocalTime.MAX);
|
|
||||||
// 筛选开始时间
|
|
||||||
IFieldFilter startTimeInRange = FieldFilters.and(FieldFilters.ge("startTime", startDateTime), FieldFilters.le("startTime", finishDateTime));
|
|
||||||
// 筛选结束时间
|
|
||||||
IFieldFilter finishTimeInRange = FieldFilters.and(FieldFilters.ge("finishTime", startDateTime), FieldFilters.le("finishTime", finishDateTime));
|
|
||||||
// OR条件查询
|
|
||||||
query.addFilter(FieldFilters.or(startTimeInRange, finishTimeInRange));
|
|
||||||
} else {
|
|
||||||
// 只输出单个参数情况
|
|
||||||
// 筛选开始时间
|
|
||||||
if (sc.getQueryStartTime() != null) {
|
|
||||||
LocalDate startDate = LocalDate.parse(sc.getQueryStartTime());
|
|
||||||
LocalDateTime startDateTime = startDate.atStartOfDay();
|
|
||||||
query.addFilter(FieldFilters.ge("startTime", startDateTime));
|
|
||||||
}
|
|
||||||
// 筛选结束时间
|
|
||||||
if (sc.getQueryFinishTime() != null) {
|
|
||||||
LocalDate finishDate = LocalDate.parse(sc.getQueryFinishTime());
|
|
||||||
LocalDateTime finishDateTime = finishDate.atTime(LocalTime.MAX);
|
|
||||||
query.addFilter(FieldFilters.le("finishTime", finishDateTime));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 原有查询是否结束逻辑
|
// 原有查询是否结束逻辑
|
||||||
if (isFinish != null) {
|
if (isFinish != null) {
|
||||||
@@ -216,8 +203,10 @@ public class StudyCourseServiceImpl implements IStudyCourseService{
|
|||||||
for (StudyCourse studyCourse1 : studyCourses) {
|
for (StudyCourse studyCourse1 : studyCourses) {
|
||||||
if (Objects.equals(userId, studyCourse1.getAid())) {
|
if (Objects.equals(userId, studyCourse1.getAid())) {
|
||||||
log.info("【分页查询课程学习记录】查询boe人员表,机构id:{}", userInfo.getDepartId());
|
log.info("【分页查询课程学习记录】查询boe人员表,机构id:{}", userInfo.getDepartId());
|
||||||
// 和技术沟通后,确认这里机构名称是redis获取的,获取不到返回null,因此正常遍历没有效率和空值问题
|
// 获取部门信息(参考现有机构表,获取namePath字段)
|
||||||
studyCourse1.setOrgInfo(organizationService.getName(userInfo.getDepartId()));
|
Organization organization = organizationService.get(userInfo.getDepartId());
|
||||||
|
String departName = organization != null ? organization.getNamePath() : "";
|
||||||
|
studyCourse1.setOrgInfo(departName);
|
||||||
// 取userNo为工号
|
// 取userNo为工号
|
||||||
studyCourse1.setUserNo(userInfo.getUserNo());
|
studyCourse1.setUserNo(userInfo.getUserNo());
|
||||||
}
|
}
|
||||||
@@ -228,17 +217,73 @@ public class StudyCourseServiceImpl implements IStudyCourseService{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 25.12.3新增,添加基于时间的查询条件,规则如下:
|
||||||
|
if (sc != null && StringUtils.isNotBlank(sc.getCourseId()) && StringUtils.isNotBlank(sc.getQueryStartTime()) && StringUtils.isNotBlank(sc.getQueryFinishTime())) {
|
||||||
|
List<StudyCourseItem> studyCourseItemList = studyCourseService.getStudyCourseItemByCourseId(sc.getCourseId());
|
||||||
|
if (studyCourseItemList != null && !studyCourseItemList.isEmpty()) {
|
||||||
|
// 将学习内容按照studyId进行分组,便于后续计算每个studyId下的总学习时长
|
||||||
|
Map<String, List<StudyCourseItem>> itemsByStudyId = studyCourseItemList.stream().filter(item -> item.getFinishTime() != null).collect(Collectors.groupingBy(StudyCourseItem::getStudyId));
|
||||||
|
// 获取查询的起止时间
|
||||||
|
String queryStartTime = sc.getQueryStartTime();
|
||||||
|
String queryFinishTime = sc.getQueryFinishTime();
|
||||||
|
for (StudyCourse studyCourse : studyCourses) {
|
||||||
|
// 实体类解耦
|
||||||
|
entityManager.detach(studyCourse);
|
||||||
|
// 解析查询时间范围
|
||||||
|
LocalDate startDate = LocalDate.parse(queryStartTime);
|
||||||
|
LocalDate endDate = LocalDate.parse(queryFinishTime);
|
||||||
|
// 如果有查询时间范围,则计算筛选后的学习时长
|
||||||
|
if (itemsByStudyId.containsKey(studyCourse.getId())) {
|
||||||
|
List<StudyCourseItem> items = itemsByStudyId.get(studyCourse.getId());
|
||||||
|
int filteredDuration = 0;
|
||||||
|
for (StudyCourseItem item : items) {
|
||||||
|
LocalDateTime finishTime = item.getFinishTime();
|
||||||
|
LocalDate finishDate = finishTime.toLocalDate();
|
||||||
|
// 判断结束时间是否在筛选范围内
|
||||||
|
boolean inRange = true;
|
||||||
|
if (finishDate.isBefore(startDate)) {
|
||||||
|
inRange = false;
|
||||||
|
}
|
||||||
|
if (finishDate.isAfter(endDate)) {
|
||||||
|
inRange = false;
|
||||||
|
}
|
||||||
|
// 如果在范围内,则累加学习时长
|
||||||
|
if (inRange) {
|
||||||
|
Integer duration = item.getStudyDuration();
|
||||||
|
if (duration != null) {
|
||||||
|
filteredDuration += duration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 更新学习时长
|
||||||
|
studyCourse.setTotalDuration(filteredDuration);
|
||||||
|
} else {
|
||||||
|
// 查询不到item的情况,默认置空
|
||||||
|
studyCourse.setTotalDuration(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return studyCoursePageList;
|
return studyCoursePageList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询课程的资源名称以及资源学习完成人数
|
||||||
|
*
|
||||||
|
* @param pageIndex 页码
|
||||||
|
* @param pageSize 每页数据条数
|
||||||
|
* @param courseId 课程id
|
||||||
|
* @param contentName 资源名称
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageList<CourseFinishCountDto> findPageResource(int pageIndex, int pageSize, String courseId) {
|
public PageList<CourseFinishCountDto> findPageResource(int pageIndex, int pageSize, String courseId, String contentName) {
|
||||||
// 1. 手动计算分页偏移量(数据库分页必需)
|
// 1. 手动计算分页偏移量(数据库分页必需)
|
||||||
// pageIndex<1时设为0,避免数据库LIMIT偏移量为负数
|
// pageIndex<1时设为0,避免数据库LIMIT偏移量为负数
|
||||||
int startIndex = (pageIndex < 1) ? 0 : (pageIndex - 1) * pageSize;
|
int startIndex = (pageIndex < 1) ? 0 : (pageIndex - 1) * pageSize;
|
||||||
// 2. 调用Dao层:查当前页数据(传入偏移量、每页条数、courseId条件)
|
// 2. 调用Dao层:查当前页数据(传入偏移量、每页条数、courseId条件)
|
||||||
List<CourseFinishCountDto> dtoList = courseStatDao.findFinishCountPage(startIndex, pageSize, courseId);
|
List<CourseFinishCountDto> dtoList = courseStatDao.findFinishCountPage(startIndex, pageSize, courseId,contentName);
|
||||||
// 3. 调用Dao层:查总条数(对应PageList的count字段,用int类型,和PageList一致)
|
// 3. 调用Dao层:查总条数(对应PageList的count字段,用int类型,和PageList一致)
|
||||||
int totalCount = courseStatDao.findFinishCountTotal(courseId);
|
int totalCount = courseStatDao.findFinishCountTotal(courseId,contentName);
|
||||||
// 4. 按PageList构造函数创建对象(只传list和count)
|
// 4. 按PageList构造函数创建对象(只传list和count)
|
||||||
PageList<CourseFinishCountDto> pageList = new PageList<>(dtoList, totalCount);
|
PageList<CourseFinishCountDto> pageList = new PageList<>(dtoList, totalCount);
|
||||||
// 5. 设置pageSize(覆盖默认10,确保总页数计算正确)
|
// 5. 设置pageSize(覆盖默认10,确保总页数计算正确)
|
||||||
@@ -806,36 +851,6 @@ public class StudyCourseServiceImpl implements IStudyCourseService{
|
|||||||
if (StringUtils.isNotBlank(sc.getAid())) {
|
if (StringUtils.isNotBlank(sc.getAid())) {
|
||||||
query.addFilter(FieldFilters.eq("aid", sc.getAid()));
|
query.addFilter(FieldFilters.eq("aid", sc.getAid()));
|
||||||
}
|
}
|
||||||
// 25.11.25新增:添加基于时间的查询条件
|
|
||||||
if (sc.getQueryStartTime() != null && sc.getQueryFinishTime() != null) {
|
|
||||||
// 开始结束时间均传入的情况,实现筛选逻辑
|
|
||||||
// (startTime >= 查询开始时间 AND startTime <= 查询结束时间) OR (finishTime >= 查询开始时间 AND finishTime <= 查询结束时间)
|
|
||||||
// 这样兼容查询结束时间为空值的情况,因为学员课程未结束时没有结束时间
|
|
||||||
LocalDate startDate = LocalDate.parse(sc.getQueryStartTime());
|
|
||||||
LocalDateTime startDateTime = startDate.atStartOfDay();
|
|
||||||
LocalDate finishDate = LocalDate.parse(sc.getQueryFinishTime());
|
|
||||||
LocalDateTime finishDateTime = finishDate.atTime(LocalTime.MAX);
|
|
||||||
// 筛选开始时间
|
|
||||||
IFieldFilter startTimeInRange = FieldFilters.and(FieldFilters.ge("startTime", startDateTime), FieldFilters.le("startTime", finishDateTime));
|
|
||||||
// 筛选结束时间
|
|
||||||
IFieldFilter finishTimeInRange = FieldFilters.and(FieldFilters.ge("finishTime", startDateTime), FieldFilters.le("finishTime", finishDateTime));
|
|
||||||
// OR条件查询
|
|
||||||
query.addFilter(FieldFilters.or(startTimeInRange, finishTimeInRange));
|
|
||||||
} else {
|
|
||||||
// 只输出单个参数情况
|
|
||||||
// 筛选开始时间
|
|
||||||
if (sc.getQueryStartTime() != null) {
|
|
||||||
LocalDate startDate = LocalDate.parse(sc.getQueryStartTime());
|
|
||||||
LocalDateTime startDateTime = startDate.atStartOfDay();
|
|
||||||
query.addFilter(FieldFilters.ge("startTime", startDateTime));
|
|
||||||
}
|
|
||||||
// 筛选结束时间
|
|
||||||
if (sc.getQueryFinishTime() != null) {
|
|
||||||
LocalDate finishDate = LocalDate.parse(sc.getQueryFinishTime());
|
|
||||||
LocalDateTime finishDateTime = finishDate.atTime(LocalTime.MAX);
|
|
||||||
query.addFilter(FieldFilters.le("finishTime", finishDateTime));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isFinish != null) {
|
if (isFinish != null) {
|
||||||
if (isFinish) {
|
if (isFinish) {
|
||||||
@@ -844,7 +859,55 @@ public class StudyCourseServiceImpl implements IStudyCourseService{
|
|||||||
query.addFilter(FieldFilters.lt("status", 9));
|
query.addFilter(FieldFilters.lt("status", 9));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return studyCourseDao.findList(query.builder());
|
// 25.12.3新增,添加基于时间的查询条件,规则如下:
|
||||||
|
List<StudyCourse> studyCourses = studyCourseDao.findList(query.builder());
|
||||||
|
if (sc != null && StringUtils.isNotBlank(sc.getCourseId()) && StringUtils.isNotBlank(sc.getQueryStartTime()) && StringUtils.isNotBlank(sc.getQueryFinishTime())) {
|
||||||
|
List<StudyCourseItem> studyCourseItemList = studyCourseService.getStudyCourseItemByCourseId(sc.getCourseId());
|
||||||
|
if (studyCourseItemList != null && !studyCourseItemList.isEmpty()) {
|
||||||
|
// 将学习内容按照studyId进行分组,便于后续计算每个studyId下的总学习时长
|
||||||
|
Map<String, List<StudyCourseItem>> itemsByStudyId = studyCourseItemList.stream().filter(item -> item.getFinishTime() != null).collect(Collectors.groupingBy(StudyCourseItem::getStudyId));
|
||||||
|
// 获取查询的起止时间
|
||||||
|
String queryStartTime = sc.getQueryStartTime();
|
||||||
|
String queryFinishTime = sc.getQueryFinishTime();
|
||||||
|
for (StudyCourse studyCourse : studyCourses) {
|
||||||
|
// 实体类解耦
|
||||||
|
entityManager.detach(studyCourse);
|
||||||
|
// 解析查询时间范围
|
||||||
|
LocalDate startDate = LocalDate.parse(queryStartTime);
|
||||||
|
LocalDate endDate = LocalDate.parse(queryFinishTime);
|
||||||
|
// 如果有查询时间范围,则计算筛选后的学习时长
|
||||||
|
if (itemsByStudyId.containsKey(studyCourse.getId())) {
|
||||||
|
List<StudyCourseItem> items = itemsByStudyId.get(studyCourse.getId());
|
||||||
|
int filteredDuration = 0;
|
||||||
|
for (StudyCourseItem item : items) {
|
||||||
|
LocalDateTime finishTime = item.getFinishTime();
|
||||||
|
LocalDate finishDate = finishTime.toLocalDate();
|
||||||
|
// 判断结束时间是否在筛选范围内
|
||||||
|
boolean inRange = true;
|
||||||
|
if (finishDate.isBefore(startDate)) {
|
||||||
|
inRange = false;
|
||||||
|
}
|
||||||
|
if (finishDate.isAfter(endDate)) {
|
||||||
|
inRange = false;
|
||||||
|
}
|
||||||
|
// 如果在范围内,则累加学习时长
|
||||||
|
if (inRange) {
|
||||||
|
Integer duration = item.getStudyDuration();
|
||||||
|
if (duration != null) {
|
||||||
|
filteredDuration += duration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 更新学习时长
|
||||||
|
studyCourse.setTotalDuration(filteredDuration);
|
||||||
|
} else {
|
||||||
|
// 查询不到item的情况,默认置空
|
||||||
|
studyCourse.setTotalDuration(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return studyCourses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.xboe.school.study.service.impl;
|
|||||||
|
|
||||||
import com.xboe.common.OrderCondition;
|
import com.xboe.common.OrderCondition;
|
||||||
import com.xboe.core.orm.FieldFilters;
|
import com.xboe.core.orm.FieldFilters;
|
||||||
|
import com.xboe.core.orm.IFieldFilter;
|
||||||
import com.xboe.core.orm.QueryBuilder;
|
import com.xboe.core.orm.QueryBuilder;
|
||||||
import com.xboe.core.orm.UpdateBuilder;
|
import com.xboe.core.orm.UpdateBuilder;
|
||||||
import com.xboe.module.course.dao.CourseContentDao;
|
import com.xboe.module.course.dao.CourseContentDao;
|
||||||
@@ -159,15 +160,24 @@ public class StudyExamServiceImpl implements IStudyExamService{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据课程id得到对应的考试记录
|
* 根据课程id或者内容id得到对应的考试记录
|
||||||
|
* 课程id必填,内容id选填
|
||||||
* 25.11.20新增
|
* 25.11.20新增
|
||||||
*
|
*
|
||||||
* @param courseId 课程id
|
* @param courseId 课程id
|
||||||
|
* @param contentId 内容id
|
||||||
* @return 考试记录集合
|
* @return 考试记录集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<StudyExam> getByCourseId(String courseId) {
|
public List<StudyExam> getByCourseIdAndContentId(String courseId, String contentId) {
|
||||||
return dao.findList(OrderCondition.desc("id"), FieldFilters.eq("courseId", courseId));
|
if (StringUtils.isEmpty(courseId)) {
|
||||||
|
throw new IllegalArgumentException("课程id不能为空");
|
||||||
|
}
|
||||||
|
IFieldFilter filter = FieldFilters.eq("courseId", courseId);
|
||||||
|
if (StringUtils.isNotEmpty(contentId)) {
|
||||||
|
filter = FieldFilters.and(filter, FieldFilters.eq("contentId", contentId));
|
||||||
|
}
|
||||||
|
return dao.findList(OrderCondition.desc("id"), filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
package com.xboe.school.study.service.impl;
|
package com.xboe.school.study.service.impl;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import com.xboe.common.OrderCondition;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import com.xboe.core.orm.FieldFilters;
|
import com.xboe.core.orm.FieldFilters;
|
||||||
|
import com.xboe.core.orm.IFieldFilter;
|
||||||
import com.xboe.module.course.dao.CourseContentDao;
|
import com.xboe.module.course.dao.CourseContentDao;
|
||||||
import com.xboe.school.study.dao.StudyCourseDao;
|
import com.xboe.school.study.dao.StudyCourseDao;
|
||||||
import com.xboe.school.study.dao.StudyCourseItemDao;
|
import com.xboe.school.study.dao.StudyCourseItemDao;
|
||||||
@@ -17,6 +10,14 @@ import com.xboe.school.study.dao.StudyHomeWorkDao;
|
|||||||
import com.xboe.school.study.entity.StudyCourseItem;
|
import com.xboe.school.study.entity.StudyCourseItem;
|
||||||
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 org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
|
public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
|
||||||
@@ -95,4 +96,24 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
|
|||||||
return dao.findList(FieldFilters.in("student_name", studentName),FieldFilters.eq("contentId", contentId));
|
return dao.findList(FieldFilters.in("student_name", studentName),FieldFilters.eq("contentId", contentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据课程id得到对应的作业记录
|
||||||
|
* 25.11.20新增
|
||||||
|
*
|
||||||
|
* @param courseId 课程id
|
||||||
|
* @param contentId 内容id
|
||||||
|
* @return 作业记录集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<StudyHomeWork> getByCourseIdAndContentId(String courseId, String contentId) {
|
||||||
|
if (StringUtils.isEmpty(courseId)) {
|
||||||
|
throw new IllegalArgumentException("课程id不能为空");
|
||||||
|
}
|
||||||
|
IFieldFilter filter = FieldFilters.eq("courseId", courseId);
|
||||||
|
if (StringUtils.isNotEmpty(contentId)) {
|
||||||
|
filter = FieldFilters.and(filter, FieldFilters.eq("contentId", contentId));
|
||||||
|
}
|
||||||
|
return dao.findList(OrderCondition.desc("id"), filter);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
query.addFilter(FieldFilters.eq("courseId",courseId));
|
query.addFilter(FieldFilters.eq("courseId",courseId));
|
||||||
}
|
}
|
||||||
if(StringUtils.isNotBlank(name)) {
|
if(StringUtils.isNotBlank(name)) {
|
||||||
query.addFilter(FieldFilters.eq("aname", name));
|
query.addFilter(FieldFilters.like("aname", name));
|
||||||
}
|
}
|
||||||
int pageIndex2 = (pageIndex-1)*10;
|
int pageIndex2 = (pageIndex-1)*10;
|
||||||
if(status!=null) {
|
if(status!=null) {
|
||||||
@@ -265,65 +265,26 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
return scItemDao.findPage(query.builder());
|
return scItemDao.findPage(query.builder());
|
||||||
}else if (status == 1) {
|
}else if (status == 1) {
|
||||||
// 25.11.27标注:这里是查询没有item联表数据的主表数据,等同于没有学习情况的资源
|
// 25.11.27标注:这里是查询没有item联表数据的主表数据,等同于没有学习情况的资源
|
||||||
String sql = "select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.content_id,0 as progress,1 as status,item.id as item_id from boe_study_course bsc " +
|
// 25.12.1修改:找技术帮忙查看了前端代码,没有status == 1的调用,此处应查询状态为未开始的数据,重写此处逻辑
|
||||||
" left join boe_study_course_item item on bsc.course_id = item.course_id and bsc.id = item.study_id" +
|
// 未开始(结合现有数据,这里筛选状态为1及为null的数据)
|
||||||
" where bsc.course_id = '" + courseId + "'" +
|
query.addFilter(FieldFilters.or(FieldFilters.eq("status", 1), FieldFilters.isNull("status")));
|
||||||
(StringUtils.isBlank(name) ? "" : "and bsc.aname like '%"+name+"%'") + "and bsc.id not in(" +
|
return scItemDao.findPage(query.builder());
|
||||||
" select item.study_id from boe_study_course_item item " +
|
|
||||||
" where item.course_id = '" + courseId + "'" +
|
|
||||||
(StringUtils.isBlank(contentId) ? "" : "and item.content_id = '" + contentId + "'") +
|
|
||||||
(StringUtils.isBlank(name) ? "" : "and item.aname like '%" + name+"%'") + " group by item.study_id" +
|
|
||||||
" ) group by bsc.id limit "+ pageIndex2+","+ pageSize+";";
|
|
||||||
|
|
||||||
String sql2 = "select count(*) as total from (select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.content_id,0 as progress,1 as status from boe_study_course bsc " +
|
|
||||||
" left join boe_study_course_item item on bsc.course_id = item.course_id and bsc.id = item.study_id" +
|
|
||||||
" where bsc.course_id = '"+courseId+"'" +
|
|
||||||
(StringUtils.isBlank(name) ? "" : "and bsc.aname like '%"+name+"%'") + " and bsc.id not in(" +
|
|
||||||
" select item.study_id from boe_study_course_item item " +
|
|
||||||
" where item.course_id = '" + courseId + "'" +
|
|
||||||
(StringUtils.isBlank(contentId) ? "" : "and item.content_id = '" + contentId + "'") +
|
|
||||||
(StringUtils.isBlank(name) ? "" : "and item.aname like '%" + name+"%'") + " group by item.study_id" +
|
|
||||||
" ) group by bsc.id) as total";
|
|
||||||
log.info("资源完成情况sql:{}", sql);
|
|
||||||
List<Object[]> list = scDao.sqlFindList(sql);
|
|
||||||
int totalCount = scDao.sqlCount(sql2);
|
|
||||||
List<StudyCourseItem> item = new ArrayList<>();
|
|
||||||
for (Object[] objs : list) {
|
|
||||||
StudyCourseItem sc = new StudyCourseItem();
|
|
||||||
// 25.11.27新增,如果有id,添加item表id供后续联表使用
|
|
||||||
if (objs[7] != null) {
|
|
||||||
sc.setId(String.valueOf(objs[7]));
|
|
||||||
}
|
|
||||||
sc.setProgress(Integer.valueOf(objs[5].toString()));
|
|
||||||
sc.setStatus(Integer.valueOf(objs[6].toString()));
|
|
||||||
sc.setAname(objs[3].toString());
|
|
||||||
item.add(sc);
|
|
||||||
}
|
|
||||||
PageList<StudyCourseItem> pageList = new PageList<>(item);
|
|
||||||
pageList.setCount(totalCount);
|
|
||||||
pageList.setPageSize(pageSize);
|
|
||||||
pageList.setList(item);
|
|
||||||
return pageList;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 未传输status的情况,查询所有资源学习情况数据
|
// 未传输status的情况,查询所有资源学习情况数据
|
||||||
String sql = "select a.id, a.course_id, a.course_name, a.aname, " + "IFNULL(b.finish_time, '0') as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status,b.score,b.item_id " + "from (select id, course_id, course_name, aname, 0, 1 from boe_study_course where course_id = '" + courseId + "'" + (StringUtils.isBlank(name) ? "" : "and item.aname like '%" + name + "%'") + ") a " + "left join " + "(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.id as item_id,item.finish_time, item.progress, item.status,MAX(item.score) score " +
|
String sql = "select a.id, a.course_id, a.course_name, a.aname, " + "IFNULL(b.finish_time, '0') as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status " + ",b.score,b.item_id,b.aid " + "from (select id, course_id, course_name, aname, 0, 1 from boe_study_course where course_id = '" + courseId + "'" + (StringUtils.isBlank(name) ? "" : "and aname like '%" + name + "%'") + ") a " + "inner join " + "(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.id as item_id,item.finish_time, item.progress, item.status,MAX(item.score) score,item.aid " + "from boe_study_course bsc left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " + "where bsc.course_id = '" + courseId + "'" +
|
||||||
"from boe_study_course bsc left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
|
|
||||||
"where bsc.course_id = '" + courseId + "'" +
|
|
||||||
(StringUtils.isBlank(contentId) ? "" : "and item.content_id = '" + contentId + "'") +
|
(StringUtils.isBlank(contentId) ? "" : "and item.content_id = '" + contentId + "'") +
|
||||||
(StringUtils.isBlank(name) ? "" : "and item.aname like '%" + name +"%'") + " group by bsc.id) b " +
|
(StringUtils.isBlank(name) ? "" : "and item.aname like '%" + name +"%'") + " group by bsc.id) b " +
|
||||||
"on a.course_id = b.course_id and a.id = b.id " +
|
"on a.course_id = b.course_id and a.id = b.id " +
|
||||||
"group by a.id limit "+ pageIndex2+","+ pageSize+";";
|
"group by a.id limit "+ pageIndex2+","+ pageSize+";";
|
||||||
String sql2 = "select count(*) as total from (select a.id, a.course_id, a.course_name, a.aname, " +
|
String sql2 = "select count(*) as total from (select a.id, a.course_id, a.course_name, a.aname, " + "IFNULL(b.finish_time, 0) as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status " + "from (select id, course_id, course_name, aname, 0, 1 from boe_study_course where course_id = '" + courseId + "'" + (StringUtils.isBlank(name) ? "" : "and aname like '%" + name + "%'") + ") a " + "inner join " + "(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.finish_time, item.progress, item.status " + "from boe_study_course bsc left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " + "where bsc.course_id = '" + courseId + "'" +
|
||||||
"IFNULL(b.finish_time, 0) as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status " +
|
|
||||||
"from (select id, course_id, course_name, aname, 0, 1 from boe_study_course where course_id = '" + courseId + "'" +
|
|
||||||
(StringUtils.isBlank(name) ? "" : "and item.aname like '%" + name + "%'") + ") a " + "left join " + "(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.finish_time, item.progress, item.status " + "from boe_study_course bsc left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " + "where bsc.course_id = '" + courseId + "'" +
|
|
||||||
(StringUtils.isBlank(contentId) ? "" : "and item.content_id = '" + contentId + "'") +
|
(StringUtils.isBlank(contentId) ? "" : "and item.content_id = '" + contentId + "'") +
|
||||||
(StringUtils.isBlank(name) ? "" : "and item.aname like '%" + name +"%'") +
|
(StringUtils.isBlank(name) ? "" : "and item.aname like '%" + name +"%'") +
|
||||||
" group by bsc.id) b " +
|
" group by bsc.id) b " +
|
||||||
"on a.course_id = b.course_id and a.id = b.id " +
|
"on a.course_id = b.course_id and a.id = b.id " +
|
||||||
"group by a.id) as total";
|
"group by a.id) as total";
|
||||||
log.info("资源完成情况sql:{}", sql);
|
log.info("资源完成情况sql:{}", sql);
|
||||||
|
log.info("数量查询sql:{}", sql2);
|
||||||
List<Object[]> list = scDao.sqlFindList(sql);
|
List<Object[]> list = scDao.sqlFindList(sql);
|
||||||
int totalCount = scDao.sqlCount(sql2);
|
int totalCount = scDao.sqlCount(sql2);
|
||||||
List<StudyCourseItem> item = new ArrayList<>();
|
List<StudyCourseItem> item = new ArrayList<>();
|
||||||
@@ -344,6 +305,10 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
if(objs[7] != null){
|
if(objs[7] != null){
|
||||||
sc.setScore(Float.valueOf(objs[7].toString()));
|
sc.setScore(Float.valueOf(objs[7].toString()));
|
||||||
}
|
}
|
||||||
|
// 25.12.5新增,补全aid查询
|
||||||
|
if (objs[8] != null) {
|
||||||
|
sc.setAid(String.valueOf(objs[8].toString()));
|
||||||
|
}
|
||||||
item.add(sc);
|
item.add(sc);
|
||||||
}
|
}
|
||||||
PageList<StudyCourseItem> pageList = new PageList<>(item);
|
PageList<StudyCourseItem> pageList = new PageList<>(item);
|
||||||
|
|||||||
Reference in New Issue
Block a user