|
|
|
@ -3,7 +3,9 @@ package com.logpm.factorydata.zbom.util;
|
|
|
|
|
import cn.hutool.core.map.MapUtil; |
|
|
|
|
import cn.hutool.http.HttpResponse; |
|
|
|
|
import cn.hutool.http.HttpUtil; |
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
import com.logpm.factorydata.zbom.pros.ZbFactoryProperties; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.common.constant.HttpConstants; |
|
|
|
|
import org.springblade.common.utils.CommonUtil; |
|
|
|
|
|
|
|
|
@ -18,10 +20,12 @@ import java.util.Map;
|
|
|
|
|
* @author zhaoqiaobo |
|
|
|
|
* @create 2024-03-21 15:23 |
|
|
|
|
*/ |
|
|
|
|
@Slf4j |
|
|
|
|
public class ZbomUtil { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 推送数据 |
|
|
|
|
* |
|
|
|
|
* @param zbProperties 志邦配置信息 |
|
|
|
|
* @param body 请求提 |
|
|
|
|
* @param method 请求方法 |
|
|
|
@ -31,6 +35,7 @@ public class ZbomUtil {
|
|
|
|
|
public static String pushZbomSystem(ZbFactoryProperties zbProperties, String body, String method) throws Exception { |
|
|
|
|
// 构建请求url
|
|
|
|
|
String url = ZbomUtil.buildUrl(zbProperties, body, method); |
|
|
|
|
log.info("推送志邦url:{}", url); |
|
|
|
|
// 请求数据
|
|
|
|
|
HashMap<String, String> headers = MapUtil.of(HttpConstants.HTTP.HEADER_NAME.CONTENT_TYPE, HttpConstants.HTTP.HEADER_VALUE.JSON); |
|
|
|
|
HttpResponse execute = HttpUtil.createPost(url).headerMap(headers, false).body(body).timeout(5 * 1000).execute(); |
|
|
|
@ -47,8 +52,11 @@ public class ZbomUtil {
|
|
|
|
|
params.put("sign_method", "md5"); |
|
|
|
|
params.put("timestamp", CommonUtil.dateToStringGeneral(new Date())); |
|
|
|
|
params.put("v", "1.0"); |
|
|
|
|
log.info("推送志邦参数:{}", JSONUtil.toJsonStr(params)); |
|
|
|
|
String body = bodyParam.replaceAll("\\s+", ""); |
|
|
|
|
log.info("推送志邦请求体:{}", body); |
|
|
|
|
String sign = QmSignUntil.signTopRequest(params, zbProperties.getSecretkey(), "md5", body); |
|
|
|
|
log.info("推送志邦签名:{}", sign); |
|
|
|
|
String url = getZbUrl(zbProperties.getUrl() + "/api/edi/ots/in?", params, sign); |
|
|
|
|
return url; |
|
|
|
|
} |
|
|
|
|