Commit 3b66b4d8 authored by fangxinjiang's avatar fangxinjiang

目录优化

parent d3e22082
package com.yifu.cloud.plus.v1.yifu.ekp.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* @Author huyc
* @Description 公积金明细对接
* @Date 11:57 2022/8/29
* @Param
* @return
**/
@Data
@Component
@PropertySource("classpath:ekpFundConfig.properties")
@ConfigurationProperties(value = "ekpfund", ignoreInvalidFields = false)
public class EkpFundProperties {
String url;
String fdModelId;
String fdFlowId;
String docStatus;
String LoginName;
String docSubject;
}
package com.yifu.cloud.plus.v1.yifu.ekp.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* @Author fxj
* @Description 薪资明细对接
* @Date 11:57 2022/8/22
* @Param
* @return
**/
@Data
@Component
@PropertySource("classpath:ekpIncomeConfig.properties")
@ConfigurationProperties(value = "income", ignoreInvalidFields = false)
public class EkpIncomeProperties {
String url;
String fdModelIdManage;
String fdFlowIdManage;
String fdModelIdRisk;
String fdFlowIdRisk;
String docStatus;
String loginName;
String docSubject;
}
package com.yifu.cloud.plus.v1.yifu.ekp.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* @author zhaji
* @description TODO
* @date 2022-08-31 08:57:02
*/
@Data
@Component
@PropertySource("classpath:ekpInsuranceConfig.properties")
@ConfigurationProperties(value = "insurance",ignoreInvalidFields = false)
public class EkpInsuranceProperties {
String insuranceUrl;
String insuranceFdModelId;
String insuranceFdFlowId;
String insuranceDocStatus;
String insuranceLoginName;
String insuranceFocSubject;
}
package com.yifu.cloud.plus.v1.yifu.ekp.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* @author licancan
* @description 对接ekp订单
* @date 2022-08-31 15:35:20
*/
@Data
@Component
@PropertySource("classpath:ekpOrderConfig.properties")
@ConfigurationProperties(value = "ekporder",ignoreInvalidFields = false)
public class EkpOrderProperties {
/**
* 接口url
*/
String url;
/**
* 订单modelId
*/
String orderFdModelId;
/**
* 订单flowID
*/
String orderFdFlowId;
/**
* 订单回复modelId
*/
String replyFdModelId;
/**
* 订单回复flowID
*/
String replyFdFlowId;
/**
* 订单附件key
*/
String replyAttachKey;
String docStatus;
String LoginName;
/**
* 描述:用于项目订单更新接口
*/
String orderDocSubject;
/**
* 描述:用于订单回复接口
*/
String replyDocSubject;
}
package com.yifu.cloud.plus.v1.yifu.ekp.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* @Author fxj
* @Description 薪资明细对接
* @Date 11:57 2022/8/22
* @Param
* @return
**/
@Data
@Component
@PropertySource("classpath:ekpSalaryConfig.properties")
@ConfigurationProperties(value = "ekp", ignoreInvalidFields = false)
public class EkpSalaryProperties {
String url;
String fdModelId;
String fdFlowId;
String docStatus;
String LoginName;
String docSubject;
}
package com.yifu.cloud.plus.v1.yifu.ekp.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* @Author huyc
* @Description 社保明细对接
* @Date 11:57 2022/8/29
* @Param
* @return
**/
@Data
@Component
@PropertySource("classpath:ekpSocialConfig.properties")
@ConfigurationProperties(value = "ekpsocial", ignoreInvalidFields = false)
public class EkpSocialProperties {
String url;
String fdModelId;
String fdFlowId;
String docStatus;
String LoginName;
String docSubject;
}
package com.yifu.cloud.plus.v1.yifu.ekp.util;
import cn.hutool.json.JSONObject;
import com.yifu.cloud.plus.v1.yifu.ekp.config.EkpFundProperties;
import com.yifu.cloud.plus.v1.yifu.ekp.constant.EkpConstants;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpPushFundParam;
import io.micrometer.core.instrument.util.StringUtils;
import lombok.extern.log4j.Log4j2;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
/**
* @Author huyc
* @Date 2022/8/29
* @Description
* @Version 1.0
*/
@Log4j2
@EnableConfigurationProperties(EkpFundProperties.class)
public class EkpFundUtil {
@Autowired
private EkpFundProperties ekpProperties;
public String sendToEKP(EkpPushFundParam param){
log.info("推送EKP开始--公积金明细数据");
RestTemplate yourRestTemplate = new RestTemplate();
try{
String formValues = new ObjectMapper().writeValueAsString(param);
//指向EKP的接口url
//把ModelingAppModelParameterAddForm转换成MultiValueMap
JSONObject loginName = new JSONObject();
loginName.append("LoginName",ekpProperties.getLoginName());
String loginData = new ObjectMapper().writeValueAsString(loginName);
MultiValueMap<String,Object> wholeForm = new LinkedMultiValueMap<>();
//wholeForm.add("docSubject", new String(docSubject.getBytes("UTF-8"),"ISO-8859-1") );
wholeForm.add("docSubject",ekpProperties.getDocSubject());
wholeForm.add("docCreator", "{\"LoginName\":\"admin\"}");
//wholeForm.add("docCreator", loginData);
wholeForm.add("docStatus", ekpProperties.getDocStatus());
wholeForm.add("fdModelId", ekpProperties.getFdModelId());
wholeForm.add("fdFlowId", ekpProperties.getFdFlowId());
//wholeForm.add("formValues", new String(formValues.getBytes("UTF-8"),"ISO-8859-1"));
wholeForm.add("formValues", formValues);
//wholeForm.add("formValues", new String("{\"fd_3adfe6af71a1cc\":\"王五\", \"fd_3adfe658c6229e\":\"2019-03-26\", \"fd_3adfe6592b4158\":\"这里内容\"}".getBytes("UTF-8"),"ISO-8859-1") );
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(ekpProperties.getUrl(), 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.info(e.getMessage());
return null;
}
}
}
package com.yifu.cloud.plus.v1.yifu.ekp.util;
import cn.hutool.json.JSONObject;
import com.yifu.cloud.plus.v1.yifu.ekp.config.EkpIncomeProperties;
import com.yifu.cloud.plus.v1.yifu.ekp.constant.EkpConstants;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpIncomeParamManage;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpIncomeParamRisk;
import io.micrometer.core.instrument.util.StringUtils;
import lombok.extern.log4j.Log4j2;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
/**
* @Author hgw
* @Date 2022-8-31 12:00:07
* @Description
* @Version 1.0
*/
@Log4j2
@EnableConfigurationProperties(EkpIncomeProperties.class)
public class EkpIncomeUtil {
@Autowired
private EkpIncomeProperties ekpProperties;
/**
* @param param 内容传参
* @Description:
* @Author: hgw
* @Date: 2022/9/5 16:12
* @return: java.lang.String
**/
public String sendToEkpManage(EkpIncomeParamManage param) {
log.info("推送EKP开始--收入明细数据");
RestTemplate yourRestTemplate = new RestTemplate();
try {
String formValues = new ObjectMapper().writeValueAsString(param);
//指向EKP的接口url
//把ModelingAppModelParameterAddForm转换成MultiValueMap
JSONObject loginName = new JSONObject();
loginName.append("LoginName", ekpProperties.getLoginName());
MultiValueMap<String, Object> wholeForm = new LinkedMultiValueMap<>();
wholeForm.add("docSubject", ekpProperties.getDocSubject());
wholeForm.add("docCreator", "{\"LoginName\":\"admin\"}");
wholeForm.add("docStatus", ekpProperties.getDocStatus());
wholeForm.add("fdModelId", ekpProperties.getFdModelIdManage());
wholeForm.add("fdFlowId", ekpProperties.getFdFlowIdManage());
wholeForm.add("formValues", formValues);
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<>(wholeForm, headers);
//有返回值的情况 VO可以替换成具体的JavaBean
ResponseEntity<String> obj = yourRestTemplate.exchange(ekpProperties.getUrl(), HttpMethod.POST, entity, String.class);
String body = obj.getBody();
if (StringUtils.isBlank(body)) {
log.error(EkpConstants.SEND_FAILED);
return EkpConstants.SEND_FAILED;
} else {
log.info(EkpConstants.SEND_SUCCESS + body);
return body;
}
} catch (Exception e) {
log.info(e.getMessage());
return e.getMessage();
}
}
public String sendToEkpRisk(EkpIncomeParamRisk param) {
log.info("推送EKP开始--收入明细数据");
RestTemplate yourRestTemplate = new RestTemplate();
try {
String formValues = new ObjectMapper().writeValueAsString(param);
//指向EKP的接口url
//把ModelingAppModelParameterAddForm转换成MultiValueMap
JSONObject loginName = new JSONObject();
loginName.append("LoginName", ekpProperties.getLoginName());
MultiValueMap<String, Object> wholeForm = new LinkedMultiValueMap<>();
wholeForm.add("docSubject", ekpProperties.getDocSubject());
wholeForm.add("docCreator", "{\"LoginName\":\"admin\"}");
wholeForm.add("docStatus", ekpProperties.getDocStatus());
wholeForm.add("fdModelId", ekpProperties.getFdModelIdRisk());
wholeForm.add("fdFlowId", ekpProperties.getFdFlowIdRisk());
wholeForm.add("formValues", formValues);
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<>(wholeForm, headers);
//有返回值的情况 VO可以替换成具体的JavaBean
ResponseEntity<String> obj = yourRestTemplate.exchange(ekpProperties.getUrl(), HttpMethod.POST, entity, String.class);
String body = obj.getBody();
if (StringUtils.isBlank(body)) {
log.error(EkpConstants.SEND_FAILED);
return EkpConstants.SEND_FAILED;
} else {
log.info(EkpConstants.SEND_SUCCESS + body);
return body;
}
} catch (Exception e) {
log.info(e.getMessage());
return e.getMessage();
}
}
}
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.vo.EKPInsurancePushParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.EkpInteractiveParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.TInsuranceSettlePushParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/**
* @author zhaji
* @description EKP交互工具类
*
* @date 2022-08-05 09:42:33
*/
@Slf4j
@EnableConfigurationProperties(EkpInsuranceProperties.class)
public class EkpInsuranceUtil {
@Resource
private EkpInsuranceProperties ekpInsuranceProperties;
/**
* 多层级的VO对象,且包含上传功能的样例
* 注意key的书写格式,类似EL表达式的方式,属性关系用'.', 列表和数组关系用[],Map关系用["xxx"]
*/
public String sendToEkp(EkpInteractiveParam param){
RestTemplate yourRestTemplate = new RestTemplate();
EKPInsurancePushParam pushParam = insuranceDetail2PushParam(param);
try{
String formValues = new ObjectMapper().writeValueAsString(pushParam);
//指向EKP的接口url
//把ModelingAppModelParameterAddForm转换成MultiValueMap
MultiValueMap<String,Object> wholeForm = new LinkedMultiValueMap<>();
wholeForm.add("docSubject",ekpInsuranceProperties.getInsuranceFocSubject());
wholeForm.add("docCreator", "{\"LoginName\":\"admin\"}");
wholeForm.add("docStatus", ekpInsuranceProperties.getInsuranceDocStatus());
wholeForm.add("fdModelId", ekpInsuranceProperties.getInsuranceFdModelId());
wholeForm.add("fdFlowId", ekpInsuranceProperties.getInsuranceFdFlowId());
wholeForm.add("formValues", formValues);
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
log.info("推送EKP开始,formValues:"+formValues);
ResponseEntity<String> obj = yourRestTemplate.exchange(ekpInsuranceProperties.getInsuranceUrl(), HttpMethod.POST, entity, String.class);
String body = obj.getBody();
if (StringUtils.isBlank(body)){
log.error("交易失败:"+obj);
return null;
}else{
log.info("交易成功:"+obj);
return body;
}
}catch (Exception e){
log.error("交易失败:", e);
return null;
}
}
/**
* 将类转换成EKP要求的格式
*
* @author zhaji
* @param param 转换类
* @return {@link TInsuranceSettlePushParam}
*/
public static EKPInsurancePushParam insuranceDetail2PushParam(EkpInteractiveParam param){
String format = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
EKPInsurancePushParam pushParam = new EKPInsurancePushParam();
param.setHappenDate(format);
//ekpId
if(null != param.getDetailId() && null != param.getDefaultSettleId()){
pushParam.setFd_3afa8a70006bea(param.getDetailId()+CommonConstants.DOWN_LINE_STRING+param.getDefaultSettleId());
}else{
pushParam.setFd_3afa8a70006bea(CommonConstants.EMPTY_STRING);
}
//单据类型
if(null != param.getSettleType()){
pushParam.setFd_3adfe6af71a1cc(param.getSettleType());
}else{
pushParam.setFd_3adfe6af71a1cc(CommonConstants.EMPTY_STRING);
}
//项目编码
pushParam.setFd_3adfe658c6229e(param.getDeptNo());
if(null != param.getDeptNo()){
pushParam.setFd_3adfe658c6229e(param.getDeptNo());
}else{
pushParam.setFd_3adfe658c6229e(CommonConstants.EMPTY_STRING);
}
//项目名称
pushParam.setFd_3adfe6592b4158(param.getDeptName());
if(null != param.getDeptName()){
pushParam.setFd_3adfe6592b4158(param.getDeptName());
}else{
pushParam.setFd_3adfe6592b4158(CommonConstants.EMPTY_STRING);
}
//客户编码
pushParam.setFd_3adfe6598281e8(param.getCustomerCode());
if(null != param.getCustomerCode()){
pushParam.setFd_3adfe6598281e8(param.getCustomerCode());
}else{
pushParam.setFd_3adfe6598281e8(CommonConstants.EMPTY_STRING);
}
//客户名称
pushParam.setFd_3adfe7a2688902(param.getCustomerName());
if(null != param.getCustomerName()){
pushParam.setFd_3adfe7a2688902(param.getCustomerName());
}else{
pushParam.setFd_3adfe7a2688902(CommonConstants.EMPTY_STRING);
}
//发生日期
pushParam.setFd_3adfe67c24dace(param.getHappenDate());
//姓名
pushParam.setFd_3adfe65d759650(param.getEmpName());
if(null != param.getEmpName()){
pushParam.setFd_3adfe65d759650(param.getEmpName());
}else{
pushParam.setFd_3adfe65d759650(CommonConstants.EMPTY_STRING);
}
//身份证号
pushParam.setFd_3adfe65dbd9f68(param.getEmpIdcardNo());
if(null != param.getEmpIdcardNo()){
pushParam.setFd_3adfe65dbd9f68(param.getEmpIdcardNo());
}else{
pushParam.setFd_3adfe65dbd9f68(CommonConstants.EMPTY_STRING);
}
//发票号
if(null != param.getInvoiceNo()){
pushParam.setFd_3adfe65e0cd094(param.getInvoiceNo());
}else{
pushParam.setFd_3adfe65e0cd094(CommonConstants.EMPTY_STRING);
}
//险种
if(null != param.getInsuranceTypeName()){
pushParam.setFd_3adfe65f6599e4(param.getInsuranceTypeName());
}else{
pushParam.setFd_3adfe65f6599e4(CommonConstants.EMPTY_STRING);
}
//保险公司
if(null != param.getInsuranceCompanyName()){
pushParam.setFd_3adfe65ea04728(param.getInsuranceCompanyName());
}else{
pushParam.setFd_3adfe65ea04728(CommonConstants.EMPTY_STRING);
}
//保单号
if(null != param.getPolicyNo()){
pushParam.setFd_3adfe65e60e110(param.getPolicyNo());
}else{
pushParam.setFd_3adfe65e60e110(CommonConstants.EMPTY_STRING);
}
//保险开始日期
if(null != param.getPolicyStart()){
pushParam.setFd_3adfe6b7e0ede8(param.getPolicyStart().toString());
}else{
pushParam.setFd_3adfe6b7e0ede8(CommonConstants.EMPTY_STRING);
}
//保险结束日期
if(null != param.getPolicyEnd()){
pushParam.setFd_3adfe6b847bfe6(param.getPolicyEnd().toString());
}else{
pushParam.setFd_3adfe6b847bfe6(CommonConstants.EMPTY_STRING);
}
//购买标准
pushParam.setFd_3adfe6d55384c6(param.getBuyStandard());
if(null != param.getBuyStandard()){
pushParam.setFd_3adfe6d55384c6(param.getBuyStandard());
}else{
pushParam.setFd_3adfe6d55384c6(CommonConstants.EMPTY_STRING);
}
//实际保费
if(null != param.getActualPremium()){
pushParam.setFd_3adfe6610c0d2c(param.getActualPremium().toString());
}else{
pushParam.setFd_3adfe6610c0d2c(CommonConstants.EMPTY_STRING);
}
//医保
if(null != param.getMedicalQuota()){
pushParam.setFd_3adfe66041a996(param.getMedicalQuota());
}else{
pushParam.setFd_3adfe66041a996(CommonConstants.EMPTY_STRING);
}
//事故或残疾
if(null != param.getDieDisableQuota()){
pushParam.setFd_3adfe6609aa810(param.getDieDisableQuota());
}else{
pushParam.setFd_3adfe6609aa810(CommonConstants.EMPTY_STRING);
}
//预估保费
if(null != param.getEstimatePremium()){
pushParam.setFd_3adfe6e30f2a3c(param.getEstimatePremium().toString());
}else{
pushParam.setFd_3adfe6e30f2a3c(CommonConstants.EMPTY_STRING);
}
//结算月
if(null != param.getSettleMonth()){
pushParam.setFd_3aea2f0180eccc(param.getSettleMonth());
}else{
pushParam.setFd_3aea2f0180eccc(CommonConstants.EMPTY_STRING);
}
//交易类型
if(null != param.getInteractiveType()){
pushParam.setFd_3af9197b31071c(param.getInteractiveType());
}else{
pushParam.setFd_3af9197b31071c(CommonConstants.EMPTY_STRING);
}
//有无预估
if(null != param.getEstimateStatus()){
pushParam.setFd_3b0a5937928c8c(param.getEstimateStatus());
}else{
pushParam.setFd_3b0a5937928c8c(CommonConstants.EMPTY_STRING);
}
//是否bro客户
if(null != param.getBpoFlag()){
pushParam.setFd_3b178f8ba1a91c(param.getBpoFlag());
}else{
pushParam.setFd_3b178f8ba1a91c(CommonConstants.EMPTY_STRING);
}
return pushParam;
}
}
package com.yifu.cloud.plus.v1.yifu.ekp.util;
import com.yifu.cloud.plus.v1.yifu.ekp.config.EkpOrderProperties;
import com.yifu.cloud.plus.v1.yifu.ekp.constant.EkpConstants;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpOrderParam;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpOrderReplyParam;
import io.micrometer.core.instrument.util.StringUtils;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.ArrayUtils;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* @author licancan
* @description 对接ekp订单
* @date 2022-08-31 15:35:20
*/
@Log4j2
@EnableConfigurationProperties(EkpOrderProperties.class)
public class EkpOrderUtil {
@Autowired
private EkpOrderProperties ekpProperties;
/**
* 更新订单状态
*
* @author licancan
* @param param
* @return {@link String}
*/
public String sendOrderToEKP(EkpOrderParam 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",ekpProperties.getOrderDocSubject());
wholeForm.add("docCreator", "{\"LoginName\":\"admin\"}");
wholeForm.add("docStatus", ekpProperties.getDocStatus());
wholeForm.add("fdModelId", ekpProperties.getOrderFdModelId());
wholeForm.add("fdFlowId", ekpProperties.getOrderFdFlowId());
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(ekpProperties.getUrl(), 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(e);
return null;
}
}
/**
* 推送订单回复
*
* @author licancan
* @param param
* @return {@link String}
*/
public String sendReplyToEKP(EkpOrderReplyParam param, MultipartFile[] multipartFiles){
log.info("推送EKP开始--订单回复信息");
RestTemplate yourRestTemplate = new RestTemplate();
List<File> fileList = new ArrayList<>();
try{
String formValues = new ObjectMapper().writeValueAsString(param);
//指向EKP的接口url
//把ModelingAppModelParameterAddForm转换成MultiValueMap
MultiValueMap<String,Object> wholeForm = new LinkedMultiValueMap<>();
wholeForm.add("docSubject",ekpProperties.getReplyDocSubject());
wholeForm.add("docCreator", "{\"LoginName\":\"admin\"}");
wholeForm.add("docStatus", ekpProperties.getDocStatus());
wholeForm.add("fdModelId", ekpProperties.getReplyFdModelId());
wholeForm.add("fdFlowId", ekpProperties.getReplyFdFlowId());
wholeForm.add("formValues", formValues);
if (ArrayUtils.isNotEmpty(multipartFiles)){
for (int i = 0; i < multipartFiles.length; i++) {
String fileName = multipartFiles[i].getOriginalFilename();
File file = new File(fileName);
FileUtils.copyInputStreamToFile(multipartFiles[i].getInputStream(), file);
wholeForm.add("attachmentForms["+i+"].fdKey", ekpProperties.getReplyAttachKey());
wholeForm.add("attachmentForms["+i+"].fdFileName", multipartFiles[i].getOriginalFilename());
wholeForm.add("attachmentForms["+i+"].fdAttachment", new FileSystemResource(file));
fileList.add(file);
}
}
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(ekpProperties.getUrl(), 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(e);
return null;
}finally {
//将产生的临时附件删除,这里的fileList没值得话是[],不会是null,如果是null需要做判空处理
fileList.stream().forEach(e -> {
boolean delete = e.delete();
log.info("临时附件删除结果:{}",delete);
});
}
}
}
package com.yifu.cloud.plus.v1.yifu.ekp.util;
import cn.hutool.json.JSONObject;
import com.yifu.cloud.plus.v1.yifu.ekp.config.EkpSalaryProperties;
import com.yifu.cloud.plus.v1.yifu.ekp.constant.EkpConstants;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpSalaryParam;
import io.micrometer.core.instrument.util.StringUtils;
import lombok.extern.log4j.Log4j2;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
/**
* @Author fxj
* @Date 2022/7/11
* @Description
* @Version 1.0
*/
@Log4j2
@EnableConfigurationProperties(EkpSalaryProperties.class)
public class EkpSalaryUtil {
@Autowired
private EkpSalaryProperties ekpProperties;
public String sendToEKP(EkpSalaryParam param){
log.info("推送EKP开始--薪资明细数据");
RestTemplate yourRestTemplate = new RestTemplate();
try{
String formValues = new ObjectMapper().writeValueAsString(param);
//指向EKP的接口url
//把ModelingAppModelParameterAddForm转换成MultiValueMap
JSONObject loginName = new JSONObject();
loginName.append("LoginName",ekpProperties.getLoginName());
MultiValueMap<String,Object> wholeForm = new LinkedMultiValueMap<>();
//wholeForm.add("docSubject", new String(docSubject.getBytes("UTF-8"),"ISO-8859-1") )
wholeForm.add("docSubject",ekpProperties.getDocSubject());
wholeForm.add("docCreator", "{\"LoginName\":\"admin\"}");
//wholeForm.add("docCreator", loginData)
wholeForm.add("docStatus", ekpProperties.getDocStatus());
wholeForm.add("fdModelId", ekpProperties.getFdModelId());
wholeForm.add("fdFlowId", ekpProperties.getFdFlowId());
//wholeForm.add("formValues", new String(formValues.getBytes("UTF-8"),"ISO-8859-1"))
wholeForm.add("formValues", formValues);
//wholeForm.add("formValues", new String("{\"fd_3adfe6af71a1cc\":\"王五\", \"fd_3adfe658c6229e\":\"2019-03-26\", \"fd_3adfe6592b4158\":\"这里内容\"}".getBytes("UTF-8"),"ISO-8859-1") )
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<>(wholeForm,headers);
//有返回值的情况 VO可以替换成具体的JavaBean
ResponseEntity<String> obj = yourRestTemplate.exchange(ekpProperties.getUrl(), HttpMethod.POST, entity, String.class);
String body = obj.getBody();
if (StringUtils.isBlank(body)){
log.error(EkpConstants.SEND_FAILED);
return EkpConstants.SEND_FAILED;
}else{
log.info(EkpConstants.SEND_SUCCESS+body);
return body;
}
}catch (Exception e){
log.info(e.getMessage());
return e.getMessage();
}
}
}
package com.yifu.cloud.plus.v1.yifu.ekp.util;
import cn.hutool.json.JSONObject;
import com.yifu.cloud.plus.v1.yifu.ekp.config.EkpSocialProperties;
import com.yifu.cloud.plus.v1.yifu.ekp.constant.EkpConstants;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpPushSocialParam;
import io.micrometer.core.instrument.util.StringUtils;
import lombok.extern.log4j.Log4j2;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
/**
* @Author huyc
* @Date 2022/8/29
* @Description
* @Version 1.0
*/
@Log4j2
@EnableConfigurationProperties(EkpSocialProperties.class)
public class EkpSocialUtil {
@Autowired
private EkpSocialProperties ekpProperties;
public String sendToEKP(EkpPushSocialParam param){
log.info("推送EKP开始--社保明细数据");
RestTemplate yourRestTemplate = new RestTemplate();
try{
String formValues = new ObjectMapper().writeValueAsString(param);
//指向EKP的接口url
//把ModelingAppModelParameterAddForm转换成MultiValueMap
JSONObject loginName = new JSONObject();
loginName.append("LoginName",ekpProperties.getLoginName());
String loginData = new ObjectMapper().writeValueAsString(loginName);
MultiValueMap<String,Object> wholeForm = new LinkedMultiValueMap<>();
//wholeForm.add("docSubject", new String(docSubject.getBytes("UTF-8"),"ISO-8859-1") );
wholeForm.add("docSubject",ekpProperties.getDocSubject());
wholeForm.add("docCreator", "{\"LoginName\":\"admin\"}");
//wholeForm.add("docCreator", loginData);
wholeForm.add("docStatus", ekpProperties.getDocStatus());
wholeForm.add("fdModelId", ekpProperties.getFdModelId());
wholeForm.add("fdFlowId", ekpProperties.getFdFlowId());
//wholeForm.add("formValues", new String(formValues.getBytes("UTF-8"),"ISO-8859-1"));
wholeForm.add("formValues", formValues);
//wholeForm.add("formValues", new String("{\"fd_3adfe6af71a1cc\":\"王五\", \"fd_3adfe658c6229e\":\"2019-03-26\", \"fd_3adfe6592b4158\":\"这里内容\"}".getBytes("UTF-8"),"ISO-8859-1") );
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(ekpProperties.getUrl(), 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.info(e.getMessage());
return null;
}
}
}
ekpfund.url=http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel #ekpfund.url=http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel
ekpfund.url=http://ekp.wanxinwork.com/api/sys-modeling/appModelRestService/addModel
ekpfund.fdModelId=181d741547a691aa68b16149a40de901 ekpfund.fdModelId=181d741547a691aa68b16149a40de901
ekpfund.fdFlowId=18290af372be55308327273487abf72a ekpfund.fdFlowId=18290af372be55308327273487abf72a
ekpfund.docStatus=20 ekpfund.docStatus=20
......
income.url=http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel #income.url=http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel
income.url=http://ekp.wanxinwork.com/api/sys-modeling/appModelRestService/addModel
income.fdModelIdManage=181d76db26e419a88dba97b0c406689e income.fdModelIdManage=181d76db26e419a88dba97b0c406689e
income.fdFlowIdManage=182d3b6e522b2690119e70d4ff082136 income.fdFlowIdManage=182d3b6e522b2690119e70d4ff082136
income.fdModelIdRisk=181d76db26e4112e14b9bb4274d06ba1 income.fdModelIdRisk=181d76db26e4112e14b9bb4274d06ba1
......
insurance.insuranceUrl=http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel #insurance.insuranceUrl=http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel
insurance.insuranceUrl=http://ekp.wanxinwork.com/api/sys-modeling/appModelRestService/addModel
insurance.insuranceFdModelId=181d73279372e5a55438a47d7436ab7e insurance.insuranceFdModelId=181d73279372e5a55438a47d7436ab7e
insurance.insuranceFdFlowId=18267f206233f29cbd3c5ee425c9408a insurance.insuranceFdFlowId=18267f206233f29cbd3c5ee425c9408a
insurance.insuranceDocStatus=20 insurance.insuranceDocStatus=20
......
ekporder.url=http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel #ekporder.url=http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel
ekporder.url=http://ekp.wanxinwork.com/api/sys-modeling/appModelRestService/addModel
ekporder.orderFdModelId=182f1b7ffe2e96f975564e44e559847d ekporder.orderFdModelId=182f1b7ffe2e96f975564e44e559847d
ekporder.orderFdFlowId=182f1c098ce991ca96bc927408792beb ekporder.orderFdFlowId=182f1c098ce991ca96bc927408792beb
ekporder.replyFdModelId=182f1bb35bb2156fb9a02904bc88dd8a ekporder.replyFdModelId=182f1bb35bb2156fb9a02904bc88dd8a
...@@ -6,7 +7,7 @@ ekporder.replyFdFlowId=182f1c3d6f5724e335b88d544be8c993 ...@@ -6,7 +7,7 @@ ekporder.replyFdFlowId=182f1c3d6f5724e335b88d544be8c993
ekporder.replyAttachKey=fd_3ac904c9342fe2 ekporder.replyAttachKey=fd_3ac904c9342fe2
ekporder.docStatus=20 ekporder.docStatus=20
ekporder.LoginName=admin ekporder.LoginName=admin
ekporder.orderDocSubject=\u7528\u4e8e\u9879\u76ee\u8ba2\u5355\u66f4\u65b0\u63a5\u53e3 ekporder.orderDocSubject=\u7528\u4E8E\u9879\u76EE\u8BA2\u5355\u66F4\u65B0\u63A5\u53E3
ekporder.replyDocSubject=\u7528\u4e8e\u8ba2\u5355\u56de\u590d\u63a5\u53e3 ekporder.replyDocSubject=\u7528\u4E8E\u8BA2\u5355\u56DE\u590D\u63A5\u53E3
ekp.url=http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel #ekp.url=http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel
ekp.url=http://ekp.wanxinwork.com/api/sys-modeling/appModelRestService/addModel
ekp.fdModelId=181d7633ff8bc797276d0d3a54e80ad6 ekp.fdModelId=181d7633ff8bc797276d0d3a54e80ad6
ekp.fdFlowId=182b40249c1bc940d7226b941c7a4183 ekp.fdFlowId=182b40249c1bc940d7226b941c7a4183
ekp.docStatus=20 ekp.docStatus=20
......
ekpsocial.url=http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel #ekpsocial.url=http://119.96.227.251:8080/api/sys-modeling/appModelRestService/addModel
ekpsocial.url=http://ekp.wanxinwork.com/api/sys-modeling/appModelRestService/addModel
ekpsocial.fdModelId=181d741547a69ba9dbc12377948e98fd ekpsocial.fdModelId=181d741547a69ba9dbc12377948e98fd
ekpsocial.fdFlowId=18233028fe91511376b00f74b3a8f3a7 ekpsocial.fdFlowId=18233028fe91511376b00f74b3a8f3a7
ekpsocial.docStatus=20 ekpsocial.docStatus=20
......
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