| | |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.HackLoopTableRenderPolicy; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.procurementrecord.service.ProcurementRecordService; |
| | |
| | | @Override |
| | | public int submit(QualityInspect inspect) { |
| | | QualityInspect qualityInspect = qualityInspectMapper.selectById(inspect.getId()); |
| | | |
| | | //提交前必须判断是否合格 |
| | | if (ObjectUtils.isNull(qualityInspect.getCheckResult())) { |
| | | throw new RuntimeException("请先判断是否合格"); |
| | | throw new ServiceException("请先判断是否合格"); |
| | | } |
| | | |
| | | if (ObjectUtils.isNull(qualityInspect.getQualifiedQuantity())) { |
| | | throw new RuntimeException("合格数量不能为空"); |
| | | throw new ServiceException("合格数量不能为空"); |
| | | } |
| | | |
| | | if (ObjectUtils.isNull(qualityInspect.getUnqualifiedQuantity())) { |
| | | throw new RuntimeException("不合格数量不能为空"); |
| | | throw new ServiceException("不合格数量不能为空"); |
| | | } |
| | | |
| | | // 区分合格数量以及不合格处理进行对应的处理 |
| | | Assert.isTrue(qualityInspect.getQuantity().compareTo(qualityInspect.getQualifiedQuantity().add(qualityInspect.getUnqualifiedQuantity())) == 0,"请检查合格数量和不合格数量,需要合格数量+不合格数量与总数保持一致"); |
| | | // 如果合格数量为空,设为0 |
| | | if (qualityInspect.getQualifiedQuantity() == null) { |
| | | qualityInspect.setQualifiedQuantity(BigDecimal.ZERO); |
| | | } |
| | | |
| | | // 如果不合格数量为空,设为0 |
| | | if (qualityInspect.getUnqualifiedQuantity() == null) { |
| | | qualityInspect.setUnqualifiedQuantity(BigDecimal.ZERO); |
| | | } |
| | | |
| | | // 合格直接入库 |
| | | if(qualityInspect.getQualifiedQuantity().compareTo(BigDecimal.ZERO) > 0){ |
| | | //合格直接入库 |
| | | // stockUtils.addStock(qualityInspect.getProductModelId(), qualityInspect.getQuantity(), StockInQualifiedRecordTypeEnum.QUALITYINSPECT_STOCK_IN.getCode(), qualityInspect.getId()); |
| | | //仅添加入库记录 |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | //如果是采购质检合格入库选用CUSTOMIZATION_UNSTOCK_OUT,其余合格入库选用QUALITYINSPECT_STOCK_IN |
| | |
| | | qualityInspect.getProductModelId())); |
| | | stockInventoryService.addStockInRecordOnly(stockInventoryDto); |
| | | } |
| | | // 不合格处理 |
| | | if(qualityInspect.getUnqualifiedQuantity().compareTo(BigDecimal.ZERO) > 0){ |
| | | QualityUnqualified qualityUnqualified = new QualityUnqualified(); |
| | | BeanUtils.copyProperties(qualityInspect, qualityUnqualified); |