Commit af4547d6 authored by zhangqingle's avatar zhangqingle

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

parents 90c8c687 5f501cb9
# 修改 blesson value 19-12-10
ALTER table b_lesson modify column value_consume VARCHAR (16);
ALTER table b_lesson modify column value_gain VARCHAR (16);
# 修改 b_lesson_person value 19-12-10
ALTER table b_lesson_person modify column `value` VARCHAR (16);
# 修改 b_person_value value 19-12-10
ALTER table b_person_value modify column `value` VARCHAR (16);
# 修改 b_release_value value 19-12-10
ALTER table b_release_value modify column lesson_value VARCHAR (16);
ALTER table b_release_value modify column train_value VARCHAR (16);
# 添加b_person_value lessonId 字段 19-12-11
alter table b_person_value add lesson_id varchar(64) COMMENT '课程或培训id' after type;
# -------------测试环境已更新--------------
......@@ -6,6 +6,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.blesson.entity.BLessonPerson;
import org.rcisoft.business.brstudentchapter.dto.BRStudentChapterDto;
import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.sys.user.bean.CurUser;
......@@ -44,11 +45,10 @@ public class BRStudentChapterController extends PaginationController<BRStudentCh
@PostMapping(value = "/add")
public Result addOrUpdate(CurUser curUser, @Valid BRStudentChapterDto brStudentChapterDto, BindingResult bindingResult) {
brStudentChapterDto.setStudentId(curUser.getUserId());
PersistModel data = bRStudentChapterServiceImpl.save(brStudentChapterDto, curUser);
return Result.builder(data,
return Result.builder( new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
brStudentChapterDto);
bRStudentChapterServiceImpl.save(brStudentChapterDto, curUser));
}
}
package org.rcisoft.business.brstudentchapter.service;
import org.rcisoft.business.blesson.entity.BLessonPerson;
import org.rcisoft.business.brstudentchapter.dto.BRStudentChapterDto;
import org.rcisoft.business.brstudentchapter.entity.BRStudentChapter;
import org.rcisoft.core.model.PersistModel;
......@@ -7,6 +8,7 @@ import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.sys.user.bean.CurUser;
import java.util.List;
import java.util.Map;
/**
* Created by on 2019-9-25 10:01:43.
......@@ -18,7 +20,7 @@ public interface BRStudentChapterService {
* @param bRStudentChapter
* @return
*/
PersistModel save(BRStudentChapterDto bRStudentChapter, CurUser curUser);
Map save(BRStudentChapterDto bRStudentChapter, CurUser curUser);
/**
* 根据id查询
......
......@@ -33,7 +33,10 @@ import org.springframework.transaction.annotation.Transactional;
import java.text.NumberFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
......@@ -66,8 +69,9 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel save(BRStudentChapterDto brStudentChapterDto, CurUser curUser){
public Map save(BRStudentChapterDto brStudentChapterDto, CurUser curUser){
int line = 0;
String currentProgress = "";
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMaximumFractionDigits(0);
// 查詢是否已經開始觀看此章節
......@@ -79,12 +83,14 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
// 判断进度 是否大于数据库已经存在的进度
double now = brStudentChapter.getProgress();
if (now >= old){ // 进度大于以前的进度
currentProgress = (now*100)+"%";
if (brStudentChapterDto.getMaxPosition() != null){
brStudentChapter.setMaxPosition(brStudentChapterDto.getMaxPosition());
}
line = bRStudentChapterRepository.updateById(brStudentChapter);
}else { // 反之,只需更新最近看的时间
brStudentChapter.setProgress(old);
currentProgress = (old*100)+"%";
line = bRStudentChapterRepository.updateById(brStudentChapter);
}
}else { // 更新
......@@ -93,7 +99,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
brStudentChapter = this.dealBrstudentChapter(brStudentChapter, brStudentChapterDto);
brStudentChapter.setStudentId(brStudentChapterDto.getStudentId());
brStudentChapter.setChapterId(brStudentChapterDto.getChapterId());
currentProgress = (brStudentChapter.getProgress()*100)+"%";
line = bRStudentChapterRepository.insertSelective(brStudentChapter);
}
// b_lesson_person
......@@ -129,9 +135,10 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
totalProgress = tempTotalProgress > 100 ? "100%" : tempTotalProgress < 0 ? "0%" : tempTotalProgress + "%";
// totalProgress = tempTotalProgress + "%";
};
BLessonPerson bLessonPerson = new BLessonPerson();
// 判斷是否已經開始觀看此課程
if (null != bLessonPersonList && bLessonPersonList.size() >0 && bLessonPersonList.get(0) != null){
BLessonPerson bLessonPerson = this.dealBLessonPerson(bLessonPersonList.get(0),brStudentChapterDto,totalProgress);
bLessonPerson = this.dealBLessonPerson(bLessonPersonList.get(0),brStudentChapterDto,totalProgress);
//TODO 判断是否为已学完 曾经是否学完过 奖励积分
BLesson bLesson = bLessonRepository.selectByPrimaryKey(brStudentChapterDto.getLessonId());
if (bLesson != null && IsFinishEnum.FINISHED.getCode().equals(bLessonPerson.getIsFinish()) && !("1".equals(bLessonPerson.getEverFinished()))){
......@@ -142,7 +149,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
}
bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
}else {
BLessonPerson bLessonPerson = new BLessonPerson();
bLessonPerson.initModel();
bLessonPerson = this.dealBLessonPerson(bLessonPerson,brStudentChapterDto,totalProgress);
bLessonPerson.setPersonId(brStudentChapterDto.getStudentId());
......@@ -164,7 +171,9 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
bChapter.setCourseTime(brStudentChapterDto.getDuration().toString());
line = bChapterRepository.updateByPrimaryKeySelective(bChapter) > line ? bChapterRepository.updateByPrimaryKeySelective(bChapter): line;
}
return new PersistModel(line);
Map map = new HashMap();
map.put("currentProgress", currentProgress);
return map;
}
// b_r_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