Commit f31a1630 authored by zhangqingle's avatar zhangqingle

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

# Conflicts:
#	src/main/java/org/rcisoft/business/bchapter/dao/BChapterRepository.java
#	src/main/java/org/rcisoft/core/result/ResultServiceEnums.java
parents 12e0fefb e2aa1a56
...@@ -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获取主键
...@@ -406,5 +406,8 @@ public interface BChapterRepository extends BaseMapper<BChapter> { ...@@ -406,5 +406,8 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
@Delete("delete from b_r_student_chapter where chapter_id = #{chapterId} and student_id = #{uid} ") @Delete("delete from b_r_student_chapter where chapter_id = #{chapterId} and student_id = #{uid} ")
int deleteBStudentChapter(@Param("chapterId") String chapterId,@Param("uid") String uid); int deleteBStudentChapter(@Param("chapterId") String chapterId,@Param("uid") String uid);
@Select("select count(0) from b_chapter where lesson_id = #{lessonId} and chapter_level = 2 and del_flag != 1 and flag =1")
int getlessonHours(@Param("lessonId") String lessonId);
} }
...@@ -8,7 +8,7 @@ import lombok.Data; ...@@ -8,7 +8,7 @@ import lombok.Data;
@Data @Data
public class ChapterDTO { public class ChapterDTO {
@ApiModelProperty(value = "课程id 修改章节时传入") @ApiModelProperty(value = "章节id 修改章节时传入")
private String businessId; private String businessId;
@ApiModelProperty(value = "课程ID") @ApiModelProperty(value = "课程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;
...@@ -290,29 +291,58 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -290,29 +291,58 @@ 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);
model.setCourseTime(dto.getFileTime());
model.setIsTest(dto.getType()); model.setIsTest(dto.getType());
if (StringUtils.isNotEmpty(dto.getFileTime()) && dto.getFileTime().contains(".")) { if (StringUtils.isNotEmpty(dto.getFileTime()) && dto.getFileTime().contains(".")) {
model.setCourseTime(dto.getFileTime().substring(0, dto.getFileTime().lastIndexOf("."))); model.setCourseTime(dto.getFileTime().substring(0, dto.getFileTime().lastIndexOf(".")));
bFile.setFileTime(dto.getFileTime().substring(0, dto.getFileTime().lastIndexOf("."))); bFile.setFileTime(dto.getFileTime().substring(0, dto.getFileTime().lastIndexOf(".")));
} }
//先判断该课程的第一节是否是本节 更新blesson表中course_time字段 //先判断该课程的第一节是否是本节 更新blesson表中course_time字段
String cid = bChapterRepository.getFirstChapter(model.getLessonId()); String cid = bChapterRepository.getFirstChapter(model.getLessonId());
log.debug("--------------------------------第一节id--------:"+cid);
log.debug("------------------------------当前章节id--------:"+model.getBusinessId());
if (model.getBusinessId().equals(cid)) { if (model.getBusinessId().equals(cid)) {
bChapterRepository.updateVideoTimeInLesson(model.getCourseTime(), model.getLessonId()); int linex = bChapterRepository.updateVideoTimeInLesson(model.getCourseTime(), model.getLessonId());
log.debug("----------------------更新lesson表中第一节时长--"+(linex==0?"失败":"成功")+"----------");
log.debug("--------------------------时长-----------:"+model.getCourseTime());
} }
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;
}
if ("2".equals(lessonPerson.getIsFinish()) && newLearnProgress < 1){
lessonPerson.setIsFinish("1");
}
lessonPerson.setLearnProgress(newLearnProgress*100 + "%");
bLessonPersonRepository.updateByPrimaryKeySelective(lessonPerson);
studentChapter.setProgress(0);
brStudentChapterRepository.updateById(studentChapter);
}
}
}
} }
//不是为添加章时插入资料表 //不是为添加章时插入资料表
...@@ -338,6 +368,31 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -338,6 +368,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) {
...@@ -349,15 +404,22 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -349,15 +404,22 @@ public class BChapterServiceImpl implements BChapterService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel removeBChapter(String id,String userId) { public PersistModel removeBChapter(String id,String userId) {
BChapter bChapter = bChapterRepository.selectByPrimaryKey(id); BChapter bChapter = bChapterRepository.selectByPrimaryKey(id);
String lessonId = bChapterRepository.getLessonIdBychaperId(id);
if (bChapter == null) if (bChapter == null)
throw new ServiceException(ResultServiceEnums.CHAPTER_NOT_EXISTS); throw new ServiceException(ResultServiceEnums.CHAPTER_NOT_EXISTS);
int chapterCount =bChapterRepository.getlessonHours(lessonId);
if(chapterCount == 1){
throw new ServiceException(ResultServiceEnums.CHAPTER_ONLY_ONE);
}
String firstChapter = bChapterRepository.getFirstChapter(id);
List<QueryChapterListResDTO> childList = bChapterRepository.queryBChaptersByPid(id); List<QueryChapterListResDTO> childList = bChapterRepository.queryBChaptersByPid(id);
boolean hasChild = childList != null && childList.size() > 0; boolean hasChild = childList != null && childList.size() > 0;
boolean isChapter = bChapter.getChapterLevel() == ChapterLevelEnum.CHAPTER.getCode(); boolean isChapter = bChapter.getChapterLevel() == ChapterLevelEnum.CHAPTER.getCode();
if (isChapter && hasChild) { if (isChapter && hasChild) {
throw new ServiceException(ResultServiceEnums.CHAPTER_HAS_CHILD); throw new ServiceException(ResultServiceEnums.CHAPTER_HAS_CHILD);
} }
String lessonId = bChapterRepository.getLessonIdBychaperId(id);
//获取第一节课的id 与当前id对比 //获取第一节课的id 与当前id对比
String firstId = bChapterRepository.getFirstChapter(lessonId); String firstId = bChapterRepository.getFirstChapter(lessonId);
int line = bChapterRepository.removeByPrimaryKey(id); int line = bChapterRepository.removeByPrimaryKey(id);
...@@ -367,7 +429,9 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -367,7 +429,9 @@ public class BChapterServiceImpl implements BChapterService {
String secondId = bChapterRepository.getFirstChapter(lessonId); String secondId = bChapterRepository.getFirstChapter(lessonId);
String time = bChapterRepository.getTimeByChapterId(secondId); String time = bChapterRepository.getTimeByChapterId(secondId);
//更新到b_lesson 表 //更新到b_lesson 表
bChapterRepository.updateCourseTimeForLesson(time,lessonId); bChapterRepository.updateVideoTimeInLesson(time,lessonId);
// 更新学生 对应章节总进度
this.updateLessonProgress(lessonId, false);
//删除student_chapter表中数据 //删除student_chapter表中数据
bChapterRepository.deleteBStudentChapter(id,userId); bChapterRepository.deleteBStudentChapter(id,userId);
......
...@@ -155,7 +155,7 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> { ...@@ -155,7 +155,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=','> " +
...@@ -165,6 +165,11 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> { ...@@ -165,6 +165,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
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap; import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.rcisoft.business.bchapter.dao.BChapterRepository;
import org.rcisoft.business.bcourse.dao.BCourseRepository; import org.rcisoft.business.bcourse.dao.BCourseRepository;
import org.rcisoft.business.bcourse.dto.AllCourseDTO; import org.rcisoft.business.bcourse.dto.AllCourseDTO;
import org.rcisoft.business.bfile.dao.BTrainFileRepository; import org.rcisoft.business.bfile.dao.BTrainFileRepository;
...@@ -83,6 +84,9 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -83,6 +84,9 @@ public class BLessonServiceImpl implements BLessonService {
@Autowired @Autowired
private BMaterialRepository bMaterialRepository; private BMaterialRepository bMaterialRepository;
@Autowired
private BChapterRepository bChapterRepository;
@Autowired @Autowired
MTCotactApiRequestClient cotactApiRequestClient; MTCotactApiRequestClient cotactApiRequestClient;
...@@ -500,6 +504,9 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -500,6 +504,9 @@ public class BLessonServiceImpl implements BLessonService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel releaseBLesson(String id) { public PersistModel releaseBLesson(String id) {
if(bChapterRepository.getlessonHours(id) == 0){
throw new ServiceException(ResultServiceEnums.LESSON_NO_CHAPTER);
}
BLesson bLesson = new BLesson(); BLesson bLesson = new BLesson();
bLesson.setBusinessId(id); bLesson.setBusinessId(id);
bLesson = bLessonRepository.selectByPrimaryKey(bLesson); bLesson = bLessonRepository.selectByPrimaryKey(bLesson);
......
...@@ -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());
......
...@@ -232,6 +232,8 @@ public enum ResultServiceEnums { ...@@ -232,6 +232,8 @@ public enum ResultServiceEnums {
NO_ACCESS(132,"您对该课程无可见权限"), NO_ACCESS(132,"您对该课程无可见权限"),
LABEL_MORE_NUM(133,"标签超过规定个数"), LABEL_MORE_NUM(133,"标签超过规定个数"),
SAVED_THIS_FILE(134,"已保存过改资料"), SAVED_THIS_FILE(134,"已保存过改资料"),
CHAPTER_ONLY_ONE(135,"当前课程仅有一节,不能被删除"),
LESSON_NO_CHAPTER(136,"当前课程暂无章节,不能被发布"),
; ;
private Integer code; private Integer code;
......
...@@ -219,7 +219,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> { ...@@ -219,7 +219,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
" and u.del_flag !=1 " + " and u.del_flag !=1 " +
" and u.flag = 1 " + " and u.flag = 1 " +
" and r.r_status = 1 ") " and r.r_status = 1 ")
String queryAllRoleById(@Param("userId") String userId); List<String>queryAllRoleById(@Param("userId") String userId);
@Select("<script>select " + @Select("<script>select " +
" (select count(1) from " + " (select count(1) from " +
......
...@@ -246,7 +246,19 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -246,7 +246,19 @@ public class SysUserServiceImpl implements SysUserService {
@Override @Override
public String queryAllRoleById(String userId) { public String queryAllRoleById(String userId) {
return sysUserMapper.queryAllRoleById(userId); List<String> roles = sysUserMapper.queryAllRoleById(userId);
StringBuffer sb = new StringBuffer();
for(String role : roles){
sb.append(role+",");
}
String str1 = sb.toString().substring(0,sb.toString().length() - 1);
String [] strs = str1.split(",");
Set roleSet = new HashSet();
for(String s : strs){
roleSet.add(s);
}
String allRole = StringUtils.join(roleSet.toArray(), ",");
return allRole;
} }
@Override @Override
......
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