Commit 2081ddca authored by zhangqingle's avatar zhangqingle

Merge branch 'meiteng' of ssh://103.249.252.28:10022/lcy/education into meiteng

parents 92804c46 ee87005e
......@@ -71,17 +71,12 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
String isFinish = "0";
// 沒有開始看-新增信息
if (null != brStudentChapterList && brStudentChapterList.size() >0){
BRStudentChapter brStudentChapter = brStudentChapterList.get(0);
brStudentChapter.setCurrentLocation(brStudentChapterDto.getCurrent());
if (brStudentChapterDto.getCurrent().equals(brStudentChapterDto.getDuration())){
brStudentChapter.setProgress(1);
double old = brStudentChapterList.get(0).getProgress();
BRStudentChapter brStudentChapter = this.dealBrstudentChapter(brStudentChapterList.get(0), brStudentChapterDto);
if (1== brStudentChapter.getProgress()){
isFinish = "2";
}else{
isFinish = "1";
brStudentChapter.setProgress(new BigDecimal((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}
// 判断进度 是否大于数据库已经存在的进度
double old = brStudentChapterList.get(0).getProgress();
double now = brStudentChapter.getProgress();
if (now > old){
line = bRStudentChapterRepository.updateById(brStudentChapter);
......@@ -89,18 +84,23 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
}else { // 更新
BRStudentChapter brStudentChapter = new BRStudentChapter();
brStudentChapter.setBusinessId(IdGen.uuid());
brStudentChapter = this.dealBrstudentChapter(brStudentChapter, brStudentChapterDto);
brStudentChapter.setStudentId(brStudentChapterDto.getStudentId());
brStudentChapter.setChapterId(brStudentChapterDto.getChapterId());
brStudentChapter.setCurrentLocation(brStudentChapterDto.getCurrent()); // 保存當前學習進度
if (brStudentChapterDto.getCurrent() == brStudentChapterDto.getDuration()){ // 判断是否已经完成
brStudentChapter.setIsComplete("1");
brStudentChapter.setProgress(1);
if (1== brStudentChapter.getProgress()){
isFinish = "2";
}else {
isFinish = "1";
brStudentChapter.setIsComplete("0");
brStudentChapter.setProgress(new BigDecimal((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}
// brStudentChapter.setCurrentLocation(brStudentChapterDto.getCurrent()); // 保存當前學習進度
// if (brStudentChapterDto.getCurrent().equals(brStudentChapterDto.getDuration())){ // 判断是否已经完成
// brStudentChapter.setIsComplete("1");
// brStudentChapter.setProgress(1);
// isFinish = "2";
// }else {
// isFinish = "1";
// brStudentChapter.setIsComplete("0");
// brStudentChapter.setProgress((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration());
//// brStudentChapter.setProgress(new BigDecimal((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
// }
line = bRStudentChapterRepository.insertSelective(brStudentChapter);
}
// b_lesson_person
......@@ -135,23 +135,25 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
};
// 判斷是否已經開始觀看此課程
if (null != bLessonPersonList && bLessonPersonList.size() >0){
BLessonPerson bLessonPerson = bLessonPersonList.get(0);
bLessonPerson.setChapterId(brStudentChapterDto.getChapterId());
bLessonPerson.setLearnProgress(totalProgress); // 保存课程学习进度
if ("2".equals(isFinish))
bLessonPerson.setFinishDate(new Date());
bLessonPerson.setIsFinish(isFinish);
BLessonPerson bLessonPerson = this.dealBLessonPerson(bLessonPersonList.get(0),brStudentChapterDto,totalProgress,isFinish);
// BLessonPerson bLessonPerson = bLessonPersonList.get(0);
// bLessonPerson.setChapterId(brStudentChapterDto.getChapterId());
// bLessonPerson.setLearnProgress(totalProgress); // 保存课程学习进度
// if ("2".equals(isFinish))
// bLessonPerson.setFinishDate(new Date());
// bLessonPerson.setIsFinish(isFinish);
bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
}else {
BLessonPerson bLessonPerson = new BLessonPerson();
UserUtil.setCurrentPersistOperation(bLessonPerson);
bLessonPerson.setChapterId(brStudentChapterDto.getChapterId());
bLessonPerson = this.dealBLessonPerson(bLessonPersonList.get(0),brStudentChapterDto,totalProgress,isFinish);
bLessonPerson.setPersonId(brStudentChapterDto.getStudentId());
bLessonPerson.setLessonId(brStudentChapterDto.getLessonId());
bLessonPerson.setLearnProgress(totalProgress); // 保存课程学习进度
if ("2".equals(isFinish))
bLessonPerson.setFinishDate(new Date());
bLessonPerson.setIsFinish(isFinish);
// if ("2".equals(isFinish))
// bLessonPerson.setFinishDate(new Date());
// bLessonPerson.setIsFinish(isFinish);
// bLessonPerson.setChapterId(brStudentChapterDto.getChapterId());
// bLessonPerson.setLearnProgress(totalProgress); // 保存课程学习进度
line = bLessonPersonRepository.insertSelective(bLessonPerson) > line ? bLessonPersonRepository.insertSelective(bLessonPerson): line ;
}
// 获取章节总进度 存库
......@@ -163,6 +165,28 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
return new PersistModel(line);
}
// b_r_student_chapter
private BRStudentChapter dealBrstudentChapter(BRStudentChapter brStudentChapter, BRStudentChapterDto brStudentChapterDto){
brStudentChapter.setCurrentLocation(brStudentChapterDto.getCurrent());
if (brStudentChapterDto.getCurrent().equals(brStudentChapterDto.getDuration())){
brStudentChapter.setProgress(1);
}else{
brStudentChapter.setProgress((Math.floor((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()*100))/100);
}
return brStudentChapter;
}
// b_lesson_person
private BLessonPerson dealBLessonPerson(BLessonPerson bLessonPerson, BRStudentChapterDto brStudentChapterDto, String totalProgress, String isFinish){
bLessonPerson.setChapterId(brStudentChapterDto.getChapterId());
bLessonPerson.setLearnProgress(totalProgress); // 保存课程学习进度
if ("2".equals(isFinish))
bLessonPerson.setFinishDate(new Date());
bLessonPerson.setIsFinish(isFinish);
return bLessonPerson;
}
/**
* 根据id查询 bRStudentChapter
* @param id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment