diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/mdmDistribute/plugin/MdmModulePluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/mdmDistribute/plugin/MdmModulePluginInitializer.java index ebff9dc2..beb4c48e 100644 --- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/mdmDistribute/plugin/MdmModulePluginInitializer.java +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/mdmDistribute/plugin/MdmModulePluginInitializer.java @@ -452,6 +452,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { } } } catch (Exception e) { + logger.info("执行异常错误原因:"+e); logger.error("新增返回脚本解析保存三方id错误"+jsonResultEntity.getAttribute()); taskDetailEntity.setResult("新增返回脚本解析保存三方id错误"); taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); @@ -543,7 +544,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { map1.put("tableName",mainDb); map1.put("dataStatus", "N"); map1.put("deleteStatus", "0"); - map1.put("size", 10); + map1.put("size", 50); objects = mdmModuleDao.queryMdmSTs(map1); objects = toLowerCaseKeys(objects); @@ -738,7 +739,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { map1.put("tableName",mainDb); //map1.put("dataStatus", "F"); map1.put("updateStatus", "0"); - map1.put("size", 10); + map1.put("size", 50); objects = mdmModuleDao.queryMdmSTs(map1); objects = toLowerCaseKeys(objects); @@ -926,7 +927,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { map1.put("tableName",mainDb); //map1.put("dataStatus", "Y"); map1.put("addStatus", "0"); - map1.put("size", 100); + map1.put("size", 50); objects = mdmModuleDao.queryMdmSTs(map1); objects = toLowerCaseKeys(objects); @@ -991,6 +992,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { mdmModuleSendLogEntity.setTableName(mainDb+"_send_log"); mdmModuleSendLogEntity.setFormmainId(doObjects.get(i).getString("id")); mdmModuleSendLogEntity.setSts("Y"); + mdmModuleSendLogEntity.setDataType("1"); mdmModuleSendLogEntity.setAppId(sysApplicationEntity.getId()); mdmModuleSendLogEntity.setApiId(apiEntity.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"); + objects.get(i).put("sendsanfzt123",true); continue; }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"); + objects.get(i).put("sendsanfzt123",false); continue; } } @@ -1132,12 +1136,14 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { //所有下发发送完成,修改数据状态 for (int i = 0; i < objects.size(); i++) { - Map updateMap = new HashMap<>(); - updateMap.put("tableName",mainDb); - //updateMap.put("dataStatus", "Y"); - updateMap.put("addStatus", "1"); - updateMap.put("id", objects.get(i).getString("id")); - mdmModuleDao.updateMdmSTs(updateMap); + if(objects.get(i).getBoolean("sendsanfzt123")){ + Map updateMap = new HashMap<>(); + updateMap.put("tableName",mainDb); + //updateMap.put("dataStatus", "Y"); + updateMap.put("addStatus", "1"); + updateMap.put("id", objects.get(i).getString("id")); + mdmModuleDao.updateMdmSTs(updateMap); + } } } diff --git a/base-buildpackage/src/test/java/com/hzya/frame/temButtom.java b/base-buildpackage/src/test/java/com/hzya/frame/temButtom.java index 68701ee7..825925b0 100644 --- a/base-buildpackage/src/test/java/com/hzya/frame/temButtom.java +++ b/base-buildpackage/src/test/java/com/hzya/frame/temButtom.java @@ -1,19 +1,37 @@ package com.hzya.frame; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSONObject; 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.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; 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 * @Description * @Author llg * Date 2023/7/16 8:18 上午 */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = {WebappApplication.class}) +//@RunWith(SpringRunner.class) +//@SpringBootTest(classes = {WebappApplication.class}) public class temButtom { @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 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 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 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(); + } } diff --git a/base-service/src/main/java/com/hzya/frame/mdm/mdmModule/entity/MdmModuleEntity.xml b/base-service/src/main/java/com/hzya/frame/mdm/mdmModule/entity/MdmModuleEntity.xml index 8403c031..822bd239 100644 --- a/base-service/src/main/java/com/hzya/frame/mdm/mdmModule/entity/MdmModuleEntity.xml +++ b/base-service/src/main/java/com/hzya/frame/mdm/mdmModule/entity/MdmModuleEntity.xml @@ -974,10 +974,10 @@ where id = #{id} < #{item.filedVaule} - like concat('%',#{item.filedVaule},'%') + like #{item.filedVaule} - not like concat('%',#{item.filedVaule},'%') + not like #{item.filedVaule} diff --git a/base-service/src/main/java/com/hzya/frame/mdm/service/impl/MdmServiceImpl.java b/base-service/src/main/java/com/hzya/frame/mdm/service/impl/MdmServiceImpl.java index b5d7e716..8550e8cb 100644 --- a/base-service/src/main/java/com/hzya/frame/mdm/service/impl/MdmServiceImpl.java +++ b/base-service/src/main/java/com/hzya/frame/mdm/service/impl/MdmServiceImpl.java @@ -2111,7 +2111,8 @@ public class MdmServiceImpl implements IMdmService { return BaseResult.getSuccessMessageEntity("发送成功"); } else { 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")); } } diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/application/service/ISysApplicationService.java b/base-service/src/main/java/com/hzya/frame/sysnew/application/service/ISysApplicationService.java index f8dd60b1..363f69c4 100644 --- a/base-service/src/main/java/com/hzya/frame/sysnew/application/service/ISysApplicationService.java +++ b/base-service/src/main/java/com/hzya/frame/sysnew/application/service/ISysApplicationService.java @@ -309,6 +309,7 @@ public interface ISysApplicationService extends IBaseService 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 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 filenemes = multipartRequest.getFileNames(); + Map> 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 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 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 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> entry : files.entrySet()) { + String key = entry.getKey(); + List 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 { @@ -2599,6 +3036,7 @@ public class SysApplicationServiceImpl extends BaseServicehttpclient ${httpclient.version} + + org.apache.httpcomponents + httpmime + 4.5.13 + org.springframework.boot spring-boot-starter-cache