|
|
@@ -19,6 +19,7 @@ import com.jzg.commons.util.MinioUtils;
|
|
|
import com.jzg.commons.util.StringUtils;
|
|
|
import com.jzg.commons.util.idgen.IdGenerate;
|
|
|
import com.jzg.organization.client.EsmInsCompanyClient;
|
|
|
+import com.jzg.organization.mapper.PtlAgreementCostExternalMapper;
|
|
|
import com.jzg.organization.mapper.PtlAgreementMapper;
|
|
|
import com.jzg.organization.mapper.SysUploadFilesMapper;
|
|
|
import com.jzg.organization.mapper.SysUserMapper;
|
|
|
@@ -83,6 +84,8 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
|
|
|
|
|
|
@Autowired
|
|
|
private PtlAgreementCostExternalService ptlAgreementCostExternalService;
|
|
|
+ @Autowired
|
|
|
+ private PtlAgreementCostExternalTypeService ptlAgreementCostExternalTypeService;
|
|
|
|
|
|
/**
|
|
|
* 协议分页查询
|
|
|
@@ -437,6 +440,123 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
|
|
|
// 复制承保规则和费用
|
|
|
this.copyRuleAndCost(costGroup, allCostIds, costList, newAgreement);
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 内部协议复制到外部协议
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ public void agreementCopyOutToIn(AgreementCopyParam param) {
|
|
|
+ log.info("内部协议复制到外部协议。 param=[{}]", JSONUtil.toJsonStr(param));
|
|
|
+ if(param.getId().isEmpty()){
|
|
|
+ throw new SystemException("请选择您要复制的协议信息");
|
|
|
+ }
|
|
|
+ if(param.getDockingPerson().isEmpty()){
|
|
|
+ throw new SystemException("请填写对接人信息");
|
|
|
+ }
|
|
|
+ if(param.getDockingPhone().isEmpty()){
|
|
|
+ throw new SystemException("请填写对接人信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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{
|
|
|
+ log.info("根据协议agreement[{}]中的companyId[{}]无法获取到保险公司信息", JSONUtil.toJsonStr(agreement), agreement.getId());
|
|
|
+ throw new SystemException("根据公司id"+agreement.getCompanyId()+"无法获取到保险公司信息");
|
|
|
+ }
|
|
|
+ String sysCode = baseController.getUserSystemCode();
|
|
|
+ PtlAgreement newAgreement = new PtlAgreement();
|
|
|
+ BeanUtils.copyProperties(agreement,newAgreement);
|
|
|
+ newAgreement.setId(null);
|
|
|
+ newAgreement.setAgreementTitle(LocalDateTime.now().getSecond() + agreement.getAgreementTitle());
|
|
|
+ newAgreement.setAgreementCode(sysCode + companyCode + System.currentTimeMillis());
|
|
|
+ newAgreement.setAuditStatus(0);
|
|
|
+ newAgreement.setCreateTime(LocalDateTime.now());
|
|
|
+ newAgreement.setUpdateTime(LocalDateTime.now());
|
|
|
+ // 外部协议
|
|
|
+ newAgreement.setIsExternal(1);
|
|
|
+ // 根据测试反馈,复制后的协议,默认应该是停用状态
|
|
|
+ newAgreement.setIsEnable(1);
|
|
|
+ save(newAgreement);
|
|
|
+
|
|
|
+ List<String> costIds = param.getCostIds();
|
|
|
+ if(CollUtil.isEmpty(costIds)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<PtlAgreementCost> selectedCostList = agreementCostService.listByIds(costIds);
|
|
|
+ if (CollUtil.isEmpty(selectedCostList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Set<String> allCostIds = selectedCostList.stream().map(PtlAgreementCost::getId).collect(Collectors.toSet());
|
|
|
+ LambdaQueryWrapper<PtlAgreementCostType> costTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ costTypeLambdaQueryWrapper.in(PtlAgreementCostType::getPtlAgreementCostId, allCostIds);
|
|
|
+ List<PtlAgreementCostType> costTypeList = agreementCostTypeService.list(costTypeLambdaQueryWrapper);
|
|
|
+ Map<String, List<PtlAgreementCostType>> costTypeMap = costTypeList.stream().collect(
|
|
|
+ Collectors.groupingBy(PtlAgreementCostType::getPtlAgreementCostId));
|
|
|
+
|
|
|
+ for(PtlAgreementCost cost :selectedCostList){
|
|
|
+ PtlAgreementCostExternal costExternal = new PtlAgreementCostExternal();
|
|
|
+ // 同名同类型字段直接复制
|
|
|
+ // 关联新协议ID:String -> Long
|
|
|
+ costExternal.setPtlAgreementId(Long.valueOf(newAgreement.getId()));
|
|
|
+ costExternal.setProductName(cost.getProductName());
|
|
|
+ costExternal.setProductId(cost.getProductId());
|
|
|
+ costExternal.setEffectiveTime(cost.getEffectiveTime());
|
|
|
+ costExternal.setFailureTime(cost.getFailureTime());
|
|
|
+ costExternal.setAuditMethod(cost.getAuditMethod());
|
|
|
+ costExternal.setCostDescribe(cost.getCostDescribe());
|
|
|
+ costExternal.setReviewDescription(cost.getReviewDescription());
|
|
|
+ costExternal.setIsEnabled(cost.getIsEnabled());
|
|
|
+ costExternal.setAuditTime(cost.getAuditTime());
|
|
|
+ costExternal.setAuditPerson(cost.getAuditPerson());
|
|
|
+ // 默认非现询,非现询为1
|
|
|
+ costExternal.setIsInquiry(1);
|
|
|
+
|
|
|
+ // 类型转换:Integer -> String
|
|
|
+ if (cost.getPriorityLevel() != null) {
|
|
|
+ costExternal.setPriorityLevel(String.valueOf(cost.getPriorityLevel()));
|
|
|
+ }
|
|
|
+ // 复制的费用默认待审核
|
|
|
+ costExternal.setAuditStatus(0);
|
|
|
+ // 复制对接人信息
|
|
|
+ costExternal.setContactPerson(param.getDockingPerson());
|
|
|
+ costExternal.setContactMobile(param.getDockingPhone());
|
|
|
+ ptlAgreementCostExternalService.save(costExternal);
|
|
|
+
|
|
|
+ List<PtlAgreementCostType> costTypes = costTypeMap.get(cost.getId());
|
|
|
+ if (CollUtil.isNotEmpty(costTypes)) {
|
|
|
+ List<PtlAgreementCostExternalType> costExternalTypes = new ArrayList<>();
|
|
|
+ for(PtlAgreementCostType costType :costTypes){
|
|
|
+ PtlAgreementCostExternalType costExternalType = new PtlAgreementCostExternalType();
|
|
|
+ // 同名同类型字段直接复制
|
|
|
+ costExternalType.setCostType(costType.getCostType());
|
|
|
+ costExternalType.setInlet(costType.getInlet());
|
|
|
+ costExternalType.setExport(costType.getExport());
|
|
|
+ costExternalType.setAddThrow(costType.getAddThrow());
|
|
|
+ costExternalType.setKeepPointRatio(costType.getKeepPointRatio());
|
|
|
+ // 关联新外部费用ID:String -> Long
|
|
|
+ costExternalType.setPtlAgreementCostExternalId(costExternal.getId());
|
|
|
+ costExternalType.setCreateTime(LocalDateTime.now());
|
|
|
+ costExternalType.setUpdateTime(LocalDateTime.now());
|
|
|
+ costExternalTypes.add(costExternalType);
|
|
|
+
|
|
|
+ }
|
|
|
+ ptlAgreementCostExternalTypeService.saveBatch(costExternalTypes);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|