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 84fd248..54720fd 100644 --- a/src/main/java/com/glxp/mipsdl/client/hlfyyy/HlfyyyClient.java +++ b/src/main/java/com/glxp/mipsdl/client/hlfyyy/HlfyyyClient.java @@ -3,6 +3,7 @@ package com.glxp.mipsdl.client.hlfyyy; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.StrUtil; @@ -647,6 +648,11 @@ public class HlfyyyClient extends CommonHttpClient { return null; } + @Override + public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) { + return null; + } + @Resource SysParamConfigService sysParamConfigService; @@ -745,106 +751,21 @@ public class HlfyyyClient extends CommonHttpClient { ZzzyyRequest zaZyRequest = new ZzzyyRequest(); zaZyRequest.setMsgHeader(getMsgHeader("saveBuyApplyInfo")); zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); - submitByWebService(zaZyRequest.getMsgHeader(), zaZyRequest.getMsgBody()); +// submitByWebService(zaZyRequest.getMsgHeader(), zaZyRequest.getMsgBody()); return submitOrder(orderEntity, zaZyRequest); } - public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) { - if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) { - return ResultVOUtils.error(500, "单据号不能为空"); - } - ZaxzyyOrderRequest zaxzyyOrderRequest = new ZaxzyyOrderRequest(); - BeanUtil.copyProperties(udiwmsOrderRequest, zaxzyyOrderRequest); - //查询单据和详情信息,组装第三方系统接口所需参数 - IoOrderEntity orderEntity = orderDao.selectOne(new QueryWrapper().eq("billNo", udiwmsOrderRequest.getBillNo())); - zaxzyyOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime())); - //查询对应的第三方单据类型 - zaxzyyOrderRequest.setBillType("01"); - zaxzyyOrderRequest.setBillFlag("1"); - zaxzyyOrderRequest.setThirdSys("thirdSys"); - //查询单据类型 - //供应商 - BasicCorpEntity basicCorpEntity = null; - if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) { - basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp()); - } - if (basicCorpEntity != null) { - zaxzyyOrderRequest.setCorpId(basicCorpEntity.getThirdId()); - zaxzyyOrderRequest.setCorpName(basicCorpEntity.getName()); - } else { - String msg = "查询单据对应的第三方往来单位信息异常"; - orderUploadLogService.updateLocalErr(orderEntity, msg); - log.error("----单据提交-----" + orderEntity.getBillNo() + msg); - return ResultVOUtils.error(500, msg); - } - //查询仓库信息 - AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper().eq("code", orderEntity.getInvCode())); + public String submitByWebService(String msgHeader, String msgBody) { + String response = null; try { - zaxzyyOrderRequest.setLocInvCode(warehouseEntity.getCode()); - zaxzyyOrderRequest.setLocInvName(warehouseEntity.getName()); - } catch (Exception e) { - log.error("查询第三方系统仓库信息异常", e); - String msg = "查询第三方系统仓库信息异常"; - orderUploadLogService.updateLocalErr(orderEntity, msg); - return ResultVOUtils.error(500, msg); + response = callInterface(msgHeader, msgBody); + } catch (AxisFault axisFault) { + axisFault.printStackTrace(); + log.error(ExceptionUtil.stacktraceToString(axisFault)); } - //设置单据出入库类型 - zaxzyyOrderRequest.setInoutType(1); //入库 - //设置备注信息 - zaxzyyOrderRequest.setRemark("udi管理系统提交单据"); - //组装单据明细数据 - List ioCodeEntities = codeDao.selectList(new QueryWrapper() - .eq("orderId", orderEntity.getBillNo()) - .ne("action", "StockCheck") - ); - List items = new ArrayList<>(); - //查询业务单据详情 - List detailBizEntities = orderDetailBizDao.selectList(new QueryWrapper().eq("orderIdFk", orderEntity.getBillNo())); - String errMsg = setOrderDetailList(ioCodeEntities, items, detailBizEntities); - zaxzyyOrderRequest.setItem(items); - if (CollUtil.isEmpty(items)) { - orderUploadLogService.updateLocalErr(orderEntity, errMsg); - return ResultVOUtils.error(500, errMsg); - } - - if (StrUtil.isNotEmpty(errMsg)) { - orderUploadLogService.updateLocalErr(orderEntity, errMsg); - return ResultVOUtils.error(500, errMsg); - } - for (UdiwmsOrderDetailRequest i : items) { - String fphm = ""; - String fprq = null; - List invoiceList = IoOrderInvoiceEntity.builder().build() - .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)); - if (CollectionUtil.isNotEmpty(invoiceList)) { - fphm = invoiceList.stream().map(IoOrderInvoiceEntity::getInvoiceEncode).collect(Collectors.joining(",")); - if (invoiceList.get(0).getInvoiceDate() != null) - fprq = DateUtil.formatDateTime(invoiceList.get(0).getInvoiceDate()); - } - i.setFirstSalesInvNo(fphm); - i.setSecSalesInvNo(fphm); - i.setInvoiceDate(fprq); - } - //构造诏安接口参数 - ZzzyyRequest zaZyRequest = new ZzzyyRequest(); - zaZyRequest.setMsgHeader(getMsgHeader("saveBuyApplyInfo")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); - submitByWebService(zaZyRequest.getMsgHeader(), zaZyRequest.getMsgBody()); - 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(); - } - + log.error("Service Response: " + response); + return response; } /** @@ -1315,8 +1236,10 @@ public class HlfyyyClient extends CommonHttpClient { uploadLog.setSubmitTime(new Date()); uploadLog.setBillNo(orderEntity.getBillNo()); uploadLog.setFromType(Constants.THIRD_ORDER_UPLOAD); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_ORDER_SUBMIT_URL), zaZyRequest); - response = parserResult(response); + + + String data = submitByWebService(zaZyRequest.getMsgHeader(), zaZyRequest.getMsgBody()); + String response = parserResult(data); if (StrUtil.isNotBlank(response)) { try { BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); @@ -2459,24 +2382,31 @@ public class HlfyyyClient extends CommonHttpClient { // WebService地址 private static final String METHOD_NAME = "saveBuyApplyInfo"; - private static final String WSDL_URL = "http://192.168.158.208:8152/ZoesoftHipService.asmx?WSDL"; +// private static final String WSDL_URL = "http://192.168.158.208:8152/ZoesoftHipService.asmx?WSDL"; public String callInterface(String msgHeader, String msgBody) throws AxisFault { - // Create RPC Service Client - RPCServiceClient serviceClient = new RPCServiceClient(); - Options options = serviceClient.getOptions(); - // Set the target endpoint - EndpointReference targetEPR = new EndpointReference(WSDL_URL); - options.setTo(targetEPR); - // Prepare parameters Object[] params = new Object[]{msgHeader, msgBody, ""}; // Define return type Class[] returnTypes = new Class[]{String.class}; - // Invoke the web service + // Create RPC Service Client + RPCServiceClient serviceClient = new RPCServiceClient(); + Options options = serviceClient.getOptions(); + String url = thrSystemDetailService.getUrlExclude(Constants.URL_NAME_ORDER_SUBMIT_URL); + // Set the target endpoint + EndpointReference targetEPR = new EndpointReference(url); + options.setTo(targetEPR); + + // 设置 SOAPAction + options.setAction("http://tempuri.org/CallInterface"); // 添加这行 + // 或者使用空字符串 + // options.setAction(""); + + // 设置超时时间(毫秒) + options.setTimeOutInMilliSeconds(30000); log.error("msgHeader:" + msgHeader);