|
|
@@ -393,66 +393,76 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
|
|
|
|
|
|
@GlobalTransactional
|
|
|
@Override
|
|
|
- public List<String> costCopy(PtlAgreementCostCopyParam costCopyParam) {
|
|
|
+ public HttpResult costCopy(PtlAgreementCostCopyParam costCopyParam) {
|
|
|
List<String> newCostId = new ArrayList<>();
|
|
|
List<String> costIds = costCopyParam.getCostIds();
|
|
|
+ StringBuilder errMsg = new StringBuilder();
|
|
|
costIds.forEach(oldCostId-> {
|
|
|
PtlAgreementCost ptlAgreementCost = ptlAgreementCostMapper.selectById(oldCostId);
|
|
|
- List<PtlAgreementCostType> ptlAgreementCostTypes = ptlAgreementCostTypeMapper.selectList(new LambdaQueryWrapper<PtlAgreementCostType>()
|
|
|
- .eq(PtlAgreementCostType::getPtlAgreementCostId, ptlAgreementCost.getId()));
|
|
|
- List<PtlAgreementCostRule> ptlAgreementCostRules = ptlAgreementCostRuleMapper.selectList(new LambdaQueryWrapper<PtlAgreementCostRule>()
|
|
|
- .eq(PtlAgreementCostRule::getPtlAgreementCostId, ptlAgreementCost.getId()));
|
|
|
-
|
|
|
- // 调整数据 进行copy
|
|
|
- String costId = IdGenerate.nextId();
|
|
|
- ptlAgreementCost.setId(costId);
|
|
|
- ptlAgreementCost.setCoverRuleId(costCopyParam.getCoverRuleId());
|
|
|
- ptlAgreementCost.setPtlAgreementId(costCopyParam.getAgreementId());
|
|
|
- ptlAgreementCost.setCostDescribe("复制的费用:" + ptlAgreementCost.getCostDescribe());
|
|
|
- ptlAgreementCost.setCreateTime(LocalDateTime.now());
|
|
|
- ptlAgreementCost.setUpdateTime(LocalDateTime.now());
|
|
|
- ptlAgreementCost.setProductId(costCopyParam.getProductId());
|
|
|
- ptlAgreementCost.setProductName(costCopyParam.getProductName());
|
|
|
- // 复制的费用为待审核
|
|
|
- ptlAgreementCost.setApproved(0);
|
|
|
-
|
|
|
-
|
|
|
- List<PtlAgreementCostType> newPtlAgreementCostTypes = ptlAgreementCostTypes.stream()
|
|
|
- .filter(item -> {
|
|
|
- String productId = costCopyParam.getProductId();
|
|
|
- // 单交剔除 CostType = 商业险
|
|
|
- if ("0330".equals(productId)) {
|
|
|
- return !"商业险".equals(item.getCostType());
|
|
|
- }
|
|
|
- // 单商剔除 CostType = 交强险
|
|
|
- if ("034001".equals(productId)) {
|
|
|
- return !"交强险".equals(item.getCostType());
|
|
|
- }
|
|
|
- // 单三剔除 CostType = 交强险
|
|
|
- if ("034002".equals(productId)) {
|
|
|
- return !"交强险".equals(item.getCostType());
|
|
|
- }
|
|
|
- return true;
|
|
|
- })
|
|
|
- .peek(item -> {
|
|
|
- // 给留存的元素赋值字段
|
|
|
- item.setId(IdGenerate.nextId());
|
|
|
- item.setPtlAgreementCostId(costId);
|
|
|
- })
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- ptlAgreementCostRules.forEach(item->{
|
|
|
- item.setId(IdGenerate.nextId());
|
|
|
- item.setPtlAgreementCostId(costId);
|
|
|
- });
|
|
|
+ if(ptlAgreementCost != null){
|
|
|
+ List<PtlAgreementCostType> ptlAgreementCostTypes = ptlAgreementCostTypeMapper.selectList(new LambdaQueryWrapper<PtlAgreementCostType>()
|
|
|
+ .eq(PtlAgreementCostType::getPtlAgreementCostId, ptlAgreementCost.getId()));
|
|
|
+ List<PtlAgreementCostRule> ptlAgreementCostRules = ptlAgreementCostRuleMapper.selectList(new LambdaQueryWrapper<PtlAgreementCostRule>()
|
|
|
+ .eq(PtlAgreementCostRule::getPtlAgreementCostId, ptlAgreementCost.getId()));
|
|
|
+
|
|
|
+ // 调整数据 进行copy
|
|
|
+ String costId = IdGenerate.nextId();
|
|
|
+ ptlAgreementCost.setId(costId);
|
|
|
+ ptlAgreementCost.setCoverRuleId(costCopyParam.getCoverRuleId());
|
|
|
+ ptlAgreementCost.setPtlAgreementId(costCopyParam.getAgreementId());
|
|
|
+ ptlAgreementCost.setCostDescribe("复制的费用:" + ptlAgreementCost.getCostDescribe());
|
|
|
+ ptlAgreementCost.setCreateTime(LocalDateTime.now());
|
|
|
+ ptlAgreementCost.setUpdateTime(LocalDateTime.now());
|
|
|
+ if(costCopyParam.getProductId() != null && !costCopyParam.getProductId().isEmpty()){
|
|
|
+ ptlAgreementCost.setProductId(costCopyParam.getProductId());
|
|
|
+ }
|
|
|
+ if(costCopyParam.getProductName() != null && !costCopyParam.getProductName().isEmpty()){
|
|
|
+ ptlAgreementCost.setProductName(costCopyParam.getProductName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 复制的费用为待审核
|
|
|
+ ptlAgreementCost.setApproved(0);
|
|
|
+ List<PtlAgreementCostType> newPtlAgreementCostTypes = ptlAgreementCostTypes.stream()
|
|
|
+ .filter(item -> {
|
|
|
+ String productId = costCopyParam.getProductId();
|
|
|
+ // 单交剔除 CostType = 商业险
|
|
|
+ if ("0330".equals(productId)) {
|
|
|
+ return !"商业险".equals(item.getCostType());
|
|
|
+ }
|
|
|
+ // 单商剔除 CostType = 交强险
|
|
|
+ if ("034001".equals(productId)) {
|
|
|
+ return !"交强险".equals(item.getCostType());
|
|
|
+ }
|
|
|
+ // 单三剔除 CostType = 交强险
|
|
|
+ if ("034002".equals(productId)) {
|
|
|
+ return !"交强险".equals(item.getCostType());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ })
|
|
|
+ .peek(item -> {
|
|
|
+ // 给留存的元素赋值字段
|
|
|
+ item.setId(IdGenerate.nextId());
|
|
|
+ item.setPtlAgreementCostId(costId);
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ ptlAgreementCostRules.forEach(item->{
|
|
|
+ item.setId(IdGenerate.nextId());
|
|
|
+ item.setPtlAgreementCostId(costId);
|
|
|
+ });
|
|
|
+
|
|
|
+ ptlAgreementCostMapper.insert(ptlAgreementCost);
|
|
|
+ ptlAgreementCostTypeMapper.insert(newPtlAgreementCostTypes);
|
|
|
+ ptlAgreementCostRuleMapper.insert(ptlAgreementCostRules);
|
|
|
+ newCostId.add(ptlAgreementCost.getId());
|
|
|
+
|
|
|
+ }else{
|
|
|
+ errMsg.append("costId为"+oldCostId+"的费用信息已被删除");
|
|
|
+ }
|
|
|
|
|
|
- ptlAgreementCostMapper.insert(ptlAgreementCost);
|
|
|
- ptlAgreementCostTypeMapper.insert(newPtlAgreementCostTypes);
|
|
|
- ptlAgreementCostRuleMapper.insert(ptlAgreementCostRules);
|
|
|
- newCostId.add(ptlAgreementCost.getId());
|
|
|
|
|
|
});
|
|
|
- return newCostId;
|
|
|
+ return HttpResult.ok(errMsg.toString(),newCostId);
|
|
|
}
|
|
|
|
|
|
@Override
|