| | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| | | |
| | |
| | | if (materialStock == null) { |
| | | throw exception(WM_MATERIAL_STOCK_NOT_EXISTS); |
| | | } |
| | | // 校验物料、批次、仓库等维度一致(防止传入错误的 materialStockId) |
| | | // 校验物料、批次、仓库等维度一致(防止传入错误的 materialStockId)。 |
| | | // 若此处不一致,通常是该库存已被移库/合并/拆分,需退回重新拣货,故给出针对性提示 |
| | | if (ObjUtil.notEqual(materialStock.getItemId(), reqDTO.getItemId()) |
| | | || ObjUtil.notEqual(materialStock.getWarehouseId(), reqDTO.getWarehouseId()) |
| | | || ObjUtil.notEqual(materialStock.getLocationId(), reqDTO.getLocationId()) |
| | | || ObjUtil.notEqual(materialStock.getAreaId(), reqDTO.getAreaId())) { |
| | | throw exception(WM_MATERIAL_STOCK_SELECTION_MISMATCH); |
| | | throw new ServiceException(WM_MATERIAL_STOCK_SELECTION_MISMATCH.getCode(), |
| | | "该库存记录已变动(可能被移库/合并/拆分),与出库明细不一致,无法扣减,请退回重新拣货"); |
| | | } |
| | | } else if (isInbound) { |
| | | // 入库事务:根据 forceCreateNewStock 标志决定是创建新记录还是查找/创建 |