首页异常日志预警,异常日志重新推送功能
This commit is contained in:
parent
ef5d366074
commit
a1b601a41d
|
@ -3,6 +3,7 @@ package com.hzya.frame.sysnew.application.service;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
|
||||
import com.hzya.frame.basedao.service.IBaseService;
|
||||
import com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
@ -308,6 +309,8 @@ public interface ISysApplicationService extends IBaseService<SysApplicationEntit
|
|||
|
||||
JsonResultEntity externalCallInterface(ServletRequest servletRequest, ServletResponse servletResponse);
|
||||
|
||||
JsonResultEntity externalCallInterfaceResend(SysMessageManageLogEntity resendLogEntity);
|
||||
|
||||
/**
|
||||
* @Author lvleigang
|
||||
* @Description 应用列表查询接口 多字段模糊查询,枚举类型字段转换
|
||||
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.date.DateTime;
|
|||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
|
@ -2045,6 +2046,370 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional()
|
||||
public JsonResultEntity externalCallInterfaceResend(SysMessageManageLogEntity resendLogEntity) {
|
||||
|
||||
JSONObject objectSourceData = JSON.parseObject(resendLogEntity.getSourceData());
|
||||
JSONObject headerObject = objectSourceData.getJSONObject("header");
|
||||
if (headerObject == null || headerObject.equals("")) {
|
||||
return BaseResult.getFailureMessageEntity("传入源数据为空");
|
||||
}
|
||||
JSONObject bodyObject = objectSourceData.getJSONObject("body");
|
||||
//将请求头转换为map
|
||||
Map<String, String> oldheaderMap = new HashMap<>();
|
||||
Iterator it = headerObject.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, String> entry = (Map.Entry<String, String>) it.next();
|
||||
oldheaderMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
String oldId = resendLogEntity.getId();
|
||||
String oldbodys = bodyObject.toString();
|
||||
String oldquerys = "";
|
||||
//应用key
|
||||
String publicKey = headerObject.getString("publickey");
|
||||
//应用密钥
|
||||
String secretKey = headerObject.getString("secretkey");
|
||||
//appId
|
||||
String appId = headerObject.getString("appid");
|
||||
//apiCode
|
||||
String apiCode = headerObject.getString("apicode");
|
||||
String ip = headerObject.getString("x-real-ip");
|
||||
if (publicKey == null || "".equals(publicKey)) {
|
||||
return BaseResult.getFailureMessageEntity("请先传递公钥");
|
||||
}
|
||||
if (secretKey == null || "".equals(secretKey)) {
|
||||
return BaseResult.getFailureMessageEntity("请先传递密钥");
|
||||
}
|
||||
if (appId == null || "".equals(appId)) {
|
||||
return BaseResult.getFailureMessageEntity("请先传递接收方应用");
|
||||
}
|
||||
if (apiCode == null || "".equals(apiCode)) {
|
||||
return BaseResult.getFailureMessageEntity("请先传递发送接口");
|
||||
}
|
||||
|
||||
logger.info("请求参数:publicKey:【" + publicKey + "】secretKey:【" + secretKey + "】appId:【" + appId + "】apiCode:【" + apiCode);
|
||||
//根据请求a应用的公钥、密钥是否能查找到一条数据
|
||||
|
||||
SysApplicationEntity sendApp = getAppByPublicKeySecretKey(publicKey, secretKey);
|
||||
if (sendApp == null) {
|
||||
//saveLog(new SysApplicationEntity(), new SysApplicationEntity(), new SysApplicationApiEntity(), oldbodys, null, oldheaderMap, null, null, oldquerys, null, null, false,"公钥、密钥错误");
|
||||
return BaseResult.getFailureMessageEntity("公钥、密钥错误,请联系管理员");
|
||||
}
|
||||
//判断应用是否启用
|
||||
if (sendApp.getAppStatus() == null || !"1".equals(sendApp.getAppStatus())) {
|
||||
return BaseResult.getFailureMessageEntity(sendApp.getName() + "应用未启用,请联系管理员");
|
||||
}
|
||||
|
||||
SysApplicationEntity receiveApp = getAppByAppId(appId);
|
||||
if (receiveApp == null) {
|
||||
return BaseResult.getFailureMessageEntity("根据appId:" + appId + "未匹配到应用,请联系管理员");
|
||||
}
|
||||
//判断应用是否启用
|
||||
if (receiveApp.getAppStatus() == null || !"1".equals(receiveApp.getAppStatus())) {
|
||||
return BaseResult.getFailureMessageEntity(receiveApp.getName() + "应用未启用,请联系管理员");
|
||||
}
|
||||
//判断应用接口是否启用
|
||||
if (receiveApp.getInterfaceStatus() == null || !"1".equals(receiveApp.getInterfaceStatus())) {
|
||||
return BaseResult.getFailureMessageEntity(receiveApp.getName() + "应用接口环境未启用,请联系管理员");
|
||||
}
|
||||
|
||||
SysApplicationApiEntity receiveApi = getApiByAppIdApiCode(receiveApp.getId(), apiCode);
|
||||
if (receiveApi == null) {
|
||||
return BaseResult.getFailureMessageEntity(receiveApp.getName() + ":" + apiCode + "未启用或者未创建");
|
||||
}
|
||||
|
||||
SysApplicationApiAuthEntity sysApplicationApiAuthEntity = getApiAuthByNameAppId(sendApp.getId(), receiveApp.getId());
|
||||
if (sysApplicationApiAuthEntity == null) {
|
||||
return BaseResult.getFailureMessageEntity(receiveApp.getName() + "应用权限配置错误");
|
||||
}
|
||||
if (sysApplicationApiAuthEntity.getSystemAddress() != null && !"".equals(sysApplicationApiAuthEntity.getSystemAddress())
|
||||
&& !sysApplicationApiAuthEntity.getSystemAddress().contains(ip)) {
|
||||
return BaseResult.getFailureMessageEntity(receiveApp.getName() + "发送应用" + receiveApp.getName() + "的ip白名单配置错误");
|
||||
}
|
||||
|
||||
SysApplicationApiAuthDetailEntity sysApplicationApiAuthDetailEntity = getApiAuthDetailByAppIdApiIdTripartiteSystemId(receiveApp.getId(), receiveApi.getId(), sysApplicationApiAuthEntity.getId());
|
||||
if (sysApplicationApiAuthDetailEntity == null) {
|
||||
return BaseResult.getFailureMessageEntity(receiveApi.getApiName() + "未授权给" + sendApp.getName() + ",请联系管理员");
|
||||
}
|
||||
SysExtensionApiEntity sysExtensionApiEntity = new SysExtensionApiEntity();
|
||||
|
||||
|
||||
List<String> a = Arrays.asList(new String[]{"apicode", "appid", "secretkey", "publickey", "x-forwarded-for", "cookie", "x-forwarded-proto", "x-real-ip", "content-length", "accept-language", "host", "content-type", "connection", "cache-control", "accept-encoding", "pragma", "accept", "user-agent"});
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
if (receiveApi.getHeaderIn() != null && !"".equals(receiveApi.getHeaderIn())) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(receiveApi.getHeaderIn());
|
||||
if (jsonArray != null && jsonArray.size() > 0) {
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject object1 = jsonArray.getJSONObject(i);
|
||||
headers.put(object1.getString("parameterName"), object1.getString("example"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (oldheaderMap != null && oldheaderMap.size() > 0) {
|
||||
for (Map.Entry<String, String> entry : oldheaderMap.entrySet()) {
|
||||
if (!a.contains(entry.getKey())) {
|
||||
headers.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sysExtensionApiEntity.setSendApp(sendApp);
|
||||
sysExtensionApiEntity.setReceiveApp(receiveApp);
|
||||
sysExtensionApiEntity.setReceiveApi(receiveApi);
|
||||
sysExtensionApiEntity.setHeaders(headers);
|
||||
sysExtensionApiEntity.setQuerys(oldquerys);
|
||||
sysExtensionApiEntity.setBodys(oldbodys);
|
||||
Method[] methods = null;
|
||||
Object object = null;
|
||||
|
||||
// 判断是否有内部api 是否扩展api 1、启用 2、停用
|
||||
if (receiveApi.getExtensionApi() != null && "1".equals(receiveApi.getExtensionApi())
|
||||
&& receiveApi.getBeanName() != null && !"".equals(receiveApi.getBeanName())
|
||||
&& receiveApi.getFunName() != null && !"".equals(receiveApi.getFunName())
|
||||
) {
|
||||
//获取类
|
||||
try {
|
||||
object = ApplicationContextUtil.getBeanByName(receiveApi.getBeanName());
|
||||
} catch (SecurityException e) {
|
||||
|
||||
}
|
||||
//获取类下面的方法
|
||||
methods = object.getClass().getMethods();
|
||||
if (methods == null || methods.length == 0) {
|
||||
return BaseResult.getFailureMessageEntity("未找到内部方法,请联系管理员");
|
||||
}
|
||||
for (Method m : methods) {
|
||||
if (null != m) {
|
||||
if (m.getName().equals(receiveApi.getFunName().trim())) {
|
||||
try {
|
||||
logger.info("invoke开始>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
sysExtensionApiEntity = (SysExtensionApiEntity) m.invoke(object, sysExtensionApiEntity);
|
||||
logger.info("invoke结束>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
logger.error("invokeException{}", e.getMessage());
|
||||
return BaseResult.getFailureMessageEntity("内部方法执行错误,请联系管理员");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
headers = sysExtensionApiEntity.getHeaders();
|
||||
String querys = sysExtensionApiEntity.getQuerys();
|
||||
String bodys = sysExtensionApiEntity.getBodys();
|
||||
//设置参数获取参数
|
||||
StringBuffer url = new StringBuffer();
|
||||
if(!receiveApi.getDestinationAddress().toLowerCase().startsWith("http")){
|
||||
url.append(receiveApp.getInterfaceAddress());
|
||||
}
|
||||
url.append(receiveApi.getDestinationAddress());
|
||||
if (querys != null) {
|
||||
url.append("?");
|
||||
url.append(querys);
|
||||
}
|
||||
Integer outTime = 6000;
|
||||
if (receiveApi.getTimeoutPeriod() != null && !"".equals(receiveApi.getTimeoutPeriod())) {
|
||||
outTime = Integer.valueOf(receiveApi.getTimeoutPeriod());
|
||||
}
|
||||
//1、POST 2、GET
|
||||
String method = "POST";
|
||||
if ("2".equals(receiveApi.getRequestMethod())) {
|
||||
method = "GET";
|
||||
}
|
||||
//List<String> a = Arrays.asList(new String[]{"apicode", "appid", "secretkey", "publickey", "x-forwarded-for", "cookie", "x-forwarded-proto", "x-real-ip", "content-length", "accept-language", "host", "content-type", "connection", "cache-control", "accept-encoding", "pragma", "accept", "user-agent"});
|
||||
//Map<String, String> headers = new HashMap<>();
|
||||
//if (receiveApi.getHeaderIn() != null && !"".equals(receiveApi.getHeaderIn())) {
|
||||
// JSONArray jsonArray = JSONArray.parseArray(receiveApi.getHeaderIn());
|
||||
// if (jsonArray != null && jsonArray.size() > 0) {
|
||||
// for (int i = 0; i < jsonArray.size(); i++) {
|
||||
// JSONObject object1 = jsonArray.getJSONObject(i);
|
||||
// headers.put(object1.getString("parameterName"), object1.getString("example"));
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//if (headerMap != null && headerMap.size() > 0) {
|
||||
// for (Map.Entry<String, String> entry : headerMap.entrySet()) {
|
||||
// if (!a.contains(entry.getKey())) {
|
||||
// headers.put(entry.getKey(), entry.getValue());
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
if ("POST".equals(method)) {
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
// HttpClient
|
||||
CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build();
|
||||
HttpPost post = new HttpPost(url.toString());
|
||||
CloseableHttpResponse response = null;
|
||||
|
||||
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(outTime).build();
|
||||
post.setConfig(requestConfig);//设置请求参数【超时时间】
|
||||
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (String key : headers.keySet()) {
|
||||
post.setHeader(key, headers.get(key));
|
||||
}
|
||||
}
|
||||
StringBuilder body = new StringBuilder();
|
||||
boolean flag = true;
|
||||
try {
|
||||
if (bodys != null && !"".equals(bodys)) {
|
||||
ByteArrayEntity entity = new ByteArrayEntity(bodys.getBytes("UTF-8"));
|
||||
entity.setContentType("application/json");
|
||||
post.setEntity(entity);
|
||||
}
|
||||
response = closeableHttpClient.execute(post);
|
||||
|
||||
HttpEntity entity = response.getEntity();
|
||||
synchronized (lock) {
|
||||
body.append(EntityUtils.toString(entity,"UTF-8"));
|
||||
}
|
||||
flag = true;
|
||||
logger.info("返回结果:" + body);
|
||||
} catch (Exception e) {
|
||||
logger.error("请求错误:" + e.getMessage());
|
||||
body.append(e.getMessage());
|
||||
flag = false;
|
||||
} finally {
|
||||
try {
|
||||
// 关闭响应对象
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
// 关闭响应对象
|
||||
if (closeableHttpClient != null) {
|
||||
closeableHttpClient.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
logger.info("保存日志开始");
|
||||
//重写saveLog方法,利用他原有逻辑判断重推结果,根据重推结果,设置该条日志的状态
|
||||
SysMessageManageLogEntity sysMessageManageLogEntity = updateLog(sendApp, receiveApp, receiveApi, oldbodys,bodys, oldheaderMap,headers, headers, oldquerys,querys, body.toString(),true,null,oldId);
|
||||
if (methods != null && methods.length > 0) {
|
||||
for (Method m : methods) {
|
||||
if (null != m) {
|
||||
if (m.getName().equals(receiveApi.getFunName().trim()+"CallBack")) {
|
||||
try {
|
||||
logger.info("invoke开始>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
m.invoke(object, sysMessageManageLogEntity);
|
||||
logger.info("invoke结束>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
} catch (Exception e) {
|
||||
logger.error("invokeException{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("保存日志结束");
|
||||
if (flag) {
|
||||
if (JSONUtil.isTypeJSON(body.toString())) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(body.toString());
|
||||
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
||||
return BaseResult.getSuccessMessageEntity("重推成功", jsonObject);
|
||||
}else {
|
||||
return BaseResult.getSuccessMessageEntity("重推失败", jsonObject);
|
||||
}
|
||||
} else {
|
||||
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
||||
return BaseResult.getSuccessMessageEntity("重推成功", body);
|
||||
}else {
|
||||
return BaseResult.getSuccessMessageEntity("重推失败", body);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return BaseResult.getSuccessMessageEntity("重推失败", body);
|
||||
}
|
||||
|
||||
} else {//GET
|
||||
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
// HttpClient
|
||||
CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build();
|
||||
HttpGet get = new HttpGet(url.toString());
|
||||
CloseableHttpResponse response = null;
|
||||
|
||||
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(outTime).build();
|
||||
get.setConfig(requestConfig);//设置请求参数【超时时间】
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (String key : headers.keySet()) {
|
||||
get.setHeader(key, headers.get(key));
|
||||
}
|
||||
}
|
||||
StringBuilder body = new StringBuilder();
|
||||
|
||||
boolean flag = true;
|
||||
try {
|
||||
response = closeableHttpClient.execute(get);
|
||||
HttpEntity entity = response.getEntity();
|
||||
synchronized (lock) {
|
||||
body.append(EntityUtils.toString(entity,"UTF-8"));
|
||||
}
|
||||
flag = true;
|
||||
logger.info("返回结果:" + body);
|
||||
} catch (Exception e) {
|
||||
logger.error("请求错误:" + e.getMessage());
|
||||
body.append(e.getMessage());
|
||||
flag = false;
|
||||
} finally {
|
||||
try {
|
||||
// 关闭响应对象
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
// 关闭响应对象
|
||||
if (closeableHttpClient != null) {
|
||||
closeableHttpClient.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
logger.info("保存日志开始");
|
||||
SysMessageManageLogEntity sysMessageManageLogEntity = updateLog(sendApp, receiveApp, receiveApi, oldbodys,bodys, oldheaderMap,headers, headers, oldquerys,querys, body.toString(), true,null,oldId);
|
||||
if (methods != null && methods.length > 0) {
|
||||
for (Method m : methods) {
|
||||
if (null != m) {
|
||||
if (m.getName().equals(receiveApi.getFunName().trim()+"CallBack")) {
|
||||
try {
|
||||
logger.info("invoke开始>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
m.invoke(object, sysMessageManageLogEntity);
|
||||
logger.info("invoke结束>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
} catch (Exception e) {
|
||||
logger.error("invokeException{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("保存日志结束");
|
||||
if (flag) {
|
||||
if (JSONUtil.isTypeJSON(body.toString())) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(body.toString());
|
||||
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
||||
return BaseResult.getSuccessMessageEntity("重推成功", jsonObject);
|
||||
}else {
|
||||
return BaseResult.getSuccessMessageEntity("重推失败", jsonObject);
|
||||
}
|
||||
} else {
|
||||
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
||||
return BaseResult.getSuccessMessageEntity("重推成功", body);
|
||||
}else {
|
||||
return BaseResult.getSuccessMessageEntity("重推失败", body);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return BaseResult.getSuccessMessageEntity("重推失败", body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SysApplicationApiAuthDetailEntity getApiAuthDetailByAppIdApiIdTripartiteSystemId(String appId, String apiId, String tripartiteSystemId) {
|
||||
String str = "appId" + appId + "apiId" + apiId + "tripartiteSystemId" + tripartiteSystemId;
|
||||
Object o = applicationCache.get("4", str);
|
||||
|
@ -2276,6 +2641,161 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
|
|||
return sysMessageManageLogEntity;
|
||||
}
|
||||
|
||||
private SysMessageManageLogEntity updateLog(SysApplicationEntity sendApp, SysApplicationEntity receiveApp, SysApplicationApiEntity receiveApi,
|
||||
String oldbodys,String bodys,
|
||||
Map<String, String> oldheaderMap,Map<String, String> headerMap,
|
||||
Map<String, String> headers,
|
||||
String oldquerys, String querys,
|
||||
String body, boolean flag,String msg,String oldId) {
|
||||
SysMessageManageLogEntity sysMessageManageLogEntity = new SysMessageManageLogEntity();
|
||||
//messageManageId 消息主表主键
|
||||
//theme 消息主题
|
||||
//messageCode 消息编码
|
||||
//sendApp
|
||||
sysMessageManageLogEntity.setSendApp(sendApp.getId());//发送者应用
|
||||
//sendApi 发送者
|
||||
sysMessageManageLogEntity.setReceiveCode(receiveApi.getApiCode() != null ? receiveApi.getApiCode().toString() : null);//接收者编码
|
||||
sysMessageManageLogEntity.setReceiveApp(receiveApp.getId());//接收者应用
|
||||
sysMessageManageLogEntity.setReceiveApi(receiveApi.getId());//接收者
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("body", oldbodys);
|
||||
jsonObject.put("header", oldheaderMap);
|
||||
jsonObject.put("querys", oldquerys);
|
||||
sysMessageManageLogEntity.setSourceData(jsonObject.toString());//源数据
|
||||
JSONObject send = new JSONObject();
|
||||
send.put("body", bodys);
|
||||
send.put("header", headers);
|
||||
send.put("querys", querys);
|
||||
sysMessageManageLogEntity.setTargetData(send.toString());//目标data
|
||||
if(receiveApp.getAppType() != null && "4".equals(receiveApp.getAppType())){//宁波银行
|
||||
JSONObject jsonObject1 = JSONObject.parseObject(body);
|
||||
String retCode = jsonObject1.getString("retCode");
|
||||
if(retCode != null && "0000".equals(retCode)){
|
||||
JSONObject jsonObject2 = JSONObject.parseObject(jsonObject1.getString("data"));
|
||||
String fileBytes = jsonObject2.getString("fileBytes");
|
||||
if(fileBytes != null && !"".equals(fileBytes)){
|
||||
jsonObject2.put("fileBytes","");
|
||||
jsonObject1.put("data",jsonObject2);
|
||||
sysMessageManageLogEntity.setReturnData(jsonObject1.toJSONString());//返回信息
|
||||
}else {
|
||||
sysMessageManageLogEntity.setReturnData(body);//返回信息
|
||||
}
|
||||
}else {
|
||||
sysMessageManageLogEntity.setReturnData(body);//返回信息
|
||||
}
|
||||
}else {
|
||||
sysMessageManageLogEntity.setReturnData(body);//返回信息
|
||||
}
|
||||
|
||||
|
||||
//校验返回
|
||||
if (!flag) {
|
||||
sysMessageManageLogEntity.setStatus("4");//返回信息
|
||||
sysMessageManageLogEntity.setRemark(msg);//返回信息
|
||||
} else {
|
||||
if (receiveApi.getReturnSuccessField() != null && !"".equals(receiveApi.getReturnSuccessField())
|
||||
&& receiveApi.getReturnSuccessValue() != null && !"".equals(receiveApi.getReturnSuccessValue())) {
|
||||
if (JSONUtil.isTypeJSON(body)) {
|
||||
JSONObject cheackdatas = JSONObject.parseObject(body);
|
||||
JSONObject datas = JSONObject.parseObject(body);
|
||||
String checkdata = cheackdatas.getString(receiveApi.getReturnSuccessField());
|
||||
if (checkdata != null && receiveApi.getReturnSuccessValue().equals(checkdata)) {
|
||||
sysMessageManageLogEntity.setStatus("3");//返回信息
|
||||
if (receiveApi.getReturnMsg() != null && !"".equals(receiveApi.getReturnMsg())) {
|
||||
String returnMsg = cheackdatas.getString(receiveApi.getReturnMsg());
|
||||
sysMessageManageLogEntity.setRemark("接口调用成功,返回信息如下:" + returnMsg);//返回信息
|
||||
} else {
|
||||
sysMessageManageLogEntity.setRemark("接口调用成功");//返回信息
|
||||
}
|
||||
}else if(receiveApi.getReturnSuccessValue().equals("not null") && checkdata != null){
|
||||
sysMessageManageLogEntity.setStatus("3");//返回信息
|
||||
if (receiveApi.getReturnMsg() != null && !"".equals(receiveApi.getReturnMsg())) {
|
||||
String returnMsg = cheackdatas.getString(receiveApi.getReturnMsg());
|
||||
sysMessageManageLogEntity.setRemark("接口调用成功,返回信息如下:" + returnMsg);//返回信息
|
||||
} else {
|
||||
sysMessageManageLogEntity.setRemark("接口调用成功");//返回信息
|
||||
}
|
||||
}else {
|
||||
String fieldname = receiveApi.getReturnSuccessField();
|
||||
if(fieldname.contains(".")){
|
||||
String[] fileds = fieldname.split("\\.");
|
||||
boolean flags = false;
|
||||
for (int i = 0; i < fileds.length; i++) {
|
||||
if (JSONUtil.isTypeJSON(datas.getString(fileds[i]))) {
|
||||
datas = datas.getJSONObject(fileds[i]);
|
||||
if(fileds.length-2 == i ){
|
||||
String a = datas.getString(fileds[i+1]);
|
||||
if (a != null && receiveApi.getReturnSuccessValue().equals(a)) {
|
||||
flags = true;
|
||||
break;
|
||||
}else if(receiveApi.getReturnSuccessValue().equals("not null") && a != null){
|
||||
flags = true;
|
||||
break;
|
||||
}else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(flags){
|
||||
sysMessageManageLogEntity.setStatus("3");//返回信息
|
||||
if (receiveApi.getReturnMsg() != null && !"".equals(receiveApi.getReturnMsg())) {
|
||||
String returnMsg = cheackdatas.getString(receiveApi.getReturnMsg());
|
||||
sysMessageManageLogEntity.setRemark("接口调用成功,返回信息如下:" + returnMsg);//返回信息
|
||||
} else {
|
||||
sysMessageManageLogEntity.setRemark("接口调用成功");//返回信息
|
||||
}
|
||||
}else {
|
||||
sysMessageManageLogEntity.setStatus("4");//返回信息
|
||||
if (receiveApi.getReturnMsg() != null && !"".equals(receiveApi.getReturnMsg())) {
|
||||
String returnMsg = cheackdatas.getString(receiveApi.getReturnMsg());
|
||||
sysMessageManageLogEntity.setRemark("接口调用失败,返回值错误,返回信息如下:" + returnMsg);//返回信息
|
||||
} else {
|
||||
sysMessageManageLogEntity.setRemark("接口调用失败,返回值错误");//返回信息
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
sysMessageManageLogEntity.setStatus("4");//返回信息
|
||||
if (receiveApi.getReturnMsg() != null && !"".equals(receiveApi.getReturnMsg())) {
|
||||
String returnMsg = cheackdatas.getString(receiveApi.getReturnMsg());
|
||||
sysMessageManageLogEntity.setRemark("接口调用失败,返回值错误,返回信息如下:" + returnMsg);//返回信息
|
||||
} else {
|
||||
sysMessageManageLogEntity.setRemark("接口调用失败,返回值错误");//返回信息
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sysMessageManageLogEntity.setStatus("4");//返回信息
|
||||
sysMessageManageLogEntity.setRemark("接口调用失败,返回格式错误,不是JSON");//返回信息
|
||||
}
|
||||
} else {
|
||||
sysMessageManageLogEntity.setStatus("4");//返回信息
|
||||
if (receiveApi.getReturnMsg() != null && !"".equals(receiveApi.getReturnMsg())) {
|
||||
if (JSONUtil.isTypeJSON(body)) {
|
||||
JSONObject cheackdatas = JSONObject.parseObject(body);
|
||||
String checkdata = cheackdatas.getString(receiveApi.getReturnMsg());
|
||||
sysMessageManageLogEntity.setRemark("接口调用失败,api返回信息字段未配置,返回信息如下:" + checkdata);//返回信息
|
||||
} else {
|
||||
sysMessageManageLogEntity.setRemark("接口调用失败,返回格式错误,不是JSON");//返回信息
|
||||
}
|
||||
} else {
|
||||
sysMessageManageLogEntity.setRemark("接口调用失败");//返回信息
|
||||
}
|
||||
}
|
||||
}
|
||||
//remark 备注
|
||||
sysMessageManageLogEntity.setErrorStatus("2");//返回信息
|
||||
sysMessageManageLogEntity.setId(oldId);
|
||||
sysMessageManageLogEntity.setCreate_user_id("c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||
sysMessageManageLogEntity.setModify_user_id("c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||
//sysMessageManageLogEntity.setCreate_time(new Date());
|
||||
sysMessageManageLogEntity.setModify_time(new Date());
|
||||
sysMessageManageLogEntity.setSts("Y");
|
||||
taskExecutor.execute(() -> doEsbTaskNew(sysMessageManageLogEntity));
|
||||
return sysMessageManageLogEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param manageLogEntities
|
||||
* @return void
|
||||
|
@ -2286,6 +2806,9 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
|
|||
private void doEsbTask(SysMessageManageLogEntity manageLogEntities) {
|
||||
sysMessageManageLogDao.save(manageLogEntities);
|
||||
}
|
||||
private void doEsbTaskNew(SysMessageManageLogEntity manageLogEntities) {
|
||||
sysMessageManageLogDao.update(manageLogEntities);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.hzya.frame.webapp.entrance.controler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.bip.v3.v2207.service.IBipSsoService;
|
||||
import com.hzya.frame.sysnew.application.service.ISysApplicationService;
|
||||
import com.hzya.frame.sys.entity.EsbReturnEntity;
|
||||
|
@ -7,6 +8,7 @@ import com.hzya.frame.sys.file.download.entity.FileDownloadEntity;
|
|||
import com.hzya.frame.sys.file.download.service.IFileDownloadService;
|
||||
import com.hzya.frame.sys.file.upload.entity.FileResultEntity;
|
||||
import com.hzya.frame.sys.file.upload.entity.FileUploadDto;
|
||||
import com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity;
|
||||
import com.hzya.frame.web.entity.BaseResult;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import com.hzya.frame.web.exception.BaseSystemException;
|
||||
|
@ -212,6 +214,13 @@ public class EntranceController {
|
|||
public JsonResultEntity externalCallInterface(ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
||||
return sysApplicationService.externalCallInterface(servletRequest,servletResponse);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/externalCallInterfaceResend")
|
||||
@ResponseBody
|
||||
public JsonResultEntity externalCallInterfaceResend(SysMessageManageLogEntity resendLogEntity) throws Exception {
|
||||
return sysApplicationService.externalCallInterfaceResend(resendLogEntity);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/externalCallInterfaceToESB")
|
||||
@ResponseBody
|
||||
public JsonResultEntity externalCallInterfaceToESB(ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
||||
|
|
Loading…
Reference in New Issue