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