feat(wms): 添加炉计划钢卷重复性校验功能

- 实现 planId 和 coilId 组合的唯一性检查
- 在更新操作时排除当前记录的重复校验
- 查询数据库验证相同计划下的钢卷是否存在
- 抛出运行时异常阻止重复添加相同钢卷到计划
- 完善数据校验逻辑确保业务规则正确执行
This commit is contained in:
2026-05-05 13:10:08 +08:00
parent 28755f77c7
commit 723ccc9e58

View File

@@ -95,7 +95,20 @@ public class WmsFurnacePlanCoilServiceImpl implements IWmsFurnacePlanCoilService
* 保存前的数据校验 * 保存前的数据校验
*/ */
private void validEntityBeforeSave(WmsFurnacePlanCoil entity){ private void validEntityBeforeSave(WmsFurnacePlanCoil entity){
//TODO 做一些数据校验,如唯一约束 // 检查是否已存在相同的planId和coilId组合
LambdaQueryWrapper<WmsFurnacePlanCoil> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(WmsFurnacePlanCoil::getPlanId, entity.getPlanId())
.eq(WmsFurnacePlanCoil::getCoilId, entity.getCoilId());
// 如果是更新操作,需要排除当前记录
if (entity.getPlanCoilId() != null) {
queryWrapper.ne(WmsFurnacePlanCoil::getPlanCoilId, entity.getPlanCoilId());
}
long count = baseMapper.selectCount(queryWrapper);
if (count > 0) {
throw new RuntimeException("该计划下已存在此钢卷,不能重复添加");
}
} }
/** /**