|
@@ -2,8 +2,6 @@ package com.jzg.organization.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
import cn.hutool.core.convert.Convert;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -15,10 +13,7 @@ import com.jzg.commons.entity.dto.AgreementEditParam;
|
|
|
import com.jzg.commons.entity.dto.AgreementParam;
|
|
import com.jzg.commons.entity.dto.AgreementParam;
|
|
|
import com.jzg.commons.entity.enums.YesNoEnum;
|
|
import com.jzg.commons.entity.enums.YesNoEnum;
|
|
|
import com.jzg.commons.entity.po.*;
|
|
import com.jzg.commons.entity.po.*;
|
|
|
-import com.jzg.commons.entity.vo.AgreementInfoVo;
|
|
|
|
|
-import com.jzg.commons.entity.vo.AgreementUserVo;
|
|
|
|
|
-import com.jzg.commons.entity.vo.AgreementVo;
|
|
|
|
|
-import com.jzg.commons.entity.vo.UpAndDownVo;
|
|
|
|
|
|
|
+import com.jzg.commons.entity.vo.*;
|
|
|
import com.jzg.commons.exception.SystemException;
|
|
import com.jzg.commons.exception.SystemException;
|
|
|
import com.jzg.commons.util.MinioUtils;
|
|
import com.jzg.commons.util.MinioUtils;
|
|
|
import com.jzg.commons.util.StringUtils;
|
|
import com.jzg.commons.util.StringUtils;
|
|
@@ -35,9 +30,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -71,6 +64,12 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private PtlAgreementCostService agreementCostService;
|
|
private PtlAgreementCostService agreementCostService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private PtlAgreementCostRuleService agreementCostRuleService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private PtlAgreementCostTypeService agreementCostTypeService;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private PtlAgreementUndwrtRulesAttrService agreementUndwrtRulesAttrService;
|
|
private PtlAgreementUndwrtRulesAttrService agreementUndwrtRulesAttrService;
|
|
|
|
|
|
|
@@ -230,18 +229,122 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
public void agreementCopy(AgreementCopyParam param) {
|
|
public void agreementCopy(AgreementCopyParam param) {
|
|
|
|
|
+ PtlAgreement agreement = getById(param.getId());
|
|
|
|
|
+ // 获取保险公司信息
|
|
|
|
|
+ HttpResult<EsmInsCompany> result = companyClient.findById(agreement.getCompanyId());
|
|
|
|
|
+ String companyCode = "";
|
|
|
|
|
+ if(result.getCode() == 200 && Objects.nonNull(result.getData())){
|
|
|
|
|
+ companyCode = result.getData().getCompanyCode();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ throw new SystemException("无法获取到保险公司信息");
|
|
|
|
|
+ }
|
|
|
|
|
+ String sysCode = baseController.getUserSystemCode();
|
|
|
|
|
+ PtlAgreement newAgreement = new PtlAgreement();
|
|
|
|
|
+ BeanUtils.copyProperties(agreement,newAgreement);
|
|
|
|
|
+ newAgreement.setId(null);
|
|
|
|
|
+ newAgreement.setAgreementCode(sysCode + companyCode + +System.currentTimeMillis());
|
|
|
|
|
+ newAgreement.setAuditStatus(0);
|
|
|
|
|
+ save(newAgreement);
|
|
|
|
|
+
|
|
|
List<String> costIds = param.getCostIds();
|
|
List<String> costIds = param.getCostIds();
|
|
|
List<PtlAgreementCost> costList = agreementCostService.listByIds(costIds);
|
|
List<PtlAgreementCost> costList = agreementCostService.listByIds(costIds);
|
|
|
if(CollUtil.isEmpty(costList)){
|
|
if(CollUtil.isEmpty(costList)){
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- Set<String> agreementIds = costList.stream().map(PtlAgreementCost::getPtlAgreementId)
|
|
|
|
|
- .collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
|
|
+ Map<String,List<PtlAgreementCost>> costGroup = new HashMap<>();
|
|
|
|
|
+ for (PtlAgreementCost ptlAgreementCost : costList) {
|
|
|
|
|
+ List<PtlAgreementCost> costGroupList = new ArrayList<>();
|
|
|
|
|
+ if(costGroup.containsKey(ptlAgreementCost.getCoverRuleId())){
|
|
|
|
|
+ costGroupList = costGroup.get(ptlAgreementCost.getCoverRuleId());
|
|
|
|
|
+ costGroupList.add(ptlAgreementCost);
|
|
|
|
|
+ costGroup.put(ptlAgreementCost.getCoverRuleId(), costGroupList);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ costGroupList.add(ptlAgreementCost);
|
|
|
|
|
+ costGroup.put(ptlAgreementCost.getCoverRuleId(), costGroupList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ /** 复制承保规则和费用 **/
|
|
|
|
|
+ this.copyRuleAndCost(costGroup,costIds,costList,newAgreement);
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void copyRuleAndCost(Map<String, List<PtlAgreementCost>> costGroup,
|
|
|
|
|
+ List<String> costIds,
|
|
|
|
|
+ List<PtlAgreementCost> costList,
|
|
|
|
|
+ PtlAgreement newAgreement) {
|
|
|
|
|
+
|
|
|
|
|
+ // 获取查询所有的旧承保规则
|
|
|
|
|
+ Set<String> rulesIds = costList.stream().map(PtlAgreementCost :: getCoverRuleId).collect(Collectors.toSet());
|
|
|
|
|
+ List<PtlAgreementUndwrtRules> rulesList = agreementRulesService.listByIds(rulesIds);
|
|
|
|
|
+ Map<String, PtlAgreementUndwrtRules> rulesMap = rulesList.stream().collect(
|
|
|
|
|
+ Collectors.toMap(PtlAgreementUndwrtRules::getId,rules -> rules));
|
|
|
|
|
+
|
|
|
|
|
+ // 查询所有承保规则明细
|
|
|
|
|
+ LambdaQueryWrapper<PtlAgreementUndwrtRulesAttrLink> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.in(PtlAgreementUndwrtRulesAttrLink::getId, rulesIds);
|
|
|
|
|
+ List<PtlAgreementUndwrtRulesAttrLink> linkList = agreementUndwrtRulesAttrLinkService.list(queryWrapper);
|
|
|
|
|
+ Map<String, List<PtlAgreementUndwrtRulesAttrLink>> linkMap = linkList.stream().collect(
|
|
|
|
|
+ Collectors.groupingBy(PtlAgreementUndwrtRulesAttrLink::getRulesId));
|
|
|
|
|
+
|
|
|
|
|
+ // 查询所有旧的费用规则
|
|
|
|
|
+ LambdaQueryWrapper<PtlAgreementCostRule> costRuleLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ costRuleLambdaQueryWrapper.in(PtlAgreementCostRule::getPtlAgreementCostId, costIds);
|
|
|
|
|
+ List<PtlAgreementCostRule> costRuleList = agreementCostRuleService.list(costRuleLambdaQueryWrapper);
|
|
|
|
|
+ Map<String, List<PtlAgreementCostRule>> costRulesMap = costRuleList.stream().collect(
|
|
|
|
|
+ Collectors.groupingBy(PtlAgreementCostRule::getPtlAgreementCostId));
|
|
|
|
|
+ // 查询所有旧的费用明细
|
|
|
|
|
+ LambdaQueryWrapper<PtlAgreementCostType> costTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ costTypeLambdaQueryWrapper.in(PtlAgreementCostType::getPtlAgreementCostId, costIds);
|
|
|
|
|
+ List<PtlAgreementCostType> costTypeList = agreementCostTypeService.list(costTypeLambdaQueryWrapper);
|
|
|
|
|
+ Map<String, List<PtlAgreementCostType>> costTypeMap = costTypeList.stream().collect(
|
|
|
|
|
+ Collectors.groupingBy(PtlAgreementCostType::getPtlAgreementCostId));
|
|
|
|
|
+
|
|
|
|
|
+ costGroup.forEach((key, value) -> {
|
|
|
|
|
+
|
|
|
|
|
+ /** 1-承保规则复制 **/
|
|
|
|
|
+ PtlAgreementUndwrtRules agreementUndwrtRules = rulesMap.get(key);
|
|
|
|
|
+ PtlAgreementUndwrtRules newAgreementUndwrtRules = new PtlAgreementUndwrtRules();
|
|
|
|
|
+ BeanUtils.copyProperties(agreementUndwrtRules,newAgreementUndwrtRules);
|
|
|
|
|
+ newAgreementUndwrtRules.setId(null);
|
|
|
|
|
+ newAgreementUndwrtRules.setAgreementId(newAgreement.getId());
|
|
|
|
|
+ agreementRulesService.save(newAgreementUndwrtRules);
|
|
|
|
|
+
|
|
|
|
|
+ // 复制承保规则因子
|
|
|
|
|
+ List<PtlAgreementUndwrtRulesAttrLink> links = linkMap.get(agreementUndwrtRules.getId());
|
|
|
|
|
+ links.forEach(link -> {
|
|
|
|
|
+ link.setId(null);
|
|
|
|
|
+ link.setRulesId(newAgreementUndwrtRules.getId());
|
|
|
|
|
+ });
|
|
|
|
|
+ agreementUndwrtRulesAttrLinkService.saveBatch(links);
|
|
|
|
|
+
|
|
|
|
|
+ /** 2-费用复制 **/
|
|
|
|
|
+ List<PtlAgreementCost> agreementCostList = costGroup.get(key);
|
|
|
|
|
+ agreementCostList.forEach(agreementCost -> {
|
|
|
|
|
+ PtlAgreementCost newAgreementCost = new PtlAgreementCost();
|
|
|
|
|
+ BeanUtils.copyProperties(agreementCost,newAgreementCost);
|
|
|
|
|
+ newAgreementCost.setId(null);
|
|
|
|
|
+ newAgreementCost.setApproved(0);
|
|
|
|
|
+ newAgreementCost.setIsEnabled(Boolean.TRUE);
|
|
|
|
|
+ agreementCostService.save(newAgreementCost);
|
|
|
|
|
+ List<PtlAgreementCostRule> costRules = costRulesMap.get(agreementCost.getId());
|
|
|
|
|
+ costRules.forEach(costRule -> {
|
|
|
|
|
+ costRule.setId(null);
|
|
|
|
|
+ costRule.setPtlAgreementCostId(newAgreementCost.getId());
|
|
|
|
|
+ });
|
|
|
|
|
+ agreementCostRuleService.saveBatch(costRules);
|
|
|
|
|
+ List<PtlAgreementCostType> costTypes = costTypeMap.get(agreementCost.getId());
|
|
|
|
|
+ costTypes.forEach(costType -> {
|
|
|
|
|
+ costType.setId(null);
|
|
|
|
|
+ costType.setPtlAgreementCostId(newAgreementCost.getId());
|
|
|
|
|
+ });
|
|
|
|
|
+ agreementCostTypeService.saveBatch(costTypes);
|
|
|
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|