Commit 75009031 authored by luzhuang's avatar luzhuang

Merge remote-tracking branch 'origin/meiteng' into meiteng

parents a525e0ac 57c58c93
...@@ -144,8 +144,8 @@ public interface BChapterRepository extends BaseMapper<BChapter> { ...@@ -144,8 +144,8 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
"AND t1.del_flag = 0 and t1.flag = 1</script>") "AND t1.del_flag = 0 and t1.flag = 1</script>")
List<StuScoreDTO> selectScoreListBySlIdAndStuId(@Param("slid") String slid, @Param("stuid") String stuid); List<StuScoreDTO> selectScoreListBySlIdAndStuId(@Param("slid") String slid, @Param("stuid") String stuid);
@Delete("<script>delete from b_r_student_chapter where chapter_id = #{chapterId}</script>") // @Delete("<script>delete from b_r_student_chapter where chapter_id = #{chapterId}</script>")
int deleteStudentChapter(String chapterId); // int deleteStudentChapter(String chapterId);
/** /**
* 根据章节id和学生id获取主键 * 根据章节id和学生id获取主键
......
...@@ -21,6 +21,7 @@ import org.rcisoft.business.bfile.util.GetVideoTime; ...@@ -21,6 +21,7 @@ import org.rcisoft.business.bfile.util.GetVideoTime;
import org.rcisoft.business.blesson.dao.BCollectRepository; import org.rcisoft.business.blesson.dao.BCollectRepository;
import org.rcisoft.business.blesson.dao.BLessonPersonRepository; import org.rcisoft.business.blesson.dao.BLessonPersonRepository;
import org.rcisoft.business.blesson.dao.BLessonRepository; import org.rcisoft.business.blesson.dao.BLessonRepository;
import org.rcisoft.business.blesson.dto.AppointLessonDTO;
import org.rcisoft.business.blesson.entity.BLesson; import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.bfile.dao.BFileRepository; import org.rcisoft.business.bfile.dao.BFileRepository;
import org.rcisoft.business.bfile.entity.BFile; import org.rcisoft.business.bfile.entity.BFile;
...@@ -285,9 +286,12 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -285,9 +286,12 @@ public class BChapterServiceImpl implements BChapterService {
//上传文件数据插入到bfile表中 //上传文件数据插入到bfile表中
int x = bFileRepository.insertUploadFile(bFile); int x = bFileRepository.insertUploadFile(bFile);
bChapterRepository.updateClassHourInLesson(model.getLessonId());//更新b_lesson表中 class_hour bChapterRepository.updateClassHourInLesson(model.getLessonId());//更新b_lesson表中 class_hour
// 更新课程总进度
this.updateLessonProgress(chapterDTO.getLessonId(), true);
log.debug("-----------------------------更新课时成功-------------------"); log.debug("-----------------------------更新课时成功-------------------");
} }
} else { } else {
BFile bFileOld = bFileRepository.selectInfoByChapterId(chapterDTO.getBusinessId());
UserUtil.setCurrentMergeOperation(model); UserUtil.setCurrentMergeOperation(model);
bFile.setChapterId(model.getBusinessId()); bFile.setChapterId(model.getBusinessId());
UserUtil.setCurrentMergeOperation(bFile); UserUtil.setCurrentMergeOperation(bFile);
...@@ -308,6 +312,27 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -308,6 +312,27 @@ public class BChapterServiceImpl implements BChapterService {
line = bChapterRepository.updateByPrimaryKeySelective(model); line = bChapterRepository.updateByPrimaryKeySelective(model);
int x = bFileRepository.updateUploadFile(bFile); int x = bFileRepository.updateUploadFile(bFile);
// 判断 新文件 更新 课程学习进度(总进度 此章节进度)
if (!(bFileOld.getVideoUrl().equals(dto.getVideoUrl())) ) {
// 所有学习过此课程的 学生课程信息
List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.selectByLessonId(chapterDTO.getLessonId());
BLesson bLesson = bLessonRepository.selectByPrimaryKey(chapterDTO.getLessonId());
for (BLessonPerson lessonPerson: bLessonPersonList){
// 更新 学生针对此章节的中间表
List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(chapterDTO.getBusinessId(), "");
for (BRStudentChapter studentChapter: brStudentChapterList){
double learnProgress = Double.parseDouble(lessonPerson.getLearnProgress().split("%")[0]) / 100 ;
double newLearnProgress = Math.floor((learnProgress * Integer.parseInt(bLesson.getClassHour()) - studentChapter.getProgress()) / Integer.parseInt(bLesson.getClassHour()));
if (learnProgress > 0 && newLearnProgress < 0.01){
newLearnProgress = 0.01f;
}
lessonPerson.setLearnProgress(newLearnProgress*100 + "%");
bLessonPersonRepository.updateByPrimaryKeySelective(lessonPerson);
studentChapter.setProgress(0);
brStudentChapterRepository.updateById(studentChapter);
}
}
}
} }
//不是为添加章时插入资料表 //不是为添加章时插入资料表
...@@ -333,6 +358,31 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -333,6 +358,31 @@ public class BChapterServiceImpl implements BChapterService {
return new PersistModel(line); return new PersistModel(line);
} }
/**
*
* @param lessonId
* @param add true: 新增 false 删除
*/
// 新增章节 - 更新学生观看课程总进度
private void updateLessonProgress(String lessonId, boolean add){
List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.selectByLessonId(lessonId);
BLesson bLesson = bLessonRepository.selectByPrimaryKey(lessonId);
for (BLessonPerson lessonPerson: bLessonPersonList){
float newLearnProgress ;
float learnProgress = Float.parseFloat(lessonPerson.getLearnProgress().split("%")[0]) / 100 ;
if (add){
newLearnProgress = (float) Math.floor(learnProgress * Integer.parseInt(bLesson.getClassHour()) / (Integer.parseInt(bLesson.getClassHour()) + 1));
}else {
newLearnProgress = Integer.parseInt(bLesson.getClassHour()) == 0 ? 0 : (float) Math.floor(learnProgress * Integer.parseInt(bLesson.getClassHour() + 1) / (Integer.parseInt(bLesson.getClassHour())));
}
if (learnProgress > 0 && newLearnProgress < 0.01){
newLearnProgress = 0.01f;
}
lessonPerson.setLearnProgress(newLearnProgress*100+"%");
bLessonPersonRepository.updateByPrimaryKeySelective(lessonPerson);
}
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override @Override
public PersistModel update(BChapter model) { public PersistModel update(BChapter model) {
...@@ -363,6 +413,8 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -363,6 +413,8 @@ public class BChapterServiceImpl implements BChapterService {
String time = bChapterRepository.getTimeByChapterId(secondId); String time = bChapterRepository.getTimeByChapterId(secondId);
//更新到b_lesson 表 //更新到b_lesson 表
bChapterRepository.updateCourseTimeForLesson(time,lessonId); bChapterRepository.updateCourseTimeForLesson(time,lessonId);
// 更新学生 对应章节总进度
this.updateLessonProgress(lessonId, false);
//删除student_chapter表中数据 //删除student_chapter表中数据
bChapterRepository.deleteBStudentChapter(id,userId); bChapterRepository.deleteBStudentChapter(id,userId);
......
...@@ -143,7 +143,7 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> { ...@@ -143,7 +143,7 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
* @param param * @param param
* @return * @return
*/ */
@Select("<script>select business_id,person_id from b_lesson_person where 1=1 " + @Select("<script>select business_id,person_id,lesson_id from b_lesson_person where 1=1 " +
// "and del_flag = 0 and flag = 1 " + // "and del_flag = 0 and flag = 1 " +
"AND person_id IN" + "AND person_id IN" +
"<foreach item='item' collection='appointPersonList' open='(' close=')' separator=','> " + "<foreach item='item' collection='appointPersonList' open='(' close=')' separator=','> " +
...@@ -153,6 +153,11 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> { ...@@ -153,6 +153,11 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
@ResultMap(value = "BaseResultMap") @ResultMap(value = "BaseResultMap")
List<BLessonPerson> selectPersonIdByLessonId(AppointLessonDTO param); List<BLessonPerson> selectPersonIdByLessonId(AppointLessonDTO param);
@Select("<script>select business_id,person_id,lesson_id , learn_progress from b_lesson_person where 1=1 " +
"and lesson_id = #{lessonId}</script>")
@ResultMap(value = "BaseResultMap")
List<BLessonPerson> selectByLessonId(@Param("lessonId") String lessonId);
/** /**
* 按课程id删除指派未开始 * 按课程id删除指派未开始
* @param param * @param param
......
...@@ -150,7 +150,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService { ...@@ -150,7 +150,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
// bLessonPerson.setIsFinish(isFinish); // bLessonPerson.setIsFinish(isFinish);
// bLessonPerson.setChapterId(brStudentChapterDto.getChapterId()); // bLessonPerson.setChapterId(brStudentChapterDto.getChapterId());
// bLessonPerson.setLearnProgress(totalProgress); // 保存课程学习进度 // bLessonPerson.setLearnProgress(totalProgress); // 保存课程学习进度
line = bLessonPersonRepository.insertSelective(bLessonPerson) > line ? bLessonPersonRepository.insertSelective(bLessonPerson): line ; line = bLessonPersonRepository.insertSelective(bLessonPerson) ;
} }
// 获取章节总进度 存库 // 获取章节总进度 存库
BChapter bChapter = bChapterRepository.selectByPrimaryKey(brStudentChapterDto.getChapterId()); BChapter bChapter = bChapterRepository.selectByPrimaryKey(brStudentChapterDto.getChapterId());
......
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