|
|
@ -244,8 +244,9 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal remainingHours = BigDecimal.ZERO; // 初始化剩余学时
|
|
|
|
BigDecimal remainingHours = BigDecimal.ZERO; // 初始化剩余学时
|
|
|
|
|
|
|
|
|
|
|
|
if (pid == null) { |
|
|
|
if (pid == null||pid.equals(0L)) { |
|
|
|
BigDecimal classHours = coursesMapper.getClassHoursById(chapterDTO.getCourseId()); |
|
|
|
BigDecimal classHours = coursesMapper.getClassHoursById(chapterDTO.getCourseId()); |
|
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<Chapter> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
LambdaQueryWrapper<Chapter> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
lambdaQueryWrapper.eq(Chapter::getPid, 0) |
|
|
|
lambdaQueryWrapper.eq(Chapter::getPid, 0) |
|
|
|
.eq(Chapter::getCourseId, chapterDTO.getCourseId()); |
|
|
|
.eq(Chapter::getCourseId, chapterDTO.getCourseId()); |
|
|
@ -258,10 +259,10 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl |
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
|
|
|
|
|
|
remainingHours = classHours.subtract(totalChapterHours).setScale(1, RoundingMode.HALF_UP); |
|
|
|
remainingHours = classHours.subtract(totalChapterHours).setScale(1, RoundingMode.HALF_UP); |
|
|
|
|
|
|
|
BigDecimal newChapterHours = BigDecimal.valueOf(chapter.getTotalClassHours()); // 根据实际返回类型调整
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (newChapterHours.compareTo(remainingHours) <= 0) { |
|
|
|
if (totalChapterHours.compareTo(classHours) < 0) { |
|
|
|
|
|
|
|
chapter.setPid(0L); |
|
|
|
chapter.setPid(0L); |
|
|
|
LambdaQueryWrapper<Chapter> maxSortWrapper = new LambdaQueryWrapper<>(); |
|
|
|
LambdaQueryWrapper<Chapter> maxSortWrapper = new LambdaQueryWrapper<>(); |
|
|
|
maxSortWrapper.eq(Chapter::getPid, 0).orderByDesc(Chapter::getOrderNum).last("limit 1"); |
|
|
|
maxSortWrapper.eq(Chapter::getPid, 0).orderByDesc(Chapter::getOrderNum).last("limit 1"); |
|
|
@ -274,10 +275,12 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl |
|
|
|
chapter.setCreateTime(LocalDateTime.now()); |
|
|
|
chapter.setCreateTime(LocalDateTime.now()); |
|
|
|
chapter.setUpdateTime(LocalDateTime.now()); |
|
|
|
chapter.setUpdateTime(LocalDateTime.now()); |
|
|
|
this.save(chapter); |
|
|
|
this.save(chapter); |
|
|
|
|
|
|
|
remainingHours = remainingHours.subtract(newChapterHours).setScale(1, RoundingMode.HALF_UP); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw new BusinessException(ErrorCode.PARAMS_ERROR, "当前课程的总学时已经分配完成,请先修改章节学时,或者课程总学时"); |
|
|
|
throw new BusinessException(ErrorCode.PARAMS_ERROR, "当前添加的学时为:"+newChapterHours+"当前剩余学时为:"+remainingHours); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal chapterHours = chapterMapper.getChapterHours(pid); |
|
|
|
BigDecimal chapterHours = chapterMapper.getChapterHours(pid); |
|
|
|
|
|
|
|
|
|
|
@ -297,7 +300,6 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
remainingHours = chapterHours.subtract(hours).setScale(1, RoundingMode.HALF_UP); |
|
|
|
remainingHours = chapterHours.subtract(hours).setScale(1, RoundingMode.HALF_UP); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|