Commit 6977e8e9 by wangnb

包活干V1.9.0调接口取消尝试三次--think.wang

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@27331 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 968bdd82
......@@ -6,7 +6,6 @@ import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.HttpUtils;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.ordercenter.constants.insurance.InsuranceStatus;
import com.glsx.ordercenter.dto.resp.OraResultObject;
import com.glsx.ordercenter.mapper.insurance.SysInsurancePolicyMapper;
import com.glsx.ordercenter.pojo.insurance.SysInsurancePolicy;
import com.glsx.ordercenter.utils.OraSignUtil;
......@@ -34,9 +33,6 @@ public class OraReturnInsurancePdfTask implements Runnable{
private SysInsurancePolicyMapper policyMapper;
private Semaphore semaphore;
protected final int TRY_COUNT = 3;
protected final int TRY_WAIT_TIME = 5 * 100;
public OraReturnInsurancePdfTask(Integer id, SysInsurancePolicyMapper policyMapper, Semaphore semaphore) {
this.id = id;
this.policyMapper = policyMapper;
......@@ -95,22 +91,9 @@ public class OraReturnInsurancePdfTask implements Runnable{
urlBuf.append("&sign=" + sign);
//发送请求
String result = null;
int tryCount = TRY_COUNT;
while (tryCount-- > 0) {
try {
HttpUtils httpUtils = new HttpUtils();
result = httpUtils.postJson(urlBuf.toString(), params);
logger.info("保单号:{}回传保单响应数据:{}", insurancePolicy.getInsuranceNo() , result);
OraResultObject oreResult = JSON.parseObject(result, OraResultObject.class);
if(oreResult.getCode() == 0){
break;
}
} catch (Exception e) {
Thread.sleep(TRY_WAIT_TIME);
continue;
}
}
HttpUtils httpUtils = new HttpUtils();
String result = httpUtils.postJson(urlBuf.toString(), params);
logger.info("保单号:{}回传保单响应数据:{}", insurancePolicy.getInsuranceNo() , result);
} catch (Exception e) {
logger.error("调用欧拉接口回传保单接口异常:{}", e);
}finally {
......
......@@ -6,7 +6,6 @@ import com.alibaba.fastjson.JSONObject;
import com.glsx.common.utils.HttpUtils;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.ordercenter.constants.BizConstants;
import com.glsx.ordercenter.dto.resp.OraResultObject;
import com.glsx.ordercenter.exception.BusinessException;
import com.glsx.ordercenter.mapper.SysOrderDeviceMapper;
import com.glsx.ordercenter.mapper.SysOrderFileMapper;
......@@ -43,9 +42,6 @@ public class OraReturnOrderSetupTask implements Runnable {
private SysOrderFileMapper orderFileMapper;
private SysUserMapper userMapper;
protected final int TRY_COUNT = 3;
protected final int TRY_WAIT_TIME = 5 * 100;
public OraReturnOrderSetupTask(Integer id, SysOrderMapper orderMapper, SysOrderDeviceMapper orderDeviceMapper,
SysOrderFileMapper orderFileMapper, SysUserMapper userMapper) {
this.id = id;
......@@ -71,7 +67,7 @@ public class OraReturnOrderSetupTask implements Runnable {
logger.error("通过id={}未找到工单数据", id);
return;
}
if(!BizConstants.CC_ORA.equals(order.getChannel())){
if (!BizConstants.CC_ORA.equals(order.getChannel())) {
return;
}
//业务参数封装
......@@ -100,22 +96,9 @@ public class OraReturnOrderSetupTask implements Runnable {
urlBuf.append("&sign=" + sign);
//发送请求
String result = null;
int tryCount = TRY_COUNT;
while (tryCount-- > 0) {
try {
HttpUtils httpUtils = new HttpUtils();
result = httpUtils.postJson(urlBuf.toString(), params);
logger.info("订单id:{}回传修改预约信息响应数据:{}", id, result);
OraResultObject oreResult = JSON.parseObject(result, OraResultObject.class);
if (oreResult.getCode() == 0) {
break;
}
} catch (Exception e) {
Thread.sleep(TRY_WAIT_TIME);
continue;
}
}
HttpUtils httpUtils = new HttpUtils();
String result = httpUtils.postJson(urlBuf.toString(), params);
logger.info("订单id:{}回传修改预约信息响应数据:{}", id, result);
} catch (BusinessException e) {
logger.error("欧拉更新工单预约信息数据异常:{}", e.getResultEntity().toString());
} catch (Exception e) {
......
......@@ -6,7 +6,6 @@ import com.glsx.common.utils.HttpUtils;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.ordercenter.constants.BizConstants;
import com.glsx.ordercenter.constants.insurance.OraResultCode;
import com.glsx.ordercenter.dto.resp.OraResultObject;
import com.glsx.ordercenter.exception.BusinessException;
import com.glsx.ordercenter.mapper.SysAreaMapper;
import com.glsx.ordercenter.mapper.SysOrderMapper;
......@@ -28,7 +27,7 @@ import java.util.Map;
* @Description 欧拉接口更新工单预约信息
* @date 2020/5/28
*/
public class OraReturnReserveOrderInfoTask implements Runnable{
public class OraReturnReserveOrderInfoTask implements Runnable {
private Logger logger = LoggerFactory.getLogger(OraReturnReserveOrderInfoTask.class);
......@@ -36,9 +35,6 @@ public class OraReturnReserveOrderInfoTask implements Runnable{
private SysOrderMapper orderMapper;
private SysAreaMapper areaMapper;
protected final int TRY_COUNT = 3;
protected final int TRY_WAIT_TIME = 5 * 100;
public OraReturnReserveOrderInfoTask(Integer id, SysOrderMapper orderMapper, SysAreaMapper areaMapper) {
this.id = id;
this.orderMapper = orderMapper;
......@@ -57,11 +53,11 @@ public class OraReturnReserveOrderInfoTask implements Runnable{
String method = PropertiesUtil.getProperty("ora.workorder.updateOrder");
SysOrder order = orderMapper.selectByPrimaryKey(id);
if(order == null){
if (order == null) {
logger.error("通过id={}未找到工单数据", id);
return;
}
if(!BizConstants.CC_ORA.equals(order.getChannel())){
if (!BizConstants.CC_ORA.equals(order.getChannel())) {
return;
}
//业务参数封装
......@@ -90,63 +86,50 @@ public class OraReturnReserveOrderInfoTask implements Runnable{
urlBuf.append("&sign=" + sign);
//发送请求
String result = null;
int tryCount = TRY_COUNT;
while (tryCount-- > 0) {
try {
HttpUtils httpUtils = new HttpUtils();
result = httpUtils.postJson(urlBuf.toString(), params);
logger.info("订单id:{}回传修改预约信息响应数据:{}", id , result);
OraResultObject oreResult = JSON.parseObject(result, OraResultObject.class);
if(oreResult.getCode() == 0){
break;
}
} catch (Exception e) {
Thread.sleep(TRY_WAIT_TIME);
continue;
}
}
HttpUtils httpUtils = new HttpUtils();
String result = httpUtils.postJson(urlBuf.toString(), params);
logger.info("订单id:{}回传修改预约信息响应数据:{}", id, result);
} catch (BusinessException e) {
logger.error("欧拉更新工单预约信息数据异常:{}", e.getResultEntity().toString());
}
catch (Exception e) {
} catch (Exception e) {
logger.error("欧拉更新工单预约信息接口异常:{}", e.getMessage());
}
}
/**
* 业务参数封装
*
* @param order
* @return
*/
private JSONObject setBusinessParams(SysOrder order){
private JSONObject setBusinessParams(SysOrder order) {
JSONObject object = new JSONObject();
object.put("orderId",order.getWorkOrderNo());
object.put("orderId", order.getWorkOrderNo());
Integer district = order.getDistrict();
if(district != null){
object.put("cityId",district);
if (district != null) {
object.put("cityId", district);
SysArea cityObj = areaMapper.selectByPrimaryKey(district);
if(cityObj != null){
object.put("cityName",cityObj.getAreaName());
if (cityObj != null) {
object.put("cityName", cityObj.getAreaName());
Integer parentId = cityObj.getParentId();
if(parentId != null && parentId != 0){
object.put("provinceId",parentId);
if (parentId != null && parentId != 0) {
object.put("provinceId", parentId);
SysArea provinceObj = areaMapper.selectByPrimaryKey(parentId);
object.put("provinceName",provinceObj.getAreaName());
} else{
throw BusinessException.create(OraResultCode.PARAM_ERROR.getCode(),"工单id:" + id + "未找到省级数据");
object.put("provinceName", provinceObj.getAreaName());
} else {
throw BusinessException.create(OraResultCode.PARAM_ERROR.getCode(), "工单id:" + id + "未找到省级数据");
}
}else{
throw BusinessException.create(OraResultCode.PARAM_ERROR.getCode(),"工单id:" + id + "通过district未找到市级数据");
} else {
throw BusinessException.create(OraResultCode.PARAM_ERROR.getCode(), "工单id:" + id + "通过district未找到市级数据");
}
} else{
throw BusinessException.create(OraResultCode.PARAM_ERROR.getCode(),"工单id:" + id + "district为空");
} else {
throw BusinessException.create(OraResultCode.PARAM_ERROR.getCode(), "工单id:" + id + "district为空");
}
object.put("installAddress",order.getAddress());
object.put("reserveInstallationTime",order.getReserveInstallTime());
object.put("installAddress", order.getAddress());
object.put("reserveInstallationTime", order.getReserveInstallTime());
object.put("installStore", order.getMerchantName());
object.put("storeContacts",order.getContact());
object.put("storeContactPhone",order.getPhoneNumber());
object.put("storeContacts", order.getContact());
object.put("storeContactPhone", order.getPhoneNumber());
return object;
}
......
......@@ -26,7 +26,7 @@ import java.util.concurrent.Semaphore;
* @Description 调用TSP接口获取保单信息pdf路径
* @date 2020/5/28
*/
public class TspGetInsurancePdfTask implements Runnable{
public class TspGetInsurancePdfTask implements Runnable {
private Logger logger = LoggerFactory.getLogger(TspGetInsurancePdfTask.class);
......@@ -34,9 +34,6 @@ public class TspGetInsurancePdfTask implements Runnable{
private SysInsurancePolicyMapper policyMapper;
private Semaphore semaphore;
protected final int TRY_COUNT = 3;
protected final int TRY_WAIT_TIME = 5 * 100;
public TspGetInsurancePdfTask(Integer id, SysInsurancePolicyMapper policyMapper, Semaphore semaphore) {
this.id = id;
this.policyMapper = policyMapper;
......@@ -57,11 +54,11 @@ public class TspGetInsurancePdfTask implements Runnable{
String source = PropertiesUtil.getProperty("insurance.picc.source");
SysInsurancePolicy insurancePolicy = policyMapper.selectByPrimaryKey(id);
if(insurancePolicy == null){
if (insurancePolicy == null) {
logger.error("通过id={}未找到保单数据", id);
return;
}
if(insurancePolicy.getStatus().byteValue() != InsuranceStatus.APPLIED.getStatus()){
if (insurancePolicy.getStatus().byteValue() != InsuranceStatus.APPLIED.getStatus()) {
logger.error("id={}保单数据未成功投保", id);
return;
}
......@@ -83,31 +80,21 @@ public class TspGetInsurancePdfTask implements Runnable{
map.put("sign", sign);
logger.info("获取保单pdf传送数据为:{}", JSON.toJSONString(map));
//发送请求
String result = null;
int tryCount = TRY_COUNT;
while (tryCount-- > 0) {
try {
result = HttpUtil.postFormData(insuranceUrl, map);
break;
} catch (Exception e) {
Thread.sleep(TRY_WAIT_TIME);
continue;
}
}
logger.info("保单号:{}获取pdf信息响应数据:{}", map.get("fullInsuranceNo"), result);
String result = HttpUtil.postFormData(insuranceUrl, map);
logger.info("保单号:{}获取pdf信息响应数据:{}", map.get("fullInsuranceNo"), result);
TspResp tspResp = JSON.parseObject(result, TspResp.class);
if(tspResp != null && "0".equals(tspResp.getCode())){ //请求成功
if (tspResp != null && "0".equals(tspResp.getCode())) { //请求成功
SysInsurancePolicy policy = new SysInsurancePolicy();
policy.setId(id);
TspRespData respData = tspResp.getData();
policy.setInsurancePdf(respData.getObj()); //得到pdf路径
policyMapper.updateByPrimaryKeySelective(policy); //保存返回数据
}else{
} else {
logger.error("获取保单pdf失败,保单号为:{}", map.get("fullInsuranceNo"));
}
} catch (Exception e) {
logger.error("调用TSP获取pdf接口异常:{}", e);
}finally {
} finally {
semaphore.release();
}
}
......
......@@ -33,7 +33,7 @@ import java.util.concurrent.CountDownLatch;
* @Description 调用TSP接口进行投保
* @date 2020/5/28
*/
public class TspSaveInsuranceDataTask implements Runnable{
public class TspSaveInsuranceDataTask implements Runnable {
private Logger logger = LoggerFactory.getLogger(TspSaveInsuranceDataTask.class);
......@@ -41,9 +41,6 @@ public class TspSaveInsuranceDataTask implements Runnable{
private SysInsurancePolicyMapper policyMapper;
private CountDownLatch countDownLatch;
protected final int TRY_COUNT = 3;
protected final int TRY_WAIT_TIME = 5 * 100;
public TspSaveInsuranceDataTask(Integer id, SysInsurancePolicyMapper policyMapper, CountDownLatch countDownLatch) {
this.id = id;
this.policyMapper = policyMapper;
......@@ -63,7 +60,7 @@ public class TspSaveInsuranceDataTask implements Runnable{
String source = PropertiesUtil.getProperty("insurance.picc.source");
SysInsurancePolicy insurancePolicy = policyMapper.selectByPrimaryKey(id);
if(insurancePolicy == null){
if (insurancePolicy == null) {
logger.error("通过id={}未找到保单数据", id);
return;
}
......@@ -84,23 +81,13 @@ public class TspSaveInsuranceDataTask implements Runnable{
map.put("sign", sign);
logger.info("投保发送数据为:{}", JSON.toJSONString(map));
//发送请求
String result = null;
int tryCount = TRY_COUNT;
while (tryCount-- > 0) {
try {
result = HttpUtil.postFormData(insuranceUrl, map);
break;
} catch (Exception e) {
Thread.sleep(TRY_WAIT_TIME);
continue;
}
}
logger.info("车架号:{}投保响应数据:{}", map.get("standNo"), result);
String result = HttpUtil.postFormData(insuranceUrl, map);
logger.info("车架号:{}投保响应数据:{}", map.get("standNo"), result);
SysInsurancePolicy policy = new SysInsurancePolicy();
policy.setId(id);
Date now = new Date();
TspResp tspResp = JSON.parseObject(result, TspResp.class);
if(tspResp != null && "0".equals(tspResp.getCode())){ //请求成功
if (tspResp != null && "0".equals(tspResp.getCode())) { //请求成功
TspRespData respData = tspResp.getData();
policy.setStatus(InsuranceStatus.APPLIED.getStatus().byteValue());
policy.setInsuranceNo(respData.getObj()); //保单号set
......@@ -108,7 +95,7 @@ public class TspSaveInsuranceDataTask implements Runnable{
policy.setInsuranceSeqNo(respData.getInfo()); //保单序列号set
policy.setExpectedEffectiveTime(DateUtil.getStartDateOfNextDay(now)); //预期生效日期
policy.setRealEffectiveTime(now); //实际生效日期
}else{
} else {
policy.setStatus(InsuranceStatus.APPLY_FAILED.getStatus().byteValue()); //更新状态投保失败
}
policy.setUpdateTime(now);
......@@ -116,17 +103,18 @@ public class TspSaveInsuranceDataTask implements Runnable{
policyMapper.updateByPrimaryKeySelective(policy); //保存返回数据
} catch (Exception e) {
logger.error("调用TSP投保接口异常:{}", e);
}finally {
} finally {
countDownLatch.countDown();
}
}
/**
* 数据设置
*
* @param policy
* @return
*/
private TspSaveReq setSendData(SysInsurancePolicy policy){
private TspSaveReq setSendData(SysInsurancePolicy policy) {
TspSaveReq saveData = new TspSaveReq();
saveData.setInsuranceCompany(InsuranceCompany.PICC.getCompanyCode()); //默认人保
......@@ -149,7 +137,7 @@ public class TspSaveInsuranceDataTask implements Runnable{
saveData.setInstallPoint("");
saveData.setInstallPerson("");
saveData.setSumAmount(policy.getVehicleInvoiceMoney()
.setScale(0, RoundingMode.FLOOR).toPlainString()); //保额 必填
.setScale(0, RoundingMode.FLOOR).toPlainString()); //保额 必填
saveData.setSumPremium(0L); //保费
saveData.setSpid("");
saveData.setSpecialContent("");
......@@ -168,7 +156,7 @@ public class TspSaveInsuranceDataTask implements Runnable{
saveData.setVehicleSeriesName("其他");
saveData.setVehicleTypeName("");
saveData.setVehiclePrice(policy.getVehicleInvoiceMoney()
.setScale(0, RoundingMode.FLOOR).toPlainString()); //车辆价格
.setScale(0, RoundingMode.FLOOR).toPlainString()); //车辆价格
saveData.setVehicleUsage("1"); //默认都是非运营车
saveData.setShopName("");
saveData.setFixTime("");
......
package com.glsx.ordercenter.thread;
import java.math.RoundingMode;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.Semaphore;
import com.alibaba.fastjson.JSON;
import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.PropertiesUtil;
......@@ -20,6 +16,11 @@ import com.glsx.ordercenter.utils.TspSignUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.RoundingMode;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.Semaphore;
/**
* @author think.wang
* @version 1.0.0
......@@ -28,7 +29,7 @@ import org.slf4j.LoggerFactory;
* @Description 调用TSP接口修改保单
* @date 2020/5/28
*/
public class TspUpdateInsuranceDataTask implements Runnable{
public class TspUpdateInsuranceDataTask implements Runnable {
private Logger logger = LoggerFactory.getLogger(TspUpdateInsuranceDataTask.class);
......@@ -36,9 +37,6 @@ public class TspUpdateInsuranceDataTask implements Runnable{
private SysInsurancePolicyMapper policyMapper;
private Semaphore semaphore;
protected final int TRY_COUNT = 3;
protected final int TRY_WAIT_TIME = 5 * 100;
public TspUpdateInsuranceDataTask(Integer id, SysInsurancePolicyMapper policyMapper, Semaphore semaphore) {
this.id = id;
this.policyMapper = policyMapper;
......@@ -59,7 +57,7 @@ public class TspUpdateInsuranceDataTask implements Runnable{
String source = PropertiesUtil.getProperty("insurance.picc.source");
SysInsurancePolicy insurancePolicy = policyMapper.selectByPrimaryKey(id);
if(insurancePolicy == null){
if (insurancePolicy == null) {
logger.error("通过id={}未找到保单数据", id);
return;
}
......@@ -80,37 +78,28 @@ public class TspUpdateInsuranceDataTask implements Runnable{
map.put("sign", sign);
logger.info("修改保单发送数据为:{}", JSON.toJSONString(map));
//发送请求
String result = null;
int tryCount = TRY_COUNT;
while (tryCount-- > 0) {
try {
result = HttpUtil.postFormData(insuranceUrl, map);
break;
} catch (Exception e) {
Thread.sleep(TRY_WAIT_TIME);
continue;
}
}
String result = HttpUtil.postFormData(insuranceUrl, map);
logger.info("保单号:{}修改投保响应数据:{}", map.get("fullInsuranceNo"), result);
TspResp tspResp = JSON.parseObject(result, TspResp.class);
if(tspResp != null && "0".equals(tspResp.getCode())){ //请求成功
if (tspResp != null && "0".equals(tspResp.getCode())) { //请求成功
logger.info("修改保单数据成功,保单号为:{}", map.get("fullInsuranceNo"));
}else{
} else {
logger.error("修改保单数据失败,保单号为:{}", map.get("fullInsuranceNo"));
}
} catch (Exception e) {
logger.error("调用TSP投保接口异常:{}", e);
}finally {
} finally {
semaphore.release();
}
}
/**
* 数据设置
*
* @param policy
* @return
*/
private TspUpdateReq setSendData(SysInsurancePolicy policy){
private TspUpdateReq setSendData(SysInsurancePolicy policy) {
TspUpdateReq updateData = new TspUpdateReq();
updateData.setInsuranceCompany(InsuranceCompany.PICC.getCompanyCode()); //默认人保
......@@ -130,7 +119,7 @@ public class TspUpdateInsuranceDataTask implements Runnable{
updateData.setInstallPoint("");
updateData.setInstallPerson("");
updateData.setSumAmount(policy.getVehicleInvoiceMoney()
.setScale(0, RoundingMode.FLOOR).toPlainString()); //保额 必填
.setScale(0, RoundingMode.FLOOR).toPlainString()); //保额 必填
updateData.setSpid("");
updateData.setSpecialContent("");
updateData.setStandNo(policy.getVin());
......@@ -143,7 +132,7 @@ public class TspUpdateInsuranceDataTask implements Runnable{
updateData.setVehicleSeriesName("其他");
updateData.setVehicleTypeName("");
updateData.setVehiclePrice(policy.getVehicleInvoiceMoney()
.setScale(0, RoundingMode.FLOOR).toPlainString()); //车辆价格
.setScale(0, RoundingMode.FLOOR).toPlainString()); //车辆价格
updateData.setVehicleUsage("1"); //默认都是非运营车
updateData.setShopName("");
updateData.setFixTime("");
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!