From 5cd012cc66f89900ecf5d26915a0ded71dbce3d1 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 25 Nov 2020 16:38:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=B5=81=E7=A8=8B=E4=BF=AE?= =?UTF-8?q?=E6=94=B9&=E8=B4=B5=E8=A3=85=E5=A4=87=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../publish/MapSystemController.java | 4 +- .../training/TrainingV1Controller.java | 12 ++++-- .../club/joylink/rtss/dao/LsLessonDAO.java | 41 +++++++++++++++++-- .../joylink/rtss/services/ILessonService.java | 5 +++ .../rtss/services/IMapSystemService.java | 5 ++- .../joylink/rtss/services/LessonService.java | 8 ++++ .../rtss/services/MapSystemService.java | 25 +++++------ .../student/ClassStudentUserServiceImpl.java | 3 +- .../services/training/ITrainingV1Service.java | 5 +++ .../services/training/TrainingV1Service.java | 33 +++++++++------ .../cbtc/GroupSimulationServiceImpl.java | 1 + 11 files changed, 105 insertions(+), 37 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/publish/MapSystemController.java b/src/main/java/club/joylink/rtss/controller/publish/MapSystemController.java index f3a64fa5c..fed2c4b42 100644 --- a/src/main/java/club/joylink/rtss/controller/publish/MapSystemController.java +++ b/src/main/java/club/joylink/rtss/controller/publish/MapSystemController.java @@ -70,8 +70,8 @@ public class MapSystemController { @ApiOperation(value = "查询子系统详情") @GetMapping("/{id}/detail") - public MapSystemDetailVO getMapSystemDetail(@PathVariable Long id, @RequestAttribute UserVO user) { - return iMapSystemService.getMapSystemDetail(id, user); + public MapSystemDetailVO getMapSystemDetail(@PathVariable Long id, @RequestAttribute LoginUserInfoVO loginInfo) { + return iMapSystemService.getMapSystemDetail(id, loginInfo); } @ApiOperation(value = "删除地图系统") diff --git a/src/main/java/club/joylink/rtss/controller/training/TrainingV1Controller.java b/src/main/java/club/joylink/rtss/controller/training/TrainingV1Controller.java index db61a0527..4f1ce72c3 100644 --- a/src/main/java/club/joylink/rtss/controller/training/TrainingV1Controller.java +++ b/src/main/java/club/joylink/rtss/controller/training/TrainingV1Controller.java @@ -2,8 +2,8 @@ package club.joylink.rtss.controller.training; import club.joylink.rtss.constants.RoleEnum; import club.joylink.rtss.controller.advice.Role; -import club.joylink.rtss.services.training.ITrainingV1Service; import club.joylink.rtss.services.training.GenerateTask; +import club.joylink.rtss.services.training.ITrainingV1Service; import club.joylink.rtss.services.training.data.GenerateConfig; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; @@ -85,8 +85,8 @@ public class TrainingV1Controller { @ApiOperation(value="实训开始") @GetMapping(path="/{id}/start") - public TrainingNewVO trainingStart(@PathVariable Long id, String group, String mode) { - return this.iTrainingService.trainingStart(id, group, mode); + public void trainingStart(@PathVariable Long id, String group, String mode) { + this.iTrainingService.trainingStart(id, group, mode); } /** @@ -189,4 +189,10 @@ public class TrainingV1Controller { public void deleteUserTraining(@PathVariable Long id, @ApiIgnore @RequestAttribute UserVO user) { this.iTrainingService.deleteUserTraining(id, user); } + + @ApiOperation("加载实训到仿真中") + @PutMapping("/{group}/{id}/loadTraining") + public TrainingNewVO loadTraining(@PathVariable String group, @PathVariable Long id) { + return iTrainingService.loadTraining(group, id); + } } diff --git a/src/main/java/club/joylink/rtss/dao/LsLessonDAO.java b/src/main/java/club/joylink/rtss/dao/LsLessonDAO.java index 86ea51fb3..672be44b2 100644 --- a/src/main/java/club/joylink/rtss/dao/LsLessonDAO.java +++ b/src/main/java/club/joylink/rtss/dao/LsLessonDAO.java @@ -2,9 +2,8 @@ package club.joylink.rtss.dao; import club.joylink.rtss.entity.LsLesson; import club.joylink.rtss.entity.LsLessonExample; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Update; +import club.joylink.rtss.vo.client.LessonVO; +import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; import java.util.List; @@ -36,4 +35,38 @@ public interface LsLessonDAO extends MyBatisBaseDao" + "") int batchInsertWithId(@Param("list") List lessonList); -} \ No newline at end of file + + @Results(id = "one", + value = { + @Result (column="id", property="id"), + @Result (column="map_id", property="mapId"), + @Result (column="prd_type", property="prdType"), + @Result (column="name", property="name"), + @Result (column="remarks", property="remarks"), + @Result (column="author_id", property="authorId"), + @Result (column="update_time", property="updateTime"), + @Result (column="creator_id", property="creatorId"), + @Result (column="city_code", property="cityCode"), + @Result (column="status", property="status") + } + ) + @Select("") + List getValidLesson(List ids, String prdType); +} diff --git a/src/main/java/club/joylink/rtss/services/ILessonService.java b/src/main/java/club/joylink/rtss/services/ILessonService.java index 962b2de4a..11ce5dee7 100644 --- a/src/main/java/club/joylink/rtss/services/ILessonService.java +++ b/src/main/java/club/joylink/rtss/services/ILessonService.java @@ -135,4 +135,9 @@ public interface ILessonService { @Transactional void generateLessonAndExam(List mapIds, UserVO userVO); + + /** + * 获取有效的课程 + */ + List getValidLesson(List ids, String prdType); } diff --git a/src/main/java/club/joylink/rtss/services/IMapSystemService.java b/src/main/java/club/joylink/rtss/services/IMapSystemService.java index 60d09f29b..a9fa52856 100644 --- a/src/main/java/club/joylink/rtss/services/IMapSystemService.java +++ b/src/main/java/club/joylink/rtss/services/IMapSystemService.java @@ -1,6 +1,7 @@ package club.joylink.rtss.services; import club.joylink.rtss.constants.Project; +import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.TreeNode; @@ -61,10 +62,10 @@ public interface IMapSystemService { /** * 根据系统类型和地图产品code查询详细信息 * @param id - * @param user + * @param loginInfo * @return */ - MapSystemDetailVO getMapSystemDetail(Long id, UserVO user); + MapSystemDetailVO getMapSystemDetail(Long id, LoginUserInfoVO loginInfo); /** * 删除地图系统 diff --git a/src/main/java/club/joylink/rtss/services/LessonService.java b/src/main/java/club/joylink/rtss/services/LessonService.java index 84c6bec1c..19090d1f0 100644 --- a/src/main/java/club/joylink/rtss/services/LessonService.java +++ b/src/main/java/club/joylink/rtss/services/LessonService.java @@ -15,12 +15,14 @@ import club.joylink.rtss.vo.client.training.TrainingNewVO; import club.joylink.rtss.vo.client.userPermission.UserPermissionVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; +import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import org.springframework.validation.annotation.Validated; import java.time.LocalDateTime; import java.util.*; @@ -33,6 +35,7 @@ import java.util.stream.Collectors; */ @Service @Slf4j +@Validated public class LessonService implements ILessonService { @Autowired @@ -591,6 +594,11 @@ public class LessonService implements ILessonService { } + @Override + public List getValidLesson(@NonNull List ids, String prdType) { + return lessonDAO.getValidLesson(ids, prdType); + } + private void generateLessonBy(UserVO userVO, MapVO mapVO, BusinessConsts.Lesson.PrdInfo prdLessonInfo, String prdType) { //课程 LsLesson lesson = new LsLesson(); diff --git a/src/main/java/club/joylink/rtss/services/MapSystemService.java b/src/main/java/club/joylink/rtss/services/MapSystemService.java index 71f4639ff..b066b4775 100644 --- a/src/main/java/club/joylink/rtss/services/MapSystemService.java +++ b/src/main/java/club/joylink/rtss/services/MapSystemService.java @@ -1,15 +1,17 @@ package club.joylink.rtss.services; -import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import com.github.pagehelper.Page; -import com.github.pagehelper.PageHelper; import club.joylink.rtss.constants.MapPrdTypeEnum; import club.joylink.rtss.constants.MapSystemType; import club.joylink.rtss.constants.Project; import club.joylink.rtss.constants.StatusEnum; import club.joylink.rtss.dao.MapSystemDAO; -import club.joylink.rtss.entity.*; +import club.joylink.rtss.entity.MapSystem; +import club.joylink.rtss.entity.MapSystemExample; +import club.joylink.rtss.entity.StudentRelIdClass; +import club.joylink.rtss.entity.StudentRelLessonClass; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.student.IClassStudentUserService; +import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.LessonVO; import club.joylink.rtss.vo.client.PageVO; @@ -20,12 +22,14 @@ import club.joylink.rtss.vo.client.sub.MapSystemDetailVO; import club.joylink.rtss.vo.client.sub.MapSystemQueryVO; import club.joylink.rtss.vo.client.sub.MapSystemVO; import club.joylink.rtss.vo.client.userPermission.UserPermissionVO; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import lombok.extern.slf4j.Slf4j; -import org.springframework.util.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import java.util.List; import java.util.Objects; @@ -199,13 +203,10 @@ public class MapSystemService implements IMapSystemService { /** * 根据mapSystem表id查询该产品下 - * - * @param id - * @param userVO - * @return */ @Override - public MapSystemDetailVO getMapSystemDetail(Long id, UserVO userVO) { + public MapSystemDetailVO getMapSystemDetail(Long id, LoginUserInfoVO loginInfo) { + UserVO userVO = loginInfo.getUserVO(); MapSystem mapSystem = getEntity(id); MapSystemDetailVO mapSystemDetailVO = new MapSystemDetailVO(mapSystem); @@ -220,11 +221,11 @@ public class MapSystemService implements IMapSystemService { List lessonVOList = null; //用户存在班级关系时,根据班级课程关系查询课程,目前仅GZB使用 List studentRelIdClasses = this.iClassStudentUserService.getRelClassByUser(userVO.getId()); - if(!CollectionUtils.isEmpty(studentRelIdClasses)){ + if(loginInfo.getProject().equals(Project.GZB) && !CollectionUtils.isEmpty(studentRelIdClasses)){ Integer classId = studentRelIdClasses.get(0).getClassId();//学生只关联一个班 List relLessonsByClass = this.iClassStudentUserService.getRelLessonsByClass(classId); if(!CollectionUtils.isEmpty(relLessonsByClass)){ - lessonVOList = iLessonService.getByIdsWithPrdType(relLessonsByClass.stream().map(StudentRelLessonClass::getLessonId).collect(Collectors.toList()),mapSystem.getPrdType()); + lessonVOList = iLessonService.getValidLesson(relLessonsByClass.stream().map(StudentRelLessonClass::getLessonId).collect(Collectors.toList()), mapSystem.getPrdType()); } }else{ diff --git a/src/main/java/club/joylink/rtss/services/student/ClassStudentUserServiceImpl.java b/src/main/java/club/joylink/rtss/services/student/ClassStudentUserServiceImpl.java index 09094c05e..3e11ea2ce 100644 --- a/src/main/java/club/joylink/rtss/services/student/ClassStudentUserServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/student/ClassStudentUserServiceImpl.java @@ -169,7 +169,8 @@ public class ClassStudentUserServiceImpl implements IClassStudentUserService { @Override public List getLessonByClass(Integer classId){ - return getRelLessonsByClass(classId).stream().map(studentRelLessonClass -> this.lessonService.getLessonInfo(studentRelLessonClass.getLessonId())).collect(Collectors.toList()); + List lessonIds = getRelLessonsByClass(classId).stream().map(StudentRelLessonClass::getLessonId).collect(Collectors.toList()); + return lessonService.getValidLesson(lessonIds, null); } @Override diff --git a/src/main/java/club/joylink/rtss/services/training/ITrainingV1Service.java b/src/main/java/club/joylink/rtss/services/training/ITrainingV1Service.java index d07a0abb4..d1c3ecc26 100644 --- a/src/main/java/club/joylink/rtss/services/training/ITrainingV1Service.java +++ b/src/main/java/club/joylink/rtss/services/training/ITrainingV1Service.java @@ -176,4 +176,9 @@ public interface ITrainingV1Service { Map copyAllOfMapAndPrd(Long sourceMapId, Long targetMapId); List queryTrainingsBy(Long mapId, String prdType, String trainingType); + + /** + * 加载实训到仿真中 + */ + TrainingNewVO loadTraining(String group, Long trainingId); } diff --git a/src/main/java/club/joylink/rtss/services/training/TrainingV1Service.java b/src/main/java/club/joylink/rtss/services/training/TrainingV1Service.java index d4655bec7..2a2a8d251 100644 --- a/src/main/java/club/joylink/rtss/services/training/TrainingV1Service.java +++ b/src/main/java/club/joylink/rtss/services/training/TrainingV1Service.java @@ -111,7 +111,8 @@ public class TrainingV1Service implements ITrainingV1Service { @Override public TrainingNewVO getTrainingDetail(Long id, String group) { Assert.hasText(group, "group不能为空!"); - return this.prepareTrainingData(id, group); + return groupTrainingDataCache.getTrainingByGroup(group); +// return this.prepareTrainingData(id, group); } private TrainingNewVO prepareTrainingData(Long id, String group) { @@ -196,18 +197,7 @@ public class TrainingV1Service implements ITrainingV1Service { @Override public TrainingNewVO trainingStart(Long id, String group, String mode) { - Assert.hasText(group, "group不能为空!"); - Simulation simulation = this.groupSimulationService.getSimulationByGroup(group); - BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(simulation, String.format("仿真[%s]不存在", group)); - //准备实训数据 - TrainingWithBLOBs training = trainingDAO.selectByPrimaryKey(id); - BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(training, "实训数据不存在"); - TrainingNewVO trainingVo = new TrainingNewVO(training); - this.groupTrainingDataCache.saveGroupTraining(group, trainingVo); - if (StringUtils.hasText(training.getSteps())) { - trainingVo.setSteps(JsonUtils.read(training.getSteps(), JsonUtils.getCollectionType(List.class, TrainingStepVO.class))); - } - groupSimulationService.loadScenes(group, training.getScenes()); + TrainingNewVO trainingVo = loadTraining(group, id); trainingVo.clearActualSteps(); return trainingVo; } @@ -680,4 +670,21 @@ public class TrainingV1Service implements ITrainingV1Service { List trainings = this.trainingDAO.selectByExample(te); return trainings; } + + @Override + public TrainingNewVO loadTraining(String group, Long trainingId) { + Assert.hasText(group, "group不能为空!"); + Simulation simulation = this.groupSimulationService.getSimulationByGroup(group); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(simulation, String.format("仿真[%s]不存在", group)); + //准备实训数据 + TrainingWithBLOBs training = trainingDAO.selectByPrimaryKey(trainingId); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(training, "实训数据不存在"); + TrainingNewVO trainingVo = new TrainingNewVO(training); + this.groupTrainingDataCache.saveGroupTraining(group, trainingVo); + if (StringUtils.hasText(training.getSteps())) { + trainingVo.setSteps(JsonUtils.read(training.getSteps(), JsonUtils.getCollectionType(List.class, TrainingStepVO.class))); + } + groupSimulationService.loadScenes(group, training.getScenes()); + return trainingVo; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java index 840460fe2..5014dcd80 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java @@ -337,6 +337,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { Simulation simulation = this.create(loginUserInfoVO, training.getMapId(), MapPrdTypeEnum.getMapPrdTypeEnumByCode(training.getPrdType()), Simulation.FunctionalType.LESSON); + iTrainingV1Service.loadTraining(simulation.getGroup(), trainingId); return simulation.getGroup(); }