Merge branch 'zcwy0716-llf' into dev0525

This commit is contained in:
nisen
2024-07-30 11:06:11 +08:00

View File

@@ -2,6 +2,7 @@ package com.xboe.school.study.service.impl;
import java.math.BigInteger;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -181,6 +182,7 @@ public class StudyServiceImpl implements IStudyService{
if(StringUtils.isNotBlank(name)) {
query.addFilter(FieldFilters.eq("aname", name));
}
int pageIndex2 = pageIndex-1;
if(status!=null) {
if(status==3) {
query.addFilter(FieldFilters.eq("status", 2));
@@ -189,50 +191,103 @@ public class StudyServiceImpl implements IStudyService{
query.addFilter(FieldFilters.eq("status",9));
return scItemDao.findPage(query.builder());
}else if (status == 1) {
String sql = "select bsc.id,bsc.course_id,bsc.course_name,bsc.aname from boe_study_course bsc " +
" where bsc.course_id = '"+courseId+"' and bsc.id != (" +
" 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+"'" +
" )";
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 "+ 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+"' 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) as total";
log.info("资源完成情况未开始sql"+sql);
List<Object[]> list = scDao.sqlFindList(sql);
log.info("资源完成情况人数"+list);
int totalCount = scDao.sqlCount(sql2);
List<StudyCourseItem> item = new ArrayList<>();
for (Object[] objs : list) {
String sql2 = "select id, course_id, content_name, aname from boe_study_course_item where `status` !=2 and `status` !=9 and course_id = '" + courseId + "' and content_id = '"+contentId +"'";
List<Object[]> itemList = scItemDao.sqlFindList(sql2);// 执行查询
if (itemList.isEmpty()) {
StudyCourseItem sc = new StudyCourseItem();
sc.setProgress(0);
sc.setStatus(1);
sc.setAname(objs[3].toString());
item.add(sc);
}
StudyCourseItem sc = new StudyCourseItem();
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<StudyCourseItem> pageList = new PageList<>(item);
pageList.setCount(totalCount);
pageList.setPageSize(pageSize);
pageList.setList(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+"' " +
"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 != (" +
" 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+"'" +
" )) a group by a.id";
List<Object[]> 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, 1) 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 " +
"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 + "') 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 " +
"on a.course_id = b.course_id and a.id = b.id " +
"group by a.id) as total";
log.info("资源完成情况全部sql"+sql);
List<Object[]> list = scDao.sqlFindList(sql);
log.info("资源完成情况人数"+list);
int totalCount = scDao.sqlCount(sql2);
List<StudyCourseItem> 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()));
if (!"0".equals(objs[4].toString())) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime finishTime = LocalDateTime.parse(objs[4].toString(), formatter);
sc.setFinishTime(finishTime);
}
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<StudyCourseItem> pageList = new PageList<>(item);
pageList.setCount(totalCount);
pageList.setPageSize(pageSize);
pageList.setList(item);
return pageList;
}