| | |
| | | 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; |
| | |
| | | */ |
| | | @Service |
| | | @Validated |
| | | @Slf4j |
| | | public class MesWmItemConsumeServiceImpl implements MesWmItemConsumeService { |
| | | |
| | | @Resource |
| | |
| | | // 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()) |