liyong
3 天以前 f8ac65dfe03e7ff64fecb26c58674b7f3ba5e1d8
fix(production): 修复生产产品数量更新逻辑
已修改1个文件
27 ■■■■■ 文件已修改
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -87,34 +87,7 @@
        SysUser user = SecurityUtils.getLoginUser().getUser();
        if (dto.isReportWork()) {
            // 更新逻辑 - 只更新数量
            QueryWrapper<ProductionProductOutput> outputWrapper = new QueryWrapper<>();
            outputWrapper.eq("product_main_id", dto.getProductMainId());
            ProductionProductOutput output = productionProductOutputMapper.selectOne(outputWrapper);
            if (output == null) {
                throw new RuntimeException("产出记录不存在");
            }
            // 查询生产核算记录
            QueryWrapper<SalesLedgerProductionAccounting> accountingWrapper = new QueryWrapper<>();
            accountingWrapper.eq("sales_ledger_work_id", dto.getProductMainId());
            SalesLedgerProductionAccounting accounting = salesLedgerProductionAccountingMapper.selectOne(accountingWrapper);
            if (accounting == null) {
                throw new RuntimeException("生产核算记录不存在");
            }
            // 只更新数量
            if (dto.getQuantity() != null) {
                output.setQuantity(output.getQuantity().add(dto.getQuantity()));
                productionProductOutputMapper.updateById(output);
                // 更新生产核算记录
                accounting.setFinishedNum(accounting.getFinishedNum().add(dto.getQuantity()));
                salesLedgerProductionAccountingMapper.updateById(accounting);
            }
            return true;
        }
        // 新增逻辑
        ProductionProductMain productionProductMain = new ProductionProductMain();