Commit 36f9d4a4 authored by hkl's avatar hkl

feat:1.冲突限制

parent 6b7261e7
......@@ -13,11 +13,14 @@ import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.deviceAsset.dto.CurveManagementDTO;
import org.jeecg.modules.deviceAsset.entity.CurveManagement;
import org.jeecg.modules.deviceAsset.service.ICurveManagementService;
import org.jeecg.modules.deviceAsset.service.IRailManagementService;
import org.jeecg.modules.deviceAsset.service.impl.RailManagementServiceImpl;
import org.jeecg.modules.deviceAsset.vo.CurveManagementQueryVO;
import org.springframework.web.bind.annotation.*;
import org.jeecg.common.system.base.controller.JeecgController;
import javax.annotation.Resource;
import java.util.Arrays;
/**
......@@ -33,6 +36,8 @@ import java.util.Arrays;
@Api(tags = "资产管理-曲线管理")
public class CurveManagementController extends JeecgController<CurveManagement, ICurveManagementService> {
@Resource
private IRailManagementService railManagementService;
@AutoLog(value = "资产管理-曲线管理 -分页列表查询")
@ApiOperation(value = "资产管理-曲线管理-分页列表查询", notes = "资产管理-曲线管理-分页列表查询")
......@@ -50,6 +55,15 @@ public class CurveManagementController extends JeecgController<CurveManagement,
@ApiOperation(value = "资产管理-曲线管理-编辑", notes = "资产管理-曲线管理-编辑")
@PostMapping(value = "/edit")
public Result<String> edit(@RequestBody CurveManagement curveManagement) {
railManagementService.verifyUnitDeviceConflicts(
curveManagement.getId(),
curveManagement.getLightRailId(),
curveManagement.getLineAliasId(),
curveManagement.getCurveMileageZh(),
curveManagement.getCurveMileageHz()
);
this.service.edit(curveManagement);
return Result.OK("编辑成功!");
}
......
......@@ -53,6 +53,15 @@ public class RailManagementController extends JeecgController<RailManagement, IR
@ApiOperation(value = "资产管理-钢轨管理-编辑", notes = "资产管理-钢轨管理-编辑")
@PostMapping(value = "/edit")
public Result<String> edit(@RequestBody RailManagement railManagement) {
this.service.verifyUnitDeviceConflicts(
railManagement.getId(),
railManagement.getLightRailId(),
railManagement.getLineAliasId(),
railManagement.getStartingMileage(),
railManagement.getEndMileage()
);
this.service.edit(railManagement);
return Result.OK("编辑成功!");
......@@ -75,16 +84,6 @@ public class RailManagementController extends JeecgController<RailManagement, IR
}
// @AutoLog(value = "资产管理-钢轨管理-智能生成")
// @ApiOperation(value = "资产管理-钢轨管理-智能生成", notes = "资产管理-钢轨管理-智能生成")
// @GetMapping(value = "/intelligentGeneration")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "lightRailId", value = "线路id")
// })
// public Result<String> intelligentGeneration(String lightRailId) {
// this.service.intelligentGeneration(lightRailId);
// return Result.OK("生成成功");
// }
@AutoLog(value = "资产管理-钢轨管理-智能生成")
@ApiOperation(value = "资产管理-钢轨管理-智能生成", notes = "资产管理-钢轨管理-智能生成")
@GetMapping(value = "/intelligentGeneration")
......@@ -92,8 +91,8 @@ public class RailManagementController extends JeecgController<RailManagement, IR
@ApiImplicitParam(name = "lightRailId", value = "线路id"),
@ApiImplicitParam(name = "lineAliasId", value = "线别id")
})
public Result<String> intelligentGeneration(String lightRailId,String lineAliasId) {
this.service.intelligentGeneration(lightRailId,lineAliasId);
public Result<String> intelligentGeneration(String lightRailId, String lineAliasId) {
this.service.intelligentGeneration(lightRailId, lineAliasId);
return Result.OK("生成成功");
}
......@@ -125,9 +124,10 @@ public class RailManagementController extends JeecgController<RailManagement, IR
// 2.如果有钢轨有空隙就返回空隙
// 3.如果钢轨没有空隙返回区间里程
// 4.如果返回过长的里程
Map<String, Object> map = this.service.getAddParams(lightRailId,lineAliasId,sectionId);
Map<String, Object> map = this.service.getAddParams(lightRailId, lineAliasId, sectionId);
return Result.OK(map);
}
}
......@@ -12,6 +12,7 @@ import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.deviceAsset.dto.SwitchManagementQueryDTO;
import org.jeecg.modules.deviceAsset.entity.SwitchManagement;
import org.jeecg.modules.deviceAsset.service.IRailManagementService;
import org.jeecg.modules.deviceAsset.service.ISwitchManagementService;
import org.jeecg.modules.deviceAsset.vo.SwitchManagementQueryVO;
import org.springframework.web.bind.annotation.*;
......@@ -30,7 +31,8 @@ import java.util.Arrays;
@RequestMapping("/deviceAsset/switchManagement")
@Slf4j
public class SwitchManagementController extends JeecgController<SwitchManagement, ISwitchManagementService> {
@Resource
private IRailManagementService railManagementService;
@AutoLog(value = "资产管理-道岔管理-分页列表查询")
@ApiOperation(value = "资产管理-道岔管理-分页列表查询", notes = "资产管理-道岔管理-分页列表查询")
......@@ -48,6 +50,14 @@ public class SwitchManagementController extends JeecgController<SwitchManagement
@ApiOperation(value = "资产管理-道岔管理-编辑", notes = "资产管理-道岔管理-编辑")
@PostMapping(value = "/edit")
public Result<String> edit(@RequestBody SwitchManagement switchManagement) {
railManagementService.verifyUnitDeviceConflicts(
switchManagement.getId(),
switchManagement.getLightRailId(),
switchManagement.getLineAliasId(),
switchManagement.getByroadPreMileage(),
switchManagement.getByroadCenterMileage()
);
this.service.edit(switchManagement);
......@@ -81,6 +91,7 @@ public class SwitchManagementController extends JeecgController<SwitchManagement
this.service.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@AutoLog(value = "资产管理-道岔管理-校验道岔编码重复")
@ApiOperation(value = "资产管理-道岔管理-校验道岔编码重复", notes = "资产管理-轨枕管理-校验道岔编码重复")
@GetMapping(value = "/checkSwitchCodeRepeat")
......
......@@ -13,6 +13,7 @@ import org.jeecg.modules.deviceAsset.dto.CurveManagementDTO;
import org.jeecg.modules.deviceAsset.dto.VerticalCurveManagementDTO;
import org.jeecg.modules.deviceAsset.entity.CurveManagement;
import org.jeecg.modules.deviceAsset.entity.VerticalCurveManagement;
import org.jeecg.modules.deviceAsset.service.IRailManagementService;
import org.jeecg.modules.deviceAsset.service.IVerticalCurveManagementService;
import org.jeecg.modules.deviceAsset.vo.CurveManagementQueryVO;
import org.jeecg.modules.deviceAsset.vo.VerticalCurveManagementVO;
......@@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
import org.jeecg.common.system.base.controller.JeecgController;
import javax.annotation.Resource;
import java.util.Arrays;
/**
......@@ -34,6 +36,9 @@ import java.util.Arrays;
@RequestMapping("/deviceAsset/verticalCurveManagement")
@Api(tags = "资产管理-竖曲线管理")
public class VerticalCurveManagementController extends JeecgController<VerticalCurveManagement, IVerticalCurveManagementService> {
@Resource
private IRailManagementService railManagementService;
@AutoLog(value = "资产管理-竖曲线管理-分页列表查询")
@ApiOperation(value = "资产管理-竖曲线管理-分页列表查询", notes = "资产管理-竖曲线管理-分页列表查询")
@GetMapping(value = "/list")
......@@ -50,6 +55,16 @@ public class VerticalCurveManagementController extends JeecgController<VerticalC
@ApiOperation(value = "资产管理-竖曲线管理-编辑", notes = "资产管理-竖曲线管理-编辑")
@PostMapping(value = "/edit")
public Result<String> edit(@RequestBody VerticalCurveManagement verticalCurveManagement) {
railManagementService.verifyUnitDeviceConflicts(
verticalCurveManagement.getId(),
verticalCurveManagement.getLightRailId(),
verticalCurveManagement.getLineAliasId(),
verticalCurveManagement.getStartingMileage(),
verticalCurveManagement.getEndMileage()
);
this.service.edit(verticalCurveManagement);
return Result.OK("编辑成功!");
......
package org.jeecg.modules.deviceAsset.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
......@@ -92,4 +93,8 @@ public class CurveManagement implements Serializable {
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "线路id")
@TableField(exist = false)
private String lightRailId;
}
package org.jeecg.modules.deviceAsset.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
......@@ -77,4 +78,8 @@ public class SwitchManagement implements Serializable {
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "线路id")
@TableField(exist = false)
private String lightRailId;
}
......@@ -2,9 +2,11 @@ package org.jeecg.modules.deviceAsset.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
......@@ -89,5 +91,8 @@ public class VerticalCurveManagement implements Serializable {
@TableField("remark")
private String remark;
@ApiModelProperty(value = "线路id")
@TableField(exist = false)
private String lightRailId;
}
......@@ -6,6 +6,7 @@ import org.jeecg.modules.deviceAsset.entity.RailManagement;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.deviceAsset.vo.RailManagementVO;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
......@@ -25,7 +26,7 @@ public interface IRailManagementService extends IService<RailManagement> {
void intelligentGeneration(String lightRailId);
void intelligentGeneration(String lightRailId,String lineAliasId);
void intelligentGeneration(String lightRailId, String lineAliasId);
/**
* 获取线路的特殊钢轨
......@@ -37,4 +38,9 @@ public interface IRailManagementService extends IService<RailManagement> {
Long checkRailCodeRepeat(String id, String lightRailId, String railCode);
Map<String, Object> getAddParams(String lightRailId, String lineAliasId, String sectionId);
/**
* 验证单元设备是否冲突
*/
void verifyUnitDeviceConflicts(String unitDeviceId, String lightRailId, String lineAliasId, BigDecimal startMileage, BigDecimal endMileage);
}
......@@ -26,9 +26,6 @@ import javax.annotation.Resource;
@Service
public class CurveManagementServiceImpl extends ServiceImpl<CurveManagementMapper, CurveManagement> implements ICurveManagementService {
@Resource
private LineAliasMapper lineAliasMapper;
@Override
public Page<CurveManagementQueryVO> queryPageList(Page<CurveManagementQueryVO> pageData, CurveManagementDTO dto) {
return this.baseMapper.queryPageList(pageData, dto);
......@@ -50,6 +47,6 @@ public class CurveManagementServiceImpl extends ServiceImpl<CurveManagementMappe
@Override
public Long checkCurveCodeRepeat(String id, String lightRailId, String curveCode) {
return this.baseMapper.checkCurveCodeRepeat(id,lightRailId,curveCode);
return this.baseMapper.checkCurveCodeRepeat(id, lightRailId, curveCode);
}
}
......@@ -6,6 +6,7 @@ import cn.hutool.extra.pinyin.PinyinUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.UUIDGenerator;
import org.jeecg.config.AsyncTask;
import org.jeecg.modules.deviceAsset.dto.RailManagementDTO;
......@@ -215,15 +216,21 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
allRailList.addAll(innerRailList);
}
// 只有一个的情况下做一个判断第一个单元可能只有半截
// 只有一个单元
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) {
List<RailManagement> innerRailList = this.generate(currentEndMileage, endMileage, lineAliasId);
allRailList.addAll(innerRailList);
}
}
continue;
}
......@@ -279,10 +286,17 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
allRailList.addAll(innerRailList);
}
// 只有一个的情况下做一个判断第一个单元可能只有半截
// 只有一个单元
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);
}
// ③ 线路终点里程 > 最后一个单元结束里程,要补充[最后一个单元结束里程,线路终点里程]
if (endMileage.subtract(currentEndMileage).compareTo(BigDecimal.ZERO) > 0) {
List<RailManagement> innerRailList = this.generate(currentEndMileage, endMileage, lineAliasId);
allRailList.addAll(innerRailList);
}
......@@ -596,4 +610,45 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
map.put("endMileage", subwayEndMileage);
return map;
}
@Override
public void verifyUnitDeviceConflicts(String unitDeviceId, String lightRailId, String lineAliasId, BigDecimal startMileage, BigDecimal endMileage) {
// 1. 获取所有设备
List<Map<String, Object>> lineSpecialRail = this.getLineSpecialRail(lightRailId, lineAliasId);
if (ObjectUtil.isEmpty(lineSpecialRail)) {
return;
}
// 2.循环判断里程是否冲突
for (Map<String, Object> currentMap : lineSpecialRail) {
BigDecimal currentStartMileage = Convert.toBigDecimal(currentMap.get("startMileage"));
BigDecimal currentEndMileage = Convert.toBigDecimal(currentMap.get("endMileage"));
String id = Convert.toStr(currentMap.get("id"));
String typeName = Convert.toStr(currentMap.get("typeName"));
String deviceCode = Convert.toStr(currentMap.get("deviceCode"));
// 如果是更新,排除自己
if (id.equals(unitDeviceId)) {
continue;
}
// 判断区间是否重叠
if (currentStartMileage.compareTo(startMileage) == 0 && currentEndMileage.compareTo(endMileage) == 0) {
throw JeecgBootException.error("新增单元里程和【" + typeName + "编号:" + deviceCode + "】里程冲突");
}
// 判断开始里程是否是否冲突
if (currentStartMileage.compareTo(startMileage) <= 0 && currentEndMileage.compareTo(startMileage) >= 0) {
throw JeecgBootException.error("新增单元里程和 "+typeName+"单元【" + typeName + "编号:" + deviceCode + "】里程冲突");
}
// 判断结束里程是否是否冲突
if (currentStartMileage.compareTo(endMileage) <= 0 && currentEndMileage.compareTo(endMileage) >= 0) {
throw JeecgBootException.error("新增单元里程和【" + typeName + "编号:" + deviceCode + "】里程冲突");
}
}
}
}
......@@ -49,6 +49,6 @@
LEFT JOIN t_sn_light_rail t3 on t1.light_rail_id = t3.id
LEFT JOIN t_sn_line_alias t4 ON t1.line_alias_id = t4.id
WHERE t3.status = 1
ORDER BY startMileage,line_alias_id
ORDER BY startMileage,end_mileage,line_alias_id
</select>
</mapper>
\ No newline at end of file
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