From ece27b786fac105b20580d0c1e7b9b22dc2f1085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Fri, 12 Jun 2026 16:46:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E9=80=BB=E8=BE=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mhd/system/api/OmsServiceFeign.java | 4 + .../RemoteOmsFeignFallbackFactory.java | 5 + ...vationStockOutOrderApplicationService.java | 207 ++++++++++++++++++ .../ReservationStockOutOrderApi.java | 10 + .../StockOutOrderApplicationService.java | 6 +- 5 files changed, 229 insertions(+), 3 deletions(-) diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java index 4396cc46e..03d48d2f4 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java @@ -62,4 +62,8 @@ public interface OmsServiceFeign { @ApiOperation("批量推送") @PostMapping("/reservationStockOutOrderApi/batchPush") public AjaxResult batchPush(@RequestBody List idList); + + @ApiOperation("批量推送") + @PostMapping("/reservationStockOutOrderApi/batchPushByNumber") + public AjaxResult batchPushByNumber(@RequestBody List numberList); } \ No newline at end of file diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteOmsFeignFallbackFactory.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteOmsFeignFallbackFactory.java index e8ab07f66..fc4eff84f 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteOmsFeignFallbackFactory.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteOmsFeignFallbackFactory.java @@ -85,6 +85,11 @@ public class RemoteOmsFeignFallbackFactory implements FallbackFactory idList) { return null; } + + @Override + public AjaxResult batchPushByNumber(List numberList) { + return null; + } }; } } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/service/ReservationStockOutOrderApplicationService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/service/ReservationStockOutOrderApplicationService.java index 1631e9602..0098c9a18 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/service/ReservationStockOutOrderApplicationService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/service/ReservationStockOutOrderApplicationService.java @@ -1080,6 +1080,213 @@ public class ReservationStockOutOrderApplicationService { return stockOutOrderDomainService.queryOutStockNoticePrintDetail(stockOutOrderDO); } + public AjaxResult batchPushByNumber(List numberList) { + if (numberList == null || numberList.isEmpty() || numberList.size() < 1) { + return AjaxResult.error("没有数据需要推送"); + } + String s = numberList.get(0); + ReservationStockOutOrder one = stockOutOrderService.getOne(new LambdaQueryWrapper() + .eq(ReservationStockOutOrder::getOutOrderNumber, s) + .eq(ReservationStockOutOrder::getDelFlag, 1), false); + List idList = new ArrayList<>(); + idList.add(one.getOutOrderId()); + LoginUser loginUser = SecurityUtils.getLoginUser(); + Long pushBy = loginUser != null ? loginUser.getUserid() : null; + String pushByName = loginUser != null ? loginUser.getUsername() : null; + Long organizationId = loginUser != null ? loginUser.getUserPo().getOrganizationId() : null; + Long topOrganizationId = loginUser != null ? loginUser.getUserPo().getTopOrganizationId() : null; + String organizationName = loginUser != null ? loginUser.getUserPo().getOrganizationName() : null; + + int successCount = 0; + int failCount = 0; + StringBuilder failMsg = new StringBuilder(); + + + for (Long id : idList) { + + +// 查询出库单 + ReservationStockOutOrder reservationStockOutOrder = reservationStockOutOrderMapper.selectById(id); + if (reservationStockOutOrder == null) { + failCount++; + failMsg.append("id:").append(id).append("不存在;"); + continue; + } + + // 获取货主NC编码 + Long shipperId = reservationStockOutOrder.getShipperId(); + String userNcCode = reservationStockInOrderMapper.getUserNcCode(shipperId); + + // 构建主单Map + Map order = new HashMap<>(); + order.put("billNo", reservationStockOutOrder.getOutOrderNumber()); + order.put("ieFlag", "E"); + order.put("billDate", reservationStockOutOrder.getDocumentDate()); + order.put("corpCode", userNcCode != null ? userNcCode : ""); + + // 查询出库物料明细 + List reservationOutMaterialDetails = + reservationOutMaterialDetailMapper.selectList( + new LambdaQueryWrapper() + .eq(ReservationOutMaterialDetail::getOutOrderNumber, reservationStockOutOrder.getOutOrderNumber()) + .eq(ReservationOutMaterialDetail::getDelFlag, 1) + ); + + if (reservationOutMaterialDetails == null || reservationOutMaterialDetails.isEmpty()) { + failCount++; + failMsg.append("id:").append(id).append("无物料明细;"); + continue; + } + + // 构建明细List + List> orderList = new ArrayList<>(); + for (ReservationOutMaterialDetail detail : reservationOutMaterialDetails) { + Map item = new HashMap<>(); + item.put("billNo", reservationStockOutOrder.getOutOrderNumber()); + String lotNo = detail.getLotNo(); + if (lotNo != null) { + String[] split = lotNo.split("-"); + if (split.length == 2) { + item.put("lineNum", split[1]); + } else { + item.put("lineNum", 1); + } + } else { + item.put("lineNum", 1); + } + item.put("qty", detail.getQuantity()); + + // 获取物料详情 + if (detail.getMaterialBaseInfoId() != null) { + MaterialBaseInfoPO materialBaseInfoPO = reservationStockInOrderMapper.getinfo(detail.getMaterialBaseInfoId()); + if (materialBaseInfoPO != null) { + item.put("erpCurr", materialBaseInfoPO.getCurrency() != null ? materialBaseInfoPO.getCurrency() : ""); + item.put("erpPrice", materialBaseInfoPO.getUnitPrice()); + item.put("itemNo", materialBaseInfoPO.getMaterialCode() != null ? materialBaseInfoPO.getMaterialCode() : ""); + item.put("itemName", materialBaseInfoPO.getMaterialName() != null ? materialBaseInfoPO.getMaterialName() : ""); + item.put("spec", materialBaseInfoPO.getSpecificationModel() != null ? materialBaseInfoPO.getSpecificationModel() : ""); + item.put("unit", materialBaseInfoPO.getDeclarationUnit() != null ? materialBaseInfoPO.getDeclarationUnit() : ""); + // 计算金额 + BigDecimal unitPrice = materialBaseInfoPO.getUnitPrice(); + BigDecimal quantity = detail.getQuantity(); + if (unitPrice != null && quantity != null && unitPrice.compareTo(BigDecimal.ZERO) != 0 && quantity.compareTo(BigDecimal.ZERO) != 0) { + BigDecimal amount = unitPrice.multiply(quantity).setScale(2, BigDecimal.ROUND_HALF_UP); + item.put("amount", amount); + } + } + } + + // 库存关联信息(实体默认值 + WMS覆盖) + Long kcId = reservationOutMaterialDetailMapper.getkcIdByUniqueId(detail.getUniqueId()); + if (kcId != null) { + String inOrderNumber = reservationOutMaterialDetailMapper.getInOrderNumber(kcId); + String warehouseCode = reservationOutMaterialDetailMapper.getWarehouse(kcId); + String opWhLoc = reservationOutMaterialDetailMapper.getOpWhLoc(kcId); + String inLotNo = reservationOutMaterialDetailMapper.getLotByKcId(kcId); + + if (inOrderNumber != null) { + item.put("orderINo", inOrderNumber); + } + if (warehouseCode != null) { + item.put("warehouse", warehouseCode); + } + if (opWhLoc != null) { + item.put("opWhLoc", opWhLoc); + } + // billI = 入库单号 + if (inOrderNumber != null) { + item.put("billI", inOrderNumber); + } + if (inLotNo != null && inLotNo.contains("-")) { + String[] split = inLotNo.split("-"); + if (split.length == 2) { + item.put("orderIRow", split[1]); + item.put("billIRow", split[1]); + } else { + item.put("orderIRow", 1); + item.put("billIRow", 1); + } + } else { + item.put("orderIRow", 1); + item.put("billIRow", 1); + } + } + orderList.add(item); + } + order.put("orderList", orderList); + + // 构建推送body + List> bodyList = new ArrayList<>(); + bodyList.add(order); + + GwLog gwLog = new GwLog(); + gwLog.setType("保税仓-出口订单"); + gwLog.setBusinessId(id); + gwLog.setRequestBody(com.alibaba.fastjson.JSONObject.toJSONString(bodyList)); + gwLog.setResponseBody(""); + gwLog.setStatus(1); + gwLog.setSendTime(new Date()); + gwLog.setOrganizationId(organizationId); + gwLog.setTopOrganizationId(topOrganizationId); + gwLog.setOrganizationName(organizationName); + gwLog.setCreateBy(pushBy); + gwLog.setCreateTime(new Date()); + gwLog.setDelFlag(1); + gwLogMapper.insert(gwLog); + + updatePushStatus(id, 2, new Date(), pushBy,pushByName); + + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpPost httpPost = new HttpPost(PUSH_API_URL); + StringEntity postingString = new StringEntity(com.alibaba.fastjson.JSONObject.toJSONString(bodyList), "UTF-8"); + httpPost.setEntity(postingString); + httpPost.setHeader("Content-type", "application/json"); + httpPost.setHeader("apiName", API_NAME); + httpPost.setHeader("verify", VERIFY); + + try { + CloseableHttpResponse response = httpClient.execute(httpPost); + String responseString = EntityUtils.toString(response.getEntity()); + gwLog.setResponseBody(responseString); + + if (response.getStatusLine().getStatusCode() == 200) { + gwLog.setStatus(2); + updatePushStatus(id, 3, new Date(), pushBy,pushByName); + successCount++; + } else { + gwLog.setStatus(3); + gwLog.setErrorMsg(responseString); + updatePushStatus(id, 4, new Date(), pushBy,pushByName); + failCount++; + failMsg.append("id:").append(id).append("失败;"); + } + gwLogMapper.updateById(gwLog); + response.close(); + } catch (IOException e) { + gwLog.setStatus(3); + gwLog.setErrorMsg(e.getMessage()); + gwLog.setResponseBody("请求异常:" + e.getMessage()); + gwLogMapper.updateById(gwLog); + updatePushStatus(id, 4, new Date(), pushBy,pushByName); + failCount++; + failMsg.append("id:").append(id).append("异常:").append(e.getMessage()).append(";"); + log.error("保税仓推送异常: id={}, error={}", id, e.getMessage()); + } finally { + try { + httpClient.close(); + } catch (Exception e) { + log.error("关闭httpClient异常: {}", e.getMessage()); + } + } + } + + String resultMsg = "推送完成: 成功" + successCount + "条, 失败" + failCount + "条"; + if (failCount > 0) { + resultMsg += "[" + failMsg.toString() + "]"; + } + return AjaxResult.success(resultMsg); + } + public AjaxResult batchPush(List idList) { if (idList == null || idList.isEmpty()) { return AjaxResult.error("没有数据需要推送"); diff --git a/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/ReservationStockOutOrder/ReservationStockOutOrderApi.java b/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/ReservationStockOutOrder/ReservationStockOutOrderApi.java index e346d44de..abe0a56b7 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/ReservationStockOutOrder/ReservationStockOutOrderApi.java +++ b/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/ReservationStockOutOrder/ReservationStockOutOrderApi.java @@ -199,6 +199,16 @@ public class ReservationStockOutOrderApi extends BaseController { } + @ApiOperation("批量推送") + @PostMapping("/batchPushByNumber") + public AjaxResult batchPushByNumber(@RequestBody List numberList){ + if(numberList == null || numberList.isEmpty()){ + return AjaxResult.error("没有数据需要推送"); + } + return stockOutOrderApplicationService.batchPushByNumber(numberList); + + } + @ApiOperation("退货") @GetMapping("/returnGoods") diff --git a/mhd_wms/src/main/java/com/mhd/wms/application/service/stockOutOrder/StockOutOrderApplicationService.java b/mhd_wms/src/main/java/com/mhd/wms/application/service/stockOutOrder/StockOutOrderApplicationService.java index fec3c8af3..1a8687f4f 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/application/service/stockOutOrder/StockOutOrderApplicationService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/application/service/stockOutOrder/StockOutOrderApplicationService.java @@ -1010,10 +1010,10 @@ public class StockOutOrderApplicationService { ids.add(outOrderId); batchPush(ids); } else { - Long outOrderId = stockOutOrderDO.getOutOrderId(); - List ids = new ArrayList<>(); + String outOrderId = stockOutOrderDO.getOutOrderNumber(); + List ids = new ArrayList<>(); ids.add(outOrderId); - omsServiceFeign.batchPush(ids); + omsServiceFeign.batchPushByNumber(ids); } } catch (Exception e) { throw new ServiceException("生成报关单失败");