Commit 8abd7980 authored by 王淑君's avatar 王淑君

更新接口

parent 560c0e12
......@@ -33,10 +33,7 @@ import org.rcisoft.sys.role.dao.SysRoleRepository;
import org.rcisoft.sys.user.bean.CurUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
......@@ -116,7 +113,7 @@ public class BChapterController extends PaginationController<BChapter> {
}
@ApiOperation(value = "205 查询章节带进度", notes = "根据lessonId查询章节带进度", response = QueryChapterListResDTO.class)
@GetMapping(value = "/queryBChaptersWithProgress")
public Result queryBChaptersWithProgress(CurUser curUser,@Valid String lessonId,BindingResult br) {
public Result queryBChaptersWithProgress(CurUser curUser, @RequestParam String lessonId, BindingResult br) {
Map<String, Object> map = new HashedMap();
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
......
......@@ -37,6 +37,7 @@ import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -93,16 +94,31 @@ public class BChapterServiceImpl implements BChapterService {
model.setLessonId(lessonId);
model.setStudentId(curUser.getUserId());
List<QueryChapterListResDTO> queryChapterListResDTOS = queryChapterListResDTO(model, curUser.getCorpId());
queryChapterListResDTOS.stream().forEach(queryChapterListResDTO -> {
queryChapterListResDTO.getChildList().stream().forEach(childList -> {
int i = 0;
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);
}
});
});
i++;
}
}
// queryChapterListResDTOS.stream().forEach(queryChapterListResDTO -> {
// queryChapterListResDTO.getChildList().stream().forEach(childList -> {
// List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(childList.getBusinessId(), curUser.getUserId());
// if (null != brStudentChapterList && brStudentChapterList.size() > 0) {
// childList.setProgress(brStudentChapterList.get(0).getProgress());
// }
// });
// });
Map map = new HashMap();
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()));
return map;
}
......
package org.rcisoft.business.brstudentchapter.dao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.rcisoft.business.brstudentchapter.dto.BRStudentChapterDto;
import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.business.brstudentchapter.entity.BRStudentChapter;
......@@ -38,5 +39,12 @@ public interface BRStudentChapterRepository extends BaseMapper<BRStudentChapter>
+ "</script>")
@ResultMap(value = "BRStudentChapterResultMap" )
List<BRStudentChapter> queryByStuIdAndChapter(@Param("chapterId") String chapterId,@Param("studentId") String studentId);
@Update("UPDATE b_r_student_chapter " +
"SET progress = #{progress} " +
"WHERE " +
" business_id = #{businessId} ")
@ResultMap(value = "BRStudentChapterResultMap" )
int updateById(BRStudentChapter brStudentChapter);
}
......@@ -44,16 +44,16 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
public PersistModel save(BRStudentChapterDto brStudentChapterDto){
int line = 0;
List<BRStudentChapter> brStudentChapterList = bRStudentChapterRepository.queryByStuIdAndChapter(brStudentChapterDto.getChapterId(),brStudentChapterDto.getStudentId());
DecimalFormat df=new DecimalFormat("0.00");//设置保留位数
if (null != brStudentChapterList && brStudentChapterList.size() >0){
// DecimalFormat df=new DecimalFormat("0.00");//设置保留位数
// df.format((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration());
BRStudentChapter brStudentChapter = brStudentChapterList.get(0);
if (brStudentChapterDto.getCurrent() == brStudentChapterDto.getDuration()){
// who finish
brStudentChapter.setProgress("100%");
}else
brStudentChapter.setProgress(brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()*100+"%");
line = bRStudentChapterRepository.updateByPrimaryKey(brStudentChapter);
}else{
brStudentChapter.setProgress(df.format((float)brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()*100)+ "%");
}
line = bRStudentChapterRepository.updateById(brStudentChapter);
}else {
BRStudentChapter brStudentChapter = new BRStudentChapter();
brStudentChapter.setBusinessId(IdGen.uuid());
......@@ -66,7 +66,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
}else {
brStudentChapter.setIsComplete("0");
// brStudentChapter.setAutomatic("0");
brStudentChapter.setProgress(brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()*100+"%");
brStudentChapter.setProgress(df.format(brStudentChapterDto.getCurrent()/brStudentChapterDto.getDuration()*100)+"%");
}
line = bRStudentChapterRepository.insertSelective(brStudentChapter);
}
......
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