7 小时以前 e85a60b1778ed442545c00e14bbfe4f8d33c68ac
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemconsume/MesWmItemConsumeServiceImpl.java
@@ -27,6 +27,7 @@
import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseLocationService;
import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@@ -48,6 +49,7 @@
 */
@Service
@Validated
@Slf4j
public class MesWmItemConsumeServiceImpl implements MesWmItemConsumeService {
    @Resource
@@ -181,6 +183,11 @@
        // 2. 遍历明细,创建库存事务(按批次精确扣减线边库)
        for (MesWmItemConsumeDetailDO detail : details) {
            MesMdItemDO item = mesMdItemService.getItem(detail.getItemId());
            // 物料主数据缺失(BOM 引用了已删除/未同步的物料)时跳过该行,避免 NPE 阻断报工
            if (item == null || item.getMdmItemId() == null) {
                log.warn("[finishItemConsume] 消耗明细({}) 物料({}) 在 mes_md_item 中不存在,跳过扣库", detail.getId(), detail.getItemId());
                continue;
            }
            wmTransactionService.createTransaction(new MesWmTransactionSaveReqDTO()
                    .setType(MesWmTransactionTypeEnum.OUT.getType())
                    .setItemId(item.getMdmItemId())