考试相关
This commit is contained in:
@@ -43,8 +43,6 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
private UserCourseBuyDao userCourseBuyDao;
|
||||
@Autowired
|
||||
private CourseDao courseDao;
|
||||
@Autowired
|
||||
private CourseCatalogueChapterDao courseCatalogueChapterDao;
|
||||
|
||||
@Override
|
||||
public Page getClassModelList(Map<String, Object> params) {
|
||||
@@ -79,12 +77,12 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean editClassModel(ClassModel classModel) {
|
||||
public R editClassModel(ClassModel classModel) {
|
||||
LambdaQueryWrapper<ClassEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ClassEntity::getModelId,classModel.getId());
|
||||
//模型下有小班,不能编辑
|
||||
if (this.getBaseMapper().selectCount(wrapper)>0){
|
||||
return false;
|
||||
return R.error("模型下有小班,不能编辑");
|
||||
}else {
|
||||
classModelDao.updateById(classModel);
|
||||
//查询出所属课程,先删除,在添加
|
||||
@@ -100,7 +98,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
classCourseDao.insert(classCourse);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,6 +208,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
public R updateClassState(Map<String, Object> params) {
|
||||
String state = params.get("state").toString();
|
||||
ClassEntity classEntity = this.getBaseMapper().selectById(params.get("classId").toString());
|
||||
ClassModel classModel = classModelDao.selectById(classEntity.getModelId());
|
||||
if ("1".equals(state)){
|
||||
//开班校验
|
||||
int monitorCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
@@ -232,17 +231,49 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
if (commentCount<3){
|
||||
return R.error("请先设置3位评分员");
|
||||
}
|
||||
int taskCount = classTaskDao.selectCount(new LambdaQueryWrapper<ClassTask>()
|
||||
.eq(ClassTask::getClassId,classEntity.getId()).eq(ClassTask::getType,"0"));
|
||||
ClassModel classModel = classModelDao.selectById(classEntity.getModelId());
|
||||
if (taskCount<(classModel.getDays()/7.0)){
|
||||
return R.error("请至少发布"+Math.ceil(classModel.getDays()/7.0)+"个任务。");
|
||||
|
||||
if (classModel.getIsTask()==1){
|
||||
int taskCount = classTaskDao.selectCount(new LambdaQueryWrapper<ClassTask>()
|
||||
.eq(ClassTask::getClassId,classEntity.getId()).eq(ClassTask::getType,"0"));
|
||||
if (taskCount<(classModel.getDays()/7.0)){
|
||||
return R.error("请至少发布"+Math.ceil(classModel.getDays()/7.0)+"个任务。");
|
||||
}
|
||||
}
|
||||
|
||||
int studentCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"0"));
|
||||
if (studentCount<classEntity.getNumber()){
|
||||
return R.error("学生人数未满");
|
||||
}
|
||||
|
||||
List<ClassUser> userList = classUserDao.selectList(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"0"));
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (userList.size() > 0) {
|
||||
for (ClassUser classUser:userList){
|
||||
MyUserEntity user = myUserDao.selectById(classUser.getUserId());
|
||||
if ("0".equals(user.getVip())||"3".equals(user.getVip())){
|
||||
//不是vip查询每门课是否购买
|
||||
boolean flag = false;
|
||||
List<ClassCourse> courses = classCourseDao.selectList(new LambdaQueryWrapper<ClassCourse>()
|
||||
.eq(ClassCourse::getModelId,classEntity.getModelId()));
|
||||
for (ClassCourse classCourse:courses){
|
||||
List<UserCourseBuyEntity> ucb = userCourseBuyDao.selectList(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||
.eq(UserCourseBuyEntity::getUserId,classUser.getUserId())
|
||||
.eq(UserCourseBuyEntity::getCourseId,classCourse.getCourseId()));
|
||||
if (ucb.size() == 0){
|
||||
flag = true;
|
||||
CourseEntity c = courseDao.selectById(classCourse.getCourseId());
|
||||
sb.append("用户"+ user.getTel()+"未购买课程"+c.getTitle()+";\n");
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
return R.error(sb.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
classEntity.setState("1");
|
||||
Date startTime = new Date();
|
||||
classEntity.setStartTime(startTime);
|
||||
|
||||
@@ -11,14 +11,8 @@ import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.ClassExamService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@@ -34,86 +28,6 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
|
||||
@Autowired
|
||||
private ClassExamUserDao classExamUserDao;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public String importSubject(MultipartFile file, int courseId) {
|
||||
try (InputStream fis = file.getInputStream()) {
|
||||
Workbook workbook = WorkbookFactory.create(fis);
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
Date date = new Date();
|
||||
// 遍历行
|
||||
for (Row row : sheet) {
|
||||
if (!isRowEmpty(row)){
|
||||
if (row.getRowNum()==0){
|
||||
continue;
|
||||
}
|
||||
ClassExamSubject subject = new ClassExamSubject();
|
||||
subject.setCourseId(courseId);
|
||||
//类型
|
||||
String type = row.getCell(0)==null?"":row.getCell(0).toString();
|
||||
if (type.contains("单选")){
|
||||
subject.setType(0);
|
||||
}else if (type.contains("多选")){
|
||||
subject.setType(1);
|
||||
}else {
|
||||
System.out.println(row.getRowNum()+"此题无题目类型");
|
||||
}
|
||||
//题目
|
||||
subject.setContent(row.getCell(1)==null?"":row.getCell(1).toString());
|
||||
//所属章节
|
||||
subject.setChapter(row.getCell(13)==null?"":row.getCell(13).toString());
|
||||
//音视频序号
|
||||
subject.setMedia(row.getCell(14)==null?"":row.getCell(14).toString());
|
||||
//音视频时间
|
||||
subject.setMediaTime(row.getCell(15)==null?"":row.getCell(15).toString());
|
||||
//出题人
|
||||
subject.setCreateUser(row.getCell(16)==null?"":row.getCell(16).toString());
|
||||
classExamSubjectDao.insert(subject);
|
||||
//选项1-6
|
||||
for (int i=2; i<=7;i++) {
|
||||
if (row.getCell(i)!=null&&!"".equals(row.getCell(i).toString())){
|
||||
ClassExamOption option = new ClassExamOption();
|
||||
option.setSubjectId(subject.getId());
|
||||
String content = row.getCell(i).toString();
|
||||
String raw = row.getCell(8)==null?"":row.getCell(8).toString();
|
||||
if (raw.contains(content.substring(0,1))){
|
||||
option.setRightWrong(1);
|
||||
}else {
|
||||
option.setRightWrong(0);
|
||||
}
|
||||
char[] c = content.toCharArray();
|
||||
if (c.length>1){
|
||||
if (c[1]=='、'||c[1]==':'||c[1]==';'||c[1]==':'||c[1]==';'||c[1]==' '||c[1]=='.'){
|
||||
content = content.substring(2);
|
||||
}else {
|
||||
content = content.substring(1);
|
||||
}
|
||||
}else {
|
||||
content = "";
|
||||
}
|
||||
if (StringUtils.isNotBlank(content)){
|
||||
option.setContent(content);
|
||||
classExamOptionDao.insert(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("结束"+(new Date().getTime()-date.getTime()));
|
||||
} catch (IOException | InvalidFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static boolean isRowEmpty(Row row) {
|
||||
for (Cell cell : row) {
|
||||
if (cell.getCellTypeEnum() != CellType.BLANK) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassExamSubject(ClassExamSubject classExamSubject) {
|
||||
classExamSubjectDao.insert(classExamSubject);
|
||||
|
||||
Reference in New Issue
Block a user