| | |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeLineDO; |
| | | import cn.iocoder.yudao.module.mes.service.wm.salesnotice.MesWmSalesNoticeLineService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.oqc.MesQcOqcService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.unitconvert.MesWmItemUnitConvertService; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.context.annotation.Lazy; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | /** |
| | | * MES 销售出库单行 Service 实现类 |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Service |
| | | @Validated |
| | |
| | | @Resource |
| | | @Lazy |
| | | private MesQcOqcService oqcService; |
| | | @Resource |
| | | private MesWmItemUnitConvertService itemUnitConvertService; |
| | | |
| | | @Override |
| | | public Long createProductSalesLine(MesWmProductSalesLineSaveReqVO createReqVO) { |
| | | // 双单位换算:按录入单位换算为物料主单位数量(必须先换算,再校验与发货通知单行的数量一致性) |
| | | fillPrimaryQuantity(createReqVO); |
| | | // 校验数据 |
| | | validateLineSaveData(createReqVO); |
| | | |
| | |
| | | public void updateProductSalesLine(MesWmProductSalesLineSaveReqVO updateReqVO) { |
| | | // 校验存在 |
| | | MesWmProductSalesLineDO oldLine = validateProductSalesLineExists(updateReqVO.getId()); |
| | | // 校验数据 |
| | | updateReqVO.setSalesId(oldLine.getSalesId()); |
| | | // 双单位换算:按录入单位换算为物料主单位数量(必须先换算,再校验与发货通知单行的数量一致性) |
| | | fillPrimaryQuantity(updateReqVO); |
| | | // 校验数据 |
| | | validateLineSaveData(updateReqVO); |
| | | |
| | | // 更新 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 双单位换算:选择了录入单位时,按「录入数量 × 换算比率」得到物料主单位口径的出库数量 |
| | | * |
| | | * 未按辅单位录入时必须直接填写出库数量 |
| | | */ |
| | | private void fillPrimaryQuantity(MesWmProductSalesLineSaveReqVO reqVO) { |
| | | if (reqVO.getEnterUnitMeasureId() != null) { |
| | | BigDecimal primaryQuantity = itemUnitConvertService.convertToPrimaryUnit( |
| | | reqVO.getItemId(), reqVO.getItemModelId(), |
| | | reqVO.getEnterUnitMeasureId(), reqVO.getEnterQuantity()); |
| | | if (primaryQuantity != null) { |
| | | reqVO.setQuantity(primaryQuantity); |
| | | } |
| | | } |
| | | if (reqVO.getQuantity() == null) { |
| | | throw exception(WM_PRODUCT_SALES_LINE_QUANTITY_REQUIRED); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据 batchCode 解析 batchId |
| | | */ |
| | | private void fillBatchId(MesWmProductSalesLineSaveReqVO reqVO) { |