Commit e86b7f8c authored by luzhuang's avatar luzhuang

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

parents d36675e2 882e8a60
...@@ -60,6 +60,7 @@ import java.nio.file.Files; ...@@ -60,6 +60,7 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.*; import java.util.*;
...@@ -126,8 +127,6 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -126,8 +127,6 @@ public class BChapterServiceImpl implements BChapterService {
model.setLessonId(lessonId); model.setLessonId(lessonId);
model.setStudentId(curUser.getUserId()); model.setStudentId(curUser.getUserId());
List<QueryChapterListResDTO> queryChapterListResDTOS = queryChapterListResDTO(model, curUser.getCorpId()); List<QueryChapterListResDTO> queryChapterListResDTOS = queryChapterListResDTO(model, curUser.getCorpId());
// int i = 0;
// int percent = 0;
for (QueryChapterListResDTO queryChapterListResDTO : queryChapterListResDTOS) { for (QueryChapterListResDTO queryChapterListResDTO : queryChapterListResDTOS) {
for (QueryChapterListResDTO childList : queryChapterListResDTO.getChildList()) { for (QueryChapterListResDTO childList : queryChapterListResDTO.getChildList()) {
// 遍历学生章节中间表 查询学生观看章节进度 // 遍历学生章节中间表 查询学生观看章节进度
...@@ -135,9 +134,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -135,9 +134,7 @@ public class BChapterServiceImpl implements BChapterService {
if (null != brStudentChapterList && brStudentChapterList.size() > 0) { if (null != brStudentChapterList && brStudentChapterList.size() > 0) {
childList.setProgress(brStudentChapterList.get(0).getProgress() * 100 + "%"); childList.setProgress(brStudentChapterList.get(0).getProgress() * 100 + "%");
childList.setCurrentLocation(brStudentChapterList.get(0).getCurrentLocation()); childList.setCurrentLocation(brStudentChapterList.get(0).getCurrentLocation());
// percent += brStudentChapterList.get(0).getProgress();
} }
// i++;
} }
} }
Map map = new HashMap(); Map map = new HashMap();
...@@ -149,7 +146,6 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -149,7 +146,6 @@ public class BChapterServiceImpl implements BChapterService {
}else { }else {
map.put("totalProgress", "0%"); map.put("totalProgress", "0%");
} }
// map.put("totalProgress", i == 0 ? "0%" : df.format((float) percent / i) + "%");
BLesson bLesson = bLessonRepository.selectInfoById(lessonId); BLesson bLesson = bLessonRepository.selectInfoById(lessonId);
//判断课程是否存在 //判断课程是否存在
if (bLesson == null){ if (bLesson == null){
...@@ -318,16 +314,18 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -318,16 +314,18 @@ public class BChapterServiceImpl implements BChapterService {
// 所有学习过此课程的 学生课程信息 // 所有学习过此课程的 学生课程信息
List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.selectByLessonId(chapterDTO.getLessonId()); List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.selectByLessonId(chapterDTO.getLessonId());
BLesson bLesson = bLessonRepository.selectByPrimaryKey(chapterDTO.getLessonId()); BLesson bLesson = bLessonRepository.selectByPrimaryKey(chapterDTO.getLessonId());
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMaximumFractionDigits(2);
for (BLessonPerson lessonPerson: bLessonPersonList){ for (BLessonPerson lessonPerson: bLessonPersonList){
// 更新 学生针对此章节的中间表 // 更新 学生针对此章节的中间表
List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(chapterDTO.getBusinessId(), ""); List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(chapterDTO.getBusinessId(), "");
for (BRStudentChapter studentChapter: brStudentChapterList){ for (BRStudentChapter studentChapter: brStudentChapterList){
double learnProgress = Double.parseDouble(lessonPerson.getLearnProgress().split("%")[0]) / 100 ; double learnProgress = Double.parseDouble(lessonPerson.getLearnProgress().split("%")[0]) / 100 ;
double newLearnProgress = (learnProgress * Integer.parseInt(bLesson.getClassHour()) - studentChapter.getProgress()) / Double.parseDouble(bLesson.getClassHour()); double newLearnProgress = Double.parseDouble(numberFormat.format((float) (learnProgress * Integer.parseInt(bLesson.getClassHour()) - studentChapter.getProgress()) / Float.parseFloat(bLesson.getClassHour())));
if (learnProgress > 0 && newLearnProgress < 0.01){ if (learnProgress > 0 && newLearnProgress < 0.01){
newLearnProgress = 0.01; newLearnProgress = 0.01;
} }
if ("2".equals(lessonPerson.getIsFinish()) && newLearnProgress < 1){ if (newLearnProgress < 1){
lessonPerson.setIsFinish("1"); lessonPerson.setIsFinish("1");
lessonPerson.setFinishDate(null); lessonPerson.setFinishDate(null);
} }
...@@ -370,29 +368,31 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -370,29 +368,31 @@ public class BChapterServiceImpl implements BChapterService {
*/ */
// 新增章节 - 更新学生观看课程总进度 // 新增章节 - 更新学生观看课程总进度
private void updateLessonProgress(String lessonId, boolean add){ private void updateLessonProgress(String lessonId, boolean add){
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMaximumFractionDigits(2);
List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.selectByLessonId(lessonId); List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.selectByLessonId(lessonId);
BLesson bLesson = bLessonRepository.selectByPrimaryKey(lessonId); BLesson bLesson = bLessonRepository.selectByPrimaryKey(lessonId);
for (BLessonPerson lessonPerson: bLessonPersonList){ for (BLessonPerson lessonPerson: bLessonPersonList){
double newLearnProgress ; String newLearnProgress ;
double learnProgress = Double.parseDouble(lessonPerson.getLearnProgress().split("%")[0]) / 100 ; double learnProgress = Double.parseDouble(lessonPerson.getLearnProgress().split("%")[0]) / 100 ;
if (add){ if (add){
newLearnProgress = (float) Math.floor(learnProgress * Integer.parseInt(bLesson.getClassHour()) / (Double.parseDouble(bLesson.getClassHour()) + 1)); newLearnProgress = numberFormat.format( Math.floor(learnProgress * Integer.parseInt(bLesson.getClassHour()) / (Double.parseDouble(bLesson.getClassHour()) + 1) ));
}else { }else {
newLearnProgress = Integer.parseInt(bLesson.getClassHour()) == 0 ? 0 : (float) Math.floor(learnProgress * Integer.parseInt(bLesson.getClassHour() + 1) / Double.parseDouble(bLesson.getClassHour())); newLearnProgress = Integer.parseInt(bLesson.getClassHour()) == 0 ? "0" : numberFormat.format( Math.floor(learnProgress * Integer.parseInt(bLesson.getClassHour() + 1) / Double.parseDouble(bLesson.getClassHour()) ));
} }
if (learnProgress > 0 && newLearnProgress < 0.01){ if (learnProgress > 0 && Double.parseDouble(newLearnProgress) < 0.01){
newLearnProgress = 0.01; newLearnProgress = "0.01";
} }
if ("2".equals(lessonPerson.getIsFinish()) && newLearnProgress < 1){ if ("2".equals(lessonPerson.getIsFinish()) && Double.parseDouble(newLearnProgress) < 1){
lessonPerson.setIsFinish("1"); lessonPerson.setIsFinish("1");
lessonPerson.setFinishDate(null); lessonPerson.setFinishDate(null);
} }
if (newLearnProgress >= 1){ if (Double.parseDouble(newLearnProgress) >= 1){
newLearnProgress = 1; newLearnProgress = "1";
lessonPerson.setIsFinish("2"); lessonPerson.setIsFinish("2");
} }
lessonPerson.setLearnProgress(newLearnProgress*100+"%"); lessonPerson.setLearnProgress(Float.parseFloat(newLearnProgress)*100+"%");
bLessonPersonRepository.updateByPrimaryKeySelective(lessonPerson); bLessonPersonRepository.updateByPrimaryKeySelective(lessonPerson);
} }
} }
......
...@@ -33,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -33,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.BreakIterator; import java.text.BreakIterator;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -65,7 +66,9 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService { ...@@ -65,7 +66,9 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
@Override @Override
public PersistModel save(BRStudentChapterDto brStudentChapterDto, CurUser curUser){ public PersistModel save(BRStudentChapterDto brStudentChapterDto, CurUser curUser){
int line = 0; int line = 0;
DecimalFormat df=new DecimalFormat("0.00");//设置保留位数 // DecimalFormat df=new DecimalFormat("0.00");//设置保留位数
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMaximumFractionDigits(0);
// 查詢是否已經開始觀看此章節 // 查詢是否已經開始觀看此章節
List<BRStudentChapter> brStudentChapterList = bRStudentChapterRepository.queryByStuIdAndChapter(brStudentChapterDto.getChapterId(),brStudentChapterDto.getStudentId()); List<BRStudentChapter> brStudentChapterList = bRStudentChapterRepository.queryByStuIdAndChapter(brStudentChapterDto.getChapterId(),brStudentChapterDto.getStudentId());
// 沒有開始看-新增信息 // 沒有開始看-新增信息
...@@ -86,17 +89,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService { ...@@ -86,17 +89,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
brStudentChapter = this.dealBrstudentChapter(brStudentChapter, brStudentChapterDto); brStudentChapter = this.dealBrstudentChapter(brStudentChapter, brStudentChapterDto);
brStudentChapter.setStudentId(brStudentChapterDto.getStudentId()); brStudentChapter.setStudentId(brStudentChapterDto.getStudentId());
brStudentChapter.setChapterId(brStudentChapterDto.getChapterId()); brStudentChapter.setChapterId(brStudentChapterDto.getChapterId());
// brStudentChapter.setCurrentLocation(brStudentChapterDto.getCurrent()); // 保存當前學習進度
// if (brStudentChapterDto.getCurrent().equals(brStudentChapterDto.getDuration())){ // 判断是否已经完成
// brStudentChapter.setIsComplete("1");
// brStudentChapter.setProgress(1);
// isFinish = "2";
// }else {
// isFinish = "1";
// brStudentChapter.setIsComplete("0");
// brStudentChapter.setProgress((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration());
//// brStudentChapter.setProgress(new BigDecimal((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
// }
line = bRStudentChapterRepository.insertSelective(brStudentChapter); line = bRStudentChapterRepository.insertSelective(brStudentChapter);
} }
// b_lesson_person // b_lesson_person
...@@ -127,17 +120,13 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService { ...@@ -127,17 +120,13 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
if (i == 0){ if (i == 0){
totalProgress = "0.00%"; totalProgress = "0.00%";
}else { }else {
totalProgress = df.format((float) ((percent / i) * 100)) + "%"; totalProgress = numberFormat.format((float) percent / (float) i * 100) + "%";
// totalProgress = df.format((float) ((percent / i) * 100)) + "%";
}; };
// 判斷是否已經開始觀看此課程 // 判斷是否已經開始觀看此課程
if (null != bLessonPersonList && bLessonPersonList.size() >0){ if (null != bLessonPersonList && bLessonPersonList.size() >0){
BLessonPerson bLessonPerson = this.dealBLessonPerson(bLessonPersonList.get(0),brStudentChapterDto,totalProgress); BLessonPerson bLessonPerson = this.dealBLessonPerson(bLessonPersonList.get(0),brStudentChapterDto,totalProgress);
// BLessonPerson bLessonPerson = bLessonPersonList.get(0);
// bLessonPerson.setChapterId(brStudentChapterDto.getChapterId());
// bLessonPerson.setLearnProgress(totalProgress); // 保存课程学习进度
// if ("2".equals(isFinish))
// bLessonPerson.setFinishDate(new Date());
// bLessonPerson.setIsFinish(isFinish);
bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson); bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
}else { }else {
BLessonPerson bLessonPerson = new BLessonPerson(); BLessonPerson bLessonPerson = new BLessonPerson();
...@@ -145,11 +134,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService { ...@@ -145,11 +134,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
bLessonPerson = this.dealBLessonPerson(bLessonPersonList.get(0),brStudentChapterDto,totalProgress); bLessonPerson = this.dealBLessonPerson(bLessonPersonList.get(0),brStudentChapterDto,totalProgress);
bLessonPerson.setPersonId(brStudentChapterDto.getStudentId()); bLessonPerson.setPersonId(brStudentChapterDto.getStudentId());
bLessonPerson.setLessonId(brStudentChapterDto.getLessonId()); bLessonPerson.setLessonId(brStudentChapterDto.getLessonId());
// if ("2".equals(isFinish)) // 保存课程学习进度
// bLessonPerson.setFinishDate(new Date());
// bLessonPerson.setIsFinish(isFinish);
// bLessonPerson.setChapterId(brStudentChapterDto.getChapterId());
// bLessonPerson.setLearnProgress(totalProgress); // 保存课程学习进度
line = bLessonPersonRepository.insertSelective(bLessonPerson) ; line = bLessonPersonRepository.insertSelective(bLessonPerson) ;
} }
// 获取章节总进度 存库 // 获取章节总进度 存库
...@@ -181,8 +166,6 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService { ...@@ -181,8 +166,6 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
String isFinish; String isFinish;
if ("100%".equals(totalProgress)) { if ("100%".equals(totalProgress)) {
isFinish = "2"; isFinish = "2";
}else if ("0%".equals(totalProgress)){
isFinish = "0";
}else { }else {
isFinish = "1"; isFinish = "1";
} }
......
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