Commit a6371ce2 authored by hkl's avatar hkl

feat:1.修改bug

parent ec59cd0b
...@@ -154,6 +154,14 @@ public class Result<T> implements Serializable { ...@@ -154,6 +154,14 @@ public class Result<T> implements Serializable {
return r; return r;
} }
public static <T> Result<T> batchDelete(String msg) {
Result<T> r = new Result<T>();
r.setSuccess(true);
r.setCode(207);
r.setMessage(msg);
return r;
}
public static <T> Result<T> error(String msg) { public static <T> Result<T> error(String msg) {
return error(CommonConstant.SC_INTERNAL_SERVER_ERROR_500, msg); return error(CommonConstant.SC_INTERNAL_SERVER_ERROR_500, msg);
} }
......
...@@ -74,10 +74,6 @@ ...@@ -74,10 +74,6 @@
<properties> <properties>
<package.environment>hkl</package.environment> <package.environment>hkl</package.environment>
</properties> </properties>
<!-- 是否默认 true表示默认-->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile> </profile>
<!-- 测试环境 --> <!-- 测试环境 -->
...@@ -94,6 +90,10 @@ ...@@ -94,6 +90,10 @@
<properties> <properties>
<package.environment>pressure</package.environment> <package.environment>pressure</package.environment>
</properties> </properties>
<!-- 是否默认 true表示默认-->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile> </profile>
<!-- 生成环境环境--> <!-- 生成环境环境-->
......
...@@ -24,8 +24,6 @@ public interface IRailManagementService extends IService<RailManagement> { ...@@ -24,8 +24,6 @@ public interface IRailManagementService extends IService<RailManagement> {
void edit(RailManagement railManagement); void edit(RailManagement railManagement);
void intelligentGeneration(String lightRailId);
void intelligentGeneration(String lightRailId, String lineAliasId); void intelligentGeneration(String lightRailId, String lineAliasId);
/** /**
......
...@@ -78,97 +78,6 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper, ...@@ -78,97 +78,6 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
// 1.判断完整的线路有没有空白部分(指剩余区间既不是道岔、曲线、竖曲线、钢轨的部分),只需要填空白部分,空白部分一定是钢轨,按照25一根的逻辑余数自成一根; // 1.判断完整的线路有没有空白部分(指剩余区间既不是道岔、曲线、竖曲线、钢轨的部分),只需要填空白部分,空白部分一定是钢轨,按照25一根的逻辑余数自成一根;
// 2.如果不存在空白部分,则定义道岔曲线竖曲线为绝对正确里程值,并且定义为特殊钢轨,相邻两个特殊钢轨之间的里程区间按照25一根的逻辑余数自成一根。 // 2.如果不存在空白部分,则定义道岔曲线竖曲线为绝对正确里程值,并且定义为特殊钢轨,相邻两个特殊钢轨之间的里程区间按照25一根的逻辑余数自成一根。
@Override
public void intelligentGeneration(String lightRailId) {
// 1.删除整条线的
this.lambdaUpdate().eq(RailManagement::getLightRailId, lightRailId).remove();
// 2.查询当前车站的上下行里程
LightRail lightRail = lightRailMapper.selectById(lightRailId);
// 3.处理上行
// 3.1 查询上行所有里程数
List<RailManagement> allRailList = new ArrayList<>();
String sdkId = "1"; // 上行线id
generationCore(lightRail, allRailList, sdkId);
for (int i = 0; i < allRailList.size(); i++) {
RailManagement railManagement = allRailList.get(i);
String railCode = "钢轨[上行]" + UnitCodeUtil.supplementZero(4, i + 1);
railManagement.setRailCode(railCode);
String unitCode = "SXXGG" + UnitCodeUtil.supplementZero(4, i + 1);
railManagement.setUnitCode(unitCode);
railManagement.setLightRailId(lightRailId);
railManagement.setRailOrderNum(i + 1);
railManagement.setCreateBy("系统生成");
railManagement.setUpdateBy("系统生成");
}
// 3.2 计算区间
this.calcSection(lightRailId, sdkId, allRailList);
// 4.处理下行
List<RailManagement> downRailList = new ArrayList<>();
String xdkId = "2"; // 下行线id
generationCore(lightRail, downRailList, xdkId);
for (int i = 0; i < downRailList.size(); i++) {
RailManagement railManagement = downRailList.get(i);
String railCode = "钢轨[下行]" + UnitCodeUtil.supplementZero(4, i + 1);
railManagement.setRailCode(railCode);
String unitCode = "DXXGG" + UnitCodeUtil.supplementZero(4, i + 1);
railManagement.setUnitCode(unitCode);
railManagement.setLightRailId(lightRailId);
railManagement.setRailOrderNum(i + 1);
railManagement.setCreateBy("系统生成");
railManagement.setUpdateBy("系统生成");
}
this.calcSection(lightRailId, xdkId, downRailList);
allRailList.addAll(downRailList);
// 异步执行保存
asyncTask.getAsyncExecutor().execute(() -> {
this.saveBatch(allRailList);
});
}
// @Override
public void intelligentGeneration1(String lightRailId, String lineAliasId) {
// 1.查询当前车站的上下行里程
LightRail lightRail = lightRailMapper.selectById(lightRailId);
// 2.1 查询上行所有里程数
List<RailManagement> allRailList = new ArrayList<>();
generationCore(lightRail, allRailList, lineAliasId);
for (int i = 0; i < allRailList.size(); i++) {
RailManagement railManagement = allRailList.get(i);
String railCode = "钢轨[上行]" + UnitCodeUtil.supplementZero(4, i + 1) + "[自动]";
railManagement.setRailCode(railCode);
String unitCode = "SXXGG" + UnitCodeUtil.supplementZero(4, i + 1);
railManagement.setUnitCode(unitCode);
railManagement.setLightRailId(lightRailId);
railManagement.setRailOrderNum(i + 1);
railManagement.setCreateBy("系统生成");
railManagement.setUpdateBy("系统生成");
}
// 3.2 计算区间
this.calcSection(lightRailId, lineAliasId, allRailList);
// 异步执行保存
asyncTask.getAsyncExecutor().execute(() -> {
this.saveBatch(allRailList);
});
}
@Override @Override
public void intelligentGeneration(String lightRailId, String lineAliasId) { public void intelligentGeneration(String lightRailId, String lineAliasId) {
// 1.查询当前车站的上下行里程 // 1.查询当前车站的上下行里程
...@@ -225,14 +134,6 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper, ...@@ -225,14 +134,6 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
List<RailManagement> innerRailList = this.generate(currentEndMileage, endMileage, lineAliasId); List<RailManagement> innerRailList = this.generate(currentEndMileage, endMileage, lineAliasId);
allRailList.addAll(innerRailList); allRailList.addAll(innerRailList);
} }
// // ③ 线路终点里程 > 一个单元结束里程,要补充[最后一个单元结束里程,线路终点里程]
// if (endMileage.subtract(currentEndMileage).compareTo(BigDecimal.ZERO) > 0) {
// isGenerateRule2 = false;
//
// List<RailManagement> innerRailList = this.generate(currentEndMileage, endMileage, lineAliasId);
// allRailList.addAll(innerRailList);
// }
} }
continue; continue;
} }
...@@ -301,12 +202,6 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper, ...@@ -301,12 +202,6 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
List<RailManagement> innerRailList = this.generate(currentEndMileage, endMileage, lineAliasId); List<RailManagement> innerRailList = this.generate(currentEndMileage, endMileage, lineAliasId);
allRailList.addAll(innerRailList); allRailList.addAll(innerRailList);
} }
// // ③ 线路终点里程 > 最后一个单元结束里程,要补充[最后一个单元结束里程,线路终点里程]
// if (endMileage.subtract(currentEndMileage).compareTo(BigDecimal.ZERO) > 0) {
// List<RailManagement> innerRailList = this.generate(currentEndMileage, endMileage, lineAliasId);
// allRailList.addAll(innerRailList);
// }
} }
continue; continue;
} }
...@@ -534,14 +429,23 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper, ...@@ -534,14 +429,23 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
} }
// 2.处理不到25米一段的钢轨 // 2.处理不到25米一段的钢轨,如果开始里程等于结束里程也不计算
RailManagement railManagement = new RailManagement();
railManagement.setId(UUIDGenerator.generate()); //中心里程 = (开始里程 + 结束里程) / 2
railManagement.setLineAliasId(lineAliasId); BigDecimal centerMileage = startMileage.add(endMileage).divide(new BigDecimal("2"), 3, RoundingMode.HALF_UP);
railManagement.setStartingMileage(startMileage); // 开始里程 == 中心里程 == 结束里程 这是一个点
railManagement.setCenterMileage(startMileage.add(endMileage).divide(new BigDecimal("2"), 3, RoundingMode.HALF_UP)); // 中心里程 = (开始里程+结束里程) / 2 if (startMileage.compareTo(centerMileage) == 0 && endMileage.compareTo(centerMileage) == 0) {
railManagement.setEndMileage(endMileage); // 啥也不做
result.add(railManagement); } else {
RailManagement railManagement = new RailManagement();
railManagement.setId(UUIDGenerator.generate());
railManagement.setLineAliasId(lineAliasId);
railManagement.setStartingMileage(startMileage);
railManagement.setCenterMileage(centerMileage);
railManagement.setEndMileage(endMileage);
result.add(railManagement);
}
return result; return result;
} }
......
...@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.dto.PageSearch; import org.jeecg.common.api.dto.PageSearch;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
...@@ -23,7 +22,6 @@ import org.jeecg.modules.subwayNetwork.service.ITrainStationService; ...@@ -23,7 +22,6 @@ import org.jeecg.modules.subwayNetwork.service.ITrainStationService;
import org.jeecg.modules.subwayNetwork.vo.LightRailQueryVO; import org.jeecg.modules.subwayNetwork.vo.LightRailQueryVO;
import org.jeecg.modules.subwayNetwork.vo.SectionStationMapVO; import org.jeecg.modules.subwayNetwork.vo.SectionStationMapVO;
import org.jeecg.modules.subwayNetwork.vo.SectionStationNode; import org.jeecg.modules.subwayNetwork.vo.SectionStationNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -154,10 +152,8 @@ public class LightRailController extends JeecgController<LightRail, ILightRailSe ...@@ -154,10 +152,8 @@ public class LightRailController extends JeecgController<LightRail, ILightRailSe
if (totalNum - successNum > 0) { if (totalNum - successNum > 0) {
message = message + ",未删除" + failNum + "条。未删除" + failMessage + "原因是线路下面有关联车站或区间故不能被删除"; message = message + ",未删除" + failNum + "条。未删除" + failMessage + "原因是线路下面有关联车站或区间故不能被删除";
// throw JeecgBootException.error(message.toString());
} }
return Result.batchDelete(message);
return Result.OK(message);
} }
/** /**
......
...@@ -142,31 +142,31 @@ public class SubwaySectionController extends JeecgController<SubwaySection, ISub ...@@ -142,31 +142,31 @@ public class SubwaySectionController extends JeecgController<SubwaySection, ISub
} }
if (switchCount != 0) { if (switchCount != 0) {
isDel = true; isDel = true;
errorMsg.append("道岔单元:" + railCount + "个"); errorMsg.append("道岔单元:" + switchCount + "个");
} }
if (curveCount != 0) { if (curveCount != 0) {
isDel = true; isDel = true;
errorMsg.append("曲线单元:" + railCount + "个"); errorMsg.append("曲线单元:" + curveCount + "个");
} }
if (verticalCurveCount != 0) { if (verticalCurveCount != 0) {
isDel = true; isDel = true;
errorMsg.append("竖曲线单元:" + railCount + "个"); errorMsg.append("竖曲线单元:" + verticalCurveCount + "个");
} }
if (trackBedCount != 0) { if (trackBedCount != 0) {
isDel = true; isDel = true;
errorMsg.append("道床:" + railCount + "个"); errorMsg.append("道床:" + trackBedCount + "个");
} }
if (fastenerCount != 0) { if (fastenerCount != 0) {
isDel = true; isDel = true;
errorMsg.append("扣件:" + railCount + "个"); errorMsg.append("扣件:" + fastenerCount + "个");
} }
if (sleeperCount != 0) { if (sleeperCount != 0) {
isDel = true; isDel = true;
errorMsg.append("轨枕:" + railCount + "个"); errorMsg.append("轨枕:" + sleeperCount + "个");
} }
if (signBoardCount != 0) { if (signBoardCount != 0) {
isDel = true; isDel = true;
errorMsg.append("轨行区标示牌:" + railCount + "个"); errorMsg.append("轨行区标示牌:" + signBoardCount + "个");
} }
if (isDel) { if (isDel) {
throw JeecgBootException.error(errorMsg.toString()); throw JeecgBootException.error(errorMsg.toString());
...@@ -177,15 +177,96 @@ public class SubwaySectionController extends JeecgController<SubwaySection, ISub ...@@ -177,15 +177,96 @@ public class SubwaySectionController extends JeecgController<SubwaySection, ISub
@ApiOperation(value = "线路车站-地铁区间-批量删除", notes = "线路车站-地铁区间-批量删除") @ApiOperation(value = "线路车站-地铁区间-批量删除", notes = "线路车站-地铁区间-批量删除")
@GetMapping(value = "/deleteBatch") @GetMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
for (String id : Arrays.asList(ids.split(","))) { String message = "";
verifyDeleteParams(id); Integer totalNum = 0;
sectionStationMapService.lambdaUpdate() Integer successNum = 0;
Integer failNum = 0;
String failMessage = " ";
List<SubwaySection> listRecords = this.service.lambdaQuery()
.in(SubwaySection::getId, Arrays.asList(ids.split(",")))
.list();
for (SubwaySection record : listRecords) {
totalNum++;
String id = record.getId();
Long railCount = railManagementService.lambdaQuery()
.eq(RailManagement::getSectionId, id)
.count();
Long switchCount = 0L;
List<SectionStationMap> sectionStationMapList = sectionStationMapService.lambdaQuery()
.eq(SectionStationMap::getSectionId, id) .eq(SectionStationMap::getSectionId, id)
.remove(); .list();
this.service.removeById(id); if (ObjectUtil.isNotEmpty(sectionStationMapList)) {
List<String> sectionStationMapIds = sectionStationMapList.stream()
.map(SectionStationMap::getId)
.collect(Collectors.toList());
switchCount = switchManagementService.lambdaQuery()
.in(SwitchManagement::getSectionStationMapId, sectionStationMapIds)
.count();
}
Long curveCount = curveManagementService.lambdaQuery()
.eq(CurveManagement::getSectionId, id)
.count();
Long verticalCurveCount = verticalCurveManagementService.lambdaQuery()
.eq(VerticalCurveManagement::getSectionId, id)
.count();
Long trackBedCount = trackBedManagementService.lambdaQuery()
.eq(TrackBedManagement::getSectionId, id)
.count();
Long fastenerCount = fastenerManagementService.lambdaQuery()
.eq(FastenerManagement::getSectionId, id)
.count();
Long sleeperCount = sleeperManagementService.lambdaQuery()
.eq(SleeperManagement::getSectionId, id)
.count();
Long signBoardCount = signBoardManagementService.lambdaQuery()
.eq(SignBoardManagement::getSectionId, id)
.count();
boolean isDel = false;
if (railCount != 0) {
isDel = true;
}
if (switchCount != 0) {
isDel = true;
}
if (curveCount != 0) {
isDel = true;
}
if (verticalCurveCount != 0) {
isDel = true;
}
if (trackBedCount != 0) {
isDel = true;
}
if (fastenerCount != 0) {
isDel = true;
}
if (sleeperCount != 0) {
isDel = true;
}
if (signBoardCount != 0) {
isDel = true;
}
if (isDel) {
failNum++;
failMessage = failMessage + record.getSectionName() + " ";
} else {
successNum++;
sectionStationMapService.lambdaUpdate()
.eq(SectionStationMap::getSectionId, id)
.remove();
this.service.removeById(id);
}
} }
message = "选中" + totalNum + "条数据已删除数据" + successNum + "条";
return Result.OK("批量删除成功!"); if (totalNum - successNum > 0) {
message = message + ",未删除" + failNum + "条。未删除" + failMessage + "原因是线路下面有关联设备故不能被删除";
}
return Result.batchDelete(message);
} }
......
...@@ -12,9 +12,9 @@ import org.jeecg.common.exception.JeecgBootException; ...@@ -12,9 +12,9 @@ import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.subwayNetwork.dto.TrainStationEditDTO; import org.jeecg.modules.subwayNetwork.dto.TrainStationEditDTO;
import org.jeecg.modules.subwayNetwork.dto.TrainStationQueryDTO; import org.jeecg.modules.subwayNetwork.dto.TrainStationQueryDTO;
import org.jeecg.modules.subwayNetwork.entity.LightRail; import org.jeecg.modules.subwayNetwork.entity.*;
import org.jeecg.modules.subwayNetwork.entity.SectionStationMap; import org.jeecg.modules.subwayNetwork.service.ILightRailService;
import org.jeecg.modules.subwayNetwork.entity.TrainStation; import org.jeecg.modules.subwayNetwork.service.ILineAliasService;
import org.jeecg.modules.subwayNetwork.service.ISectionStationMapService; import org.jeecg.modules.subwayNetwork.service.ISectionStationMapService;
import org.jeecg.modules.subwayNetwork.service.ITrainStationService; import org.jeecg.modules.subwayNetwork.service.ITrainStationService;
import org.jeecg.modules.subwayNetwork.vo.TrainStationVO; import org.jeecg.modules.subwayNetwork.vo.TrainStationVO;
...@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
/** /**
...@@ -41,6 +42,12 @@ public class TrainStationController extends JeecgController<TrainStation, ITrain ...@@ -41,6 +42,12 @@ public class TrainStationController extends JeecgController<TrainStation, ITrain
@Resource @Resource
private ISectionStationMapService sectionStationMapService; private ISectionStationMapService sectionStationMapService;
@Resource
private ILightRailService lightRailService;
@Resource
private ILineAliasService lineAliasService;
@AutoLog(value = "线路车站-地铁站-分页列表查询") @AutoLog(value = "线路车站-地铁站-分页列表查询")
@ApiOperation(value = "线路车站-地铁站-分页列表查询", notes = "线路车站-地铁站-分页列表查询") @ApiOperation(value = "线路车站-地铁站-分页列表查询", notes = "线路车站-地铁站-分页列表查询")
@PostMapping(value = "/list") @PostMapping(value = "/list")
...@@ -54,6 +61,52 @@ public class TrainStationController extends JeecgController<TrainStation, ITrain ...@@ -54,6 +61,52 @@ public class TrainStationController extends JeecgController<TrainStation, ITrain
@ApiOperation(value = "线路车站-地铁站-编辑", notes = "线路车站-地铁站-编辑") @ApiOperation(value = "线路车站-地铁站-编辑", notes = "线路车站-地铁站-编辑")
@PostMapping(value = "/edit") @PostMapping(value = "/edit")
public Result<String> edit(@RequestBody TrainStationEditDTO dto) { public Result<String> edit(@RequestBody TrainStationEditDTO dto) {
LightRail lightRail = lightRailService.getById(dto.getLightRailId());
LineAlias lineAlias = lineAliasService.getById(dto.getLineAliasId());
BigDecimal lightRailEndMileage = lightRail.getUpLineMileage();
if (lineAlias.getLineAliasName().contains("下行")) {
lightRailEndMileage = lightRail.getDownLineMileage();
}
if (dto.getEndMileage().compareTo(lightRailEndMileage) > 0) {
throw JeecgBootException.error("新增车站结束里程超过:" + lightRail.getRailLineName() + "的" + lineAlias.getLineAliasName() + "的结束里程【" + lightRailEndMileage + "】");
}
List<TrainStation> listRecord = this.service.lambdaQuery()
.eq(TrainStation::getLightRailId, dto.getLightRailId())
.eq(TrainStation::getLineAliasId, dto.getLineAliasId())
.list();
for (TrainStation record : listRecord) {
// 如果是更新,排除自己
if (record.getId().equals(dto.getId())) {
continue;
}
BigDecimal currentStartMileage = record.getStartingMileage();
BigDecimal currentEndMileage = record.getEndMileage();
BigDecimal startMileage = dto.getStartingMileage();
BigDecimal endMileage = dto.getEndMileage();
// 判断区间是否重叠
if (currentStartMileage.compareTo(startMileage) >= 0 && currentEndMileage.compareTo(endMileage) <= 0) {
throw JeecgBootException.error("你输入的站点里程范围【" + dto.getStartingMileage() + "~" + dto.getEndMileage() + "】;" +
"冲突区间名称:" + record.getStationName() + ",里程范围【" + record.getStartingMileage() + "~" + record.getEndMileage() + "】");
}
// 判断开始里程是否是否冲突
if (currentStartMileage.compareTo(startMileage) < 0 && currentEndMileage.compareTo(startMileage) > 0) {
throw JeecgBootException.error("你输入的站点里程范围【" + dto.getStartingMileage() + "~" + dto.getEndMileage() + "】;" +
"冲突区间名称:" + record.getStationName() + ",里程范围【" + record.getStartingMileage() + "~" + record.getEndMileage() + "】");
}
// 判断结束里程是否是否冲突
if (currentStartMileage.compareTo(endMileage) < 0 && currentEndMileage.compareTo(endMileage) > 0) {
throw JeecgBootException.error("你输入的站点里程范围【" + dto.getStartingMileage() + "~" + dto.getEndMileage() + "】;" +
"冲突区间名称:" + record.getStationName() + ",里程范围【" + record.getStartingMileage() + "~" + record.getEndMileage() + "】");
}
}
trainStationService.edit(dto); trainStationService.edit(dto);
...@@ -115,7 +168,7 @@ public class TrainStationController extends JeecgController<TrainStation, ITrain ...@@ -115,7 +168,7 @@ public class TrainStationController extends JeecgController<TrainStation, ITrain
// throw JeecgBootException.error(message.toString()); // throw JeecgBootException.error(message.toString());
} }
return Result.OK(message); return Result.batchDelete(message);
} }
......
...@@ -11,6 +11,7 @@ import org.apache.shiro.SecurityUtils; ...@@ -11,6 +11,7 @@ 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.exception.JeecgBootException;
import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.deviceAsset.entity.TrackBedManagement;
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;
import org.jeecg.modules.subwayNetwork.entity.LightRail; import org.jeecg.modules.subwayNetwork.entity.LightRail;
...@@ -60,19 +61,42 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S ...@@ -60,19 +61,42 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S
throw JeecgBootException.error("选中站点开始里程要小于结束里程"); throw JeecgBootException.error("选中站点开始里程要小于结束里程");
} }
// 1.2. 验证这条线路,线别区间是否有交集验证表达式: (start1 < end2) AND (end1 > start2); List<SubwaySection> listRecord = this.lambdaQuery()
SubwaySection existOne = this.lambdaQuery()
.ne(ObjectUtil.isNotEmpty(dto.getId()), SubwaySection::getId, dto.getId())
.eq(SubwaySection::getLightRailId, dto.getLightRailId()) .eq(SubwaySection::getLightRailId, dto.getLightRailId())
.eq(SubwaySection::getLineAliasId, dto.getLineAliasId()) .eq(SubwaySection::getLineAliasId, dto.getLineAliasId())
.le(SubwaySection::getSectionStartingMileage, startTrainStation.getCenterMileage()) .list();
.ge(SubwaySection::getSectionEndMileage, endTrainStation.getCenterMileage()) for (SubwaySection record : listRecord) {
.last("limit 1") // 如果是更新,排除自己
.one(); if (record.getId().equals(dto.getId())) {
if (ObjectUtil.isNotEmpty(existOne)) { continue;
throw JeecgBootException.error("和区间 " + existOne.getSectionName() + "有里程交集;" + }
"你选中的站点里程范围【" + startTrainStation.getEndMileage() + "~" + endTrainStation.getEndMileage() + "】;" + BigDecimal currentStartMileage = record.getSectionStartingMileage();
"冲突区间名称:" + existOne.getSectionName() + ",里程范围【" + existOne.getSectionStartingMileage() + "~" + existOne.getSectionEndMileage() + "】"); BigDecimal currentEndMileage = record.getSectionEndMileage();
BigDecimal startMileage = startTrainStation.getCenterMileage();
BigDecimal endMileage = endTrainStation.getCenterMileage();
// 判断区间是否重叠
if (currentStartMileage.compareTo(startMileage) >= 0 && currentEndMileage.compareTo(endMileage) <= 0) {
throw JeecgBootException.error("和区间 " + record.getSectionName() + "有里程交集;" +
"你选中的站点里程范围【" + startTrainStation.getCenterMileage() + "~" + endTrainStation.getCenterMileage() + "】;" +
"冲突区间名称:" + record.getSectionName() + ",里程范围【" + record.getSectionStartingMileage() + "~" + record.getSectionEndMileage() + "】");
}
// 判断开始里程是否是否冲突
if (currentStartMileage.compareTo(startMileage) < 0 && currentEndMileage.compareTo(startMileage) > 0) {
throw JeecgBootException.error("和区间 " + record.getSectionName() + "有里程交集;" +
"你选中的站点里程范围【" + startTrainStation.getCenterMileage() + "~" + endTrainStation.getCenterMileage() + "】;" +
"冲突区间名称:" + record.getSectionName() + ",里程范围【" + record.getSectionStartingMileage() + "~" + record.getSectionEndMileage() + "】");
}
// 判断结束里程是否是否冲突
if (currentStartMileage.compareTo(endMileage) < 0 && currentEndMileage.compareTo(endMileage) > 0) {
throw JeecgBootException.error("和区间 " + record.getSectionName() + "有里程交集;" +
"你选中的站点里程范围【" + startTrainStation.getCenterMileage() + "~" + endTrainStation.getCenterMileage() + "】;" +
"冲突区间名称:" + record.getSectionName() + ",里程范围【" + record.getSectionStartingMileage() + "~" + record.getSectionEndMileage() + "】");
}
} }
......
...@@ -37,6 +37,7 @@ public class TrainStationServiceImpl extends ServiceImpl<TrainStationMapper, Tra ...@@ -37,6 +37,7 @@ public class TrainStationServiceImpl extends ServiceImpl<TrainStationMapper, Tra
@Override @Override
public void edit(TrainStationEditDTO dto) { public void edit(TrainStationEditDTO dto) {
// 1.计算站长度:终点里程-起始里程 // 1.计算站长度:终点里程-起始里程
BigDecimal length = dto.getEndMileage().subtract(dto.getStartingMileage()); BigDecimal length = dto.getEndMileage().subtract(dto.getStartingMileage());
......
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