推送修改

This commit is contained in:
zhaoqing
2026-06-09 11:40:05 +08:00
parent 02978d8969
commit 5dfe90aa33
3 changed files with 27 additions and 11 deletions
@@ -35,6 +35,7 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@@ -52,12 +53,16 @@ import java.util.*;
@Slf4j @Slf4j
public class BusinessDocumentOrderApplicationService { public class BusinessDocumentOrderApplicationService {
private static final String PUSH_API_URL = "http://10.33.0.100/nagu-erp-api/transfer/pushData";
private static final String API_NAME_I = "saveBill_i"; private static final String API_NAME_I = "saveBill_i";
private static final String API_NAME_E = "saveBill_e"; private static final String API_NAME_E = "saveBill_e";
private static final String VERIFY = "FuDjK3iuftzwf8kWJ44DDZJ9icZmL9Ee4Valv8Qz6VfsdW60fNEzNSEtrKlUr6OI";
private static final String API_NAME = "billAppModify"; private static final String API_NAME = "billAppModify";
@Value("${gw.push.url}")
private String pushUrl;
@Value("${gw.push.verify-key1}")
private String verifyKey;
@@ -279,12 +284,12 @@ public class BusinessDocumentOrderApplicationService {
// 7. 调用推送接口 // 7. 调用推送接口
try { try {
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(PUSH_API_URL); HttpPost httpPost = new HttpPost(pushUrl);
StringEntity postingString = new StringEntity(JSONObject.toJSONString(bodyList), "UTF-8"); StringEntity postingString = new StringEntity(JSONObject.toJSONString(bodyList), "UTF-8");
httpPost.setEntity(postingString); httpPost.setEntity(postingString);
httpPost.setHeader("Content-type", "application/json"); httpPost.setHeader("Content-type", "application/json");
httpPost.setHeader("verify", VERIFY); httpPost.setHeader("verify", verifyKey);
if ("I".equals(order.getIeType())) { if ("I".equals(order.getIeType())) {
httpPost.setHeader("apiName", API_NAME_I); httpPost.setHeader("apiName", API_NAME_I);
} else if ("E".equals(order.getIeType())) { } else if ("E".equals(order.getIeType())) {
@@ -406,12 +411,12 @@ public class BusinessDocumentOrderApplicationService {
// 3. 调用推送接口 // 3. 调用推送接口
try { try {
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(PUSH_API_URL); HttpPost httpPost = new HttpPost(pushUrl);
StringEntity postingString = new StringEntity(JSONObject.toJSONString(bodyList), "UTF-8"); StringEntity postingString = new StringEntity(JSONObject.toJSONString(bodyList), "UTF-8");
httpPost.setEntity(postingString); httpPost.setEntity(postingString);
httpPost.setHeader("Content-type", "application/json"); httpPost.setHeader("Content-type", "application/json");
httpPost.setHeader("verify", VERIFY); httpPost.setHeader("verify", verifyKey);
httpPost.setHeader("apiName", API_NAME); httpPost.setHeader("apiName", API_NAME);
CloseableHttpResponse response = httpClient.execute(httpPost); CloseableHttpResponse response = httpClient.execute(httpPost);
@@ -20,6 +20,7 @@ import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@@ -30,10 +31,13 @@ import java.util.*;
@Slf4j @Slf4j
public class BusinessPartnerApplicationService { public class BusinessPartnerApplicationService {
private static final String PUSH_API_URL = "http://10.33.0.100/nagu-erp-api/transfer/pushData";
private static final String API_NAME = "saveCorporation"; private static final String API_NAME = "saveCorporation";
private static final String VERIFY = "ESLuxAmB6VXCgbqP1eFzxTPVRagkQ62BUkfhElrgQ6XmE/g2reHVflY/SiCSU7JD"; @Value("${gw.push.url}")
private String pushUrl;
@Value("${gw.push.verify-key2}")
private String verifyKey;
@Resource @Resource
private UserServiceFeign userServiceFeign; private UserServiceFeign userServiceFeign;
@@ -115,12 +119,12 @@ public class BusinessPartnerApplicationService {
updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()),2,new Date(),pushBy,pushByName); updatePushStatus(Long.valueOf(businessPartnerDTO.getShipperId()),2,new Date(),pushBy,pushByName);
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(PUSH_API_URL); HttpPost httpPost = new HttpPost(pushUrl);
StringEntity postingString = new StringEntity(JSONObject.toJSONString(bodyList),"UTF-8"); StringEntity postingString = new StringEntity(JSONObject.toJSONString(bodyList),"UTF-8");
httpPost.setEntity(postingString); httpPost.setEntity(postingString);
httpPost.setHeader("Content-type", "application/json"); httpPost.setHeader("Content-type", "application/json");
httpPost.setHeader("apiName", API_NAME); httpPost.setHeader("apiName", API_NAME);
httpPost.setHeader("verify", VERIFY); httpPost.setHeader("verify", verifyKey);
try{ try{
CloseableHttpResponse response = httpClient.execute(httpPost); CloseableHttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity()); String responseString = EntityUtils.toString(response.getEntity());
+7
View File
@@ -35,3 +35,10 @@ spring:
namespace: # 命名空间id namespace: # 命名空间id
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置 group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
file-extension: yml #默认properties file-extension: yml #默认properties
# GW推送配置
gw:
push:
url: http://10.33.0.100/nagu-erp-api/transfer/pushData
verify-key1: FuDjK3iuftzwf8kWJ44DDZJ9icZmL9Ee4Valv8Qz6VfsdW60fNEzNSEtrKlUr6OI
verify-key2: ESLuxAmB6VXCgbqP1eFzxTPVRagkQ62BUkfhElrgQ6XmE/g2reHVflY/SiCSU7JD