Commit 2426ac2a authored by luzhuang's avatar luzhuang

修改

parent 75fec82e
...@@ -312,7 +312,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -312,7 +312,7 @@ public class BChapterServiceImpl implements BChapterService {
// 新增节 才更新进度 // 新增节 才更新进度
if (2 == chapterDTO.getChapterLevel()){ if (2 == chapterDTO.getChapterLevel()){
// 更新课程总进度 // 更新课程总进度
this.updateLessonProgress(chapterDTO.getLessonId(), true, 0, ""); this.updateLessonProgress(chapterDTO.getLessonId(), true, "");
} }
log.debug("-----------------------------更新课时成功-------------------"); log.debug("-----------------------------更新课时成功-------------------");
} }
...@@ -447,11 +447,13 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -447,11 +447,13 @@ public class BChapterServiceImpl implements BChapterService {
* @param add true: 新增 false 删除 * @param add true: 新增 false 删除
*/ */
// 新增章节 - 更新学生观看课程总进度 // 新增章节 - 更新学生观看课程总进度
private void updateLessonProgress(String lessonId, boolean add, double delProgress,String chapterId){ private void updateLessonProgress(String lessonId, boolean add, String chapterId){
NumberFormat numberFormat = NumberFormat.getInstance(); NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMaximumFractionDigits(2); numberFormat.setMaximumFractionDigits(2);
List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.selectByLessonId(lessonId, ""); List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.selectByLessonId(lessonId, "");
BLesson bLesson = bLessonRepository.selectByPrimaryKey(lessonId); BLesson bLesson = bLessonRepository.selectByPrimaryKey(lessonId);
for (BLessonPerson lessonPerson: bLessonPersonList){ for (BLessonPerson lessonPerson: bLessonPersonList){
if (!add && null != lessonPerson.getChapterId() && lessonPerson.getChapterId().equals(chapterId)){ if (!add && null != lessonPerson.getChapterId() && lessonPerson.getChapterId().equals(chapterId)){
bLessonPersonRepository.clearChapterId(lessonPerson.getBusinessId()); bLessonPersonRepository.clearChapterId(lessonPerson.getBusinessId());
...@@ -460,12 +462,18 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -460,12 +462,18 @@ public class BChapterServiceImpl implements BChapterService {
if(lessonPerson.getLearnProgress() == null){ if(lessonPerson.getLearnProgress() == null){
break; break;
} }
List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(chapterId, lessonPerson.getPersonId());
double oldProgress = 0;
if (null !=brStudentChapterList && brStudentChapterList.size()>0){
oldProgress = brStudentChapterList.get(0).getProgress();
}
double learnProgress = Double.parseDouble(lessonPerson.getLearnProgress().split("%")[0]) / 100 ; double learnProgress = Double.parseDouble(lessonPerson.getLearnProgress().split("%")[0]) / 100 ;
if (add){ if (add){
newLearnProgress =Integer.parseInt(bLesson.getClassHour()) -1 == 0? "0": numberFormat.format( learnProgress * (Integer.parseInt(bLesson.getClassHour()) -1) / (Double.parseDouble(bLesson.getClassHour())) ); newLearnProgress =Integer.parseInt(bLesson.getClassHour()) -1 == 0? "0": numberFormat.format( learnProgress * (Integer.parseInt(bLesson.getClassHour()) -1) / (Double.parseDouble(bLesson.getClassHour())) );
}else { }else {
int oldClassHour = Integer.parseInt(bLesson.getClassHour()) + 1; int oldClassHour = Integer.parseInt(bLesson.getClassHour()) + 1;
newLearnProgress = numberFormat.format((learnProgress * oldClassHour - delProgress)/(oldClassHour -1) ); newLearnProgress = numberFormat.format((learnProgress * oldClassHour - oldProgress)/(oldClassHour -1) );
} }
if (0 == Double.parseDouble(newLearnProgress)){ if (0 == Double.parseDouble(newLearnProgress)){
lessonPerson.setIsFinish("0"); lessonPerson.setIsFinish("0");
...@@ -485,6 +493,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -485,6 +493,7 @@ public class BChapterServiceImpl implements BChapterService {
lessonPerson.setIsFinish("2"); lessonPerson.setIsFinish("2");
} }
} }
//TODO 判断 曾经是否学完过 奖励积分 //TODO 判断 曾经是否学完过 奖励积分
if ( "2".equals(lessonPerson.getIsFinish()) && !("1".equals(lessonPerson.getEverFinished()))){ if ( "2".equals(lessonPerson.getIsFinish()) && !("1".equals(lessonPerson.getEverFinished()))){
//查询课程信息 //查询课程信息
...@@ -498,6 +507,8 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -498,6 +507,8 @@ public class BChapterServiceImpl implements BChapterService {
lessonPerson.setLearnProgress(Float.parseFloat(newLearnProgress)*100+"%"); lessonPerson.setLearnProgress(Float.parseFloat(newLearnProgress)*100+"%");
bLessonPersonRepository.updateAtChapter(lessonPerson); bLessonPersonRepository.updateAtChapter(lessonPerson);
// 根据chapter_id 删除b_r_student_chapter
brStudentChapterRepository.deleteBatchByChapterId(chapterId);
} }
} }
...@@ -564,18 +575,18 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -564,18 +575,18 @@ public class BChapterServiceImpl implements BChapterService {
//更新表中sort //更新表中sort
bChapterRepository.updateSort(params); bChapterRepository.updateSort(params);
} }
List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(id, curUser.getUserId()); // List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(id, curUser.getUserId());
// 判断 2-节 才重新计算进度 // 判断 2-节 才重新计算进度
if (2 == bChapter.getChapterLevel()){ if (2 == bChapter.getChapterLevel()){
// double oldProgress = 0;
// if (null !=brStudentChapterList && brStudentChapterList.size()>0){
// oldProgress = brStudentChapterList.get(0).getProgress();
// }
// 根据chapter_id 删除b_r_student_chapter // 根据chapter_id 删除b_r_student_chapter
brStudentChapterRepository.deleteBatchByChapterId(id); // brStudentChapterRepository.deleteBatchByChapterId(id);
double oldProgress = 0;
if (null !=brStudentChapterList && brStudentChapterList.size()>0){
oldProgress = brStudentChapterList.get(0).getProgress();
}
// 更新学生 对应章节总进度 // 更新学生 对应章节总进度
this.updateLessonProgress(lessonId, false, oldProgress,id); this.updateLessonProgress(lessonId, false,id);
} }
//删除student_chapter表中数据 //删除student_chapter表中数据
......
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