| | |
| | | import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants; |
| | | import cn.iocoder.yudao.module.mes.enums.qc.MesQcStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.MesQcCompletionHelper; |
| | | import cn.iocoder.yudao.module.mes.service.qc.defectrecord.MesQcDefectRecordService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateItemService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesLineService; |
| | |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicatorresult.MesQcIndicatorResultService; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import jakarta.annotation.Resource; |
| | | import org.junit.jupiter.api.BeforeEach; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.context.annotation.Import; |
| | | import org.springframework.test.context.bean.override.mockito.MockitoBean; |
| | |
| | | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| | | import static org.junit.jupiter.api.Assertions.*; |
| | | import static org.mockito.ArgumentMatchers.eq; |
| | | import static org.mockito.ArgumentMatchers.*; |
| | | import static org.mockito.Mockito.*; |
| | | |
| | | /** |
| | |
| | | private AdminUserApi adminUserApi; |
| | | @MockitoBean |
| | | private MesQcIndicatorResultService indicatorResultService; |
| | | @MockitoBean |
| | | private MesQcCompletionHelper completionHelper; |
| | | |
| | | @BeforeEach |
| | | void stubCompletionHelper() { |
| | | when(completionHelper.validateAndGetResult(anyString(), anyLong(), any(), any(), any())).thenReturn(1); |
| | | } |
| | | |
| | | @Test |
| | | public void testFinishOqc_writeBack_productSales() { |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void testFinishOqc_checkResultEmpty() { |
| | | // 准备数据:checkResult 为空,应该报错 |
| | | public void testFinishOqc_checkResultAutoComputed() { |
| | | // 准备数据:检测结论不再由用户填写,完成时按合格/不合格数量自动判定 |
| | | MesQcOqcDO oqc = randomPojo(MesQcOqcDO.class, o -> { |
| | | o.setStatus(MesQcStatusEnum.DRAFT.getStatus()); |
| | | o.setCheckResult(null); // 检测结论为空 |
| | | o.setCheckResult(null); |
| | | o.setSourceDocType(null); |
| | | o.setCheckQuantity(java.math.BigDecimal.valueOf(100)); |
| | | o.setQualifiedQuantity(java.math.BigDecimal.valueOf(100)); |
| | | o.setUnqualifiedQuantity(java.math.BigDecimal.ZERO); |
| | | }); |
| | | oqcMapper.insert(oqc); |
| | | |
| | | // 调用,应该抛异常(检测结论必填) |
| | | assertServiceException(() -> oqcService.finishOqc(oqc.getId()), QC_OQC_CHECK_RESULT_EMPTY); |
| | | // 调用 |
| | | oqcService.finishOqc(oqc.getId()); |
| | | |
| | | // 断言:检测结论由系统判定并回写 |
| | | MesQcOqcDO updatedOqc = oqcMapper.selectById(oqc.getId()); |
| | | assertEquals(MesQcStatusEnum.FINISHED.getStatus(), updatedOqc.getStatus()); |
| | | assertEquals(1, updatedOqc.getCheckResult()); |
| | | } |
| | | |
| | | @Test |