Commit 2b42c19a authored by hkl's avatar hkl

feat:1.修改bug

parent 867f3bf0
......@@ -74,10 +74,6 @@
<properties>
<package.environment>hkl</package.environment>
</properties>
<!-- 是否默认 true表示默认-->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- 测试环境 -->
......@@ -94,6 +90,10 @@
<properties>
<package.environment>pressure</package.environment>
</properties>
<!-- 是否默认 true表示默认-->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- 生成环境环境-->
......
......@@ -14,6 +14,7 @@ import org.jeecg.modules.deviceAsset.dto.FastenerManagementDTO;
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.vo.FastenerManagementVO;
import org.jeecg.modules.deviceAsset.vo.SignBoardManagementVO;
......@@ -28,6 +29,7 @@ import org.jeecg.common.system.base.controller.JeecgController;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
/**
* <p>
......@@ -71,7 +73,17 @@ public class SignBoardManagementController extends JeecgController<SignBoardMana
lightRailEndMileage = lightRail.getDownLineMileage();
}
if (signBoardManagement.getMileage().compareTo(lightRailEndMileage) > 0) {
throw JeecgBootException.error("新增道床结束里程超过:" + lightRail.getRailLineName() + "的" + lineAlias.getLineAliasName() + "的结束里程【" + lightRailEndMileage + "】");
throw JeecgBootException.error("轨行区标识牌超过:" + lightRail.getRailLineName() + "的" + lineAlias.getLineAliasName() + "的结束里程【" + lightRailEndMileage + "】");
}
Long count = 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() + "】里程冲突");
}
......
......@@ -2,11 +2,9 @@ package org.jeecg.modules.deviceAsset.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.jeecg.common.api.vo.Result;
......@@ -28,7 +26,6 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* <p>
......@@ -64,7 +61,27 @@ public class TrackBedManagementController extends JeecgController<TrackBedManage
@ApiOperation(value = "资产管理-道床管理-编辑", notes = "资产管理-道床管理-编辑")
@PostMapping(value = "/edit")
public Result<String> edit(@RequestBody TrackBedManagement trackBedManagement) {
// 1.查询当前车站的上下行里程&获取所有设备
// 1.验证参数
verifyEditParams(trackBedManagement);
// 2.执行保存
if (ObjectUtil.isEmpty(trackBedManagement.getId())) {
trackBedManagement.setId(UUIDGenerator.generate());
this.service.save(trackBedManagement);
} else {
this.service.updateById(trackBedManagement);
}
return Result.OK("编辑成功!");
}
/**
* 验证参数
*
* @param trackBedManagement
*/
private void verifyEditParams(TrackBedManagement trackBedManagement) {
LightRail lightRail = lightRailService.getById(trackBedManagement.getLightRailId());
LineAlias lineAlias = lineAliasService.getById(trackBedManagement.getLineAliasId());
BigDecimal lightRailEndMileage = lightRail.getUpLineMileage();
......@@ -75,15 +92,41 @@ public class TrackBedManagementController extends JeecgController<TrackBedManage
throw JeecgBootException.error("新增道床结束里程超过:" + lightRail.getRailLineName() + "的" + lineAlias.getLineAliasName() + "的结束里程【" + lightRailEndMileage + "】");
}
List<TrackBedManagement> listRecord = this.service.lambdaQuery()
.eq(TrackBedManagement::getSectionId, trackBedManagement.getSectionId())
.eq(TrackBedManagement::getLineAliasId, trackBedManagement.getLineAliasId())
.orderByDesc(TrackBedManagement::getStartingMileage)
.list();
if (ObjectUtil.isEmpty(trackBedManagement.getId())) {
trackBedManagement.setId(UUIDGenerator.generate());
this.service.save(trackBedManagement);
} else {
this.service.updateById(trackBedManagement);
}
for (TrackBedManagement record : listRecord) {
return Result.OK("编辑成功!");
// 如果是更新,排除自己
if (record.getId().equals(trackBedManagement.getId())) {
continue;
}
BigDecimal currentStartMileage = record.getStartingMileage();
BigDecimal currentEndMileage = record.getEndMileage();
BigDecimal startMileage = trackBedManagement.getStartingMileage();
BigDecimal endMileage = trackBedManagement.getEndMileage();
String deviceCode = trackBedManagement.getTrackBedCode();
// 判断区间是否重叠
if (currentStartMileage.compareTo(startMileage) == 0 && currentEndMileage.compareTo(endMileage) == 0) {
throw JeecgBootException.error("和【道床编号:" + deviceCode + "】里程冲突");
}
// 判断开始里程是否是否冲突
if (currentStartMileage.compareTo(startMileage) < 0 && currentEndMileage.compareTo(startMileage) > 0) {
throw JeecgBootException.error("和【道床编号:" + deviceCode + "】里程冲突");
}
// 判断结束里程是否是否冲突
if (currentStartMileage.compareTo(endMileage) < 0 && currentEndMileage.compareTo(endMileage) > 0) {
throw JeecgBootException.error("和【道床编号:" + deviceCode + "】里程冲突");
}
}
}
/**
......
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