Commit ec59cd0b authored by hkl's avatar hkl

feat:1.修改bug

parent fa4a630d
......@@ -74,6 +74,10 @@
<properties>
<package.environment>hkl</package.environment>
</properties>
<!-- 是否默认 true表示默认-->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- 测试环境 -->
......@@ -90,10 +94,6 @@
<properties>
<package.environment>pressure</package.environment>
</properties>
<!-- 是否默认 true表示默认-->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- 生成环境环境-->
......
......@@ -15,7 +15,7 @@ import org.jeecg.modules.deviceAsset.dto.SignBoardManagementDTO;
import org.jeecg.modules.deviceAsset.entity.FastenerManagement;
import org.jeecg.modules.deviceAsset.entity.SignBoardManagement;
import org.jeecg.modules.deviceAsset.entity.TrackBedManagement;
import org.jeecg.modules.deviceAsset.service.ISignBoardManagementService;
import org.jeecg.modules.deviceAsset.service.*;
import org.jeecg.modules.deviceAsset.vo.FastenerManagementVO;
import org.jeecg.modules.deviceAsset.vo.SignBoardManagementVO;
import org.jeecg.modules.subwayNetwork.entity.LightRail;
......@@ -45,10 +45,10 @@ import java.util.List;
public class SignBoardManagementController extends JeecgController<SignBoardManagement, ISignBoardManagementService> {
@Resource
private ILightRailService lightRailService;
@Resource
private ILineAliasService lineAliasService;
@AutoLog(value = "资产管理-轨行区标识管理 -分页列表查询")
@ApiOperation(value = "资产管理-道岔管理-分页列表查询", notes = "资产管理-道岔管理-分页列表查询")
@GetMapping(value = "/list")
......@@ -76,14 +76,15 @@ public class SignBoardManagementController extends JeecgController<SignBoardMana
throw JeecgBootException.error("轨行区标识牌超过:" + lightRail.getRailLineName() + "的" + lineAlias.getLineAliasName() + "的结束里程【" + lightRailEndMileage + "】");
}
Long count = this.service.lambdaQuery()
SignBoardManagement existSignBoardManagement = this.service.lambdaQuery()
.eq(SignBoardManagement::getSectionId, signBoardManagement.getSectionId())
.eq(SignBoardManagement::getLineAliasId, signBoardManagement.getLineAliasId())
.eq(SignBoardManagement::getMileage, signBoardManagement.getMileage())
.ne(ObjectUtil.isNotEmpty(signBoardManagement.getId()), SignBoardManagement::getId, signBoardManagement.getId())
.count();
if (count > 0) {
throw JeecgBootException.error("轨行区标识牌已存在,和轨行区标识牌【编号:" + signBoardManagement.getSignBoardCode() + "】里程冲突");
.last("limit 1")
.one();
if (existSignBoardManagement != null) {
throw JeecgBootException.error("轨行区标识牌已存在,和轨行区标识牌【编号:" + existSignBoardManagement.getSignBoardCode() + "】里程冲突");
}
......@@ -107,6 +108,8 @@ public class SignBoardManagementController extends JeecgController<SignBoardMana
@ApiOperation(value = "资产管理-轨行区标识管理-通过id删除", notes = "资产管理-轨行区标识管理-通过id删除")
@GetMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
this.service.removeById(id);
return Result.OK("删除成功!");
}
......
......@@ -104,16 +104,16 @@ public class TrackBedManagementController extends JeecgController<TrackBedManage
if (record.getId().equals(trackBedManagement.getId())) {
continue;
}
BigDecimal currentStartMileage = record.getStartingMileage();
BigDecimal currentEndMileage = record.getEndMileage();
String deviceCode = record.getTrackBedCode();
BigDecimal startMileage = trackBedManagement.getStartingMileage();
BigDecimal endMileage = trackBedManagement.getEndMileage();
String deviceCode = trackBedManagement.getTrackBedCode();
// 判断区间是否重叠
if (currentStartMileage.compareTo(startMileage) == 0 && currentEndMileage.compareTo(endMileage) == 0) {
if (currentStartMileage.compareTo(startMileage) >= 0 && currentEndMileage.compareTo(endMileage) <= 0) {
throw JeecgBootException.error("和【道床编号:" + deviceCode + "】里程冲突");
}
......
......@@ -219,14 +219,14 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
// 只有一个单元
if (size == 1) {
// ② 第一个开始里程 <= 线路起点里程 < 第一个单元结束里程[第一个单元结束里程,结束里程] ,
if (lineStartMileage.compareTo(currentStartMileage) >= 0 && lineStartMileage.compareTo(currentEndMileage) < 0) {
if (lineStartMileage.compareTo(currentStartMileage) <= 0 && lineStartMileage.compareTo(currentEndMileage) < 0) {
isGenerateRule2 = false;
List<RailManagement> innerRailList = this.generate(currentEndMileage, endMileage, lineAliasId);
allRailList.addAll(innerRailList);
}
// // ③ 线路终点里程 > 最后一个单元结束里程,要补充[最后一个单元结束里程,线路终点里程]
// // ③ 线路终点里程 > 一个单元结束里程,要补充[最后一个单元结束里程,线路终点里程]
// if (endMileage.subtract(currentEndMileage).compareTo(BigDecimal.ZERO) > 0) {
// isGenerateRule2 = false;
//
......@@ -274,6 +274,11 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
.remove();
size = lineSpecialRailList.size();
if (size == 0 && endMileage.compareTo(lineStartMileage) > 0) {
List<RailManagement> innerRailList = this.generate(lineStartMileage, endMileage, lineAliasId);
allRailList.addAll(innerRailList);
}
for (int i = 0; i < size; i++) {
Map<String, Object> currentMap = lineSpecialRailList.get(i);
BigDecimal currentStartMileage = Convert.toBigDecimal(currentMap.get("startMileage"));
......@@ -291,7 +296,7 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
// 只有一个单元
if (size == 1) {
// ② 第一个开始里程 <= 线路起点里程 < 第一个单元结束里程[第一个单元结束里程,结束里程] ,
if (lineStartMileage.compareTo(currentStartMileage) >= 0 && lineStartMileage.compareTo(currentEndMileage) < 0) {
if (lineStartMileage.compareTo(currentStartMileage) <= 0 && lineStartMileage.compareTo(currentEndMileage) < 0) {
List<RailManagement> innerRailList = this.generate(currentEndMileage, endMileage, lineAliasId);
allRailList.addAll(innerRailList);
......@@ -509,7 +514,7 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
List<RailManagement> result = new ArrayList<>();
// 1.处理25米一段的钢轨
while (startMileage.add(UNIT_LENGTH).compareTo(endMileage) < 0) {
while (startMileage.add(UNIT_LENGTH).compareTo(endMileage) <= 0) {
// 开始里程向后移动25米
BigDecimal currentEndMileage = startMileage.add(UNIT_LENGTH);
......@@ -649,7 +654,9 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
// 判断区间是否重叠
if (currentStartMileage.compareTo(startMileage) == 0 && currentEndMileage.compareTo(endMileage) == 0) {
// 例如 曲线区间 【250 - 280】
// 道岔区间 【240 - 280】
if (currentStartMileage.compareTo(startMileage) >= 0 && currentEndMileage.compareTo(endMileage) <= 0) {
throw JeecgBootException.error("新增单元里程和【" + typeName + "编号:" + deviceCode + "】里程冲突");
}
......
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.dto.PageSearch;
import org.jeecg.common.api.vo.Result;
......@@ -112,25 +113,51 @@ public class LightRailController extends JeecgController<LightRail, ILightRailSe
@ApiOperation(value = "线路车站-轻轨线路-批量删除", notes = "线路车站-轻轨线路-批量删除")
@GetMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
List<String> idList = Arrays.asList(ids.split(","));
for (String id : idList) {
String message = "";
Integer totalNum = 0;
Integer successNum = 0;
Integer failNum = 0;
String failMessage = " ";
// 1.查询待删除的线路
List<LightRail> lightRails = this.service.lambdaQuery()
.in(LightRail::getId, Arrays.asList(ids.split(",")))
.list();
// 2.循环删除和校验
for (LightRail lightRail : lightRails) {
totalNum++;
Long sectionStationMapCount = sectionStationMapService.lambdaQuery()
.eq(SectionStationMap::getLightRailId, id)
.eq(SectionStationMap::getLightRailId, lightRail.getId())
.count();
if (sectionStationMapCount > 0) {
throw new JeecgBootException("该线路下面还有关联区间");
failNum++;
failMessage = failMessage + lightRail.getRailLineName() + " ";
continue;
}
Long trainStationCount = trainStationService.lambdaQuery()
.eq(TrainStation::getLightRailId, id)
.eq(TrainStation::getLightRailId, lightRail.getId())
.count();
if (trainStationCount > 0) {
throw new JeecgBootException("该线路下面还有车站");
failNum++;
failMessage = failMessage + lightRail.getRailLineName() + " ";
continue;
}
successNum++;
this.service.removeById(lightRail.getId());
}
message = "选中" + totalNum + "条数据已删除数据" + successNum + "条";
if (totalNum - successNum > 0) {
message = message + ",未删除" + failNum + "条。未删除" + failMessage + "原因是线路下面有关联车站或区间故不能被删除";
// throw JeecgBootException.error(message.toString());
}
this.service.removeByIds(idList);
return Result.OK("批量删除成功!");
return Result.OK(message);
}
/**
......
package org.jeecg.modules.subwayNetwork.controller;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import cn.hutool.core.util.ObjectUtil;
import org.jeecg.common.api.dto.PageSearch;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.deviceAsset.entity.*;
import org.jeecg.modules.deviceAsset.service.*;
import org.jeecg.modules.subwayNetwork.dto.SubwaySectionEditDTO;
import org.jeecg.modules.subwayNetwork.dto.SubwaySectionQueryDTO;
import org.jeecg.modules.subwayNetwork.entity.LightRail;
import org.jeecg.modules.subwayNetwork.entity.SectionStationMap;
import org.jeecg.modules.subwayNetwork.entity.SubwaySection;
import org.jeecg.modules.subwayNetwork.service.ISectionStationMapService;
import org.jeecg.modules.subwayNetwork.service.ISubwaySectionService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.subwayNetwork.vo.SubwaySectionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: 线路车站-地铁区间
......@@ -39,14 +38,31 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
@RequestMapping("/subwayNetwork/subwaySection")
@Slf4j
public class SubwaySectionController extends JeecgController<SubwaySection, ISubwaySectionService> {
@Autowired
private ISubwaySectionService subwaySectionService;
@Resource
private ISectionStationMapService sectionStationMapService;
@Resource
private IRailManagementService railManagementService;
@Resource
private ISwitchManagementService switchManagementService;
@Resource
private ICurveManagementService curveManagementService;
@Resource
private IVerticalCurveManagementService verticalCurveManagementService;
@Resource
private ITrackBedManagementService trackBedManagementService;
@Resource
private IFastenerManagementService fastenerManagementService;
@Resource
private ISignBoardManagementService signBoardManagementService;
@Resource
private ISleeperManagementService sleeperManagementService;
@AutoLog(value = "线路车站-地铁区间-分页列表查询")
@ApiOperation(value = "线路车站-地铁区间-分页列表查询", notes = "线路车站-地铁区间-分页列表查询")
@PostMapping(value = "/list")
public Result<IPage<SubwaySectionVO>> queryPageList(@RequestBody PageSearch<SubwaySectionQueryDTO> dto) {
IPage<SubwaySectionVO> pageList = subwaySectionService.queryPageList(dto);
IPage<SubwaySectionVO> pageList = this.service.queryPageList(dto);
return Result.OK(pageList);
}
......@@ -56,7 +72,7 @@ public class SubwaySectionController extends JeecgController<SubwaySection, ISub
@PostMapping(value = "/edit")
public Result<String> edit(@RequestBody SubwaySectionEditDTO dto) {
subwaySectionService.edit(dto);
this.service.edit(dto);
return Result.OK("编辑成功!");
}
......@@ -66,15 +82,109 @@ public class SubwaySectionController extends JeecgController<SubwaySection, ISub
@ApiOperation(value = "线路车站-地铁区间-通过id删除", notes = "线路车站-地铁区间-通过id删除")
@GetMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
subwaySectionService.delete(id);
verifyDeleteParams(id);
sectionStationMapService.lambdaUpdate()
.eq(SectionStationMap::getSectionId, id)
.remove();
this.service.removeById(id);
return Result.OK("删除成功!");
}
private void verifyDeleteParams(String id) {
Long railCount = railManagementService.lambdaQuery()
.eq(RailManagement::getSectionId, id)
.count();
Long switchCount = 0L;
List<SectionStationMap> sectionStationMapList = sectionStationMapService.lambdaQuery()
.eq(SectionStationMap::getSectionId, id)
.list();
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;
StringBuilder errorMsg = new StringBuilder("该区间下还有");
if (railCount != 0) {
isDel = true;
errorMsg.append("钢轨单元:" + railCount + "个");
}
if (switchCount != 0) {
isDel = true;
errorMsg.append("道岔单元:" + railCount + "个");
}
if (curveCount != 0) {
isDel = true;
errorMsg.append("曲线单元:" + railCount + "个");
}
if (verticalCurveCount != 0) {
isDel = true;
errorMsg.append("竖曲线单元:" + railCount + "个");
}
if (trackBedCount != 0) {
isDel = true;
errorMsg.append("道床:" + railCount + "个");
}
if (fastenerCount != 0) {
isDel = true;
errorMsg.append("扣件:" + railCount + "个");
}
if (sleeperCount != 0) {
isDel = true;
errorMsg.append("轨枕:" + railCount + "个");
}
if (signBoardCount != 0) {
isDel = true;
errorMsg.append("轨行区标示牌:" + railCount + "个");
}
if (isDel) {
throw JeecgBootException.error(errorMsg.toString());
}
}
@AutoLog(value = "线路车站-地铁区间-批量删除")
@ApiOperation(value = "线路车站-地铁区间-批量删除", notes = "线路车站-地铁区间-批量删除")
@GetMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.subwaySectionService.removeByIds(Arrays.asList(ids.split(",")));
for (String id : Arrays.asList(ids.split(","))) {
verifyDeleteParams(id);
sectionStationMapService.lambdaUpdate()
.eq(SectionStationMap::getSectionId, id)
.remove();
this.service.removeById(id);
}
return Result.OK("批量删除成功!");
}
......@@ -83,7 +193,7 @@ public class SubwaySectionController extends JeecgController<SubwaySection, ISub
@ApiOperation(value = "线路车站-轻轨线路-获取全部线路", notes = "线路车站-轻轨线路-获取全部线路")
@GetMapping(value = "/listAll")
public Result<List<Map<String, Object>>> listAll() {
List<SubwaySection> subwaySections = subwaySectionService.list();
List<SubwaySection> subwaySections = this.service.list();
List<Map<String, Object>> list = new ArrayList<>();
for (SubwaySection subwaySection : subwaySections) {
......@@ -91,7 +201,7 @@ public class SubwaySectionController extends JeecgController<SubwaySection, ISub
map.put("label", subwaySection.getSectionName());
map.put("value", subwaySection.getId());
map.put("parentId", subwaySection.getLightRailId());
map.put("lineAliasId",subwaySection.getLineAliasId());
map.put("lineAliasId", subwaySection.getLineAliasId());
list.add(map);
}
return Result.OK(list);
......
......@@ -82,19 +82,40 @@ public class TrainStationController extends JeecgController<TrainStation, ITrain
@ApiOperation(value = "线路车站-地铁站-批量删除", notes = "线路车站-地铁站-批量删除")
@GetMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
List<String> idList = Arrays.asList(ids.split(","));
for (String id : idList) {
String message = "";
Integer totalNum = 0;
Integer successNum = 0;
Integer failNum = 0;
String failMessage = " ";
// 1.查询待删除的数据
List<TrainStation> list = this.service.lambdaQuery()
.in(TrainStation::getId, Arrays.asList(ids.split(",")))
.list();
for (TrainStation trainStation : list) {
totalNum++;
Long sectionStationMapCount = sectionStationMapService.lambdaQuery()
.eq(SectionStationMap::getStationId, id)
.eq(SectionStationMap::getStationId, trainStation.getId())
.count();
if (sectionStationMapCount > 0) {
throw new JeecgBootException("该车站下面还有关联区间");
failNum++;
failMessage = failMessage + trainStation.getStationName() + " ";
continue;
}
successNum++;
this.service.removeById(trainStation.getId());
}
message = "选中" + totalNum + "条数据已删除数据" + successNum + "条";
if (totalNum - successNum > 0) {
message = message + ",未删除" + failNum + "条。未删除" + failMessage + "车站下面有关联区间故不能被删除!";
// throw JeecgBootException.error(message.toString());
}
this.service.removeByIds(idList);
return Result.OK("批量删除成功!");
return Result.OK(message);
}
......
......@@ -20,5 +20,4 @@ public interface ISubwaySectionService extends IService<SubwaySection> {
IPage<SubwaySectionVO> queryPageList(PageSearch<SubwaySectionQueryDTO> dto);
void delete(String id);
}
......@@ -48,6 +48,7 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S
@Resource
private SectionStationMapMapper sectionStationMapMapper;
@Override
public void edit(SubwaySectionEditDTO dto) {
// 1.查询[起,始]站信息
......@@ -61,10 +62,11 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S
// 1.2. 验证这条线路,线别区间是否有交集验证表达式: (start1 < end2) AND (end1 > start2);
SubwaySection existOne = this.lambdaQuery()
.ne(ObjectUtil.isNotEmpty(dto.getId()), SubwaySection::getId, dto.getId())
.eq(SubwaySection::getLightRailId, dto.getLightRailId())
.eq(SubwaySection::getLineAliasId, dto.getLineAliasId())
.lt(SubwaySection::getSectionStartingMileage, endTrainStation.getEndMileage())
.gt(SubwaySection::getSectionEndMileage, startTrainStation.getCenterMileage())
.le(SubwaySection::getSectionStartingMileage, startTrainStation.getCenterMileage())
.ge(SubwaySection::getSectionEndMileage, endTrainStation.getCenterMileage())
.last("limit 1")
.one();
if (ObjectUtil.isNotEmpty(existOne)) {
......@@ -143,12 +145,4 @@ public class SubwaySectionServiceImpl extends ServiceImpl<SubwaySectionMapper, S
return page;
}
@Override
public void delete(String id) {
LambdaQueryWrapper<SectionStationMap> ssmQueryWrapper = new LambdaQueryWrapper<>();
ssmQueryWrapper.eq(SectionStationMap::getSectionId, id);
sectionStationMapMapper.delete(ssmQueryWrapper);
this.removeById(id);
}
}
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