fix: 教培
parent
ca2092bd82
commit
a30f19909f
|
|
@ -46,10 +46,10 @@ public class ClassStudentDTO {
|
||||||
@ApiModelProperty("已完成学时(小时)")
|
@ApiModelProperty("已完成学时(小时)")
|
||||||
private BigDecimal completedHours;
|
private BigDecimal completedHours;
|
||||||
|
|
||||||
@ApiModelProperty("学习状态:0-未学习,1-学习中,2-已学完,3-已完成")
|
@ApiModelProperty("学习状态:0-未学习,1-学习中,2-已完成")
|
||||||
private Integer studyStatus;
|
private Integer studyStatus;
|
||||||
|
|
||||||
@ApiModelProperty("考试状态:0-不考试,1-待考试,2-考试未通过,3-考试通过,4-未参加")
|
@ApiModelProperty("考试状态:0-不考试,1-待考试,2-考试未通过,3-考试通过")
|
||||||
private Integer examStatus;
|
private Integer examStatus;
|
||||||
|
|
||||||
@ApiModelProperty("入班时间")
|
@ApiModelProperty("入班时间")
|
||||||
|
|
|
||||||
|
|
@ -50,13 +50,13 @@ public class ClassStudentDO extends BaseEntity {
|
||||||
private BigDecimal completedHours;
|
private BigDecimal completedHours;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 学习状态:0-未学习,1-学习中,2-已学完,3-已完成
|
* 学习状态:0-未学习,1-学习中,2-已完成
|
||||||
*/
|
*/
|
||||||
@TableField("study_status")
|
@TableField("study_status")
|
||||||
private Integer studyStatus;
|
private Integer studyStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 考试状态:0-不考试,1-待考试,2-考试未通过,3-考试通过,4-未参加
|
* 考试状态:0-不考试,1-待考试,2-考试未通过,3-考试通过
|
||||||
*/
|
*/
|
||||||
@TableField("exam_status")
|
@TableField("exam_status")
|
||||||
private Integer examStatus;
|
private Integer examStatus;
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@ public class ClassStudentPageQuery extends BasePageQuery {
|
||||||
@ApiModelProperty("手机号")
|
@ApiModelProperty("手机号")
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
@ApiModelProperty("学习状态")
|
@ApiModelProperty("学习状态:0-未学习,1-学习中,2-已完成")
|
||||||
private Integer studyStatus;
|
private Integer studyStatus;
|
||||||
|
|
||||||
@ApiModelProperty("考试状态")
|
@ApiModelProperty("考试状态:0-不考试,1-待考试,2-考试未通过,3-考试通过")
|
||||||
private Integer examStatus;
|
private Integer examStatus;
|
||||||
|
|
||||||
@ApiModelProperty("参训单位")
|
@ApiModelProperty("参训单位")
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,10 @@ public class ClassStudentVO extends BaseVO {
|
||||||
@ApiModelProperty("已完成学时(小时)")
|
@ApiModelProperty("已完成学时(小时)")
|
||||||
private BigDecimal completedHours;
|
private BigDecimal completedHours;
|
||||||
|
|
||||||
@ApiModelProperty("学习状态:0-未学习,1-学习中,2-已学完,3-已完成")
|
@ApiModelProperty("学习状态:0-未学习,1-学习中,2-已完成")
|
||||||
private Integer studyStatus;
|
private Integer studyStatus;
|
||||||
|
|
||||||
@ApiModelProperty("考试状态:0-不考试,1-待考试,2-考试未通过,3-考试通过,4-未参加")
|
@ApiModelProperty("考试状态:0-不考试,1-待考试,2-考试未通过,3-考试通过")
|
||||||
private Integer examStatus;
|
private Integer examStatus;
|
||||||
|
|
||||||
@ApiModelProperty("入班时间")
|
@ApiModelProperty("入班时间")
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
package org.qinan.cedu.service.impl;
|
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.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.qinan.cedu.convertor.ClassStudentExamRecordConvertor;
|
import org.qinan.cedu.convertor.ClassStudentExamRecordConvertor;
|
||||||
import org.qinan.cedu.enums.DeleteEnum;
|
import org.qinan.cedu.enums.DeleteEnum;
|
||||||
import org.qinan.cedu.mapper.ClassStudentExamRecordMapper;
|
import org.qinan.cedu.mapper.ClassStudentExamRecordMapper;
|
||||||
|
import org.qinan.cedu.mapper.ClassStudentMapper;
|
||||||
import org.qinan.cedu.model.dto.ClassStudentExamRecordDTO;
|
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.entity.ClassStudentExamRecordDO;
|
||||||
import org.qinan.cedu.model.query.ClassStudentExamRecordPageQuery;
|
import org.qinan.cedu.model.query.ClassStudentExamRecordPageQuery;
|
||||||
import org.qinan.cedu.model.vo.ClassStudentExamRecordVO;
|
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.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 学员考试记录服务实现
|
* 学员考试记录服务实现
|
||||||
|
|
@ -26,6 +32,8 @@ public class ClassStudentExamRecordServiceImpl extends ServiceImpl<ClassStudentE
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ClassStudentExamRecordConvertor classStudentExamRecordConvertor;
|
private ClassStudentExamRecordConvertor classStudentExamRecordConvertor;
|
||||||
|
@Autowired
|
||||||
|
private ClassStudentMapper classStudentMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<ClassStudentExamRecordVO> pageQuery(ClassStudentExamRecordPageQuery query) {
|
public IPage<ClassStudentExamRecordVO> pageQuery(ClassStudentExamRecordPageQuery query) {
|
||||||
|
|
@ -51,6 +59,7 @@ public class ClassStudentExamRecordServiceImpl extends ServiceImpl<ClassStudentE
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean saveRecord(ClassStudentExamRecordDTO dto) {
|
public boolean saveRecord(ClassStudentExamRecordDTO dto) {
|
||||||
ClassStudentExamRecordDO entity = classStudentExamRecordConvertor.convertDtoToE(dto);
|
ClassStudentExamRecordDO entity = classStudentExamRecordConvertor.convertDtoToE(dto);
|
||||||
InsertFieldDefaults.apply(entity);
|
InsertFieldDefaults.apply(entity);
|
||||||
|
|
@ -61,16 +70,31 @@ public class ClassStudentExamRecordServiceImpl extends ServiceImpl<ClassStudentE
|
||||||
if (entity.getWrongCount() == null) {
|
if (entity.getWrongCount() == null) {
|
||||||
entity.setWrongCount(0);
|
entity.setWrongCount(0);
|
||||||
}
|
}
|
||||||
|
callbackFillStudent(entity);
|
||||||
return this.save(entity);
|
return this.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean updateRecord(ClassStudentExamRecordDTO dto) {
|
public boolean updateRecord(ClassStudentExamRecordDTO dto) {
|
||||||
ClassStudentExamRecordDO entity = classStudentExamRecordConvertor.convertDtoToE(dto);
|
ClassStudentExamRecordDO entity = classStudentExamRecordConvertor.convertDtoToE(dto);
|
||||||
InsertFieldDefaults.applyForUpdate(entity);
|
InsertFieldDefaults.applyForUpdate(entity);
|
||||||
|
callbackFillStudent(entity);
|
||||||
return this.updateById(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
|
@Override
|
||||||
public boolean deleteById(Long id) {
|
public boolean deleteById(Long id) {
|
||||||
return baseMapper.deleteById(id) > 0;
|
return baseMapper.deleteById(id) > 0;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,17 @@
|
||||||
package org.qinan.cedu.service.impl;
|
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.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.qinan.cedu.convertor.ClassStudentLearningRecordConvertor;
|
import org.qinan.cedu.convertor.ClassStudentLearningRecordConvertor;
|
||||||
import org.qinan.cedu.enums.DeleteEnum;
|
import org.qinan.cedu.enums.DeleteEnum;
|
||||||
|
import org.qinan.cedu.mapper.ClassCourseMapper;
|
||||||
import org.qinan.cedu.mapper.ClassStudentLearningRecordMapper;
|
import org.qinan.cedu.mapper.ClassStudentLearningRecordMapper;
|
||||||
|
import org.qinan.cedu.mapper.ClassStudentMapper;
|
||||||
import org.qinan.cedu.model.dto.ClassStudentLearningRecordDTO;
|
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.entity.ClassStudentLearningRecordDO;
|
||||||
import org.qinan.cedu.model.query.ClassStudentLearningRecordPageQuery;
|
import org.qinan.cedu.model.query.ClassStudentLearningRecordPageQuery;
|
||||||
import org.qinan.cedu.model.vo.ClassStudentLearningRecordVO;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
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
|
@Autowired
|
||||||
private ClassStudentLearningRecordConvertor classStudentLearningRecordConvertor;
|
private ClassStudentLearningRecordConvertor classStudentLearningRecordConvertor;
|
||||||
|
@Autowired
|
||||||
|
private ClassStudentMapper classStudentMapper;
|
||||||
|
@Autowired
|
||||||
|
private ClassCourseMapper classCourseMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<ClassStudentLearningRecordVO> pageQuery(ClassStudentLearningRecordPageQuery query) {
|
public IPage<ClassStudentLearningRecordVO> pageQuery(ClassStudentLearningRecordPageQuery query) {
|
||||||
|
|
@ -64,7 +77,37 @@ public class ClassStudentLearningRecordServiceImpl extends ServiceImpl<ClassStud
|
||||||
}
|
}
|
||||||
|
|
||||||
public void callbackFillStudent(ClassStudentLearningRecordDO entity) {
|
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)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
|
@ -72,6 +115,7 @@ public class ClassStudentLearningRecordServiceImpl extends ServiceImpl<ClassStud
|
||||||
public boolean updateRecord(ClassStudentLearningRecordDTO dto) {
|
public boolean updateRecord(ClassStudentLearningRecordDTO dto) {
|
||||||
ClassStudentLearningRecordDO entity = classStudentLearningRecordConvertor.convertDtoToE(dto);
|
ClassStudentLearningRecordDO entity = classStudentLearningRecordConvertor.convertDtoToE(dto);
|
||||||
InsertFieldDefaults.applyForUpdate(entity);
|
InsertFieldDefaults.applyForUpdate(entity);
|
||||||
|
callbackFillStudent(entity);
|
||||||
return this.updateById(entity);
|
return this.updateById(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue