Commit c97e8310 authored by luzhuang's avatar luzhuang

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

parents 7b238578 88d4cb10
......@@ -407,5 +407,19 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
//
//
// 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;
import org.rcisoft.business.bchapter.vo.StudentChapterScoreVO;
import org.rcisoft.business.bfile.dto.uploadDTO;
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.entity.BLesson;
import org.rcisoft.business.bfile.dao.BFileRepository;
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.entity.BMaterial;
import org.rcisoft.business.brstudentchapter.dao.BRStudentChapterRepository;
......@@ -69,6 +71,8 @@ public class BChapterServiceImpl implements BChapterService {
private Global global;
@Autowired
BRStudentChapterRepository brStudentChapterRepository;
@Autowired
BLessonPersonRepository bLessonPersonRepository;
@Override
public BChapter selectOne(String businessId) {
......@@ -103,11 +107,11 @@ public class BChapterServiceImpl implements BChapterService {
int percent = 0;
for (QueryChapterListResDTO queryChapterListResDTO: queryChapterListResDTOS){
for (QueryChapterListResDTO childList: queryChapterListResDTO.getChildList()){
// 遍历学生章节中间表 查询学生观看章节进度
List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(childList.getBusinessId(), curUser.getUserId());
if (null != brStudentChapterList && brStudentChapterList.size() > 0) {
childList.setProgress(brStudentChapterList.get(0).getProgress());
String temp = brStudentChapterList.get(0).getProgress().substring(0,brStudentChapterList.get(0).getProgress().length()-1);
percent += Float.valueOf(temp);
childList.setProgress(brStudentChapterList.get(0).getProgress()*100 + "%");
percent += brStudentChapterList.get(0).getProgress();
}
i++;
}
......@@ -124,7 +128,12 @@ public class BChapterServiceImpl implements BChapterService {
DecimalFormat df=new DecimalFormat("0.00");//设置保留位数
map.put("chapterList", queryChapterListResDTOS);
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;
}
......
......@@ -39,7 +39,7 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
// 退出课程
@Update("update b_lesson_person set flag = 0 where business_id = #{id}")
@Update("update b_lesson_person set del_flag = 1 where business_id = #{id}")
int quit(String id);
//查询线上课程学员追踪图表
......@@ -232,4 +232,9 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
" #{param.isAppoint}) " +
"</script>")
int insertBLessonPerson(@Param("param") BLessonPerson param);
@Select("<script>select * from b_lesson_person where 1=1 " +
"and business_id = #{businessId}</script>")
@ResultMap(value = "BaseResultMap")
BLessonPerson selectById(String businessId);
}
package org.rcisoft.business.blesson.dao;
import org.apache.ibatis.annotations.*;
import org.rcisoft.business.bchapter.entity.BChapter;
import org.rcisoft.business.blabel.dto.QueryLabelResDTO;
import org.rcisoft.business.blesson.dto.*;
import org.rcisoft.business.blesson.entity.BLesson;
......@@ -843,6 +844,8 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
@Select("<script>" +
"SELECT * FROM `b_recommend` where type = 0 and corp_id = #{corpId} and lesson_id = #{lessonId} " +
"</script>")
@ResultMap(value = "BaseResultMap")
List<BRecommend> queryRecommendByLessonId(@Param("corpId") String corpId, @Param("lessonId")String lessonId);
}
......@@ -52,6 +52,10 @@ public class BLessonPerson extends IdEntity<BLessonPerson> {
@Length(min = 1,max = 1,message = "长度最小为1,最大为1")
private String appointId;
@ApiModelProperty(value = "章節id")
@Length(min = 1,max = 1,message = "长度最小为1,最大为1")
private String chapterId;
// @ApiModelProperty(value = "是否开始")
// @Length(min = 1,max = 1,message = "长度最小为1,最大为1")
// private String startFlag;
......
......@@ -45,7 +45,7 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override
public PersistModel quit(QuitLessonDTO quitLessonDTO) {
BLessonPerson bLessonPerson = bLessonPersonRepository.selectByPrimaryKey(quitLessonDTO.getBusinessId());
BLessonPerson bLessonPerson = bLessonPersonRepository.selectById(quitLessonDTO.getBusinessId());
if ("1".equals(bLessonPerson.getIsAppoint())){
throw new ServiceException(ResultExceptionEnum.APPOINT_NOT_CLOSE);
}
......
......@@ -69,14 +69,14 @@ public class BLessonServiceImpl implements BLessonService {
//获取部门(目前写死)
private List<String> getDeparts(){
List<String> departs = new ArrayList<>();
departs.add("1");
departs.add("2");
departs.add("3");
return departs;
}
// //获取部门(目前写死)
// private List<String> getDeparts(){
// List<String> departs = new ArrayList<>();
// departs.add("1");
// departs.add("2");
// departs.add("3");
// return departs;
// }
......@@ -114,7 +114,19 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public List<BLesson> queryPersonMoreByPagination(PageUtil pageUtil, CurUser curUser) {
//---------获取部门id------------
List<String> departs = getDeparts();
// List<String> departs = getDeparts();
List<String> departs = new ArrayList<>();
List<String> ids = Arrays.asList(new String[]{curUser.getUserId()});
MTUserGetsReqDTO mtUserGetsReqDTO = new MTUserGetsReqDTO();
mtUserGetsReqDTO.setCorpId(curUser.getCorpId());
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
List<MTUserInfoRspDTO.DeptsBean> deptsBeans = mtUserInfoRspDTO.getDepts();
deptsBeans.forEach(deptsBean -> {
departs.addAll(Arrays.asList(deptsBean.getPid().split(",")));
});
});
//------------------------------
return bLessonRepository.queryPersonMore(curUser,departs);
}
......@@ -142,7 +154,19 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public List<BLesson> queryConcernByPagination(PageUtil pageUtil,CurUser curUser) {
//---------获取部门id------------
List<String> departs = getDeparts();
// List<String> departs = getDeparts();
List<String> departs = new ArrayList<>();
List<String> ids = Arrays.asList(new String[]{curUser.getUserId()});
MTUserGetsReqDTO mtUserGetsReqDTO = new MTUserGetsReqDTO();
mtUserGetsReqDTO.setCorpId(curUser.getCorpId());
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
List<MTUserInfoRspDTO.DeptsBean> deptsBeans = mtUserInfoRspDTO.getDepts();
deptsBeans.forEach(deptsBean -> {
departs.addAll(Arrays.asList(deptsBean.getPid().split(",")));
});
});
//------------------------------
return bLessonRepository.queryConcern(curUser,departs);
}
......@@ -151,7 +175,19 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public List<BLesson> queryInterestedByPagination(PageUtil pageUtil,CurUser curUser) {
//---------获取部门id------------
List<String> departs = getDeparts();
// List<String> departs = getDeparts();
List<String> departs = new ArrayList<>();
List<String> ids = Arrays.asList(new String[]{curUser.getUserId()});
MTUserGetsReqDTO mtUserGetsReqDTO = new MTUserGetsReqDTO();
mtUserGetsReqDTO.setCorpId(curUser.getCorpId());
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
List<MTUserInfoRspDTO.DeptsBean> deptsBeans = mtUserInfoRspDTO.getDepts();
deptsBeans.forEach(deptsBean -> {
departs.addAll(Arrays.asList(deptsBean.getPid().split(",")));
});
});
//------------------------------
return bLessonRepository.queryInterested(curUser,departs);
}
......@@ -259,7 +295,19 @@ public class BLessonServiceImpl implements BLessonService {
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public List<BLesson> queryHomeBLessonsByPagination(PageUtil pageUtil, FirstPageQueryDTO firstPageQueryDTO,List<AllCourseDTO> allCourse) {
List<String> departs = getDeparts();
// List<String> departs = getDeparts();
List<String> departs = new ArrayList<>();
List<String> ids = Arrays.asList(new String[]{firstPageQueryDTO.getUserId()});
MTUserGetsReqDTO mtUserGetsReqDTO = new MTUserGetsReqDTO();
mtUserGetsReqDTO.setCorpId(firstPageQueryDTO.getCorpId());
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
List<MTUserInfoRspDTO.DeptsBean> deptsBeans = mtUserInfoRspDTO.getDepts();
deptsBeans.forEach(deptsBean -> {
departs.addAll(Arrays.asList(deptsBean.getPid().split(",")));
});
});
firstPageQueryDTO.setDeparts(departs);
List<String> courseIds = null;
if (allCourse != null){
......@@ -358,15 +406,15 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public List<FindLessonRecommendRspDTO> queryRecommendByLessonId(FindLessonRecommendDTO param) {
//按部门名模糊查询部门id(list)------
if (StringUtils.isEmpty(param.getViewParam())){
param.setViewParam("");
}
// if (StringUtils.isEmpty(param.getViewParam())){
// param.setViewParam("");
// }
List<DeptGetRspDTO> departs = cotactApiRequestClient.deptListDeptInfoByName(param.getCorpId(),param.getViewParam());
//查询结果放入DTO中
param.setDeparts(departs);
//查询该课程推荐的所有人
List<FindLessonRecommendRspDTO> findLessonPersonRecommend = bRecommendRepository.queryRecommendPersonByLessonId(param);
//查询该课程推荐的所有部门
List<FindLessonRecommendRspDTO> findLessonDepartRecommend = bRecommendRepository.queryRecommendDepartByLessonId(param);
if (departs != null && departs.size() > 0 && findLessonDepartRecommend != null && findLessonDepartRecommend.size() > 0){
......@@ -473,7 +521,19 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public List<BLesson> queryListAllLessonByPagination(PageUtil pageUtil, FindListLessonDTO model, List<AllCourseDTO> allCourse) {
//---------获取部门------------
List<String> departs = getDeparts();
// List<String> departs = getDeparts();
List<String> departs = new ArrayList<>();
List<String> ids = Arrays.asList(new String[]{model.getUserId()});
MTUserGetsReqDTO mtUserGetsReqDTO = new MTUserGetsReqDTO();
mtUserGetsReqDTO.setCorpId(model.getCorpId());
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
List<MTUserInfoRspDTO.DeptsBean> deptsBeans = mtUserInfoRspDTO.getDepts();
deptsBeans.forEach(deptsBean -> {
departs.addAll(Arrays.asList(deptsBean.getPid().split(",")));
});
});
//----------------------------
model.setDeparts(departs);
List<String> courseIds;
......
......@@ -20,6 +20,8 @@ public class BRStudentChapterDto {
private String studentId;
private String lessonId;
private String progress;
private Integer current;
......
......@@ -41,7 +41,9 @@ public class BRStudentChapter {
private String paperFinish;
private String progress;
private double progress;
private int currentLocation;
}
......
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.core.util.IdGen;
import org.rcisoft.core.util.UserUtil;
......@@ -17,6 +22,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.text.BreakIterator;
import java.text.DecimalFormat;
import java.util.List;
......@@ -32,7 +38,8 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
@Autowired
private BRStudentChapterRepository bRStudentChapterRepository;
@Autowired
private BLessonPersonRepository bLessonPersonRepository;
/**
* 保存 bRStudentChapter
......@@ -43,30 +50,56 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
@Override
public PersistModel save(BRStudentChapterDto brStudentChapterDto){
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());
DecimalFormat df=new DecimalFormat("0.00");//设置保留位数
// 沒有開始看-新增信息
if (null != brStudentChapterList && brStudentChapterList.size() >0){
BRStudentChapter brStudentChapter = brStudentChapterList.get(0);
brStudentChapter.setCurrentLocation(brStudentChapterDto.getCurrent());
if (brStudentChapterDto.getCurrent() == brStudentChapterDto.getDuration()){
// who finish
brStudentChapter.setProgress("100%");
brStudentChapter.setProgress(1);
}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.setBusinessId(IdGen.uuid());
brStudentChapter.setStudentId(brStudentChapterDto.getStudentId());
brStudentChapter.setChapterId(brStudentChapterDto.getChapterId());
brStudentChapter.setCurrentLocation(brStudentChapterDto.getCurrent()); // 保存當前學習進度
if (brStudentChapterDto.getCurrent() == brStudentChapterDto.getDuration()){ // 判断是否已经完成
brStudentChapter.setIsComplete("1");
// brStudentChapter.setAutomatic("1");
brStudentChapter.setProgress("100%");
brStudentChapter.setProgress(1);
}else {
brStudentChapter.setIsComplete("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);
}
......
......@@ -34,6 +34,7 @@
<result column="is_finish" jdbcType="VARCHAR" property="isFinish"/>
<result column="is_collect" jdbcType="VARCHAR" property="isCollect"/>
<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="is_appoint" jdbcType="VARCHAR" property="isAppoint"/>
</resultMap>
......
......@@ -12,7 +12,8 @@
<result column="pdf_finish" jdbcType="VARCHAR" property="pdfFinish"/>
<result column="video_finish" jdbcType="VARCHAR" property="videoFinish"/>
<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>
<!--<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