Merge remote-tracking branch 'origin/main'

This commit is contained in:
owan 2024-11-12 15:12:54 +08:00
commit 21c09d2be3
1 changed files with 18 additions and 5 deletions

View File

@ -1,11 +1,13 @@
package shkd.sys.sys.midservice.utils; package shkd.sys.sys.midservice.utils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.bes.mq.org.apache.commons.codec.digest.DigestUtils;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.bos.util.HttpClientUtils; import kd.bos.util.HttpClientUtils;
import kd.bos.util.StringUtils; import kd.bos.util.StringUtils;
import kd.ebg.aqap.banks.srcb.dc.services.utils.SmUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -27,11 +29,15 @@ public class RequestClient {
private String protocal;//http private String protocal;//http
private String ip;// 域名 private String ip;// 域名
private String port;// 端口 private String port;// 端口
private String clientKey;// clientKey
private String clientSecret_scict;// clientSecret-scict
private RequestClient() { private RequestClient() {
this.protocal = System.getProperty("efms.midservice.protocal"); this.protocal = System.getProperty("backlog-protocal");
this.ip = System.getProperty("efms.midservice.ip"); this.ip = System.getProperty("backlog-ip");
this.port = System.getProperty("efms.midservice.port"); this.port = System.getProperty("backlog-port");
this.clientKey= System.getProperty("clientKey-scict");
this.clientSecret_scict= System.getProperty("clientSecret-scict");
} }
/** /**
* 获取中台服务客户端实例 * 获取中台服务客户端实例
@ -53,20 +59,24 @@ public class RequestClient {
*/ */
public String callService(String url, String body) { public String callService(String url, String body) {
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
header.put("systemid", this.clientKey);
header.put("sign",this.clientSecret_scict);
header.put("Content-Type", "application/x-www-form-urlencoded"); header.put("Content-Type", "application/x-www-form-urlencoded");
// header.put("Content-Type", "application/json; charset=utf-8");
StringBuffer urlStr = new StringBuffer(); StringBuffer urlStr = new StringBuffer();
urlStr.append(this.protocal).append("://").append(this.ip); urlStr.append(this.protocal).append("://").append(this.ip);
if (!StringUtils.isEmpty(this.port)) { if (!StringUtils.isEmpty(this.port)) {
urlStr.append(":").append(this.port); urlStr.append(":").append(this.port);
} }
logger.info("环境参数,protocal:"+this.protocal+",ip:"+this.ip+",this.port:"+this.port);
urlStr.append(url); urlStr.append(url);
String responseText = null; String responseText = null;
try { try {
//直接POST请求 //直接POST请求
responseText = HttpClientUtils.postjson(urlStr.toString(), header, body); responseText = HttpClientUtils.postjson(urlStr.toString(), header, body);
logger.info(String.format("###调用接口成功请求URL%s请求Header%s请求Body%s响应报文%s", url, JSON.toJSONString(header), body, responseText)); logger.info(String.format("###调用接口成功请求URL%s请求Header%s请求Body%s响应报文%s", urlStr, JSON.toJSONString(header), body, responseText));
} catch (IOException e) { } catch (IOException e) {
logger.error(String.format("###调用接口异常:%s请求URL%s请求Header%s请求Body%s", e.getMessage(), url, JSON.toJSONString(header), body), e); logger.error(String.format("###调用接口异常:%s请求URL%s请求Header%s请求Body%s", e.getMessage(), urlStr, JSON.toJSONString(header), body), e);
} }
return responseText; return responseText;
} }
@ -87,7 +97,9 @@ public class RequestClient {
urlStr.append(":").append(this.port); urlStr.append(":").append(this.port);
} }
urlStr.append(url);; urlStr.append(url);;
logger.info("保存时,环境参数,protocal:"+this.protocal+",ip:"+this.ip+",this.port:"+this.port);
DynamicObject dynamicObject = BusinessDataServiceHelper.newDynamicObject("shkd_backlog"); DynamicObject dynamicObject = BusinessDataServiceHelper.newDynamicObject("shkd_backlog");
logger.info("保存日志表id"+dynamicObject.getPkValue());
dynamicObject.set("shkd_url",urlStr); dynamicObject.set("shkd_url",urlStr);
dynamicObject.set("shkd_request",title); dynamicObject.set("shkd_request",title);
dynamicObject.set("shkd_request_tag",jsonMessage); dynamicObject.set("shkd_request_tag",jsonMessage);
@ -95,6 +107,7 @@ public class RequestClient {
dynamicObject.set("shkd_response",result); dynamicObject.set("shkd_response",result);
dynamicObject.set("shkd_status","0"); dynamicObject.set("shkd_status","0");
SaveServiceHelper.save(new DynamicObject[]{dynamicObject}); SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
logger.info("保存日志表id"+dynamicObject.getPkValue());
logger.info("###结束调用待办保存日志方法"); logger.info("###结束调用待办保存日志方法");
} }
/*** /***