Merge remote-tracking branch 'origin/dev-tmp1' into dev-tmp1
commit
2866589177
|
|
@ -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("入班时间")
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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("参训单位")
|
||||
|
|
|
|||
|
|
@ -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("入班时间")
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue