diff --git a/servers/boe-server-all/src/main/java/com/xboe/school/study/service/impl/StudyServiceImpl.java b/servers/boe-server-all/src/main/java/com/xboe/school/study/service/impl/StudyServiceImpl.java index 3a459007..dfda15af 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/school/study/service/impl/StudyServiceImpl.java +++ b/servers/boe-server-all/src/main/java/com/xboe/school/study/service/impl/StudyServiceImpl.java @@ -265,59 +265,19 @@ public class StudyServiceImpl implements IStudyService{ return scItemDao.findPage(query.builder()); }else if (status == 1) { // 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 " + - " 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 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 list = scDao.sqlFindList(sql); - int totalCount = scDao.sqlCount(sql2); - List 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 pageList = new PageList<>(item); - pageList.setCount(totalCount); - pageList.setPageSize(pageSize); - pageList.setList(item); - return pageList; + // 25.12.1修改:找技术帮忙查看了前端代码,没有status == 1的调用,此处应查询状态为未开始的数据,重写此处逻辑 + // 未开始(结合现有数据,这里筛选状态为1及为null的数据) + query.addFilter(FieldFilters.or(FieldFilters.eq("status", 1), FieldFilters.isNull("status"))); + return scItemDao.findPage(query.builder()); } } // 未传输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 " + - "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 + "'" + + 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 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 " + "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(name) ? "" : "and item.aname like '%" + name +"%'") + " group by bsc.id) b " + "on a.course_id = b.course_id and a.id = b.id " + "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, " + - "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 + "'" + + 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 + "'" + (StringUtils.isBlank(contentId) ? "" : "and item.content_id = '" + contentId + "'") + (StringUtils.isBlank(name) ? "" : "and item.aname like '%" + name +"%'") + " group by bsc.id) b " +