Commit 5f2bd8be authored by hkl's avatar hkl

feat:1.代码提交

parent 6069faab
...@@ -16,4 +16,5 @@ import org.jeecg.modules.subwayNetwork.vo.TrainStationVO; ...@@ -16,4 +16,5 @@ import org.jeecg.modules.subwayNetwork.vo.TrainStationVO;
public interface TrainStationMapper extends BaseMapper<TrainStation> { public interface TrainStationMapper extends BaseMapper<TrainStation> {
IPage<TrainStationVO> queryPageList(IPage<LightRailQueryVO> page, TrainStationQueryDTO query); IPage<TrainStationVO> queryPageList(IPage<LightRailQueryVO> page, TrainStationQueryDTO query);
} }
...@@ -60,7 +60,7 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S ...@@ -60,7 +60,7 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S
// 车站数量 // 车站数量
int trainStationNum = endTrainStation.getSeq() - startTrainStation.getSeq(); int trainStationNum = endTrainStation.getSeq() - startTrainStation.getSeq() + 1;
record.setTrainStationNum(trainStationNum); record.setTrainStationNum(trainStationNum);
} }
......
...@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service; ...@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
/** /**
* @Description: 线路车站-地铁站 * @Description: 线路车站-地铁站
...@@ -36,26 +37,38 @@ public class TrainStationServiceImpl extends ServiceImpl<TrainStationMapper, Tra ...@@ -36,26 +37,38 @@ public class TrainStationServiceImpl extends ServiceImpl<TrainStationMapper, Tra
@Override @Override
public void edit(TrainStationEditDTO dto) { public void edit(TrainStationEditDTO dto) {
// 1.计算当前线路下面有多少个站台 // 1.计算站长度:终点里程-起始里程
Long count = this.lambdaQuery()
.eq(TrainStation::getLightRailId, dto.getLightRailId())
.count();
// 2.计算站长度:终点里程-起始里程
BigDecimal length = dto.getEndMileage().subtract(dto.getStartingMileage()); BigDecimal length = dto.getEndMileage().subtract(dto.getStartingMileage());
// 3.通过id判断是保存还是修改
// 2.通过id判断是保存还是修改
if (ObjectUtil.isEmpty(dto.getId())) { if (ObjectUtil.isEmpty(dto.getId())) {
//
Integer seq = 1;
TrainStation exist = this.lambdaQuery().eq(TrainStation::getLightRailId, dto.getLightRailId())
.eq(TrainStation::getStationName, dto.getStationName())
.last("limit 1")
.one();
if (ObjectUtil.isEmpty(exist)) {
List<TrainStation> list = this.lambdaQuery()
.eq(TrainStation::getLightRailId, dto.getLightRailId())
.groupBy(TrainStation::getStationName)
.list();
seq = list.size() + 1;
} else {
seq = exist.getSeq();
}
TrainStation trainStation = BeanUtil.copyProperties(dto, TrainStation.class); TrainStation trainStation = BeanUtil.copyProperties(dto, TrainStation.class);
trainStation.setLength(length); trainStation.setLength(length);
trainStation.setSeq(count.intValue() + 1); trainStation.setSeq(seq);
this.save(trainStation); this.save(trainStation);
} else { } else {
TrainStation trainStation = BeanUtil.copyProperties(dto, TrainStation.class); TrainStation trainStation = BeanUtil.copyProperties(dto, TrainStation.class);
trainStation.setLength(length); trainStation.setLength(length);
trainStation.setSeq(count.intValue() + 1);
this.updateById(trainStation); this.updateById(trainStation);
} }
} }
} }
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