|
|
@ -71,13 +71,15 @@ public class HaiAnInterfaceCallLogServiceImpl extends ServiceImpl<HaiAnInterface |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
try { |
|
|
try { |
|
|
|
|
|
// 统一调用方的Success/FAILED为页面状态码,仅转换日志状态,不根据响应提示文字重判接口成败 - rqrq |
|
|
|
|
|
String normalizedStatus = normalizeCallStatus(status); |
|
|
// 每次回填新建事务模板并挂起外层业务事务,避免共享可变配置及业务回滚丢失接口结果 - rqrq |
|
|
// 每次回填新建事务模板并挂起外层业务事务,避免共享可变配置及业务回滚丢失接口结果 - rqrq |
|
|
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); |
|
|
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); |
|
|
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); |
|
|
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); |
|
|
// 开启、更新、提交均在try内;新事务仅更新独立日志行,不操作业务表或依赖同类事务代理 - rqrq |
|
|
// 开启、更新、提交均在try内;新事务仅更新独立日志行,不操作业务表或依赖同类事务代理 - rqrq |
|
|
Integer updatedRows = transactionTemplate.execute(transactionStatus -> { |
|
|
Integer updatedRows = transactionTemplate.execute(transactionStatus -> { |
|
|
// logId来自已独立提交的请求日志;按主键直接回填完整响应、状态及耗时,SQL失败回滚本次日志事务 - rqrq |
|
|
// logId来自已独立提交的请求日志;按主键直接回填完整响应、状态及耗时,SQL失败回滚本次日志事务 - rqrq |
|
|
return this.baseMapper.updateCallResultDirect(logId, responseData, status, errorMessage, executionTime); |
|
|
|
|
|
|
|
|
return this.baseMapper.updateCallResultDirect(logId, responseData, normalizedStatus, errorMessage, executionTime); |
|
|
}); |
|
|
}); |
|
|
if (updatedRows == null || updatedRows != 1) { |
|
|
if (updatedRows == null || updatedRows != 1) { |
|
|
// 日志不存在等异常仅告警,保留业务原有成功或失败结果,避免静默漏记 - rqrq |
|
|
// 日志不存在等异常仅告警,保留业务原有成功或失败结果,避免静默漏记 - rqrq |
|
|
@ -104,7 +106,8 @@ public class HaiAnInterfaceCallLogServiceImpl extends ServiceImpl<HaiAnInterface |
|
|
callLog.setMethodName(methodName); |
|
|
callLog.setMethodName(methodName); |
|
|
callLog.setRequestData(requestData); |
|
|
callLog.setRequestData(requestData); |
|
|
callLog.setResponseData(responseData); |
|
|
callLog.setResponseData(responseData); |
|
|
callLog.setStatus(status); |
|
|
|
|
|
|
|
|
// 完整日志与结果回填采用同一状态口径,空值及未知状态保留,避免被误判为成功 - rqrq |
|
|
|
|
|
callLog.setStatus(normalizeCallStatus(status)); |
|
|
callLog.setErrorMessage(errorMessage); |
|
|
callLog.setErrorMessage(errorMessage); |
|
|
callLog.setExecutionTime(executionTime); |
|
|
callLog.setExecutionTime(executionTime); |
|
|
callLog.setSite(site); |
|
|
callLog.setSite(site); |
|
|
@ -118,6 +121,19 @@ public class HaiAnInterfaceCallLogServiceImpl extends ServiceImpl<HaiAnInterface |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 兼容历史成功/失败写法,输出SUCCESS/ERROR;其它状态原样保留,不解析resMsg、不改变业务返回结果 - rqrq |
|
|
|
|
|
*/ |
|
|
|
|
|
private String normalizeCallStatus(String status) { |
|
|
|
|
|
if ("SUCCESS".equalsIgnoreCase(status)) { |
|
|
|
|
|
return "SUCCESS"; |
|
|
|
|
|
} |
|
|
|
|
|
if ("FAILED".equalsIgnoreCase(status) || "ERROR".equalsIgnoreCase(status)) { |
|
|
|
|
|
return "ERROR"; |
|
|
|
|
|
} |
|
|
|
|
|
return status; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @author rqrq |
|
|
* @author rqrq |
|
|
* @Description 分页查询海安接口调用日志,支持站点/接口/状态/日期过滤 - rqrq |
|
|
* @Description 分页查询海安接口调用日志,支持站点/接口/状态/日期过滤 - rqrq |
|
|
@ -139,7 +155,15 @@ public class HaiAnInterfaceCallLogServiceImpl extends ServiceImpl<HaiAnInterface |
|
|
wrapper.like("business_key", data.getBusinessKey()); |
|
|
wrapper.like("business_key", data.getBusinessKey()); |
|
|
} |
|
|
} |
|
|
if (StringUtils.hasText(data.getStatus())) { |
|
|
if (StringUtils.hasText(data.getStatus())) { |
|
|
wrapper.eq("status", data.getStatus()); |
|
|
|
|
|
|
|
|
// 筛选兼容已有Success/FAILED日志,仍叠加工厂和其它条件,无需批量改写历史数据 - rqrq |
|
|
|
|
|
String status = normalizeCallStatus(data.getStatus()); |
|
|
|
|
|
if ("SUCCESS".equals(status)) { |
|
|
|
|
|
wrapper.in("status", "SUCCESS", "Success"); |
|
|
|
|
|
} else if ("ERROR".equals(status)) { |
|
|
|
|
|
wrapper.in("status", "ERROR", "FAILED"); |
|
|
|
|
|
} else { |
|
|
|
|
|
wrapper.eq("status", status); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
if (data.getStartDate() != null) { |
|
|
if (data.getStartDate() != null) { |
|
|
wrapper.ge("created_time", data.getStartDate()); |
|
|
wrapper.ge("created_time", data.getStartDate()); |
|
|
|