| | |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.returnissue.vo.detail.MesWmReturnIssueDetailSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnissue.MesWmReturnIssueDetailDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnissue.MesWmReturnIssueLineDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.materialstock.MesWmMaterialStockDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.wm.returnissue.MesWmReturnIssueDetailMapper; |
| | | import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseAreaService; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | 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 (ObjUtil.notEqual(line.getItemId(), reqVO.getItemId())) { |
| | | throw exception(WM_RETURN_ISSUE_DETAIL_ITEM_MISMATCH); |
| | | } |
| | | // 校验仓库、库区、库位的关联关系 |
| | | // 校验上架目标仓库、库区、库位的关联关系 |
| | | warehouseAreaService.validateWarehouseAreaExists( |
| | | reqVO.getWarehouseId(), reqVO.getLocationId(), reqVO.getAreaId()); |
| | | // 校验库位物料/批次混放规则 |
| | | // 校验上架目标库位的物料/批次混放规则 |
| | | materialStockService.checkAreaMixingRule(reqVO.getAreaId(), reqVO.getItemId(), reqVO.getBatchId()); |
| | | // 校验库存记录 |
| | | materialStockService.validateSelectedStock( |
| | | reqVO.getMaterialStockId(), reqVO.getItemId(), reqVO.getBatchId(), reqVO.getBatchCode(), |
| | | reqVO.getWarehouseId(), reqVO.getLocationId(), reqVO.getAreaId(), reqVO.getQuantity()); |
| | | // 校验来源库存记录(materialStockId 指向虚拟线边库,warehouseId 是上架目标仓库,两者仓库不同是正常的) |
| | | if (reqVO.getMaterialStockId() != null) { |
| | | MesWmMaterialStockDO stock = materialStockService.getMaterialStock(reqVO.getMaterialStockId()); |
| | | if (stock == null) { |
| | | throw exception(WM_MATERIAL_STOCK_NOT_EXISTS); |
| | | } |
| | | // 校验物料一致:此处只比对物料,因为来源库存(线边/虚拟仓)与上架目标仓库本就不同属正常 |
| | | if (ObjUtil.notEqual(stock.getItemId(), reqVO.getItemId())) { |
| | | throw new ServiceException(WM_MATERIAL_STOCK_SELECTION_MISMATCH.getCode(), |
| | | "所选来源库存归属物料与当前退货物料不一致,请重新选择来源库存"); |
| | | } |
| | | // 校验库存数量充足 |
| | | if (reqVO.getQuantity() != null && stock.getQuantity() != null |
| | | && stock.getQuantity().compareTo(reqVO.getQuantity()) < 0) { |
| | | throw exception(WM_MATERIAL_STOCK_INSUFFICIENT); |
| | | } |
| | | } |
| | | // 校验明细总数量不超过行数量(排除自身) |
| | | validateDetailQuantityNotExceed(reqVO.getLineId(), reqVO.getQuantity(), reqVO.getId(), line); |
| | | } |