Commit 3fae48b1 authored by hkl's avatar hkl

feat:1.更新线路管理

parent 1b7860ed
...@@ -22,8 +22,8 @@ public class TrainStationEditDTO { ...@@ -22,8 +22,8 @@ public class TrainStationEditDTO {
@ApiModelProperty(value = "车站编码") @ApiModelProperty(value = "车站编码")
private String stationCode; private String stationCode;
@ApiModelProperty(value = "线别Code") @ApiModelProperty(value = "线别id")
private String lineAliasCode; private String lineAliasId;
@ApiModelProperty(value = "起始里程") @ApiModelProperty(value = "起始里程")
private BigDecimal startingMileage; private BigDecimal startingMileage;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
(SELECT line_alias_name FROM t_sn_line_alias WHERE id = t1.line_alias_id limit 1) line_alias_name, (SELECT line_alias_name FROM t_sn_line_alias WHERE id = t1.line_alias_id limit 1) line_alias_name,
t1.section_starting_mileage, t1.section_starting_mileage,
t1.section_end_mileage, t1.section_end_mileage,
t1.section_starting_mileage-t1.section_end_mileage sectionMileage,
t1.remark t1.remark
FROM FROM
t_sn_subway_section t1 LEFT JOIN t_sn_light_rail t2 ON t1.light_rail_id = t2.id t_sn_subway_section t1 LEFT JOIN t_sn_light_rail t2 ON t1.light_rail_id = t2.id
......
...@@ -48,24 +48,31 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S ...@@ -48,24 +48,31 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S
@Override @Override
public void edit(SubwaySectionEditDTO dto) { public void edit(SubwaySectionEditDTO dto) {
// 1.查询[起,始]站信息
TrainStation startTrainStation = trainStationMapper.selectById(dto.getStartTrainStationId());
TrainStation endTrainStation = trainStationMapper.selectById(dto.getEndTrainStationId());
// 2.设置区间信息
SubwaySection subwaySection = BeanUtil.copyProperties(dto, SubwaySection.class); SubwaySection subwaySection = BeanUtil.copyProperties(dto, SubwaySection.class);
LightRail rail = lightRailMapper.selectById(dto.getLightRailId()); LightRail rail = lightRailMapper.selectById(dto.getLightRailId()); // 线路id
subwaySection.setLightRailName(rail.getRailLineName()); subwaySection.setLightRailName(rail.getRailLineName());// 线路昵称
subwaySection.setSectionStartingMileage(startTrainStation.getStartingMileage()); // 区间起始里程
subwaySection.setSectionEndMileage(endTrainStation.getEndMileage());// 区间结束里程
if (ObjectUtil.isEmpty(dto.getId())) { if (ObjectUtil.isEmpty(dto.getId())) {
this.save(subwaySection); this.save(subwaySection);
} else { } else {
this.updateById(subwaySection); this.updateById(subwaySection);
} }
// 先删除
// 3.设置区间-车站关联信息
// 3.1 先删除关联信息
LambdaQueryWrapper<SectionStationMap> ssmQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SectionStationMap> ssmQueryWrapper = new LambdaQueryWrapper<>();
ssmQueryWrapper.eq(SectionStationMap::getSectionId, subwaySection.getId()); ssmQueryWrapper.eq(SectionStationMap::getSectionId, subwaySection.getId());
sectionStationMapMapper.delete(ssmQueryWrapper); sectionStationMapMapper.delete(ssmQueryWrapper);
// 3.2 查询这个单行区间的车站
// 查询这个区间的车站
TrainStation startTrainStation = trainStationMapper.selectById(subwaySection.getStartTrainStationId());
TrainStation endTrainStation = trainStationMapper.selectById(subwaySection.getEndTrainStationId());
QueryWrapper<TrainStation> tsQueryWrapper = new QueryWrapper<>(); QueryWrapper<TrainStation> tsQueryWrapper = new QueryWrapper<>();
tsQueryWrapper.lambda().ge(TrainStation::getSeq, startTrainStation.getSeq()) tsQueryWrapper.lambda().ge(TrainStation::getSeq, startTrainStation.getSeq())
.eq(TrainStation::getLineAliasId, dto.getLineAliasId()) .eq(TrainStation::getLineAliasId, dto.getLineAliasId())
...@@ -74,8 +81,7 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S ...@@ -74,8 +81,7 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S
List<TrainStation> trainStations = trainStationMapper.selectList(tsQueryWrapper); List<TrainStation> trainStations = trainStationMapper.selectList(tsQueryWrapper);
LightRail lightRail = lightRailMapper.selectById(subwaySection.getLightRailId()); LightRail lightRail = lightRailMapper.selectById(subwaySection.getLightRailId());
// 3.3 保存关联关系
// 后新增
for (TrainStation trainStation : trainStations) { for (TrainStation trainStation : trainStations) {
SectionStationMap sectionStationMap = new SectionStationMap(); SectionStationMap sectionStationMap = new SectionStationMap();
sectionStationMap.setLightRailId(lightRail.getId());// 车站id sectionStationMap.setLightRailId(lightRail.getId());// 车站id
...@@ -84,9 +90,12 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S ...@@ -84,9 +90,12 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S
sectionStationMap.setSectionName(subwaySection.getSectionName()); // 区间名称 sectionStationMap.setSectionName(subwaySection.getSectionName()); // 区间名称
sectionStationMap.setStationId(trainStation.getId()); // 车站id sectionStationMap.setStationId(trainStation.getId()); // 车站id
sectionStationMap.setStationName(trainStation.getStationName()); // 车站名称 sectionStationMap.setStationName(trainStation.getStationName()); // 车站名称
sectionStationMap.setLightRailId(dto.getLightRailId());
sectionStationMap.setStationStartingMileage(trainStation.getStartingMileage());// 车站起始里程
sectionStationMap.setStationCenterMileage(trainStation.getCenterMileage());// 车站中心里程
sectionStationMap.setStationEndMileage(trainStation.getEndMileage());// 车站结束里程
sectionStationMapMapper.insert(sectionStationMap); sectionStationMapMapper.insert(sectionStationMap);
} }
} }
@Override @Override
...@@ -94,22 +103,7 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S ...@@ -94,22 +103,7 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S
// 分页查询 // 分页查询
IPage<SubwaySectionVO> page = new Page<>(dto.getPageNo(), dto.getPageSize()); IPage<SubwaySectionVO> page = new Page<>(dto.getPageNo(), dto.getPageSize());
page = this.baseMapper.queryPageList(page, dto.getQuery()); page = this.baseMapper.queryPageList(page, dto.getQuery());
for (SubwaySectionVO record : page.getRecords()) {
// 计算区间里程
TrainStation startTrainStation = trainStationMapper.selectById(record.getStartTrainStationId());
TrainStation endTrainStation = trainStationMapper.selectById(record.getEndTrainStationId());
BigDecimal sectionMileage = endTrainStation.getEndMileage().subtract(startTrainStation.getEndMileage());
record.setSectionMileage(sectionMileage);
// 车站数量
int trainStationNum = endTrainStation.getSeq() - startTrainStation.getSeq() + 1;
record.setTrainStationNum(trainStationNum);
}
return page; return page;
} }
@Override @Override
......
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