Commit ba89541f by wubh

包活干V1.9.0-修改:退保重试增加延迟

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@27016 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 709c178b
......@@ -490,11 +490,10 @@ public class ReportController extends BaseReportController {
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
super.mergeRequestParams(insuranceReq, InsuranceReq.class);
insuranceReq.setPageIndex(null);
insuranceReq.setPageSize(null);
PagedResp<InsuranceResp> pagedResp = this.insuranceService.query(insuranceReq);
insuranceReq.setPageIndex(-1);
PagedResp<InsuranceResp> result = this.insuranceService.query(insuranceReq);
if (pagedResp.getItems().size() > 5000) {
if (result.getItems().size() > 5000) {
throw SysException.create(
ResultCodeEnum.INSURANCE_EXPORT_TO_MANY.getCode(),
ResultCodeEnum.INSURANCE_EXPORT_TO_MANY.getMsg());
......@@ -504,7 +503,7 @@ public class ReportController extends BaseReportController {
if (attributes != null && attributes.getResponse() != null) {
String title = "保单详情-" +
DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss").format(LocalDateTime.now());
this.exportObject(attributes.getResponse(), pagedResp.getItems(), title);
this.exportObject(attributes.getResponse(), result.getItems(), title);
} else {
throw new IOException(ResultCodeEnum.INSURANCE_EXPORT_NOT_SUPPORTED.getMsg());
}
......
......@@ -58,6 +58,7 @@ public class InsuranceServiceImpl extends BaseOrderService implements InsuranceS
* 调用API失败重试次数
*/
private static final int API_INVOKE_RETRIES = 3;
private static final int API_INVOKE_RETRY_DELAY = 500;
@Autowired
private SysInsurancePolicyMapper insurancePolicyMapper;
......@@ -251,7 +252,7 @@ public class InsuranceServiceImpl extends BaseOrderService implements InsuranceS
if (req instanceof PagedReq) {
PagedReq pagedReq = (PagedReq) req;
if (pagedReq.getPageIndex() != null && pagedReq.getPageSize() != null) {
if (pagedReq.getPageIndex() > -1 && pagedReq.getPageSize() > -1) {
PageHelper.startPage(pagedReq.getPageIndex(),
pagedReq.getPageSize(), true);
}
......@@ -425,15 +426,20 @@ public class InsuranceServiceImpl extends BaseOrderService implements InsuranceS
tspRefundReq.setSeqNo(insurancePolicy.getInsuranceSeqNo());
this.taskExecutor.defaultThreadPool().execute(() -> {
TspResp tspResp = this.tspApiInvoker.with(this.appKey, this.secret)
.refund(tspRefundReq);
super.logInfo("TSP接口调用结果", tspResp);
// 判断是否调用成功
boolean invokeSuccess = TspResultCode.SUCCESS.getCode().equals(tspResp.getCode())
&& (tspResp.getData() != null)
&& tspResp.getData().getCallResult();
boolean invokeSuccess;
try {
TspResp tspResp = this.tspApiInvoker.with(this.appKey, this.secret)
.refund(tspRefundReq);
super.logInfo("TSP接口调用结果", tspResp);
// 判断是否调用成功
invokeSuccess = TspResultCode.SUCCESS.getCode().equals(tspResp.getCode())
&& (tspResp.getData() != null)
&& tspResp.getData().getCallResult();
} catch (RuntimeException e) {
super.logError("TSP接口调用异常", e);
invokeSuccess = false;
}
if (invokeSuccess) {
// 成功,更新字段状态
......@@ -442,7 +448,12 @@ public class InsuranceServiceImpl extends BaseOrderService implements InsuranceS
if (!invokeSuccess && retries > 1) {
// 如果失败并且需要重试则重新退保
this.refundAutomatically(insurancePolicy, retries - 1);
try {
Thread.sleep(API_INVOKE_RETRY_DELAY);
this.refundAutomatically(insurancePolicy, retries - 1);
} catch (InterruptedException e) {
super.logError("TSP重试调用错误", e);
}
}
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!