This commit is contained in:
fang 2024-11-12 13:42:18 +08:00
parent 30c1d93a38
commit c78998b2d5
1 changed files with 12 additions and 2 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("backlog-protocal"); this.protocal = System.getProperty("backlog-protocal");
this.ip = System.getProperty("backlog-ip"); this.ip = System.getProperty("backlog-ip");
this.port = System.getProperty("backlog-port"); this.port = System.getProperty("backlog-port");
this.clientKey= System.getProperty("clientKey-scict");
this.clientSecret_scict= System.getProperty("clientSecret-scict");
} }
/** /**
* 获取中台服务客户端实例 * 获取中台服务客户端实例
@ -53,7 +59,10 @@ 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("clientKey", 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)) {
@ -65,9 +74,9 @@ public class RequestClient {
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;
} }
@ -98,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("###结束调用待办保存日志方法");
} }
/*** /***