From f346a6cb5e2ea684e2f8d89a2c66087030225d71 Mon Sep 17 00:00:00 2001 From: yewj Date: Thu, 26 Dec 2024 14:28:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eservice=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 23 ++- .../mipsdl/client/hlfyyy/HlfyyyClient.java | 147 +++++++----------- 2 files changed, 76 insertions(+), 94 deletions(-) diff --git a/pom.xml b/pom.xml index daf3d3f..36f8ebd 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ 1.2.73 - + @@ -156,11 +156,11 @@ yb zephyr1.7.0 - - - - - + + + + + com.glxp @@ -172,7 +172,16 @@ jna 5.11.0 - + + javax.xml.ws + jaxws-api + 2.3.1 + + + com.sun.xml.ws + jaxws-rt + 2.3.1 + diff --git a/src/main/java/com/glxp/mipsdl/client/hlfyyy/HlfyyyClient.java b/src/main/java/com/glxp/mipsdl/client/hlfyyy/HlfyyyClient.java index 6285194..219371d 100644 --- a/src/main/java/com/glxp/mipsdl/client/hlfyyy/HlfyyyClient.java +++ b/src/main/java/com/glxp/mipsdl/client/hlfyyy/HlfyyyClient.java @@ -78,10 +78,13 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import javax.xml.namespace.QName; +import javax.xml.soap.*; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigDecimal; +import java.net.URL; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -660,7 +663,6 @@ public class HlfyyyClient extends CommonHttpClient { zaxzyyOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime())); //查询对应的第三方单据类型 ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new QueryWrapper().eq("code", udiwmsOrderRequest.getBillType())); - zaxzyyOrderRequest.setThirdSys(getUserName(orderEntity)); zaxzyyOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode()); zaxzyyOrderRequest.setBillFlag("1"); @@ -715,8 +717,6 @@ public class HlfyyyClient extends CommonHttpClient { return ResultVOUtils.error(500, msg); } } - - //查询仓库信息 AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper().eq("code", orderEntity.getInvCode())); try { @@ -764,8 +764,6 @@ public class HlfyyyClient extends CommonHttpClient { orderUploadLogService.updateLocalErr(orderEntity, errMsg); return ResultVOUtils.error(500, errMsg); } - - for (UdiwmsOrderDetailRequest i : items) { String fphm = ""; String fprq = null; @@ -773,7 +771,7 @@ public class HlfyyyClient extends CommonHttpClient { .selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo()) .eq(IoOrderInvoiceEntity::getBindRlFk, i.getBindRlFk()) .eq(StrUtil.isNotEmpty(i.getBatchNo()), IoOrderInvoiceEntity::getBatchNo, i.getBatchNo()). - groupBy(IoOrderInvoiceEntity::getInvoiceEncode)); + groupBy(IoOrderInvoiceEntity::getInvoiceEncode)); if (CollectionUtil.isNotEmpty(invoiceList)) { fphm = invoiceList.stream().map(IoOrderInvoiceEntity::getInvoiceEncode).collect(Collectors.joining(",")); if (invoiceList.get(0).getInvoiceDate() != null) @@ -783,68 +781,25 @@ public class HlfyyyClient extends CommonHttpClient { i.setSecSalesInvNo(fphm); i.setInvoiceDate(fprq); } - - //构造诏安接口参数 ZzzyyRequest zaZyRequest = new ZzzyyRequest(); - - //提交到第三方系统 - if (thrSystemBusApiEntity.getUrl().equals("saveMasterialInput")) { -// //采购入库单据 -// if (vailHightMaterial(detailBizEntities.get(0))) { -// zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight")); -// UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = submitPreInOrderToThirdSys(zaxzyyOrderRequest, orderEntity); -// zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest)); -// } else { -// zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); -// zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); -// } - Boolean b = sysParamConfigService.selectByKey("ct_split_groupbuy"); - if (b) { - Map> splitMap = items.stream() - .collect(Collectors.groupingBy(UdiwmsOrderDetailRequest::getFirstSalesInvNo)); - BaseResponse baseResponse = null; - int index = 1; - if (splitMap.size() > 1) { - for (List splitItems : splitMap.values()) { - zaxzyyOrderRequest.setItem(splitItems); - zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); - orderEntity.setBillNo(orderEntity.getBillNo() + "-" + index); - baseResponse = submitOrder(orderEntity, zaZyRequest); - } - return baseResponse; - } else { - zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); - return submitOrder(orderEntity, zaZyRequest); - } - } else { - zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); - return submitOrder(orderEntity, zaZyRequest); - } - - - } else if (thrSystemBusApiEntity.getUrl().equals("saveMaterialHight")) { - -// // 1.先提交到物资 -// zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); -// zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); -// submitOrder(orderEntity, zaZyRequest); + zaZyRequest.setMsgHeader(getMsgHeader("saveBuyApplyInfo")); + zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); + submitByWebService(zaZyRequest.getMsgHeader(), zaZyRequest.getMsgBody()); + return submitOrder(orderEntity, zaZyRequest); + } - //2.提交到预备货 - zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight")); - UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = submitPreInOrderToThirdSys(zaxzyyOrderRequest, orderEntity); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest)); - return submitOrder(orderEntity, zaZyRequest); + public void submitByWebService(String msgHeader, String msgBody) { + try { + String response = callInterface(msgHeader, msgBody); + System.out.println("Service Response: " + response); + } catch (Exception e) { + e.printStackTrace(); } - return ResultVOUtils.error(500, "提交失败!"); } - /** * 校验是否高值耗材 * @@ -866,33 +821,6 @@ public class HlfyyyClient extends CommonHttpClient { public String getUserName(IoOrderEntity orderEntity) { return "方奕生/1007"; -// String userName = null; -// //创建人非供应商 -// if (StrUtil.isNotEmpty(orderEntity.getCheckUser())) { -// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCheckUser()); -// if (authUserEntity == null) -// userName = null; -// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName(); -// } else if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) { -// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getReviewUser()); -// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName(); -// } else if (StrUtil.isNotEmpty(orderEntity.getCreateUser()) && orderEntity.getCreateUser().length() != 14) { -// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCreateUser()); -// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName(); -// } else if (StrUtil.isNotEmpty(orderEntity.getUpdateUser()) && orderEntity.getUpdateUser().length() != 14) { -// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getUpdateUser()); -// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName(); -// } -// if (userName == null) { -// List authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper().eq("code", orderEntity.getInvCode())); -// if (CollUtil.isNotEmpty(authWarehouseUsers)) { -// AuthWarehouseUser authWarehouseUser = authWarehouseUsers.get(0); -// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCheckUser()); -// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName(); -// return userName; -// } -// } -// return userName; } @@ -2475,4 +2403,49 @@ public class HlfyyyClient extends CommonHttpClient { } } + + private static final String WSDL_URL = "http://192.168.158.208:8152/ZoesoftHipService.asmx?WSDL"; + private static final String NAMESPACE = "http://192.168.158.208:8152/"; + private static final String SERVICE_NAME = "saveBuyApplyInfo"; + + + public String callInterface(String msgHeader, String msgBody) throws Exception { + SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); + SOAPConnection connection = soapConnectionFactory.createConnection(); + + try { + MessageFactory messageFactory = MessageFactory.newInstance(); + SOAPMessage soapMessage = messageFactory.createMessage(); + + SOAPPart soapPart = soapMessage.getSOAPPart(); + SOAPEnvelope envelope = soapPart.getEnvelope(); + envelope.addNamespaceDeclaration("tem", NAMESPACE); + + SOAPBody soapBody = envelope.getBody(); + + SOAPElement operationElement = soapBody.addChildElement(SERVICE_NAME, "tem"); + + SOAPElement msgHeaderElement = operationElement.addChildElement("as_msgHeader"); + msgHeaderElement.addTextNode(msgHeader); + + SOAPElement msgBodyElement = operationElement.addChildElement("as_msgBody"); + msgBodyElement.addTextNode(msgBody); + + SOAPElement responseElement = operationElement.addChildElement("rs_response_xml"); + + log.error("request: {}", soapMessage.toString()); + + soapMessage.saveChanges(); + + SOAPMessage soapResponse = connection.call(soapMessage, WSDL_URL); + + SOAPBody responseBody = soapResponse.getSOAPBody(); + return responseBody.getTextContent(); + + } finally { + connection.close(); + } + } + + }