实训生成后原有课程恢复
This commit is contained in:
parent
c61ac54e2b
commit
9360fd5020
@ -50,7 +50,7 @@ public class LessonController {
|
|||||||
@ApiOperation(value = "根据条件获取课程列表")
|
@ApiOperation(value = "根据条件获取课程列表")
|
||||||
@GetMapping(path = "")
|
@GetMapping(path = "")
|
||||||
public List<LessonVO> queryLessons(LessonQueryVO lessonQueryVO) {
|
public List<LessonVO> queryLessons(LessonQueryVO lessonQueryVO) {
|
||||||
return this.iLessonService.queryLessons(lessonQueryVO);
|
return this.iLessonService.queryValidLessons(lessonQueryVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "根据班级获取关联课程列表")
|
@ApiOperation(value = "根据班级获取关联课程列表")
|
||||||
@ -68,7 +68,7 @@ public class LessonController {
|
|||||||
@ApiOperation(value = "获取课程列表")
|
@ApiOperation(value = "获取课程列表")
|
||||||
@GetMapping(path = "/listOfMap")
|
@GetMapping(path = "/listOfMap")
|
||||||
public List<LessonVO> queryLessonsOfMap(Long mapId) {
|
public List<LessonVO> queryLessonsOfMap(Long mapId) {
|
||||||
return this.iLessonService.queryLessonsOfMap(mapId);
|
return this.iLessonService.queryValidLessonsOfMap(mapId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "分页获取已发布的课程")
|
@ApiOperation(value = "分页获取已发布的课程")
|
||||||
|
@ -2,6 +2,7 @@ package club.joylink.rtss.dao;
|
|||||||
|
|
||||||
import club.joylink.rtss.entity.LsRelChapterTraining;
|
import club.joylink.rtss.entity.LsRelChapterTraining;
|
||||||
import club.joylink.rtss.entity.LsRelChapterTrainingExample;
|
import club.joylink.rtss.entity.LsRelChapterTrainingExample;
|
||||||
|
import club.joylink.rtss.vo.client.LessonChapterTrainingRelVO;
|
||||||
import org.apache.ibatis.annotations.Insert;
|
import org.apache.ibatis.annotations.Insert;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
@ -24,4 +25,15 @@ public interface LsRelChapterTrainingDAO extends MyBatisBaseDao<LsRelChapterTrai
|
|||||||
" </foreach>" +
|
" </foreach>" +
|
||||||
"</script>")
|
"</script>")
|
||||||
int batchInsertWithId(@Param("list") List<LsRelChapterTraining> relChapterTrainingList);
|
int batchInsertWithId(@Param("list") List<LsRelChapterTraining> relChapterTrainingList);
|
||||||
|
|
||||||
|
@Insert(value = "<script>" +
|
||||||
|
"insert into ls_rel_chapter_training (lesson_id, chapter_id, training_id, " +
|
||||||
|
" order_num, trial) " +
|
||||||
|
" values " +
|
||||||
|
" <foreach collection=\"list\" item=\"entity\" separator=\",\"> " +
|
||||||
|
" (#{entity.lessonId,jdbcType=BIGINT}, #{entity.chapterId,jdbcType=BIGINT}," +
|
||||||
|
" #{entity.trainingId,jdbcType=BIGINT}, #{entity.orderNum,jdbcType=INTEGER}, #{entity.trial,jdbcType=BIT})"+
|
||||||
|
" </foreach>" +
|
||||||
|
"</script>")
|
||||||
|
int batchInsert(@Param("list") List<LessonChapterTrainingRelVO> relChapterTrainingList);
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ public class ExamService implements IExamService{
|
|||||||
criteria.andLessonIdEqualTo(queryVO.getLessonId());
|
criteria.andLessonIdEqualTo(queryVO.getLessonId());
|
||||||
} else if (Objects.nonNull(queryVO.getMapId())) {
|
} else if (Objects.nonNull(queryVO.getMapId())) {
|
||||||
// 地图id查询
|
// 地图id查询
|
||||||
List<LessonVO> lessonList = this.iLessonService.queryLessonsOfMap(queryVO.getMapId());
|
List<LessonVO> lessonList = this.iLessonService.queryValidLessonsOfMap(queryVO.getMapId());
|
||||||
if (!CollectionUtils.isEmpty(lessonList)) {
|
if (!CollectionUtils.isEmpty(lessonList)) {
|
||||||
List<Long> lessonIdList = lessonList.stream()
|
List<Long> lessonIdList = lessonList.stream()
|
||||||
.map(LessonVO::getId)
|
.map(LessonVO::getId)
|
||||||
|
@ -27,8 +27,9 @@ public interface ILessonDraftService {
|
|||||||
/**
|
/**
|
||||||
* 创建课程
|
* 创建课程
|
||||||
* @param lessonVo
|
* @param lessonVo
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
void createLesson(LessonVO lessonVo, UserVO userVO);
|
Long createLesson(LessonVO lessonVo, UserVO userVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从发布课程创建
|
* 从发布课程创建
|
||||||
|
@ -17,10 +17,6 @@ public interface ILessonService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取课程树
|
* 获取课程树
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @param userVO
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
LessonTreeVO getLessonTree(Long id, UserVO userVO);
|
LessonTreeVO getLessonTree(Long id, UserVO userVO);
|
||||||
|
|
||||||
@ -32,6 +28,11 @@ public interface ILessonService {
|
|||||||
*/
|
*/
|
||||||
LessonVO getLessonDetail(Long id, UserVO userVO);
|
LessonVO getLessonDetail(Long id, UserVO userVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询地图下的课程、章节、章节和实训的关联关系
|
||||||
|
*/
|
||||||
|
List<LessonVO> queryLessonDetail(Long mapId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取课程详细信息
|
* 获取课程详细信息
|
||||||
* @param id
|
* @param id
|
||||||
@ -42,11 +43,15 @@ public interface ILessonService {
|
|||||||
LessonVO findByMapAndNameAndPrdType(Long mapId, String name, String prdType);
|
LessonVO findByMapAndNameAndPrdType(Long mapId, String name, String prdType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询课程列表
|
* 查询有效的课程列表
|
||||||
* @param lessonQueryVO
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
List<LessonVO> queryLessons(LessonQueryVO lessonQueryVO);
|
List<LessonVO> queryValidLessons(LessonQueryVO lessonQueryVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询课程列表(无视状态)
|
||||||
|
* @param mapId
|
||||||
|
*/
|
||||||
|
List<LessonVO> queryLessons(Long mapId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新所属城市
|
* 更新所属城市
|
||||||
@ -121,7 +126,10 @@ public interface ILessonService {
|
|||||||
|
|
||||||
Map<Long, Long> copy(Long sourceMapId, Long targetMapId, Map<Long, Long> trainingRelMap, UserVO user);
|
Map<Long, Long> copy(Long sourceMapId, Long targetMapId, Map<Long, Long> trainingRelMap, UserVO user);
|
||||||
|
|
||||||
List<LessonVO> queryLessonsOfMap(Long mapId);
|
/**
|
||||||
|
* 查询地图下有效的课程
|
||||||
|
*/
|
||||||
|
List<LessonVO> queryValidLessonsOfMap(Long mapId);
|
||||||
|
|
||||||
List<LessonVO> findByMapIdAndPrdType(Long mapId, String prdType);
|
List<LessonVO> findByMapIdAndPrdType(Long mapId, String prdType);
|
||||||
|
|
||||||
@ -142,4 +150,10 @@ public interface ILessonService {
|
|||||||
* 获取有效的课程
|
* 获取有效的课程
|
||||||
*/
|
*/
|
||||||
List<LessonVO> getValidLesson(List<Long> ids, String prdType);
|
List<LessonVO> getValidLesson(List<Long> ids, String prdType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除并添加章节-实训关联关系
|
||||||
|
* @param relVOS
|
||||||
|
*/
|
||||||
|
void addChapterTrainingRelAfterDelete(List<LessonChapterTrainingRelVO> relVOS);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import club.joylink.rtss.entity.LsDraftLessonChapterExample.Criteria;
|
|||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.vo.UserVO;
|
import club.joylink.rtss.vo.UserVO;
|
||||||
import club.joylink.rtss.vo.client.*;
|
import club.joylink.rtss.vo.client.*;
|
||||||
import club.joylink.rtss.vo.client.map.MapVO;
|
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -87,12 +86,13 @@ public class LessonDraftService implements ILessonDraftService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void createLesson(LessonVO lessonVo, UserVO userVO) {
|
public Long createLesson(LessonVO lessonVo, UserVO userVO) {
|
||||||
LsDraftLesson lesson = lessonVo.convert2Draft();
|
LsDraftLesson lesson = lessonVo.convert2Draft();
|
||||||
lesson.setUpdateTime(LocalDateTime.now());
|
lesson.setUpdateTime(LocalDateTime.now());
|
||||||
lesson.setCreatorId(userVO.getId());
|
lesson.setCreatorId(userVO.getId());
|
||||||
lesson.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_01);
|
lesson.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_01);
|
||||||
this.lsDraftLessonDAO.insert(lesson);
|
this.lsDraftLessonDAO.insert(lesson);
|
||||||
|
return lesson.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -532,4 +532,5 @@ public class LessonDraftService implements ILessonDraftService {
|
|||||||
example.createCriteria().andTrainingIdIn(trainingIdList);
|
example.createCriteria().andTrainingIdIn(trainingIdList);
|
||||||
this.draftRelChapterTrainingDAO.deleteByExample(example);
|
this.draftRelChapterTrainingDAO.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,6 +147,39 @@ public class LessonService implements ILessonService {
|
|||||||
return lessonVo;
|
return lessonVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LessonVO> queryLessonDetail(Long mapId) {
|
||||||
|
//查询课程
|
||||||
|
List<LsLesson> lessons = findLessonEntities(mapId);
|
||||||
|
List<LessonVO> lessonVOS = LessonVO.convert2PublishVO(lessons);
|
||||||
|
if (!CollectionUtils.isEmpty(lessons)) {
|
||||||
|
Map<Long, LessonVO> lessonVOMap = lessonVOS.stream().collect(Collectors.toMap(LessonVO::getId, Function.identity()));
|
||||||
|
//查询章节
|
||||||
|
List<Long> lessonIds = lessons.stream().map(LsLesson::getId).collect(Collectors.toList());
|
||||||
|
List<LsLessonChapter> chapters = findChapterEntities(lessonIds);
|
||||||
|
if (!CollectionUtils.isEmpty(chapters)) {
|
||||||
|
List<LessonChapterVO> chapterVOS = LessonChapterVO.convert2PublishVO(chapters);
|
||||||
|
Map<Long, List<LessonChapterVO>> groupByLessonIdChapterMap = chapterVOS.stream().collect(Collectors.groupingBy(LessonChapterVO::getLessonId));
|
||||||
|
groupByLessonIdChapterMap.forEach((lessonId, chapterList) -> {
|
||||||
|
LessonVO lessonVO = lessonVOMap.get(lessonId);
|
||||||
|
if (lessonVO != null)
|
||||||
|
lessonVO.setChapters(chapterList);
|
||||||
|
});
|
||||||
|
//查询章节和实训的关联关系
|
||||||
|
List<Long> chapterIds = chapters.stream().map(LsLessonChapter::getId).collect(Collectors.toList());
|
||||||
|
List<LsRelChapterTraining> rels = findChapterTrainingRelEntities(chapterIds);
|
||||||
|
List<LessonChapterTrainingRelVO> relVOS = LessonChapterTrainingRelVO.convert2VOList(rels);
|
||||||
|
Map<Long, List<LessonChapterTrainingRelVO>> groupByLessonIdRelVOMap = relVOS.stream().collect(Collectors.groupingBy(LessonChapterTrainingRelVO::getLessonId));
|
||||||
|
groupByLessonIdRelVOMap.forEach((lessonId, relList) -> {
|
||||||
|
LessonVO lessonVO = lessonVOMap.get(lessonId);
|
||||||
|
if (lessonVO != null)
|
||||||
|
lessonVO.setRel(relList);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lessonVOS;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LessonVO getLessonInfo(Long id) {
|
public LessonVO getLessonInfo(Long id) {
|
||||||
LsLesson lesson = this.lessonDAO.selectByPrimaryKey(id);
|
LsLesson lesson = this.lessonDAO.selectByPrimaryKey(id);
|
||||||
@ -194,7 +228,7 @@ public class LessonService implements ILessonService {
|
|||||||
} else {
|
} else {
|
||||||
addRelLessonClass(publishVO, publishedLesson.getId());
|
addRelLessonClass(publishVO, publishedLesson.getId());
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
if (!CollectionUtils.isEmpty(studentRelLessonClasses)) {
|
if (!CollectionUtils.isEmpty(studentRelLessonClasses)) {
|
||||||
this.studentRelLessonClassDAO.deleteByExample(relLessonClassExample);
|
this.studentRelLessonClassDAO.deleteByExample(relLessonClassExample);
|
||||||
}
|
}
|
||||||
@ -208,28 +242,6 @@ public class LessonService implements ILessonService {
|
|||||||
this.saveChapterDetail(newLesson, lessonVo);
|
this.saveChapterDetail(newLesson, lessonVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加课程班级关系
|
|
||||||
*/
|
|
||||||
private void addRelLessonClass(LessonPublishVO publishVO, Long id) {
|
|
||||||
publishVO.getClassIdList().forEach(classId -> {
|
|
||||||
StudentRelLessonClass relLessonClass = new StudentRelLessonClass();
|
|
||||||
relLessonClass.setClassId(classId);
|
|
||||||
relLessonClass.setLessonId(id);
|
|
||||||
this.studentRelLessonClassDAO.insert(relLessonClass);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private LessonVO findByMapAndName(Long mapId, String name) {
|
|
||||||
LsLessonExample lessonExample = new LsLessonExample();
|
|
||||||
lessonExample.createCriteria().andMapIdEqualTo(mapId).andNameEqualTo(name);
|
|
||||||
List<LsLesson> lessonList = this.lessonDAO.selectByExample(lessonExample);
|
|
||||||
if (CollectionUtils.isEmpty(lessonList)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new LessonVO(lessonList.get(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LessonVO findByMapAndNameAndPrdType(Long mapId, String name, String prdType) {
|
public LessonVO findByMapAndNameAndPrdType(Long mapId, String name, String prdType) {
|
||||||
LsLessonExample lessonExample = new LsLessonExample();
|
LsLessonExample lessonExample = new LsLessonExample();
|
||||||
@ -241,97 +253,8 @@ public class LessonService implements ILessonService {
|
|||||||
return new LessonVO(lessonList.get(0));
|
return new LessonVO(lessonList.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存课程章节及章节关联的实训信息
|
|
||||||
*/
|
|
||||||
private void saveChapterDetail(LsLesson newLesson, LessonVO lessonVo) {
|
|
||||||
// 清除关系表
|
|
||||||
LsRelChapterTrainingExample relExample = new LsRelChapterTrainingExample();
|
|
||||||
relExample.createCriteria().andLessonIdEqualTo(newLesson.getId());
|
|
||||||
this.relChapterTrainingDAO.deleteByExample(relExample);
|
|
||||||
// 清空章节信息
|
|
||||||
LsLessonChapterExample example = new LsLessonChapterExample();
|
|
||||||
example.createCriteria().andLessonIdEqualTo(newLesson.getId());
|
|
||||||
this.lessonChapterDAO.deleteByExample(example);
|
|
||||||
// 保存
|
|
||||||
Map<Long, Long> idChangedMap = new HashMap<>();
|
|
||||||
this.saveChaptersInfo(newLesson, lessonVo.getChapters(), idChangedMap);
|
|
||||||
this.saveRelChapterTraining(newLesson, lessonVo.getRel(), idChangedMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存课程章节信息
|
|
||||||
*/
|
|
||||||
private void saveChaptersInfo(LsLesson newLesson, List<LessonChapterVO> chapterVos, Map<Long, Long> idChangedMap) {
|
|
||||||
List<LsLessonChapter> chapters = LessonChapterVO.convert2PublishDB(chapterVos).stream()
|
|
||||||
.sorted(Comparator.comparing(LsLessonChapter::getParentId)).collect(Collectors.toList());
|
|
||||||
if (!CollectionUtils.isEmpty(chapters)) {
|
|
||||||
chapters.forEach(chapter -> {
|
|
||||||
Long oldId = chapter.getId();
|
|
||||||
chapter.setLessonId(newLesson.getId());
|
|
||||||
if (chapter.getParentId() != 0) {
|
|
||||||
chapter.setParentId(idChangedMap.get(chapter.getParentId()));
|
|
||||||
}
|
|
||||||
this.lessonChapterDAO.insert(chapter);
|
|
||||||
idChangedMap.put(oldId, chapter.getId());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存章节-实训 关联数据
|
|
||||||
*/
|
|
||||||
private void saveRelChapterTraining(LsLesson newLesson, List<LessonChapterTrainingRelVO> relVos, Map<Long, Long> idChangedMap) {
|
|
||||||
List<LsRelChapterTraining> relList = LessonChapterTrainingRelVO.convert2PublishDB(relVos);
|
|
||||||
if (!CollectionUtils.isEmpty(relList)) {
|
|
||||||
relList.forEach(rel -> {
|
|
||||||
rel.setLessonId(newLesson.getId());
|
|
||||||
rel.setChapterId(idChangedMap.get(rel.getChapterId()));
|
|
||||||
this.relChapterTrainingDAO.insert(rel);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建并插入课程版本信息
|
|
||||||
*/
|
|
||||||
private void buildAndInsertLessonVersion(LsLesson lesson) {
|
|
||||||
LsLessonVersion latest = this.getLatestLessonVersion(lesson.getId());
|
|
||||||
String version = null == latest ? null : latest.getVersion();
|
|
||||||
LsLessonVersion newVersion = buildVersion(lesson, version);
|
|
||||||
this.lessonVersionDAO.insert(newVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建新的版本信息
|
|
||||||
*/
|
|
||||||
private LsLessonVersion buildVersion(LsLesson lesson, String old) {
|
|
||||||
String version = VersionUtil.generateNext(old);
|
|
||||||
LsLessonVersion lessonVersion = new LsLessonVersion();
|
|
||||||
lessonVersion.setLessonId(lesson.getId());
|
|
||||||
lessonVersion.setCreatorId(lesson.getCreatorId());
|
|
||||||
lessonVersion.setUpdateTime(lesson.getUpdateTime());
|
|
||||||
lessonVersion.setVersion(version);
|
|
||||||
return lessonVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取最新的课程版本信息
|
|
||||||
*/
|
|
||||||
private LsLessonVersion getLatestLessonVersion(Long lessonId) {
|
|
||||||
LsLessonVersionExample example = new LsLessonVersionExample();
|
|
||||||
example.createCriteria().andLessonIdEqualTo(lessonId);
|
|
||||||
example.setOrderByClause("update_time desc");
|
|
||||||
List<LsLessonVersion> list = this.lessonVersionDAO.selectByExample(example);
|
|
||||||
if (CollectionUtils.isEmpty(list)) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return list.get(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LessonVO> queryLessons(LessonQueryVO lessonQueryVO) {
|
public List<LessonVO> queryValidLessons(LessonQueryVO lessonQueryVO) {
|
||||||
LsLessonExample example = new LsLessonExample();
|
LsLessonExample example = new LsLessonExample();
|
||||||
example.setOrderByClause("id desc");
|
example.setOrderByClause("id desc");
|
||||||
Criteria criteria = example.createCriteria()
|
Criteria criteria = example.createCriteria()
|
||||||
@ -343,6 +266,15 @@ public class LessonService implements ILessonService {
|
|||||||
return LessonVO.convert2PublishVO(list);
|
return LessonVO.convert2PublishVO(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LessonVO> queryLessons(@NonNull Long mapId) {
|
||||||
|
LsLessonExample example = new LsLessonExample();
|
||||||
|
example.setOrderByClause("id desc");
|
||||||
|
example.createCriteria().andMapIdEqualTo(mapId);
|
||||||
|
List<LsLesson> list = this.lessonDAO.selectByExample(example);
|
||||||
|
return LessonVO.convert2PublishVO(list);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateCity(Long mapId) {
|
public void updateCity(Long mapId) {
|
||||||
MapVO mapVO = this.iMapService.getMapInfoById(mapId);
|
MapVO mapVO = this.iMapService.getMapInfoById(mapId);
|
||||||
@ -502,7 +434,7 @@ public class LessonService implements ILessonService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public Map<Long, Long> copy(Long sourceMapId, Long targetMapId, Map<Long, Long> trainingRelMap, UserVO user) {
|
public Map<Long, Long> copy(Long sourceMapId, Long targetMapId, Map<Long, Long> trainingRelMap, UserVO user) {
|
||||||
|
|
||||||
List<LsLesson> lessonList = findEntityByMapId(sourceMapId);
|
List<LsLesson> lessonList = findLessonEntities(sourceMapId);
|
||||||
Map<Long, Long> relationMap = new HashMap<>();
|
Map<Long, Long> relationMap = new HashMap<>();
|
||||||
if (CollectionUtils.isEmpty(lessonList)) {
|
if (CollectionUtils.isEmpty(lessonList)) {
|
||||||
return relationMap;
|
return relationMap;
|
||||||
@ -546,14 +478,8 @@ public class LessonService implements ILessonService {
|
|||||||
return relationMap;
|
return relationMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<LsLesson> findEntityByMapId(Long mapId) {
|
|
||||||
LsLessonExample example = new LsLessonExample();
|
|
||||||
example.createCriteria().andMapIdEqualTo(mapId);
|
|
||||||
return lessonDAO.selectByExample(example);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LessonVO> queryLessonsOfMap(Long mapId) {
|
public List<LessonVO> queryValidLessonsOfMap(Long mapId) {
|
||||||
LsLessonExample example = new LsLessonExample();
|
LsLessonExample example = new LsLessonExample();
|
||||||
example.createCriteria()
|
example.createCriteria()
|
||||||
.andMapIdEqualTo(mapId)
|
.andMapIdEqualTo(mapId)
|
||||||
@ -611,6 +537,17 @@ public class LessonService implements ILessonService {
|
|||||||
return lessonDAO.getValidLesson(ids, prdType);
|
return lessonDAO.getValidLesson(ids, prdType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addChapterTrainingRelAfterDelete(List<LessonChapterTrainingRelVO> relVOS) {
|
||||||
|
//删除旧数据
|
||||||
|
List<Long> ids = relVOS.stream().map(LessonChapterTrainingRelVO::getTrainingId).collect(Collectors.toList());
|
||||||
|
LsRelChapterTrainingExample example = new LsRelChapterTrainingExample();
|
||||||
|
example.createCriteria().andIdIn(ids);
|
||||||
|
relChapterTrainingDAO.deleteByExample(example);
|
||||||
|
//添加新数据
|
||||||
|
relChapterTrainingDAO.batchInsert(relVOS);
|
||||||
|
}
|
||||||
|
|
||||||
private void generateLessonBy(UserVO userVO, MapVO mapVO, BusinessConsts.Lesson.PrdInfo prdLessonInfo, String prdType) {
|
private void generateLessonBy(UserVO userVO, MapVO mapVO, BusinessConsts.Lesson.PrdInfo prdLessonInfo, String prdType) {
|
||||||
//课程
|
//课程
|
||||||
LsLesson lesson = new LsLesson();
|
LsLesson lesson = new LsLesson();
|
||||||
@ -742,4 +679,138 @@ public class LessonService implements ILessonService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存课程章节及章节关联的实训信息
|
||||||
|
*/
|
||||||
|
private void saveChapterDetail(LsLesson newLesson, LessonVO lessonVo) {
|
||||||
|
// 清除关系表
|
||||||
|
LsRelChapterTrainingExample relExample = new LsRelChapterTrainingExample();
|
||||||
|
relExample.createCriteria().andLessonIdEqualTo(newLesson.getId());
|
||||||
|
this.relChapterTrainingDAO.deleteByExample(relExample);
|
||||||
|
// 清空章节信息
|
||||||
|
LsLessonChapterExample example = new LsLessonChapterExample();
|
||||||
|
example.createCriteria().andLessonIdEqualTo(newLesson.getId());
|
||||||
|
this.lessonChapterDAO.deleteByExample(example);
|
||||||
|
// 保存
|
||||||
|
Map<Long, Long> idChangedMap = new HashMap<>();
|
||||||
|
this.saveChaptersInfo(newLesson, lessonVo.getChapters(), idChangedMap);
|
||||||
|
this.saveRelChapterTraining(newLesson, lessonVo.getRel(), idChangedMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存课程章节信息
|
||||||
|
*/
|
||||||
|
private void saveChaptersInfo(LsLesson newLesson, List<LessonChapterVO> chapterVos, Map<Long, Long> idChangedMap) {
|
||||||
|
List<LsLessonChapter> chapters = LessonChapterVO.convert2PublishDB(chapterVos).stream()
|
||||||
|
.sorted(Comparator.comparing(LsLessonChapter::getParentId)).collect(Collectors.toList());
|
||||||
|
if (!CollectionUtils.isEmpty(chapters)) {
|
||||||
|
chapters.forEach(chapter -> {
|
||||||
|
Long oldId = chapter.getId();
|
||||||
|
chapter.setLessonId(newLesson.getId());
|
||||||
|
if (chapter.getParentId() != 0) {
|
||||||
|
chapter.setParentId(idChangedMap.get(chapter.getParentId()));
|
||||||
|
}
|
||||||
|
this.lessonChapterDAO.insert(chapter);
|
||||||
|
idChangedMap.put(oldId, chapter.getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存章节-实训 关联数据
|
||||||
|
*/
|
||||||
|
private void saveRelChapterTraining(LsLesson newLesson, List<LessonChapterTrainingRelVO> relVos, Map<Long, Long> idChangedMap) {
|
||||||
|
List<LsRelChapterTraining> relList = LessonChapterTrainingRelVO.convert2PublishDB(relVos);
|
||||||
|
if (!CollectionUtils.isEmpty(relList)) {
|
||||||
|
relList.forEach(rel -> {
|
||||||
|
rel.setLessonId(newLesson.getId());
|
||||||
|
rel.setChapterId(idChangedMap.get(rel.getChapterId()));
|
||||||
|
this.relChapterTrainingDAO.insert(rel);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建并插入课程版本信息
|
||||||
|
*/
|
||||||
|
private void buildAndInsertLessonVersion(LsLesson lesson) {
|
||||||
|
LsLessonVersion latest = this.getLatestLessonVersion(lesson.getId());
|
||||||
|
String version = null == latest ? null : latest.getVersion();
|
||||||
|
LsLessonVersion newVersion = buildVersion(lesson, version);
|
||||||
|
this.lessonVersionDAO.insert(newVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建新的版本信息
|
||||||
|
*/
|
||||||
|
private LsLessonVersion buildVersion(LsLesson lesson, String old) {
|
||||||
|
String version = VersionUtil.generateNext(old);
|
||||||
|
LsLessonVersion lessonVersion = new LsLessonVersion();
|
||||||
|
lessonVersion.setLessonId(lesson.getId());
|
||||||
|
lessonVersion.setCreatorId(lesson.getCreatorId());
|
||||||
|
lessonVersion.setUpdateTime(lesson.getUpdateTime());
|
||||||
|
lessonVersion.setVersion(version);
|
||||||
|
return lessonVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最新的课程版本信息
|
||||||
|
*/
|
||||||
|
private LsLessonVersion getLatestLessonVersion(Long lessonId) {
|
||||||
|
LsLessonVersionExample example = new LsLessonVersionExample();
|
||||||
|
example.createCriteria().andLessonIdEqualTo(lessonId);
|
||||||
|
example.setOrderByClause("update_time desc");
|
||||||
|
List<LsLessonVersion> list = this.lessonVersionDAO.selectByExample(example);
|
||||||
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return list.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加课程班级关系
|
||||||
|
*/
|
||||||
|
private void addRelLessonClass(LessonPublishVO publishVO, Long id) {
|
||||||
|
publishVO.getClassIdList().forEach(classId -> {
|
||||||
|
StudentRelLessonClass relLessonClass = new StudentRelLessonClass();
|
||||||
|
relLessonClass.setClassId(classId);
|
||||||
|
relLessonClass.setLessonId(id);
|
||||||
|
this.studentRelLessonClassDAO.insert(relLessonClass);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private LessonVO findByMapAndName(Long mapId, String name) {
|
||||||
|
LsLessonExample lessonExample = new LsLessonExample();
|
||||||
|
lessonExample.createCriteria().andMapIdEqualTo(mapId).andNameEqualTo(name);
|
||||||
|
List<LsLesson> lessonList = this.lessonDAO.selectByExample(lessonExample);
|
||||||
|
if (CollectionUtils.isEmpty(lessonList)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new LessonVO(lessonList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<LsLesson> findLessonEntities(@NonNull Long mapId) {
|
||||||
|
LsLessonExample example = new LsLessonExample();
|
||||||
|
example.createCriteria().andMapIdEqualTo(mapId);
|
||||||
|
return lessonDAO.selectByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<LsLessonChapter> findChapterEntities(@NonNull List<Long> lessonIds) {
|
||||||
|
if (CollectionUtils.isEmpty(lessonIds))
|
||||||
|
return new ArrayList<>();
|
||||||
|
LsLessonChapterExample example = new LsLessonChapterExample();
|
||||||
|
example.createCriteria().andLessonIdIn(lessonIds);
|
||||||
|
return lessonChapterDAO.selectByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<LsRelChapterTraining> findChapterTrainingRelEntities(@NonNull List<Long> chapterIds) {
|
||||||
|
if (CollectionUtils.isEmpty(chapterIds))
|
||||||
|
return new ArrayList<>();
|
||||||
|
LsRelChapterTrainingExample example = new LsRelChapterTrainingExample();
|
||||||
|
example.createCriteria().andChapterIdIn(chapterIds);
|
||||||
|
return relChapterTrainingDAO.selectByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class UserUsageStatsService implements IUserUsageStatsService {
|
|||||||
}
|
}
|
||||||
usageTotalStatsVO.setTrainingUserCount(0L);
|
usageTotalStatsVO.setTrainingUserCount(0L);
|
||||||
usageTotalStatsVO.setTrainingTime(0L);
|
usageTotalStatsVO.setTrainingTime(0L);
|
||||||
List<LessonVO> lessonVOList = iLessonService.queryLessonsOfMap(mapVO.getId());
|
List<LessonVO> lessonVOList = iLessonService.queryValidLessonsOfMap(mapVO.getId());
|
||||||
List<Long> lessonIds = lessonVOList.stream().map(LessonVO::getId).collect(Collectors.toList());
|
List<Long> lessonIds = lessonVOList.stream().map(LessonVO::getId).collect(Collectors.toList());
|
||||||
if (!CollectionUtils.isEmpty(lessonIds)) {
|
if (!CollectionUtils.isEmpty(lessonIds)) {
|
||||||
UserTrainingStatsExample userTrainingStatsExample = new UserTrainingStatsExample();
|
UserTrainingStatsExample userTrainingStatsExample = new UserTrainingStatsExample();
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package club.joylink.rtss.services.training;
|
package club.joylink.rtss.services.training;
|
||||||
|
|
||||||
import club.joylink.rtss.constants.MapPrdTypeEnum;
|
import club.joylink.rtss.constants.MapPrdTypeEnum;
|
||||||
import club.joylink.rtss.services.ICommandService;
|
import club.joylink.rtss.entity.Training;
|
||||||
import club.joylink.rtss.services.IMapService;
|
import club.joylink.rtss.services.*;
|
||||||
import club.joylink.rtss.services.IOperateService;
|
|
||||||
import club.joylink.rtss.services.IRunPlanTemplateService;
|
|
||||||
import club.joylink.rtss.services.training.data.GenerateConfig;
|
import club.joylink.rtss.services.training.data.GenerateConfig;
|
||||||
import club.joylink.rtss.services.training.generatornew.GeneratorFactoryNew;
|
import club.joylink.rtss.services.training.generatornew.GeneratorFactoryNew;
|
||||||
import club.joylink.rtss.services.training.generatornew.GeneratorNew;
|
import club.joylink.rtss.services.training.generatornew.GeneratorNew;
|
||||||
@ -12,6 +10,8 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
|
|||||||
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
|
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
|
||||||
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
|
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
|
||||||
import club.joylink.rtss.vo.client.CommandDefinitionVO;
|
import club.joylink.rtss.vo.client.CommandDefinitionVO;
|
||||||
|
import club.joylink.rtss.vo.client.LessonChapterTrainingRelVO;
|
||||||
|
import club.joylink.rtss.vo.client.LessonVO;
|
||||||
import club.joylink.rtss.vo.client.OperateDefinitionVO;
|
import club.joylink.rtss.vo.client.OperateDefinitionVO;
|
||||||
import club.joylink.rtss.vo.client.map.MapVO;
|
import club.joylink.rtss.vo.client.map.MapVO;
|
||||||
import club.joylink.rtss.vo.client.runplan.RunPlanVO;
|
import club.joylink.rtss.vo.client.runplan.RunPlanVO;
|
||||||
@ -26,6 +26,7 @@ import org.springframework.util.CollectionUtils;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -52,11 +53,17 @@ public class GenerateTask {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ICommandService iCommandService;
|
private ICommandService iCommandService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ILessonService iLessonService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ILessonDraftService iLessonDraftService;
|
||||||
|
|
||||||
private List<String> generateNew(GenerateConfig config, MapVO mapVO, Simulation simulation) {
|
private List<String> generateNew(GenerateConfig config, MapVO mapVO, Simulation simulation) {
|
||||||
// 查询生成规则
|
// 查询生成规则
|
||||||
GeneratorNew generator = this.generatorFactoryNew.getGenerator(config.getTrainingType());
|
GeneratorNew generator = this.generatorFactoryNew.getGenerator(config.getTrainingType());
|
||||||
if (Objects.isNull(generator)) {
|
if (Objects.isNull(generator)) {
|
||||||
log.warn("无对应实训类型[{}]的规则生成器",config.getTrainingType());
|
log.warn("无对应实训类型[{}]的规则生成器", config.getTrainingType());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
@ -79,7 +86,7 @@ public class GenerateTask {
|
|||||||
this.iTrainingV1Service.batchSaveAutoGenerateTrainings(trainingVOList);
|
this.iTrainingV1Service.batchSaveAutoGenerateTrainings(trainingVOList);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(MapPrdTypeEnum.getMapPrdTypeEnumByCode(config.getPrdType()) + ":" + operateType + " 生成失败", e);
|
log.error(MapPrdTypeEnum.getMapPrdTypeEnumByCode(config.getPrdType()) + ":" + operateType + " 生成失败", e);
|
||||||
results.add(MapPrdTypeEnum.getMapPrdTypeEnumByCode(config.getPrdType()) + ":" +operateType + " 生成失败");
|
results.add(MapPrdTypeEnum.getMapPrdTypeEnumByCode(config.getPrdType()) + ":" + operateType + " 生成失败");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -106,18 +113,17 @@ public class GenerateTask {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量更新自动生成实训的用时/说明
|
* 批量更新自动生成实训的用时/说明
|
||||||
*
|
|
||||||
* @param config
|
|
||||||
*/
|
*/
|
||||||
public void batchUpdateGenerateTraining(GenerateConfig config) {
|
public void batchUpdateGenerateTraining(GenerateConfig config) {
|
||||||
this.iTrainingV1Service.batchUpdateGenerateTraining(config);
|
this.iTrainingV1Service.batchUpdateGenerateTraining(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**生成新地图实训,只能在一键生成接口调用*/
|
/**
|
||||||
|
* 生成新地图实训,只能在一键生成接口调用
|
||||||
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public String generateNewTrainings(Long mapId, MapVO mapVO) {
|
public String generateNewTrainings(Long mapId, MapVO mapVO) {
|
||||||
log.warn("generate training start...[{}]", LocalTime.now());
|
log.warn("generate training start...[{}]", LocalTime.now());
|
||||||
try{
|
|
||||||
// 查询通用运行图
|
// 查询通用运行图
|
||||||
RunPlanVO planVO = this.iRunPlanTemplateService.getFirstRunPlanByMapId(mapVO.getId());
|
RunPlanVO planVO = this.iRunPlanTemplateService.getFirstRunPlanByMapId(mapVO.getId());
|
||||||
this.delete(mapId);
|
this.delete(mapId);
|
||||||
@ -141,7 +147,7 @@ public class GenerateTask {
|
|||||||
groupByOperationObject.forEach((o, cdo) -> {
|
groupByOperationObject.forEach((o, cdo) -> {
|
||||||
config.setTrainingType(o);
|
config.setTrainingType(o);
|
||||||
config.setOperateType(cdo.stream().map(cd -> cd.getOperate()).collect(Collectors.toList()));
|
config.setOperateType(cdo.stream().map(cd -> cd.getOperate()).collect(Collectors.toList()));
|
||||||
List<String> list =this.generateNew(config, mapVO,simulation);
|
List<String> list = this.generateNew(config, mapVO, simulation);
|
||||||
if (!CollectionUtils.isEmpty(list)) {
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
results.addAll(list);
|
results.addAll(list);
|
||||||
}
|
}
|
||||||
@ -149,20 +155,82 @@ public class GenerateTask {
|
|||||||
});
|
});
|
||||||
log.warn("generate training end...[{}]", LocalTime.now());
|
log.warn("generate training end...[{}]", LocalTime.now());
|
||||||
return CollectionUtils.isEmpty(results) ? "成功" : String.join(",", results);
|
return CollectionUtils.isEmpty(results) ? "成功" : String.join(",", results);
|
||||||
}finally {
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
@Transactional
|
||||||
|
public String generateTrainings(Long mapId) {
|
||||||
|
try {
|
||||||
|
Objects.requireNonNull(mapId, "地图id不能为空");
|
||||||
|
//获取地图下章节和实训的关联关系,记录章节下关联的实训的类型和数量
|
||||||
|
List<LessonVO> lessonVOS = iLessonService.queryLessonDetail(mapId);
|
||||||
|
List<LessonChapterTrainingRelVO> rels = lessonVOS.stream().flatMap(lessonVO -> {
|
||||||
|
List<LessonChapterTrainingRelVO> rel = lessonVO.getRel();
|
||||||
|
if (rel == null)
|
||||||
|
return null;
|
||||||
|
// rel = new ArrayList<>();
|
||||||
|
return rel.stream();
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
lessonVOS = null;
|
||||||
|
Map<Long, Training> trainingMap = iTrainingV1Service.findEntities(mapId)
|
||||||
|
.stream().collect(Collectors.toMap(Training::getId, Function.identity()));
|
||||||
|
Map<LessonChapterTrainingRelVO, Training> chapterTrainingRelMap = new HashMap<>();
|
||||||
|
for (LessonChapterTrainingRelVO rel : rels) {
|
||||||
|
Training training = trainingMap.get(rel.getTrainingId());
|
||||||
|
chapterTrainingRelMap.put(rel, training);
|
||||||
|
}
|
||||||
|
trainingMap = null;
|
||||||
|
rels = null;
|
||||||
|
Map<Long, Map<String, Map<String, Map<String, List<Map.Entry<LessonChapterTrainingRelVO, Training>>>>>> oldRelMap
|
||||||
|
= chapterTrainingRelMap.entrySet().stream().collect(
|
||||||
|
Collectors.groupingBy(entry -> entry.getKey().getChapterId(),
|
||||||
|
Collectors.groupingBy(entry -> entry.getValue().getPrdType(),
|
||||||
|
Collectors.groupingBy(entry -> entry.getValue().getType(),
|
||||||
|
Collectors.groupingBy(entry -> entry.getValue().getOperateType())))));
|
||||||
|
chapterTrainingRelMap = null;
|
||||||
|
//生成实训
|
||||||
|
MapVO mapVO = iMapService.getMapDetail(mapId);
|
||||||
|
String result = generateNewTrainings(mapId, mapVO);
|
||||||
|
//根据上面的记录结果重建章节-实训关联关系
|
||||||
|
Map<String, Map<String, Map<String, List<Training>>>> newTrainingMap = iTrainingV1Service.findEntities(mapId)
|
||||||
|
.stream().collect(Collectors.groupingBy(Training::getPrdType, Collectors.groupingBy(Training::getType, Collectors.groupingBy(Training::getOperateType))));
|
||||||
|
List<LessonChapterTrainingRelVO> newRelList = new ArrayList<>();
|
||||||
|
oldRelMap.forEach((chapterId, oldTrainingInfo) -> {
|
||||||
|
oldTrainingInfo.forEach((prdType, typeAndOperateType) -> {
|
||||||
|
Map<String, Map<String, List<Training>>> groupByTypeTrainingMap = newTrainingMap.get(prdType);
|
||||||
|
if (CollectionUtils.isEmpty(groupByTypeTrainingMap)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
typeAndOperateType.forEach((type, operateTypeAndRelEntries) -> {
|
||||||
|
Map<String, List<Training>> groupByOperateTypeTrainingMap = groupByTypeTrainingMap.get(type);
|
||||||
|
if (CollectionUtils.isEmpty(groupByOperateTypeTrainingMap)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
operateTypeAndRelEntries.forEach((operateType, relEntries) -> {
|
||||||
|
List<Training> trainings = groupByOperateTypeTrainingMap.get(operateType);
|
||||||
|
if (CollectionUtils.isEmpty(trainings))
|
||||||
|
return;
|
||||||
|
int trainingIndex = 0;
|
||||||
|
for (Map.Entry<LessonChapterTrainingRelVO, Training> entry : relEntries) {
|
||||||
|
LessonChapterTrainingRelVO oldRel = entry.getKey();
|
||||||
|
oldRel.setTrainingId(trainings.get(trainingIndex).getId());
|
||||||
|
newRelList.add(oldRel);
|
||||||
|
trainingIndex++;
|
||||||
|
if (trainingIndex >= trainings.size())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
iLessonService.addChapterTrainingRelAfterDelete(newRelList);
|
||||||
|
return result;
|
||||||
|
} finally {
|
||||||
runningmapIds.remove(mapId);
|
runningmapIds.remove(mapId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
public Set<Long> getRunningmapIds() {
|
||||||
public String generateTrainings(Long mapId){
|
|
||||||
|
|
||||||
Objects.requireNonNull(mapId, "地图id不能为空");
|
|
||||||
MapVO mapVO = iMapService.getMapDetail(mapId);
|
|
||||||
return generateNewTrainings(mapId, mapVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Long> getRunningmapIds(){
|
|
||||||
return this.runningmapIds;
|
return this.runningmapIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import club.joylink.rtss.vo.client.training.TrainingNewVO;
|
|||||||
import club.joylink.rtss.vo.client.training.TrainingQueryVO;
|
import club.joylink.rtss.vo.client.training.TrainingQueryVO;
|
||||||
import club.joylink.rtss.vo.client.training.TrainingResultVO;
|
import club.joylink.rtss.vo.client.training.TrainingResultVO;
|
||||||
import club.joylink.rtss.vo.client.training.TrainingStepVO;
|
import club.joylink.rtss.vo.client.training.TrainingStepVO;
|
||||||
|
import lombok.NonNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -187,4 +188,6 @@ public interface ITrainingV1Service {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Training> findEntities(Long mapId, String prdType);
|
List<Training> findEntities(Long mapId, String prdType);
|
||||||
|
|
||||||
|
List<Training> findEntities(@NonNull Long mapId);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import club.joylink.rtss.vo.client.training.TrainingResultVO;
|
|||||||
import club.joylink.rtss.vo.client.training.TrainingStepVO;
|
import club.joylink.rtss.vo.client.training.TrainingStepVO;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import lombok.NonNull;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -689,9 +690,16 @@ public class TrainingV1Service implements ITrainingV1Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Training> findEntities(Long mapId, String prdType) {
|
public List<Training> findEntities(@NonNull Long mapId, @NonNull String prdType) {
|
||||||
TrainingExample example = new TrainingExample();
|
TrainingExample example = new TrainingExample();
|
||||||
example.createCriteria().andMapIdEqualTo(mapId).andPrdTypeEqualTo(prdType);
|
example.createCriteria().andMapIdEqualTo(mapId).andPrdTypeEqualTo(prdType);
|
||||||
return trainingDAO.selectByExample(example);
|
return trainingDAO.selectByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Training> findEntities(@NonNull Long mapId) {
|
||||||
|
TrainingExample example = new TrainingExample();
|
||||||
|
example.createCriteria().andMapIdEqualTo(mapId);
|
||||||
|
return trainingDAO.selectByExample(example);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package club.joylink.rtss.vo.client;
|
package club.joylink.rtss.vo.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
|
||||||
import club.joylink.rtss.entity.LsDraftRelChapterTraining;
|
import club.joylink.rtss.entity.LsDraftRelChapterTraining;
|
||||||
import club.joylink.rtss.entity.LsRelChapterTraining;
|
import club.joylink.rtss.entity.LsRelChapterTraining;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -22,6 +22,8 @@ public class LessonChapterTrainingRelVO {
|
|||||||
*/
|
*/
|
||||||
private String lessonCode;
|
private String lessonCode;
|
||||||
|
|
||||||
|
private Long lessonId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课程章节ID
|
* 课程章节ID
|
||||||
*/
|
*/
|
||||||
@ -51,6 +53,7 @@ public class LessonChapterTrainingRelVO {
|
|||||||
|
|
||||||
public LessonChapterTrainingRelVO(LsDraftRelChapterTraining rel) {
|
public LessonChapterTrainingRelVO(LsDraftRelChapterTraining rel) {
|
||||||
// this.lessonCode = rel.getLessonCode();
|
// this.lessonCode = rel.getLessonCode();
|
||||||
|
this.lessonId = rel.getLessonId();
|
||||||
this.chapterId = rel.getChapterId();
|
this.chapterId = rel.getChapterId();
|
||||||
this.trainingId = rel.getTrainingId();
|
this.trainingId = rel.getTrainingId();
|
||||||
this.orderNum = rel.getOrderNum();
|
this.orderNum = rel.getOrderNum();
|
||||||
@ -59,6 +62,7 @@ public class LessonChapterTrainingRelVO {
|
|||||||
|
|
||||||
public LessonChapterTrainingRelVO(LsRelChapterTraining rel) {
|
public LessonChapterTrainingRelVO(LsRelChapterTraining rel) {
|
||||||
// this.lessonCode = rel.getLessonCode();
|
// this.lessonCode = rel.getLessonCode();
|
||||||
|
this.lessonId = rel.getLessonId();
|
||||||
this.chapterId = rel.getChapterId();
|
this.chapterId = rel.getChapterId();
|
||||||
this.trainingId = rel.getTrainingId();
|
this.trainingId = rel.getTrainingId();
|
||||||
this.orderNum = rel.getOrderNum();
|
this.orderNum = rel.getOrderNum();
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package club.joylink.rtss.vo.client;
|
package club.joylink.rtss.vo.client;
|
||||||
|
|
||||||
|
import club.joylink.rtss.entity.LsDraftLessonChapter;
|
||||||
|
import club.joylink.rtss.entity.LsLessonChapter;
|
||||||
import club.joylink.rtss.vo.client.training.TrainingNewVO;
|
import club.joylink.rtss.vo.client.training.TrainingNewVO;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
import club.joylink.rtss.entity.LsDraftLessonChapter;
|
|
||||||
import club.joylink.rtss.entity.LsLessonChapter;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -88,6 +88,7 @@ public class LessonChapterVO implements Comparable<LessonChapterVO> {
|
|||||||
|
|
||||||
public LessonChapterVO(LsLessonChapter chapter) {
|
public LessonChapterVO(LsLessonChapter chapter) {
|
||||||
this.id = chapter.getId();
|
this.id = chapter.getId();
|
||||||
|
this.lessonId = chapter.getLessonId();
|
||||||
this.name = chapter.getName();
|
this.name = chapter.getName();
|
||||||
this.remarks = chapter.getRemarks();
|
this.remarks = chapter.getRemarks();
|
||||||
this.parentId = chapter.getParentId();
|
this.parentId = chapter.getParentId();
|
||||||
|
Loading…
Reference in New Issue
Block a user