Merge branch 'master' of http://ufidahz.com.cn:9015/root/kangarooDataCenterV3 into 237master
This commit is contained in:
commit
1319cce5f6
|
@ -452,6 +452,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
logger.info("执行异常错误原因:"+e);
|
||||||
logger.error("新增返回脚本解析保存三方id错误"+jsonResultEntity.getAttribute());
|
logger.error("新增返回脚本解析保存三方id错误"+jsonResultEntity.getAttribute());
|
||||||
taskDetailEntity.setResult("新增返回脚本解析保存三方id错误");
|
taskDetailEntity.setResult("新增返回脚本解析保存三方id错误");
|
||||||
taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity);
|
taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity);
|
||||||
|
@ -543,7 +544,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
||||||
map1.put("tableName",mainDb);
|
map1.put("tableName",mainDb);
|
||||||
map1.put("dataStatus", "N");
|
map1.put("dataStatus", "N");
|
||||||
map1.put("deleteStatus", "0");
|
map1.put("deleteStatus", "0");
|
||||||
map1.put("size", 10);
|
map1.put("size", 50);
|
||||||
objects = mdmModuleDao.queryMdmSTs(map1);
|
objects = mdmModuleDao.queryMdmSTs(map1);
|
||||||
objects = toLowerCaseKeys(objects);
|
objects = toLowerCaseKeys(objects);
|
||||||
|
|
||||||
|
@ -738,7 +739,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
||||||
map1.put("tableName",mainDb);
|
map1.put("tableName",mainDb);
|
||||||
//map1.put("dataStatus", "F");
|
//map1.put("dataStatus", "F");
|
||||||
map1.put("updateStatus", "0");
|
map1.put("updateStatus", "0");
|
||||||
map1.put("size", 10);
|
map1.put("size", 50);
|
||||||
objects = mdmModuleDao.queryMdmSTs(map1);
|
objects = mdmModuleDao.queryMdmSTs(map1);
|
||||||
objects = toLowerCaseKeys(objects);
|
objects = toLowerCaseKeys(objects);
|
||||||
|
|
||||||
|
@ -926,7 +927,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
||||||
map1.put("tableName",mainDb);
|
map1.put("tableName",mainDb);
|
||||||
//map1.put("dataStatus", "Y");
|
//map1.put("dataStatus", "Y");
|
||||||
map1.put("addStatus", "0");
|
map1.put("addStatus", "0");
|
||||||
map1.put("size", 100);
|
map1.put("size", 50);
|
||||||
objects = mdmModuleDao.queryMdmSTs(map1);
|
objects = mdmModuleDao.queryMdmSTs(map1);
|
||||||
objects = toLowerCaseKeys(objects);
|
objects = toLowerCaseKeys(objects);
|
||||||
|
|
||||||
|
@ -991,6 +992,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
||||||
mdmModuleSendLogEntity.setTableName(mainDb+"_send_log");
|
mdmModuleSendLogEntity.setTableName(mainDb+"_send_log");
|
||||||
mdmModuleSendLogEntity.setFormmainId(doObjects.get(i).getString("id"));
|
mdmModuleSendLogEntity.setFormmainId(doObjects.get(i).getString("id"));
|
||||||
mdmModuleSendLogEntity.setSts("Y");
|
mdmModuleSendLogEntity.setSts("Y");
|
||||||
|
mdmModuleSendLogEntity.setDataType("1");
|
||||||
mdmModuleSendLogEntity.setAppId(sysApplicationEntity.getId());
|
mdmModuleSendLogEntity.setAppId(sysApplicationEntity.getId());
|
||||||
mdmModuleSendLogEntity.setApiId(apiEntity.getId());
|
mdmModuleSendLogEntity.setApiId(apiEntity.getId());
|
||||||
//mdmModuleSendLogEntity.setDistributeId(mdmModuleDistributeEntities.get(i1).getId());
|
//mdmModuleSendLogEntity.setDistributeId(mdmModuleDistributeEntities.get(i1).getId());
|
||||||
|
@ -1121,10 +1123,12 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
||||||
}
|
}
|
||||||
//保存日志
|
//保存日志
|
||||||
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1");
|
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1");
|
||||||
|
objects.get(i).put("sendsanfzt123",true);
|
||||||
continue;
|
continue;
|
||||||
}else {
|
}else {
|
||||||
//保存日志
|
//保存日志
|
||||||
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败:"+jsonResultEntity.getAttribute(),mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1");
|
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败:"+jsonResultEntity.getAttribute(),mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1");
|
||||||
|
objects.get(i).put("sendsanfzt123",false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1132,12 +1136,14 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
||||||
|
|
||||||
//所有下发发送完成,修改数据状态
|
//所有下发发送完成,修改数据状态
|
||||||
for (int i = 0; i < objects.size(); i++) {
|
for (int i = 0; i < objects.size(); i++) {
|
||||||
Map<String, Object> updateMap = new HashMap<>();
|
if(objects.get(i).getBoolean("sendsanfzt123")){
|
||||||
updateMap.put("tableName",mainDb);
|
Map<String, Object> updateMap = new HashMap<>();
|
||||||
//updateMap.put("dataStatus", "Y");
|
updateMap.put("tableName",mainDb);
|
||||||
updateMap.put("addStatus", "1");
|
//updateMap.put("dataStatus", "Y");
|
||||||
updateMap.put("id", objects.get(i).getString("id"));
|
updateMap.put("addStatus", "1");
|
||||||
mdmModuleDao.updateMdmSTs(updateMap);
|
updateMap.put("id", objects.get(i).getString("id"));
|
||||||
|
mdmModuleDao.updateMdmSTs(updateMap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,37 @@
|
||||||
package com.hzya.frame;
|
package com.hzya.frame;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hzya.frame.util.AESUtil;
|
import com.hzya.frame.util.AESUtil;
|
||||||
|
import org.apache.http.HttpEntity;
|
||||||
|
import org.apache.http.client.config.RequestConfig;
|
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.client.methods.HttpPut;
|
||||||
|
import org.apache.http.entity.StringEntity;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName dsasas
|
* @ClassName dsasas
|
||||||
* @Description
|
* @Description
|
||||||
* @Author llg
|
* @Author llg
|
||||||
* Date 2023/7/16 8:18 上午
|
* Date 2023/7/16 8:18 上午
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
//@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = {WebappApplication.class})
|
//@SpringBootTest(classes = {WebappApplication.class})
|
||||||
public class temButtom {
|
public class temButtom {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -25,6 +43,104 @@ public class temButtom {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test02() {
|
||||||
|
// 1056162015172640840 -7858803986346327947 3178176833471791293 合同评审-待办测试(bdmanager 2024-10-22 16:45) 7743552636545550897 bdmanager 18058147870 pending start success 新增成功!
|
||||||
|
// success 更新待办为已办成功!
|
||||||
|
// task7803207f54ff047d6008dcce31c2628f 新增成功!
|
||||||
|
// 2024-10-24 2024-10-24
|
||||||
|
|
||||||
|
String phone ="19357235324";
|
||||||
|
String taskid ="task8b0c7ca72439bc9b0c1c89e8866c8275";
|
||||||
|
//token
|
||||||
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
String token ="https://oapi.dingtalk.com/gettoken?appkey=dingxewtjaserj292ggu&appsecret=DuRw6EEEvhGXfr6Q8wN_x4025qKjrffIGCXF9KeCKKIID-LVSsR6_8KWMei6sug1";
|
||||||
|
String body = sendGet(token,headers);
|
||||||
|
JSONObject tokenobject = JSONObject.parseObject(body);
|
||||||
|
|
||||||
|
//钉钉id
|
||||||
|
headers = new HashMap<>();
|
||||||
|
//https://oapi.dingtalk.com/user/get_by_mobile?access_token=9abd3996cb103ba48dd8c69fea5473e7&mobile=15700100840
|
||||||
|
String ddid ="https://oapi.dingtalk.com/user/get_by_mobile?access_token="+tokenobject.get("access_token")+"&mobile="+phone;
|
||||||
|
String ddidbody = sendGet(ddid,headers);
|
||||||
|
JSONObject ddidobject = JSONObject.parseObject(ddidbody);
|
||||||
|
|
||||||
|
//人员id
|
||||||
|
headers = new HashMap<>();
|
||||||
|
//https://oapi.dingtalk.com/user/get?userid=111336474727636213&access_token=3d21a6614fb037a98542a537336e8149
|
||||||
|
String userid ="https://oapi.dingtalk.com/user/get?userid="+ddidobject.get("userid")+"&access_token="+tokenobject.get("access_token");
|
||||||
|
String useridbody = sendGet(userid,headers);
|
||||||
|
JSONObject useridobject = JSONObject.parseObject(useridbody);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||||
|
HttpPut httpPut = new HttpPut("https://api.dingtalk.com/v1.0/todo/users/"+useridobject.get("unionid")+"/tasks/"+taskid);
|
||||||
|
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000).setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
|
||||||
|
httpPut.setConfig(requestConfig);
|
||||||
|
httpPut.setHeader("Content-type", "application/json");
|
||||||
|
httpPut.setHeader("x-acs-dingtalk-access-token", tokenobject.getString("access_token"));
|
||||||
|
Map<String, Object> dataMap = new HashMap();
|
||||||
|
dataMap.put("done", true);
|
||||||
|
CloseableHttpResponse httpResponse = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
httpPut.setEntity(new StringEntity("{\"done\": true}"));
|
||||||
|
httpResponse = httpClient.execute(httpPut);
|
||||||
|
HttpEntity entity = httpResponse.getEntity();
|
||||||
|
String results = EntityUtils.toString(entity);
|
||||||
|
System.out.println(results);
|
||||||
|
} catch (Exception var15) {
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
httpResponse.close();
|
||||||
|
httpClient.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String sendGet(String url, Map<String, String> headers) {
|
||||||
|
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||||
|
// HttpClient
|
||||||
|
CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build();
|
||||||
|
HttpGet get = new HttpGet(url.toString());
|
||||||
|
CloseableHttpResponse response = null;
|
||||||
|
|
||||||
|
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000).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();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
response = closeableHttpClient.execute(get);
|
||||||
|
HttpEntity entity = response.getEntity();
|
||||||
|
body.append(EntityUtils.toString(entity,"UTF-8"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
body.append(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
// 关闭响应对象
|
||||||
|
if (response != null) {
|
||||||
|
response.close();
|
||||||
|
}
|
||||||
|
// 关闭响应对象
|
||||||
|
if (closeableHttpClient != null) {
|
||||||
|
closeableHttpClient.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return body.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -974,10 +974,10 @@ where id = #{id}
|
||||||
< #{item.filedVaule}
|
< #{item.filedVaule}
|
||||||
</when>
|
</when>
|
||||||
<when test="item.compareType == '5'.toString() ">
|
<when test="item.compareType == '5'.toString() ">
|
||||||
like concat('%',#{item.filedVaule},'%')
|
like #{item.filedVaule}
|
||||||
</when>
|
</when>
|
||||||
<when test="item.compareType == '6'.toString() ">
|
<when test="item.compareType == '6'.toString() ">
|
||||||
not like concat('%',#{item.filedVaule},'%')
|
not like #{item.filedVaule}
|
||||||
</when>
|
</when>
|
||||||
</choose>
|
</choose>
|
||||||
|
|
||||||
|
|
|
@ -2111,7 +2111,8 @@ public class MdmServiceImpl implements IMdmService {
|
||||||
return BaseResult.getSuccessMessageEntity("发送成功");
|
return BaseResult.getSuccessMessageEntity("发送成功");
|
||||||
} else {
|
} else {
|
||||||
saveMdmModuleSendLogEntity(mdmModuleEntity.getMdmCode(), mdmModuleDistributeEntity.getId(), "2", "转发失败:"+jsonResultEntity.getAttribute(), dbname, object.getString("id"), sysApplicationEntity.getName(), sysApplicationEntity.getId(), apiEntity.getApiName(), apiEntity.getId(), object.toJSONString(), type);
|
saveMdmModuleSendLogEntity(mdmModuleEntity.getMdmCode(), mdmModuleDistributeEntity.getId(), "2", "转发失败:"+jsonResultEntity.getAttribute(), dbname, object.getString("id"), sysApplicationEntity.getName(), sysApplicationEntity.getId(), apiEntity.getApiName(), apiEntity.getId(), object.toJSONString(), type);
|
||||||
return BaseResult.getFailureMessageEntity("发送错误:" + jsonResultEntity.getAttribute());
|
JSONObject object1 = JSONObject.parseObject(jsonResultEntity.getAttribute().toString());
|
||||||
|
return BaseResult.getFailureMessageEntity("发送错误:" +object1.getString("msg"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -309,6 +309,7 @@ public interface ISysApplicationService extends IBaseService<SysApplicationEntit
|
||||||
JsonResultEntity enableOrDisableAppDatasource(JSONObject jsonObject);
|
JsonResultEntity enableOrDisableAppDatasource(JSONObject jsonObject);
|
||||||
|
|
||||||
JsonResultEntity externalCallInterface(ServletRequest servletRequest, ServletResponse servletResponse);
|
JsonResultEntity externalCallInterface(ServletRequest servletRequest, ServletResponse servletResponse);
|
||||||
|
JsonResultEntity externalCallInterfacefileUpload(ServletRequest servletRequest, ServletResponse servletResponse);
|
||||||
|
|
||||||
JsonResultEntity externalCallInterfaceResend(SysMessageManageLogEntity resendLogEntity);
|
JsonResultEntity externalCallInterfaceResend(SysMessageManageLogEntity resendLogEntity);
|
||||||
|
|
||||||
|
|
|
@ -55,23 +55,36 @@ import com.hzya.frame.web.action.ApplicationContextUtil;
|
||||||
import com.hzya.frame.web.entity.BaseResult;
|
import com.hzya.frame.web.entity.BaseResult;
|
||||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.config.RequestConfig;
|
import org.apache.http.client.config.RequestConfig;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||||
|
import org.apache.http.conn.ssl.TrustAllStrategy;
|
||||||
import org.apache.http.entity.ByteArrayEntity;
|
import org.apache.http.entity.ByteArrayEntity;
|
||||||
|
import org.apache.http.entity.ContentType;
|
||||||
|
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.apache.http.ssl.SSLContextBuilder;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.task.TaskExecutor;
|
import org.springframework.core.task.TaskExecutor;
|
||||||
|
import org.springframework.http.client.MultipartBodyBuilder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
@ -1687,7 +1700,6 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
|
||||||
@Override
|
@Override
|
||||||
@DSTransactional()
|
@DSTransactional()
|
||||||
public JsonResultEntity externalCallInterface(ServletRequest servletRequest, ServletResponse servletResponse) {
|
public JsonResultEntity externalCallInterface(ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||||
|
|
||||||
//例如:A应用发送数据到中台,中台转发到B应用
|
//例如:A应用发送数据到中台,中台转发到B应用
|
||||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||||
String oldbodys = ServletUtil.getBody(servletRequest);
|
String oldbodys = ServletUtil.getBody(servletRequest);
|
||||||
|
@ -1881,9 +1893,28 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
|
||||||
|
|
||||||
|
|
||||||
if ("POST".equals(method)) {
|
if ("POST".equals(method)) {
|
||||||
|
|
||||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||||
// HttpClient
|
// HttpClient
|
||||||
CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build();
|
//CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build();
|
||||||
|
// 创建一个 CloseableHttpClient 并配置 SSL 上下文和主机名验证器
|
||||||
|
// 创建一个信任所有证书的 SSLContext
|
||||||
|
SSLContext sslContext = null;
|
||||||
|
try {
|
||||||
|
sslContext = new SSLContextBuilder()
|
||||||
|
.loadTrustMaterial(null, TrustAllStrategy.INSTANCE)
|
||||||
|
.build();
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
CloseableHttpClient closeableHttpClient = HttpClients.custom()
|
||||||
|
.setSSLContext(sslContext)
|
||||||
|
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
//HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||||
|
// HttpClient
|
||||||
|
//CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build();
|
||||||
HttpPost post = new HttpPost(url.toString());
|
HttpPost post = new HttpPost(url.toString());
|
||||||
CloseableHttpResponse response = null;
|
CloseableHttpResponse response = null;
|
||||||
|
|
||||||
|
@ -1954,17 +1985,29 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
|
||||||
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
||||||
return BaseResult.getSuccessMessageEntity("转发成功", jsonObject);
|
return BaseResult.getSuccessMessageEntity("转发成功", jsonObject);
|
||||||
}else {
|
}else {
|
||||||
return BaseResult.getFailureMessageEntity("转发失败", jsonObject);
|
if(sysMessageManageLogEntity.getReturnMsg()!= null&& !"".equals(sysMessageManageLogEntity.getReturnMsg())){
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败:"+sysMessageManageLogEntity.getReturnMsg(), jsonObject);
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败", jsonObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
||||||
return BaseResult.getSuccessMessageEntity("转发成功", body);
|
return BaseResult.getSuccessMessageEntity("转发成功", body);
|
||||||
}else {
|
}else {
|
||||||
return BaseResult.getFailureMessageEntity("转发失败", body);
|
if(sysMessageManageLogEntity.getReturnMsg()!= null&& !"".equals(sysMessageManageLogEntity.getReturnMsg())){
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败:"+sysMessageManageLogEntity.getReturnMsg(), body);
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败", body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return BaseResult.getFailureMessageEntity("转发失败", body);
|
if(sysMessageManageLogEntity.getReturnMsg()!= null&& !"".equals(sysMessageManageLogEntity.getReturnMsg())){
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败:"+sysMessageManageLogEntity.getReturnMsg(), body);
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败", body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {//GET
|
} else {//GET
|
||||||
|
@ -2036,13 +2079,407 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
|
||||||
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
||||||
return BaseResult.getSuccessMessageEntity("转发成功", jsonObject);
|
return BaseResult.getSuccessMessageEntity("转发成功", jsonObject);
|
||||||
}else {
|
}else {
|
||||||
return BaseResult.getFailureMessageEntity("转发失败", jsonObject);
|
if(sysMessageManageLogEntity.getReturnMsg()!= null&& !"".equals(sysMessageManageLogEntity.getReturnMsg())){
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败:"+sysMessageManageLogEntity.getReturnMsg(), jsonObject);
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败", jsonObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
||||||
return BaseResult.getSuccessMessageEntity("转发成功", body);
|
return BaseResult.getSuccessMessageEntity("转发成功", body);
|
||||||
}else {
|
}else {
|
||||||
return BaseResult.getFailureMessageEntity("转发失败", body);
|
if(sysMessageManageLogEntity.getReturnMsg()!= null&& !"".equals(sysMessageManageLogEntity.getReturnMsg())){
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败:"+sysMessageManageLogEntity.getReturnMsg(), body);
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败", body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败", body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param servletRequest
|
||||||
|
* @param servletResponse
|
||||||
|
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||||
|
* @Author lvleigang
|
||||||
|
* @Description 外部系统调用接口
|
||||||
|
* @Date 4:21 下午 2023/10/19
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
@DSTransactional()
|
||||||
|
public JsonResultEntity externalCallInterfacefileUpload(ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||||
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) servletRequest;
|
||||||
|
// 获取普通表单参数
|
||||||
|
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||||
|
Map<String, String> oldheaderMap = ServletUtil.getHeaderMap(request);
|
||||||
|
//应用key
|
||||||
|
String publicKey = request.getHeader("publicKey");
|
||||||
|
//应用密钥
|
||||||
|
String secretKey = request.getHeader("secretKey");
|
||||||
|
//appId
|
||||||
|
String appId = request.getHeader("appId");
|
||||||
|
//apiCode
|
||||||
|
String apiCode = request.getHeader("apiCode");
|
||||||
|
|
||||||
|
Enumeration<String> bodyname = multipartRequest.getParameterNames();
|
||||||
|
JSONObject bodysss = new JSONObject();
|
||||||
|
if (bodyname.hasMoreElements()) {
|
||||||
|
while (bodyname.hasMoreElements()) {
|
||||||
|
String headerName = bodyname.nextElement();
|
||||||
|
String headerValue = multipartRequest.getParameter(headerName);
|
||||||
|
bodysss.put( headerName,headerValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String oldquerys = multipartRequest.getQueryString();
|
||||||
|
String oldbodys = bodysss.toJSONString();
|
||||||
|
Iterator<String> filenemes = multipartRequest.getFileNames();
|
||||||
|
Map<String, List<MultipartFile>> files = new HashMap<>();
|
||||||
|
|
||||||
|
if (filenemes.hasNext()) {
|
||||||
|
filenemes.forEachRemaining(element -> files.put(element,multipartRequest.getFiles(element)));
|
||||||
|
}
|
||||||
|
|
||||||
|
String ip = IPHelper.getIpAddr(multipartRequest);
|
||||||
|
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) {
|
||||||
|
return BaseResult.getFailureMessageEntity("公钥、密钥错误,请联系管理员");
|
||||||
|
}
|
||||||
|
//判断应用是否启用
|
||||||
|
if (sendApp.getAppStatus() == null || !"1".equals(sendApp.getAppStatus())) {
|
||||||
|
saveLog(sendApp, new SysApplicationEntity(), new SysApplicationApiEntity(), oldbodys, null, oldheaderMap, null, null, oldquerys, null, null, false,sendApp.getName() + "应用未启用");
|
||||||
|
return BaseResult.getFailureMessageEntity(sendApp.getName() + "应用未启用,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SysApplicationEntity receiveApp = getAppByAppId(appId);
|
||||||
|
if (receiveApp == null) {
|
||||||
|
saveLog(sendApp, new SysApplicationEntity(), new SysApplicationApiEntity(), oldbodys, null, oldheaderMap, null, null, oldquerys, null, null, false,"根据appId:" + appId + "未匹配到应用");
|
||||||
|
return BaseResult.getFailureMessageEntity("根据appId:" + appId + "未匹配到应用,请联系管理员");
|
||||||
|
}
|
||||||
|
//判断应用是否启用
|
||||||
|
if (receiveApp.getAppStatus() == null || !"1".equals(receiveApp.getAppStatus())) {
|
||||||
|
saveLog(sendApp, receiveApp, new SysApplicationApiEntity(), oldbodys, null, oldheaderMap, null, null, oldquerys, null, null, false,receiveApp.getName() + "应用未启用" );
|
||||||
|
return BaseResult.getFailureMessageEntity(receiveApp.getName() + "应用未启用,请联系管理员");
|
||||||
|
}
|
||||||
|
//判断应用接口是否启用
|
||||||
|
if (receiveApp.getInterfaceStatus() == null || !"1".equals(receiveApp.getInterfaceStatus())) {
|
||||||
|
saveLog(sendApp, receiveApp, new SysApplicationApiEntity(), oldbodys, null, oldheaderMap, null, null, oldquerys, null, null, false,receiveApp.getName() + "应用接口环境未启用" );
|
||||||
|
return BaseResult.getFailureMessageEntity(receiveApp.getName() + "应用接口环境未启用,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
|
SysApplicationApiEntity receiveApi = getApiByAppIdApiCode(receiveApp.getId(), apiCode);
|
||||||
|
if (receiveApi == null) {
|
||||||
|
saveLog(sendApp, receiveApp, new SysApplicationApiEntity(), oldbodys, null, oldheaderMap, null, null, oldquerys, null, null, false,receiveApp.getName() + ":" + apiCode + "未启用或者未创建" );
|
||||||
|
return BaseResult.getFailureMessageEntity(receiveApp.getName() + ":" + apiCode + "未启用或者未创建");
|
||||||
|
}
|
||||||
|
|
||||||
|
SysApplicationApiAuthEntity sysApplicationApiAuthEntity = getApiAuthByNameAppId(sendApp.getId(), receiveApp.getId());
|
||||||
|
if (sysApplicationApiAuthEntity == null) {
|
||||||
|
saveLog(sendApp, receiveApp, receiveApi, oldbodys, null, oldheaderMap, null, null, oldquerys, null, null, false,receiveApp.getName() + "应用权限配置错误" );
|
||||||
|
return BaseResult.getFailureMessageEntity(receiveApp.getName() + "应用权限配置错误");
|
||||||
|
}
|
||||||
|
if (sysApplicationApiAuthEntity.getSystemAddress() != null && !"".equals(sysApplicationApiAuthEntity.getSystemAddress())
|
||||||
|
&& !sysApplicationApiAuthEntity.getSystemAddress().contains(ip)) {
|
||||||
|
saveLog(sendApp, receiveApp, receiveApi, oldbodys, null, oldheaderMap, null, null, oldquerys, null, null, false,receiveApp.getName() + "发送应用" + receiveApp.getName() + "的ip白名单配置错误" );
|
||||||
|
return BaseResult.getFailureMessageEntity(receiveApp.getName() + "发送应用" + receiveApp.getName() + "的ip白名单配置错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
SysApplicationApiAuthDetailEntity sysApplicationApiAuthDetailEntity = getApiAuthDetailByAppIdApiIdTripartiteSystemId(receiveApp.getId(), receiveApi.getId(), sysApplicationApiAuthEntity.getId());
|
||||||
|
if (sysApplicationApiAuthDetailEntity == null) {
|
||||||
|
saveLog(sendApp, receiveApp, receiveApi, oldbodys, null, oldheaderMap, null, null, oldquerys, null, null, false,receiveApi.getApiName() + "未授权给" + sendApp.getName() );
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("POST".equals(method)) {
|
||||||
|
StringBuilder body = new StringBuilder();
|
||||||
|
boolean flag = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpPost httpPost = new HttpPost(url.toString());
|
||||||
|
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||||
|
if(!files.isEmpty()){
|
||||||
|
for (Map.Entry<String, List<MultipartFile>> entry : files.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
List<MultipartFile> multipartFile = entry.getValue();
|
||||||
|
if(multipartFile != null && multipartFile.size() > 0){
|
||||||
|
for (int i = 0; i < multipartFile.size(); i++) {
|
||||||
|
File file = new File(multipartFile.get(i).getOriginalFilename());
|
||||||
|
Files.write(Paths.get(file.getAbsolutePath()), multipartFile.get(i).getBytes());
|
||||||
|
builder.addBinaryBody(key, file, ContentType.APPLICATION_OCTET_STREAM, file.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (headers != null && headers.size() > 0) {
|
||||||
|
for (String key : headers.keySet()) {
|
||||||
|
httpPost.setHeader(key, headers.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//if (bodys != null && !"".equals(bodys)) {
|
||||||
|
// builder.addTextBody("fileFlag", "true", ContentType.TEXT_PLAIN);
|
||||||
|
// builder.addTextBody("businessType", "application", ContentType.TEXT_PLAIN);
|
||||||
|
//}
|
||||||
|
HttpEntity entity = builder.build();
|
||||||
|
httpPost.setEntity(entity);
|
||||||
|
|
||||||
|
HttpResponse response = null;
|
||||||
|
response = HttpClientBuilder.create().build().execute(httpPost);
|
||||||
|
|
||||||
|
HttpEntity entity1 = response.getEntity();
|
||||||
|
synchronized (lock) {
|
||||||
|
body.append(EntityUtils.toString(entity1,"UTF-8"));
|
||||||
|
}
|
||||||
|
flag = true;
|
||||||
|
logger.info("返回结果:" + body);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("请求错误:" + e.getMessage());
|
||||||
|
body.append(e.getMessage());
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
logger.info("保存日志开始");
|
||||||
|
SysMessageManageLogEntity sysMessageManageLogEntity = saveLog(sendApp, receiveApp, receiveApi, oldbodys,bodys, oldheaderMap,headers, headers, oldquerys,querys, body.toString(),true,null);
|
||||||
|
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 {
|
||||||
|
if(sysMessageManageLogEntity.getReturnMsg()!= null&& !"".equals(sysMessageManageLogEntity.getReturnMsg())){
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败:"+sysMessageManageLogEntity.getReturnMsg(), jsonObject);
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败", jsonObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
||||||
|
return BaseResult.getSuccessMessageEntity("转发成功", body);
|
||||||
|
}else {
|
||||||
|
if(sysMessageManageLogEntity.getReturnMsg()!= null&& !"".equals(sysMessageManageLogEntity.getReturnMsg())){
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败:"+sysMessageManageLogEntity.getReturnMsg(), body);
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败", body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(sysMessageManageLogEntity.getReturnMsg()!= null&& !"".equals(sysMessageManageLogEntity.getReturnMsg())){
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败:"+sysMessageManageLogEntity.getReturnMsg(), body);
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败", 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 = saveLog(sendApp, receiveApp, receiveApi, oldbodys,bodys, oldheaderMap,headers, headers, oldquerys,querys, body.toString(), true,null);
|
||||||
|
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 {
|
||||||
|
if(sysMessageManageLogEntity.getReturnMsg()!= null&& !"".equals(sysMessageManageLogEntity.getReturnMsg())){
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败:"+sysMessageManageLogEntity.getReturnMsg(), jsonObject);
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败", jsonObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(sysMessageManageLogEntity.getStatus() != null && "3".equals(sysMessageManageLogEntity.getStatus())){
|
||||||
|
return BaseResult.getSuccessMessageEntity("转发成功", body);
|
||||||
|
}else {
|
||||||
|
if(sysMessageManageLogEntity.getReturnMsg()!= null&& !"".equals(sysMessageManageLogEntity.getReturnMsg())){
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败:"+sysMessageManageLogEntity.getReturnMsg(), body);
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("转发失败", body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2599,6 +3036,7 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
|
||||||
sysMessageManageLogEntity.setStatus("4");//返回信息
|
sysMessageManageLogEntity.setStatus("4");//返回信息
|
||||||
if (receiveApi.getReturnMsg() != null && !"".equals(receiveApi.getReturnMsg())) {
|
if (receiveApi.getReturnMsg() != null && !"".equals(receiveApi.getReturnMsg())) {
|
||||||
String returnMsg = cheackdatas.getString(receiveApi.getReturnMsg());
|
String returnMsg = cheackdatas.getString(receiveApi.getReturnMsg());
|
||||||
|
sysMessageManageLogEntity.setReturnMsg(returnMsg);//返回信息
|
||||||
sysMessageManageLogEntity.setRemark("接口调用失败,返回值错误,返回信息如下:" + returnMsg);//返回信息
|
sysMessageManageLogEntity.setRemark("接口调用失败,返回值错误,返回信息如下:" + returnMsg);//返回信息
|
||||||
} else {
|
} else {
|
||||||
sysMessageManageLogEntity.setRemark("接口调用失败,返回值错误");//返回信息
|
sysMessageManageLogEntity.setRemark("接口调用失败,返回值错误");//返回信息
|
||||||
|
@ -2609,6 +3047,7 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
|
||||||
sysMessageManageLogEntity.setStatus("4");//返回信息
|
sysMessageManageLogEntity.setStatus("4");//返回信息
|
||||||
if (receiveApi.getReturnMsg() != null && !"".equals(receiveApi.getReturnMsg())) {
|
if (receiveApi.getReturnMsg() != null && !"".equals(receiveApi.getReturnMsg())) {
|
||||||
String returnMsg = cheackdatas.getString(receiveApi.getReturnMsg());
|
String returnMsg = cheackdatas.getString(receiveApi.getReturnMsg());
|
||||||
|
sysMessageManageLogEntity.setReturnMsg(returnMsg);//返回信息
|
||||||
sysMessageManageLogEntity.setRemark("接口调用失败,返回值错误,返回信息如下:" + returnMsg);//返回信息
|
sysMessageManageLogEntity.setRemark("接口调用失败,返回值错误,返回信息如下:" + returnMsg);//返回信息
|
||||||
} else {
|
} else {
|
||||||
sysMessageManageLogEntity.setRemark("接口调用失败,返回值错误");//返回信息
|
sysMessageManageLogEntity.setRemark("接口调用失败,返回值错误");//返回信息
|
||||||
|
@ -2625,6 +3064,7 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
|
||||||
if (JSONUtil.isTypeJSON(body)) {
|
if (JSONUtil.isTypeJSON(body)) {
|
||||||
JSONObject cheackdatas = JSONObject.parseObject(body);
|
JSONObject cheackdatas = JSONObject.parseObject(body);
|
||||||
String checkdata = cheackdatas.getString(receiveApi.getReturnMsg());
|
String checkdata = cheackdatas.getString(receiveApi.getReturnMsg());
|
||||||
|
sysMessageManageLogEntity.setReturnMsg(checkdata);//返回信息
|
||||||
sysMessageManageLogEntity.setRemark("接口调用失败,api返回信息字段未配置,返回信息如下:" + checkdata);//返回信息
|
sysMessageManageLogEntity.setRemark("接口调用失败,api返回信息字段未配置,返回信息如下:" + checkdata);//返回信息
|
||||||
} else {
|
} else {
|
||||||
sysMessageManageLogEntity.setRemark("接口调用失败,返回格式错误,不是JSON");//返回信息
|
sysMessageManageLogEntity.setRemark("接口调用失败,返回格式错误,不是JSON");//返回信息
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class SysMessageManageLogEntity extends BaseEntity {
|
||||||
private String status;
|
private String status;
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
private String remark;
|
private String remark;
|
||||||
|
private String returnMsg;
|
||||||
/** 返回解析类型 */
|
/** 返回解析类型 */
|
||||||
private String returnType;
|
private String returnType;
|
||||||
/** 失败状态(1、需要重新发送 2、不需要重新发送) */
|
/** 失败状态(1、需要重新发送 2、不需要重新发送) */
|
||||||
|
@ -206,5 +207,13 @@ public class SysMessageManageLogEntity extends BaseEntity {
|
||||||
public void setSendAppName(String sendAppName) {
|
public void setSendAppName(String sendAppName) {
|
||||||
this.sendAppName = sendAppName;
|
this.sendAppName = sendAppName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getReturnMsg() {
|
||||||
|
return returnMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReturnMsg(String returnMsg) {
|
||||||
|
this.returnMsg = returnMsg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,17 @@ public class EntranceController {
|
||||||
logger.info("-------------------结束调用上传文件upload接口-------------------");
|
logger.info("-------------------结束调用上传文件upload接口-------------------");
|
||||||
return jsonResultEntity;
|
return jsonResultEntity;
|
||||||
}
|
}
|
||||||
|
/***
|
||||||
|
* 文件上传接口
|
||||||
|
* @param
|
||||||
|
* @return@@
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/fileUploadlist", method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
public JsonResultEntity fileUploadlist(MultipartFile[] file, FileUploadDto entity, ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||||
|
entity.getBusinessType();
|
||||||
|
return BaseResult.getSuccessMessageEntity("gc");
|
||||||
|
}
|
||||||
@RequestMapping(value = "/pluginfileUpload", method = RequestMethod.POST)
|
@RequestMapping(value = "/pluginfileUpload", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public JsonResultEntity pluginfileUpload(MultipartFile file, FileUploadDto entity,String pluginPackageName, ServletRequest servletRequest, ServletResponse servletResponse) {
|
public JsonResultEntity pluginfileUpload(MultipartFile file, FileUploadDto entity,String pluginPackageName, ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||||
|
@ -195,6 +205,12 @@ public class EntranceController {
|
||||||
return sysApplicationService.externalCallInterface(servletRequest,servletResponse);
|
return sysApplicationService.externalCallInterface(servletRequest,servletResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/externalCallInterfacefileUpload")
|
||||||
|
@ResponseBody
|
||||||
|
public JsonResultEntity externalCallInterfacefileUpload(ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
||||||
|
return sysApplicationService.externalCallInterfacefileUpload(servletRequest,servletResponse);
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/externalCallInterfaceResend")
|
@RequestMapping(value = "/externalCallInterfaceResend")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public JsonResultEntity externalCallInterfaceResend(SysMessageManageLogEntity resendLogEntity) throws Exception {
|
public JsonResultEntity externalCallInterfaceResend(SysMessageManageLogEntity resendLogEntity) throws Exception {
|
||||||
|
|
5
pom.xml
5
pom.xml
|
@ -114,6 +114,11 @@
|
||||||
<artifactId>httpclient</artifactId>
|
<artifactId>httpclient</artifactId>
|
||||||
<version>${httpclient.version}</version>
|
<version>${httpclient.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpmime</artifactId>
|
||||||
|
<version>4.5.13</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-cache</artifactId>
|
<artifactId>spring-boot-starter-cache</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue