| | |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.test.context.bean.override.mockito.MockitoBean; |
| | | |
| | | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| | | import cn.iocoder.yudao.module.erp.api.sale.ErpSaleOrderApi; |
| | | import cn.iocoder.yudao.module.mes.service.mdm.MesMdmItemService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.oqc.MesQcOqcService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.batch.MesWmBatchService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.salesnotice.MesWmSalesNoticeLineService; |
| | | |
| | | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; |
| | | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; |
| | |
| | | private MesWmProductSalesDetailService productSalesDetailService; |
| | | |
| | | @MockitoBean |
| | | private MesMdItemService itemService; |
| | | private MesMdmItemService mdmItemService; |
| | | @MockitoBean |
| | | private MesWmBatchService batchService; |
| | | @MockitoBean |
| | | private MesWmSalesNoticeLineService salesNoticeLineService; |
| | | @MockitoBean |
| | | private MesQcOqcService oqcService; |
| | | @MockitoBean |
| | | private ErpSaleOrderApi saleOrderApi; |
| | | |
| | | @Test |
| | | public void testUpdateProductSalesLineWhenOqcFinish_pass() { |
| | |
| | | MesWmProductSalesLineDO updateLine = productSalesLineMapper.selectById(lineDO.getId()); |
| | | assertEquals(oqcId, updateLine.getOqcId()); |
| | | assertEquals(MesWmQualityStatusEnum.PASS.getStatus(), updateLine.getQualityStatus()); |
| | | // 断言:全部需检行合格 → 出库单自动流转待拣货 |
| | | verify(productSalesService).confirmProductSales(lineDO.getSalesId()); |
| | | } |
| | | |
| | | @Test |
| | | public void testUpdateProductSalesLineWhenOqcFinish_fail() { |
| | | // 准备参数 |
| | | // 准备参数:2 表示校验不通过 |
| | | Long oqcId = randomLongId(); |
| | | Integer checkResult = MesQcCheckResultEnum.QUALIFIED.getType(); |
| | | Integer checkResult = 2; |
| | | |
| | | // mock 数据 |
| | | MesWmProductSalesLineDO lineDO = randomPojo(MesWmProductSalesLineDO.class, o -> { |
| | |
| | | MesWmProductSalesLineDO updateLine = productSalesLineMapper.selectById(lineDO.getId()); |
| | | assertEquals(oqcId, updateLine.getOqcId()); |
| | | assertEquals(MesWmQualityStatusEnum.FAIL.getStatus(), updateLine.getQualityStatus()); |
| | | // 断言:存在不合格行时保持待检测,不自动取消整张出库单 |
| | | verify(productSalesService, never()).cancelProductSales(anyLong()); |
| | | verify(productSalesService, never()).confirmProductSales(anyLong()); |
| | | } |
| | | |
| | | @Test |
| | | public void testUpdateProductSalesLineWhenOqcFinish_cancelWhenNg() { |
| | | public void testUpdateProductSalesLineWhenOqcFinish_noCancelWhenNg() { |
| | | // 准备数据:同一出库单下 2 行,第 1 行已合格,第 2 行即将变更为不合格 |
| | | Long salesId = randomLongId(); |
| | | MesWmProductSalesLineDO line1 = randomPojo(MesWmProductSalesLineDO.class, o -> { |
| | |
| | | |
| | | // 调用:第 2 行质检不合格 |
| | | productSalesLineService.updateProductSalesLineWhenOqcFinish( |
| | | line2.getId(), randomLongId(), MesQcCheckResultEnum.QUALIFIED.getType()); |
| | | line2.getId(), randomLongId(), 2); |
| | | |
| | | // 断言:应该调用 cancelProductSales |
| | | verify(productSalesService).cancelProductSales(eq(salesId)); |
| | | // 断言:不合格行留待后续处置,不能自动取消出库单 |
| | | verify(productSalesService, never()).cancelProductSales(anyLong()); |
| | | verify(productSalesService, never()).confirmProductSales(anyLong()); |
| | | } |
| | | |
| | | @Test |
| | | public void testUpdateProductSalesLineWhenOqcFinish_noCancelWhenAllPass() { |
| | | public void testUpdateProductSalesLineWhenOqcFinish_confirmWhenAllPass() { |
| | | // 准备数据:同一出库单下 2 行,第 1 行已合格,第 2 行即将变更为合格 |
| | | Long salesId = randomLongId(); |
| | | MesWmProductSalesLineDO line1 = randomPojo(MesWmProductSalesLineDO.class, o -> { |
| | |
| | | productSalesLineService.updateProductSalesLineWhenOqcFinish( |
| | | line2.getId(), randomLongId(), MesQcCheckResultEnum.QUALIFIED.getType()); |
| | | |
| | | // 断言:不应该调用 cancelProductSales |
| | | // 断言:全部需检行合格 → 流转待拣货,不取消出库单 |
| | | verify(productSalesService).confirmProductSales(eq(salesId)); |
| | | verify(productSalesService, never()).cancelProductSales(anyLong()); |
| | | } |
| | | |
| | |
| | | }); |
| | | productSalesLineMapper.insert(line2); |
| | | |
| | | // 调用:第 2 行质检不合格 |
| | | // 调用:第 2 行质检合格 |
| | | productSalesLineService.updateProductSalesLineWhenOqcFinish( |
| | | line2.getId(), randomLongId(), MesQcCheckResultEnum.QUALIFIED.getType()); |
| | | |
| | | // 断言:第 2 行不合格 → 应该取消出库单 |
| | | verify(productSalesService).cancelProductSales(eq(salesId)); |
| | | // 断言:未勾选出货检验的行不参与待检判断 → 全部需检行合格后流转待拣货 |
| | | verify(productSalesService).confirmProductSales(eq(salesId)); |
| | | verify(productSalesService, never()).cancelProductSales(anyLong()); |
| | | } |
| | | |
| | | } |