diff --git a/mhd_oms/src/main/java/com/mhd/oms/application/service/businessPartner/BusinessPartnerApplicationService.java b/mhd_oms/src/main/java/com/mhd/oms/application/service/businessPartner/BusinessPartnerApplicationService.java index 5ce1d0038..db78414eb 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/application/service/businessPartner/BusinessPartnerApplicationService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/application/service/businessPartner/BusinessPartnerApplicationService.java @@ -24,10 +24,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.IOException; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service @Slf4j @@ -91,14 +88,19 @@ public class BusinessPartnerApplicationService { for (BusinessPartnerDTO businessPartnerDTO :businessPartnerDTOList){ - Map body = new HashMap<>(); - body.put("copyCode",businessPartnerDTO.getCorpCode()); - body.put("copyName",businessPartnerDTO.getCorpName()); + // 构建单个对象 + Map item = new HashMap<>(); + item.put("corpCode", businessPartnerDTO.getCorpCode()); + item.put("corpName", businessPartnerDTO.getCorpName()); + +// 包装成数组 + List> bodyList = new ArrayList<>(); + bodyList.add(item); GwLog gwLog = new GwLog(); gwLog.setType("商业合作伙伴"); gwLog.setBusinessId(Long.valueOf(businessPartnerDTO.getShipperId())); - gwLog.setRequestBody(JSONObject.toJSONString(body)); + gwLog.setRequestBody(JSONObject.toJSONString(bodyList)); gwLog.setResponseBody(""); gwLog.setStatus(1); gwLog.setSendTime(new Date()); @@ -114,7 +116,7 @@ public class BusinessPartnerApplicationService { CloseableHttpClient httpClient = HttpClients.createDefault(); 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.setHeader("Content-type", "application/json"); httpPost.setHeader("apiName", API_NAME);