From ddcd259ce577331fabfaac7d95d990e87f73fb1e Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Fri, 17 Oct 2025 16:55:55 +0800 Subject: [PATCH] =?UTF-8?q?2025-10-17=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ProductionInboundServiceImpl.java | 39 ++++++++++++++++++- .../ProductionInboundMapper.xml | 12 +++--- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gaotao/modules/productionInbound/service/impl/ProductionInboundServiceImpl.java b/src/main/java/com/gaotao/modules/productionInbound/service/impl/ProductionInboundServiceImpl.java index 34a83c1..8c9c22a 100644 --- a/src/main/java/com/gaotao/modules/productionInbound/service/impl/ProductionInboundServiceImpl.java +++ b/src/main/java/com/gaotao/modules/productionInbound/service/impl/ProductionInboundServiceImpl.java @@ -1,11 +1,13 @@ package com.gaotao.modules.productionInbound.service.impl; +import com.gaotao.common.exception.XJException; import com.gaotao.modules.inventoryStock.dao.InventoryStockMapper; import com.gaotao.modules.pms.entity.vo.PartLabelTemplateVo; import com.gaotao.modules.productionInbound.dao.ProductionInboundMapper; import com.gaotao.modules.productionInbound.service.ProductionInboundService; import com.gaotao.modules.inventoryStock.entity.InventoryStock; import com.gaotao.modules.inventoryStock.service.InventoryStockService; +import com.gaotao.modules.schedule.mapper.ProcedureMapper; import com.gaotao.modules.sys.entity.SysUserEntity; import com.gaotao.modules.trans.entity.TransDetail; import com.gaotao.modules.trans.entity.TransDetailDto; @@ -48,6 +50,9 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { @Autowired private TransDetailSubService transDetailSubService; + @Autowired + private ProcedureMapper procedureMapper; + @Override public List> getQualifiedInboundList(String site, String warehouseId, String searchCode, String status) { SysUserEntity sysUserEntity = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); @@ -81,6 +86,9 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { @Override @Transactional(rollbackFor = Exception.class) public boolean confirmInboundStorage(String orderNo, String locationCode, List> labels, String site, String buNo) { + SysUserEntity sysUserEntity = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); + String userName = sysUserEntity.getUsername(); + logger.info("开始确认生产入库上架,入库单号: {}, 库位号: {}, 标签数量: {}", orderNo, locationCode, labels.size()); try { // 1. 验证库位是否存在且可用 @@ -115,7 +123,18 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { insertInventoryStock(orderNo, warehouseId, locationCode, labels, site, buNo); // 6. 生成入库事务记录 - generateInboundTransaction(orderNo, warehouseId, locationCode, labels, site, buNo); + String transNo = generateInboundTransaction(orderNo, warehouseId, locationCode, labels, site, buNo); + +// // 7. 基于工单BOM,生成入库倒冲数据 +// // 调用存储过程 +// Map resultMap = this.UspBackflushMaterialByOrder(site, buNo, transNo, orderNo, 1, userName); +// //判断是否检验成功 +// String resultCode = String.valueOf(resultMap.get("resultCode")); +// if ("400".equalsIgnoreCase(resultCode)) { +// String msg = String.valueOf(resultMap.get("resultMsg")); +// String objectId = String.valueOf(resultMap.get("objectId")); +// throw new XJException(msg,objectId); +// } // 7. 异步调用ERP接口(这里可以发送消息到队列) //asyncCallErpInterface(orderNo, partNo, labels); @@ -128,6 +147,20 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { } } + public Map UspBackflushMaterialByOrder(String site, String buNo, String transNo, String orderNo, int inQty, String userName) { + List params = new ArrayList<>(); + params.add(site); + params.add(buNo); + params.add(transNo); + params.add(orderNo); + params.add(inQty); + params.add(userName); + + List> resultList = procedureMapper.getProcedureData("UspBackflushMaterialByOrder", params); + //处理返回的结果 + return resultList.get(0); + } + /** * 插入或更新库存数据 */ @@ -264,7 +297,7 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { /** * 生成入库事务记录 */ - private void generateInboundTransaction(String orderNo, String warehouseId, String locationCode, List> labels, String site,String buNo) { + private String generateInboundTransaction(String orderNo, String warehouseId, String locationCode, List> labels, String site,String buNo) { logger.info("开始生成生产入库事务记录,入库单号: {}", orderNo); // 构建TransDetailDto对象 @@ -289,6 +322,8 @@ public class ProductionInboundServiceImpl implements ProductionInboundService { // 生成事务子明细记录 addSubTransactionDetails(transHeader.getTransno(), labels, site, buNo, transDetailList, warehouseId, locationCode); logger.info("入库事务子记录生成完成,事务单号: {}, 入库单号: {}, 明细记录数: {}", transHeader.getTransno(), orderNo, labels.size()); + + return transHeader.getTransno(); } @Override diff --git a/src/main/resources/mapper/productionInbound/ProductionInboundMapper.xml b/src/main/resources/mapper/productionInbound/ProductionInboundMapper.xml index 46bd6f5..c590515 100644 --- a/src/main/resources/mapper/productionInbound/ProductionInboundMapper.xml +++ b/src/main/resources/mapper/productionInbound/ProductionInboundMapper.xml @@ -14,7 +14,7 @@ SUM(CASE WHEN pr.status = '已入库' THEN 1 ELSE 0 END) AS labelinCount, -- 已入库标签数 COUNT(DISTINCT pr.RollNo) AS totalLabels, -- 需入库标签数 SUM(CASE WHEN pr.status = '已入库' THEN ISNULL(pr.RollQty, 0) ELSE 0 END) AS totalinLabels, -- 已入库物料总数 - SUM(CAST(D.required_qty AS float)) as labelCount --需入库总数 + D.required_qty as labelCount --需入库总数 FROM inbound_notification_head h LEFT JOIN inbound_notification_detail d ON h.site = d.site and h.bu_no = d.bu_no and h.order_no = d.order_no INNER JOIN ShopOrder sh ON d.site = sh.site and d.bu_no = sh.bu_no and d.related_order_no = sh.OrderNo and d.part_no = sh.PartNo @@ -31,7 +31,7 @@ AND CONVERT(DATE, h.required_inbound_date) = CONVERT(DATE, GETDATE()) - GROUP BY h.site,h.bu_no, h.order_no, h.required_inbound_date + GROUP BY h.site,h.bu_no, h.order_no, h.required_inbound_date,D.required_qty ORDER BY h.required_inbound_date DESC @@ -46,7 +46,7 @@ SUM(CASE WHEN pr.status = '已入库' THEN 1 ELSE 0 END) AS labelinCount, -- 已入库标签数 COUNT(DISTINCT pr.RollNo) AS totalLabels, -- 需入库标签数 SUM(CASE WHEN pr.status = '已入库' THEN ISNULL(pr.RollQty, 0) ELSE 0 END) AS totalinLabels, -- 已入库物料总数 - SUM(CAST(D.required_qty AS float)) as labelCount --需入库总数 + D.required_qty as labelCount --需入库总数 FROM inbound_notification_head h LEFT JOIN inbound_notification_detail d ON h.site = d.site and h.bu_no = d.bu_no and h.order_no = d.order_no INNER JOIN ShopOrder sh ON d.site = sh.site and d.bu_no = sh.bu_no and d.related_order_no = sh.OrderNo and d.part_no = sh.PartNo @@ -55,7 +55,7 @@ h.site = #{site} AND h.bu_no = #{buNo} AND h.order_no = #{orderNo} - GROUP BY h.site, h.bu_no, h.order_no, h.required_inbound_date + GROUP BY h.site, h.bu_no, h.order_no, h.required_inbound_date,D.required_qty @@ -123,7 +123,7 @@ h.bu_no AS buNo, d.part_no AS partNo, SUM(CASE WHEN pr.status = '已入库' THEN ISNULL(pr.RollQty, 0) ELSE 0 END) AS totalinLabels, -- 已入库物料总数 - SUM(CAST(D.required_qty AS float)) as labelCount --需入库总数 + D.required_qty as labelCount --需入库总数 FROM inbound_notification_head h LEFT JOIN inbound_notification_detail d ON h.site = d.site and h.bu_no = d.bu_no and h.order_no = d.order_no INNER JOIN ShopOrder sh ON d.site = sh.site and d.bu_no = sh.bu_no and d.related_order_no = sh.OrderNo and d.part_no = sh.PartNo @@ -132,7 +132,7 @@ h.site = #{site} AND h.bu_no = #{buNo} AND h.order_no = #{inboundNo} - GROUP BY h.site, h.bu_no,d.part_no + GROUP BY h.site, h.bu_no,d.part_no,D.required_qty