| | |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales.MesWmProductSalesLineMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.qc.MesQcCheckResultEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| | | import cn.iocoder.yudao.module.mes.service.mdm.MesMdmItemService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.batch.MesWmBatchService; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.batch.MesWmBatchDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeLineDO; |
| | |
| | | /** |
| | | * MES 销售出库单行 Service 实现类 |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Service |
| | | @Validated |
| | |
| | | @Resource |
| | | private MesWmProductSalesDetailService productSalesDetailService; |
| | | @Resource |
| | | private MesMdItemService itemService; |
| | | private MesMdmItemService mdmItemService; |
| | | @Resource |
| | | private MesWmBatchService batchService; |
| | | @Resource |
| | |
| | | // 校验主单存在且为草稿状态 |
| | | MesWmProductSalesDO sales = productSalesService.validateProductSalesExistsAndDraft(reqVO.getSalesId()); |
| | | // 校验物料存在 |
| | | itemService.validateItemExistsAndEnable(reqVO.getItemId()); |
| | | mdmItemService.validateItemExistsAndEnable(reqVO.getItemId()); |
| | | // 校验关联发货通知单行(存在性 + 归属 + 字段一致性) |
| | | validateSalesNoticeLine(sales, reqVO); |
| | | // 根据 batchCode 解析 batchId |
| | |
| | | } |
| | | MesWmSalesNoticeLineDO noticeLine = salesNoticeLineService.validateSalesNoticeLineExists( |
| | | noticeLineId, sales.getNoticeId()); |
| | | // 校验关键字段一致性:物料、数量、批次号、OQC 检验标识 |
| | | // 校验关键字段一致性:物料、数量、批次号 |
| | | // 注:OQC 检验标识允许在出库时独立设置,不强制与通知单一致 |
| | | if (ObjUtil.notEqual(reqVO.getItemId(), noticeLine.getItemId())) { |
| | | throw exception(WM_PRODUCT_SALES_LINE_NOTICE_LINE_ITEM_MISMATCH); |
| | | } |
| | |
| | | if (StrUtil.isNotBlank(noticeLine.getBatchCode()) |
| | | && ObjUtil.notEqual(reqVO.getBatchCode(), noticeLine.getBatchCode())) { |
| | | throw exception(WM_PRODUCT_SALES_LINE_NOTICE_LINE_BATCH_MISMATCH); |
| | | } |
| | | if (noticeLine.getOqcCheckFlag() != null |
| | | && ObjUtil.notEqual(reqVO.getOqcCheckFlag(), noticeLine.getOqcCheckFlag())) { |
| | | throw exception(WM_PRODUCT_SALES_LINE_NOTICE_LINE_OQC_MISMATCH); |
| | | } |
| | | return; |
| | | } |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateProductSalesLineWhenOqcFinish(Long id, Long oqcId, Integer checkResult) { |
| | | // 1. 更新行的 oqcId + qualityStatus |
| | | Integer qualityStatus = Objects.equals(checkResult, MesQcCheckResultEnum.PASS.getType()) |
| | | Integer qualityStatus = Objects.equals(checkResult, MesQcCheckResultEnum.QUALIFIED.getType()) |
| | | ? MesWmQualityStatusEnum.PASS.getStatus() : MesWmQualityStatusEnum.FAIL.getStatus(); |
| | | productSalesLineMapper.updateById(new MesWmProductSalesLineDO() |
| | | .setId(id).setOqcId(oqcId).setQualityStatus(qualityStatus)); |