Showing
1 changed file
with
19 additions
and
8 deletions
| @@ -481,11 +481,7 @@ public class ContractDistributorStandardServiceImpl extends | @@ -481,11 +481,7 @@ public class ContractDistributorStandardServiceImpl extends | ||
| 481 | throw new DefaultClientException("合同编号不能为空!"); | 481 | throw new DefaultClientException("合同编号不能为空!"); |
| 482 | } | 482 | } |
| 483 | // 编号查重:全表校验(含已删除状态),保证新增合同编号不重复 | 483 | // 编号查重:全表校验(含已删除状态),保证新增合同编号不重复 |
| 484 | - long codeCount = count(Wrappers.lambdaQuery(ContractDistributorStandard.class) | ||
| 485 | - .eq(ContractDistributorStandard::getCode, vo.getCode())); | ||
| 486 | - if (codeCount > 0) { | ||
| 487 | - throw new DefaultClientException("合同编号[" + vo.getCode() + "]已存在,请勿重复使用!"); | ||
| 488 | - } | 484 | + assertCodeUnique(vo.getCode(), null); |
| 489 | 485 | ||
| 490 | ContractDistributorStandard data = new ContractDistributorStandard(); | 486 | ContractDistributorStandard data = new ContractDistributorStandard(); |
| 491 | data.setId(IdUtil.getUUID()); | 487 | data.setId(IdUtil.getUUID()); |
| @@ -531,6 +527,18 @@ public class ContractDistributorStandardServiceImpl extends | @@ -531,6 +527,18 @@ public class ContractDistributorStandardServiceImpl extends | ||
| 531 | return data; | 527 | return data; |
| 532 | } | 528 | } |
| 533 | 529 | ||
| 530 | + /** | ||
| 531 | + * 编号查重:按 code_unique 全表校验(锁价子合同与原合同同编号、code_unique 为空,不参与唯一性;excludeId 用于修改场景排除自身) | ||
| 532 | + */ | ||
| 533 | + private void assertCodeUnique(String code, String excludeId) { | ||
| 534 | + long codeCount = count(Wrappers.lambdaQuery(ContractDistributorStandard.class) | ||
| 535 | + .eq(ContractDistributorStandard::getCodeUnique, code) | ||
| 536 | + .ne(StringUtils.isNotBlank(excludeId), ContractDistributorStandard::getId, excludeId)); | ||
| 537 | + if (codeCount > 0) { | ||
| 538 | + throw new DefaultClientException("合同编号[" + code + "]已被其他合同使用,请修改后重试!"); | ||
| 539 | + } | ||
| 540 | + } | ||
| 541 | + | ||
| 534 | @OpLog(type = OtherOpLogType.class, name = "修改合同,ID:{}", params = {"#id"}) | 542 | @OpLog(type = OtherOpLogType.class, name = "修改合同,ID:{}", params = {"#id"}) |
| 535 | @Transactional(rollbackFor = Exception.class) | 543 | @Transactional(rollbackFor = Exception.class) |
| 536 | @Override | 544 | @Override |
| @@ -569,7 +577,8 @@ public class ContractDistributorStandardServiceImpl extends | @@ -569,7 +577,8 @@ public class ContractDistributorStandardServiceImpl extends | ||
| 569 | 577 | ||
| 570 | LambdaUpdateWrapper<ContractDistributorStandard> updateWrapper = Wrappers.lambdaUpdate(ContractDistributorStandard.class) | 578 | LambdaUpdateWrapper<ContractDistributorStandard> updateWrapper = Wrappers.lambdaUpdate(ContractDistributorStandard.class) |
| 571 | .set(ContractDistributorStandard::getCode, vo.getCode()) | 579 | .set(ContractDistributorStandard::getCode, vo.getCode()) |
| 572 | - .set(ContractDistributorStandard::getCodeUnique, vo.getCode()) | 580 | + // 锁价子合同与原合同同编号,不参与编号唯一性(code_unique 保持为空) |
| 581 | + .set(data.getPriceLockUserId() == null, ContractDistributorStandard::getCodeUnique, vo.getCode()) | ||
| 573 | .set(ContractDistributorStandard::getSupplier, vo.getSupplier()) | 582 | .set(ContractDistributorStandard::getSupplier, vo.getSupplier()) |
| 574 | .set(ContractDistributorStandard::getBuyer, vo.getBuyer()) | 583 | .set(ContractDistributorStandard::getBuyer, vo.getBuyer()) |
| 575 | .set(vo.getDeptId() != null, ContractDistributorStandard::getDeptId, vo.getDeptId()) | 584 | .set(vo.getDeptId() != null, ContractDistributorStandard::getDeptId, vo.getDeptId()) |
| @@ -809,7 +818,8 @@ public class ContractDistributorStandardServiceImpl extends | @@ -809,7 +818,8 @@ public class ContractDistributorStandardServiceImpl extends | ||
| 809 | 818 | ||
| 810 | LambdaUpdateWrapper<ContractDistributorStandard> updateWrapper = Wrappers.lambdaUpdate(ContractDistributorStandard.class) | 819 | LambdaUpdateWrapper<ContractDistributorStandard> updateWrapper = Wrappers.lambdaUpdate(ContractDistributorStandard.class) |
| 811 | .set(ContractDistributorStandard::getCode, vo.getCode()) | 820 | .set(ContractDistributorStandard::getCode, vo.getCode()) |
| 812 | - .set(ContractDistributorStandard::getCodeUnique, vo.getCode()) | 821 | + // 锁价子合同与原合同同编号,不参与编号唯一性(code_unique 保持为空) |
| 822 | + .set(data.getPriceLockUserId() == null, ContractDistributorStandard::getCodeUnique, vo.getCode()) | ||
| 813 | .set(ContractDistributorStandard::getSupplier, vo.getSupplier()) | 823 | .set(ContractDistributorStandard::getSupplier, vo.getSupplier()) |
| 814 | .set(ContractDistributorStandard::getBuyer, vo.getBuyer()) | 824 | .set(ContractDistributorStandard::getBuyer, vo.getBuyer()) |
| 815 | .set(vo.getDeptId() != null, ContractDistributorStandard::getDeptId, vo.getDeptId()) | 825 | .set(vo.getDeptId() != null, ContractDistributorStandard::getDeptId, vo.getDeptId()) |
| @@ -1166,7 +1176,8 @@ public class ContractDistributorStandardServiceImpl extends | @@ -1166,7 +1176,8 @@ public class ContractDistributorStandardServiceImpl extends | ||
| 1166 | 1176 | ||
| 1167 | LambdaUpdateWrapper<ContractDistributorStandard> updateWrapper = Wrappers.lambdaUpdate(ContractDistributorStandard.class) | 1177 | LambdaUpdateWrapper<ContractDistributorStandard> updateWrapper = Wrappers.lambdaUpdate(ContractDistributorStandard.class) |
| 1168 | .set(ContractDistributorStandard::getCode, vo.getCode()) | 1178 | .set(ContractDistributorStandard::getCode, vo.getCode()) |
| 1169 | - .set(ContractDistributorStandard::getCodeUnique, vo.getCode()) | 1179 | + // 锁价子合同与原合同同编号,不参与编号唯一性(code_unique 保持为空) |
| 1180 | + .set(data.getPriceLockUserId() == null, ContractDistributorStandard::getCodeUnique, vo.getCode()) | ||
| 1170 | .set(ContractDistributorStandard::getSupplier, vo.getSupplier()) | 1181 | .set(ContractDistributorStandard::getSupplier, vo.getSupplier()) |
| 1171 | .set(ContractDistributorStandard::getBuyer, vo.getBuyer()) | 1182 | .set(ContractDistributorStandard::getBuyer, vo.getBuyer()) |
| 1172 | .set(vo.getDeptId() != null, ContractDistributorStandard::getDeptId, vo.getDeptId()) | 1183 | .set(vo.getDeptId() != null, ContractDistributorStandard::getDeptId, vo.getDeptId()) |