|
@@ -190,6 +190,8 @@ public class TqContractServiceImpl implements ITqContractService
|
|
|
Long.valueOf(tqContractDto.getCurrencyId()),
|
|
|
tqContractDto.getSigningDate()
|
|
|
));
|
|
|
+ //将合同的初始version设置为1
|
|
|
+ tqContractDto.setVersion(1L);
|
|
|
Map<Long, BigDecimal> idAndRateMap = tbContractCurrencyService.selectExchangeRateByCurrencyId(contractCurrencyTimeList);
|
|
|
//将签单币种汇率赋值
|
|
|
if(idAndRateMap.containsKey(Long.parseLong(tqContractDto.getCurrencyId()))){
|
|
@@ -222,14 +224,33 @@ public class TqContractServiceImpl implements ITqContractService
|
|
|
public int updateTqContract(TqContractDto tqContractDto)
|
|
|
{
|
|
|
List<TqContractLift> tqContractLiftList = tqContractDto.getTqContractLiftList();
|
|
|
+ String type = tqContractDto.getType();
|
|
|
+ //如果是变更或者作废 将版本+1
|
|
|
+ if("amendment".equals(type) || "toVoid".equals(type)){
|
|
|
+ tqContractDto.setVersion(tqContractDto.getVersion() + 1L);
|
|
|
+ }
|
|
|
+ //如果是变更的数据 先将所有的 设备数据的id清空
|
|
|
+ if("amendment".equals(type)){
|
|
|
+ List<TqContractLift> liftList = tqContractDto.getTqContractLiftList();
|
|
|
+ if (liftList != null) {
|
|
|
+ liftList.forEach(item -> item.setId(null));
|
|
|
+ }
|
|
|
+ tqContractDto.setTqContractLiftList(liftList);
|
|
|
+ }
|
|
|
if(CollectionUtils.isNotEmpty(tqContractLiftList)){
|
|
|
//获取设备更新List
|
|
|
List<TqContractLift> tqContractLiftUpdateList = tqContractLiftList.stream().filter(item-> item.getId() != null).collect(Collectors.toList());
|
|
|
List<Long> idList = tqContractLiftUpdateList.stream().map(item->item.getId()).collect(Collectors.toList());
|
|
|
- //删除当前合同下不存在的设备番号
|
|
|
- if(CollectionUtils.isNotEmpty(idList)){
|
|
|
- tqContractLiftMapper.deleteTqContractLiftByNoId(tqContractDto.getContractNo(),idList);
|
|
|
+ //如果是变更 就不存在删除 只有新增
|
|
|
+ if("amendment".equals(type)){
|
|
|
+ //将现在的
|
|
|
+ }else{
|
|
|
+ //删除当前合同下不存在的设备番号
|
|
|
+ if(CollectionUtils.isNotEmpty(idList)){
|
|
|
+ tqContractLiftMapper.deleteTqContractLiftByNoId(tqContractDto.getContractNo(),tqContractDto.getVersion(),idList);
|
|
|
+ }
|
|
|
}
|
|
|
+ //获取update数据
|
|
|
if(CollectionUtils.isNotEmpty(tqContractLiftUpdateList)){
|
|
|
tqContractLiftUpdateList = attachTqContractLift(tqContractDto,tqContractLiftUpdateList);
|
|
|
tqContractLiftMapper.updateTqContractLiftBatch(tqContractLiftUpdateList);
|
|
@@ -304,9 +325,9 @@ public class TqContractServiceImpl implements ITqContractService
|
|
|
.collect(Collectors.toList());
|
|
|
Map<Long, BigDecimal> deliveryListIdAndRateMap = tbContractCurrencyService.selectExchangeRateByCurrencyId(deliveryList);
|
|
|
|
|
|
- //获取版本
|
|
|
- Long version = tqContractLiftHistoryMapper.selectVersionMaxFromHistory(tqContractDto.getContractNo());
|
|
|
- String contractNoVersionNo = version == null ? "1": String.valueOf(version+1L);
|
|
|
+// //获取版本
|
|
|
+// Long version = tqContractLiftHistoryMapper.selectVersionMaxFromHistory(tqContractDto.getContractNo());
|
|
|
+// String contractNoVersionNo = version == null ? "1": String.valueOf(version+1L);
|
|
|
tqContractLiftList.forEach(item -> {
|
|
|
item.setContractNo(tqContractDto.getContractNo());
|
|
|
item.setContractName(tqContractDto.getContractName());
|
|
@@ -323,7 +344,7 @@ public class TqContractServiceImpl implements ITqContractService
|
|
|
item.setSigningDate(tqContractDto.getSigningDate());
|
|
|
item.setContractAmendmentDate(new Date());
|
|
|
item.setPaymentRatio(tqContractDto.getPaymentRatio());
|
|
|
- item.setContractNoVersionNo(tqContractDto.getContractNo()+"-"+contractNoVersionNo);
|
|
|
+ item.setContractNoVersionNo(tqContractDto.getContractNo()+"-"+tqContractDto.getVersion());
|
|
|
item.setPermissionChar(SecurityUtils.getPermissionCharIns());
|
|
|
item.setRate4SigningContracts(tqContractDto.getRate4SigningContracts());
|
|
|
//将签单币种汇率赋值
|