Commit 0bacddfc authored by 王淑君's avatar 王淑君

修改视频学习页

parent 4ea9df43
...@@ -407,5 +407,19 @@ public interface BChapterRepository extends BaseMapper<BChapter> { ...@@ -407,5 +407,19 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
// //
// //
// int insertBChapter(BChapter model); // int insertBChapter(BChapter model);
@Select("<script>" +
"SELECT bc.* \n" +
"FROM\n" +
"\tb_lesson_person bp\n" +
"\tLEFT JOIN b_lesson b ON bp.lesson_id = b.business_id\n" +
"\tLEFT JOIN b_chapter bc ON bc.business_id = bp.chapter_id \n" +
"WHERE\n" +
"\tbp.chapter_id IS NOT NULL \n" +
"\tAND bp.chapter_id != '' \n" +
"\tAND b.business_id = #{lessonId} " +
"</script>")
@ResultMap(value = "BaseResultMap")
BChapter getWithCurrentChapterBylessonId(@Param("lessonId")String lessonId);
} }
...@@ -14,10 +14,12 @@ import org.rcisoft.business.bchapter.service.BChapterService; ...@@ -14,10 +14,12 @@ import org.rcisoft.business.bchapter.service.BChapterService;
import org.rcisoft.business.bchapter.vo.StudentChapterScoreVO; import org.rcisoft.business.bchapter.vo.StudentChapterScoreVO;
import org.rcisoft.business.bfile.dto.uploadDTO; import org.rcisoft.business.bfile.dto.uploadDTO;
import org.rcisoft.business.bfile.util.GetVideoTime; import org.rcisoft.business.bfile.util.GetVideoTime;
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.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;
import org.rcisoft.business.blesson.entity.BLessonPerson;
import org.rcisoft.business.bmaterial.dao.BMaterialRepository; import org.rcisoft.business.bmaterial.dao.BMaterialRepository;
import org.rcisoft.business.bmaterial.entity.BMaterial; import org.rcisoft.business.bmaterial.entity.BMaterial;
import org.rcisoft.business.brstudentchapter.dao.BRStudentChapterRepository; import org.rcisoft.business.brstudentchapter.dao.BRStudentChapterRepository;
...@@ -69,6 +71,8 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -69,6 +71,8 @@ public class BChapterServiceImpl implements BChapterService {
private Global global; private Global global;
@Autowired @Autowired
BRStudentChapterRepository brStudentChapterRepository; BRStudentChapterRepository brStudentChapterRepository;
@Autowired
BLessonPersonRepository bLessonPersonRepository;
@Override @Override
public BChapter selectOne(String businessId) { public BChapter selectOne(String businessId) {
...@@ -103,11 +107,11 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -103,11 +107,11 @@ public class BChapterServiceImpl implements BChapterService {
int percent = 0; int percent = 0;
for (QueryChapterListResDTO queryChapterListResDTO: queryChapterListResDTOS){ for (QueryChapterListResDTO queryChapterListResDTO: queryChapterListResDTOS){
for (QueryChapterListResDTO childList: queryChapterListResDTO.getChildList()){ for (QueryChapterListResDTO childList: queryChapterListResDTO.getChildList()){
// 遍历学生章节中间表 查询学生观看章节进度
List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(childList.getBusinessId(), curUser.getUserId()); List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(childList.getBusinessId(), curUser.getUserId());
if (null != brStudentChapterList && brStudentChapterList.size() > 0) { if (null != brStudentChapterList && brStudentChapterList.size() > 0) {
childList.setProgress(brStudentChapterList.get(0).getProgress()); childList.setProgress(brStudentChapterList.get(0).getProgress()*100 + "%");
String temp = brStudentChapterList.get(0).getProgress().substring(0,brStudentChapterList.get(0).getProgress().length()-1); percent += brStudentChapterList.get(0).getProgress();
percent += Float.valueOf(temp);
} }
i++; i++;
} }
...@@ -124,7 +128,12 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -124,7 +128,12 @@ public class BChapterServiceImpl implements BChapterService {
DecimalFormat df=new DecimalFormat("0.00");//设置保留位数 DecimalFormat df=new DecimalFormat("0.00");//设置保留位数
map.put("chapterList", queryChapterListResDTOS); map.put("chapterList", queryChapterListResDTOS);
map.put("totalProgress", df.format((float)percent/i) + "%"); map.put("totalProgress", df.format((float)percent/i) + "%");
map.put("lessonInfo", bLessonRepository.selectByPrimaryKey(model.getLessonId())); map.put("lessonInfo", bLessonRepository.selectByPrimaryKey(lessonId)); // 课程信息
BLessonPerson bLessonPerson = bLessonPersonRepository.selectByPrimaryKey(lessonId);
if (null != bLessonPerson){
}
map.put("currentChapter", bChapterRepository.getWithCurrentChapterBylessonId(lessonId));
return map; return map;
} }
......
package org.rcisoft.business.blesson.dao; package org.rcisoft.business.blesson.dao;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import org.rcisoft.business.bchapter.entity.BChapter;
import org.rcisoft.business.blabel.dto.QueryLabelResDTO; import org.rcisoft.business.blabel.dto.QueryLabelResDTO;
import org.rcisoft.business.blesson.dto.*; import org.rcisoft.business.blesson.dto.*;
import org.rcisoft.business.blesson.entity.BLesson; import org.rcisoft.business.blesson.entity.BLesson;
...@@ -843,6 +844,8 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -843,6 +844,8 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
@Select("<script>" + @Select("<script>" +
"SELECT * FROM `b_recommend` where type = 0 and corp_id = #{corpId} and lesson_id = #{lessonId} " + "SELECT * FROM `b_recommend` where type = 0 and corp_id = #{corpId} and lesson_id = #{lessonId} " +
"</script>") "</script>")
@ResultMap(value = "BaseResultMap")
List<BRecommend> queryRecommendByLessonId(@Param("corpId") String corpId, @Param("lessonId")String lessonId); List<BRecommend> queryRecommendByLessonId(@Param("corpId") String corpId, @Param("lessonId")String lessonId);
} }
...@@ -52,6 +52,10 @@ public class BLessonPerson extends IdEntity<BLessonPerson> { ...@@ -52,6 +52,10 @@ public class BLessonPerson extends IdEntity<BLessonPerson> {
@Length(min = 1,max = 1,message = "长度最小为1,最大为1") @Length(min = 1,max = 1,message = "长度最小为1,最大为1")
private String appointId; private String appointId;
@ApiModelProperty(value = "章節id")
@Length(min = 1,max = 1,message = "长度最小为1,最大为1")
private String chapterId;
// @ApiModelProperty(value = "是否开始") // @ApiModelProperty(value = "是否开始")
// @Length(min = 1,max = 1,message = "长度最小为1,最大为1") // @Length(min = 1,max = 1,message = "长度最小为1,最大为1")
// private String startFlag; // private String startFlag;
......
...@@ -20,6 +20,8 @@ public class BRStudentChapterDto { ...@@ -20,6 +20,8 @@ public class BRStudentChapterDto {
private String studentId; private String studentId;
private String lessonId;
private String progress; private String progress;
private Integer current; private Integer current;
......
...@@ -41,7 +41,9 @@ public class BRStudentChapter { ...@@ -41,7 +41,9 @@ public class BRStudentChapter {
private String paperFinish; private String paperFinish;
private String progress; private double progress;
private int currentLocation;
} }
......
package org.rcisoft.business.brstudentchapter.service.impl; package org.rcisoft.business.brstudentchapter.service.impl;
import org.apache.commons.lang3.StringUtils;
import org.rcisoft.business.blesson.dao.BLessonPersonRepository;
import org.rcisoft.business.blesson.dto.AddMyLearnLessonDTO;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.entity.BLessonPerson;
import org.rcisoft.business.brstudentchapter.dto.BRStudentChapterDto; import org.rcisoft.business.brstudentchapter.dto.BRStudentChapterDto;
import org.rcisoft.core.util.IdGen; import org.rcisoft.core.util.IdGen;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
...@@ -17,6 +22,7 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -17,6 +22,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.text.BreakIterator; import java.text.BreakIterator;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.List; import java.util.List;
...@@ -32,7 +38,8 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService { ...@@ -32,7 +38,8 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
@Autowired @Autowired
private BRStudentChapterRepository bRStudentChapterRepository; private BRStudentChapterRepository bRStudentChapterRepository;
@Autowired
private BLessonPersonRepository bLessonPersonRepository;
/** /**
* 保存 bRStudentChapter * 保存 bRStudentChapter
...@@ -43,30 +50,56 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService { ...@@ -43,30 +50,56 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
@Override @Override
public PersistModel save(BRStudentChapterDto brStudentChapterDto){ public PersistModel save(BRStudentChapterDto brStudentChapterDto){
int line = 0; int line = 0;
// 查詢是否已經開始觀看此章節的課程
AddMyLearnLessonDTO addMy = new AddMyLearnLessonDTO();
addMy.setUserId(brStudentChapterDto.getStudentId());
addMy.setLessonId(brStudentChapterDto.getLessonId());
List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.selectByPersonAndLesson(addMy);
// 判斷是否已經開始觀看此課程
if (null != bLessonPersonList && bLessonPersonList.size() >0){
BLessonPerson bLessonPerson = bLessonPersonList.get(0);
bLessonPerson.setChapterId(brStudentChapterDto.getChapterId());
bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
}else {
BLessonPerson bLessonPerson = new BLessonPerson();
UserUtil.setCurrentPersistOperation(bLessonPerson);
bLessonPerson.setChapterId(brStudentChapterDto.getChapterId());
bLessonPerson.setPersonId(brStudentChapterDto.getStudentId());
bLessonPerson.setLessonId(brStudentChapterDto.getLessonId());
bLessonPersonRepository.insertSelective(bLessonPerson);
}
// 查詢是否已經開始觀看此章節
List<BRStudentChapter> brStudentChapterList = bRStudentChapterRepository.queryByStuIdAndChapter(brStudentChapterDto.getChapterId(),brStudentChapterDto.getStudentId()); List<BRStudentChapter> brStudentChapterList = bRStudentChapterRepository.queryByStuIdAndChapter(brStudentChapterDto.getChapterId(),brStudentChapterDto.getStudentId());
DecimalFormat df=new DecimalFormat("0.00");//设置保留位数 DecimalFormat df=new DecimalFormat("0.00");//设置保留位数
// 沒有開始看-新增信息
if (null != brStudentChapterList && brStudentChapterList.size() >0){ if (null != brStudentChapterList && brStudentChapterList.size() >0){
BRStudentChapter brStudentChapter = brStudentChapterList.get(0); BRStudentChapter brStudentChapter = brStudentChapterList.get(0);
brStudentChapter.setCurrentLocation(brStudentChapterDto.getCurrent());
if (brStudentChapterDto.getCurrent() == brStudentChapterDto.getDuration()){ if (brStudentChapterDto.getCurrent() == brStudentChapterDto.getDuration()){
// who finish brStudentChapter.setProgress(1);
brStudentChapter.setProgress("100%");
}else{ }else{
brStudentChapter.setProgress(df.format((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()*100)+ "%"); brStudentChapter.setProgress(new BigDecimal((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
} }
line = bRStudentChapterRepository.updateById(brStudentChapter); // 判断进度 是否大于数据库已经存在的进度
}else { double old = brStudentChapterList.get(0).getProgress();
double now = brStudentChapter.getProgress();
if (old >= now){
line = bRStudentChapterRepository.updateById(brStudentChapter);
}
}else { // 更新
BRStudentChapter brStudentChapter = new BRStudentChapter(); BRStudentChapter brStudentChapter = new BRStudentChapter();
brStudentChapter.setBusinessId(IdGen.uuid()); brStudentChapter.setBusinessId(IdGen.uuid());
brStudentChapter.setStudentId(brStudentChapterDto.getStudentId()); brStudentChapter.setStudentId(brStudentChapterDto.getStudentId());
brStudentChapter.setChapterId(brStudentChapterDto.getChapterId()); brStudentChapter.setChapterId(brStudentChapterDto.getChapterId());
brStudentChapter.setCurrentLocation(brStudentChapterDto.getCurrent()); // 保存當前學習進度
if (brStudentChapterDto.getCurrent() == brStudentChapterDto.getDuration()){ // 判断是否已经完成 if (brStudentChapterDto.getCurrent() == brStudentChapterDto.getDuration()){ // 判断是否已经完成
brStudentChapter.setIsComplete("1"); brStudentChapter.setIsComplete("1");
// brStudentChapter.setAutomatic("1"); // brStudentChapter.setAutomatic("1");
brStudentChapter.setProgress("100%"); brStudentChapter.setProgress(1);
}else { }else {
brStudentChapter.setIsComplete("0"); brStudentChapter.setIsComplete("0");
// brStudentChapter.setAutomatic("0"); // brStudentChapter.setAutomatic("0");
brStudentChapter.setProgress(df.format(brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()*100)+"%"); brStudentChapter.setProgress(new BigDecimal((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
} }
line = bRStudentChapterRepository.insertSelective(brStudentChapter); line = bRStudentChapterRepository.insertSelective(brStudentChapter);
} }
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
<result column="is_finish" jdbcType="VARCHAR" property="isFinish"/> <result column="is_finish" jdbcType="VARCHAR" property="isFinish"/>
<result column="is_collect" jdbcType="VARCHAR" property="isCollect"/> <result column="is_collect" jdbcType="VARCHAR" property="isCollect"/>
<result column="appoint_id" jdbcType="VARCHAR" property="appointId"/> <result column="appoint_id" jdbcType="VARCHAR" property="appointId"/>
<result column="chapter_id" jdbcType="VARCHAR" property="chapterId"/>
<!--<result column="start_flag" jdbcType="VARCHAR" property="startFlag"/>--> <!--<result column="start_flag" jdbcType="VARCHAR" property="startFlag"/>-->
<result column="is_appoint" jdbcType="VARCHAR" property="isAppoint"/> <result column="is_appoint" jdbcType="VARCHAR" property="isAppoint"/>
</resultMap> </resultMap>
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
<result column="pdf_finish" jdbcType="VARCHAR" property="pdfFinish"/> <result column="pdf_finish" jdbcType="VARCHAR" property="pdfFinish"/>
<result column="video_finish" jdbcType="VARCHAR" property="videoFinish"/> <result column="video_finish" jdbcType="VARCHAR" property="videoFinish"/>
<result column="paper_finish" jdbcType="VARCHAR" property="paperFinish"/> <result column="paper_finish" jdbcType="VARCHAR" property="paperFinish"/>
<result column="progress" jdbcType="VARCHAR" property="progress"/> <result column="progress" jdbcType="DOUBLE" property="progress"/>
<result column="current_location" jdbcType="VARCHAR" property="currentLocation"/>
</resultMap> </resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>--> <!--<cache type="${corePackag!}.util.RedisCache"/>-->
......
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