| | |
| | | if (CollUtil.isEmpty(items)) { |
| | | return; |
| | | } |
| | | // 3. 计算入库状态 |
| | | // 3. 计算入库状态和总入库数量 |
| | | int inStatus = calculateInStatus(items); |
| | | // 4. 更新采购订单入库状态 |
| | | BigDecimal totalInCount = calculateTotalInCount(items); |
| | | // 4. 更新采购订单入库状态和入库数量 |
| | | purchaseOrderMapper.updateById(new ErpPurchaseOrderDO() |
| | | .setId(orderId).setInStatus(inStatus)); |
| | | .setId(orderId).setInStatus(inStatus).setInCount(totalInCount)); |
| | | |
| | | // 5. 回写采购申请明细的入库数量和采购申请的入库状态 |
| | | updatePurchaseRequestInStatus(items, inStatus); |
| | | } |
| | | |
| | | /** |
| | | * 计算总入库数量 |
| | | */ |
| | | private BigDecimal calculateTotalInCount(List<ErpPurchaseOrderItemDO> items) { |
| | | BigDecimal total = BigDecimal.ZERO; |
| | | for (ErpPurchaseOrderItemDO item : items) { |
| | | if (item.getInCount() != null) { |
| | | total = total.add(item.getInCount()); |
| | | } |
| | | } |
| | | return total; |
| | | } |
| | | |
| | | /** |
| | | * 回写采购申请入库数量和入库状态 |
| | | * |
| | | * @param orderItems 采购订单明细列表 |