From c97cd3daabcfbec0792af2a310c7699323e25f00 Mon Sep 17 00:00:00 2001 From: zhaolongfei <2651195677@qq.com> Date: Fri, 26 Jul 2024 20:24:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E7=AE=A1=E7=90=86=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=AE=8C=E6=88=90=E6=83=85=E5=86=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../study/service/impl/StudyServiceImpl.java | 71 ++++++++++++++----- 1 file changed, 54 insertions(+), 17 deletions(-) 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 c1b09442..cf5b51e6 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 @@ -184,12 +184,21 @@ public class StudyServiceImpl implements IStudyService{ if(status!=null) { if(status==3) { query.addFilter(FieldFilters.eq("status", 2)); + query.addGroupBy("studyId"); return scItemDao.findPage(query.builder()); }else if(status==2){ query.addFilter(FieldFilters.eq("status",9)); + query.addGroupBy("studyId"); return scItemDao.findPage(query.builder()); }else if (status == 1) { String sql = "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+"' and bsc.id not in(" + + " select item.study_id from boe_study_course_item item " + + " where item.course_id = '" + courseId + "' and item.content_id = '"+ contentId+"' group by item.study_id" + + " ) group by bsc.id limit "+ pageIndex+","+ pageSize+";"; + + String sql2 = "select count(*) 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+"' and bsc.id not in(" + " select item.study_id from boe_study_course_item item " + @@ -207,34 +216,62 @@ public class StudyServiceImpl implements IStudyService{ item.add(sc); } log.info("资源完成情况人员"+item); - PageList pageList = new PageList<>(item,pageSize); + PageList pageList = new PageList<>(item); return pageList; } } - String sql2 = "select * from (select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,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.`status` in (2,9) and bsc.course_id = '"+ courseId+"' group by bsc.id " + - " UNION ALL " + - " select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,0 as progress,1 as status from boe_study_course bsc " + - " LEFT JOIN boe_study_course_item item on item.course_id = bsc.course_id " + - " where bsc.course_id = '"+courseId+"' and bsc.id not in (" + - " select bsc.id 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 + "' and item.content_id = '"+ contentId+"' group by bsc.id" + - " )group by bsc.id) a group by a.id"; - log.info("资源完成情况全部sql"+sql2); - List list = scDao.sqlFindList(sql2); +// String sql = "select * from (select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,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.`status` in (2,9) and bsc.course_id = '"+ courseId+"' group by bsc.id " + +// " UNION ALL " + +// " select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,0 as progress,1 as status from boe_study_course bsc " + +// " LEFT JOIN boe_study_course_item item on item.course_id = bsc.course_id " + +// " where bsc.course_id = '"+courseId+"' and bsc.id not in (" + +// " select bsc.id 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 + "' and item.content_id = '"+ contentId+"' group by bsc.id" + +// " )group by bsc.id) a group by a.id limit "+ pageIndex+","+ pageSize+";"; + +// String sql2 = "select count(*) from (select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,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.`status` in (2,9) and bsc.course_id = '"+ courseId+"' group by bsc.id " + +// " UNION ALL " + +// " select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,0 as progress,1 as status from boe_study_course bsc " + +// " LEFT JOIN boe_study_course_item item on item.course_id = bsc.course_id " + +// " where bsc.course_id = '"+courseId+"' and bsc.id not in (" + +// " select bsc.id 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 + "' and item.content_id = '"+ contentId+"' group by bsc.id" + +// " )group by bsc.id) a group by a.id"; + 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,0) as status " + + " from (select id,course_id,course_name,aname,0,1 from boe_study_course where course_id = ‘"+courseId+"')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 +"' and item.content_id = '"+ contentId+"' group by bsc.id)b group by a.id"; + String sql2 = "select count(*) as status " + + " from (select id,course_id,course_name,aname,0,1 from boe_study_course where course_id = ‘"+courseId+"')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 +"' and item.content_id = '"+ contentId+"' group by bsc.id)b group by a.id"; + log.info("资源完成情况全部sql"+sql); + List list = scDao.sqlFindList(sql); log.info("资源完成情况人数"+list); List item = new ArrayList<>(); for (Object[] objs : list) { StudyCourseItem sc = new StudyCourseItem(); - sc.setProgress(Integer.valueOf(objs[4].toString())); - sc.setStatus(Integer.valueOf(objs[5].toString())); + sc.setFinishTime(LocalDateTime.parse(objs[4].toString())); + sc.setProgress(Integer.valueOf(objs[5].toString())); + sc.setStatus(Integer.valueOf(objs[6].toString())); sc.setAname(objs[3].toString()); item.add(sc); } log.info("资源完成情况人员"+item); - PageList pageList = new PageList<>(item, pageSize); + PageList pageList = new PageList<>(item); + pageList.setCount(Integer.parseInt(sql2)); + pageList.setPageSize(pageSize); + pageList.setList(item); return pageList; }