fix: 教培

dev-tmp1
zhanglei 2026-08-25 11:54:49 +08:00
parent ca2092bd82
commit a30f19909f
6 changed files with 77 additions and 9 deletions

View File

@ -46,10 +46,10 @@ public class ClassStudentDTO {
@ApiModelProperty("已完成学时(小时)")
private BigDecimal completedHours;
@ApiModelProperty("学习状态0-未学习1-学习中2-已学完3-已完成")
@ApiModelProperty("学习状态0-未学习1-学习中2-已完成")
private Integer studyStatus;
@ApiModelProperty("考试状态0-不考试1-待考试2-考试未通过3-考试通过4-未参加")
@ApiModelProperty("考试状态0-不考试1-待考试2-考试未通过3-考试通过")
private Integer examStatus;
@ApiModelProperty("入班时间")

View File

@ -50,13 +50,13 @@ public class ClassStudentDO extends BaseEntity {
private BigDecimal completedHours;
/**
* 0-1-2-3-
* 0-1-2-
*/
@TableField("study_status")
private Integer studyStatus;
/**
* 0-1-2-3-4-
* 0-1-2-3-
*/
@TableField("exam_status")
private Integer examStatus;

View File

@ -22,10 +22,10 @@ public class ClassStudentPageQuery extends BasePageQuery {
@ApiModelProperty("手机号")
private String phone;
@ApiModelProperty("学习状态")
@ApiModelProperty("学习状态0-未学习1-学习中2-已完成")
private Integer studyStatus;
@ApiModelProperty("考试状态")
@ApiModelProperty("考试状态0-不考试1-待考试2-考试未通过3-考试通过")
private Integer examStatus;
@ApiModelProperty("参训单位")

View File

@ -45,10 +45,10 @@ public class ClassStudentVO extends BaseVO {
@ApiModelProperty("已完成学时(小时)")
private BigDecimal completedHours;
@ApiModelProperty("学习状态0-未学习1-学习中2-已学完3-已完成")
@ApiModelProperty("学习状态0-未学习1-学习中2-已完成")
private Integer studyStatus;
@ApiModelProperty("考试状态0-不考试1-待考试2-考试未通过3-考试通过4-未参加")
@ApiModelProperty("考试状态0-不考试1-待考试2-考试未通过3-考试通过")
private Integer examStatus;
@ApiModelProperty("入班时间")

View File

@ -1,12 +1,15 @@
package org.qinan.cedu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.qinan.cedu.convertor.ClassStudentExamRecordConvertor;
import org.qinan.cedu.enums.DeleteEnum;
import org.qinan.cedu.mapper.ClassStudentExamRecordMapper;
import org.qinan.cedu.mapper.ClassStudentMapper;
import org.qinan.cedu.model.dto.ClassStudentExamRecordDTO;
import org.qinan.cedu.model.entity.ClassStudentDO;
import org.qinan.cedu.model.entity.ClassStudentExamRecordDO;
import org.qinan.cedu.model.query.ClassStudentExamRecordPageQuery;
import org.qinan.cedu.model.vo.ClassStudentExamRecordVO;
@ -14,8 +17,11 @@ import org.qinan.cedu.service.ClassStudentExamRecordService;
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.List;
/**
*
@ -26,6 +32,8 @@ public class ClassStudentExamRecordServiceImpl extends ServiceImpl<ClassStudentE
@Autowired
private ClassStudentExamRecordConvertor classStudentExamRecordConvertor;
@Autowired
private ClassStudentMapper classStudentMapper;
@Override
public IPage<ClassStudentExamRecordVO> pageQuery(ClassStudentExamRecordPageQuery query) {
@ -51,6 +59,7 @@ public class ClassStudentExamRecordServiceImpl extends ServiceImpl<ClassStudentE
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveRecord(ClassStudentExamRecordDTO dto) {
ClassStudentExamRecordDO entity = classStudentExamRecordConvertor.convertDtoToE(dto);
InsertFieldDefaults.apply(entity);
@ -61,16 +70,31 @@ public class ClassStudentExamRecordServiceImpl extends ServiceImpl<ClassStudentE
if (entity.getWrongCount() == null) {
entity.setWrongCount(0);
}
callbackFillStudent(entity);
return this.save(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateRecord(ClassStudentExamRecordDTO dto) {
ClassStudentExamRecordDO entity = classStudentExamRecordConvertor.convertDtoToE(dto);
InsertFieldDefaults.applyForUpdate(entity);
callbackFillStudent(entity);
return this.updateById(entity);
}
public void callbackFillStudent(ClassStudentExamRecordDO entity) {
List<ClassStudentDO> classStudentDOS = classStudentMapper.selectList(new LambdaQueryWrapper<ClassStudentDO>()
.eq(ClassStudentDO::getStudentId, entity.getStudentId())
.eq(ClassStudentDO::getClassId, entity.getClassId())
.eq(ClassStudentDO::getDeleteEnum, DeleteEnum.FALSE.getCode()));
if (!CollectionUtils.isEmpty(classStudentDOS)) {
for (ClassStudentDO classStudentDO : classStudentDOS) {
classStudentDO.setExamStatus(entity.getPassed() == 1 ? 3 : 2);
}
}
}
@Override
public boolean deleteById(Long id) {
return baseMapper.deleteById(id) > 0;

View File

@ -1,12 +1,17 @@
package org.qinan.cedu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.qinan.cedu.convertor.ClassStudentLearningRecordConvertor;
import org.qinan.cedu.enums.DeleteEnum;
import org.qinan.cedu.mapper.ClassCourseMapper;
import org.qinan.cedu.mapper.ClassStudentLearningRecordMapper;
import org.qinan.cedu.mapper.ClassStudentMapper;
import org.qinan.cedu.model.dto.ClassStudentLearningRecordDTO;
import org.qinan.cedu.model.entity.ClassCourseDO;
import org.qinan.cedu.model.entity.ClassStudentDO;
import org.qinan.cedu.model.entity.ClassStudentLearningRecordDO;
import org.qinan.cedu.model.query.ClassStudentLearningRecordPageQuery;
import org.qinan.cedu.model.vo.ClassStudentLearningRecordVO;
@ -15,8 +20,12 @@ import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
*
@ -27,6 +36,10 @@ public class ClassStudentLearningRecordServiceImpl extends ServiceImpl<ClassStud
@Autowired
private ClassStudentLearningRecordConvertor classStudentLearningRecordConvertor;
@Autowired
private ClassStudentMapper classStudentMapper;
@Autowired
private ClassCourseMapper classCourseMapper;
@Override
public IPage<ClassStudentLearningRecordVO> pageQuery(ClassStudentLearningRecordPageQuery query) {
@ -64,7 +77,37 @@ public class ClassStudentLearningRecordServiceImpl extends ServiceImpl<ClassStud
}
public void callbackFillStudent(ClassStudentLearningRecordDO entity) {
List<ClassStudentDO> classStudentDOS = classStudentMapper.selectList(new LambdaQueryWrapper<ClassStudentDO>()
.eq(ClassStudentDO::getStudentId, entity.getStudentId())
.eq(ClassStudentDO::getClassId, entity.getClassId())
.eq(ClassStudentDO::getDeleteEnum, DeleteEnum.FALSE.getCode()));
int state = 1;
if (Objects.nonNull(entity.getStudyStatus()) && entity.getStudyStatus() == 2) {
// 实际需要考试
List<Long> coursewareIds = classCourseMapper.selectList(new LambdaQueryWrapper<ClassCourseDO>()
.eq(ClassCourseDO::getClassId, entity.getClassId()))
.stream()
.map(ClassCourseDO::getCoursewareId)
.flatMap(List::stream)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
// 所有考试记录
List<ClassStudentLearningRecordDO> classStudentLearningRecordDOS = this.lambdaQuery()
.eq(ClassStudentLearningRecordDO::getStudentId, entity.getStudentId())
.eq(ClassStudentLearningRecordDO::getClassId, entity.getClassId())
.eq(ClassStudentLearningRecordDO::getDeleteEnum, DeleteEnum.FALSE.getCode())
.list();
if (classStudentLearningRecordDOS != null && classStudentLearningRecordDOS.stream().allMatch(record -> record.getStudyStatus() == 2) && classStudentLearningRecordDOS.size() == coursewareIds.size()) {
state = 2;
}
}
if (!CollectionUtils.isEmpty(classStudentDOS)) {
for (ClassStudentDO classStudentDO : classStudentDOS) {
classStudentDO.setStudyStatus(state);
classStudentMapper.updateById(classStudentDO);
}
}
}
@Transactional(rollbackFor = Exception.class)
@ -72,6 +115,7 @@ public class ClassStudentLearningRecordServiceImpl extends ServiceImpl<ClassStud
public boolean updateRecord(ClassStudentLearningRecordDTO dto) {
ClassStudentLearningRecordDO entity = classStudentLearningRecordConvertor.convertDtoToE(dto);
InsertFieldDefaults.applyForUpdate(entity);
callbackFillStudent(entity);
return this.updateById(entity);
}