fix: 教培调整
parent
9a46857a0e
commit
0a46f676ba
|
|
@ -32,9 +32,15 @@ public class ClassCourseDO extends BaseEntity {
|
|||
@TableField("course_id")
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 要求学时
|
||||
*/
|
||||
@TableField("required_total_hours")
|
||||
private BigDecimal requiredTotalHours;
|
||||
|
||||
/**
|
||||
* 视频时长
|
||||
*/
|
||||
@TableField("video_duration")
|
||||
private BigDecimal videoDuration;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,9 +43,15 @@ public class ClassStudentDO extends BaseEntity {
|
|||
@TableField("face_auth")
|
||||
private Integer faceAuth;
|
||||
|
||||
/**
|
||||
* 要求学时
|
||||
*/
|
||||
@TableField("required_hours")
|
||||
private BigDecimal requiredHours;
|
||||
|
||||
/**
|
||||
* 完成学时
|
||||
*/
|
||||
@TableField("completed_hours")
|
||||
private BigDecimal completedHours;
|
||||
|
||||
|
|
|
|||
|
|
@ -144,24 +144,17 @@ public class ClassCourseServiceImpl extends ServiceImpl<ClassCourseMapper, Class
|
|||
InsertFieldDefaults.apply(entity);
|
||||
entity.setUpdateTime(LocalDateTime.now());
|
||||
List<CoursewareManagementDO> coursewareManagementDOS = coursewareManagementMapper.selectBatchIds(CollectionUtils.isEmpty(dto.getCoursewareId()) ? Collections.singletonList(0L) : dto.getCoursewareId());
|
||||
// 判空
|
||||
if (entity.getRequiredTotalHours() != null) {
|
||||
entity.setRequiredTotalHours(entity.getRequiredTotalHours().add(coursewareManagementDOS.stream().map(CoursewareManagementDO::getClassHourDuration).reduce(BigDecimal.ZERO, BigDecimal::add)));
|
||||
} else {
|
||||
entity.setRequiredTotalHours(coursewareManagementDOS.stream().map(CoursewareManagementDO::getClassHourDuration).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
}
|
||||
if (entity.getVideoDuration() != null) {
|
||||
entity.setVideoDuration(entity.getVideoDuration().add(coursewareManagementDOS.stream().map(CoursewareManagementDO::getCreditHours).reduce(BigDecimal.ZERO, BigDecimal::add)));
|
||||
} else {
|
||||
entity.setVideoDuration(coursewareManagementDOS.stream().map(CoursewareManagementDO::getCreditHours).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
}
|
||||
|
||||
entity.setRequiredTotalHours(coursewareManagementDOS.stream().map(CoursewareManagementDO::getCreditHours).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
entity.setVideoDuration(coursewareManagementDOS.stream().map(CoursewareManagementDO::getClassHourDuration).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
|
||||
// 学员回填数据(要求学时)
|
||||
for (ClassStudentDO classStudentDO : classStudentMapper.selectList(new LambdaQueryWrapper<ClassStudentDO>()
|
||||
.eq(ClassStudentDO::getClassId, entity.getClassId()))) {
|
||||
if (classStudentDO.getRequiredHours() != null) {
|
||||
classStudentDO.setRequiredHours(classStudentDO.getRequiredHours().add(entity.getVideoDuration()));
|
||||
classStudentDO.setRequiredHours(classStudentDO.getRequiredHours().add(entity.getRequiredTotalHours()));
|
||||
} else {
|
||||
classStudentDO.setRequiredHours(entity.getVideoDuration());
|
||||
classStudentDO.setRequiredHours(entity.getRequiredTotalHours());
|
||||
}
|
||||
classStudentMapper.updateById(classStudentDO);
|
||||
}
|
||||
|
|
@ -174,24 +167,17 @@ public class ClassCourseServiceImpl extends ServiceImpl<ClassCourseMapper, Class
|
|||
ClassCourseDO entity = classCourseConvertor.convertDtoToE(dto);
|
||||
InsertFieldDefaults.applyForUpdate(entity);
|
||||
List<CoursewareManagementDO> coursewareManagementDOS = coursewareManagementMapper.selectBatchIds(CollectionUtils.isEmpty(dto.getCoursewareId()) ? Collections.singletonList(0L) : dto.getCoursewareId());
|
||||
// 判空
|
||||
if (entity.getRequiredTotalHours() != null) {
|
||||
entity.setRequiredTotalHours(entity.getRequiredTotalHours().add(coursewareManagementDOS.stream().map(CoursewareManagementDO::getClassHourDuration).reduce(BigDecimal.ZERO, BigDecimal::add)));
|
||||
} else {
|
||||
entity.setRequiredTotalHours(coursewareManagementDOS.stream().map(CoursewareManagementDO::getClassHourDuration).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
}
|
||||
if (entity.getVideoDuration() != null) {
|
||||
entity.setVideoDuration(entity.getVideoDuration().add(coursewareManagementDOS.stream().map(CoursewareManagementDO::getCreditHours).reduce(BigDecimal.ZERO, BigDecimal::add)));
|
||||
} else {
|
||||
entity.setVideoDuration(coursewareManagementDOS.stream().map(CoursewareManagementDO::getCreditHours).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
}
|
||||
|
||||
entity.setRequiredTotalHours(coursewareManagementDOS.stream().map(CoursewareManagementDO::getCreditHours).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
entity.setVideoDuration(coursewareManagementDOS.stream().map(CoursewareManagementDO::getClassHourDuration).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
|
||||
// 学员回填数据(要求学时)
|
||||
for (ClassStudentDO classStudentDO : classStudentMapper.selectList(new LambdaQueryWrapper<ClassStudentDO>()
|
||||
.eq(ClassStudentDO::getClassId, entity.getClassId()))) {
|
||||
if (classStudentDO.getRequiredHours() != null) {
|
||||
classStudentDO.setRequiredHours(classStudentDO.getRequiredHours().add(entity.getVideoDuration()));
|
||||
classStudentDO.setRequiredHours(classStudentDO.getRequiredHours().add(entity.getRequiredTotalHours()));
|
||||
} else {
|
||||
classStudentDO.setRequiredHours(entity.getVideoDuration());
|
||||
classStudentDO.setRequiredHours(entity.getRequiredTotalHours());
|
||||
}
|
||||
classStudentMapper.updateById(classStudentDO);
|
||||
}
|
||||
|
|
@ -199,7 +185,18 @@ public class ClassCourseServiceImpl extends ServiceImpl<ClassCourseMapper, Class
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteById(Long id) {
|
||||
// 清除学员学时
|
||||
ClassCourseDO classCourseDO = baseMapper.selectById(id);
|
||||
for (ClassStudentDO classStudentDO : classStudentMapper.selectList(new LambdaQueryWrapper<ClassStudentDO>()
|
||||
.eq(ClassStudentDO::getClassId, classCourseDO.getClassId()))) {
|
||||
if (classStudentDO.getRequiredHours() != null) {
|
||||
classStudentDO.setRequiredHours(classStudentDO.getRequiredHours().subtract(classCourseDO.getRequiredTotalHours()));
|
||||
}
|
||||
classStudentMapper.updateById(classStudentDO);
|
||||
}
|
||||
|
||||
return baseMapper.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue