Showing
1 changed file
with
21 additions
and
2 deletions
| @@ -62,7 +62,6 @@ public class ContractFrameworkServiceImpl extends BaseMpServiceImpl<ContractFram | @@ -62,7 +62,6 @@ public class ContractFrameworkServiceImpl extends BaseMpServiceImpl<ContractFram | ||
| 62 | return getBaseMapper().query(vo); | 62 | return getBaseMapper().query(vo); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | - @Cacheable(value = ContractFramework.CACHE_NAME, key = "@cacheVariables.tenantId() + #id", unless = "#result == null") | ||
| 66 | @Override | 65 | @Override |
| 67 | public ContractFramework findById(String id) { | 66 | public ContractFramework findById(String id) { |
| 68 | 67 | ||
| @@ -77,6 +76,19 @@ public class ContractFrameworkServiceImpl extends BaseMpServiceImpl<ContractFram | @@ -77,6 +76,19 @@ public class ContractFrameworkServiceImpl extends BaseMpServiceImpl<ContractFram | ||
| 77 | if (ObjectUtil.isNull(data)) { | 76 | if (ObjectUtil.isNull(data)) { |
| 78 | throw new DefaultClientException("合同框架不存在!"); | 77 | throw new DefaultClientException("合同框架不存在!"); |
| 79 | } | 78 | } |
| 79 | + QueryContractFrameworkVo vo1 = new QueryContractFrameworkVo(); | ||
| 80 | + vo1.setCustomerId(vo.getCustomerId()); | ||
| 81 | + vo1.setCompany(vo.getCompany()); | ||
| 82 | + vo1.setMaterialTypeId(vo.getMaterialTypeId()); | ||
| 83 | + List<ContractFramework> query = this.query(vo1); | ||
| 84 | + if (CollectionUtils.isNotEmpty(query)) { | ||
| 85 | + // 过滤掉当前 ID 的记录,看是否还有其他记录 | ||
| 86 | + boolean hasOtherRecords = query.stream() | ||
| 87 | + .anyMatch(item -> !item.getId().equals(vo.getId())); | ||
| 88 | + if (hasOtherRecords) { | ||
| 89 | + throw new DefaultClientException("已经存在相同的框架合同!"); | ||
| 90 | + } | ||
| 91 | + } | ||
| 80 | 92 | ||
| 81 | LambdaUpdateWrapper<ContractFramework> updateWrapper = Wrappers.lambdaUpdate(ContractFramework.class) | 93 | LambdaUpdateWrapper<ContractFramework> updateWrapper = Wrappers.lambdaUpdate(ContractFramework.class) |
| 82 | .set(ContractFramework::getCode, vo.getCode()) | 94 | .set(ContractFramework::getCode, vo.getCode()) |
| @@ -97,7 +109,14 @@ public class ContractFrameworkServiceImpl extends BaseMpServiceImpl<ContractFram | @@ -97,7 +109,14 @@ public class ContractFrameworkServiceImpl extends BaseMpServiceImpl<ContractFram | ||
| 97 | @Transactional(rollbackFor = Exception.class) | 109 | @Transactional(rollbackFor = Exception.class) |
| 98 | @Override | 110 | @Override |
| 99 | public String create(CreateContractFrameworkVo vo) { | 111 | public String create(CreateContractFrameworkVo vo) { |
| 100 | - | 112 | + QueryContractFrameworkVo vo1 = new QueryContractFrameworkVo(); |
| 113 | + vo1.setCustomerId(vo.getCustomerId()); | ||
| 114 | + vo1.setCompany(vo.getCompany()); | ||
| 115 | + vo1.setMaterialTypeId(vo.getMaterialTypeId()); | ||
| 116 | + List<ContractFramework> query = this.query(vo1); | ||
| 117 | + if (CollectionUtils.isNotEmpty(query)) { | ||
| 118 | + throw new DefaultClientException("已经存在相同的框架合同!"); | ||
| 119 | + } | ||
| 101 | ContractFramework data = new ContractFramework(); | 120 | ContractFramework data = new ContractFramework(); |
| 102 | data.setId(IdUtil.getId()); | 121 | data.setId(IdUtil.getId()); |
| 103 | data.setCode(vo.getCode()); | 122 | data.setCode(vo.getCode()); |