| | |
| | | receipt.setStatus(MesWmItemReceiptStatusEnum.PREPARE.getStatus()); |
| | | itemReceiptMapper.insert(receipt); |
| | | |
| | | // 6. 遍历行创建入库单行 |
| | | // 6. 遍历行创建入库单行:需检行只入质检合格数量,无需检行入到货数量 |
| | | int createdLineCount = 0; |
| | | for (MesWmArrivalNoticeLineDO noticeLine : lines) { |
| | | BigDecimal receivable = noticeLine.getQualifiedQuantity() != null |
| | | BigDecimal receivable = Boolean.TRUE.equals(noticeLine.getIqcCheckFlag()) |
| | | ? noticeLine.getQualifiedQuantity() : noticeLine.getArrivalQuantity(); |
| | | // 整行已退供应商时不生成零数量入库行;其余行仍正常收货。 |
| | | // 整行不合格(合格数量为 0)或无需检行未填写到货数量时,不生成零数量入库行 |
| | | if (receivable == null || receivable.signum() <= 0) { |
| | | continue; |
| | | } |
| | |
| | | receiptLine.setArrivalNoticeLineId(noticeLine.getId()); |
| | | receiptLine.setPurchaseOrderItemId(noticeLine.getPurchaseOrderItemId()); |
| | | receiptLine.setItemId(noticeLine.getItemId()); |
| | | // 使用合格数量(如果有 IQC 则是合格数量,否则是到货数量) |
| | | receiptLine.setReceivedQuantity(receivable); |
| | | // 按采购订单行单价快照金额,供来票/对账使用 |
| | | fillReceiptLinePrice(receiptLine); |
| | | itemReceiptLineService.createItemReceiptLineFromArrivalNoticeLine(receiptLine); |
| | | createdLineCount++; |
| | | } |
| | | if (createdLineCount == 0) { |
| | | throw new ServiceException(WM_ARRIVAL_NOTICE_NO_QUALIFIED_LINE.getCode(), |
| | | "到货通知单[" + notice.getCode() + "]没有可入库的合格数量:所有需检行的质检合格数量均为 0 或为空。" |
| | | + "请先完成不合格品的处置(退货或让步接收),处置完成后再生成入库单。"); |
| | | } |
| | | |
| | | return receipt.getId(); |