|
|
@ -113,24 +113,12 @@ public class InBusinessController { |
|
|
|
if (serviceBusiness == null) { |
|
|
|
return AjaxResult.error("未找到对应的业务配置"); |
|
|
|
} |
|
|
|
// 调用数据库查询 |
|
|
|
AjaxResult ajaxResult = this.outQuery(id, serviceBusiness); |
|
|
|
if (!ajaxResult.isSuccess()) { |
|
|
|
return ajaxResult; |
|
|
|
} |
|
|
|
Object bodyData = ajaxResult.get("data"); |
|
|
|
if (bodyData == null) { |
|
|
|
return ajaxResult; |
|
|
|
} |
|
|
|
if (!(bodyData instanceof Map)) { |
|
|
|
return AjaxResult.error("响应数据格式异常"); |
|
|
|
} |
|
|
|
Map<String, Object> dataMap = (Map<String, Object>) bodyData; |
|
|
|
Object rows = dataMap.get("rows"); |
|
|
|
if (!(rows instanceof List)) { |
|
|
|
return AjaxResult.error("缺少有效的业务数据"); |
|
|
|
// 获取ipcType |
|
|
|
String[] tableParts = serviceBusiness.getTableName().split("_"); |
|
|
|
if (tableParts.length < 3) { |
|
|
|
return AjaxResult.error("表名格式不符合规范: " + serviceBusiness.getTableName()); |
|
|
|
} |
|
|
|
List<?> rowsList = (List<?>) rows; |
|
|
|
String ipcType = tableParts[1].toUpperCase(); // 提取中间部分并转为大写 |
|
|
|
|
|
|
|
// 获取remark信息 |
|
|
|
String urlSuffix = ""; |
|
|
@ -143,6 +131,19 @@ public class InBusinessController { |
|
|
|
remarkJson = JSONObject.parseObject(serviceBusiness.getRemark()); |
|
|
|
// 提取 url 字段 |
|
|
|
urlSuffix = remarkJson.getString("url"); |
|
|
|
if (StringUtils.isEmpty(urlSuffix)) { |
|
|
|
return AjaxResult.error("remark 字段中缺少 url 字段"); |
|
|
|
} |
|
|
|
if (urlSuffix.contains("gl1001")) { |
|
|
|
Map<String, Object> reqMap = new HashMap<>(); |
|
|
|
TransportRequest request = buildRequest(ipcType, reqMap, finalToken); |
|
|
|
logger.info("线程[{}] 请求报文:\n{}", Thread.currentThread().getId(), gson.toJson(request)); |
|
|
|
String responseJson = postRequest(request, urlSuffix); |
|
|
|
TransportResponse response = parseResponse(responseJson); |
|
|
|
handleResponse(response, urlSuffix); |
|
|
|
logger.info("心跳检测成功"); |
|
|
|
return AjaxResult.success("心跳检测成功"); |
|
|
|
} |
|
|
|
reqBody = remarkJson.getString("body"); |
|
|
|
if (StringUtils.isEmpty(reqBody)) { |
|
|
|
reqBody = "recordInfo"; |
|
|
@ -153,7 +154,6 @@ public class InBusinessController { |
|
|
|
reqBody = parts[0]; |
|
|
|
reqBodyType = parts[1]; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("解析 remark 字段失败", e); |
|
|
@ -166,14 +166,25 @@ public class InBusinessController { |
|
|
|
final String finalUrlSuffix = urlSuffix; |
|
|
|
// 新增final副本用于lambda |
|
|
|
final String finalReqBody = reqBody; |
|
|
|
// 新增final副本用于lambda |
|
|
|
final String finalReqBodyType = reqBodyType; |
|
|
|
|
|
|
|
String[] tableParts = serviceBusiness.getTableName().split("_"); |
|
|
|
if (tableParts.length < 3) { |
|
|
|
return AjaxResult.error("表名格式不符合规范: " + serviceBusiness.getTableName()); |
|
|
|
// 调用数据库查询 |
|
|
|
AjaxResult ajaxResult = this.outQuery(id, serviceBusiness); |
|
|
|
if (!ajaxResult.isSuccess()) { |
|
|
|
return ajaxResult; |
|
|
|
} |
|
|
|
String ipcType = tableParts[1].toUpperCase(); // 提取中间部分并转为大写 |
|
|
|
Object bodyData = ajaxResult.get("data"); |
|
|
|
if (bodyData == null) { |
|
|
|
return ajaxResult; |
|
|
|
} |
|
|
|
if (!(bodyData instanceof Map)) { |
|
|
|
return AjaxResult.error("响应数据格式异常"); |
|
|
|
} |
|
|
|
Map<String, Object> dataMap = (Map<String, Object>) bodyData; |
|
|
|
Object rows = dataMap.get("rows"); |
|
|
|
if (!(rows instanceof List)) { |
|
|
|
return AjaxResult.error("缺少有效的业务数据"); |
|
|
|
} |
|
|
|
List<?> rowsList = (List<?>) rows; |
|
|
|
|
|
|
|
if ("JSONObject".equals(reqBodyType)){ |
|
|
|
Map<String, Object> reqMap = new HashMap<>(); |
|
|
|