| | |
| | | if (!bindList.isEmpty()) { |
| | | List<Integer> processIds = bindList.stream().map(SalesLedgerProductProcessBind::getSalesLedgerProductProcessId).collect(Collectors.toList()); |
| | | Map<Integer, Integer> processQuantityMap = bindList.stream().collect(Collectors.toMap(SalesLedgerProductProcessBind::getSalesLedgerProductProcessId, SalesLedgerProductProcessBind::getQuantity, (a, b) -> a)); |
| | | Map<Integer, BigDecimal> processAmountMap = bindList.stream().collect(Collectors.toMap(SalesLedgerProductProcessBind::getSalesLedgerProductProcessId, SalesLedgerProductProcessBind::getAmount, (a, b) -> a)); |
| | | List<SalesLedgerProductProcess> processList = salesLedgerProductProcessService.listByIds(processIds); |
| | | processList.forEach(p -> p.setQuantity(processQuantityMap.get(p.getId()))); |
| | | processList.forEach(p -> { |
| | | p.setQuantity(processQuantityMap.get(p.getId())); |
| | | if (processAmountMap.get(p.getId()) != null) p.setUnitPrice(processAmountMap.get(p.getId())); |
| | | }); |
| | | product.setSalesProductProcessList(processList); |
| | | } |
| | | ProductModel productModel = productModelMap.get(product.getProductModelId()); |
| | |
| | | SalesLedgerProductProcess p = new SalesLedgerProductProcess(); |
| | | p.setId(process.getId()); |
| | | p.setQuantity(processQty.intValue()); |
| | | p.setUnitPrice(process.getUnitPrice()); |
| | | processList.add(p); |
| | | extraProcessAmountPerPiece = extraProcessAmountPerPiece.add(defaultDecimal(process.getUnitPrice()).multiply(processQty)); |
| | | } |
| | |
| | | BigDecimal stockedQty = item.getStockedQuantity() == null ? BigDecimal.ZERO : item.getStockedQuantity(); |
| | | return orderQty.compareTo(BigDecimal.ZERO) <= 0 || stockedQty.compareTo(orderQty) >= 0; |
| | | }); |
| | | int newStockStatus = allStocked ? 2 : (hasStocked ? 1 : 0); |
| | | if (newStockStatus > 0 && ledger.getDeliveryDate() == null) { |
| | | ledger.setDeliveryDate(LocalDate.now().plusDays(7)); |
| | | } |
| | | ledger.setStockStatus(newStockStatus); |
| | | ledger.setStockStatus(allStocked ? 2 : (hasStocked ? 1 : 0)); |
| | | baseMapper.updateById(ledger); |
| | | } |
| | | |
| | |
| | | return sq != null && sq.compareTo(BigDecimal.ZERO) > 0; |
| | | }); |
| | | boolean allLinesFull = ledgerAllProducts.stream().allMatch(p -> Objects.equals(p.getProductStockStatus(), 2)); |
| | | int newStockStatus = allLinesFull ? 2 : (anyInbound ? 1 : 0); |
| | | if (newStockStatus > 0 && salesLedger.getDeliveryDate() == null) { |
| | | salesLedger.setDeliveryDate(LocalDate.now().plusDays(7)); |
| | | } |
| | | salesLedger.setStockStatus(newStockStatus); |
| | | salesLedger.setStockStatus(allLinesFull ? 2 : (anyInbound ? 1 : 0)); |
| | | baseMapper.updateById(salesLedger); |
| | | } |
| | | |
| | |
| | | SalesLedgerProductProcess bind = new SalesLedgerProductProcess(); |
| | | bind.setId(process.getId()); |
| | | bind.setQuantity(entry.getValue()); |
| | | bind.setUnitPrice(process.getUnitPrice()); |
| | | result.add(bind); |
| | | } |
| | | return result; |
| | |
| | | // 5. 取消审批流程 |
| | | cancelApproveProcesses(id, originalLedger.getSalesContractNo()); |
| | | |
| | | // 6. 重新生成:创建新台账副本 |
| | | // 6. 重新生成:此处不直接在后端入库,而是返回原单据ID给前端 |
| | | // 前端拿到ID后会获取原单据详情并跳转到新增页面(带入预填数据),由用户在页面上编辑后统一新增,以避免数据重复生成 |
| | | if (dto.getCounterReviewType() == 2) { |
| | | SalesLedger newLedger = new SalesLedger(); |
| | | BeanUtils.copyProperties(originalLedger, newLedger); |
| | | newLedger.setId(null); |
| | | newLedger.setSalesContractNo(generateSalesContractNo()); |
| | | newLedger.setDeliveryStatus(1); |
| | | newLedger.setStockStatus(0); |
| | | newLedger.setReviewStatus(0); |
| | | newLedger.setCounterReviewTime(null); |
| | | newLedger.setCounterReviewPerson(null); |
| | | newLedger.setCounterReviewPersonId(null); |
| | | newLedger.setCounterReviewType(null); |
| | | newLedger.setCounterReviewDesc(null); |
| | | salesLedgerMapper.insert(newLedger); |
| | | |
| | | // 复制产品到新台账 |
| | | List<SalesLedgerProduct> originalProducts = salesLedgerProductMapper.selectList( |
| | | Wrappers.<SalesLedgerProduct>lambdaQuery() |
| | | .eq(SalesLedgerProduct::getSalesLedgerId, id) |
| | | ); |
| | | for (SalesLedgerProduct originalProduct : originalProducts) { |
| | | SalesLedgerProduct newProduct = new SalesLedgerProduct(); |
| | | BeanUtils.copyProperties(originalProduct, newProduct); |
| | | newProduct.setId(null); |
| | | newProduct.setSalesLedgerId(newLedger.getId()); |
| | | newProduct.setStockedQuantity(BigDecimal.ZERO); |
| | | newProduct.setShippedQuantity(BigDecimal.ZERO); |
| | | newProduct.setUnqualifiedStockedQuantity(BigDecimal.ZERO); |
| | | newProduct.setUnqualifiedShippedQuantity(BigDecimal.ZERO); |
| | | newProduct.setReturnQuality(BigDecimal.ZERO); |
| | | newProduct.setAvailableQuality(newProduct.getQuantity().subtract(newProduct.getReturnQuality())); |
| | | newProduct.setProductStockStatus(0); |
| | | newProduct.fillRemainingQuantity(); |
| | | salesLedgerProductMapper.insert(newProduct); |
| | | } |
| | | newLedgerIds.add(newLedger.getId()); |
| | | newLedgerIds.add(id); |
| | | } |
| | | } |
| | | return newLedgerIds; |
| | |
| | | } |
| | | |
| | | } |
| | | |