diff --git a/src/main/java/club/joylink/rtss/constants/BusinessConsts.java b/src/main/java/club/joylink/rtss/constants/BusinessConsts.java index 2822d6a7e..8fa1e82d2 100644 --- a/src/main/java/club/joylink/rtss/constants/BusinessConsts.java +++ b/src/main/java/club/joylink/rtss/constants/BusinessConsts.java @@ -1,5 +1,7 @@ package club.joylink.rtss.constants; +import club.joylink.rtss.simulation.cbtc.data.map.Switch; + public interface BusinessConsts { String Default_NationCode = "86"; @@ -559,6 +561,17 @@ public interface BusinessConsts { public String getRemarks() { return remarks; } + + public static PrdInfo getBy(String prdType) { + switch (prdType) { + case "01": + return prdType01; + case "02": + return prdType02; + } + return null; + } + } interface Version { diff --git a/src/main/java/club/joylink/rtss/services/ILessonService.java b/src/main/java/club/joylink/rtss/services/ILessonService.java index 11ce5dee7..0b5034974 100644 --- a/src/main/java/club/joylink/rtss/services/ILessonService.java +++ b/src/main/java/club/joylink/rtss/services/ILessonService.java @@ -39,6 +39,8 @@ public interface ILessonService { */ LessonVO getLessonInfo(Long id); + LessonVO findByMapAndNameAndPrdType(Long mapId, String name, String prdType); + /** * 查询课程列表 * @param lessonQueryVO diff --git a/src/main/java/club/joylink/rtss/services/LessonDraftService.java b/src/main/java/club/joylink/rtss/services/LessonDraftService.java index 407667b07..025746f21 100644 --- a/src/main/java/club/joylink/rtss/services/LessonDraftService.java +++ b/src/main/java/club/joylink/rtss/services/LessonDraftService.java @@ -8,6 +8,7 @@ import club.joylink.rtss.entity.LsDraftLessonChapterExample.Criteria; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.*; +import club.joylink.rtss.vo.client.map.MapVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import lombok.extern.slf4j.Slf4j; @@ -53,6 +54,9 @@ public class LessonDraftService implements ILessonDraftService { @Autowired private TrainingDAO trainingDAO; + @Autowired + private IMapService iMapService; + @Override public PageVO queryPagedDraftLesson(Long mapId, PageQueryVO queryVO, UserVO userVO) { PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); @@ -290,6 +294,12 @@ public class LessonDraftService implements ILessonDraftService { @Override public void publishLesson(Long id, LessonPublishVO publishVO) { + MapVO mapVO = iMapService.findMapBaseInfoById(publishVO.getMapId()); + BusinessConsts.Lesson.PrdInfo prdInf = BusinessConsts.Lesson.PrdInfo.getBy(publishVO.getPrdType()); + if(Objects.nonNull(prdInf)){ + String defaultLessonName = String.join("-", mapVO.getName(), prdInf.getName()); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(Objects.equals(publishVO.getName(),defaultLessonName),"与系统默认课程同名,请重新设置名称"); + } LessonVO lessonVo = this.getDraftLessonDetail(id); this.iLessonService.publish(lessonVo, publishVO); } diff --git a/src/main/java/club/joylink/rtss/services/LessonService.java b/src/main/java/club/joylink/rtss/services/LessonService.java index e3a96e811..c76386818 100644 --- a/src/main/java/club/joylink/rtss/services/LessonService.java +++ b/src/main/java/club/joylink/rtss/services/LessonService.java @@ -224,7 +224,8 @@ public class LessonService implements ILessonService { return new LessonVO(lessonList.get(0)); } - private LessonVO findByMapAndNameAndPrdType(Long mapId, String name, String prdType) { + @Override + public LessonVO findByMapAndNameAndPrdType(Long mapId, String name, String prdType) { LsLessonExample lessonExample = new LsLessonExample(); lessonExample.createCriteria().andMapIdEqualTo(mapId).andNameEqualTo(name).andPrdTypeEqualTo(prdType); List lessonList = this.lessonDAO.selectByExample(lessonExample); diff --git a/src/main/java/club/joylink/rtss/services/MapSystemService.java b/src/main/java/club/joylink/rtss/services/MapSystemService.java index 29a95d631..e7337fc73 100644 --- a/src/main/java/club/joylink/rtss/services/MapSystemService.java +++ b/src/main/java/club/joylink/rtss/services/MapSystemService.java @@ -1,9 +1,6 @@ package club.joylink.rtss.services; -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.constants.*; import club.joylink.rtss.dao.MapSystemDAO; import club.joylink.rtss.entity.MapSystem; import club.joylink.rtss.entity.MapSystemExample; @@ -227,7 +224,16 @@ public class MapSystemService implements IMapSystemService { if(!CollectionUtils.isEmpty(relLessonsByClass)){ lessonVOList = iLessonService.getValidLesson(relLessonsByClass.stream().map(StudentRelLessonClass::getLessonId).collect(Collectors.toList()), mapSystem.getPrdType()); } - + //默认课程展示 + MapVO mapVO = iMapService.findMapBaseInfoById(mapSystem.getMapId()); + BusinessConsts.Lesson.PrdInfo prdInfo = BusinessConsts.Lesson.PrdInfo.getBy(mapSystem.getPrdType()); + if (Objects.nonNull(prdInfo)) { + String defaultLessonName = String.join("-", mapVO.getName(), prdInfo.name()); + LessonVO existedDefaultLesson = iLessonService.findByMapAndNameAndPrdType(mapSystem.getMapId(), defaultLessonName, mapSystem.getPrdType()); + if (Objects.nonNull(existedDefaultLesson)) { + lessonVOList.add(existedDefaultLesson); + } + } }else{ lessonVOList = iLessonService.getByMapIdAndPrdType(mapSystem.getMapId(), mapSystem.getPrdType()); } diff --git a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java index 50308a385..504251cd2 100644 --- a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java @@ -448,13 +448,13 @@ public class RunPlanDraftService implements IRunPlanDraftService { if (Objects.nonNull(endReentrySectionCode)) { endReentrySection = mapVO.findSectionNew(endReentrySectionCode); } else { - BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception("车站" + routingData.getEndStationCode() + "折返轨未设置"); + throw BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception("车站" + routingData.getEndStationCode() + "折返轨未设置"); } MapSectionNewVO startReentrySection = null; if (Objects.nonNull(startReentrySectionCode)) { startReentrySection = mapVO.findSectionNew(startReentrySectionCode); } else { - BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception("车站" + routingData.getStartStationCode() + "折返轨未设置"); + throw BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception("车站" + routingData.getStartStationCode() + "折返轨未设置"); } RunPlanTripVO tripVO = new RunPlanTripVO(tripConfigVO, routingData, startReentrySection, endReentrySection); if (mapVO.getConfigVO().getUpRight()) { @@ -698,13 +698,13 @@ public class RunPlanDraftService implements IRunPlanDraftService { if (Objects.nonNull(endReentrySectionCode)) { endReentrySection = mapVO.findSectionNew(endReentrySectionCode); } else { - BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception("车站" + routingData.getEndStationCode() + "折返轨未设置"); + throw BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception("车站" + routingData.getEndStationCode() + "折返轨未设置"); } MapSectionNewVO startReentrySection = null; if (Objects.nonNull(startReentrySectionCode)) { startReentrySection = mapVO.findSectionNew(startReentrySectionCode); } else { - BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception("车站" + routingData.getStartStationCode() + "折返轨未设置"); + throw BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception("车站" + routingData.getStartStationCode() + "折返轨未设置"); } tripVO = new RunPlanTripVO(tripConfig, routingData, startReentrySection, endReentrySection); // 构建类车到站数据 diff --git a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java index 7a5b8300e..5e4e2700e 100644 --- a/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java +++ b/src/main/java/club/joylink/rtss/vo/runplan/newdraw/RunPlanGenerator.java @@ -72,7 +72,7 @@ public class RunPlanGenerator { // 检测折返轨配置 if (Objects.isNull(userReentryData.get(running1Routing.getParkSectionCodeList().get(0).getStationCode())) || Objects.isNull(userReentryData.get(running1Routing.getParkSectionCodeList().get(running1Routing.getParkSectionCodeList().size() - 1).getStationCode()))) { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("折返轨未设置"); + throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("折返轨未设置"); } //生成车次 @@ -261,7 +261,7 @@ public class RunPlanGenerator { outRef = running2Routing; other = running1Routing; } else { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("出库交路 无法与环路交路相接"); + throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("出库交路 无法与环路交路相接"); } //查站间运行等级 List levels = runPlanRunlevelService.queryUserRunLevels(userId, mapVO.getId()); @@ -276,7 +276,7 @@ public class RunPlanGenerator { // 检测折返轨配置 if (Objects.isNull(userReentryData.get(running1Routing.getParkSectionCodeList().get(0).getStationCode())) || Objects.isNull(userReentryData.get(running1Routing.getParkSectionCodeList().get(running1Routing.getParkSectionCodeList().size() - 1).getStationCode()))) { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("折返轨未设置"); + throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("折返轨未设置"); } List tripList = new ArrayList<>(100);