| | |
| | | import cn.iocoder.yudao.module.mes.service.wm.productissue.MesWmProductIssueLineService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.productissue.MesWmProductIssueService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.returnissue.MesWmReturnIssueLineService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.unitconvert.MesWmItemUnitConvertService; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private MesWmProductIssueDetailService issueDetailService; |
| | | @Resource |
| | | private MesProWorkOrderBomService workOrderBomService; |
| | | @Resource |
| | | private MesWmItemUnitConvertService itemUnitConvertService; |
| | | |
| | | @Override |
| | | public Long createProductIssueLine(MesWmProductIssueLineSaveReqVO createReqVO) { |
| | | validateProductIssueLineSaveData(createReqVO); |
| | | // 双单位换算:按录入单位换算为物料主单位数量 |
| | | fillPrimaryQuantity(createReqVO); |
| | | |
| | | // 插入 |
| | | MesWmProductIssueLineDO line = BeanUtils.toBean(createReqVO, MesWmProductIssueLineDO.class); |
| | |
| | | // 校验存在 |
| | | validateProductIssueLineExists(updateReqVO.getId()); |
| | | validateProductIssueLineSaveData(updateReqVO); |
| | | // 双单位换算:按录入单位换算为物料主单位数量 |
| | | fillPrimaryQuantity(updateReqVO); |
| | | |
| | | // 更新 |
| | | MesWmProductIssueLineDO updateObj = BeanUtils.toBean(updateReqVO, MesWmProductIssueLineDO.class); |
| | | issueLineMapper.updateById(updateObj); |
| | | } |
| | | |
| | | /** |
| | | * 双单位换算:选择了录入单位时,按「录入数量 × 换算比率」得到物料主单位口径的领料数量 |
| | | * |
| | | * 未按辅单位录入时必须直接填写领料数量 |
| | | */ |
| | | private void fillPrimaryQuantity(MesWmProductIssueLineSaveReqVO 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_ISSUE_LINE_QUANTITY_REQUIRED); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deleteProductIssueLine(Long id) { |
| | | // 校验存在 |