mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-12 12:26:51 +08:00
Merge branch 'zcwy0424-l' into 'master'
Zcwy0424 l See merge request !79
This commit is contained in:
@@ -13,4 +13,11 @@ public class CourseContentDao extends BaseDao<CourseContent> {
|
|||||||
int sum=count(hql, courseId);
|
int sum=count(hql, courseId);
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCount(String courseId) {
|
||||||
|
// String hql="SELECT count(*) from boe_course_content c left join boe_base.boe_course_section s on c.csection_id = s.id where c.course_id = ?1 and c.deleted =0 and s.id is not null";
|
||||||
|
String hql="SELECT count(*) from CourseContent c left join CourseSection s on c.csectionId = s.id where c.courseId = ?1 and c.deleted =0 and s.id is not null";
|
||||||
|
int count=count(hql, courseId);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,16 @@ public class StudyExamApi extends ApiBaseController{
|
|||||||
@Autowired
|
@Autowired
|
||||||
IStudyExamService sexamService;
|
IStudyExamService sexamService;
|
||||||
|
|
||||||
|
/**2024.04.24
|
||||||
|
* 矫正学员课程进度及完成状态
|
||||||
|
* */
|
||||||
|
@GetMapping("/correctStstus")
|
||||||
|
public void correctStstus(){
|
||||||
|
log.info("---------矫正学员课程进度及完成状态--correctStstus---开始-----");
|
||||||
|
sexamService.correctStstus();
|
||||||
|
log.info("---------矫正学员课程进度及完成状态--correctStstus---结束-----");
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public JsonResponse<StudyExam> save(@RequestBody StudyExam exam){
|
public JsonResponse<StudyExam> save(@RequestBody StudyExam exam){
|
||||||
if(StringUtils.isBlank(exam.getCourseId())) {
|
if(StringUtils.isBlank(exam.getCourseId())) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.xboe.school.study.dao;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ import com.xboe.module.course.dao.CourseContentDao;
|
|||||||
import com.xboe.school.study.entity.StudyCourse;
|
import com.xboe.school.study.entity.StudyCourse;
|
||||||
import com.xboe.school.study.entity.StudyCourseItem;
|
import com.xboe.school.study.entity.StudyCourseItem;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Repository
|
@Repository
|
||||||
public class StudyCourseDao extends BaseDao<StudyCourse> {
|
public class StudyCourseDao extends BaseDao<StudyCourse> {
|
||||||
|
|
||||||
@@ -32,7 +34,8 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
//已完成的内容
|
//已完成的内容
|
||||||
int n=scItemDao.count(FieldFilters.eq("studyId",studyId),FieldFilters.eq("status",StudyCourseItem.STATUS_FINISH));
|
int n=scItemDao.count(FieldFilters.eq("studyId",studyId),FieldFilters.eq("status",StudyCourseItem.STATUS_FINISH));
|
||||||
if(total==null) {
|
if(total==null) {
|
||||||
total=courseContentDao.count(FieldFilters.eq("courseId", courseId),FieldFilters.eq("deleted",false));
|
// total=courseContentDao.count(FieldFilters.eq("courseId", courseId),FieldFilters.eq("deleted",false));
|
||||||
|
total = courseContentDao.getCount(courseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
//以下注意,float类型,是否等于100对应
|
//以下注意,float类型,是否等于100对应
|
||||||
@@ -52,6 +55,39 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void finishCheck1(String studyId,String courseId,Integer total){
|
||||||
|
LocalDateTime now=LocalDateTime.now();
|
||||||
|
//已完成的内容
|
||||||
|
int n=scItemDao.count(FieldFilters.eq("studyId",studyId),FieldFilters.eq("status",StudyCourseItem.STATUS_FINISH));
|
||||||
|
if(total==null) {
|
||||||
|
// total=courseContentDao.count(FieldFilters.eq("courseId", courseId),FieldFilters.eq("deleted",false));
|
||||||
|
total = courseContentDao.getCount(courseId);
|
||||||
|
}
|
||||||
|
if (total != 0){
|
||||||
|
|
||||||
|
//以下注意,float类型,是否等于100对应
|
||||||
|
float percent=n*100/total;
|
||||||
|
if(n>=total) {
|
||||||
|
log.info(" 100进度 CourseId = " + courseId + " , StudyId = " + studyId + " , total = " + total + ",已完成 = " + n);
|
||||||
|
//自主报名的课程,代表学习完成
|
||||||
|
super.updateMultiFieldById(studyId,
|
||||||
|
UpdateBuilder.create("progress",100f),
|
||||||
|
UpdateBuilder.create("lastTime",now),
|
||||||
|
UpdateBuilder.create("finishTime",now),
|
||||||
|
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
|
||||||
|
}else {
|
||||||
|
log.info("进度=" + percent + " ,CourseId = " + courseId + " , StudyId = " + studyId + " , total = " + total + ",已完成 = " + n);
|
||||||
|
super.updateMultiFieldById(studyId,
|
||||||
|
UpdateBuilder.create("progress",percent),
|
||||||
|
UpdateBuilder.create("lastTime",LocalDateTime.now()),
|
||||||
|
UpdateBuilder.create("status",StudyCourse.STATUS_STUDYING));
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
log.info("----------分母等于0-------total = " + total);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 仅仅是更新学习进度,不做其它的处理
|
* 仅仅是更新学习进度,不做其它的处理
|
||||||
* @param studyId
|
* @param studyId
|
||||||
|
|||||||
@@ -5,6 +5,14 @@ import org.springframework.stereotype.Repository;
|
|||||||
import com.xboe.core.orm.BaseDao;
|
import com.xboe.core.orm.BaseDao;
|
||||||
import com.xboe.school.study.entity.StudyExam;
|
import com.xboe.school.study.entity.StudyExam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class StudyExamDao extends BaseDao<StudyExam> {
|
public class StudyExamDao extends BaseDao<StudyExam> {
|
||||||
|
|
||||||
|
public List<StudyExam> getAllStudyExamByStudyId() {
|
||||||
|
String hql1 = "SELECT courseId,studyId,studentId FROM StudyExam GROUP BY studyId";
|
||||||
|
List<StudyExam> listByHql = super.findListByHql(hql1);
|
||||||
|
return listByHql;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,4 +29,6 @@ public interface IStudyExamService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<StudyExam> getByStudyIdAndContentId(String studyId,String contentId);
|
List<StudyExam> getByStudyIdAndContentId(String studyId,String contentId);
|
||||||
|
|
||||||
|
void correctStstus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import java.util.List;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
import com.xboe.core.orm.QueryBuilder;
|
||||||
|
import com.xboe.system.user.entity.Message;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -21,6 +24,7 @@ import com.xboe.school.study.entity.StudyCourseItem;
|
|||||||
import com.xboe.school.study.entity.StudyExam;
|
import com.xboe.school.study.entity.StudyExam;
|
||||||
import com.xboe.school.study.service.IStudyExamService;
|
import com.xboe.school.study.service.IStudyExamService;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class StudyExamServiceImpl implements IStudyExamService{
|
public class StudyExamServiceImpl implements IStudyExamService{
|
||||||
|
|
||||||
@@ -71,7 +75,8 @@ public class StudyExamServiceImpl implements IStudyExamService{
|
|||||||
//更新最终成绩
|
//更新最终成绩
|
||||||
//if(exam.get)
|
//if(exam.get)
|
||||||
//检查是否全部学习完成
|
//检查是否全部学习完成
|
||||||
int totalContent=courseContentDao.count(FieldFilters.eq("courseId", exam.getCourseId()),FieldFilters.eq("deleted",false));
|
// int totalContent=courseContentDao.count(FieldFilters.eq("courseId", exam.getCourseId()),FieldFilters.eq("deleted",false));
|
||||||
|
int totalContent = courseContentDao.getCount(exam.getCourseId());
|
||||||
scDao.finishCheck(exam.getStudyId(),exam.getCourseId(),totalContent);
|
scDao.finishCheck(exam.getStudyId(),exam.getCourseId(),totalContent);
|
||||||
}else {
|
}else {
|
||||||
exam.setStudyItemId(obj.toString());//此项就是学习条目的id
|
exam.setStudyItemId(obj.toString());//此项就是学习条目的id
|
||||||
@@ -104,4 +109,44 @@ public class StudyExamServiceImpl implements IStudyExamService{
|
|||||||
return dao.findList(OrderCondition.desc("id"),FieldFilters.eq("studyId", studyId),FieldFilters.eq("contentId", contentId));
|
return dao.findList(OrderCondition.desc("id"),FieldFilters.eq("studyId", studyId),FieldFilters.eq("contentId", contentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void correctStstus() {
|
||||||
|
|
||||||
|
/* List<StudyExam> list = null;
|
||||||
|
try {
|
||||||
|
list = dao.getAllStudyExamByStudyId();
|
||||||
|
log.info("------------list.size = " + list.size() + ",0 = " + list.get(0));
|
||||||
|
|
||||||
|
for(StudyExam item : list){
|
||||||
|
log.info("-----------------CourseId = " + item.getCourseId() + " , StudyId = " + item.getStudyId() + " , StudentId = " + item.getStudentId());
|
||||||
|
int totalContent = courseContentDao.getCount(item.getCourseId());
|
||||||
|
scDao.finishCheck(item.getStudyId(),item.getCourseId(),totalContent);
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
try {
|
||||||
|
QueryBuilder builder = QueryBuilder.from(StudyExam.class);
|
||||||
|
builder.addGroupBy("studyId");
|
||||||
|
List<StudyExam> list1 = dao.findList(builder.builder());
|
||||||
|
log.info("------------QueryBuilder list1.size = " + list1.size() + ",0 = " + list1.get(0));
|
||||||
|
|
||||||
|
for(StudyExam item : list1){
|
||||||
|
log.info("-----------------CourseId = " + item.getCourseId() + " , StudyId = " + item.getStudyId() + " , StudentId = " + item.getStudentId());
|
||||||
|
int totalContent = courseContentDao.getCount(item.getCourseId());
|
||||||
|
log.info("----------准备判断进度-------totalContent = " + totalContent);
|
||||||
|
scDao.finishCheck1(item.getStudyId(),item.getCourseId(),totalContent);
|
||||||
|
log.info("----------判断进度完毕----------------------");
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
log.info("------异常----------------------:" +exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user