Commit ccf7744e by wangnb

包活干V1.9.0保单接口开发--think.wang

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@27007 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent e17ca34a
...@@ -33,7 +33,7 @@ public class TspUpdateReq implements Serializable { ...@@ -33,7 +33,7 @@ public class TspUpdateReq implements Serializable {
private String installPoint; private String installPoint;
private String installPerson; private String installPerson;
//保额,车辆价格 //保额,车辆价格
private Long sumAmount; private String sumAmount;
private String spid; private String spid;
private String specialContent; private String specialContent;
//车架号 //车架号
...@@ -197,11 +197,11 @@ public class TspUpdateReq implements Serializable { ...@@ -197,11 +197,11 @@ public class TspUpdateReq implements Serializable {
this.installPerson = installPerson; this.installPerson = installPerson;
} }
public Long getSumAmount() { public String getSumAmount() {
return sumAmount; return sumAmount;
} }
public void setSumAmount(Long sumAmount) { public void setSumAmount(String sumAmount) {
this.sumAmount = sumAmount; this.sumAmount = sumAmount;
} }
......
...@@ -26,9 +26,9 @@ import java.util.concurrent.Semaphore; ...@@ -26,9 +26,9 @@ import java.util.concurrent.Semaphore;
* @Description 调用TSP接口获取保单信息pdf路径 * @Description 调用TSP接口获取保单信息pdf路径
* @date 2020/5/28 * @date 2020/5/28
*/ */
public class TspInsurancePdfTask implements Runnable{ public class TspGetInsurancePdfTask implements Runnable{
private Logger logger = LoggerFactory.getLogger(TspInsurancePdfTask.class); private Logger logger = LoggerFactory.getLogger(TspGetInsurancePdfTask.class);
private Integer id; private Integer id;
private SysInsurancePolicyMapper policyMapper; private SysInsurancePolicyMapper policyMapper;
...@@ -37,7 +37,7 @@ public class TspInsurancePdfTask implements Runnable{ ...@@ -37,7 +37,7 @@ public class TspInsurancePdfTask implements Runnable{
protected final int TRY_COUNT = 3; protected final int TRY_COUNT = 3;
protected final int TRY_WAIT_TIME = 5 * 100; protected final int TRY_WAIT_TIME = 5 * 100;
public TspInsurancePdfTask(Integer id, SysInsurancePolicyMapper policyMapper, Semaphore semaphore) { public TspGetInsurancePdfTask(Integer id, SysInsurancePolicyMapper policyMapper, Semaphore semaphore) {
this.id = id; this.id = id;
this.policyMapper = policyMapper; this.policyMapper = policyMapper;
this.semaphore = semaphore; this.semaphore = semaphore;
......
...@@ -6,6 +6,7 @@ import com.glsx.common.utils.PropertiesUtil; ...@@ -6,6 +6,7 @@ import com.glsx.common.utils.PropertiesUtil;
import com.glsx.common.utils.StringUtils; import com.glsx.common.utils.StringUtils;
import com.glsx.gps.utils.HttpUtil; import com.glsx.gps.utils.HttpUtil;
import com.glsx.ordercenter.constants.insurance.InsuranceCardType; import com.glsx.ordercenter.constants.insurance.InsuranceCardType;
import com.glsx.ordercenter.constants.insurance.InsuranceCompany;
import com.glsx.ordercenter.constants.insurance.InsuranceCustomerType; import com.glsx.ordercenter.constants.insurance.InsuranceCustomerType;
import com.glsx.ordercenter.constants.insurance.InsuranceStatus; import com.glsx.ordercenter.constants.insurance.InsuranceStatus;
import com.glsx.ordercenter.dto.insurance.TspResp; import com.glsx.ordercenter.dto.insurance.TspResp;
...@@ -27,14 +28,14 @@ import java.util.concurrent.Semaphore; ...@@ -27,14 +28,14 @@ import java.util.concurrent.Semaphore;
/** /**
* @author think.wang * @author think.wang
* @version 1.0.0 * @version 1.0.0
* @Title TspSaveInsuranceTask * @Title TspSaveInsuranceDataTask
* @Package com.glsx.ordercenter.thread * @Package com.glsx.ordercenter.thread
* @Description 调用TSP接口进行投保 * @Description 调用TSP接口进行投保
* @date 2020/5/28 * @date 2020/5/28
*/ */
public class TspSaveInsuranceTask implements Runnable{ public class TspSaveInsuranceDataTask implements Runnable{
private Logger logger = LoggerFactory.getLogger(TspSaveInsuranceTask.class); private Logger logger = LoggerFactory.getLogger(TspSaveInsuranceDataTask.class);
private SysInsurancePolicy data; private SysInsurancePolicy data;
private SysInsurancePolicyMapper policyMapper; private SysInsurancePolicyMapper policyMapper;
...@@ -43,7 +44,7 @@ public class TspSaveInsuranceTask implements Runnable{ ...@@ -43,7 +44,7 @@ public class TspSaveInsuranceTask implements Runnable{
protected final int TRY_COUNT = 3; protected final int TRY_COUNT = 3;
protected final int TRY_WAIT_TIME = 5 * 100; protected final int TRY_WAIT_TIME = 5 * 100;
public TspSaveInsuranceTask(SysInsurancePolicy data, SysInsurancePolicyMapper policyMapper, Semaphore semaphore) { public TspSaveInsuranceDataTask(SysInsurancePolicy data, SysInsurancePolicyMapper policyMapper, Semaphore semaphore) {
this.data = data; this.data = data;
this.policyMapper = policyMapper; this.policyMapper = policyMapper;
this.semaphore = semaphore; this.semaphore = semaphore;
...@@ -63,10 +64,10 @@ public class TspSaveInsuranceTask implements Runnable{ ...@@ -63,10 +64,10 @@ public class TspSaveInsuranceTask implements Runnable{
String source = PropertiesUtil.getProperty("insurance.picc.source"); String source = PropertiesUtil.getProperty("insurance.picc.source");
//业务参数封装 //业务参数封装
TspSaveReq req = this.setSaveData(data); TspSaveReq saveData = this.setSendData(this.data);
//对象转map进行签名 //对象转map进行签名
logger.info("投保签名的对象为:{}", JSON.toJSONString(req)); logger.info("投保签名的对象为:{}", JSON.toJSONString(saveData));
Map<String, String> map = ObjectUtils.objectToMap(req); Map<String, String> map = ObjectUtils.objectToMap(saveData);
//系统参数封装 //系统参数封装
map.put("method", method); map.put("method", method);
...@@ -84,7 +85,7 @@ public class TspSaveInsuranceTask implements Runnable{ ...@@ -84,7 +85,7 @@ public class TspSaveInsuranceTask implements Runnable{
while (tryCount-- > 0) { while (tryCount-- > 0) {
try { try {
result = HttpUtil.postData(insuranceUrl, JSON.toJSONString(map), ContentType.APPLICATION_JSON); result = HttpUtil.postData(insuranceUrl, JSON.toJSONString(map), ContentType.APPLICATION_JSON);
logger.info(result + "======投保请求人保投保响应数据=========" + map.get("standNo")); logger.info(result + "======请求人保投保响应数据=========" + map.get("standNo"));
break; break;
} catch (Exception e) { } catch (Exception e) {
Thread.sleep(TRY_WAIT_TIME); Thread.sleep(TRY_WAIT_TIME);
...@@ -92,7 +93,7 @@ public class TspSaveInsuranceTask implements Runnable{ ...@@ -92,7 +93,7 @@ public class TspSaveInsuranceTask implements Runnable{
} }
} }
SysInsurancePolicy policy = new SysInsurancePolicy(); SysInsurancePolicy policy = new SysInsurancePolicy();
policy.setId(data.getId()); policy.setId(this.data.getId());
TspResp tspResp = JSON.parseObject(result, TspResp.class); TspResp tspResp = JSON.parseObject(result, TspResp.class);
if(tspResp.getCode().equals("0")){ //请求成功 if(tspResp.getCode().equals("0")){ //请求成功
TspRespData respData = tspResp.getData(); TspRespData respData = tspResp.getData();
...@@ -115,51 +116,51 @@ public class TspSaveInsuranceTask implements Runnable{ ...@@ -115,51 +116,51 @@ public class TspSaveInsuranceTask implements Runnable{
* @param policy * @param policy
* @return * @return
*/ */
private TspSaveReq setSaveData(SysInsurancePolicy policy){ private TspSaveReq setSendData(SysInsurancePolicy policy){
TspSaveReq saveReq = new TspSaveReq(); TspSaveReq saveData = new TspSaveReq();
saveReq.setInsuranceCompany("picc"); //默认人保 saveData.setInsuranceCompany(InsuranceCompany.PICC.getCompanyCode()); //默认人保
saveReq.setSeqNo(UUID.randomUUID().toString()); saveData.setSeqNo(UUID.randomUUID().toString());
saveReq.setPlanNo("0000"); saveData.setPlanNo("0000");
saveReq.setCompensationName(policy.getTastingUnit()); //第一受益人 saveData.setCompensationName(policy.getTastingUnit()); //第一受益人
String address = policy.getVehicleOwnerAddress(); String address = policy.getVehicleOwnerAddress();
saveReq.setAddress(StringUtils.isEmpty(address) ? "暂无" : address); //车主地址 必填 saveData.setAddress(StringUtils.isEmpty(address) ? "暂无" : address); //车主地址 必填
String customerType = InsuranceCustomerType.INDIVIDUAL.getType().equals(policy.getCustomerType()) ? "00" : "02"; String customerType = InsuranceCustomerType.INDIVIDUAL.getType().equals(policy.getCustomerType()) ? "00" : "02";
saveReq.setCustomerType(customerType); saveData.setCustomerType(customerType);
String cardType = InsuranceCardType.CREDIT_CODE.getType().equals(policy.getIdCardType()) ? "02" : "00"; //其他和身份证都传身份证类型 String cardType = InsuranceCardType.CREDIT_CODE.getType().equals(policy.getIdCardType()) ? "02" : "00"; //其他和身份证都传身份证类型
saveReq.setCardType(cardType); saveData.setCardType(cardType);
saveReq.setCardNo(policy.getIdCardNum()); saveData.setCardNo(policy.getIdCardNum());
saveReq.setBirthday(""); //填写 saveData.setBirthday(""); //填写
saveReq.setName(policy.getVehicleOwnerName()); saveData.setName(policy.getVehicleOwnerName());
saveReq.setSex(""); saveData.setSex("");
saveReq.setPhone(policy.getPhone()); saveData.setPhone(policy.getPhone());
saveReq.setEffectDate(DateUtil.formatDate(policy.getExpectedEffectiveTime())); saveData.setEffectDate(DateUtil.formatDate(policy.getExpectedEffectiveTime()));
saveReq.setInsurePeriod(String.valueOf(policy.getInsurancePeriod() * 12)); //保单期限 saveData.setInsurePeriod(String.valueOf(policy.getInsurancePeriod() * 12)); //保单期限
saveReq.setInstallPoint(""); saveData.setInstallPoint("");
saveReq.setInstallPerson(""); saveData.setInstallPerson("");
saveReq.setSumAmount(String.valueOf(policy.getPilferInsuranceMoney())); //保额 必填 saveData.setSumAmount(String.valueOf(policy.getVehicleInvoiceMoney())); //保额 必填
saveReq.setSumPremium(0L); //保费 saveData.setSumPremium(0L); //保费
saveReq.setSpid(""); saveData.setSpid("");
saveReq.setSpecialContent(""); saveData.setSpecialContent("");
saveReq.setDeviceName(""); //设备型号 saveData.setDeviceName(""); //设备型号
saveReq.setProductType(""); //产品类型 saveData.setProductType(""); //产品类型
saveReq.setDeviceType(""); saveData.setDeviceType("");
saveReq.setSn(policy.getGpsNo()); //设备号 saveData.setSn(policy.getGpsNo()); //设备号
saveReq.setActiveDate(""); saveData.setActiveDate("");
saveReq.setStandNo(policy.getVin()); saveData.setStandNo(policy.getVin());
saveReq.setPlateNum(policy.getVehicleNo()); saveData.setPlateNum(policy.getVehicleNo());
saveReq.setEngine(policy.getEngineNumber()); saveData.setEngine(policy.getEngineNumber());
saveReq.setBuyType("00"); //默认贷款车 saveData.setBuyType("00"); //默认贷款车
saveReq.setVehicleColor(policy.getVehicleColor()); saveData.setVehicleColor(policy.getVehicleColor());
saveReq.setVehicleBrand(policy.getCarBrand()); saveData.setVehicleBrand(policy.getCarBrand());
saveReq.setVehicleChildsBrandName("其他"); saveData.setVehicleChildsBrandName("其他");
saveReq.setVehicleSeriesName("其他"); saveData.setVehicleSeriesName("其他");
saveReq.setVehicleTypeName(""); saveData.setVehicleTypeName("");
saveReq.setVehiclePrice(policy.getVehicleInvoiceMoney()); //车辆价格 saveData.setVehiclePrice(policy.getVehicleInvoiceMoney()); //车辆价格
saveReq.setVehicleUsage("1"); //默认都是非运营车 saveData.setVehicleUsage("1"); //默认都是非运营车
saveReq.setShopName(""); saveData.setShopName("");
saveReq.setFixTime(""); saveData.setFixTime("");
return saveReq; return saveData;
} }
......
package com.glsx.ordercenter.thread;
import com.alibaba.fastjson.JSON;
import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.common.utils.StringUtils;
import com.glsx.gps.utils.HttpUtil;
import com.glsx.ordercenter.constants.insurance.InsuranceCompany;
import com.glsx.ordercenter.constants.insurance.InsuranceCustomerType;
import com.glsx.ordercenter.constants.insurance.InsuranceStatus;
import com.glsx.ordercenter.dto.insurance.TspResp;
import com.glsx.ordercenter.dto.insurance.TspRespData;
import com.glsx.ordercenter.dto.insurance.TspUpdateReq;
import com.glsx.ordercenter.mapper.insurance.SysInsurancePolicyMapper;
import com.glsx.ordercenter.pojo.insurance.SysInsurancePolicy;
import com.glsx.ordercenter.utils.ObjectUtils;
import com.glsx.ordercenter.utils.TspSignUtil;
import org.apache.http.entity.ContentType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.Semaphore;
/**
* @author think.wang
* @version 1.0.0
* @Title TspUpdateInsuranceDataTask
* @Package com.glsx.ordercenter.thread
* @Description 调用TSP接口修改保单
* @date 2020/5/28
*/
public class TspUpdateInsuranceDataTask implements Runnable{
private Logger logger = LoggerFactory.getLogger(TspUpdateInsuranceDataTask.class);
private SysInsurancePolicy data;
private SysInsurancePolicyMapper policyMapper;
private Semaphore semaphore;
protected final int TRY_COUNT = 3;
protected final int TRY_WAIT_TIME = 5 * 100;
public TspUpdateInsuranceDataTask(SysInsurancePolicy data, SysInsurancePolicyMapper policyMapper, Semaphore semaphore) {
this.data = data;
this.policyMapper = policyMapper;
this.semaphore = semaphore;
}
@Override
public void run() {
try {
semaphore.acquire();
//系统参数获取
String insuranceUrl = PropertiesUtil.getProperty("insurance.picc.url");
String method = PropertiesUtil.getProperty("insurance.picc.update"); //修改保单方法
String appKey = PropertiesUtil.getProperty("insurance.picc.appKey");
String appSecret = PropertiesUtil.getProperty("insurance.picc.secret");
String version = PropertiesUtil.getProperty("insurance.picc.version");
String format = PropertiesUtil.getProperty("insurance.picc.format");
String source = PropertiesUtil.getProperty("insurance.picc.source");
//业务参数封装
TspUpdateReq updateData = this.setSendData(data);
//对象转map进行签名
logger.info("修改保单签名的对象为:{}", JSON.toJSONString(updateData));
Map<String, String> map = ObjectUtils.objectToMap(updateData);
//系统参数封装
map.put("method", method);
map.put("format", format);
map.put("v", version);
map.put("appKey", appKey);
map.put("timestamp", DateUtil.formatDate(new Date()));
map.put("source", source);
String sign = TspSignUtil.sign(map, appSecret); //除了sign所有参数进行验签
map.put("sign", sign);
//发送请求
String result = null;
int tryCount = TRY_COUNT;
while (tryCount-- > 0) {
try {
result = HttpUtil.postData(insuranceUrl, JSON.toJSONString(map), ContentType.APPLICATION_JSON);
logger.info(result + "======请求修改投保响应数据=========" + map.get("fullInsuranceNo"));
break;
} catch (Exception e) {
Thread.sleep(TRY_WAIT_TIME);
continue;
}
}
SysInsurancePolicy policy = new SysInsurancePolicy();
policy.setId(data.getId());
TspResp tspResp = JSON.parseObject(result, TspResp.class);
if(tspResp.getCode().equals("0")){ //请求成功
TspRespData respData = tspResp.getData();
policy.setStatus(InsuranceStatus.APPLIED.getStatus().byteValue());
policy.setInsuranceNo(respData.getObj()); //保单号set
policy.setInsuranceSeqNo(respData.getInfo()); //保单序列号set
}else{
policy.setStatus(InsuranceStatus.APPLY_FAILED.getStatus().byteValue()); //更新状态投保失败
}
policyMapper.updateByPrimaryKeySelective(policy); //保存返回数据
} catch (Exception e) {
logger.error("调用TSP投保接口异常:{}", e);
}finally {
semaphore.release();
}
}
/**
* 数据设置
* @param policy
* @return
*/
private TspUpdateReq setSendData(SysInsurancePolicy policy){
TspUpdateReq updateData = new TspUpdateReq();
updateData.setInsuranceCompany(InsuranceCompany.PICC.getCompanyCode()); //默认人保
updateData.setFullInsuranceNo(policy.getInsuranceNo());
updateData.setSeqNo(policy.getInsuranceSeqNo());
updateData.setCompensationName(policy.getTastingUnit()); //第一受益人
String address = policy.getVehicleOwnerAddress();
updateData.setAddress(StringUtils.isEmpty(address) ? "暂无" : address); //车主地址 必填
String customerType = InsuranceCustomerType.INDIVIDUAL.getType().equals(policy.getCustomerType()) ? "00" : "02";
updateData.setCustomerType(customerType);
updateData.setBirthday(""); //填写
updateData.setName(policy.getVehicleOwnerName());
updateData.setSex("");
updateData.setPhone(policy.getPhone());
updateData.setEffectDate(DateUtil.formatDate(policy.getExpectedEffectiveTime()));
updateData.setInsurePeriod(String.valueOf(policy.getInsurancePeriod() * 12)); //保单期限
updateData.setInstallPoint("");
updateData.setInstallPerson("");
updateData.setSumAmount(String.valueOf(policy.getVehicleInvoiceMoney())); //保额 必填
updateData.setSpid("");
updateData.setSpecialContent("");
updateData.setStandNo(policy.getVin());
updateData.setPlateNum(policy.getVehicleNo());
updateData.setEngine(policy.getEngineNumber());
updateData.setBuyType("00"); //默认贷款车
updateData.setVehicleColor(policy.getVehicleColor());
updateData.setVehicleBrand(policy.getCarBrand());
updateData.setVehicleChildsBrandName("其他");
updateData.setVehicleSeriesName("其他");
updateData.setVehicleTypeName("");
updateData.setVehiclePrice(policy.getVehicleInvoiceMoney()); //车辆价格
updateData.setVehicleUsage("1"); //默认都是非运营车
updateData.setShopName("");
updateData.setFixTime("");
return updateData;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!