From a30f19909f92901c0ede05ff04e705db52bcf651 Mon Sep 17 00:00:00 2001 From: zhanglei Date: Tue, 25 Aug 2026 11:54:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=95=99=E5=9F=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qinan/cedu/model/dto/ClassStudentDTO.java | 4 +- .../cedu/model/entity/ClassStudentDO.java | 4 +- .../model/query/ClassStudentPageQuery.java | 4 +- .../qinan/cedu/model/vo/ClassStudentVO.java | 4 +- .../ClassStudentExamRecordServiceImpl.java | 24 ++++++++++ ...ClassStudentLearningRecordServiceImpl.java | 46 ++++++++++++++++++- 6 files changed, 77 insertions(+), 9 deletions(-) diff --git a/safety-cedu-service/src/main/java/org/qinan/cedu/model/dto/ClassStudentDTO.java b/safety-cedu-service/src/main/java/org/qinan/cedu/model/dto/ClassStudentDTO.java index 5fbed03d..1b8331b4 100644 --- a/safety-cedu-service/src/main/java/org/qinan/cedu/model/dto/ClassStudentDTO.java +++ b/safety-cedu-service/src/main/java/org/qinan/cedu/model/dto/ClassStudentDTO.java @@ -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("入班时间") diff --git a/safety-cedu-service/src/main/java/org/qinan/cedu/model/entity/ClassStudentDO.java b/safety-cedu-service/src/main/java/org/qinan/cedu/model/entity/ClassStudentDO.java index 95d75313..29f0da82 100644 --- a/safety-cedu-service/src/main/java/org/qinan/cedu/model/entity/ClassStudentDO.java +++ b/safety-cedu-service/src/main/java/org/qinan/cedu/model/entity/ClassStudentDO.java @@ -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; diff --git a/safety-cedu-service/src/main/java/org/qinan/cedu/model/query/ClassStudentPageQuery.java b/safety-cedu-service/src/main/java/org/qinan/cedu/model/query/ClassStudentPageQuery.java index 077272d9..bbe30320 100644 --- a/safety-cedu-service/src/main/java/org/qinan/cedu/model/query/ClassStudentPageQuery.java +++ b/safety-cedu-service/src/main/java/org/qinan/cedu/model/query/ClassStudentPageQuery.java @@ -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("参训单位") diff --git a/safety-cedu-service/src/main/java/org/qinan/cedu/model/vo/ClassStudentVO.java b/safety-cedu-service/src/main/java/org/qinan/cedu/model/vo/ClassStudentVO.java index fe8dc034..e37b79a9 100644 --- a/safety-cedu-service/src/main/java/org/qinan/cedu/model/vo/ClassStudentVO.java +++ b/safety-cedu-service/src/main/java/org/qinan/cedu/model/vo/ClassStudentVO.java @@ -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("入班时间") diff --git a/safety-cedu-service/src/main/java/org/qinan/cedu/service/impl/ClassStudentExamRecordServiceImpl.java b/safety-cedu-service/src/main/java/org/qinan/cedu/service/impl/ClassStudentExamRecordServiceImpl.java index c7bb3328..a11fb05c 100644 --- a/safety-cedu-service/src/main/java/org/qinan/cedu/service/impl/ClassStudentExamRecordServiceImpl.java +++ b/safety-cedu-service/src/main/java/org/qinan/cedu/service/impl/ClassStudentExamRecordServiceImpl.java @@ -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 pageQuery(ClassStudentExamRecordPageQuery query) { @@ -51,6 +59,7 @@ public class ClassStudentExamRecordServiceImpl extends ServiceImpl classStudentDOS = classStudentMapper.selectList(new LambdaQueryWrapper() + .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; diff --git a/safety-cedu-service/src/main/java/org/qinan/cedu/service/impl/ClassStudentLearningRecordServiceImpl.java b/safety-cedu-service/src/main/java/org/qinan/cedu/service/impl/ClassStudentLearningRecordServiceImpl.java index 9fa969bc..4872a11c 100644 --- a/safety-cedu-service/src/main/java/org/qinan/cedu/service/impl/ClassStudentLearningRecordServiceImpl.java +++ b/safety-cedu-service/src/main/java/org/qinan/cedu/service/impl/ClassStudentLearningRecordServiceImpl.java @@ -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 pageQuery(ClassStudentLearningRecordPageQuery query) { @@ -64,7 +77,37 @@ public class ClassStudentLearningRecordServiceImpl extends ServiceImpl classStudentDOS = classStudentMapper.selectList(new LambdaQueryWrapper() + .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 coursewareIds = classCourseMapper.selectList(new LambdaQueryWrapper() + .eq(ClassCourseDO::getClassId, entity.getClassId())) + .stream() + .map(ClassCourseDO::getCoursewareId) + .flatMap(List::stream) + .filter(Objects::nonNull) + .distinct() + .collect(Collectors.toList()); + // 所有考试记录 + List 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