推送数据类型错误

This commit is contained in:
zhaoqing
2026-05-15 16:32:22 +08:00
parent 8948ffac58
commit 96c138a2a6
@@ -24,10 +24,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service @Service
@Slf4j @Slf4j
@@ -91,14 +88,19 @@ public class BusinessPartnerApplicationService {
for (BusinessPartnerDTO businessPartnerDTO :businessPartnerDTOList){ for (BusinessPartnerDTO businessPartnerDTO :businessPartnerDTOList){
Map<String, String> body = new HashMap<>(); // 构建单个对象
body.put("copyCode",businessPartnerDTO.getCorpCode()); Map<String, String> item = new HashMap<>();
body.put("copyName",businessPartnerDTO.getCorpName()); item.put("corpCode", businessPartnerDTO.getCorpCode());
item.put("corpName", businessPartnerDTO.getCorpName());
// 包装成数组
List<Map<String, String>> bodyList = new ArrayList<>();
bodyList.add(item);
GwLog gwLog = new GwLog(); GwLog gwLog = new GwLog();
gwLog.setType("商业合作伙伴"); gwLog.setType("商业合作伙伴");
gwLog.setBusinessId(Long.valueOf(businessPartnerDTO.getShipperId())); gwLog.setBusinessId(Long.valueOf(businessPartnerDTO.getShipperId()));
gwLog.setRequestBody(JSONObject.toJSONString(body)); gwLog.setRequestBody(JSONObject.toJSONString(bodyList));
gwLog.setResponseBody(""); gwLog.setResponseBody("");
gwLog.setStatus(1); gwLog.setStatus(1);
gwLog.setSendTime(new Date()); gwLog.setSendTime(new Date());
@@ -114,7 +116,7 @@ public class BusinessPartnerApplicationService {
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(PUSH_API_URL); HttpPost httpPost = new HttpPost(PUSH_API_URL);
StringEntity postingString = new StringEntity(JSONObject.toJSONString(body),"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);