Commit bd08fd78 authored by hkl's avatar hkl

feat:1.新增区间时,不能与这条线路线别其他区间有里程交集

parent fe791c24
...@@ -5,19 +5,21 @@ package org.jeecg.common.exception; ...@@ -5,19 +5,21 @@ package org.jeecg.common.exception;
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public class JeecgBootException extends RuntimeException { public class JeecgBootException extends RuntimeException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public JeecgBootException(String message){ public JeecgBootException(String message) {
super(message); super(message);
} }
public JeecgBootException(Throwable cause) public static JeecgBootException error(String message) {
{ return new JeecgBootException(message);
super(cause); }
}
public JeecgBootException(Throwable cause) {
public JeecgBootException(String message,Throwable cause) super(cause);
{ }
super(message,cause);
} public JeecgBootException(String message, Throwable cause) {
super(message, cause);
}
} }
...@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.dto.PageSearch; import org.jeecg.common.api.dto.PageSearch;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.subwayNetwork.dto.SubwaySectionEditDTO; import org.jeecg.modules.subwayNetwork.dto.SubwaySectionEditDTO;
import org.jeecg.modules.subwayNetwork.dto.SubwaySectionQueryDTO; import org.jeecg.modules.subwayNetwork.dto.SubwaySectionQueryDTO;
...@@ -38,8 +39,6 @@ import java.util.List; ...@@ -38,8 +39,6 @@ import java.util.List;
*/ */
@Service @Service
public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, SubwaySection> implements ISubwaySectionService { public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, SubwaySection> implements ISubwaySectionService {
@Resource @Resource
private LightRailMapper lightRailMapper; private LightRailMapper lightRailMapper;
...@@ -55,6 +54,25 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S ...@@ -55,6 +54,25 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S
TrainStation startTrainStation = trainStationMapper.selectById(dto.getStartTrainStationId()); TrainStation startTrainStation = trainStationMapper.selectById(dto.getStartTrainStationId());
TrainStation endTrainStation = trainStationMapper.selectById(dto.getEndTrainStationId()); TrainStation endTrainStation = trainStationMapper.selectById(dto.getEndTrainStationId());
// 1.1 起点里程 一定要大于始点里程
if (startTrainStation.getCenterMileage().compareTo(endTrainStation.getCenterMileage()) > 0) {
throw JeecgBootException.error("选中站点开始里程要小于结束里程");
}
// 1.2. 验证这条线路,线别区间是否有交集验证表达式: (start1 < end2) AND (end1 > start2);
SubwaySection existOne = this.lambdaQuery()
.eq(SubwaySection::getLightRailId, dto.getLightRailId())
.eq(SubwaySection::getLineAliasId, dto.getLineAliasId())
.lt(SubwaySection::getSectionStartingMileage, endTrainStation.getEndMileage())
.gt(SubwaySection::getSectionEndMileage, startTrainStation.getCenterMileage())
.last("limit 1")
.one();
if (ObjectUtil.isNotEmpty(existOne)) {
throw JeecgBootException.error("和区间 " + existOne.getSectionName() + "有里程交集;" +
"你选中的站点里程范围【" + startTrainStation.getEndMileage() + "~" + endTrainStation.getEndMileage() + "】;" +
"冲突区间名称:" + existOne.getSectionName() + ",里程范围【" + existOne.getSectionStartingMileage() + "~" + existOne.getSectionEndMileage() + "】");
}
// 2.设置区间信息 // 2.设置区间信息
SubwaySection subwaySection = BeanUtil.copyProperties(dto, SubwaySection.class); SubwaySection subwaySection = BeanUtil.copyProperties(dto, SubwaySection.class);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment