| | |
| | | qualityInspect.setProductModelId(saleProduct.getProductModelId()); |
| | | qualityInspect.setUnit(saleProduct.getUnit()); |
| | | qualityInspect.setQuantity(saleProduct.getQuantity()); |
| | | qualityInspect.setQualifiedQuantity(saleProduct.getQuantity()); |
| | | qualityInspect.setUnqualifiedQuantity(BigDecimal.ZERO); |
| | | qualityInspect.setPassRate(BigDecimal.valueOf(100).setScale(2, RoundingMode.HALF_UP)); |
| | | qualityInspectMapper.insert(qualityInspect); |
| | | List<QualityTestStandard> qualityTestStandard = qualityTestStandardMapper.getQualityTestStandardByProductId(saleProduct.getProductId(), 0, null); |
| | | if (qualityTestStandard.size() > 0) { |
| | |
| | | } |
| | | // 需要质检:扫码入库进入原材料检验,不直接入合格库存 |
| | | if (Boolean.TRUE.equals(dbProduct.getIsChecked())) { |
| | | // 存在未通过/未处理的原材料检验单,则禁止继续扫码入库 |
| | | // 存在未提交或入库审批中的原材料检验单,则禁止继续扫码入库 |
| | | Long pendingInspectCount = qualityInspectMapper.selectCount(new LambdaQueryWrapper<QualityInspect>() |
| | | .eq(QualityInspect::getInspectType, 0) |
| | | .eq(QualityInspect::getPurchaseLedgerId, purchaseId) |
| | |
| | | .and(w -> w |
| | | .isNull(QualityInspect::getInspectState) |
| | | .or(q0 -> q0.eq(QualityInspect::getInspectState, 0)) |
| | | // inspect_state=1 也视为“未处理” |
| | | .or(q1 -> q1.eq(QualityInspect::getInspectState, 1) |
| | | .isNull(QualityInspect::getCheckResult)))); |
| | | .in(QualityInspect::getApprovalStatus, 1, 2)))); |
| | | if (pendingInspectCount != null && pendingInspectCount > 0) { |
| | | throw new ServiceException("入库失败,存在未通过或未处理的质检记录,请先处理后再扫码入库"); |
| | | } |
| | |
| | | .or(q1 -> q1.eq(QualityInspect::getInspectState, 1) |
| | | .and(r -> r.isNull(QualityInspect::getCheckResult) |
| | | .or() |
| | | .eq(QualityInspect::getCheckResult, "合格"))))) |
| | | .eq(QualityInspect::getCheckResult, "合格") |
| | | .or() |
| | | .eq(QualityInspect::getCheckResult, "部分合格"))))) |
| | | .stream() |
| | | .map(QualityInspect::getQuantity) |
| | | .map(this::resolveInspectCountedQuantity) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if (inspectQty.add(inboundThisLine).compareTo(orderQty) > 0) { |
| | |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | private BigDecimal resolveInspectCountedQuantity(QualityInspect inspect) { |
| | | if (inspect == null) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | if (inspect.getInspectState() == null || inspect.getInspectState() == 0) { |
| | | return inspect.getQuantity() == null ? BigDecimal.ZERO : inspect.getQuantity(); |
| | | } |
| | | if (inspect.getQualifiedQuantity() != null) { |
| | | return inspect.getQualifiedQuantity(); |
| | | } |
| | | if ("合格".equals(inspect.getCheckResult()) || "部分合格".equals(inspect.getCheckResult())) { |
| | | return inspect.getQuantity() == null ? BigDecimal.ZERO : inspect.getQuantity(); |
| | | } |
| | | return BigDecimal.ZERO; |
| | | } |
| | | } |