| | |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateItemDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceLineDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.qc.ipqc.MesQcIpqcMapper; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.pro.feedback.MesProFeedbackMapper; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.wm.productproduce.MesWmProductProduceLineMapper; |
| | | import cn.iocoder.yudao.module.mes.service.qc.ncr.MesQcNcrService; |
| | | import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants; |
| | | import cn.iocoder.yudao.module.mes.enums.qc.MesQcStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum; |
| | |
| | | private MesQcIndicatorResultService indicatorResultService; |
| | | @MockitoBean |
| | | private MesWmProductProduceLineService productProduceLineService; |
| | | @MockitoBean |
| | | private MesWmProductProduceLineMapper produceLineMapper; |
| | | @MockitoBean |
| | | private MesProFeedbackMapper feedbackMapper; |
| | | @MockitoBean |
| | | private MesQcNcrService ncrService; |
| | | |
| | | @Test |
| | | public void testFinishIpqc_writeBack_feedback() { |
| | |
| | | o.setSourceLineId(sourceLineId); |
| | | o.setQualifiedQuantity(qualifiedQty); |
| | | o.setUnqualifiedQuantity(unqualifiedQty); |
| | | o.setCheckQuantity(qualifiedQty.add(unqualifiedQty)); |
| | | o.setLaborScrapQuantity(laborScrapQty); |
| | | o.setMaterialScrapQuantity(materialScrapQty); |
| | | o.setOtherScrapQuantity(otherScrapQty); |
| | | }); |
| | | ipqcMapper.insert(ipqc); |
| | | |
| | | when(feedbackMapper.selectOne(any(com.baomidou.mybatisplus.core.conditions.Wrapper.class))).thenReturn(new MesProFeedbackDO()); |
| | | when(produceLineMapper.selectByIdForUpdate(sourceLineId)).thenReturn(MesWmProductProduceLineDO.builder() |
| | | .feedbackId(sourceDocId).qualityStatus(MesWmQualityStatusEnum.PENDING.getStatus()) |
| | | .quantity(BigDecimal.valueOf(100)).build()); |
| | | |
| | | // 调用 |
| | | ipqcService.finishIpqc(ipqc.getId()); |
| | |
| | | }); |
| | | ipqcMapper.insert(ipqc); |
| | | |
| | | // 调用 |
| | | ipqcService.finishIpqc(ipqc.getId()); |
| | | |
| | | // 断言:所有数量参数都是 BigDecimal.ZERO(defaultIfNull 处理) |
| | | verify(feedbackService).updateProFeedbackWhenIpqcFinish( |
| | | eq(sourceDocId), |
| | | eq(sourceLineId), |
| | | eq(BigDecimal.ZERO), |
| | | eq(BigDecimal.ZERO), |
| | | eq(BigDecimal.ZERO), |
| | | eq(BigDecimal.ZERO), |
| | | eq(BigDecimal.ZERO)); |
| | | when(feedbackMapper.selectOne(any(com.baomidou.mybatisplus.core.conditions.Wrapper.class))).thenReturn(new MesProFeedbackDO()); |
| | | assertEquals(QC_IPQC_QUANTITY_INVALID.getCode(), |
| | | assertThrows(ServiceException.class, () -> ipqcService.finishIpqc(ipqc.getId())).getCode()); |
| | | } |
| | | |
| | | @Test |
| | |
| | | o.setSourceDocType(null); |
| | | o.setSourceDocId(null); |
| | | o.setSourceLineId(null); |
| | | o.setCheckQuantity(BigDecimal.ONE); |
| | | o.setQualifiedQuantity(BigDecimal.ONE); |
| | | o.setUnqualifiedQuantity(BigDecimal.ZERO); |
| | | o.setLaborScrapQuantity(BigDecimal.ZERO); |
| | | o.setMaterialScrapQuantity(BigDecimal.ZERO); |
| | | o.setOtherScrapQuantity(BigDecimal.ZERO); |
| | | }); |
| | | ipqcMapper.insert(ipqc); |
| | | |
| | |
| | | ipqcMapper.insert(ipqc); |
| | | |
| | | // 调用,并断言异常 |
| | | assertThrows(IllegalArgumentException.class, () -> ipqcService.finishIpqc(ipqc.getId())); |
| | | assertThrows(ServiceException.class, () -> ipqcService.finishIpqc(ipqc.getId())); |
| | | } |
| | | |
| | | @Test |
| | |
| | | ipqcMapper.insert(ipqc); |
| | | |
| | | // 调用,并断言异常 |
| | | assertThrows(IllegalArgumentException.class, () -> ipqcService.finishIpqc(ipqc.getId())); |
| | | assertThrows(ServiceException.class, () -> ipqcService.finishIpqc(ipqc.getId())); |
| | | } |
| | | |
| | | @Test |
| | |
| | | |
| | | // 调用,断言异常 |
| | | ServiceException ex = assertThrows(ServiceException.class, () -> ipqcService.createIpqc(reqVO)); |
| | | assertEquals(QC_IPQC_SOURCE_LINE_REQUIRED.getCode(), ex.getCode()); |
| | | assertEquals(QC_IPQC_SOURCE_INCOMPLETE.getCode(), ex.getCode()); |
| | | } |
| | | |
| | | /** |
| | |
| | | line.setId(sourceLineId); |
| | | line.setFeedbackId(randomLongId()); // 不同的 feedbackId |
| | | line.setQualityStatus(MesWmQualityStatusEnum.PENDING.getStatus()); |
| | | when(productProduceLineService.validateProductProduceLineExists(sourceLineId)).thenReturn(line); |
| | | when(feedbackMapper.selectOne(any(com.baomidou.mybatisplus.core.conditions.Wrapper.class))).thenReturn(new MesProFeedbackDO()); |
| | | when(produceLineMapper.selectByIdForUpdate(sourceLineId)).thenReturn(line); |
| | | |
| | | // 调用,断言异常 |
| | | ServiceException ex = assertThrows(ServiceException.class, () -> ipqcService.createIpqc(reqVO)); |
| | |
| | | line.setId(sourceLineId); |
| | | line.setFeedbackId(feedbackId); |
| | | line.setQualityStatus(MesWmQualityStatusEnum.PASS.getStatus()); // 已合格,非待检 |
| | | when(productProduceLineService.validateProductProduceLineExists(sourceLineId)).thenReturn(line); |
| | | when(feedbackMapper.selectOne(any(com.baomidou.mybatisplus.core.conditions.Wrapper.class))).thenReturn(new MesProFeedbackDO()); |
| | | when(produceLineMapper.selectByIdForUpdate(sourceLineId)).thenReturn(line); |
| | | |
| | | // 调用,断言异常 |
| | | ServiceException ex = assertThrows(ServiceException.class, () -> ipqcService.createIpqc(reqVO)); |
| | |
| | | MesProFeedbackDO feedback = new MesProFeedbackDO(); |
| | | feedback.setId(feedbackId); |
| | | feedback.setCode("FB-001"); |
| | | feedback.setWorkOrderId(workOrderId); |
| | | feedback.setItemId(productId); |
| | | when(feedbackService.validateFeedbackExists(feedbackId)).thenReturn(feedback); |
| | | when(feedbackMapper.selectOne(any(com.baomidou.mybatisplus.core.conditions.Wrapper.class))).thenReturn(feedback); |
| | | // mock:产出行存在、归属正确、PENDING 状态 |
| | | MesWmProductProduceLineDO line = new MesWmProductProduceLineDO(); |
| | | line.setId(sourceLineId); |
| | | line.setFeedbackId(feedbackId); |
| | | line.setItemId(productId); |
| | | line.setQualityStatus(MesWmQualityStatusEnum.PENDING.getStatus()); |
| | | when(productProduceLineService.validateProductProduceLineExists(sourceLineId)).thenReturn(line); |
| | | when(produceLineMapper.selectByIdForUpdate(sourceLineId)).thenReturn(line); |
| | | |
| | | // 调用 |
| | | Long ipqcId = ipqcService.createIpqc(reqVO); |