| | |
| | | |
| | | 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(); |