修改大铁实训生成bug;生成课程考试时,如果无实训,则不生成课程与考试

This commit is contained in:
joylink_zhangsai 2022-10-08 17:33:35 +08:00
parent 689a6f433a
commit 703dd34635
2 changed files with 10 additions and 68 deletions

View File

@ -601,6 +601,13 @@ public class LessonService implements ILessonService {
private void generateLessonBy(AccountVO accountVO, MapVO mapVO, BusinessConsts.Lesson.PrdInfo prdLessonInfo, String prdType) {
Long mapId = mapVO.getId();
//生成课程的章节
Map<String, Map<String, List<Training>>> trainings = iTrainingV1Service.findEntities(mapId, prdType)
.stream().collect(Collectors.groupingBy(Training::getType, Collectors.groupingBy(Training::getOperateType)));
if (CollectionUtils.isEmpty(trainings)) {
log.warn(String.format("[id:%s]的地图无[%s]类型的实训,不生成课程", mapId, prdType));
return;
}
//课程
LsLesson lesson = new LsLesson();
lesson.setUpdateTime(LocalDateTime.now());
@ -627,18 +634,6 @@ public class LessonService implements ILessonService {
LsLessonChapterExample chapterExample = new LsLessonChapterExample();
chapterExample.createCriteria().andLessonIdEqualTo(lesson.getId());
lessonChapterDAO.deleteByExample(chapterExample);
// ExamDefinitionExample examDefinitionExample = new ExamDefinitionExample();
// examDefinitionExample.createCriteria().andLessonIdEqualTo(existedDefaultLesson.getId());
// List<ExamDefinition> examDefinitions = examDefinitionDAO.selectByExample(examDefinitionExample);
// if (!CollectionUtils.isEmpty(examDefinitions)) {
// List<Long> list = examDefinitions.stream().map(ExamDefinition::getId).collect(Collectors.toList());
// ExamDefinitionRulesExample rulesExample = new ExamDefinitionRulesExample();
// rulesExample.createCriteria().andExamIdIn(list);
// definitionRulesDAO.deleteByExample(rulesExample);
// examDefinitionDAO.deleteByExample(examDefinitionExample);
// }
} else {
lessonDAO.insert(lesson);
}
@ -650,12 +645,8 @@ public class LessonService implements ILessonService {
lessonVersion.setVersion(BusinessConsts.Lesson.Version.originalVersion);
lessonVersionDAO.insert(lessonVersion);
//生成课程的章节
List<Training> examTrainings = new ArrayList<>(20);
int orderNum = 1;
Random random = new Random();
Map<String, Map<String, List<Training>>> trainings = iTrainingV1Service.findEntities(mapId, prdType)
.stream().collect(Collectors.groupingBy(Training::getType, Collectors.groupingBy(Training::getOperateType)));
int orderNum = 1;
for (BusinessConsts.Training.Type type : BusinessConsts.Training.Type.values()) {
Map<String, List<Training>> collect = trainings.get(type.name());
if (CollectionUtils.isEmpty(collect)) continue;
@ -669,7 +660,6 @@ public class LessonService implements ILessonService {
lessonChapterDAO.insert(chapter);
collect.forEach((s, ts) -> {
if (ts.size() == 0) return;
examTrainings.add(ts.get(random.nextInt(ts.size())));
int i = 1;
while (i < 3) {
if (ts.size() == 0) return;
@ -688,54 +678,6 @@ public class LessonService implements ILessonService {
List<ExamDefinition> exams = iExamService.findEntities(lesson.getId());
if (CollectionUtils.isEmpty(exams)) {
iExamService.generateExam(mapId, lesson.getId(), lesson.getPrdType(), lesson.getName(), lesson.getCreatorId());
// //试卷定义
// if (CollectionUtils.isEmpty(examTrainings)) {
// return;
// }
// ExamDefinition examDefinition = new ExamDefinition();
// examDefinition.setMapId(mapId);
// examDefinition.setLessonId(lesson.getId());
// examDefinition.setType(prdType);
// examDefinition.setName(lesson.getName() + "试卷");
// examDefinition.setDuration(1800);
// examDefinition.setCreatorId(accountVO.getId());
// examDefinition.setCreateTime(LocalDateTime.now());
// examDefinition.setRemarks(examDefinition.getName() + "-默认试卷");
// examDefinition.setStatus("1");
// examDefinition.setTrial(true);
// examDefinition.setFullPoint(100);
// examDefinition.setPassingPoint(60);
// examDefinition.setAbnormal(false);
// examDefinition.setSystem(true);
// examDefinitionDAO.insert(examDefinition);
// //试卷规则 取20道题每中实训类型取一道
// if (examTrainings.size() < 20) {
// int m = examTrainings.size();
// int n = (int) Math.ceil(20f / m); //尽量平均地分配题型数量
// int num = 20 + m - m * n; //题数较多的题型的数量
// for (int i = 0; i < m; i++) {
// Training training = examTrainings.get(0);
// ExamDefinitionRules examRules = new ExamDefinitionRules();
// examRules.setExamId(examDefinition.getId());
// examRules.setNum(i < num ? n : n - 1);
// examRules.setPoint(5);
// examRules.setTrainingType(training.getType());
// examRules.setOperateType(training.getOperateType());
// definitionRulesDAO.insert(examRules);
// }
// } else {
// int i = 1;
// do {
// ExamDefinitionRules examRules = new ExamDefinitionRules();
// examRules.setExamId(examDefinition.getId());
// examRules.setNum(1);
// examRules.setPoint(5);
// Training training = examTrainings.remove(random.nextInt(examTrainings.size()));
// examRules.setTrainingType(training.getType());
// examRules.setOperateType(training.getOperateType());
// definitionRulesDAO.insert(examRules);
// } while (i++ < 20);
// }
}
}

View File

@ -131,7 +131,7 @@ public class SignalGeneratorNew implements GeneratorNew {
stepVOList.get(0).setTip(String.format("鼠标左键点击【信号机%s】", route.getStart().getShowName()));
stepVOList.get(1).setTip(String.format("鼠标左键点击【信号机%s】", route.getDestination().getShowName()));
}
trainingVOList.add(this.build(config, simulation, route, mapRouteNewVO, operateDefinitionVO, true));
trainingVOList.add(this.build(config, simulation, route, mapRouteNewVO, operateDefinitionVO, false));
// 仿真重置
this.resetSimulation(simulation);
}
@ -212,7 +212,7 @@ public class SignalGeneratorNew implements GeneratorNew {
continue;
}
deviceStatusModifyTool.openRouteDirect(simulation, route);
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO, true));
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO, false));
// 仿真重置
this.resetSimulation(simulation);
}