maven
8 小时以前 5eec9b5a9d8bf9e49663d5a51cab7490fef5b204
main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java
@@ -173,7 +173,7 @@
        batchInsertInventories(masterId, dto.getProductionInventoryList());
        // 插入待入库数据
        insertPendingInventory(dto.getProductionList());
//        insertPendingInventory(dto.getProductionList());
        return 1;
    }
@@ -263,6 +263,7 @@
            BeanUtils.copyProperties(p, copy);
            copy.setId(null);
            copy.setProductionMasterId(masterId);
            copy.setStatus(1);
            productionMapper.insert(copy);
        }
    }
@@ -283,7 +284,7 @@
    /**
     * 将加工产生的产品记录到待入库表
     */
    private void insertPendingInventory(List<Production> list) {
    public void insertPendingInventory(List<Production> list) {
        LocalDate currentDate = LocalDate.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String formattedDate = currentDate.format(formatter);
@@ -402,20 +403,20 @@
        }
        // 批量更新官方库存
        for (Map.Entry<Long, BigDecimal> entry : inventoryAdjustMap.entrySet()) {
            OfficialInventory official = officialInventoryMapper.selectById(entry.getKey());
            if (official == null) {
                throw new BaseException("官方库存不存在,ID: " + entry.getKey());
            }
            // 使用线程安全的BigDecimal操作
            official.setInventoryQuantity(
                    Optional.ofNullable(official.getInventoryQuantity())
                            .orElse(BigDecimal.ZERO)
                            .add(entry.getValue())
            );
            officialInventoryMapper.updateById(official);
        }
//        for (Map.Entry<Long, BigDecimal> entry : inventoryAdjustMap.entrySet()) {
//            OfficialInventory official = officialInventoryMapper.selectById(entry.getKey());
//            if (official == null) {
//                throw new BaseException("官方库存不存在,ID: " + entry.getKey());
//            }
//
//            // 使用线程安全的BigDecimal操作
//            official.setInventoryQuantity(
//                    Optional.ofNullable(official.getInventoryQuantity())
//                            .orElse(BigDecimal.ZERO)
//                            .add(entry.getValue())
//            );
//            officialInventoryMapper.updateById(official);
//        }
        // 批量删除生产库存
        if (!productionIdsToDelete.isEmpty()) {