Commit a211f529 authored by 李灿灿's avatar 李灿灿

feat:ekp推送接口

parent a7fdb14e
......@@ -26,5 +26,19 @@ public class EkpInsuranceProperties {
String insuranceLoginName;
String insuranceFocSubject;
String insuranceDocSubject;
/**
* ekp修改接口描述
*/
String insuranceUpdateDocSubject;
/**
* ekp修改FdModelId
*/
String insuranceUpdateFdModelId;
/**
* ekp修改FdFlowId
*/
String insuranceUpdateFdFlowId;
}
......@@ -3,8 +3,10 @@ package com.yifu.cloud.plus.v1.yifu.ekp.util;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.ekp.config.EkpInsuranceProperties;
import com.yifu.cloud.plus.v1.yifu.ekp.constant.EkpConstants;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EKPInsurancePushParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.EkpInteractiveParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.EkpUpdateParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.TInsuranceSettlePushParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
......@@ -44,7 +46,7 @@ public class EkpInsuranceUtil {
//指向EKP的接口url
//把ModelingAppModelParameterAddForm转换成MultiValueMap
MultiValueMap<String,Object> wholeForm = new LinkedMultiValueMap<>();
wholeForm.add("docSubject",ekpInsuranceProperties.getInsuranceFocSubject());
wholeForm.add("docSubject",ekpInsuranceProperties.getInsuranceDocSubject());
wholeForm.add("docCreator", "{\"LoginName\":\"admin\"}");
wholeForm.add("docStatus", ekpInsuranceProperties.getInsuranceDocStatus());
wholeForm.add("fdModelId", ekpInsuranceProperties.getInsuranceFdModelId());
......@@ -73,6 +75,50 @@ public class EkpInsuranceUtil {
}
}
/**
* 商险修改信息推送ekp
*
* @author licancan
* @param param
* @return {@link String}
*/
public String sendUpdateToEkp(EkpUpdateParam param){
log.info("推送EKP开始--商险修改");
RestTemplate yourRestTemplate = new RestTemplate();
try{
String formValues = new ObjectMapper().writeValueAsString(param);
//指向EKP的接口url
//把ModelingAppModelParameterAddForm转换成MultiValueMap
MultiValueMap<String,Object> wholeForm = new LinkedMultiValueMap<>();
wholeForm.add("docSubject",ekpInsuranceProperties.getInsuranceUpdateDocSubject());
wholeForm.add("docCreator", "{\"LoginName\":\"admin\"}");
wholeForm.add("docStatus", ekpInsuranceProperties.getInsuranceDocStatus());
wholeForm.add("fdModelId", ekpInsuranceProperties.getInsuranceUpdateFdModelId());
wholeForm.add("fdFlowId", ekpInsuranceProperties.getInsuranceUpdateFdFlowId());
wholeForm.add("formValues", formValues);
log.info("wholeForm:" + wholeForm);
HttpHeaders headers = new HttpHeaders();
//如果EKP对该接口启用了Basic认证,那么客户端需要加入
//addAuth(headers,"yourAccount"+":"+"yourPassword");是VO,则使用APPLICATION_JSON
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
//必须设置上传类型,如果入参是字符串,使用MediaType.TEXT_PLAIN;如果
HttpEntity<MultiValueMap<String,Object>> entity = new HttpEntity<MultiValueMap<String,Object>>(wholeForm,headers);
//有返回值的情况 VO可以替换成具体的JavaBean
ResponseEntity<String> obj = yourRestTemplate.exchange(ekpInsuranceProperties.getInsuranceUrl(), HttpMethod.POST, entity, String.class);
String body = obj.getBody();
if (StringUtils.isBlank(body)){
log.error(EkpConstants.SEND_FAILED);
return null;
}else{
log.info(EkpConstants.SEND_SUCCESS + body);
return body;
}
}catch (Exception e){
log.error(EkpConstants.SEND_FAILED +":", e);
return null;
}
}
/**
* 将类转换成EKP要求的格式
*
......
......@@ -4,6 +4,10 @@ insurance.insuranceFdModelId=181d73279372e5a55438a47d7436ab7e
insurance.insuranceFdFlowId=18267f206233f29cbd3c5ee425c9408a
insurance.insuranceDocStatus=20
insurance.insuranceLoginName=admin
insurance.insuranceFocSubject=\u85AA\u8D44\u8BA2\u5355\u660E\u7EC6\u6570\u636E\u63A5\u53E3
insurance.insuranceDocSubject=\u5546\u9669\u63a8\u9001\u0065\u006b\u0070\u63a5\u53e3
insurance.insuranceUpdateDocSubject=\u5546\u9669\u63a8\u9001\u0065\u006b\u0070\u4fee\u6539\u63a5\u53e3
insurance.insuranceUpdateFdModelId=1850416f69cc813f128474e478b83794
insurance.insuranceUpdateFdFlowId=185041a4d264c3892a0543e43be925eb
package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import lombok.Data;
import java.io.Serializable;
/**
* @author licancan
* @description ekp更新请求参数
* @date 2022-12-12 14:09:35
*/
@Data
public class EkpUpdateParam implements Serializable {
private static final long serialVersionUID = 581367013151512283L;
/**
* 保单开始时间
**/
private String fd_3b5bf02d3b8fc4;
/**
* 保单结束时间
**/
private String fd_3b5bf02e1d47cc;
/**
* 投保类型
*/
private String fd_3b5bf02fa14596;
/**
* 发票号
*/
private String fd_3b5bf030ab1a56;
/**
* 购买标准
*/
private String fd_3b5bf031b52314;
/**
* 商险ID
*/
private String fd_3b5bf032d7a822;
/**
* 商险变更ID
*/
private String fd_3b5bf033da86b2;
/**
* 变更记录
*/
private String fd_3b5bf0b7b4c058;
}
......@@ -54,6 +54,7 @@ import java.math.RoundingMode;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
......@@ -2049,13 +2050,22 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//设置发票号
detail.setInvoiceNo(success.getInvoiceNo());
detailList.add(detail);
//推送修改信息
EkpUpdateParam ekpUpdateParam = new EkpUpdateParam();
ekpUpdateParam.setFd_3b5bf02d3b8fc4(success.getPolicyStart());
ekpUpdateParam.setFd_3b5bf02e1d47cc(success.getPolicyEnd());
ekpUpdateParam.setFd_3b5bf02fa14596(getBuyType(detail.getBuyType()));
ekpUpdateParam.setFd_3b5bf030ab1a56(success.getInvoiceNo());
ekpUpdateParam.setFd_3b5bf031b52314(detail.getBuyStandard());
ekpUpdateParam.setFd_3b5bf032d7a822(detail.getId());
ekpUpdateParam.setFd_3b5bf0b7b4c058("操作人:"+user.getNickname() + ";操作时间:"+LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + ";变更前发票号:" + detail.getInvoiceNo() + ";变更后发票号:" + success.getInvoiceNo());
eKPInsuranceUtil.sendUpdateToEkp(ekpUpdateParam);
}
}
}
if (CollectionUtils.isNotEmpty(detailList)){
this.updateBatchById(detailList);
//todo 推给EKP
}
//操作记录
......@@ -2066,6 +2076,31 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
return R.ok(operateList,InsurancesConstants.OPERATE_SUCCESS);
}
/**
* 购买类型转换
*
* @author licancan
* @param buyType
* @return {@link String}
*/
private String getBuyType(Integer buyType){
String result;
switch (buyType){
case 1:
result = "新增";
break;
case 3:
result = "批增";
break;
case 4:
result = "替换";
break;
default:
result = "";
}
return result;
}
/**
* 已投保信息修改
*
......@@ -2116,6 +2151,26 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//变更记录
tBusinessOperateService.saveModificationRecord(detail.getId(),oldDetail,detail,success.getReason());
//推送修改信息
StringBuilder sb = new StringBuilder();
sb.append("操作人:"+user.getNickname() + ";操作时间:"+LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
if (!detail.getPolicyStart().toString().equals(success.getPolicyStart())){
sb.append(";变更前保单开始时间:" + detail.getPolicyStart() + ";变更后保单开始时间:" + success.getPolicyStart());
}
if (!detail.getPolicyEnd().toString().equals(success.getPolicyEnd())){
sb.append(";变更前保单结束时间:" + detail.getPolicyEnd() + ";变更后保单结束时间:" + success.getPolicyEnd());
}
if (!detail.getBuyType().equals(success.getBuyType())){
sb.append(";变更前投保类型:" + getBuyType(detail.getBuyType()) + ";变更后投保类型:" + getBuyType(success.getBuyType()));
}
EkpUpdateParam ekpUpdateParam = new EkpUpdateParam();
ekpUpdateParam.setFd_3b5bf02d3b8fc4(success.getPolicyStart());
ekpUpdateParam.setFd_3b5bf02e1d47cc(success.getPolicyEnd());
ekpUpdateParam.setFd_3b5bf02fa14596(getBuyType(success.getBuyType()));
ekpUpdateParam.setFd_3b5bf031b52314(detail.getBuyStandard());
ekpUpdateParam.setFd_3b5bf032d7a822(detail.getId());
ekpUpdateParam.setFd_3b5bf0b7b4c058(sb.toString());
eKPInsuranceUtil.sendUpdateToEkp(ekpUpdateParam);
}
}
......@@ -2140,6 +2195,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
*/
@Override
public R<String> updateInsuranceInsuredById(InsuranceInsuredDetailParam param) {
YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) {
return R.failed(CommonConstants.PLEASE_LOG_IN);
}
if (StringUtils.isBlank(param.getId())){
R.failed(InsurancesConstants.ID_IS_EMPTY);
}
......@@ -2185,7 +2244,28 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (Objects.nonNull(param.getBuyType())){
byId.setBuyType(param.getBuyType());
}
//变更记录
tBusinessOperateService.saveModificationRecord(byId.getId(),old,byId,param.getReason());
//推送修改信息
StringBuilder sb = new StringBuilder();
sb.append("操作人:"+user.getNickname() + ";操作时间:"+LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
if (!byId.getPolicyStart().toString().equals(param.getPolicyStart())){
sb.append(";变更前保单开始时间:" + byId.getPolicyStart() + ";变更后保单开始时间:" + param.getPolicyStart());
}
if (!byId.getPolicyEnd().toString().equals(param.getPolicyEnd())){
sb.append(";变更前保单结束时间:" + byId.getPolicyEnd() + ";变更后保单结束时间:" + param.getPolicyEnd());
}
if (!byId.getBuyType().equals(param.getBuyType())){
sb.append(";变更前投保类型:" + getBuyType(byId.getBuyType()) + ";变更后投保类型:" + getBuyType(param.getBuyType()));
}
EkpUpdateParam ekpUpdateParam = new EkpUpdateParam();
ekpUpdateParam.setFd_3b5bf02d3b8fc4(param.getPolicyStart());
ekpUpdateParam.setFd_3b5bf02e1d47cc(param.getPolicyEnd());
ekpUpdateParam.setFd_3b5bf02fa14596(getBuyType(param.getBuyType()));
ekpUpdateParam.setFd_3b5bf031b52314(byId.getBuyStandard());
ekpUpdateParam.setFd_3b5bf032d7a822(byId.getId());
ekpUpdateParam.setFd_3b5bf0b7b4c058(sb.toString());
eKPInsuranceUtil.sendUpdateToEkp(ekpUpdateParam);
this.updateById(byId);
return R.ok(InsurancesConstants.OPERATE_SUCCESS);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment